diff --git a/tools/vio2sf/OUTPUT/dist.bat b/tools/vio2sf/OUTPUT/dist.bat deleted file mode 100644 index dfccbc39a..000000000 --- a/tools/vio2sf/OUTPUT/dist.bat +++ /dev/null @@ -1,7 +0,0 @@ -copy /y winamp2\plugins\vio2sf.bin ~dist -copy /y winamp2\plugins\in_vio2sf.dll ~dist -copy /y winamp5\plugins\in_vio2sfu.dll ~dist -copy /y fb8\foo_8_vio2sf.dll ~dist -copy /y fb9\components\foo_input_vio2sf.dll ~dist -copy /y kbmed\plugins\vio2sf.kpi ~dist -upx -9 ~dist/* \ No newline at end of file diff --git a/tools/vio2sf/OUTPUT/readme.txt b/tools/vio2sf/OUTPUT/readme.txt deleted file mode 100644 index 1ff983962..000000000 --- a/tools/vio2sf/OUTPUT/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -drop directories in here for testing: (projects are configured to put plugins in here) -winamp2 -winamp5 -kbmed -fb8 -fb9 - -tips: -run winamp /NEW myfile.mini2sf to test builds \ No newline at end of file diff --git a/tools/vio2sf/OUTPUT/upx.exe b/tools/vio2sf/OUTPUT/upx.exe deleted file mode 100644 index 2afa5610e..000000000 Binary files a/tools/vio2sf/OUTPUT/upx.exe and /dev/null differ diff --git a/tools/vio2sf/OUTPUT/~dist/vio2sf.txt b/tools/vio2sf/OUTPUT/~dist/vio2sf.txt deleted file mode 100644 index 529f52f3a..000000000 --- a/tools/vio2sf/OUTPUT/~dist/vio2sf.txt +++ /dev/null @@ -1,130 +0,0 @@ -2SF plugins / DeSmuMe -This build is from the DeSmuMe SVN repository - -foo_8_vio2sf.dll + vio2sf.bin(put into same directory) - foobar2000 v0.8.x plugin - -foo_input_vio2sf.dll + vio2sf.bin(put into same directory) - foobar2000 v0.9.x plugin - -in_vio2sf.dll + vio2sf.bin(put into same directory) - Winamp 2.x plugin - Missing feature:reading-from-archive unicode-filename(by-spec) - -in_vio2sfu.dll + vio2sf.bin(put into same directory) - Winamp 5.x unicode plugin - Missing feature:reading-from-archive - -vio2sf.kpi + vio2sf.bin(put into same directory) - KbMedia Player plugin - Missing feature:replaygain(by-spec) tag-writing(by-spec) unicode-filename(by-spec) libs-in-archive-with-sub-directory(by-spec) - -History -------- - -0.23 (2010/01/19) - Import desmume 0.9.4 generation SPU - - fix bugs in ADPCM looping and PSG channels - Add interpolation options (none,linear,cosine) - -0.22 (2009/10/16) - Fixed: Failed to load libs by relative path. - Fixed: Failed to read '_libN' tags. - -0.21 (2009/09/30) - Fixed: Bufffer for several dsp plugins needed double space. - -0.20 (2009/07/22) - Fixed: Skipped loading 2sflib described in '_lib2' tag without '_lib' tag. - -0.19 (2009/03/13) - Removed: Experimental tag('_vio2sf_loader_type'). - Ignored: Inconsistency with priority of superimposing. - -0.18 (2009/03/10) - Added: Experimental tag('_vio2sf_loader_type'). - -0.17 (2009/03/07) - Fixed:Obsolete config dialog for Winamp 2.x was not able to be displayed. - -0.16 (2009/03/06) - Fixed:Skipped silent songs although these had length information. - -0.15 (2009/03/05) - Fixed:ROM address mask was set to invalid value when 2sf had only single memory block. - -0.14 (2008/04/30) - DeSmuMe 0.8.0 - -0.13 (2008/03/05) - Added:Plugin for foobar v0.8.x - Fixed:Informed blank title last played to Winamp. - -0.12 (2008/03/04) - Fixed:Loaded libs in nonstandard order. - Clean up common code. - -0.11 (2008/02/11) - Added:'_clockdown' tag support. - Fixed:ARM coprocessor work memory is leaked. - -0.10 (2008/02/04) - Fixed:Played with inaccurate pitch and timer speed. - Added:'_frame' tag support. - Added: Experimental tags('_vio2sf_sync_type','_vio2sf_arm9_clockdown_level','_vio2sf_arm7_clockdown_level'). - _vio2sf_sync_type=0(hsync:default),1(vsync:fast but inaccurate) - _vio2sf_arm9_clockdown_level=0(default),1(Clock of ARM9 down to 1/2),2(Clock of ARM9 down to 1/4),3(Clock of ARM9 down to 1/8) - _vio2sf_arm7_clockdown_level=0(default),1(Clock of ARM7 down to 1/2),2(Clock of ARM7 down to 1/4),3(Clock of ARM7 down to 1/8) - -0.09 (2008/02/03) - Fixed:Crashed with memory access violation over rom length. - -0.08 (2008/02/02) - Fixed:No samples clipped after mixing. - Fixed:Wasted CPU cycles by looping ADPCM. - -0.07 (2008/02/01) - SPU emulation based on DeSmuME v0.7.3wp1 mdn. - -0.06 / 0.05 / 0.04 (2008/02/01) - Fixed:Invaid initial state of ARM9. - -0.03 (2008/01/30) - Removed:Needless cpu emulation on loading process. - -0.02 (2008/01/29) - Fixed:Erased system tags('_lib') by tag writer in Winamp. - Fixed:Uncompressed buffers are leaked on loading process. - - -0.01 (2008/01/28) - First release. - -License -------- - -[DeSmuMe](GPL) - DeSmuME - _________________________________________ - Copyright (C) 2006 yopyop - Copyright (C) 2006-2007 DeSmuME team - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - -Please refer to src.7z/src/vio2sf/desmume/COPYING. - -[zlib](ZLIBL) -'zlib' general purpose compression library version 1.2.3, July 18th, 2005 - -Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - -Please refer to src.7z/src/vio2sf/zlib/zlib.h - -[loadpe](LGPL) -libloadpe -Copyright (C)2007 Ku-Zu - -Please refer to src.7z/src/loadpe/COPYING.LIB for redistributing. diff --git a/tools/vio2sf/foo_input_vio2sf.vcproj b/tools/vio2sf/foo_input_vio2sf.vcproj deleted file mode 100644 index 28a04116e..000000000 --- a/tools/vio2sf/foo_input_vio2sf.vcproj +++ /dev/null @@ -1,258 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/foo_xsf8.dsp b/tools/vio2sf/foo_xsf8.dsp deleted file mode 100644 index ef9d0e061..000000000 --- a/tools/vio2sf/foo_xsf8.dsp +++ /dev/null @@ -1,151 +0,0 @@ -# Microsoft Developer Studio Project File - Name="foo_xsf8" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=foo_xsf8 - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "foo_xsf8.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "foo_xsf8.mak" CFG="foo_xsf8 - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "foo_xsf8 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "foo_xsf8 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "foo_xsf8 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "foo_xsf8___Win32_Release" -# PROP BASE Intermediate_Dir "foo_xsf8___Win32_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "foo_xsf8___Win32_Release" -# PROP Intermediate_Dir "foo_xsf8___Win32_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /I "src/foobar8" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "NDEBUG" -# ADD RSC /l 0x411 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"OUTPUT\fb8\foo_8_vio2sf.dll" - -!ELSEIF "$(CFG)" == "foo_xsf8 - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "foo_xsf8___Win32_Debug" -# PROP BASE Intermediate_Dir "foo_xsf8___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "foo_xsf8___Win32_Debug" -# PROP Intermediate_Dir "foo_xsf8___Win32_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "src/foobar8" /I "src" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "_DEBUG" -# ADD RSC /l 0x411 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"foo_8_vio2sf.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "foo_xsf8 - Win32 Release" -# Name "foo_xsf8 - Win32 Debug" -# Begin Group "loadpe" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.c -# End Source File -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.h -# End Source File -# End Group -# Begin Group "xsfc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\xsfc\foo_input_xsf8.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\foo_input_xsfcfg8.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\leakchk.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\tagget.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfc.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfc.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfcfg.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfcfg.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfdrv.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfui.rc -# End Source File -# End Group -# Begin Source File - -SOURCE=.\src\pversion.h -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/foo_xsf8.vcproj b/tools/vio2sf/foo_xsf8.vcproj deleted file mode 100644 index afd7f0329..000000000 --- a/tools/vio2sf/foo_xsf8.vcproj +++ /dev/null @@ -1,374 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/in_xsf.dsp b/tools/vio2sf/in_xsf.dsp deleted file mode 100644 index 614119664..000000000 --- a/tools/vio2sf/in_xsf.dsp +++ /dev/null @@ -1,156 +0,0 @@ -# Microsoft Developer Studio Project File - Name="in_xsf" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=in_xsf - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "in_xsf.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "in_xsf.mak" CFG="in_xsf - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "in_xsf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "in_xsf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "in_xsf - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_in_xsf" -# PROP Intermediate_Dir "Release_in_xsf" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "NDEBUG" -# ADD RSC /l 0x411 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /pdb:none /machine:I386 /out:"OUTPUT\winamp2\plugins\in_vio2sf.dll" - -!ELSEIF "$(CFG)" == "in_xsf - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_in_xsf" -# PROP Intermediate_Dir "Debug_in_xsf" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "src/aosdk" /I "src/aosdk/zlib" /I "src" /D "LSB_FIRST" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "_DEBUG" -# ADD RSC /l 0x411 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"in_vio2sf.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "in_xsf - Win32 Release" -# Name "in_xsf - Win32 Debug" -# Begin Group "loadpe" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.c -# End Source File -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.h -# End Source File -# End Group -# Begin Group "xsfc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\xsfc\in_xsf.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\in_xsfcfg.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\in_xsfcfg.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\leakchk.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\tagget.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfc.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfc.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfcfg.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfcfg.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfdrv.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfui.rc -# End Source File -# End Group -# Begin Source File - -SOURCE=.\src\pversion.h -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/in_xsf.vcproj b/tools/vio2sf/in_xsf.vcproj deleted file mode 100644 index 94e881138..000000000 --- a/tools/vio2sf/in_xsf.vcproj +++ /dev/null @@ -1,374 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/in_xsfu.dsp b/tools/vio2sf/in_xsfu.dsp deleted file mode 100644 index b88afa93a..000000000 --- a/tools/vio2sf/in_xsfu.dsp +++ /dev/null @@ -1,156 +0,0 @@ -# Microsoft Developer Studio Project File - Name="in_xsfu" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=in_xsfu - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "in_xsfu.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "in_xsfu.mak" CFG="in_xsfu - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "in_xsfu - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "in_xsfu - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "in_xsfu - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_in_xsfu" -# PROP Intermediate_Dir "Release_in_xsfu" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "src/aosdk" /I "src/aosdk/zlib" /I "src" /D ENABLE_UNICODE_PLUGIN=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "NDEBUG" -# ADD RSC /l 0x411 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /pdb:none /machine:I386 /out:"OUTPUT\winamp5\plugins\in_vio2sfu.dll" - -!ELSEIF "$(CFG)" == "in_xsfu - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_in_xsfu" -# PROP Intermediate_Dir "Debug_in_xsfu" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "src/aosdk" /I "src/aosdk/zlib" /I "src" /D ENABLE_UNICODE_PLUGIN=1 /D "LSB_FIRST" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "_DEBUG" -# ADD RSC /l 0x411 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"in_vio2sfu.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "in_xsfu - Win32 Release" -# Name "in_xsfu - Win32 Debug" -# Begin Group "loadpe" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.c -# End Source File -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.h -# End Source File -# End Group -# Begin Group "xsfc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\xsfc\in_xsf.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\in_xsfcfg.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\in_xsfcfg.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\leakchk.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\tagget.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfc.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfc.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfcfg.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfcfg.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfdrv.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfui.rc -# End Source File -# End Group -# Begin Source File - -SOURCE=.\src\pversion.h -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/in_xsfu.vcproj b/tools/vio2sf/in_xsfu.vcproj deleted file mode 100644 index bc7e329d9..000000000 --- a/tools/vio2sf/in_xsfu.vcproj +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/kpixsf.dsp b/tools/vio2sf/kpixsf.dsp deleted file mode 100644 index a82833e62..000000000 --- a/tools/vio2sf/kpixsf.dsp +++ /dev/null @@ -1,136 +0,0 @@ -# Microsoft Developer Studio Project File - Name="kpixsf" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=kpixsf - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "kpixsf.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "kpixsf.mak" CFG="kpixsf - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "kpixsf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "kpixsf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "kpixsf - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_kpixsf" -# PROP Intermediate_Dir "Release_kpixsf" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "NDEBUG" -# ADD RSC /l 0x411 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib shlwapi.lib /nologo /dll /pdb:none /machine:I386 /out:"output\kbmed\plugins\vio2sf.kpi" - -!ELSEIF "$(CFG)" == "kpixsf - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_kpixsf" -# PROP Intermediate_Dir "Debug_kpixsf" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "_DEBUG" -# ADD RSC /l 0x411 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib shlwapi.lib /nologo /dll /debug /machine:I386 /out:"vio2sf.kpi" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "kpixsf - Win32 Release" -# Name "kpixsf - Win32 Debug" -# Begin Group "loadpe" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.c -# End Source File -# Begin Source File - -SOURCE=.\src\loadpe\loadpe.h -# End Source File -# End Group -# Begin Group "kobarin" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\kobarin\kmp_pi.h -# End Source File -# End Group -# Begin Group "xsfc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\xsfc\kpixsf.c -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\leakchk.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\tagget.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfdrv.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\src\pversion.h -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/kpixsf.vcproj b/tools/vio2sf/kpixsf.vcproj deleted file mode 100644 index ee22dc130..000000000 --- a/tools/vio2sf/kpixsf.vcproj +++ /dev/null @@ -1,286 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/readme.txt b/tools/vio2sf/readme.txt deleted file mode 100644 index 693c61b7b..000000000 --- a/tools/vio2sf/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -First build every project in vio2sf.dsw. This will include the vio2sf project which will copy vio2sf.bin into all the plugin dirs. -Then build foo_input_vio2sf from vio2sf.sln. This plugin my be built in a newer msvc. -It has a dependency on vio2sf, which will then overwrite all vio2sf.bin in all directories with a vc9 version. -This is safe since it doesn't import any CRT DLL, and it probably runs a little faster. diff --git a/tools/vio2sf/src/Winamp/DSP.H b/tools/vio2sf/src/Winamp/DSP.H deleted file mode 100644 index 54d90a337..000000000 --- a/tools/vio2sf/src/Winamp/DSP.H +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef NULLSOFT_WINAMP_DSP_H -#define NULLSOFT_WINAMP_DSP_H -// DSP plugin interface - -// notes: -// any window that remains in foreground should optimally pass unused -// keystrokes to the parent (winamp's) window, so that the user -// can still control it. As for storing configuration, -// Configuration data should be stored in \plugin.ini -// (look at the vis plugin for configuration code) - -typedef struct winampDSPModule { - char *description; // description - HWND hwndParent; // parent window (filled in by calling app) - HINSTANCE hDllInstance; // instance handle to this DLL (filled in by calling app) - - void (*Config)(struct winampDSPModule *this_mod); // configuration dialog (if needed) - int (*Init)(struct winampDSPModule *this_mod); // 0 on success, creates window, etc (if needed) - - // modify waveform samples: returns number of samples to actually write - // (typically numsamples, but no more than twice numsamples, and no less than half numsamples) - // numsamples should always be at least 128. should, but I'm not sure - int (*ModifySamples)(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate); - - void (*Quit)(struct winampDSPModule *this_mod); // called when unloading - - void *userData; // user data, optional -} winampDSPModule; - -typedef struct { - int version; // DSP_HDRVER - char *description; // description of library - winampDSPModule* (*getModule)(int); // module retrieval function - int (*sf)(int key); // DSP_HDRVER == 0x21 -} winampDSPHeader; - -// exported symbols -#ifdef USE_DSP_HDR_HWND -typedef winampDSPHeader* (*winampDSPGetHeaderType)(HWND); -#define DSP_HDRVER 0x22 - -#else - -typedef winampDSPHeader* (*winampDSPGetHeaderType)(HWND); -// header version: 0x20 == 0.20 == winamp 2.0 -#define DSP_HDRVER 0x20 -#endif - -// return values from the winampUninstallPlugin(HINSTANCE hdll, HWND parent, int param) -// which determine if we can uninstall the plugin immediately or on winamp restart -#define DSP_PLUGIN_UNINSTALL_NOW 0x0 -#define DSP_PLUGIN_UNINSTALL_REBOOT 0x1 -// -// uninstall support was added from 5.0+ and uninstall now support from 5.5+ -// it is down to you to ensure that if uninstall now is returned that it will not cause a crash -// (ie don't use if you've been subclassing the main window) - -// Version note: -// -// Added passing of Winamp's main hwnd in the call to the exported winampDSPHeader() -// which allows for primarily the use of localisation features with the bundled plugins. -// If you want to use the new version then either you can edit you version of dsp.h or -// you can add USE_DSP_HDR_HWND to your project's defined list or before use of dsp.h -// -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/Winamp/GEN.H b/tools/vio2sf/src/Winamp/GEN.H deleted file mode 100644 index a63da3461..000000000 --- a/tools/vio2sf/src/Winamp/GEN.H +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef NULLSOFT_WINAMP_GEN_H -#define NULLSOFT_WINAMP_GEN_H - -#include - -#define GEN_INIT_SUCCESS 0 - -// return values from the winampUninstallPlugin(HINSTANCE hdll, HWND parent, int param) -// which determine if we can uninstall the plugin immediately or on winamp restart -// -// uninstall support was added from 5.0+ and uninstall now support from 5.5+ -// it is down to you to ensure that if uninstall now is returned that it will not cause a crash -// (ie don't use if you've been subclassing the main window) -#define GEN_PLUGIN_UNINSTALL_NOW 0x1 -#define GEN_PLUGIN_UNINSTALL_REBOOT 0x0 - -typedef struct { - int version; - char *description; - int (*init)(); - void (*config)(); - void (*quit)(); - HWND hwndParent; - HINSTANCE hDllInstance; -} winampGeneralPurposePlugin; - -#define GPPHDR_VER 0x10 -#ifdef __cplusplus -extern "C" { -#endif -//extern winampGeneralPurposePlugin *gen_plugins[256]; -typedef winampGeneralPurposePlugin * (*winampGeneralPurposePluginGetter)(); -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/Winamp/IN2.H b/tools/vio2sf/src/Winamp/IN2.H deleted file mode 100644 index 41617668e..000000000 --- a/tools/vio2sf/src/Winamp/IN2.H +++ /dev/null @@ -1,138 +0,0 @@ - -#ifndef NULLSOFT_WINAMP_IN2H -#define NULLSOFT_WINAMP_IN2H -#include "out.h" - -// note: exported symbol is now winampGetInModule2. - -#define IN_UNICODE 0x0F000000 - -#ifdef UNICODE_INPUT_PLUGIN -#define in_char wchar_t -#define IN_VER (IN_UNICODE | 0x100) -#else -#define in_char char -#define IN_VER 0x100 -#endif - -#define IN_MODULE_FLAG_USES_OUTPUT_PLUGIN 1 -// By default, Winamp assumes that your input plugin wants to use Winamp's EQ, and doesn't do replay gain -// if you handle any of these yourself (EQ, Replay Gain adjustments), then set these flags accordingly -#define IN_MODULE_FLAG_EQ 2 // set this if you do your own EQ -#define IN_MODULE_FLAG_REPLAYGAIN 8 // set this if you adjusted volume for replay gain - // for tracks with no replay gain metadata, you should clear this flag - // UNLESS you handle "non_replaygain" gain adjustment yourself -#define IN_MODULE_FLAG_REPLAYGAIN_PREAMP 16 // use this if you queried for the replay gain preamp parameter and used it - // this parameter is new to 5.54 -typedef struct -{ - int version; // module type (IN_VER) - char *description; // description of module, with version string - - HWND hMainWindow; // winamp's main window (filled in by winamp) - HINSTANCE hDllInstance; // DLL instance handle (Also filled in by winamp) - - char *FileExtensions; // "mp3\0Layer 3 MPEG\0mp2\0Layer 2 MPEG\0mpg\0Layer 1 MPEG\0" - // May be altered from Config, so the user can select what they want - - int is_seekable; // is this stream seekable? - int UsesOutputPlug; // does this plug-in use the output plug-ins? (musn't ever change, ever :) - // note that this has turned into a "flags" field - // see IN_MODULE_FLAG_* - - void (*Config)(HWND hwndParent); // configuration dialog - void (*About)(HWND hwndParent); // about dialog - - void (*Init)(); // called at program init - void (*Quit)(); // called at program quit - -#define GETFILEINFO_TITLE_LENGTH 2048 - void (*GetFileInfo)(const in_char *file, in_char *title, int *length_in_ms); // if file == NULL, current playing is used - -#define INFOBOX_EDITED 0 -#define INFOBOX_UNCHANGED 1 - int (*InfoBox)(const in_char *file, HWND hwndParent); - - int (*IsOurFile)(const in_char *fn); // called before extension checks, to allow detection of mms://, etc - // playback stuff - int (*Play)(const in_char *fn); // return zero on success, -1 on file-not-found, some other value on other (stopping winamp) error - void (*Pause)(); // pause stream - void (*UnPause)(); // unpause stream - int (*IsPaused)(); // ispaused? return 1 if paused, 0 if not - void (*Stop)(); // stop (unload) stream - - // time stuff - int (*GetLength)(); // get length in ms - int (*GetOutputTime)(); // returns current output time in ms. (usually returns outMod->GetOutputTime() - void (*SetOutputTime)(int time_in_ms); // seeks to point in stream (in ms). Usually you signal your thread to seek, which seeks and calls outMod->Flush().. - - // volume stuff - void (*SetVolume)(int volume); // from 0 to 255.. usually just call outMod->SetVolume - void (*SetPan)(int pan); // from -127 to 127.. usually just call outMod->SetPan - - // in-window builtin vis stuff - - void (*SAVSAInit)(int maxlatency_in_ms, int srate); // call once in Play(). maxlatency_in_ms should be the value returned from outMod->Open() - // call after opening audio device with max latency in ms and samplerate - void (*SAVSADeInit)(); // call in Stop() - - - // simple vis supplying mode - void (*SAAddPCMData)(void *PCMData, int nch, int bps, int timestamp); - // sets the spec data directly from PCM data - // quick and easy way to get vis working :) - // needs at least 576 samples :) - - // advanced vis supplying mode, only use if you're cool. Use SAAddPCMData for most stuff. - int (*SAGetMode)(); // gets csa (the current type (4=ws,2=osc,1=spec)) - // use when calling SAAdd() - int (*SAAdd)(void *data, int timestamp, int csa); // sets the spec data, filled in by winamp - - - // vis stuff (plug-in) - // simple vis supplying mode - void (*VSAAddPCMData)(void *PCMData, int nch, int bps, int timestamp); // sets the vis data directly from PCM data - // quick and easy way to get vis working :) - // needs at least 576 samples :) - - // advanced vis supplying mode, only use if you're cool. Use VSAAddPCMData for most stuff. - int (*VSAGetMode)(int *specNch, int *waveNch); // use to figure out what to give to VSAAdd - int (*VSAAdd)(void *data, int timestamp); // filled in by winamp, called by plug-in - - - // call this in Play() to tell the vis plug-ins the current output params. - void (*VSASetInfo)(int srate, int nch); // <-- Correct (benski, dec 2005).. old declaration had the params backwards - - - // dsp plug-in processing: - // (filled in by winamp, calld by input plug) - - // returns 1 if active (which means that the number of samples returned by dsp_dosamples - // could be greater than went in.. Use it to estimate if you'll have enough room in the - // output buffer - int (*dsp_isactive)(); - - // returns number of samples to output. This can be as much as twice numsamples. - // be sure to allocate enough buffer for samples, then. - int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate); - - - // eq stuff - void (*EQSet)(int on, char data[10], int preamp); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore. - - // info setting (filled in by winamp) - void (*SetInfo)(int bitrate, int srate, int stereo, int synched); // if -1, changes ignored? :) - - Out_Module *outMod; // filled in by winamp, optionally used :) -} In_Module; - -// return values from the winampUninstallPlugin(HINSTANCE hdll, HWND parent, int param) -// which determine if we can uninstall the plugin immediately or on winamp restart -// -// uninstall support was added from 5.0+ and uninstall now support from 5.5+ -// it is down to you to ensure that if uninstall now is returned that it will not cause a crash -// (ie don't use if you've been subclassing the main window) -#define IN_PLUGIN_UNINSTALL_NOW 0x1 -#define IN_PLUGIN_UNINSTALL_REBOOT 0x0 - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/Winamp/OUT.H b/tools/vio2sf/src/Winamp/OUT.H deleted file mode 100644 index af76e8273..000000000 --- a/tools/vio2sf/src/Winamp/OUT.H +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef NULLSOFT_OUTH -#define NULLSOFT_OUTH -#include -#include -// ids: -// waveout: 32 -// gapless: 64 -// xfade: 63 -// disk: 33 -// dsound: 38 -// NULL: 65 -// mm2: 69 - -#if (_MSC_VER <= 1200) -typedef int intptr_t; -#endif - -#define OUT_VER 0x10 - -typedef struct -{ - int version; // module version (OUT_VER) - char *description; // description of module, with version string - intptr_t id; // module id. each input module gets its own. non-nullsoft modules should - // be >= 65536. - - HWND hMainWindow; // winamp's main window (filled in by winamp) - HINSTANCE hDllInstance; // DLL instance handle (filled in by winamp) - - void (*Config)(HWND hwndParent); // configuration dialog - void (*About)(HWND hwndParent); // about dialog - - void (*Init)(); // called when loaded - void (*Quit)(); // called when unloaded - - int (*Open)(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms); - // returns >=0 on success, <0 on failure - - // NOTENOTENOTE: bufferlenms and prebufferms are ignored in most if not all output plug-ins. - // ... so don't expect the max latency returned to be what you asked for. - // returns max latency in ms (0 for diskwriters, etc) - // bufferlenms and prebufferms must be in ms. 0 to use defaults. - // prebufferms must be <= bufferlenms - // pass bufferlenms==-666 to tell the output plugin that it's clock is going to be used to sync video - // out_ds turns off silence-eating when -666 is passed - - void (*Close)(); // close the ol' output device. - - int (*Write)(char *buf, int len); - // 0 on success. Len == bytes to write (<= 8192 always). buf is straight audio data. - // 1 returns not able to write (yet). Non-blocking, always. - - int (*CanWrite)(); // returns number of bytes possible to write at a given time. - // Never will decrease unless you call Write (or Close, heh) - - int (*IsPlaying)(); // non0 if output is still going or if data in buffers waiting to be - // written (i.e. closing while IsPlaying() returns 1 would truncate the song - - int (*Pause)(int pause); // returns previous pause state - - void (*SetVolume)(int volume); // volume is 0-255 - void (*SetPan)(int pan); // pan is -128 to 128 - - void (*Flush)(int t); // flushes buffers and restarts output at time t (in ms) - // (used for seeking) - - int (*GetOutputTime)(); // returns played time in MS - int (*GetWrittenTime)(); // returns time written in MS (used for synching up vis stuff) - -} Out_Module; - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/Winamp/ipc_pe.h b/tools/vio2sf/src/Winamp/ipc_pe.h deleted file mode 100644 index 708d8a66d..000000000 --- a/tools/vio2sf/src/Winamp/ipc_pe.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __IPC_PE_H -#define __IPC_PE_H - -#define IPC_PE_GETCURINDEX 100 // returns current idx -#define IPC_PE_GETINDEXTOTAL 101 // returns number of items -#define IPC_PE_GETINDEXINFO 102 // (copydata) lpData is of type callbackinfo, callback is called with copydata/fileinfo structure and msg IPC_PE_GETINDEXINFORESULT -#define IPC_PE_GETINDEXINFORESULT 103 // callback message for IPC_PE_GETINDEXINFO -#define IPC_PE_DELETEINDEX 104 // lParam = index -#define IPC_PE_SWAPINDEX 105 // (lParam & 0xFFFF0000) >> 16 = from, (lParam & 0xFFFF) = to -#define IPC_PE_INSERTFILENAME 106 // (copydata) lpData is of type fileinfo -#define IPC_PE_GETDIRTY 107 // returns 1 if the playlist changed since the last IPC_PE_SETCLEAN -#define IPC_PE_SETCLEAN 108 // resets the dirty flag until next modification -#define IPC_PE_GETIDXFROMPOINT 109 // pass a point parm, return a playlist index -#define IPC_PE_SAVEEND 110 // pass index to save from -#define IPC_PE_RESTOREEND 111 // no parm -#define IPC_PE_GETNEXTSELECTED 112 // same as IPC_PLAYLIST_GET_NEXT_SELECTED for the main window -#define IPC_PE_GETSELECTEDCOUNT 113 -#define IPC_PE_INSERTFILENAMEW 114 // (copydata) lpData is of type fileinfoW -#define IPC_PE_GETINDEXINFO_TITLE 115 // like IPC_PE_GETINDEXINFO, but writes the title to char file[MAX_PATH] instead of filename -#define IPC_PE_GETINDEXINFORESULT_TITLE 116 // callback message for IPC_PE_GETINDEXINFO -typedef struct { - char file[MAX_PATH]; - int index; - } fileinfo; - -typedef struct { - wchar_t file[MAX_PATH]; - int index; - } fileinfoW; - -typedef struct { - HWND callback; - int index; - } callbackinfo; - -// the following messages are in_process ONLY - -#define IPC_PE_GETINDEXTITLE 200 // lParam = pointer to fileinfo2 struct -#define IPC_PE_GETINDEXTITLEW 201 // lParam = pointer to fileinfo2W struct -#define IPC_PE_GETINDEXINFO_INPROC 202 // lParam = pointer to fileinfo struct -#define IPC_PE_GETINDEXINFOW_INPROC 203 // lParam = pointer to fileinfoW struct - -typedef struct { - int fileindex; - char filetitle[256]; - char filelength[16]; - } fileinfo2; - -typedef struct -{ - int fileindex; - wchar_t filetitle[256]; - wchar_t filelength[16]; - } fileinfo2W; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/Winamp/wa_dlg.h b/tools/vio2sf/src/Winamp/wa_dlg.h deleted file mode 100644 index df912b257..000000000 --- a/tools/vio2sf/src/Winamp/wa_dlg.h +++ /dev/null @@ -1,436 +0,0 @@ -/* -** Copyright (C) 2003-2008 Nullsoft, Inc. -** -** This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held -** liable for any damages arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, including commercial applications, and to -** alter it and redistribute it freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. -** If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -** -** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -** -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#ifndef _WA_DLG_H_ -#define _WA_DLG_H_ - -#include "wa_ipc.h" -#ifdef __cplusplus -extern "C" { -#endif -/* - 1) gen.bmp has a generic window frame for plugins to use. - its format is similar to the minibrowser's. - In addition gen.bmp includes a font for the titlebar, in both - highlight and no-highlight modes. The font is variable width, - and it uses the first color before the letter A as the delimiter. - The no-highlight form of letter must be the same width as the - highlight form. - 2) genex.bmp has button and scrollbar images, as well as some individual - pixels that describe the colors for the dialog. The button and - scrollbar images should be self explanatory (note that the buttons - have 4 pixel sized edges that are not stretched, and the center is - stretched), and the scrollbars do something similar. - The colors start at (48,0) and run every other pixel. The meaning - of each pixel is: - x=48: item background (background to edits, listviews etc) - x=50: item foreground (text color of edit/listview, etc) - x=52: window background (used to set the bg color for the dialog) - x=54: button text color - x=56: window text color - x=58: color of dividers and sunken borders - x=60: selection color for playlists - x=62: listview header background color - x=64: listview header text color - x=66: listview header frame top color - x=68: listview header frame middle color - x=70: listview header frame bottom color - x=72: listview header empty color - x=74: scrollbar foreground color - x=76: scrollbar background color - x=78: inverse scrollbar foreground color - x=80: inverse scrollbar background color - x=82: scrollbar dead area color - x=84: listview/treeview selection bar text color (active) - x=86: listview/treeview selection bar back color (active) - x=88: listview/treeview selection bar text color (inactive) - x=90: listview/treeview selection bar back color (inactive) - x=92: alternate item background - x=94: alternate item foreground -*/ - -#define DCW_SUNKENBORDER 0x00010000 -#define DCW_DIVIDER 0x00020000 - -enum -{ - WADLG_ITEMBG, - WADLG_ITEMFG, - WADLG_WNDBG, - WADLG_BUTTONFG, - WADLG_WNDFG, - WADLG_HILITE, - WADLG_SELCOLOR, - WADLG_LISTHEADER_BGCOLOR, - WADLG_LISTHEADER_FONTCOLOR, - WADLG_LISTHEADER_FRAME_TOPCOLOR, - WADLG_LISTHEADER_FRAME_MIDDLECOLOR, - WADLG_LISTHEADER_FRAME_BOTTOMCOLOR, - WADLG_LISTHEADER_EMPTY_BGCOLOR, - WADLG_SCROLLBAR_FGCOLOR, - WADLG_SCROLLBAR_BGCOLOR, - WADLG_SCROLLBAR_INV_FGCOLOR, - WADLG_SCROLLBAR_INV_BGCOLOR, - WADLG_SCROLLBAR_DEADAREA_COLOR, - WADLG_SELBAR_FGCOLOR, - WADLG_SELBAR_BGCOLOR, - WADLG_INACT_SELBAR_FGCOLOR, - WADLG_INACT_SELBAR_BGCOLOR, - WADLG_ITEMBG2, - WADLG_ITEMFG2, - WADLG_NUM_COLORS -}; - -typedef enum _WACURSOR // used in IPC_GETSKINCURSORS -{ - WACURSOR_VOLUME = 0, // volume & balane - WACURSOR_POSITION = 1, // position - WACURSOR_BTN_WINSHADE = 2, // winshade - WACURSOR_BTN_MINIMIZE = 3, // minimize - WACURSOR_BTN_CLOSE = 4, // close - WACURSOR_MENU = 5, // main menu - WACURSOR_TITLEBAR = 6, // title bar - WACURSOR_SONGNAME = 7, - WACURSOR_NORMAL = 8, - WACURSOR_WINSHADE_BTN_WINSHADE = 9, - WACURSOR_WINSHADE_BTN_MINIMIZE = 10, - WACURSOR_WINSHADE_POSITION = 11, - WACURSOR_WINSHADE_BTN_CLOSE = 12, - WACURSOR_WINSHADE_MENU = 13, - WACURSOR_WINSHADE_NORMAL = 14, - WACURSOR_PL_BTN_WINSHADE = 15, - WACURSOR_PL_BTN_CLOSE = 16, - WACURSOR_PL_TITLEBAR = 17, - WACURSOR_PL_VSCROLL = 18, - WACURSOR_PL_RESIZE = 19, - WACURSOR_PL_NORMAL = 20, - WACURSOR_PL_WINSHADE_BTN_WINSHADE = 21, - WACURSOR_PL_WINSHADE_BTN_CLOSE = 22, - WACURSOR_PL_WINSHADE_HSIZE = 23, - WACURSOR_PL_WINSHADE_NORMAL = 24, - WACURSOR_EQ_SLIDER = 25, - WACURSOR_EQ_BTN_CLOSE = 26, - WACURSOR_EQ_TITLEBAR = 27, - WACURSOR_EQ_NORMAL = 28, -} WACURSOR; - -void WADlg_init(HWND hwndWinamp); // call this on init, or on WM_DISPLAYCHANGE -void WADlg_close(); -int WADlg_getColor(int idx); -int WADlg_initted(); - -LRESULT WADlg_handleDialogMsgs(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); // -void WADlg_DrawChildWindowBorders(HWND hwndDlg, int *tab, int tabsize); // each entry in tab would be the id | DCW_* - -HBITMAP WADlg_getBitmap(); - -/// define WA_DLG_IMPLEMENT in one of your source files before including this .h -// if you are making a media library plugin, you dont need to do this, look at view_ex for -// an example of how to get the function *'s via an IPC message. -#ifdef __cplusplus -} -#endif - -#ifdef WA_DLG_IMPLEMENT - -static HBRUSH wadlg_lastbrush=0; -static HBITMAP wadlg_bitmap=0; // load this manually -static int wadlg_colors[WADLG_NUM_COLORS]; -static int wadlg_defcolors[WADLG_NUM_COLORS]= -{ - RGB(0,0,0), - RGB(0,255,0), - RGB(36,36,60), - RGB(57,56,66), - RGB(255,255,255), - RGB(132,148,165), - RGB(0,0,198), - RGB(36*2,36*2,60*2), - RGB(255,255,255), - RGB(36*3,36*3,60*3), - RGB(36,36,60), - RGB(36*0.5,36*0.5,60*0.5), - RGB(36,36,60), - RGB(36*1,36*1,60*1), - RGB(36*1,36*1,60*1), - RGB(121,130,150), - RGB(78,88,110), - RGB(36*1,36*1,60*1), - RGB(255,255,255), - RGB(0,0,180), - RGB(0,255,0), - RGB(0,0,128), - RGB(0,0,0), - RGB(0,255,0), -}; - -int WADlg_initted() -{ - return !!wadlg_bitmap; -} - -int WADlg_getColor(int idx) -{ - if (idx < 0 || idx >= WADLG_NUM_COLORS) return 0; - return wadlg_colors[idx]; -} - -HBITMAP WADlg_getBitmap() -{ - return wadlg_bitmap; -} - -void WADlg_init(HWND hwndWinamp) // call this on init, or on WM_DISPLAYCHANGE -{ - if (wadlg_bitmap) DeleteObject(wadlg_bitmap); - wadlg_bitmap = (HBITMAP) SendMessage(hwndWinamp,WM_WA_IPC,0,IPC_GET_GENSKINBITMAP); - if (wadlg_bitmap) - { - HDC tmpDC=CreateCompatibleDC(NULL); - HGDIOBJ o=SelectObject(tmpDC,(HGDIOBJ)wadlg_bitmap); - int defbgcol=GetPixel(tmpDC,111,0); - for (int x = 0; x < WADLG_NUM_COLORS; x ++) - { - int a=GetPixel(tmpDC,48+x*2,0); - if (a == CLR_INVALID || a == RGB(0,198,255) || a == defbgcol) - { - //defaults for old skins - if (x == WADLG_SELBAR_FGCOLOR || x == WADLG_INACT_SELBAR_FGCOLOR) a=wadlg_colors[WADLG_WNDFG]; - else if (x == WADLG_SELBAR_BGCOLOR || x == WADLG_INACT_SELBAR_BGCOLOR) - { - a=wadlg_colors[WADLG_SELCOLOR]; - if (x == WADLG_INACT_SELBAR_BGCOLOR) - a=((a/2)&0x7F7F7F)+(((wadlg_colors[WADLG_WNDBG])/2)&0x7F7F7F); - } - else if (x == WADLG_ITEMBG2) - { - a=wadlg_colors[WADLG_ITEMBG]; - } - else if (x == WADLG_ITEMFG2) - { - a=wadlg_colors[WADLG_ITEMFG]; - } - else a=wadlg_defcolors[x]; - } - wadlg_colors[x]=a; - } - - SelectObject(tmpDC,o); - DeleteDC(tmpDC); - } -} - -void WADlg_close() -{ - if (wadlg_bitmap) DeleteObject(wadlg_bitmap); - wadlg_bitmap=0; - if (wadlg_lastbrush) DeleteObject(wadlg_lastbrush); - wadlg_lastbrush=0; -} - -void WADlg_dotLine(HDC hdc, int left, int top, int len, int vert) -{ - for(int i=(top&1);iCtlType == ODT_BUTTON) { - wchar_t wt[256]; - RECT r; - GetDlgItemTextW(hwndDlg,(INT)wParam,wt,sizeof(wt)/sizeof(*wt)); - - HDC hdc = CreateCompatibleDC(di->hDC); - HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, wadlg_bitmap); - - r=di->rcItem; - SetStretchBltMode(di->hDC,COLORONCOLOR); - - int yoffs = (di->itemState & ODS_SELECTED) ? 15 : 0; - - BitBlt(di->hDC,r.left,r.top,4,4,hdc,0,yoffs,SRCCOPY); // top left - StretchBlt(di->hDC,r.left+4,r.top,r.right-r.left-4-4,4,hdc,4,yoffs,47-4-4,4,SRCCOPY); // top center - BitBlt(di->hDC,r.right-4,r.top,4,4,hdc,47-4,yoffs,SRCCOPY); // top right - - StretchBlt(di->hDC,r.left,r.top+4,4,r.bottom-r.top-4-4,hdc,0,4+yoffs,4,15-4-4,SRCCOPY); // left edge - StretchBlt(di->hDC,r.right-4,r.top+4,4,r.bottom-r.top-4-4,hdc,47-4,4+yoffs,4,15-4-4,SRCCOPY); // right edge - - // center - StretchBlt(di->hDC,r.left+4,r.top+4,r.right-r.left-4-4,r.bottom-r.top-4-4,hdc,4,4+yoffs,47-4-4,15-4-4,SRCCOPY); - - BitBlt(di->hDC,r.left,r.bottom-4,4,4,hdc,0,15-4+yoffs,SRCCOPY); // bottom left - StretchBlt(di->hDC,r.left+4,r.bottom-4,r.right-r.left-4-4,4,hdc,4,15-4+yoffs,47-4-4,4,SRCCOPY); // bottom center - BitBlt(di->hDC,r.right-4,r.bottom-4,4,4,hdc,47-4,15-4+yoffs,SRCCOPY); // bottom right - - // draw text - SetBkMode(di->hDC,TRANSPARENT); - - // this will do a different style for the button text depending on enabled state of the button - COLORREF colour = wadlg_colors[WADLG_BUTTONFG]; - if(!IsWindowEnabled(di->hwndItem)){ - COLORREF fg = wadlg_colors[WADLG_WNDFG], - bg = wadlg_colors[WADLG_WNDBG]; - colour = RGB((GetRValue(fg)+GetRValue(bg))/2, - (GetGValue(fg)+GetGValue(bg))/2, - (GetBValue(fg)+GetBValue(bg))/2); - } - SetTextColor(di->hDC,colour); - - if (di->itemState & ODS_SELECTED) {r.left+=2; r.top+=2;} - DrawTextW(di->hDC,wt,-1,&r,DT_VCENTER|DT_SINGLELINE|DT_CENTER); - - SelectObject(hdc, hbmpOld); - DeleteDC(hdc); - - if(GetFocus()==di->hwndItem) { - HPEN hpen, hpenOld; - hpen =CreatePen(PS_SOLID,0,RGB(0,0,0)); - hpenOld = (HPEN)SelectObject(di->hDC, hpen); - WADlg_dotLine(di->hDC,r.left+2,r.top+2,r.right-r.left-3,0); - WADlg_dotLine(di->hDC,r.right-3,r.top+2,r.bottom-r.top-3,1); - WADlg_dotLine(di->hDC,r.left+2,r.top+2,r.bottom-r.top-3,1); - WADlg_dotLine(di->hDC,r.left+2,r.bottom-3,r.right-r.left-3,0); - SelectObject(di->hDC, hpenOld); - DeleteObject(hpen); - } - } - } - - switch(uMsg) - { - case WM_CTLCOLORLISTBOX: - case WM_CTLCOLORDLG: - case WM_CTLCOLORBTN: - case WM_CTLCOLORSTATIC: - case WM_CTLCOLOREDIT: - { - int bgcolor=(uMsg == WM_CTLCOLOREDIT || uMsg == WM_CTLCOLORLISTBOX) ? wadlg_colors[WADLG_ITEMBG] : (uMsg == WM_CTLCOLORBTN ? wadlg_colors[WADLG_ITEMBG] : wadlg_colors[WADLG_WNDBG]); - LOGBRUSH lb={BS_SOLID,GetNearestColor((HDC)wParam,bgcolor)}; - if (wadlg_lastbrush) DeleteObject(wadlg_lastbrush); - wadlg_lastbrush=CreateBrushIndirect(&lb); - SetTextColor((HDC)wParam,uMsg == WM_CTLCOLORSTATIC ? wadlg_colors[WADLG_WNDFG] : wadlg_colors[WADLG_ITEMFG]); - SetBkColor((HDC)wParam,lb.lbColor); - return (LRESULT)wadlg_lastbrush; - } - } - return 0; -} - -static int RectInRect(RECT *rect1, RECT *rect2) -{ - // this has a bias towards true - - // this could probably be optimized a lot - return ((rect1->top >= rect2->top && rect1->top <= rect2->bottom) || - (rect1->bottom >= rect2->top && rect1->bottom <= rect2->bottom) || - (rect2->top >= rect1->top && rect2->top <= rect1->bottom) || - (rect2->bottom >= rect1->top && rect2->bottom <= rect1->bottom)) // vertical intersect - && - ((rect1->left >= rect2->left && rect1->left <= rect2->right) || - (rect1->right >= rect2->left && rect1->right <= rect2->right) || - (rect2->left >= rect1->left && rect2->left <= rect1->right) || - (rect2->right >= rect1->left && rect2->right <= rect1->right)) // horiz intersect - ; -} - -static void WADlg_removeFromRgn(HRGN hrgn, int left, int top, int right, int bottom) -{ - HRGN rgn2=CreateRectRgn(left,top,right,bottom); - CombineRgn(hrgn,hrgn,rgn2,RGN_DIFF); - DeleteObject(rgn2); -} - -void WADlg_DrawChildWindowBorders(HWND hwndDlg, int *tab, int tabsize) -{ - PAINTSTRUCT ps; - BeginPaint(hwndDlg,&ps); - HRGN hrgn = (ps.fErase) ? CreateRectRgnIndirect(&ps.rcPaint) : NULL; - HPEN pen = CreatePen(PS_SOLID, 0, wadlg_colors[WADLG_HILITE]); - HGDIOBJ o = SelectObject(ps.hdc, pen); - - while (tabsize--) - { - RECT r; - int a = *tab++; - GetWindowRect(GetDlgItem(hwndDlg, a & 0xffff),&r); - MapWindowPoints(HWND_DESKTOP, hwndDlg, (LPPOINT)&r, 2); - - if (RectInRect(&ps.rcPaint,&r)) - { - if ((a & 0xffff0000) == DCW_SUNKENBORDER) - { - MoveToEx(ps.hdc,r.left,r.bottom,NULL); - LineTo(ps.hdc,r.right,r.bottom); - LineTo(ps.hdc,r.right,r.top-1); - if(hrgn) - { - WADlg_removeFromRgn(hrgn,r.left,r.bottom,r.right,r.bottom+1); - WADlg_removeFromRgn(hrgn,r.right,r.top,r.right+1,r.bottom); - } - } - else if ((a & 0xffff0000) == DCW_DIVIDER) - { - if (r.right - r.left < r.bottom - r.top) // vertical - { - int left=(r.left+r.right)/2; - MoveToEx(ps.hdc,left,r.top,NULL); - LineTo(ps.hdc,left,r.bottom+1); - if(hrgn) WADlg_removeFromRgn(hrgn,left,r.top,left+1,r.bottom); - } - else // horiz - { - int top=(r.top+r.bottom)/2; - MoveToEx(ps.hdc,r.left,top,NULL); - LineTo(ps.hdc,r.right+1,top); - if(hrgn) WADlg_removeFromRgn(hrgn,r.left,top,r.right,top+1); - } - } - } - } - - SelectObject(ps.hdc, o); - DeleteObject(pen); - - if(hrgn) - { - //erase bkgnd while clipping out our own drawn stuff (for flickerless display) - HBRUSH b = CreateSolidBrush(wadlg_colors[WADLG_WNDBG]); - FillRgn(ps.hdc,hrgn,b); - DeleteObject(b); - DeleteObject(hrgn); - } - EndPaint(hwndDlg,&ps); -} -#endif - -#endif//_WA_DLG_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/Winamp/wa_ipc.h b/tools/vio2sf/src/Winamp/wa_ipc.h deleted file mode 100644 index 7e1f75d22..000000000 --- a/tools/vio2sf/src/Winamp/wa_ipc.h +++ /dev/null @@ -1,2470 +0,0 @@ -/* -** Copyright (C) 1997-2008 Nullsoft, Inc. -** -** This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held -** liable for any damages arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, including commercial applications, and to -** alter it and redistribute it freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. -** If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -** -** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -** -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#ifndef _WA_IPC_H_ -#define _WA_IPC_H_ - -#include -#include -#if (_MSC_VER <= 1200) -typedef int intptr_t; -#endif -/* -** This is the modern replacement for the classic 'frontend.h'. Most of these -** updates are designed for in-process use, i.e. from a plugin. -** -*/ - -/* Most of the IPC_* messages involve sending the message in the form of: -** result = SendMessage(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*); -** Where different then this is specified (typically with WM_COPYDATA variants) -** -** When you use SendMessage(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*) and specify a IPC_* -** which is not currently implemented/supported by the Winamp version being used then it -** will return 1 for 'result'. This is a good way of helping to check if an api being -** used which returns a function pointer, etc is even going to be valid. -*/ - -#define WM_WA_IPC WM_USER - -#define WINAMP_VERSION_MAJOR(winampVersion) ((winampVersion & 0x0000FF00) >> 12) -#define WINAMP_VERSION_MINOR(winampVersion) (winampVersion & 0x000000FF) // returns, i.e. 0x12 for 5.12 and 0x10 for 5.1... - - -#define IPC_GETVERSION 0 -/* int version = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION); -** -** The version returned will be 0x20yx for Winamp 2.yx. -** Versions previous to Winamp 2.0 typically (but not always) use 0x1zyx for 1.zx. -** Just a bit weird but that's the way it goes. -** -** For Winamp 5.x it uses the format 0x50yx for Winamp 5.yx -** e.g. 5.01 -> 0x5001 -** 5.09 -> 0x5009 -** 5.1 -> 0x5010 -** -** Notes: For 5.02 this api will return the same value as for a 5.01 build. -** For 5.07 this api will return the same value as for a 5.06 build. -*/ - - -#define IPC_GETVERSIONSTRING 1 - - -#define IPC_GETREGISTEREDVERSION 770 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETREGISTEREDVERSION); -** -** This will open the Winamp Preferences and show the Winamp Pro page. -*/ - - -typedef struct { - const char *filename; - const char *title; - int length; -} enqueueFileWithMetaStruct; // send this to a IPC_PLAYFILE in a non WM_COPYDATA, -// and you get the nice desired result. if title is NULL, it is treated as a "thing", -// otherwise it's assumed to be a file (for speed) - -typedef struct { - const wchar_t *filename; - const wchar_t *title; - int length; -} enqueueFileWithMetaStructW; - -#define IPC_PLAYFILE 100 // dont be fooled, this is really the same as enqueufile -#define IPC_ENQUEUEFILE 100 -#define IPC_PLAYFILEW 1100 -#define IPC_ENQUEUEFILEW 1100 -/* This is sent as a WM_COPYDATA with IPC_PLAYFILE as the dwData member and the string -** of the file / playlist to be enqueued into the playlist editor as the lpData member. -** This will just enqueue the file or files since you can use this to enqueue a playlist. -** It will not clear the current playlist or change the playback state. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_ENQUEUEFILE; -** cds.lpData = (void*)"c:\\test\\folder\\test.mp3"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -** -** -** With 2.9+ and all of the 5.x versions you can send this as a normal WM_WA_IPC -** (non WM_COPYDATA) with an enqueueFileWithMetaStruct as the param. -** If the title member is null then it is treated as a "thing" otherwise it will be -** assumed to be a file (for speed). -** -** enqueueFileWithMetaStruct eFWMS = {0}; -** eFWMS.filename = "c:\\test\\folder\\test.mp3"; -** eFWMS.title = "Whipping Good"; -** eFWMS.length = 300; // this is the number of seconds for the track -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&eFWMS,IPC_ENQUEUEFILE); -*/ - - -#define IPC_DELETE 101 -#define IPC_DELETE_INT 1101 -/* SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_DELETE); -** Use this api to clear Winamp's internal playlist. -** You should not need to use IPC_DELETE_INT since it is used internally by Winamp when -** it is dealing with some lame Windows Explorer issues (hard to believe that!). -*/ - - -#define IPC_STARTPLAY 102 -#define IPC_STARTPLAY_INT 1102 -/* SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_STARTPLAY); -** Sending this will start playback and is almost the same as hitting the play button. -** The IPC_STARTPLAY_INT version is used internally and you should not need to use it -** since it won't be any fun. -*/ - - -#define IPC_CHDIR 103 -/* This is sent as a WM_COPYDATA type message with IPC_CHDIR as the dwData value and the -** directory you want to change to as the lpData member. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_CHDIR; -** cds.lpData = (void*)"c:\\download"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -** -** The above example will make Winamp change to the directory 'C:\download'. -*/ - - -#define IPC_ISPLAYING 104 -/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING); -** This is sent to retrieve the current playback state of Winamp. -** If it returns 1, Winamp is playing. -** If it returns 3, Winamp is paused. -** If it returns 0, Winamp is not playing. -*/ - - -#define IPC_GETOUTPUTTIME 105 -/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETOUTPUTTIME); -** This api can return two different sets of information about current playback status. -** -** If mode = 0 then it will return the position (in ms) of the currently playing track. -** Will return -1 if Winamp is not playing. -** -** If mode = 1 then it will return the current track length (in seconds). -** Will return -1 if there are no tracks (or possibly if Winamp cannot get the length). -** -** If mode = 2 then it will return the current track length (in milliseconds). -** Will return -1 if there are no tracks (or possibly if Winamp cannot get the length). -*/ - - -#define IPC_JUMPTOTIME 106 -/* (requires Winamp 1.60+) -** SendMessage(hwnd_winamp,WM_WA_IPC,ms,IPC_JUMPTOTIME); -** This api sets the current position (in milliseconds) for the currently playing song. -** The resulting playback position may only be an approximate time since some playback -** formats do not provide exact seeking e.g. mp3 -** This returns -1 if Winamp is not playing, 1 on end of file, or 0 if it was successful. -*/ - - -#define IPC_GETMODULENAME 109 -#define IPC_EX_ISRIGHTEXE 666 -/* usually shouldnt bother using these, but here goes: -** send a WM_COPYDATA with IPC_GETMODULENAME, and an internal -** flag gets set, which if you send a normal WM_WA_IPC message with -** IPC_EX_ISRIGHTEXE, it returns whether or not that filename -** matches. lame, I know. -*/ - - -#define IPC_WRITEPLAYLIST 120 -/* (requires Winamp 1.666+) -** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_WRITEPLAYLIST); -** -** IPC_WRITEPLAYLIST will write the current playlist to '\\Winamp.m3u' and -** will also return the current playlist position (see IPC_GETLISTPOS). -** -** This is kinda obsoleted by some of the newer 2.x api items but it still is good for -** use with a front-end program (instead of a plug-in) and you want to see what is in the -** current playlist. -** -** This api will only save out extended file information in the #EXTINF entry if Winamp -** has already read the data such as if the file was played of scrolled into view. If -** Winamp has not read the data then you will only find the file with its filepath entry -** (as is the base requirements for a m3u playlist). -*/ - - -#define IPC_SETPLAYLISTPOS 121 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,position,IPC_SETPLAYLISTPOS) -** IPC_SETPLAYLISTPOS sets the playlist position to the specified 'position'. -** It will not change playback status or anything else. It will just set the current -** position in the playlist and will update the playlist view if necessary. -** -** If you use SendMessage(hwnd_winamp,WM_COMMAND,MAKEWPARAM(WINAMP_BUTTON2,0),0); -** after using IPC_SETPLAYLISTPOS then Winamp will start playing the file at 'position'. -*/ - - -#define IPC_SETVOLUME 122 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,volume,IPC_SETVOLUME); -** IPC_SETVOLUME sets the volume of Winamp (between the range of 0 to 255). -** -** If you pass 'volume' as -666 then the message will return the current volume. -** int curvol = SendMessage(hwnd_winamp,WM_WA_IPC,-666,IPC_SETVOLUME); -*/ - - -#define IPC_GETVOLUME(hwnd_winamp) SendMessage(hwnd_winamp,WM_WA_IPC,-666,IPC_SETVOLUME) -/* (requires Winamp 2.0+) -** int curvol = IPC_GETVOLUME(hwnd_winamp); -** This will return the current volume of Winamp or -*/ - - -#define IPC_SETPANNING 123 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,panning,IPC_SETPANNING); -** IPC_SETPANNING sets the panning of Winamp from 0 (left) to 255 (right). -** -** At least in 5.x+ this works from -127 (left) to 127 (right). -** -** If you pass 'panning' as -666 to this api then it will return the current panning. -** int curpan = SendMessage(hwnd_winamp,WM_WA_IPC,-666,IPC_SETPANNING); -*/ - - -#define IPC_GETLISTLENGTH 124 -/* (requires Winamp 2.0+) -** int length = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTLENGTH); -** IPC_GETLISTLENGTH returns the length of the current playlist as the number of tracks. -*/ - - -#define IPC_GETLISTPOS 125 -/* (requires Winamp 2.05+) -** int pos=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS); -** IPC_GETLISTPOS returns the current playlist position (which is shown in the playlist -** editor as a differently coloured text entry e.g is yellow for the classic skin). -** -** This api is a lot like IPC_WRITEPLAYLIST but a lot faster since it does not have to -** write out the whole of the current playlist first. -*/ - - -#define IPC_GETINFO 126 -/* (requires Winamp 2.05+) -** int inf=SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETINFO); -** IPC_GETINFO returns info about the current playing song. The value -** it returns depends on the value of 'mode'. -** Mode Meaning -** ------------------ -** 0 Samplerate, in kilohertz (i.e. 44) -** 1 Bitrate (i.e. 128) -** 2 Channels (i.e. 2) -** 3 (5+) Video LOWORD=w HIWORD=h -** 4 (5+) > 65536, string (video description) -** 5 (5.25+) Samplerate, in hertz (i.e. 44100) -*/ - - -#define IPC_GETEQDATA 127 -/* (requires Winamp 2.05+) -** int data=SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); -** IPC_GETEQDATA queries the status of the EQ. -** The value returned depends on what 'pos' is set to: -** Value Meaning -** ------------------ -** 0-9 The 10 bands of EQ data. 0-63 (+20db - -20db) -** 10 The preamp value. 0-63 (+20db - -20db) -** 11 Enabled. zero if disabled, nonzero if enabled. -** 12 Autoload. zero if disabled, nonzero if enabled. -*/ - - -#define IPC_SETEQDATA 128 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SETEQDATA); -** IPC_SETEQDATA sets the value of the last position retrieved -** by IPC_GETEQDATA. This is pretty lame, and we should provide -** an extended version that lets you do a MAKELPARAM(pos,value). -** someday... - - new (2.92+): - if the high byte is set to 0xDB, then the third byte specifies - which band, and the bottom word specifies the value. -*/ - - -#define IPC_ADDBOOKMARK 129 -#define IPC_ADDBOOKMARKW 131 -/* (requires Winamp 2.4+) -** This is sent as a WM_COPYDATA using IPC_ADDBOOKMARK as the dwData value and the -** directory you want to change to as the lpData member. This will add the specified -** file / url to the Winamp bookmark list. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_ADDBOOKMARK; -** cds.lpData = (void*)"http://www.blah.com/listen.pls"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -** -** -** In Winamp 5.0+ we use this as a normal WM_WA_IPC and the string is null separated as -** the filename and then the title of the entry. -** -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(char*)"filename\0title\0",IPC_ADDBOOKMARK); -** -** This will notify the library / bookmark editor that a bookmark was added. -** Note that using this message in this context does not actually add the bookmark. -** Do not use, it is essentially just a notification type message :) -*/ - - -#define IPC_INSTALLPLUGIN 130 -/* This is not implemented (and is very unlikely to be done due to safety concerns). -** If it was then you could do a WM_COPYDATA with a path to a .wpz and it would then -** install the plugin for you. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_INSTALLPLUGIN; -** cds.lpData = (void*)"c:\\path\\to\\file.wpz"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -*/ - - -#define IPC_RESTARTWINAMP 135 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_RESTARTWINAMP); -** IPC_RESTARTWINAMP will restart Winamp (isn't that obvious ? :) ) -** If this fails to make Winamp start after closing then there is a good chance one (or -** more) of the currently installed plugins caused Winamp to crash on exit (either as a -** silent crash or a full crash log report before it could call itself start again. -*/ - - -#define IPC_ISFULLSTOP 400 -/* (requires winamp 2.7+ I think) -** int ret=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISFULLSTOP); -** This is useful for when you're an output plugin and you want to see if the stop/close -** happening is a full stop or if you are just between tracks. This returns non zero if -** it is a full stop or zero if it is just a new track. -** benski> i think it's actually the other way around - -** !0 for EOF and 0 for user pressing stop -*/ - - -#define IPC_INETAVAILABLE 242 -/* (requires Winamp 2.05+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_INETAVAILABLE); -** IPC_INETAVAILABLE will return 1 if an Internet connection is available for Winamp and -** relates to the internet connection type setting on the main general preferences page -** in the Winamp preferences. -*/ - - -#define IPC_UPDTITLE 243 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_UPDTITLE); -** IPC_UPDTITLE will ask Winamp to update the information about the current title and -** causes GetFileInfo(..) in the input plugin associated with the current playlist entry -** to be called. This can be called such as when an input plugin is buffering a file so -** that it can cause the buffer percentage to appear in the playlist. -*/ - - -#define IPC_REFRESHPLCACHE 247 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_REFRESHPLCACHE); -** IPC_REFRESHPLCACHE will flush the playlist cache buffer and you send this if you want -** Winamp to go refetch the titles for all of the entries in the current playlist. -** -** 5.3+: pass a wchar_t * string in wParam, and it'll do a strnicmp() before clearing the cache -*/ - - -#define IPC_GET_SHUFFLE 250 -/* (requires Winamp 2.4+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_SHUFFLE); -** IPC_GET_SHUFFLE returns the status of the shuffle option. -** If set then it will return 1 and if not set then it will return 0. -*/ - - -#define IPC_GET_REPEAT 251 -/* (requires Winamp 2.4+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_REPEAT); -** IPC_GET_REPEAT returns the status of the repeat option. -** If set then it will return 1 and if not set then it will return 0. -*/ - - -#define IPC_SET_SHUFFLE 252 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_SHUFFLE); -** IPC_SET_SHUFFLE sets the status of the shuffle option. -** If 'value' is 1 then shuffle is turned on. -** If 'value' is 0 then shuffle is turned off. -*/ - - -#define IPC_SET_REPEAT 253 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_REPEAT); -** IPC_SET_REPEAT sets the status of the repeat option. -** If 'value' is 1 then shuffle is turned on. -** If 'value' is 0 then shuffle is turned off. -*/ - - -#define IPC_ENABLEDISABLE_ALL_WINDOWS 259 // 0xdeadbeef to disable -/* (requires Winamp 2.9+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(enable?0:0xdeadbeef),IPC_ENABLEDISABLE_ALL_WINDOWS); -** Sending this message with 0xdeadbeef as the param will disable all winamp windows and -** any other values will enable all of the Winamp windows again. When disabled you won't -** get any response on clicking or trying to do anything to the Winamp windows. If the -** taskbar icon is shown then you may still have control ;) -*/ - - -#define IPC_GETWND 260 -/* (requires Winamp 2.9+) -** HWND h=SendMessage(hwnd_winamp,WM_WA_IPC,IPC_GETWND_xxx,IPC_GETWND); -** returns the HWND of the window specified. -*/ - #define IPC_GETWND_EQ 0 // use one of these for the param - #define IPC_GETWND_PE 1 - #define IPC_GETWND_MB 2 - #define IPC_GETWND_VIDEO 3 -#define IPC_ISWNDVISIBLE 261 // same param as IPC_GETWND - - -/************************************************************************ -***************** in-process only (WE LOVE PLUGINS) -************************************************************************/ - -#define IPC_SETSKINW 199 -#define IPC_SETSKIN 200 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"skinname",IPC_SETSKIN); -** IPC_SETSKIN sets the current skin to "skinname". Note that skinname -** can be the name of a skin, a skin .zip file, with or without path. -** If path isn't specified, the default search path is the winamp skins -** directory. -*/ - - -#define IPC_GETSKIN 201 -#define IPC_GETSKINW 1201 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)skinname_buffer,IPC_GETSKIN); -** IPC_GETSKIN puts the directory where skin bitmaps can be found -** into skinname_buffer. -** skinname_buffer must be MAX_PATH characters in length. -** When using a .zip'd skin file, it'll return a temporary directory -** where the ZIP was decompressed. -*/ - - -#define IPC_EXECPLUG 202 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"vis_file.dll",IPC_EXECPLUG); -** IPC_EXECPLUG executes a visualization plug-in pointed to by WPARAM. -** the format of this string can be: -** "vis_whatever.dll" -** "vis_whatever.dll,0" // (first mod, file in winamp plug-in dir) -** "C:\\dir\\vis_whatever.dll,1" -*/ - - -#define IPC_GETPLAYLISTFILE 211 -#define IPC_GETPLAYLISTFILEW 214 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTFILE); -** IPC_GETPLAYLISTFILE gets the filename of the playlist entry [index]. -** returns a pointer to it. returns NULL on error. -*/ - - -#define IPC_GETPLAYLISTTITLE 212 -#define IPC_GETPLAYLISTTITLEW 213 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTTITLE); -** -** IPC_GETPLAYLISTTITLE gets the title of the playlist entry [index]. -** returns a pointer to it. returns NULL on error. -*/ - - -#define IPC_GETHTTPGETTER 240 -/* retrieves a function pointer to a HTTP retrieval function. -** if this is unsupported, returns 1 or 0. -** the function should be: -** int (*httpRetrieveFile)(HWND hwnd, char *url, char *file, char *dlgtitle); -** if you call this function, with a parent window, a URL, an output file, and a dialog title, -** it will return 0 on successful download, 1 on error. -*/ - - -#define IPC_GETHTTPGETTERW 1240 -/* int (*httpRetrieveFileW)(HWND hwnd, char *url, wchar_t *file, wchar_t *dlgtitle); */ - - -#define IPC_MBOPEN 241 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_MBOPEN); -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPEN); -** IPC_MBOPEN will open a new URL in the minibrowser. if url is NULL, it will open the Minibrowser window. -*/ - - -#define IPC_CHANGECURRENTFILE 245 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)file,IPC_CHANGECURRENTFILE); -** IPC_CHANGECURRENTFILE will set the current playlist item. -*/ - - -#define IPC_CHANGECURRENTFILEW 1245 -/* (requires Winamp 5.3+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)file,IPC_CHANGECURRENTFILEW); -** IPC_CHANGECURRENTFILEW will set the current playlist item. -*/ - - -#define IPC_GETMBURL 246 -/* (requires Winamp 2.2+) -** char buffer[4096]; // Urls can be VERY long -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)buffer,IPC_GETMBURL); -** IPC_GETMBURL will retrieve the current Minibrowser URL into buffer. -** buffer must be at least 4096 bytes long. -*/ - - -#define IPC_MBBLOCK 248 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_MBBLOCK); -** -** IPC_MBBLOCK will block the Minibrowser from updates if value is set to 1 -*/ - - -#define IPC_MBOPENREAL 249 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPENREAL); -** -** IPC_MBOPENREAL works the same as IPC_MBOPEN except that it will works even if -** IPC_MBBLOCK has been set to 1 -*/ - - -#define IPC_ADJUST_OPTIONSMENUPOS 280 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_OPTIONSMENUPOS); -** moves where winamp expects the Options menu in the main menu. Useful if you wish to insert a -** menu item above the options/skins/vis menus. -*/ - - -#define IPC_GET_HMENU 281 -/* (requires Winamp 2.9+) -** HMENU hMenu=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_HMENU); -** values for data: -** 0 : main popup menu -** 1 : main menubar file menu -** 2 : main menubar options menu -** 3 : main menubar windows menu -** 4 : main menubar help menu -** other values will return NULL. -*/ - - -#define IPC_GET_EXTENDED_FILE_INFO 290 //pass a pointer to the following struct in wParam -#define IPC_GET_EXTENDED_FILE_INFO_HOOKABLE 296 -/* (requires Winamp 2.9+) -** to use, create an extendedFileInfoStruct, point the values filename and metadata to the -** filename and metadata field you wish to query, and ret to a buffer, with retlen to the -** length of that buffer, and then SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_GET_EXTENDED_FILE_INFO); -** the results should be in the buffer pointed to by ret. -** returns 1 if the decoder supports a getExtendedFileInfo method -*/ -typedef struct { - const char *filename; - const char *metadata; - char *ret; - size_t retlen; -} extendedFileInfoStruct; - - -#define IPC_GET_BASIC_FILE_INFO 291 //pass a pointer to the following struct in wParam -typedef struct { - const char *filename; - - int quickCheck; // set to 0 to always get, 1 for quick, 2 for default (if 2, quickCheck will be set to 0 if quick wasnot used) - - // filled in by winamp - int length; - char *title; - int titlelen; -} basicFileInfoStruct; - - -#define IPC_GET_BASIC_FILE_INFOW 1291 //pass a pointer to the following struct in wParam -typedef struct { - const wchar_t *filename; - - int quickCheck; // set to 0 to always get, 1 for quick, 2 for default (if 2, quickCheck will be set to 0 if quick wasnot used) - - // filled in by winamp - int length; - wchar_t *title; - int titlelen; -} basicFileInfoStructW; - - -#define IPC_GET_EXTLIST 292 //returns doublenull delimited. GlobalFree() it when done. if data is 0, returns raw extlist, if 1, returns something suitable for getopenfilename -#define IPC_GET_EXTLISTW 1292 // wide char version of above - - -#define IPC_INFOBOX 293 -typedef struct { - HWND parent; - char *filename; -} infoBoxParam; - - -#define IPC_INFOBOXW 1293 -typedef struct { - HWND parent; - const wchar_t *filename; -} infoBoxParamW; - - -#define IPC_SET_EXTENDED_FILE_INFO 294 //pass a pointer to the a extendedFileInfoStruct in wParam -/* (requires Winamp 2.9+) -** to use, create an extendedFileInfoStruct, point the values filename and metadata to the -** filename and metadata field you wish to write in ret. (retlen is not used). and then -** SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_SET_EXTENDED_FILE_INFO); -** returns 1 if the metadata is supported -** Call IPC_WRITE_EXTENDED_FILE_INFO once you're done setting all the metadata you want to update -*/ - - -#define IPC_WRITE_EXTENDED_FILE_INFO 295 -/* (requires Winamp 2.9+) -** writes all the metadata set thru IPC_SET_EXTENDED_FILE_INFO to the file -** returns 1 if the file has been successfully updated, 0 if error -*/ - - -#define IPC_FORMAT_TITLE 297 -typedef struct -{ - char *spec; // NULL=default winamp spec - void *p; - - char *out; - int out_len; - - char * (*TAGFUNC)(const char * tag, void * p); //return 0 if not found - void (*TAGFREEFUNC)(char * tag,void * p); -} waFormatTitle; - - -#define IPC_FORMAT_TITLE_EXTENDED 298 // similiar to IPC_FORMAT_TITLE, but falls back to Winamp's %tags% if your passed tag function doesn't handle it -typedef struct -{ - const wchar_t *filename; - int useExtendedInfo; // set to 1 if you want the Title Formatter to query the input plugins for any tags that your tag function fails on - const wchar_t *spec; // NULL=default winamp spec - void *p; - - wchar_t *out; - int out_len; - - wchar_t * (*TAGFUNC)(const wchar_t * tag, void * p); //return 0 if not found, -1 for empty tag - void (*TAGFREEFUNC)(wchar_t *tag, void *p); -} waFormatTitleExtended; - - -#define IPC_COPY_EXTENDED_FILE_INFO 299 -typedef struct -{ - const char *source; - const char *dest; -} copyFileInfoStruct; - - -#define IPC_COPY_EXTENDED_FILE_INFOW 1299 -typedef struct -{ - const wchar_t *source; - const wchar_t *dest; -} copyFileInfoStructW; - - -typedef struct { - int (*inflateReset)(void *strm); - int (*inflateInit_)(void *strm,const char *version, int stream_size); - int (*inflate)(void *strm, int flush); - int (*inflateEnd)(void *strm); - unsigned long (*crc32)(unsigned long crc, const unsigned char *buf, unsigned int len); -} wa_inflate_struct; - -#define IPC_GETUNCOMPRESSINTERFACE 331 -/* returns a function pointer to uncompress(). -** int (*uncompress)(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen); -** right out of zlib, useful for decompressing zlibbed data. -** if you pass the parm of 0x10100000, it will return a wa_inflate_struct * to an inflate API. -*/ - - -typedef struct _prefsDlgRec { - HINSTANCE hInst; // dll instance containing the dialog resource - int dlgID; // resource identifier of the dialog - void *proc; // window proceedure for handling the dialog defined as - // LRESULT CALLBACK PrefsPage(HWND,UINT,WPARAM,LPARAM) - - char *name; // name shown for the prefs page in the treelist - intptr_t where; // section in the treelist the prefs page is to be added to - // 0 for General Preferences - // 1 for Plugins - // 2 for Skins - // 3 for Bookmarks (no longer in the 5.0+ prefs) - // 4 for Prefs (the old 'Setup' section - no longer in 5.0+) - - intptr_t _id; - struct _prefsDlgRec *next; // no longer implemented as a linked list, now used by Winamp for other means -} prefsDlgRec; - -typedef struct _prefsDlgRecW { - HINSTANCE hInst; // dll instance containing the dialog resource - int dlgID; // resource identifier of the dialog - void *proc; // window proceedure for handling the dialog defined as - // LRESULT CALLBACK PrefsPage(HWND,UINT,WPARAM,LPARAM) - - wchar_t *name; // name shown for the prefs page in the treelist - intptr_t where; // section in the treelist the prefs page is to be added to - // 0 for General Preferences - // 1 for Plugins - // 2 for Skins - // 3 for Bookmarks (no longer in the 5.0+ prefs) - // 4 for Prefs (the old 'Setup' section - no longer in 5.0+) - - intptr_t _id; - struct _prefsDlgRec *next; // no longer implemented as a linked list, now used by Winamp for other means -} prefsDlgRecW; - -#define IPC_ADD_PREFS_DLG 332 -#define IPC_ADD_PREFS_DLGW 1332 -#define IPC_REMOVE_PREFS_DLG 333 -/* (requires Winamp 2.9+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&prefsRec,IPC_ADD_PREFS_DLG); -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&prefsRec,IPC_REMOVE_PREFS_DLG); -** -** IPC_ADD_PREFS_DLG: -** To use this you need to allocate a prefsDlgRec structure (either on the heap or with -** some global data but NOT on the stack) and then initialise the members of the structure -** (see the definition of the prefsDlgRec structure above). -** -** hInst - dll instance of where the dialog resource is located. -** dlgID - id of the dialog resource. -** proc - dialog window procedure for the prefs dialog. -** name - name of the prefs page as shown in the preferences list. -** where - see above for the valid locations the page can be added. -** -** Then you do SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&prefsRec,IPC_ADD_PREFS_DLG); -** -** example: -** -** prefsDlgRec* prefsRec = 0; -** prefsRec = GlobalAlloc(GPTR,sizeof(prefsDlgRec)); -** prefsRec->hInst = hInst; -** prefsRec->dlgID = IDD_PREFDIALOG; -** prefsRec->name = "Pref Page"; -** prefsRec->where = 0; -** prefsRec->proc = PrefsPage; -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&prefsRec,IPC_ADD_PREFS_DLG); -** -** -** IPC_REMOVE_PREFS_DLG: -** To use you pass the address of the same prefsRec you used when adding the prefs page -** though you shouldn't really ever have to do this but it's good to clean up after you -** when you're plugin is being unloaded. -** -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&prefsRec,IPC_REMOVE_PREFS_DLG); -** -** IPC_ADD_PREFS_DLGW -** requires Winamp 5.53+ -*/ - - -#define IPC_OPENPREFSTOPAGE 380 -/* SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&prefsRec,IPC_OPENPREFSTOPAGE); -** -** There are two ways of opening a preferences page. -** -** The first is to pass an id of a builtin preferences page (see below for ids) or a -** &prefsDlgRec of the preferences page to open and this is normally done if you are -** opening a prefs page you added yourself. -** -** If the page id does not or the &prefsRec is not valid then the prefs dialog will be -** opened to the first page available (usually the Winamp Pro page). -** -** (requires Winamp 5.04+) -** Passing -1 for param will open the preferences dialog to the last page viewed. -** -** Note: v5.0 to 5.03 had a bug in this api -** -** On the first call then the correct prefs page would be opened to but on the next call -** the prefs dialog would be brought to the front but the page would not be changed to the -** specified. -** In 5.04+ it will change to the prefs page specified if the prefs dialog is already open. -*/ - -/* Builtin Preference page ids (valid for 5.0+) -** (stored in the lParam member of the TVITEM structure from the tree item) -** -** These can be useful if you want to detect a specific prefs page and add things to it -** yourself or something like that ;) -** -** Winamp Pro 20 -** General Preferences 0 -** File Types 1 -** Playlist 23 -** Titles 21 -** Playback 42 (added in 5.25) -** Station Info 41 (added in 5.11 & removed in 5.5) -** Video 24 -** Localization 25 (added in 5.5) -** Skins 40 -** Classic Skins 22 -** Plugins 30 -** Input 31 -** Output 32 -** Visualisation 33 -** DSP/Effect 34 -** General Purpose 35 -** -** Note: -** Custom page ids begin from 60 -** The value of the normal custom pages (Global Hotkeys, Jump To File, etc) is not -** guaranteed since it depends on the order in which the plugins are loaded which can -** change on different systems. -** -** Global Hotkeys, Jump To File, Media Library (under General Preferences and child pages), -** Media Library (under Plugins), Portables, CD Ripping and Modern Skins are custom pages -** created by the plugins shipped with Winamp. -*/ - - -#define IPC_GETINIFILE 334 -/* (requires Winamp 2.9+) -** char *ini=(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETINIFILE); -** This returns a pointer to the full file path of winamp.ini. -** -** char ini_path[MAX_PATH] = {0}; -** -** void GetIniFilePath(HWND hwnd){ -** if(SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION) >= 0x2900){ -** // this gets the string of the full ini file path -** lstrcpyn(ini_path,(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETINIFILE),sizeof(ini_path)); -** } -** else{ -** char* p = ini_path; -** p += GetModuleFileName(0,ini_path,sizeof(ini_path)) - 1; -** while(p && *p != '.'){p--;} -** lstrcpyn(p+1,"ini",sizeof(ini_path)); -** } -** } -*/ - - -#define IPC_GETINIDIRECTORY 335 -/* (requires Winamp 2.9+) -** char *dir=(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETINIDIRECTORY); -** This returns a pointer to the directory where winamp.ini can be found and is -** useful if you want store config files but you don't want to use winamp.ini. -*/ - - -#define IPC_GETPLUGINDIRECTORY 336 -/* (requires Winamp 5.11+) -** char *plugdir=(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETPLUGINDIRECTORY); -** This returns a pointer to the directory where Winamp has its plugins stored and is -** useful if you want store config files in plugins.ini in the plugins folder or for -** accessing any local files in the plugins folder. -*/ - - -#define IPC_GETM3UDIRECTORY 337 -/* (requires Winamp 5.11+) -** char *m3udir=(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETM3UDIRECTORY); -** This returns a pointer to the directory where winamp.m3u (and winamp.m3u8 if supported) is stored in. -*/ - - -#define IPC_GETM3UDIRECTORYW 338 -/* (requires Winamp 5.3+) -** wchar_t *m3udirW=(wchar_t*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETM3UDIRECTORYW); -** This returns a pointer to the directory where winamp.m3u (and winamp.m3u8 if supported) is stored in. -*/ - - -#define IPC_SPAWNBUTTONPOPUP 361 // param = -// 0 = eject -// 1 = previous -// 2 = next -// 3 = pause -// 4 = play -// 5 = stop - - -#define IPC_OPENURLBOX 360 -/* (requires Winamp 5.0+) -** HGLOBAL hglobal = (HGLOBAL)SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(HWND)parent,IPC_OPENURLBOX); -** You pass a hwnd for the dialog to be parented to (which modern skin support uses). -** This will return a HGLOBAL that needs to be freed with GlobalFree() if this worked. -*/ - - -#define IPC_OPENFILEBOX 362 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(HWND)parent,IPC_OPENFILEBOX); -** You pass a hwnd for the dialog to be parented to (which modern skin support uses). -*/ - - -#define IPC_OPENDIRBOX 363 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(HWND)parent,IPC_OPENDIRBOX); -** You pass a hwnd for the dialog to be parented to (which modern skin support uses). -*/ - - -#define IPC_SETDIALOGBOXPARENT 364 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(HWND)parent,IPC_SETDIALOGBOXPARENT); -** Pass 'parent' as the window which will be used as the parent for a number of the built -** in Winamp dialogs and is useful when you are taking over the whole of the UI so that -** the dialogs will not appear at the bottom right of the screen since the main winamp -** window is located at 3000x3000 by gen_ff when this is used. Call this again with -** parent = null to reset the parent back to the orginal Winamp window. -*/ - -#define IPC_GETDIALOGBOXPARENT 365 -/* (requires Winamp 5.51+) -** HWND hwndParent = SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)0, IPC_GETDIALOGBOXPARENT); -** hwndParent can/must be passed to all modal dialogs (including MessageBox) thats uses winamp as a parent -*/ - -#define IPC_UPDATEDIALOGBOXPARENT 366 -/* (requires Winamp 5.53+) -** if you previous called IPC_SETDIALOGBOXPARENT, call this every time your window resizes -*/ - -#define IPC_DRO_MIN 401 // reserved for DrO -#define IPC_SET_JTF_COMPARATOR 409 -/* pass me an int (__cdecl *)(const char *, const char *) in wParam */ -#define IPC_SET_JTF_COMPARATOR_W 410 -/* pass me an int (__cdecl *)(const wchar_t *, const wchar_t *) in wParam ... maybe someday :) */ -#define IPC_SET_JTF_DRAWTEXT 416 - -#define IPC_DRO_MAX 499 - - -// pass 0 for a copy of the skin HBITMAP -// pass 1 for name of font to use for playlist editor likeness -// pass 2 for font charset -// pass 3 for font size -#define IPC_GET_GENSKINBITMAP 503 - - -typedef struct -{ - HWND me; //hwnd of the window - - #define EMBED_FLAGS_NORESIZE 0x1 - // set this bit to keep window from being resizable - - #define EMBED_FLAGS_NOTRANSPARENCY 0x2 - // set this bit to make gen_ff turn transparency off for this window - - #define EMBED_FLAGS_NOWINDOWMENU 0x4 - // set this bit to prevent gen_ff from automatically adding your window to the right-click menu - - #define EMBED_FLAGS_GUID 0x8 - // (5.31+) call SET_EMBED_GUID(yourEmbedWindowStateStruct, GUID) to define a GUID for this window - - #define SET_EMBED_GUID(windowState, windowGUID) { windowState->flags |= EMBED_FLAGS_GUID; *((GUID *)&windowState->extra_data[4])=windowGUID; } - #define GET_EMBED_GUID(windowState) (*((GUID *)&windowState->extra_data[4])) - - int flags; // see above - - RECT r; - void *user_ptr; // for application use - int extra_data[64]; // for internal winamp use -} embedWindowState; - -#define IPC_GET_EMBEDIF 505 -/* (requires Winamp 2.9+) -** HWND myframe = (HWND)SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&wa_wnd,IPC_GET_EMBEDIF); -** -** or -** -** HWND myframe = 0; -** HWND (*embed)(embedWindowState *params)=0; -** *(void**)&embed = (void*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_EMBEDIF); -** myframe = embed(&wa_wnd); -** -** You pass an embedWindowState* and it will return a hwnd for the frame window or if you -** pass wParam as null then it will return a HWND embedWindow(embedWindowState *); -*/ - -#define IPC_SKINWINDOW 534 - -typedef struct __SKINWINDOWPARAM -{ - HWND hwndToSkin; - GUID windowGuid; -} SKINWINDOWPARAM; - - - -#define IPC_EMBED_ENUM 532 -typedef struct embedEnumStruct -{ - int (*enumProc)(embedWindowState *ws, struct embedEnumStruct *param); // return 1 to abort - int user_data; // or more :) -} embedEnumStruct; - // pass - - -#define IPC_EMBED_ISVALID 533 -/* (requires Winamp 2.9+) -** int valid = SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)embedhwnd,IPC_EMBED_ISVALID); -** Pass a hwnd in the wParam to this to check if the hwnd is a valid embed window or not. -*/ - - -#define IPC_CONVERTFILE 506 -/* (requires Winamp 2.92+) -** Converts a given file to a different format (PCM, MP3, etc...) -** To use, pass a pointer to a waFileConvertStruct struct -** This struct can be either on the heap or some global -** data, but NOT on the stack. At least, until the conversion is done. -** -** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE); -** -** Return value: -** 0: Can't start the conversion. Look at myConvertStruct->error for details. -** 1: Conversion started. Status messages will be sent to the specified callbackhwnd. -** Be sure to call IPC_CONVERTFILE_END when your callback window receives the -** IPC_CB_CONVERT_DONE message. -*/ -typedef struct -{ - char *sourcefile; // "c:\\source.mp3" - char *destfile; // "c:\\dest.pcm" - intptr_t destformat[8]; // like 'PCM ',srate,nch,bps. - //hack alert! you can set destformat[6]=mmioFOURCC('I','N','I',' '); and destformat[7]=(int)my_ini_file; (where my_ini_file is a char*) - HWND callbackhwnd; // window that will receive the IPC_CB_CONVERT notification messages - - //filled in by winamp.exe - char *error; //if IPC_CONVERTFILE returns 0, the reason will be here - - int bytes_done; //you can look at both of these values for speed statistics - int bytes_total; - int bytes_out; - - int killswitch; // don't set it manually, use IPC_CONVERTFILE_END - intptr_t extra_data[64]; // for internal winamp use -} convertFileStruct; - - -#define IPC_CONVERTFILEW 515 -// (requires Winamp 5.36+) -typedef struct -{ - wchar_t *sourcefile; // "c:\\source.mp3" - wchar_t *destfile; // "c:\\dest.pcm" - intptr_t destformat[8]; // like 'PCM ',srate,nch,bps. - //hack alert! you can set destformat[6]=mmioFOURCC('I','N','I',' '); and destformat[7]=(int)my_ini_file; (where my_ini_file is a char*) - HWND callbackhwnd; // window that will receive the IPC_CB_CONVERT notification messages - - //filled in by winamp.exe - wchar_t *error; //if IPC_CONVERTFILE returns 0, the reason will be here - - int bytes_done; //you can look at both of these values for speed statistics - int bytes_total; - int bytes_out; - - int killswitch; // don't set it manually, use IPC_CONVERTFILE_END - intptr_t extra_data[64]; // for internal winamp use -} convertFileStructW; - - -#define IPC_CONVERTFILE_END 507 -/* (requires Winamp 2.92+) -** Stop/ends a convert process started from IPC_CONVERTFILE -** You need to call this when you receive the IPC_CB_CONVERTDONE message or when you -** want to abort a conversion process -** -** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE_END); -** -** No return value -*/ - - -#define IPC_CONVERTFILEW_END 516 -// (requires Winamp 5.36+) - -typedef struct { - HWND hwndParent; - int format; - - //filled in by winamp.exe - HWND hwndConfig; - int extra_data[8]; - //hack alert! you can set extra_data[6]=mmioFOURCC('I','N','I',' '); and extra_data[7]=(int)my_ini_file; (where my_ini_file is a char*) -} convertConfigStruct; - - -#define IPC_CONVERT_CONFIG 508 -#define IPC_CONVERT_CONFIG_END 509 - -typedef struct -{ - void (*enumProc)(intptr_t user_data, const char *desc, int fourcc); - intptr_t user_data; -} converterEnumFmtStruct; -#define IPC_CONVERT_CONFIG_ENUMFMTS 510 -/* (requires Winamp 2.92+) -*/ - -typedef struct -{ - char cdletter; - char *playlist_file; - HWND callback_hwnd; - - //filled in by winamp.exe - char *error; -} burnCDStruct; -#define IPC_BURN_CD 511 -/* (requires Winamp 5.0+) -*/ - -typedef struct -{ - convertFileStruct *cfs; - int priority; -} convertSetPriority; - - -#define IPC_CONVERT_SET_PRIORITY 512 - -typedef struct -{ - convertFileStructW *cfs; - int priority; -} convertSetPriorityW; - - -#define IPC_CONVERT_SET_PRIORITYW 517 -// (requires Winamp 5.36+) - -typedef struct -{ - unsigned int format; //fourcc value - char *item; // config item, eg "bitrate" - char *data; // buffer to recieve, or buffer that contains the data - int len; // length of the data buffer (only used when getting a config item) - char *configfile; // config file to read from -} convertConfigItem; - - -#define IPC_CONVERT_CONFIG_SET_ITEM 513 // returns TRUE if successful -#define IPC_CONVERT_CONFIG_GET_ITEM 514 // returns TRUE if successful - - -typedef struct -{ - const char *filename; - char *title; // 2048 bytes - int length; - int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit -} waHookTitleStruct; - -#define IPC_HOOK_TITLES 850 -/* (requires Winamp 5.0+) -** If you hook this message and modify the information then make sure to return TRUE. -** If you don't hook the message then make sure you pass it on through the subclass chain. -** -** LRESULT CALLBACK WinampWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) -** { -** LRESULT ret = CallWindowProc((WNDPROC)WinampProc,hwnd,umsg,wParam,lParam); -** -** if(message==WM_WA_IPC && lParam==IPC_HOOK_TITLES) -** { -** waHookTitleStruct *ht = (waHookTitleStruct *) wParam; -** // Doing ATF stuff with ht->title, whatever... -** return TRUE; -** } -** return ret; -** } -*/ - -typedef struct -{ - const wchar_t *filename; - wchar_t *title; // 2048 characters - int length; - int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit -} waHookTitleStructW; -#define IPC_HOOK_TITLESW 851 -/* (requires Winamp 5.3+) -** See information on IPC_HOOK_TITLES for how to process this. -*/ - - -#define IPC_GETSADATAFUNC 800 -// 0: returns a char *export_sa_get() that returns 150 bytes of data -// 1: returns a export_sa_setreq(int want); - - -#define IPC_GETVUDATAFUNC 801 -// 0: returns a int export_vu_get(int channel) that returns 0-255 (or -1 for bad channel) - - -#define IPC_ISMAINWNDVISIBLE 900 -/* (requires Winamp 5.0+) -** int visible=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISMAINWNDVISIBLE); -** You send this to Winamp to query if the main window is visible or not such as by -** unchecking the option in the main right-click menu. If the main window is visible then -** this will return 1 otherwise it returns 0. -*/ - - -typedef struct -{ - int numElems; - int *elems; - HBITMAP bm; // set if you want to override -} waSetPlColorsStruct; - -#define IPC_SETPLEDITCOLORS 920 -/* (requires Winamp 5.0+) -** This is sent by gen_ff when a modern skin is being loaded to set the colour scheme for -** the playlist editor. When sent numElems is usually 6 and matches with the 6 possible -** colours which are provided be pledit.txt from the classic skins. The elems array is -** defined as follows: -** -** elems = 0 => normal text -** elems = 1 => current text -** elems = 2 => normal background -** elems = 3 => selected background -** elems = 4 => minibroswer foreground -** elems = 5 => minibroswer background -** -** if(uMsg == WM_WA_IPC && lParam == IPC_SETPLEDITCOLORS) -** { -** waSetPlColorsStruct* colStr = (waSetPlColorsStruct*)wp; -** if(colStr) -** { -** // set or inspect the colours being used (basically for gen_ff's benefit) -** } -** } -*/ - - -typedef struct -{ - HWND wnd; - int xpos; // in screen coordinates - int ypos; -} waSpawnMenuParms; - -// waSpawnMenuParms2 is used by the menubar submenus -typedef struct -{ - HWND wnd; - int xpos; // in screen coordinates - int ypos; - int width; - int height; -} waSpawnMenuParms2; - -// the following IPC use waSpawnMenuParms as parameter -#define IPC_SPAWNEQPRESETMENU 933 -#define IPC_SPAWNFILEMENU 934 //menubar -#define IPC_SPAWNOPTIONSMENU 935 //menubar -#define IPC_SPAWNWINDOWSMENU 936 //menubar -#define IPC_SPAWNHELPMENU 937 //menubar -#define IPC_SPAWNPLAYMENU 938 //menubar -#define IPC_SPAWNPEFILEMENU 939 //menubar -#define IPC_SPAWNPEPLAYLISTMENU 940 //menubar -#define IPC_SPAWNPESORTMENU 941 //menubar -#define IPC_SPAWNPEHELPMENU 942 //menubar -#define IPC_SPAWNMLFILEMENU 943 //menubar -#define IPC_SPAWNMLVIEWMENU 944 //menubar -#define IPC_SPAWNMLHELPMENU 945 //menubar -#define IPC_SPAWNPELISTOFPLAYLISTS 946 - - -#define WM_WA_SYSTRAY WM_USER+1 -/* This is sent by the system tray when an event happens (you might want to simulate it). -** -** if(uMsg == WM_WA_SYSTRAY) -** { -** switch(lParam) -** { -** // process the messages sent from the tray -** } -** } -*/ - - -#define WM_WA_MPEG_EOF WM_USER+2 -/* Input plugins send this when they are done playing back the current file to inform -** Winamp or anyother installed plugins that the current -** -** if(uMsg == WM_WA_MPEG_EOF) -** { -** // do what is needed here -** } -*/ - - -//// video stuff - -#define IPC_IS_PLAYING_VIDEO 501 // returns >1 if playing, 0 if not, 1 if old version (so who knows):) -#define IPC_GET_IVIDEOOUTPUT 500 // see below for IVideoOutput interface -#define VIDEO_MAKETYPE(A,B,C,D) ((A) | ((B)<<8) | ((C)<<16) | ((D)<<24)) -#define VIDUSER_SET_INFOSTRING 0x1000 -#define VIDUSER_GET_VIDEOHWND 0x1001 -#define VIDUSER_SET_VFLIP 0x1002 -#define VIDUSER_SET_TRACKSELINTERFACE 0x1003 // give your ITrackSelector interface as param2 -#define VIDUSER_OPENVIDEORENDERER 0x1004 -#define VIDUSER_CLOSEVIDEORENDERER 0x1005 -#define VIDUSER_GETPOPUPMENU 0x1006 -#define VIDUSER_SET_INFOSTRINGW 0x1007 - -typedef struct -{ - int w; - int h; - int vflip; - double aspectratio; - unsigned int fmt; -} VideoOpenStruct; - -#ifndef NO_IVIDEO_DECLARE -#ifdef __cplusplus - -class VideoOutput; -class SubsItem; - -#ifndef _NSV_DEC_IF_H_ -struct YV12_PLANE { - unsigned char* baseAddr; - long rowBytes; -} ; - -struct YV12_PLANES { - YV12_PLANE y; - YV12_PLANE u; - YV12_PLANE v; -}; -#endif - -class IVideoOutput -{ - public: - virtual ~IVideoOutput() { } - virtual int open(int w, int h, int vflip, double aspectratio, unsigned int fmt)=0; - virtual void setcallback(LRESULT (*msgcallback)(void *token, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam), void *token) { (void)token; (void)msgcallback; /* to eliminate warning C4100 */ } - virtual void close()=0; - virtual void draw(void *frame)=0; - virtual void drawSubtitle(SubsItem *item) {UNREFERENCED_PARAMETER(item); } - virtual void showStatusMsg(const char *text) {UNREFERENCED_PARAMETER(text); } - virtual int get_latency() { return 0; } - virtual void notifyBufferState(int bufferstate) { UNREFERENCED_PARAMETER(bufferstate); } /* 0-255*/ - virtual INT_PTR extended(INT_PTR param1, INT_PTR param2, INT_PTR param3) { UNREFERENCED_PARAMETER(param1); UNREFERENCED_PARAMETER(param2); UNREFERENCED_PARAMETER(param3); return 0; } // Dispatchable, eat this! -}; - -class ITrackSelector -{ - public: - virtual int getNumAudioTracks()=0; - virtual void enumAudioTrackName(int n, const char *buf, int size)=0; - virtual int getCurAudioTrack()=0; - virtual int getNumVideoTracks()=0; - virtual void enumVideoTrackName(int n, const char *buf, int size)=0; - virtual int getCurVideoTrack()=0; - - virtual void setAudioTrack(int n)=0; - virtual void setVideoTrack(int n)=0; -}; - -#endif //cplusplus -#endif//NO_IVIDEO_DECLARE - -// these messages are callbacks that you can grab by subclassing the winamp window - -// wParam = -#define IPC_CB_WND_EQ 0 // use one of these for the param -#define IPC_CB_WND_PE 1 -#define IPC_CB_WND_MB 2 -#define IPC_CB_WND_VIDEO 3 -#define IPC_CB_WND_MAIN 4 - -#define IPC_CB_ONSHOWWND 600 -#define IPC_CB_ONHIDEWND 601 - -#define IPC_CB_GETTOOLTIP 602 - -#define IPC_CB_MISC 603 - #define IPC_CB_MISC_TITLE 0 // start of playing/stop/pause - #define IPC_CB_MISC_VOLUME 1 // volume/pan - #define IPC_CB_MISC_STATUS 2 // start playing/stop/pause/ffwd/rwd - #define IPC_CB_MISC_EQ 3 - #define IPC_CB_MISC_INFO 4 - #define IPC_CB_MISC_VIDEOINFO 5 - #define IPC_CB_MISC_TITLE_RATING 6 // (5.5+ for when the rating is changed via the songticker menu on current file) - -/* Example of using IPC_CB_MISC_STATUS to detect the start of track playback with 5.x -** -** if(lParam == IPC_CB_MISC && wParam == IPC_CB_MISC_STATUS) -** { -** if(SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING) == 1 && -** !SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETOUTPUTTIME)) -** { -** char* file = (char*)SendMessage(hwnd_winamp,WM_WA_IPC, -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS),IPC_GETPLAYLISTFILE); -** // only output if a valid file was found -** if(file) -** { -** MessageBox(hwnd_winamp,file,"starting",0); -** // or do something else that you need to do -** } -** } -** } -*/ - - -#define IPC_CB_CONVERT_STATUS 604 // param value goes from 0 to 100 (percent) -#define IPC_CB_CONVERT_DONE 605 - - -#define IPC_ADJUST_FFWINDOWSMENUPOS 606 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFWINDOWSMENUPOS); -** This will move where Winamp expects the freeform windows in the menubar windows main -** menu. This is useful if you wish to insert a menu item above extra freeform windows. -*/ - - -#define IPC_ISDOUBLESIZE 608 -/* (requires Winamp 5.0+) -** int dsize=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISDOUBLESIZE); -** You send this to Winamp to query if the double size mode is enabled or not. -** If it is on then this will return 1 otherwise it will return 0. -*/ - - -#define IPC_ADJUST_FFOPTIONSMENUPOS 609 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFOPTIONSMENUPOS); -** moves where winamp expects the freeform preferences item in the menubar windows main -** menu. This is useful if you wish to insert a menu item above the preferences item. -** -** Note: This setting was ignored by gen_ff until it was fixed in 5.1 -** gen_ff would assume thatthe menu position was 11 in all cases and so when you -** had two plugins attempting to add entries into the main right click menu it -** would cause the 'colour themes' submenu to either be incorrectly duplicated or -** to just disappear.instead. -*/ - - -#define IPC_GETTIMEDISPLAYMODE 610 -/* (requires Winamp 5.0+) -** int mode=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETTIMEDISPLAYMODE); -** This will return the status of the time display i.e. shows time elapsed or remaining. -** This returns 0 if Winamp is displaying time elapsed or 1 for the time remaining. -*/ - - -#define IPC_SETVISWND 611 -/* (requires Winamp 5.0+) -** int viswnd=(HWND)SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(HWND)viswnd,IPC_SETVISWND); -** This allows you to set a window to receive the following message commands (which are -** used as part of the modern skin integration). -** When you have finished or your visualisation is closed then send wParam as zero to -** ensure that things are correctly tidied up. -*/ - -/* The following messages are received as the LOWORD(wParam) of the WM_COMMAND message. -** See %SDK%\winamp\wa5vis.txt for more info about visualisation integration in Winamp. -*/ -#define ID_VIS_NEXT 40382 -#define ID_VIS_PREV 40383 -#define ID_VIS_RANDOM 40384 -#define ID_VIS_FS 40389 -#define ID_VIS_CFG 40390 -#define ID_VIS_MENU 40391 - - -#define IPC_GETVISWND 612 -/* (requires Winamp 5.0+) -** int viswnd=(HWND)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVISWND); -** This returns a HWND to the visualisation command handler window if set by IPC_SETVISWND. -*/ - - -#define IPC_ISVISRUNNING 613 -/* (requires Winamp 5.0+) -** int visrunning=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISVISRUNNING); -** This will return 1 if a visualisation is currently running and 0 if one is not running. -*/ - - -#define IPC_CB_VISRANDOM 628 // param is status of random - - -#define IPC_SETIDEALVIDEOSIZE 614 -/* (requires Winamp 5.0+) -** This is sent by Winamp back to itself so it can be trapped and adjusted as needed with -** the desired width in HIWORD(wParam) and the desired height in LOWORD(wParam). -** -** if(uMsg == WM_WA_IPC){ -** if(lParam == IPC_SETIDEALVIDEOSIZE){ -** wParam = MAKEWPARAM(height,width); -** } -** } -*/ - - -#define IPC_GETSTOPONVIDEOCLOSE 615 -/* (requires Winamp 5.0+) -** int sovc=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETSTOPONVIDEOCLOSE); -** This will return 1 if 'stop on video close' is enabled and 0 if it is disabled. -*/ - - -#define IPC_SETSTOPONVIDEOCLOSE 616 -/* (requires Winamp 5.0+) -** int sovc=SendMessage(hwnd_winamp,WM_WA_IPC,enabled,IPC_SETSTOPONVIDEOCLOSE); -** Set enabled to 1 to enable and 0 to disable the 'stop on video close' option. -*/ - - -typedef struct { - HWND hwnd; - int uMsg; - WPARAM wParam; - LPARAM lParam; -} transAccelStruct; - -#define IPC_TRANSLATEACCELERATOR 617 -/* (requires Winamp 5.0+) -** (deprecated as of 5.53x+) -*/ - -typedef struct { - int cmd; - int x; - int y; - int align; -} windowCommand; // send this as param to an IPC_PLCMD, IPC_MBCMD, IPC_VIDCMD - - -#define IPC_CB_ONTOGGLEAOT 618 - - -#define IPC_GETPREFSWND 619 -/* (requires Winamp 5.0+) -** HWND prefs = (HWND)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETPREFSWND); -** This will return a handle to the preferences dialog if it is open otherwise it will -** return zero. A simple check with the OS api IsWindow(..) is a good test if it's valid. -** -** e.g. this will open (or close if already open) the preferences dialog and show if we -** managed to get a valid -** SendMessage(hwnd_winamp,WM_COMMAND,MAKEWPARAM(WINAMP_OPTIONS_PREFS,0),0); -** MessageBox(hwnd_winamp,(IsWindow((HWND)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETPREFSWND))?"Valid":"Not Open"),0,MB_OK); -*/ - - -#define IPC_SET_PE_WIDTHHEIGHT 620 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&point,IPC_SET_PE_WIDTHHEIGHT); -** You pass a pointer to a POINT structure which holds the width and height and Winamp -** will set the playlist editor to that size (this is used by gen_ff on skin changes). -** There does not appear to be any bounds limiting with this so it is possible to create -** a zero size playlist editor window (which is a pretty silly thing to do). -*/ - - -#define IPC_GETLANGUAGEPACKINSTANCE 621 -/* (requires Winamp 5.0+) -** HINSTANCE hInst = (HINSTANCE)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLANGUAGEPACKINSTANCE); -** This will return the HINSTANCE to the currently used language pack file for winamp.exe -** -** (5.5+) -** If you pass 1 in wParam then you will have zero returned if a language pack is in use. -** if(!SendMessage(hwnd_winamp,WM_WA_IPC,1,IPC_GETLANGUAGEPACKINSTANCE)){ -** // winamp is currently using a language pack -** } -** -** If you pass 2 in wParam then you will get the path to the language pack folder. -** wchar_t* lngpackfolder = (wchar_t*)SendMessage(hwnd_winamp,WM_WA_IPC,2,IPC_GETLANGUAGEPACKINSTANCE); -** -** If you pass 3 in wParam then you will get the path to the currently extracted language pack. -** wchar_t* lngpack = (wchar_t*)SendMessage(hwnd_winamp,WM_WA_IPC,3,IPC_GETLANGUAGEPACKINSTANCE); -** -** If you pass 4 in wParam then you will get the name of the currently used language pack. -** wchar_t* lngname = (char*)SendMessage(hwnd_winamp,WM_WA_IPC,4,IPC_GETLANGUAGEPACKINSTANCE); -*/ -#define LANG_IDENT_STR 0 -#define LANG_LANG_CODE 1 -#define LANG_COUNTRY_CODE 2 -/* -** (5.51+) -** If you pass 5 in LOWORD(wParam) then you will get the ident string/code string -** (based on the param passed in the HIWORD(wParam) of the currently used language pack. -** The string returned with LANG_IDENT_STR is used to represent the language that the -** language pack is intended for following ISO naming conventions for consistancy. -** -** wchar_t* ident_str = (wchar_t*)SendMessage(hwnd_winamp,WM_WA_IPC,MAKEWPARAM(5,LANG_XXX),IPC_GETLANGUAGEPACKINSTANCE); -** -** e.g. -** For the default language it will return the following for the different LANG_XXX codes -** LANG_IDENT_STR -> "en-US" (max buffer size of this is 9 wchar_t) -** LANG_LANG_CODE -> "en" (language code) -** LANG_COUNTRY_CODE -> "US" (country code) -** -** On pre 5.51 installs you can get LANG_IDENT_STR using the following method -** (you'll have to custom process the string returned if you want the langugage or country but that's easy ;) ) -** -** #define LANG_PACK_LANG_ID 65534 (if you don't have lang.h) -** HINSTANCE hInst = (HINSTANCE)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLANGUAGEPACKINSTANCE); -** TCHAR buffer[9] = {0}; -** LoadString(hInst,LANG_PACK_LANG_ID,buffer,sizeof(buffer)); -** -** -** -** The following example shows how using the basic api will allow you to load the playlist -** context menu resource from the currently loaded language pack or it will fallback to -** the default winamp.exe instance. -** -** HINSTANCE lang = (HINSTANCE)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLANGUAGEPACKINSTANCE); -** HMENU popup = GetSubMenu(GetSubMenu((LoadMenu(lang?lang:GetModuleHandle(0),MAKEINTRESOURCE(101))),2),5); -** // do processing as needed on the menu before displaying it -** TrackPopupMenuEx(orig,TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,rc.left,rc.bottom,hwnd_owner,0); -** DestroyMenu(popup); -** -** If you need a specific menu handle then look at IPC_GET_HMENU for more information. -*/ - - -#define IPC_CB_PEINFOTEXT 622 // data is a string, ie: "04:21/45:02" - - -#define IPC_CB_OUTPUTCHANGED 623 // output plugin was changed in config - - -#define IPC_GETOUTPUTPLUGIN 625 -/* (requires Winamp 5.0+) -** char* outdll = (char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETOUTPUTPLUGIN); -** This returns a string of the current output plugin's dll name. -** e.g. if the directsound plugin was selected then this would return 'out_ds.dll'. -*/ - - -#define IPC_SETDRAWBORDERS 626 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,enabled,IPC_SETDRAWBORDERS); -** Set enabled to 1 to enable and 0 to disable drawing of the playlist editor and winamp -** gen class windows (used by gen_ff to allow it to draw its own window borders). -*/ - - -#define IPC_DISABLESKINCURSORS 627 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,enabled,IPC_DISABLESKINCURSORS); -** Set enabled to 1 to enable and 0 to disable the use of skinned cursors. -*/ - - -#define IPC_GETSKINCURSORS 628 -/* (requires Winamp 5.36+) -** data = (WACURSOR)cursorId. (check wa_dlg.h for values) -*/ - - -#define IPC_CB_RESETFONT 629 - - -#define IPC_IS_FULLSCREEN 630 -/* (requires Winamp 5.0+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_IS_FULLSCREEN); -** This will return 1 if the video or visualisation is in fullscreen mode or 0 otherwise. -*/ - - -#define IPC_SET_VIS_FS_FLAG 631 -/* (requires Winamp 5.0+) -** A vis should send this message with 1/as param to notify winamp that it has gone to or has come back from fullscreen mode -*/ - - -#define IPC_SHOW_NOTIFICATION 632 - - -#define IPC_GETSKININFO 633 -#define IPC_GETSKININFOW 1633 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window by itself whenever it -** needs to get information to be shown about the current skin in the 'Current skin -** information' box on the main Skins page in the Winamp preferences. -** -** When this notification is received and the current skin is one you are providing the -** support for then you return a valid buffer for Winamp to be able to read from with -** information about it such as the name of the skin file. -** -** if(uMsg == WM_WA_IPC && lParam == IPC_GETSKININFO){ -** if(is_our_skin()){ -** return is_our_skin_name(); -** } -** } -*/ - - -#define IPC_GET_MANUALPLADVANCE 634 -/* (requires Winamp 5.03+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_MANUALPLADVANCE); -** IPC_GET_MANUALPLADVANCE returns the status of the Manual Playlist Advance. -** If enabled this will return 1 otherwise it will return 0. -*/ - - -#define IPC_SET_MANUALPLADVANCE 635 -/* (requires Winamp 5.03+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_MANUALPLADVANCE); -** IPC_SET_MANUALPLADVANCE sets the status of the Manual Playlist Advance option. -** Set value = 1 to turn it on and value = 0 to turn it off. -*/ - - -#define IPC_GET_NEXT_PLITEM 636 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_EOF_GET_NEXT_PLITEM); -** -** Sent to Winamp's main window when an item has just finished playback or the next -** button has been pressed and requesting the new playlist item number to go to. -** -** Subclass this message in your application to return the new item number. -** Return -1 for normal Winamp operation (default) or the new item number in -** the playlist to be played instead of the originally selected next track. -** -** This is primarily provided for the JTFE plugin (gen_jumpex.dll). -*/ - - -#define IPC_GET_PREVIOUS_PLITEM 637 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_EOF_GET_PREVIOUS_PLITEM); -** -** Sent to Winamp's main window when the previous button has been pressed and Winamp is -** requesting the new playlist item number to go to. -** -** Return -1 for normal Winamp operation (default) or the new item number in -** the playlist to be played instead of the originally selected previous track. -** -** This is primarily provided for the JTFE plugin (gen_jumpex.dll). -*/ - - -#define IPC_IS_WNDSHADE 638 -/* (requires Winamp 5.04+) -** int is_shaded=SendMessage(hwnd_winamp,WM_WA_IPC,wnd,IPC_IS_WNDSHADE); -** Pass 'wnd' as an id as defined for IPC_GETWND or pass -1 to query the status of the -** main window. This returns 1 if the window is in winshade mode and 0 if it is not. -** Make sure you only test for this on a 5.04+ install otherwise you get a false result. -** (See the notes about unhandled WM_WA_IPC messages). -*/ - - -#define IPC_SETRATING 639 -/* (requires Winamp 5.04+ with ML) -** int rating=SendMessage(hwnd_winamp,WM_WA_IPC,rating,IPC_SETRATING); -** This will allow you to set the 'rating' on the current playlist entry where 'rating' -** is an integer value from 0 (no rating) to 5 (5 stars). -** -** The following example should correctly allow you to set the rating for any specified -** playlist entry assuming of course that you're trying to get a valid playlist entry. -** -** void SetPlaylistItemRating(int item_to_set, int rating_to_set){ -** int cur_pos=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS); -** SendMessage(hwnd_winamp,WM_WA_IPC,item_to_set,IPC_SETPLAYLISTPOS); -** SendMessage(hwnd_winamp,WM_WA_IPC,rating_to_set,IPC_SETRATING); -** SendMessage(hwnd_winamp,WM_WA_IPC,cur_pos,IPC_SETPLAYLISTPOS); -** } -*/ - - -#define IPC_GETRATING 640 -/* (requires Winamp 5.04+ with ML) -** int rating=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETRATING); -** This returns the current playlist entry's rating between 0 (no rating) to 5 (5 stars). -** -** The following example should correctly allow you to get the rating for any specified -** playlist entry assuming of course that you're trying to get a valid playlist entry. -** -** int GetPlaylistItemRating(int item_to_get, int rating_to_set){ -** int cur_pos=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS), rating = 0; -** SendMessage(hwnd_winamp,WM_WA_IPC,item_to_get,IPC_SETPLAYLISTPOS); -** rating = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETRATING); -** SendMessage(hwnd_winamp,WM_WA_IPC,cur_pos,IPC_SETPLAYLISTPOS); -** return rating; -** } -*/ - - -#define IPC_GETNUMAUDIOTRACKS 641 -/* (requires Winamp 5.04+) -** int n = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETNUMAUDIOTRACKS); -** This will return the number of audio tracks available from the currently playing item. -*/ - - -#define IPC_GETNUMVIDEOTRACKS 642 -/* (requires Winamp 5.04+) -** int n = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETNUMVIDEOTRACKS); -** This will return the number of video tracks available from the currently playing item. -*/ - - -#define IPC_GETAUDIOTRACK 643 -/* (requires Winamp 5.04+) -** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETAUDIOTRACK); -** This will return the id of the current audio track for the currently playing item. -*/ - - -#define IPC_GETVIDEOTRACK 644 -/* (requires Winamp 5.04+) -** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVIDEOTRACK); -** This will return the id of the current video track for the currently playing item. -*/ - - -#define IPC_SETAUDIOTRACK 645 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,track,IPC_SETAUDIOTRACK); -** This allows you to switch to a new audio track (if supported) in the current playing file. -*/ - - -#define IPC_SETVIDEOTRACK 646 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,track,IPC_SETVIDEOTRACK); -** This allows you to switch to a new video track (if supported) in the current playing file. -*/ - - -#define IPC_PUSH_DISABLE_EXIT 647 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_PUSH_DISABLE_EXIT); -** This will let you disable or re-enable the UI exit functions (close button, context -** menu, alt-f4). Remember to call IPC_POP_DISABLE_EXIT when you are done doing whatever -** was required that needed to prevent exit otherwise you have to kill the Winamp process. -*/ - - -#define IPC_POP_DISABLE_EXIT 648 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_POP_DISABLE_EXIT); -** See IPC_PUSH_DISABLE_EXIT -*/ - - -#define IPC_IS_EXIT_ENABLED 649 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_IS_EXIT_ENABLED); -** This will return 0 if the 'exit' option of Winamp's menu is disabled and 1 otherwise. -*/ - - -#define IPC_IS_AOT 650 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_IS_AOT); -** This will return the status of the always on top flag. -** Note: This may not match the actual TOPMOST window flag while another fullscreen -** application is focused if the user has the 'Disable always on top while fullscreen -** applications are focused' option under the General Preferences page is checked. -*/ - - -#define IPC_USES_RECYCLEBIN 651 -/* (requires Winamp 5.09+) -** int use_bin=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_USES_RECYCLEBIN); -** This will return 1 if the deleted file should be sent to the recycle bin or -** 0 if deleted files should be deleted permanently (default action for < 5.09). -** -** Note: if you use this on pre 5.09 installs of Winamp then it will return 1 which is -** not correct but is due to the way that SendMessage(..) handles un-processed messages. -** Below is a quick case for checking if the returned value is correct. -** -** if(SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_USES_RECYCLEBIN) && -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION)>=0x5009) -** { -** // can safely follow the option to recycle the file -** } -** else -* { -** // need to do a permanent delete of the file -** } -*/ - - -#define IPC_FLUSHAUDITS 652 -/* -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_FLUSHAUDITS); -** -** Will flush any pending audits in the global audits queue -** -*/ - -#define IPC_GETPLAYITEM_START 653 -#define IPC_GETPLAYITEM_END 654 - - -#define IPC_GETVIDEORESIZE 655 -#define IPC_SETVIDEORESIZE 656 - - -#define IPC_INITIAL_SHOW_STATE 657 -/* (requires Winamp 5.36+) -** int show_state = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_INITIAL_SHOW_STATE); -** returns the processed value of nCmdShow when Winamp was started -** (see MSDN documentation the values passed to WinMain(..) for what this should be) -** -** e.g. -** if(SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_INITIAL_SHOW_STATE) == SW_SHOWMINIMIZED){ -** // we are starting minimised so process as needed (keep our window hidden) -** } -** -** Useful for seeing if winamp was run minimised on startup so you can act accordingly. -** On pre-5.36 versions this will effectively return SW_NORMAL/SW_SHOWNORMAL due to the -** handling of unknown apis returning 1 from Winamp. -*/ - -// >>>>>>>>>>> Next is 658 - -#define IPC_PLCMD 1000 - -#define PLCMD_ADD 0 -#define PLCMD_REM 1 -#define PLCMD_SEL 2 -#define PLCMD_MISC 3 -#define PLCMD_LIST 4 - -//#define IPC_MBCMD 1001 - -#define MBCMD_BACK 0 -#define MBCMD_FORWARD 1 -#define MBCMD_STOP 2 -#define MBCMD_RELOAD 3 -#define MBCMD_MISC 4 - -#define IPC_VIDCMD 1002 - -#define VIDCMD_FULLSCREEN 0 -#define VIDCMD_1X 1 -#define VIDCMD_2X 2 -#define VIDCMD_LIB 3 -#define VIDPOPUP_MISC 4 - -//#define IPC_MBURL 1003 //sets the URL -//#define IPC_MBGETCURURL 1004 //copies the current URL into wParam (have a 4096 buffer ready) -//#define IPC_MBGETDESC 1005 //copies the current URL description into wParam (have a 4096 buffer ready) -//#define IPC_MBCHECKLOCFILE 1006 //checks that the link file is up to date (otherwise updates it). wParam=parent HWND -//#define IPC_MBREFRESH 1007 //refreshes the "now playing" view in the library -//#define IPC_MBGETDEFURL 1008 //copies the default URL into wParam (have a 4096 buffer ready) - -#define IPC_STATS_LIBRARY_ITEMCNT 1300 // updates library count status - -/* -** IPC's in the message range 2000 - 3000 are reserved internally for freeform messages. -** These messages are taken from ff_ipc.h which is part of the Modern skin integration. -*/ - -#define IPC_FF_FIRST 2000 - -#define IPC_FF_COLOURTHEME_CHANGE IPC_FF_ONCOLORTHEMECHANGED -#define IPC_FF_ONCOLORTHEMECHANGED IPC_FF_FIRST + 3 -/* -** This is a notification message sent when the user changes the colour theme in a Modern -** skin and can also be detected when the Modern skin is first loaded as the gen_ff plugin -** applies relevant settings and styles (like the colour theme). -** -** The value of wParam is the name of the new color theme being switched to. -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(const char*)colour_theme_name,IPC_FF_ONCOLORTHEMECHANGED); -** -** (IPC_FF_COLOURTHEME_CHANGE is the name i (DrO) was using before getting a copy of -** ff_ipc.h with the proper name in it). -*/ - - -#define IPC_FF_ISMAINWND IPC_FF_FIRST + 4 -/* -** int ismainwnd = (HWND)SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(HWND)test_wnd,IPC_FF_ISMAINWND); -** -** This allows you to determine if the window handle passed to it is a modern skin main -** window or not. If it is a main window or any of its windowshade variants then it will -** return 1. -** -** Because of the way modern skins are implemented, it is possible for this message to -** return a positive test result for a number of window handles within the current Winamp -** process. This appears to be because you can have a visible main window, a compact main -** window and also a winshaded version. -** -** The following code example below is one way of seeing how this api works since it will -** enumerate all windows related to Winamp at the time and allows you to process as -** required when a detection happens. -** -** -** EnumThreadWindows(GetCurrentThreadId(),enumWndProc,0); -** -** BOOL CALLBACK enumWndProc(HWND hwnd, LPARAM lParam){ -** -** if(SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)hwnd,IPC_FF_ISMAINWND)){ -** // do processing in here -** // or continue the enum for other main windows (if they exist) -** // and just comment out the line below -** return 0; -** } -** return 1; -** } -*/ - - -#define IPC_FF_GETCONTENTWND IPC_FF_FIRST + 5 -/* -** HWND wa2embed = (HWND)SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(HWND)test_wnd,IPC_FF_GETCONTENTWND); -** -** This will return the Winamp 2 window that is embedded in the window's container -** i.e. if hwnd is the playlist editor windowshade hwnd then it will return the Winamp 2 -** playlist editor hwnd. -** -** If no content is found such as the window has nothing embedded then this will return -** the hwnd passed to it. -*/ - - -#define IPC_FF_NOTIFYHOTKEY IPC_FF_FIRST + 6 -/* -** This is a notification message sent when the user uses a global hotkey combination -** which had been registered with the gen_hotkeys plugin. -** -** The value of wParam is the description of the hotkey as passed to gen_hotkeys. -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(const char*)hotkey_desc,IPC_FF_NOTIFYHOTKEY); -*/ - -#define IPC_FF_LAST 3000 - - -/* -** General IPC messages in Winamp -** -** All notification messages appear in the lParam of the main window message proceedure. -*/ - - -#define IPC_GETDROPTARGET 3001 -/* (requires Winamp 5.0+) -** IDropTarget* IDrop = (IDropTarget*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETDROPTARGET); -** -** You call this to retrieve a copy of the IDropTarget interface which Winamp created for -** handling external drag and drop operations on to it's Windows. This is only really -** useful if you're providing an alternate interface and want your Windows to provide the -** same drag and drop support as Winamp normally provides the user. Check out MSDN or -** your prefered search facility for more information about the IDropTarget interface and -** what's needed to handle it in your own instance. -*/ - - -#define IPC_PLAYLIST_MODIFIED 3002 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window whenever the playlist is -** modified in any way e.g. the addition/removal of a playlist entry. -** -** It is not a good idea to do large amounts of processing in this notification since it -** will slow down Winamp as playlist entries are modified (especially when you're adding -** in a large playlist). -** -** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYLIST_MODIFIED) -** { -** // do what you need to do here -** } -*/ - - -#define IPC_PLAYING_FILE 3003 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window when playback begins for -** a file. This passes the full filepath in the wParam of the message received. -** -** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYING_FILE) -** { -** // do what you need to do here, e.g. -** process_file((char*)wParam); -** } -*/ - - -#define IPC_PLAYING_FILEW 13003 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window when playback begins for -** a file. This passes the full filepath in the wParam of the message received. -** -** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYING_FILEW) -** { -** // do what you need to do here, e.g. -** process_file((wchar_t*)wParam); -** } -*/ - - -#define IPC_FILE_TAG_MAY_HAVE_UPDATED 3004 -#define IPC_FILE_TAG_MAY_HAVE_UPDATEDW 3005 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window when a file's tag -** (e.g. id3) may have been updated. This appears to be sent when the InfoBox(..) function -** of the associated input plugin returns a 1 (which is the file information dialog/editor -** call normally). -** -** if(uMsg == WM_WA_IPC && lParam == IPC_FILE_TAG_MAY_HAVE_UPDATED) -** { -** // do what you need to do here, e.g. -** update_info_on_file_update((char*)wParam); -** } -*/ - - -#define IPC_ALLOW_PLAYTRACKING 3007 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,allow,IPC_ALLOW_PLAYTRACKING); -** Send allow as nonzero to allow play tracking and zero to disable the mode. -*/ - - -#define IPC_HOOK_OKTOQUIT 3010 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window asking if it's okay to -** close or not. Return zero to prevent Winamp from closing or return anything non-zero -** to allow Winamp to close. -** -** The best implementation of this option is to let the message pass through to the -** original window proceedure since another plugin may want to have a say in the matter -** with regards to Winamp closing. -** -** if(uMsg == WM_WA_IPC && lParam == IPC_HOOK_OKTOQUIT) -** { -** // do what you need to do here, e.g. -** if(no_shut_down()) -** { -** return 1; -** } -** } -*/ - - -#define IPC_WRITECONFIG 3011 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,write_type,IPC_WRITECONFIG); -** -** Send write_type as 2 to write all config settings and the current playlist. -** -** Send write_type as 1 to write the playlist and common settings. -** This won't save the following ini settings:: -** -** defext, titlefmt, proxy, visplugin_name, dspplugin_name, check_ft_startup, -** visplugin_num, pe_fontsize, visplugin_priority, visplugin_autoexec, dspplugin_num, -** sticon, splash, taskbar, dropaotfs, ascb_new, ttips, riol, minst, whichicon, -** whichicon2, addtolist, snap, snaplen, parent, hilite, disvis, rofiob, shownumsinpl, -** keeponscreen, eqdsize, usecursors, fixtitles, priority, shuffle_morph_rate, -** useexttitles, bifont, inet_mode, ospb, embedwnd_freesize, no_visseh -** (the above was valid for 5.1) -** -** Send write_type as 0 to write the common and less common settings and no playlist. -*/ - - -#define IPC_UPDATE_URL 3012 -// pass the URL (char *) in lparam, will be free()'d on done. - - -#define IPC_GET_RANDFUNC 3015 // returns a function to get a random number -/* (requires Winamp 5.1+) -** int (*randfunc)(void) = (int(*)(void))SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_GET_RANDFUNC); -** if(randfunc && randfunc != 1){ -** randfunc(); -** } -** -** This will return a positive 32-bit number (essentially 31-bit). -** The check for a returned value of 1 is because that's the default return value from -** SendMessage(..) when it is not handled so is good to check for it in this situation. -*/ - - -#define IPC_METADATA_CHANGED 3017 -/* (requires Winamp 5.1+) -** int changed=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(char*)field,IPC_METADATA_CHANGED); -** a plugin can SendMessage this to winamp if internal metadata has changes. -** wParam should be a char * of what field changed -** -** Currently used for internal actions (and very few at that) the intent of this api is -** to allow a plugin to call it when metadata has changed in the current playlist entry -** e.g.a new id3v2 tag was found in a stream -** -** The wparam value can either be NULL or a pointer to an ansi string for the metadata -** which has changed. This can be thought of as an advanced version of IPC_UPDTITLE and -** could be used to allow for update of the current title when a specific tag changed. -** -** Not recommended to be used since there is not the complete handling implemented in -** Winamp for it at the moment. -*/ - - -#define IPC_SKIN_CHANGED 3018 -/* (requires Winamp 5.1+) -** This is a notification message sent to the main Winamp window by itself whenever -** the skin in use is changed. There is no information sent by the wParam for this. -** -** if(message == WM_WA_IPC && lparam == IPC_SKIN_CHANGED) -** { -** // do what you need to do to handle skin changes, e.g. call WADlg_init(hwnd_winamp); -** } -*/ - - -#define IPC_REGISTER_LOWORD_COMMAND 3019 -/* (requires Winamp 5.1+) -** WORD id = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_REGISTER_LOWORD_COMMAND); -** This will assign you a unique id for making your own commands such as for extra menu -** entries. The starting value returned by this message will potentially change as and -** when the main resource file of Winamp is updated with extra data so assumptions cannot -** be made on what will be returned and plugin loading order will affect things as well. - -** 5.33+ -** If you want to reserve more than one id, you can pass the number of ids required in wParam -*/ - - -#define IPC_GET_DISPATCH_OBJECT 3020 // gets winamp main IDispatch * (for embedded webpages) -#define IPC_GET_UNIQUE_DISPATCH_ID 3021 // gives you a unique dispatch ID that won't conflict with anything in winamp's IDispatch * -#define IPC_ADD_DISPATCH_OBJECT 3022 // add your own dispatch object into winamp's. This lets embedded webpages access your functions -// pass a pointer to DispatchInfo (see below). Winamp makes a copy of all this data so you can safely delete it later -typedef struct -{ - wchar_t *name; // filled in by plugin, make sure it's a unicode string!! (i.e. L"myObject" instead of "myObject). - struct IDispatch *dispatch; // filled in by plugin - DWORD id; // filled in by winamp on return -} DispatchInfo; - -// see IPC_JSAPI2_GET_DISPATCH_OBJECT for version 2 of the Dispatchable scripting interface - -#define IPC_GET_PROXY_STRING 3023 -/* (requires Winamp 5.11+) -** char* proxy_string=(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_PROXY_STRING); -** This will return the same string as is shown on the General Preferences page. -*/ - - -#define IPC_USE_REGISTRY 3024 -/* (requires Winamp 5.11+) -** int reg_enabled=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_USE_REGISTRY); -** This will return 0 if you should leave your grubby hands off the registry (i.e. for -** lockdown mode). This is useful if Winamp is run from a USB drive and you can't alter -** system settings, etc. -*/ - - -#define IPC_GET_API_SERVICE 3025 -/* (requires Winamp 5.12+) -** api_service* api_service = (api_service)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_API_SERVICE); -** This api will return Winamp's api_service pointer (which is what Winamp3 used, heh). -** If this api is not supported in the Winamp version that is being used at the time then -** the returned value from this api will be 1 which is a good version check. -** -** As of 5.12 there is support for .w5s plugins which reside in %WinampDir%\System and -** are intended for common code that can be shared amongst other plugins e.g. jnetlib.w5s -** which contains jnetlib in one instance instead of being duplicated multiple times in -** all of the plugins which need internet access. -** -** Details on the .w5s specifications will come at some stage (possibly). -*/ - - -typedef struct { - const wchar_t *filename; - const wchar_t *metadata; - wchar_t *ret; - size_t retlen; -} extendedFileInfoStructW; - -#define IPC_GET_EXTENDED_FILE_INFOW 3026 -/* (requires Winamp 5.13+) -** Pass a pointer to the above struct in wParam -*/ - - -#define IPC_GET_EXTENDED_FILE_INFOW_HOOKABLE 3027 -#define IPC_SET_EXTENDED_FILE_INFOW 3028 -/* (requires Winamp 5.13+) -** Pass a pointer to the above struct in wParam -*/ - - -#define IPC_PLAYLIST_GET_NEXT_SELECTED 3029 -/* (requires 5.2+) -** int pl_item = SendMessage(hwnd_winamp,WM_WA_IPC,start,IPC_PLAYLIST_GET_NEXT_SELECTED); -** -** This works just like the ListView_GetNextItem(..) macro for ListView controls. -** 'start' is the index of the playlist item that you want to begin the search after or -** set this as -1 for the search to begin with the first item of the current playlist. -** -** This will return the index of the selected playlist according to the 'start' value or -** it returns -1 if there is no selection or no more selected items according to 'start'. -** -** Quick example: -** -** int sel = -1; -** // keep incrementing the start of the search so we get all of the selected entries -** while((sel = SendMessage(hwnd_winamp,WM_WA_IPC,sel,IPC_PLAYLIST_GET_NEXT_SELECTED))!=-1){ -** // show the playlist file entry of the selected item(s) if there were any -** MessageBox(hwnd_winamp,(char*)SendMessage(hwnd_winamp,WM_WA_IPC,sel,IPC_GETPLAYLISTFILE),0,0); -** } -*/ - - -#define IPC_PLAYLIST_GET_SELECTED_COUNT 3030 -/* (requires 5.2+) -** int selcnt = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_PLAYLIST_GET_SELECTED_COUNT); -** This will return the number of selected playlist entries. -*/ - - -#define IPC_GET_PLAYING_FILENAME 3031 -// returns wchar_t * of the currently playing filename - -#define IPC_OPEN_URL 3032 -// send either ANSI or Unicode string (it'll figure it out, but it MUST start with "h"!, so don't send ftp:// or anything funny) -// you can also send this one from another process via WM_COPYDATA (unicode only) - - -#define IPC_USE_UXTHEME_FUNC 3033 -/* (requires Winamp 5.35+) -** int ret = SendMessage(hwnd_winamp,WM_WA_IPC,param,IPC_USE_UXTHEME_FUNC); -** param can be IPC_ISWINTHEMEPRESENT or IPC_ISAEROCOMPOSITIONACTIVE or a valid hwnd. -** -** If you pass a hwnd then it will apply EnableThemeDialogTexture(ETDT_ENABLETAB) -** so your tabbed dialogs can use the correct theme (on supporting OSes ie XP+). -** -** Otherwise this will return a value based on the param passed (as defined below). -** For compatability, the return value will be zero on success (as 1 is returned -** for unsupported ipc calls on older Winamp versions) -*/ - #define IPC_ISWINTHEMEPRESENT 0 -/* This will return 0 if uxtheme.dll is present -** int isthemethere = !SendMessage(hwnd_winamp,WM_WA_IPC,IPC_ISWINTHEMEPRESENT,IPC_USE_UXTHEME_FUNC); -*/ - #define IPC_ISAEROCOMPOSITIONACTIVE 1 -/* This will return 0 if aero composition is active -** int isaero = !SendMessage(hwnd_winamp,WM_WA_IPC,IPC_ISAEROCOMPOSITIONACTIVE,IPC_USE_UXTHEME_FUNC); -*/ - - -#define IPC_GET_PLAYING_TITLE 3034 -// returns wchar_t * of the current title - - -#define IPC_CANPLAY 3035 -// pass const wchar_t *, returns an in_mod * or 0 - - -typedef struct { - // fill these in... - size_t size; // init to sizeof(artFetchData) - HWND parent; // parent window of the dialogue - - // fill as much of these in as you can, otherwise leave them 0 - const wchar_t *artist; - const wchar_t *album; - int year, amgArtistId, amgAlbumId; - - int showCancelAll; // if set to 1, this shows a "Cancel All" button on the dialogue - - // winamp will fill these in if the call returns successfully: - void* imgData; // a buffer filled with compressed image data. free with WASABI_API_MEMMGR->sysFree() - int imgDataLen; // the size of the buffer - wchar_t type[10]; // eg: "jpg" - const wchar_t *gracenoteFileId; // if you know it -} artFetchData; - -#define IPC_FETCH_ALBUMART 3036 -/* pass an artFetchData*. This will show a dialog guiding the use through choosing art, and return when it's finished -** return values: -** 1: error showing dialog -** 0: success -** -1: cancel was pressed -** -2: cancel all was pressed -*/ - -#define IPC_JSAPI2_GET_DISPATCH_OBJECT 3037 -/* pass your service's unique ID, as a wchar_t * string, in wParam -** Winamp will copy the string, so don't worry about keeping it around -** An IDispatch * object will be returned (cast the return value from SendMessage) -** This IDispatch can be used for scripting/automation/VB interaction -** Pass to IE via IDocHostUIHandler::GetExternal and it will become window.external in javscript -*/ - -#define IPC_REGISTER_WINAMP_IPCMESSAGE 65536 -/* (requires Winamp 5.0+) -** DWORD id = SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)name,IPC_REGISTER_WINAMP_IPCMESSAGE); -** The value 'id' returned is > 65536 and is incremented on subsequent calls for unique -** 'name' values passed to it. By using the same 'name' in different plugins will allow a -** common runtime api to be provided for the currently running instance of Winamp -** e.g. -** PostMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)my_param,registered_ipc); -** Have a look at wa_hotkeys.h for an example on how this api is used in practice for a -** custom WM_WA_IPC message. -** -** if(uMsg == WM_WA_IPC && lParam == id_from_register_winamp_ipcmessage){ -** // do things -** } -*/ - -#endif//_WA_IPC_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/SDK-test.sln b/tools/vio2sf/src/foobar/SDK-test.sln deleted file mode 100644 index 5d8e7a4a3..000000000 --- a/tools/vio2sf/src/foobar/SDK-test.sln +++ /dev/null @@ -1,73 +0,0 @@ -サソ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_SDK", "foobar2000\SDK\foobar2000_SDK.vcproj", "{E8091321-D79D-4575-86EF-064EA1A4A20D}" - ProjectSection(ProjectDependencies) = postProject - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C} = {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_ATL_helpers", "foobar2000\ATLHelpers\foobar2000_ATL_helpers.vcproj", "{622E8B19-8109-4717-BD4D-9657AA78363E}" - ProjectSection(ProjectDependencies) = postProject - {E8091321-D79D-4575-86EF-064EA1A4A20D} = {E8091321-D79D-4575-86EF-064EA1A4A20D} - {EE47764E-A202-4F85-A767-ABDAB4AFF35F} = {EE47764E-A202-4F85-A767-ABDAB4AFF35F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_component_client", "foobar2000\foobar2000_component_client\foobar2000_component_client.vcproj", "{71AD2674-065B-48F5-B8B0-E1F9D3892081}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_sdk_helpers", "foobar2000\helpers\foobar2000_sdk_helpers.vcproj", "{EE47764E-A202-4F85-A767-ABDAB4AFF35F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pfc", "pfc\pfc.vcproj", "{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.ActiveCfg = Debug|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.Build.0 = Debug|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.ActiveCfg = Debug|x64 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.Build.0 = Debug|x64 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.ActiveCfg = Release|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.Build.0 = Release|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.ActiveCfg = Release|x64 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.Build.0 = Release|x64 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|Win32.ActiveCfg = Debug|Win32 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|Win32.Build.0 = Debug|Win32 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|x64.ActiveCfg = Debug|x64 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|x64.Build.0 = Debug|x64 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Release|Win32.ActiveCfg = Release|Win32 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Release|Win32.Build.0 = Release|Win32 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Release|x64.ActiveCfg = Release|x64 - {622E8B19-8109-4717-BD4D-9657AA78363E}.Release|x64.Build.0 = Release|x64 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.ActiveCfg = Debug|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.Build.0 = Debug|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.ActiveCfg = Debug|x64 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.Build.0 = Debug|x64 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.ActiveCfg = Release|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.Build.0 = Release|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.ActiveCfg = Release|x64 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.Build.0 = Release|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.ActiveCfg = Debug|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.Build.0 = Debug|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.ActiveCfg = Debug|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.Build.0 = Debug|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.ActiveCfg = Release|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.Build.0 = Release|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.ActiveCfg = Release|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.Build.0 = Release|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.ActiveCfg = Debug|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.Build.0 = Debug|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.ActiveCfg = Debug|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.Build.0 = Debug|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.ActiveCfg = Release|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.Build.0 = Release|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.ActiveCfg = Release|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/abort_callback.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/abort_callback.cpp deleted file mode 100644 index affc69ff2..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/abort_callback.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "foobar2000.h" - -void abort_callback::check() const { - if (is_aborting()) throw exception_aborted(); -} - -void abort_callback::sleep(double p_timeout_seconds) const { - if (!sleep_ex(p_timeout_seconds)) throw exception_aborted(); -} - -bool abort_callback::sleep_ex(double p_timeout_seconds) const { -#ifdef _WIN32 - return !win32_event::g_wait_for(get_abort_event(),p_timeout_seconds); -#else -#error PORTME -#endif -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/abort_callback.h b/tools/vio2sf/src/foobar/foobar2000/SDK/abort_callback.h deleted file mode 100644 index 97ed3afea..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/abort_callback.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef _foobar2000_sdk_abort_callback_h_ -#define _foobar2000_sdk_abort_callback_h_ - -namespace foobar2000_io { - -PFC_DECLARE_EXCEPTION(exception_aborted,pfc::exception,"User abort"); - -#ifdef _WIN32 -typedef HANDLE abort_callback_event; -#else -#error PORTME -#endif - -//! This class is used to signal underlying worker code whether user has decided to abort a potentially time-consuming operation. It is commonly required by all file related operations. Code that receives an abort_callback object should periodically check it and abort any operations being performed if it is signaled, typically throwing exception_aborted. \n -//! See abort_callback_impl for an implementation. -class NOVTABLE abort_callback -{ -public: - //! Returns whether user has requested the operation to be aborted. - virtual bool is_aborting() const = 0; - - //! Retrieves event object that can be used with some OS calls. The even object becomes signaled when abort is triggered. On win32, this is equivalent to win32 event handle (see: CreateEvent). \n - //! You must not close this handle or call any methods that change this handle's state (SetEvent() or ResetEvent()), you can only wait for it. - virtual abort_callback_event get_abort_event() const = 0; - - //! Checks if user has requested the operation to be aborted, and throws exception_aborted if so. - void check() const; - - //! For compatibility with old code. Do not call. - inline void check_e() const {check();} - - - //! Sleeps p_timeout_seconds or less when aborted, throws exception_aborted on abort. - void sleep(double p_timeout_seconds) const; - //! Sleeps p_timeout_seconds or less when aborted, returns true when execution should continue, false when not. - bool sleep_ex(double p_timeout_seconds) const; -protected: - abort_callback() {} - ~abort_callback() {} -}; - - - -//! Implementation of abort_callback interface. -class abort_callback_impl : public abort_callback { -public: - abort_callback_impl() : m_aborting(false) { - m_event.create(true,false); - } - inline void abort() {set_state(true);} - inline void reset() {set_state(false);} - - void set_state(bool p_state) {m_aborting = p_state; m_event.set_state(p_state);} - - bool is_aborting() const {return m_aborting;} - - abort_callback_event get_abort_event() const {return m_event.get();} - -private: - abort_callback_impl(const abort_callback_impl &) {throw pfc::exception_not_implemented();} - const abort_callback_impl & operator=(const abort_callback_impl&) {throw pfc::exception_not_implemented();} - - volatile bool m_aborting; -#ifdef WIN32 - win32_event m_event; -#endif -}; - -//! Dummy abort_callback that never gets aborted. To be possibly optimized in the future. -typedef abort_callback_impl abort_callback_dummy; - -} - -using namespace foobar2000_io; - -#endif //_foobar2000_sdk_abort_callback_h_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/advconfig.h b/tools/vio2sf/src/foobar/foobar2000/SDK/advconfig.h deleted file mode 100644 index 3b2198953..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/advconfig.h +++ /dev/null @@ -1,266 +0,0 @@ -//! Entrypoint class for adding items to Advanced Preferences page. \n -//! Implementations must derive from one of subclasses: advconfig_branch, advconfig_entry_checkbox, advconfig_entry_string. \n -//! Implementations are typically registered using static service_factory_single_t, or using provided helper classes in case of standard implementations declared in this header. -class NOVTABLE advconfig_entry : public service_base { -public: - virtual void get_name(pfc::string_base & p_out) = 0; - virtual GUID get_guid() = 0; - virtual GUID get_parent() = 0; - virtual void reset() = 0; - virtual double get_sort_priority() = 0; - - static bool g_find(service_ptr_t& out, const GUID & id) { - service_enum_t e; service_ptr_t ptr; while(e.next(ptr)) { if (ptr->get_guid() == id) {out = ptr; return true;} } return false; - } - - static const GUID guid_root; - static const GUID guid_branch_tagging,guid_branch_decoding,guid_branch_tools,guid_branch_playback,guid_branch_display; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(advconfig_entry); -}; - -//! Creates a new branch in Advanced Preferences. \n -//! Implementation: see advconfig_branch_impl / advconfig_branch_factory. -class NOVTABLE advconfig_branch : public advconfig_entry { -public: - FB2K_MAKE_SERVICE_INTERFACE(advconfig_branch,advconfig_entry); -}; - -//! Creates a checkbox/radiocheckbox entry in Advanced Preferences. \n -//! The difference between checkboxes and radiocheckboxes is different icon (obviously) and that checking a radiocheckbox unchecks all other radiocheckboxes in the same branch. \n -//! Implementation: see advconfig_entry_checkbox_impl / advconfig_checkbox_factory_t. -class NOVTABLE advconfig_entry_checkbox : public advconfig_entry { -public: - virtual bool get_state() = 0; - virtual void set_state(bool p_state) = 0; - virtual bool is_radio() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_checkbox,advconfig_entry); -}; - -//! Creates a string/integer editbox entry in Advanced Preferences.\n -//! Implementation: see advconfig_entry_string_impl / advconfig_string_factory. -class NOVTABLE advconfig_entry_string : public advconfig_entry { -public: - virtual void get_state(pfc::string_base & p_out) = 0; - virtual void set_state(const char * p_string,t_size p_length = infinite) = 0; - virtual t_uint32 get_flags() = 0; - - enum { - flag_is_integer = 1 << 0, - flag_is_signed = 1 << 1, - }; - - FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_string,advconfig_entry); -}; - - -//! Standard implementation of advconfig_branch. \n -//! Usage: no need to use this class directly - use advconfig_branch_factory instead. -class advconfig_branch_impl : public advconfig_branch { -public: - advconfig_branch_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority) : m_name(p_name), m_guid(p_guid), m_parent(p_parent), m_priority(p_priority) {} - void get_name(pfc::string_base & p_out) {p_out = m_name;} - GUID get_guid() {return m_guid;} - GUID get_parent() {return m_parent;} - void reset() {} - double get_sort_priority() {return m_priority;} -private: - pfc::string8 m_name; - GUID m_guid,m_parent; - const double m_priority; -}; - -//! Standard implementation of advconfig_entry_checkbox. \n -//! p_is_radio parameter controls whether we're implementing a checkbox or a radiocheckbox (see advconfig_entry_checkbox description for more details). -template -class advconfig_entry_checkbox_impl : public advconfig_entry_checkbox { -public: - advconfig_entry_checkbox_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate) - : m_name(p_name), m_initialstate(p_initialstate), m_state(p_guid,p_initialstate), m_parent(p_parent), m_priority(p_priority) {} - - void get_name(pfc::string_base & p_out) {p_out = m_name;} - GUID get_guid() {return m_state.get_guid();} - GUID get_parent() {return m_parent;} - void reset() {m_state = m_initialstate;} - bool get_state() {return m_state;} - void set_state(bool p_state) {m_state = p_state;} - bool is_radio() {return p_is_radio;} - double get_sort_priority() {return m_priority;} - bool get_state_() const {return m_state;} -private: - pfc::string8 m_name; - const bool m_initialstate; - cfg_bool m_state; - GUID m_parent; - const double m_priority; -}; - -//! Service factory helper around standard advconfig_branch implementation. Use this class to register your own Advanced Preferences branches. \n -//! Usage: static advconfig_branch_factory mybranch(name, branchID, parentBranchID, priority); -class advconfig_branch_factory : public service_factory_single_t { -public: - advconfig_branch_factory(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority) - : service_factory_single_t(p_name,p_guid,p_parent,p_priority) {} -}; - -//! Service factory helper around standard advconfig_entry_checkbox implementation. Use this class to register your own Advanced Preferences checkbox/radiocheckbox entries. \n -//! Usage: static advconfig_entry_checkbox mybox(name, itemID, parentID, priority, initialstate); -template -class advconfig_checkbox_factory_t : public service_factory_single_t > { -public: - advconfig_checkbox_factory_t(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate) - : service_factory_single_t >(p_name,p_guid,p_parent,p_priority,p_initialstate) {} - - bool get() const {return get_static_instance().get_state_();} - void set(bool val) {get_static_instance().set_state(val);} - operator bool() const {return get();} - bool operator=(bool val) {set(val); return val;} -}; - -//! Service factory helper around standard advconfig_entry_checkbox implementation, specialized for checkboxes (rather than radiocheckboxes). See advconfig_checkbox_factory_t<> for more details. -typedef advconfig_checkbox_factory_t advconfig_checkbox_factory; -//! Service factory helper around standard advconfig_entry_checkbox implementation, specialized for radiocheckboxes (rather than standard checkboxes). See advconfig_checkbox_factory_t<> for more details. -typedef advconfig_checkbox_factory_t advconfig_radio_factory; - - -//! Standard advconfig_entry_string implementation. Use advconfig_string_factory to register your own string entries in Advanced Preferences instead of using this class directly. -class advconfig_entry_string_impl : public advconfig_entry_string { -public: - advconfig_entry_string_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate) - : m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initialstate(p_initialstate), m_state(p_guid,p_initialstate) {} - void get_name(pfc::string_base & p_out) {p_out = m_name;} - GUID get_guid() {return m_state.get_guid();} - GUID get_parent() {return m_parent;} - void reset() {core_api::ensure_main_thread();m_state = m_initialstate;} - double get_sort_priority() {return m_priority;} - void get_state(pfc::string_base & p_out) {core_api::ensure_main_thread();p_out = m_state;} - void set_state(const char * p_string,t_size p_length = infinite) {core_api::ensure_main_thread();m_state.set_string(p_string,p_length);} - t_uint32 get_flags() {return 0;} -private: - const pfc::string8 m_initialstate, m_name; - cfg_string m_state; - const double m_priority; - const GUID m_parent; -}; - -//! Service factory helper around standard advconfig_entry_string implementation. Use this class to register your own string entries in Advanced Preferences. \n -//! Usage: static advconfig_string_factory mystring(name, itemID, branchID, priority, initialValue); -class advconfig_string_factory : public service_factory_single_t { -public: - advconfig_string_factory(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate) - : service_factory_single_t(p_name,p_guid,p_parent,p_priority,p_initialstate) {} - - void get(pfc::string_base & out) {get_static_instance().get_state(out);} - void set(const char * in) {get_static_instance().set_state(in);} -}; - - -//! Special advconfig_entry_string implementation - implements integer entries. Use advconfig_integer_factory to register your own integer entries in Advanced Preferences instead of using this class directly. -class advconfig_entry_integer_impl : public advconfig_entry_string { -public: - advconfig_entry_integer_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,t_uint64 p_initialstate,t_uint64 p_min,t_uint64 p_max) - : m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initval(p_initialstate), m_min(p_min), m_max(p_max), m_state(p_guid,p_initialstate) {} - void get_name(pfc::string_base & p_out) {p_out = m_name;} - GUID get_guid() {return m_state.get_guid();} - GUID get_parent() {return m_parent;} - void reset() {m_state = m_initval;} - double get_sort_priority() {return m_priority;} - void get_state(pfc::string_base & p_out) {p_out = pfc::format_uint(m_state.get_value());} - void set_state(const char * p_string,t_size p_length) {set_state_int(pfc::atoui64_ex(p_string,p_length));} - t_uint32 get_flags() {return advconfig_entry_string::flag_is_integer;} - - t_uint64 get_state_int() const {return m_state;} - void set_state_int(t_uint64 val) {m_state = pfc::clip_t(val,m_min,m_max);} -private: - cfg_int_t m_state; - const double m_priority; - const t_uint64 m_initval, m_min, m_max; - const GUID m_parent; - const pfc::string8 m_name; -}; - -//! Service factory helper around integer-specialized advconfig_entry_string implementation. Use this class to register your own integer entries in Advanced Preferences. \n -//! Usage: static advconfig_integer_factory myint(name, itemID, parentID, priority, initialValue, minValue, maxValue); -class advconfig_integer_factory : public service_factory_single_t { -public: - advconfig_integer_factory(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,t_uint64 p_initialstate,t_uint64 p_min,t_uint64 p_max) - : service_factory_single_t(p_name,p_guid,p_parent,p_priority,p_initialstate,p_min,p_max) {} - - t_uint64 get() const {return get_static_instance().get_state_int();} - void set(t_uint64 val) {get_static_instance().set_state_int(val);} - - operator t_uint64() const {return get();} - t_uint64 operator=(t_uint64 val) {set(val); return val;} -}; - - -//! Not currently used, reserved for future use. -class NOVTABLE advconfig_entry_enum : public advconfig_entry { -public: - virtual t_size get_value_count() = 0; - virtual void enum_value(pfc::string_base & p_out,t_size p_index) = 0; - virtual t_size get_state() = 0; - virtual void set_state(t_size p_value) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_enum,advconfig_entry); -}; - - - - -//! Special version if advconfig_entry_string_impl that allows the value to be retrieved from worker threads. -class advconfig_entry_string_impl_MT : public advconfig_entry_string { -public: - advconfig_entry_string_impl_MT(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate) - : m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initialstate(p_initialstate), m_state(p_guid,p_initialstate) {} - void get_name(pfc::string_base & p_out) {p_out = m_name;} - GUID get_guid() {return m_state.get_guid();} - GUID get_parent() {return m_parent;} - void reset() { - insync(m_sync); - m_state = m_initialstate; - } - double get_sort_priority() {return m_priority;} - void get_state(pfc::string_base & p_out) { - insync(m_sync); - p_out = m_state; - } - void set_state(const char * p_string,t_size p_length = infinite) { - insync(m_sync); - m_state.set_string(p_string,p_length); - } - t_uint32 get_flags() {return 0;} -private: - const pfc::string8 m_initialstate, m_name; - cfg_string m_state; - critical_section m_sync; - const double m_priority; - const GUID m_parent; -}; - -//! Special version if advconfig_string_factory that allows the value to be retrieved from worker threads. -class advconfig_string_factory_MT : public service_factory_single_t { -public: - advconfig_string_factory_MT(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate) - : service_factory_single_t(p_name,p_guid,p_parent,p_priority,p_initialstate) {} - - void get(pfc::string_base & out) {get_static_instance().get_state(out);} - void set(const char * in) {get_static_instance().set_state(in);} -}; - - - - -/* - Advanced Preferences variable declaration examples - - static advconfig_string_factory mystring("name goes here",myguid,parentguid,0,"asdf"); - to retrieve state: pfc::string8 val; mystring.get(val); - - static advconfig_checkbox_factory mycheckbox("name goes here",myguid,parentguid,0,false); - to retrieve state: mycheckbox.get(); - - static advconfig_integer_factory myint("name goes here",myguid,parentguid,0,initialValue,minimumValue,maximumValue); - to retrieve state: myint.get(); -*/ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/album_art.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/album_art.cpp deleted file mode 100644 index 1fea648a0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/album_art.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "foobar2000.h" - -bool album_art_editor::g_get_interface(service_ptr_t & out,const char * path) { - service_enum_t e; ptr ptr; - pfc::string_extension ext(path); - while(e.next(ptr)) { - if (ptr->is_our_path(path,ext)) { - out = ptr; return true; - } - } - return false; -} - -bool album_art_editor::g_is_supported_path(const char * path) { - ptr ptr; - return g_get_interface(ptr,path); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/album_art.h b/tools/vio2sf/src/foobar/foobar2000/SDK/album_art.h deleted file mode 100644 index 6f16d9090..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/album_art.h +++ /dev/null @@ -1,222 +0,0 @@ -//new in 0.9.5 - -//! Common class for handling picture data. \n -//! Type of contained picture data is unknown and to be determined according to memory block contents by code parsing/rendering the picture. Commonly encountered types are: BMP, PNG, JPEG and GIF. \n -//! Implementation: use album_art_data_impl. -class NOVTABLE album_art_data : public service_base { -public: - //! Retrieves a pointer to a memory block containing the picture. - virtual const void * get_ptr() const = 0; - //! Retrieves size of the memory block containing the picture. - virtual t_size get_size() const = 0; - - //! Determine whether two album_art_data objects store the same picture data. - static bool equals(album_art_data const & v1, album_art_data const & v2) { - const t_size s = v1.get_size(); - if (s != v2.get_size()) return false; - return memcmp(v1.get_ptr(), v2.get_ptr(),s) == 0; - } - bool operator==(const album_art_data & other) const {return equals(*this,other);} - bool operator!=(const album_art_data & other) const {return !equals(*this,other);} - - FB2K_MAKE_SERVICE_INTERFACE(album_art_data,service_base); -}; - -typedef service_ptr_t album_art_data_ptr; - -//! Implements album_art_data. -class album_art_data_impl : public album_art_data { -public: - const void * get_ptr() const {return m_content.get_ptr();} - t_size get_size() const {return m_content.get_size();} - - void * get_ptr() {return m_content.get_ptr();} - void set_size(t_size p_size) {m_content.set_size(p_size);} - - //! Reads picture data from the specified stream object. - void from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { - set_size(p_bytes); p_stream->read_object(get_ptr(),p_bytes,p_abort); - } - - //! Creates an album_art_data object from picture data contained in a memory buffer. - static album_art_data_ptr g_create(const void * p_buffer,t_size p_bytes) { - service_ptr_t instance = new service_impl_t(); - instance->set_size(p_bytes); - memcpy(instance->get_ptr(),p_buffer,p_bytes); - return instance; - } - //! Creates an album_art_data object from picture data contained in a stream. - static album_art_data_ptr g_create(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { - service_ptr_t instance = new service_impl_t(); - instance->from_stream(p_stream,p_bytes,p_abort); - return instance; - } - -private: - pfc::array_t m_content; -}; - -//! Namespace containing identifiers of album art types. -namespace album_art_ids { - //! Front cover. - static const GUID cover_front = { 0xf1e66f4e, 0xfe09, 0x4b94, { 0x91, 0xa3, 0x67, 0xc2, 0x3e, 0xd1, 0x44, 0x5e } }; - //! Back cover. - static const GUID cover_back = { 0xcb552d19, 0x86d5, 0x434c, { 0xac, 0x77, 0xbb, 0x24, 0xed, 0x56, 0x7e, 0xe4 } }; - //! Picture of a disc or other storage media. - static const GUID disc = { 0x3dba9f36, 0xf928, 0x4fa4, { 0x87, 0x9c, 0xd3, 0x40, 0x47, 0x59, 0x58, 0x7e } }; - //! Album-specific icon (NOT a file type icon). - static const GUID icon = { 0x74cdf5b4, 0x7053, 0x4b3d, { 0x9a, 0x3c, 0x54, 0x69, 0xf5, 0x82, 0x6e, 0xec } }; -}; - -PFC_DECLARE_EXCEPTION(exception_album_art_not_found,exception_io_not_found,"Album Art Not Found"); -PFC_DECLARE_EXCEPTION(exception_album_art_unsupported_entry,exception_io_data,"Unsupported Album Art Entry"); - -//! Class encapsulating access to album art stored in a media file. Use album_art_extractor class obtain album_art_extractor_instance referring to specified media file. -class NOVTABLE album_art_extractor_instance : public service_base { -public: - //! Throws exception_album_art_not_found when the requested album art entry could not be found in the referenced media file. - virtual album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_instance,service_base); -}; - -//! Class encapsulating access to album art stored in a media file. Use album_art_editor class to obtain album_art_editor_instance referring to specified media file. -class NOVTABLE album_art_editor_instance : public album_art_extractor_instance { -public: - //! Throws exception_album_art_unsupported_entry when the file format we're dealing with does not support specific entry. - virtual void set(const GUID & p_what,album_art_data_ptr p_data,abort_callback & p_abort) = 0; - - //! Removes the requested entry. Fails silently when the entry doesn't exist. - virtual void remove(const GUID & p_what) = 0; - - //! Finalizes file tag update operation. - virtual void commit(abort_callback & p_abort) = 0; - - - FB2K_MAKE_SERVICE_INTERFACE(album_art_editor_instance,album_art_extractor_instance); -}; - -typedef service_ptr_t album_art_extractor_instance_ptr; -typedef service_ptr_t album_art_editor_instance_ptr; - -//! Entrypoint class for accessing album art extraction functionality. Register your own implementation to allow album art extraction from your media file format. \n -//! If you want to extract album art from a media file, it's recommended that you use album_art_manager API instead of calling album_art_extractor directly. -class NOVTABLE album_art_extractor : public service_base { -public: - //! Returns whether the specified file is one of formats supported by our album_art_extractor implementation. - //! @param p_path Path to file being queried. - //! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons. - virtual bool is_our_path(const char * p_path,const char * p_extension) = 0; - - //! Instantiates album_art_extractor_instance providing access to album art stored in a specified media file. \n - //! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all. - //! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally. - virtual album_art_extractor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_extractor); -}; - -//! Entrypoint class for accessing album art editing functionality. Register your own implementation to allow album art editing on your media file format. -class NOVTABLE album_art_editor : public service_base { -public: - //! Returns whether the specified file is one of formats supported by our album_art_editor implementation. - //! @param p_path Path to file being queried. - //! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons. - virtual bool is_our_path(const char * p_path,const char * p_extension) = 0; - - //! Instantiates album_art_editor_instance providing access to album art stored in a specified media file. \n - //! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally. - virtual album_art_editor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0; - - //! Helper; attempts to retrieve an album_art_editor service pointer that supports the specified file. - //! @returns True on success, false on failure (no registered album_art_editor supports this file type). - static bool g_get_interface(service_ptr_t & out,const char * path); - //! Helper; returns whether one of registered album_art_editor implementations is capable of opening the specified file. - static bool g_is_supported_path(const char * path); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_editor); -}; - -//! Primary API for interfacing with foobar2000 core's album art extraction functionality. \n -//! Use static_api_ptr_t()->instantiate() to obtain a pointer to album_art_manager_instance. \n -//! The main difference between using album_art_manager_instance and calling album_art_extractor methods directly is that -//! album_art_manager_instance will fall back to returning pictures found in the folder containing the specified media file -//! in case requested album art entries can't be extracted from the media file itself. -class NOVTABLE album_art_manager_instance : public service_base { -public: - //! @returns True when the newly requested file has different album art than the old one, false when album art we're referencing is the same as before. - virtual bool open(const char * p_file,abort_callback & p_abort) = 0; - //! Resets internal data. - virtual void close() = 0; - - //! Queries album art data for currently open media file. Throws exception_album_art_not_found when the requested album art entry isn't present. - virtual album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) = 0; - - //! Queries for stub image to display when there's no album art to show. \n - //! May fail with exception_album_art_not_found as well when we have no stub image configured. - virtual album_art_data_ptr query_stub_image(abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(album_art_manager_instance,service_base); -}; - -typedef service_ptr_t album_art_manager_instance_ptr; - -//! Entrypoint API for accessing album art loading functionality provided by foobar2000 core. Usage: static_api_ptr_t. \n -//! This API was introduced in 0.9.5. -class NOVTABLE album_art_manager : public service_base { -public: - virtual album_art_manager_instance_ptr instantiate() = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_manager); -}; - - -//! Helper - simple implementation of album_art_extractor_instance. -class album_art_extractor_instance_simple : public album_art_extractor_instance { -public: - void set(const GUID & p_what,album_art_data_ptr p_content) {m_content.set(p_what,p_content);} - bool have_item(const GUID & p_what) {return m_content.have_item(p_what);} - album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) { - album_art_data_ptr temp; - if (!m_content.query(p_what,temp)) throw exception_album_art_not_found(); - return temp; - } - bool is_empty() const {return m_content.get_count() == 0;} -private: - pfc::map_t m_content; -}; - -//! Helper API for extracting album art from APEv2 tags - introduced in 0.9.5. -class NOVTABLE tag_processor_album_art_utils : public service_base { -public: - - //! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all. - virtual album_art_extractor_instance_ptr open(file_ptr p_file,abort_callback & p_abort) = 0; - - //! Currently not implemented. Reserved for future use. - virtual album_art_editor_instance_ptr edit(file_ptr p_file,abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(tag_processor_album_art_utils) -}; - -//! Helper implementation of album_art_extractor - reads album art from arbitrary file formats that comply with APEv2 tagging specification. -class album_art_extractor_impl_stdtags : public album_art_extractor { -public: - //! @param exts Semicolon-separated list of file format extensions to support. - album_art_extractor_impl_stdtags(const char * exts) { - pfc::splitStringSimple_toList(m_extensions,";",exts); - } - - bool is_our_path(const char * p_path,const char * p_extension) { - return m_extensions.have_item(p_extension); - } - - album_art_extractor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) { - PFC_ASSERT( is_our_path(p_path, pfc::string_extension(p_path) ) ); - file_ptr l_file ( p_filehint ); - if (l_file.is_empty()) filesystem::g_open_read(l_file, p_path, p_abort); - return static_api_ptr_t()->open( l_file, p_abort ); - } -private: - pfc::avltree_t m_extensions; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/app_close_blocker.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/app_close_blocker.cpp deleted file mode 100644 index 6611e0b56..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/app_close_blocker.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "foobar2000.h" - -bool app_close_blocker::g_query() -{ - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) - { - if (!ptr->query()) return false; - } - return true; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/app_close_blocker.h b/tools/vio2sf/src/foobar/foobar2000/SDK/app_close_blocker.h deleted file mode 100644 index b63659d2f..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/app_close_blocker.h +++ /dev/null @@ -1,45 +0,0 @@ -//! (DEPRECATED) This service is used to signal whether something is currently preventing main window from being closed and app from being shut down. -class NOVTABLE app_close_blocker : public service_base -{ -public: - //! Checks whether this service is currently preventing main window from being closed and app from being shut down. - virtual bool query() = 0; - - //! Static helper function, checks whether any of registered app_close_blocker services is currently preventing main window from being closed and app from being shut down. - static bool g_query(); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(app_close_blocker); -}; - -//! An interface encapsulating a task preventing the foobar2000 application from being closed. Instances of this class need to be registered using app_close_blocking_task_manager methods. \n -//! Implementation: it's recommended that you derive from app_close_blocking_task_impl class instead of deriving from app_close_blocking_task directly, it manages registration/unregistration behind-the-scenes. -class NOVTABLE app_close_blocking_task { -public: - virtual void query_task_name(pfc::string_base & out) = 0; - -protected: - app_close_blocking_task() {} - ~app_close_blocking_task() {} - - PFC_CLASS_NOT_COPYABLE_EX(app_close_blocking_task); -}; - -//! Entrypoint class for registering app_close_blocking_task instances. Introduced in 0.9.5.1. \n -//! Usage: static_api_ptr_t(). May fail if user runs pre-0.9.5.1. It's recommended that you use app_close_blocking_task_impl class instead of calling app_close_blocking_task_manager directly. -class NOVTABLE app_close_blocking_task_manager : public service_base { -public: - virtual void register_task(app_close_blocking_task * task) = 0; - virtual void unregister_task(app_close_blocking_task * task) = 0; - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(app_close_blocking_task_manager); -}; - -//! Helper; implements standard functionality required by app_close_blocking_task implementations - registers/unregisters the task on construction/destruction. -class app_close_blocking_task_impl : public app_close_blocking_task { -public: - app_close_blocking_task_impl() { try { static_api_ptr_t()->register_task(this); } catch(exception_service_not_found) {/*user runs pre-0.9.5.1*/}} - ~app_close_blocking_task_impl() { try { static_api_ptr_t()->unregister_task(this); } catch(exception_service_not_found) {/*user runs pre-0.9.5.1*/}} - - void query_task_name(pfc::string_base & out) { out = ""; } -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk.cpp deleted file mode 100644 index 13dc73a46..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk.cpp +++ /dev/null @@ -1,335 +0,0 @@ -#include "foobar2000.h" - -void audio_chunk::set_data(const audio_sample * src,t_size samples,unsigned nch,unsigned srate,unsigned channel_config) -{ - t_size size = samples * nch; - set_data_size(size); - if (src) - pfc::memcpy_t(get_data(),src,size); - else - pfc::memset_t(get_data(),(audio_sample)0,size); - set_sample_count(samples); - set_channels(nch,channel_config); - set_srate(srate); -} - -static bool check_exclusive(unsigned val, unsigned mask) -{ - return (val&mask)!=0 && (val&mask)!=mask; -} - -namespace { - - template class msvc6_sucks_v2 { public: - inline static void do_fixedpoint_convert(const void * source,unsigned bps,t_size count,audio_sample* buffer) - { - const char * src = (const char *) source; - unsigned bytes = bps>>3; - t_size n; - T max = ((T)1)<<(bps-1); - - T negmask = - max; - - ASSUME(bytes<=sizeof(T)); - - const double div = 1.0 / (double)(1<<(bps-1)); - for(n=0;n(src); - if (b_swap) temp = pfc::byteswap_t(temp); - } - - - - if (!b_signed) temp ^= max; - - if (b_pad) - { - if (temp & max) temp |= negmask; - } - - if (b_pad) - src += bytes; - else - src += sizeof(T); - - - buffer[n] = (audio_sample) ( (double)temp * div ); - } - } - }; - - template class msvc6_sucks { public: - inline static void do_fixedpoint_convert(bool b_swap,bool b_signed,const void * source,unsigned bps,t_size count,audio_sample* buffer) - { - if (sizeof(T)==1) - { - if (b_signed) - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - else - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - } - else if (b_swap) - { - if (b_signed) - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - else - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - } - else - { - if (b_signed) - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - else - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - } - } - }; - - -}; - - -void audio_chunk::set_data_fixedpoint_ex(const void * source,t_size size,unsigned srate,unsigned nch,unsigned bps,unsigned flags,unsigned p_channel_config) -{ - assert( check_exclusive(flags,FLAG_SIGNED|FLAG_UNSIGNED) ); - assert( check_exclusive(flags,FLAG_LITTLE_ENDIAN|FLAG_BIG_ENDIAN) ); - - bool need_swap = !!(flags & FLAG_BIG_ENDIAN); - if (pfc::byte_order_is_big_endian) need_swap = !need_swap; - - t_size count = size / (bps/8); - set_data_size(count); - audio_sample * buffer = get_data(); - bool b_signed = !!(flags & FLAG_SIGNED); - - switch(bps) - { - case 8: - msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - case 16: - if (!need_swap && b_signed) audio_math::convert_from_int16((const t_int16*)source,count,buffer,1.0); - else msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - case 24: - msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - case 32: - if (!need_swap && b_signed) audio_math::convert_from_int32((const t_int32*)source,count,buffer,1.0); - else msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - default: - //unknown size, cant convert - pfc::memset_t(buffer,(audio_sample)0,count); - break; - } - set_sample_count(count/nch); - set_srate(srate); - set_channels(nch,p_channel_config); -} - -template -static void process_float_multi(audio_sample * p_out,const t_float * p_in,const t_size p_count) -{ - t_size n; - for(n=0;n -static void process_float_multi_swap(audio_sample * p_out,const t_float * p_in,const t_size p_count) -{ - t_size n; - for(n=0;n(ptr),count); - else - process_float_multi(out,reinterpret_cast(ptr),count); - } - else if (bps == 64) - { - if (use_swap) - process_float_multi_swap(out,reinterpret_cast(ptr),count); - else - process_float_multi(out,reinterpret_cast(ptr),count); - } - else throw exception_io_data("invalid bit depth"); - - set_sample_count(count/nch); - set_srate(srate); - set_channels(nch,p_channel_config); -} - -bool audio_chunk::is_valid() const -{ - unsigned nch = get_channels(); - if (nch==0 || nch>256) return false; - if (!g_is_valid_sample_rate(get_srate())) return false; - t_size samples = get_sample_count(); - if (samples==0 || samples >= 0x80000000 / (sizeof(audio_sample) * nch) ) return false; - t_size size = get_data_size(); - if (samples * nch > size) return false; - if (!get_data()) return false; - return true; -} - - -void audio_chunk::pad_with_silence_ex(t_size samples,unsigned hint_nch,unsigned hint_srate) { - if (is_empty()) - { - if (hint_srate && hint_nch) { - return set_data(0,samples,hint_nch,hint_srate); - } else throw exception_io_data(); - } - else - { - if (hint_srate && hint_srate != get_srate()) samples = MulDiv_Size(samples,get_srate(),hint_srate); - if (samples > get_sample_count()) - { - t_size old_size = get_sample_count() * get_channels(); - t_size new_size = samples * get_channels(); - set_data_size(new_size); - pfc::memset_t(get_data() + old_size,(audio_sample)0,new_size - old_size); - set_sample_count(samples); - } - } -} - -void audio_chunk::pad_with_silence(t_size samples) { - if (samples > get_sample_count()) - { - t_size old_size = get_sample_count() * get_channels(); - t_size new_size = pfc::multiply_guarded(samples,get_channels()); - set_data_size(new_size); - pfc::memset_t(get_data() + old_size,(audio_sample)0,new_size - old_size); - set_sample_count(samples); - } -} - -void audio_chunk::insert_silence_fromstart(t_size samples) { - t_size old_size = get_sample_count() * get_channels(); - t_size delta = samples * get_channels(); - t_size new_size = old_size + delta; - set_data_size(new_size); - audio_sample * ptr = get_data(); - pfc::memmove_t(ptr+delta,ptr,old_size); - pfc::memset_t(ptr,(audio_sample)0,delta); - set_sample_count(get_sample_count() + samples); -} - -t_size audio_chunk::skip_first_samples(t_size samples_delta) -{ - t_size samples_old = get_sample_count(); - if (samples_delta >= samples_old) - { - set_sample_count(0); - set_data_size(0); - return samples_old; - } - else - { - t_size samples_new = samples_old - samples_delta; - unsigned nch = get_channels(); - audio_sample * ptr = get_data(); - pfc::memmove_t(ptr,ptr+nch*samples_delta,nch*samples_new); - set_sample_count(samples_new); - set_data_size(nch*samples_new); - return samples_delta; - } -} - -audio_sample audio_chunk::get_peak(audio_sample p_peak) const { - return pfc::max_t(p_peak, get_peak()); -} - -audio_sample audio_chunk::get_peak() const { - return audio_math::calculate_peak(get_data(),get_sample_count() * get_channels()); -} - -void audio_chunk::scale(audio_sample p_value) -{ - audio_sample * ptr = get_data(); - audio_math::scale(ptr,get_sample_count() * get_channels(),ptr,p_value); -} - - -static void render_8bit(const audio_sample * in, t_size inLen, void * out) { - t_int8 * outWalk = reinterpret_cast(out); - for(t_size walk = 0; walk < inLen; ++walk) { - *outWalk++ = (t_int8)pfc::clip_t(audio_math::rint32( in[walk] * 0x80 ), -128, 127); - } -} -static void render_24bit(const audio_sample * in, t_size inLen, void * out) { - t_uint8 * outWalk = reinterpret_cast(out); - for(t_size walk = 0; walk < inLen; ++walk) { - const t_int32 v = pfc::clip_t(audio_math::rint32( in[walk] * 0x800000 ), -128 * 256 * 256, 128 * 256 * 256 - 1); - *(outWalk ++) = (t_uint8) (v & 0xFF); - *(outWalk ++) = (t_uint8) ((v >> 8) & 0xFF); - *(outWalk ++) = (t_uint8) ((v >> 16) & 0xFF); - } -} - -bool audio_chunk::to_raw_data(mem_block_container & out, t_uint32 bps) const { - const t_size samples = get_sample_count(); - const t_size dataLen = pfc::multiply_guarded(samples, (t_size)get_channel_count()); - switch(bps) { - case 8: - out.set_size(dataLen); - render_8bit(get_data(), dataLen, out.get_ptr()); - break; - case 16: - out.set_size(dataLen * 2); - audio_math::convert_to_int16(get_data(), dataLen, reinterpret_cast(out.get_ptr()), 1.0); - break; - case 24: - out.set_size(dataLen * 3); - render_24bit(get_data(), dataLen, out.get_ptr()); - break; - case 32: - pfc::static_assert(); - out.set(get_data(), dataLen * sizeof(audio_sample)); - break; - default: - return false; - } - return true; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk.h b/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk.h deleted file mode 100644 index 32988a94f..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk.h +++ /dev/null @@ -1,342 +0,0 @@ -//! Thrown when audio_chunk sample rate or channel mapping changes in mid-stream and the code receiving audio_chunks can't deal with that scenario. -PFC_DECLARE_EXCEPTION(exception_unexpected_audio_format_change, exception_io_data, "Unexpected audio format change" ); - -//! Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation. -class NOVTABLE audio_chunk { -public: - - enum { - sample_rate_min = 1000, sample_rate_max = 1000000 - }; - static bool g_is_valid_sample_rate(t_uint32 p_val) {return p_val >= sample_rate_min && p_val <= sample_rate_max;} - - //! Channel map flag declarations. Note that order of interleaved channel data in the stream is same as order of these flags. - enum - { - channel_front_left = 1<<0, - channel_front_right = 1<<1, - channel_front_center = 1<<2, - channel_lfe = 1<<3, - channel_back_left = 1<<4, - channel_back_right = 1<<5, - channel_front_center_left = 1<<6, - channel_front_center_right = 1<<7, - channel_back_center = 1<<8, - channel_side_left = 1<<9, - channel_side_right = 1<<10, - channel_top_center = 1<<11, - channel_top_front_left = 1<<12, - channel_top_front_center = 1<<13, - channel_top_front_right = 1<<14, - channel_top_back_left = 1<<15, - channel_top_back_center = 1<<16, - channel_top_back_right = 1<<17, - - channel_config_mono = channel_front_center, - channel_config_stereo = channel_front_left | channel_front_right, - channel_config_5point1 = channel_front_left | channel_front_right | channel_back_left | channel_back_right | channel_front_center | channel_lfe, - - defined_channel_count = 18, - }; - - //! Helper function; guesses default channel map for specified channel count. - static unsigned g_guess_channel_config(unsigned count); - -#ifdef _WIN32 - //! Helper function; translates audio_chunk channel map to WAVEFORMATEXTENSIBLE channel map. - static DWORD g_channel_config_to_wfx(unsigned p_config); - //! Helper function; translates WAVEFORMATEXTENSIBLE channel map to audio_chunk channel map. - static unsigned g_channel_config_from_wfx(DWORD p_wfx); -#endif - - //! Extracts flag describing Nth channel from specified map. Usable to figure what specific channel in a stream means. - static unsigned g_extract_channel_flag(unsigned p_config,unsigned p_index); - //! Counts channels specified by channel map. - static unsigned g_count_channels(unsigned p_config); - //! Calculates index of a channel specified by p_flag in a stream where channel map is described by p_config. - static unsigned g_channel_index_from_flag(unsigned p_config,unsigned p_flag); - - - - //! Retrieves audio data buffer pointer (non-const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed. \n - //! Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible. - virtual audio_sample * get_data() = 0; - //! Retrieves audio data buffer pointer (const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed. \n - //! Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible. - virtual const audio_sample * get_data() const = 0; - //! Retrieves size of allocated buffer space, in audio_samples. - virtual t_size get_data_size() const = 0; - //! Resizes audio data buffer to specified size. Throws std::bad_alloc on failure. - virtual void set_data_size(t_size p_new_size) = 0; - - //! Retrieves sample rate of contained audio data. - virtual unsigned get_srate() const = 0; - //! Sets sample rate of contained audio data. - virtual void set_srate(unsigned val) = 0; - //! Retrieves channel count of contained audio data. - virtual unsigned get_channels() const = 0; - //! Helper - for consistency - same as get_channels(). - inline unsigned get_channel_count() const {return get_channels();} - //! Retrieves channel map of contained audio data. Conditions where number of channels specified by channel map don't match get_channels() return value should not be possible. - virtual unsigned get_channel_config() const = 0; - //! Sets channel count / channel map. - virtual void set_channels(unsigned p_count,unsigned p_config) = 0; - - //! Retrieves number of valid samples in the buffer. \n - //! Note that a "sample" means a unit of interleaved PCM data representing states of each channel at given point of time, not a single PCM value. \n - //! For an example, duration of contained audio data is equal to sample count / sample rate, while actual size of contained data is equal to sample count * channel count. - virtual t_size get_sample_count() const = 0; - - //! Sets number of valid samples in the buffer. WARNING: sample count * channel count should never be above allocated buffer size. - virtual void set_sample_count(t_size val) = 0; - - //! Helper, same as get_srate(). - inline unsigned get_sample_rate() const {return get_srate();} - //! Helper, same as set_srate(). - inline void set_sample_rate(unsigned val) {set_srate(val);} - - //! Helper; sets channel count to specified value and uses default channel map for this channel count. - void set_channels(unsigned val) {set_channels(val,g_guess_channel_config(val));} - - - //! Helper; resizes audio data buffer when it's current size is smaller than requested. - inline void grow_data_size(t_size p_requested) {if (p_requested > get_data_size()) set_data_size(p_requested);} - - - //! Retrieves duration of contained audio data, in seconds. - inline double get_duration() const - { - double rv = 0; - t_size srate = get_srate (), samples = get_sample_count(); - if (srate>0 && samples>0) rv = (double)samples/(double)srate; - return rv; - } - - //! Returns whether the chunk is empty (contains no audio data). - inline bool is_empty() const {return get_channels()==0 || get_srate()==0 || get_sample_count()==0;} - - //! Returns whether the chunk contents are valid (for bug check purposes). - bool is_valid() const; - - //! Returns actual amount of audio data contained in the buffer (sample count * channel count). Must not be greater than data size (see get_data_size()). - inline t_size get_data_length() const {return get_sample_count() * get_channels();} - - //! Resets all audio_chunk data. - inline void reset() { - set_sample_count(0); - set_srate(0); - set_channels(0); - set_data_size(0); - } - - //! Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample rate / channel map. - void set_data(const audio_sample * src,t_size samples,unsigned nch,unsigned srate,unsigned channel_config); - - //! Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample rate, using default channel map for specified channel count. - inline void set_data(const audio_sample * src,t_size samples,unsigned nch,unsigned srate) {set_data(src,samples,nch,srate,g_guess_channel_config(nch));} - - //! Helper, sets chunk data to contents of specified buffer, using default win32/wav conventions for signed/unsigned switch. - inline void set_data_fixedpoint(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config) { - set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,(bps==8 ? FLAG_UNSIGNED : FLAG_SIGNED) | flags_autoendian(), channel_config); - } - - inline void set_data_fixedpoint_unsigned(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config) { - return set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,FLAG_UNSIGNED | flags_autoendian(), channel_config); - } - - inline void set_data_fixedpoint_signed(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config) { - return set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,FLAG_SIGNED | flags_autoendian(), channel_config); - } - - enum - { - FLAG_LITTLE_ENDIAN = 1, - FLAG_BIG_ENDIAN = 2, - FLAG_SIGNED = 4, - FLAG_UNSIGNED = 8, - }; - - inline static unsigned flags_autoendian() { - return pfc::byte_order_is_big_endian ? FLAG_BIG_ENDIAN : FLAG_LITTLE_ENDIAN; - } - - void set_data_fixedpoint_ex(const void * ptr,t_size bytes,unsigned p_sample_rate,unsigned p_channels,unsigned p_bits_per_sample,unsigned p_flags,unsigned p_channel_config);//p_flags - see FLAG_* above - - void set_data_floatingpoint_ex(const void * ptr,t_size bytes,unsigned p_sample_rate,unsigned p_channels,unsigned p_bits_per_sample,unsigned p_flags,unsigned p_channel_config);//signed/unsigned flags dont apply - - inline void set_data_32(const float * src,t_size samples,unsigned nch,unsigned srate) {return set_data(src,samples,nch,srate);} - - void pad_with_silence_ex(t_size samples,unsigned hint_nch,unsigned hint_srate); - void pad_with_silence(t_size samples); - void insert_silence_fromstart(t_size samples); - t_size skip_first_samples(t_size samples); - - //! Simple function to get original PCM stream back. Assumes host's endianness, integers are signed - including the 8bit mode; 32bit mode assumed to be float. - //! @returns false when the conversion could not be performed because of unsupported bit depth etc. - bool to_raw_data(class mem_block_container & out, t_uint32 bps) const; - - - //! Helper, calculates peak value of data in the chunk. The optional parameter specifies initial peak value, to simplify calling code. - audio_sample get_peak(audio_sample p_peak) const; - audio_sample get_peak() const; - - //! Helper function; scales entire chunk content by specified value. - void scale(audio_sample p_value); - - //! Helper; copies content of another audio chunk to this chunk. - void copy(const audio_chunk & p_source) { - set_data(p_source.get_data(),p_source.get_sample_count(),p_source.get_channels(),p_source.get_srate(),p_source.get_channel_config()); - } - - const audio_chunk & operator=(const audio_chunk & p_source) { - copy(p_source); - return *this; - } -protected: - audio_chunk() {} - ~audio_chunk() {} -}; - -//! Implementation of audio_chunk. Takes pfc allocator template as template parameter. -template class t_alloc = pfc::alloc_standard> -class audio_chunk_impl_t : public audio_chunk { - typedef audio_chunk_impl_t t_self; - pfc::array_t m_data; - unsigned m_srate,m_nch,m_setup; - t_size m_samples; -public: - audio_chunk_impl_t() : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {} - audio_chunk_impl_t(const audio_sample * src,unsigned samples,unsigned nch,unsigned srate) : m_srate(0), m_nch(0), m_samples(0) - {set_data(src,samples,nch,srate);} - audio_chunk_impl_t(const audio_chunk & p_source) : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {copy(p_source);} - audio_chunk_impl_t(const t_self & p_source) : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {copy(p_source);} - - virtual audio_sample * get_data() {return m_data.get_ptr();} - virtual const audio_sample * get_data() const {return m_data.get_ptr();} - virtual t_size get_data_size() const {return m_data.get_size();} - virtual void set_data_size(t_size new_size) {m_data.set_size(new_size);} - - virtual unsigned get_srate() const {return m_srate;} - virtual void set_srate(unsigned val) {m_srate=val;} - virtual unsigned get_channels() const {return m_nch;} - virtual unsigned get_channel_config() const {return m_setup;} - virtual void set_channels(unsigned val,unsigned setup) {m_nch = val;m_setup = setup;} - void set_channels(unsigned val) {set_channels(val,g_guess_channel_config(val));} - - virtual t_size get_sample_count() const {return m_samples;} - virtual void set_sample_count(t_size val) {m_samples = val;} - - const t_self & operator=(const audio_chunk & p_source) {copy(p_source);return *this;} - const t_self & operator=(const t_self & p_source) {copy(p_source);return *this;} -}; - -typedef audio_chunk_impl_t<> audio_chunk_impl; -typedef audio_chunk_impl_t audio_chunk_impl_temporary; -typedef audio_chunk_impl audio_chunk_i;//for compatibility - -//! Implements const methods of audio_chunk only, referring to an external buffer. For temporary use only (does not maintain own storage), e.g.: somefunc( audio_chunk_temp_impl(mybuffer,....) ); -class audio_chunk_temp_impl : public audio_chunk { -public: - audio_chunk_temp_impl(const audio_sample * p_data,t_size p_samples,t_uint32 p_sample_rate,t_uint32 p_channels,t_uint32 p_channel_config) : - m_data(p_data), m_samples(p_samples), m_sample_rate(p_sample_rate), m_channels(p_channels), m_channel_config(p_channel_config) - { - PFC_ASSERT(is_valid()); - } - - audio_sample * get_data() {throw pfc::exception_not_implemented();} - const audio_sample * get_data() const {return m_data;} - t_size get_data_size() const {return m_samples * m_channels;} - void set_data_size(t_size p_new_size) {throw pfc::exception_not_implemented();} - - unsigned get_srate() const {return m_sample_rate;} - void set_srate(unsigned val) {throw pfc::exception_not_implemented();} - unsigned get_channels() const {return m_channels;} - unsigned get_channel_config() const {return m_channel_config;} - void set_channels(unsigned p_count,unsigned p_config) {throw pfc::exception_not_implemented();} - - t_size get_sample_count() const {return m_samples;} - - void set_sample_count(t_size val) {throw pfc::exception_not_implemented();} - -private: - t_size m_samples; - t_uint32 m_sample_rate,m_channels,m_channel_config; - const audio_sample * m_data; -}; - - - -//! Duration counter class - accumulates duration using sample values, without any kind of rounding error accumulation. -class duration_counter { -public: - duration_counter() : m_offset() { - } - void set(double v) { - m_sampleCounts.remove_all(); - m_offset = v; - } - void reset() { - set(0); - } - - void add(double v) {m_offset += v;} - void subtract(double v) {m_offset -= v;} - - double query() const { - double acc = m_offset; - for(t_map::const_iterator walk = m_sampleCounts.first(); walk.is_valid(); ++walk) { - acc += audio_math::samples_to_time(walk->m_value, walk->m_key); - } - return acc; - } - void add(const audio_chunk & c) { - add(c.get_sample_count(), c.get_sample_rate()); - } - void add(t_uint64 sampleCount, t_uint32 sampleRate) { - PFC_ASSERT( sampleRate > 0 ); - if (sampleRate > 0 && sampleCount > 0) { - m_sampleCounts.find_or_add(sampleRate) += sampleCount; - } - } - void add(const duration_counter & other) { - add(other.m_offset); - for(t_map::const_iterator walk = other.m_sampleCounts.first(); walk.is_valid(); ++walk) { - add(walk->m_value, walk->m_key); - } - } - void subtract(const duration_counter & other) { - subtract(other.m_offset); - for(t_map::const_iterator walk = other.m_sampleCounts.first(); walk.is_valid(); ++walk) { - subtract(walk->m_value, walk->m_key); - } - } - void subtract(t_uint64 sampleCount, t_uint32 sampleRate) { - PFC_ASSERT( sampleRate > 0 ); - if (sampleRate > 0 && sampleCount > 0) { - t_uint64 * val = m_sampleCounts.query_ptr(sampleRate); - if (val == NULL) throw pfc::exception_invalid_params(); - if (*val < sampleCount) throw pfc::exception_invalid_params(); - else if (*val == sampleCount) { - m_sampleCounts.remove(sampleRate); - } else { - *val -= sampleCount; - } - - } - } - void subtract(const audio_chunk & c) { - subtract(c.get_sample_count(), c.get_sample_rate()); - } - template duration_counter & operator+=(const t_source & source) {add(source); return *this;} - template duration_counter & operator-=(const t_source & source) {subtract(source); return *this;} - template duration_counter & operator=(const t_source & source) {reset(); add(source); return *this;} -private: - double m_offset; - typedef pfc::map_t t_map; - t_map m_sampleCounts; -}; - -class audio_chunk_partial_ref : public audio_chunk_temp_impl { -public: - audio_chunk_partial_ref(const audio_chunk & chunk, t_size base, t_size count) : audio_chunk_temp_impl(chunk.get_data() + base * chunk.get_channels(), count, chunk.get_sample_rate(), chunk.get_channels(), chunk.get_channel_config()) {} -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk_channel_config.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk_channel_config.cpp deleted file mode 100644 index 16caed4c0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_chunk_channel_config.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "foobar2000.h" - -#ifdef _WIN32 -#include -#include - -#if 0 -#define SPEAKER_FRONT_LEFT 0x1 -#define SPEAKER_FRONT_RIGHT 0x2 -#define SPEAKER_FRONT_CENTER 0x4 -#define SPEAKER_LOW_FREQUENCY 0x8 -#define SPEAKER_BACK_LEFT 0x10 -#define SPEAKER_BACK_RIGHT 0x20 -#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40 -#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 -#define SPEAKER_BACK_CENTER 0x100 -#define SPEAKER_SIDE_LEFT 0x200 -#define SPEAKER_SIDE_RIGHT 0x400 -#define SPEAKER_TOP_CENTER 0x800 -#define SPEAKER_TOP_FRONT_LEFT 0x1000 -#define SPEAKER_TOP_FRONT_CENTER 0x2000 -#define SPEAKER_TOP_FRONT_RIGHT 0x4000 -#define SPEAKER_TOP_BACK_LEFT 0x8000 -#define SPEAKER_TOP_BACK_CENTER 0x10000 -#define SPEAKER_TOP_BACK_RIGHT 0x20000 -#endif - -static struct {DWORD m_wfx; unsigned m_native; } const g_translation_table[] = -{ - {SPEAKER_FRONT_LEFT, audio_chunk::channel_front_left}, - {SPEAKER_FRONT_RIGHT, audio_chunk::channel_front_right}, - {SPEAKER_FRONT_CENTER, audio_chunk::channel_front_center}, - {SPEAKER_LOW_FREQUENCY, audio_chunk::channel_lfe}, - {SPEAKER_BACK_LEFT, audio_chunk::channel_back_left}, - {SPEAKER_BACK_RIGHT, audio_chunk::channel_back_right}, - {SPEAKER_FRONT_LEFT_OF_CENTER, audio_chunk::channel_front_center_left}, - {SPEAKER_FRONT_RIGHT_OF_CENTER, audio_chunk::channel_front_center_right}, - {SPEAKER_BACK_CENTER, audio_chunk::channel_back_center}, - {SPEAKER_SIDE_LEFT, audio_chunk::channel_side_left}, - {SPEAKER_SIDE_RIGHT, audio_chunk::channel_side_right}, - {SPEAKER_TOP_CENTER, audio_chunk::channel_top_center}, - {SPEAKER_TOP_FRONT_LEFT, audio_chunk::channel_top_front_left}, - {SPEAKER_TOP_FRONT_CENTER, audio_chunk::channel_top_front_center}, - {SPEAKER_TOP_FRONT_RIGHT, audio_chunk::channel_top_front_right}, - {SPEAKER_TOP_BACK_LEFT, audio_chunk::channel_top_back_left}, - {SPEAKER_TOP_BACK_CENTER, audio_chunk::channel_top_back_center}, - {SPEAKER_TOP_BACK_RIGHT, audio_chunk::channel_top_back_right}, -}; - - -DWORD audio_chunk::g_channel_config_to_wfx(unsigned p_config) -{ - DWORD ret = 0; - unsigned n; - for(n=0;n= tabsize(g_audio_channel_config_table)) return 0; - return g_audio_channel_config_table[count]; -} - - -unsigned audio_chunk::g_channel_index_from_flag(unsigned p_config,unsigned p_flag) { - unsigned index = 0; - for(unsigned walk = 0; walk < 32; walk++) { - unsigned query = 1 << walk; - if (p_flag & query) return index; - if (p_config & query) index++; - } - return infinite; -} - -unsigned audio_chunk::g_extract_channel_flag(unsigned p_config,unsigned p_index) -{ - unsigned toskip = p_index; - unsigned flag = 1; - while(flag) - { - if (p_config & flag) - { - if (toskip == 0) break; - toskip--; - } - flag <<= 1; - } - return flag; -} - -unsigned audio_chunk::g_count_channels(unsigned p_config) -{ - unsigned ret = 0; - while(p_config) { - ret += (p_config & 1); - p_config >>= 1; - } - return ret; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_postprocessor.h b/tools/vio2sf/src/foobar/foobar2000/SDK/audio_postprocessor.h deleted file mode 100644 index 4153d2865..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/audio_postprocessor.h +++ /dev/null @@ -1,25 +0,0 @@ -//! This class handles conversion of audio data (audio_chunk) to various linear PCM types, with optional dithering. - -class NOVTABLE audio_postprocessor : public service_base -{ -public: - //! Processes one chunk of audio data. - //! @param p_chunk Chunk of audio data to process. - //! @param p_output Receives output linear signed PCM data. - //! @param p_out_bps Desired bit depth of output. - //! @param p_out_bps_physical Desired physical word width of output. Must be either 8, 16, 24 or 32, greater or equal to p_out_bps. This is typically set to same value as p_out_bps. - //! @param p_dither Indicates whether dithering should be used. Note that dithering is CPU-heavy. - //! @param p_prescale Value to scale all audio samples by when converting. Set to 1.0 to do nothing. - - virtual void run(const audio_chunk & p_chunk, - mem_block_container & p_output, - t_uint32 p_out_bps, - t_uint32 p_out_bps_physical, - bool p_dither, - audio_sample p_prescale - ) = 0; - - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(audio_postprocessor); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/autoplaylist.h b/tools/vio2sf/src/foobar/foobar2000/SDK/autoplaylist.h deleted file mode 100644 index 6417fd375..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/autoplaylist.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - Autoplaylist APIs - These APIs were introduced in foobar2000 0.9.5, to reduce amount of code required to create your own autoplaylists. Creation of autoplaylists is was also possible before through playlist lock APIs. - In most cases, you'll want to turn regular playlists into autoplaylists using the following code: - static_api_ptr_t()->add_client_simple(querypattern, sortpattern, playlistindex, forceSort ? autoplaylist_flag_sort : 0); - If you require more advanced functionality, such as using your own code to filter which part of user's Media Library should be placed in specific autoplaylist, you must implement autoplaylist_client (to let autoplaylist manager invoke your handlers when needed) / autoplaylist_client_factory (to re-instantiate your autoplaylist_client after a foobar2000 restart cycle). -*/ - -enum { - //! When set, core will keep the autoplaylist sorted and prevent user from reordering it. - autoplaylist_flag_sort = 1 << 0, -}; -//! Main class controlling autoplaylist behaviors. Implemented by autoplaylist client in scenarios where simple query/sort strings are not enough (core provides a standard implementation for simple queries). -class NOVTABLE autoplaylist_client : public service_base { -public: - virtual GUID get_guid() = 0; - //! Called only inside a metadb lock for performance reasons. - virtual void filter(metadb_handle_list_cref data, bool * out) = 0; - //! Return true when you have filled p_orderbuffer with a permutation to apply to p_items, false when you don't support sorting (core's own sort scheme will be applied). - virtual bool sort(metadb_handle_list_cref p_items,t_size * p_orderbuffer) = 0; - //! Retrieves your configuration data to be used later when re-instantiating your autoplaylist_client after a restart. - virtual void get_configuration(stream_writer * p_stream,abort_callback & p_abort) = 0; - - virtual void show_ui(t_size p_source_playlist) = 0; - - //! Helper. - template void get_configuration(t_array & p_out) { - pfc::static_assert(); - typedef pfc::array_t t_temp; t_temp temp; - get_configuration(&stream_writer_buffer_append_ref_t(temp),abort_callback_impl()); - p_out = temp; - } - - - FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_client,service_base) -}; - -typedef service_ptr_t autoplaylist_client_ptr; - -//! Supported from 0.9.5.3 up. -class NOVTABLE autoplaylist_client_v2 : public autoplaylist_client { -public: - //! Sets a completion_notify object that the autoplaylist_client implementation should call when its filtering behaviors have changed so the whole playlist needs to be rebuilt. \n - //! completion_notify::on_completion() status parameter meaning: \n - //! 0.9.5.3 : ignored. \n - //! 0.9.5.4 and newer: set to 1 to indicate that your configuration has changed as well (for an example as a result of user edits) to get a get_configuration() call as well as cause the playlist to be rebuilt; set to zero otherwise - when the configuration hasn't changed but the playlist needs to be rebuilt as a result of some other event. - virtual void set_full_refresh_notify(completion_notify::ptr notify) = 0; - - //! Returns whether the show_ui() method is available / does anything useful with out implementation (not everyone implements show_ui). - virtual bool show_ui_available() = 0; - - //! Returns a human-readable autoplaylist implementer's label to display in playlist's context menu / description / etc. - virtual void get_display_name(pfc::string_base & out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_client_v2, autoplaylist_client); -}; - -//! Class needed to re-instantiate autoplaylist_client after a restart. Not directly needed to set up an autoplaylist_client, but without it, your autoplaylist will be lost after a restart. -class NOVTABLE autoplaylist_client_factory : public service_base { -public: - //! Must return same GUID as your autoplaylist_client::get_guid() - virtual GUID get_guid() = 0; - //! Instantiates your autoplaylist_client with specified configuration. - virtual autoplaylist_client_ptr instantiate(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(autoplaylist_client_factory) -}; - -PFC_DECLARE_EXCEPTION(exception_autoplaylist,pfc::exception,"Autoplaylist error") - -PFC_DECLARE_EXCEPTION(exception_autoplaylist_already_owned,exception_autoplaylist,"This playlist is already an autoplaylist") -PFC_DECLARE_EXCEPTION(exception_autoplaylist_not_owned,exception_autoplaylist,"This playlist is not an autoplaylist") -PFC_DECLARE_EXCEPTION(exception_autoplaylist_lock_failure,exception_autoplaylist,"Playlist could not be locked") - - -//! Primary class for managing autoplaylists. Implemented by core, do not reimplement; instantiate using static_api_ptr_t. -class NOVTABLE autoplaylist_manager : public service_base { -public: - //! Throws exception_autoplaylist or one of its subclasses on failure. - //! @param p_flags See autoplaylist_flag_* constants. - virtual void add_client(autoplaylist_client_ptr p_client,t_size p_playlist,t_uint32 p_flags) = 0; - virtual bool is_client_present(t_size p_playlist) = 0; - //! Throws exception_autoplaylist or one of its subclasses on failure (eg. not an autoplaylist). - virtual autoplaylist_client_ptr query_client(t_size p_playlist) = 0; - virtual void remove_client(t_size p_playlist) = 0; - //! Helper; sets up an autoplaylist using standard autoplaylist_client implementation based on simple query/sort strings. When using this, you don't need to maintain own autoplaylist_client/autoplaylist_client_factory implementations, and autoplaylists that you create will not be lost when your DLL is removed, as opposed to using add_client() directly. - //! Throws exception_autoplaylist or one of its subclasses on failure. - //! @param p_flags See autoplaylist_flag_* constants. - virtual void add_client_simple(const char * p_query,const char * p_sort,t_size p_playlist,t_uint32 p_flags) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(autoplaylist_manager) -}; - -//! \since 0.9.5.4 -//! Extended version of autoplaylist_manager, available from 0.9.5.4 up, with methods allowing modification of autoplaylist flags. -class NOVTABLE autoplaylist_manager_v2 : public autoplaylist_manager { - FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_manager_v2, autoplaylist_manager) -public: - virtual t_uint32 get_client_flags(t_size playlist) = 0; - virtual void set_client_flags(t_size playlist, t_uint32 newFlags) = 0; - - //! For use with autoplaylist client configuration dialogs. It's recommended not to call this from anything else. - virtual t_uint32 get_client_flags(autoplaylist_client::ptr client) = 0; - //! For use with autoplaylist client configuration dialogs. It's recommended not to call this from anything else. - virtual void set_client_flags(autoplaylist_client::ptr client, t_uint32 newFlags) = 0; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/cfg_var.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/cfg_var.cpp deleted file mode 100644 index b37401416..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/cfg_var.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "foobar2000.h" - -cfg_var_reader * cfg_var_reader::g_list = NULL; -cfg_var_writer * cfg_var_writer::g_list = NULL; - -void cfg_var_reader::config_read_file(stream_reader * p_stream,abort_callback & p_abort) -{ - pfc::map_t vars; - for(cfg_var_reader * walk = g_list; walk != NULL; walk = walk->m_next) { - vars.set(walk->m_guid,walk); - } - for(;;) { - - GUID guid; - t_uint32 size; - - if (p_stream->read(&guid,sizeof(guid),p_abort) != sizeof(guid)) break; - guid = pfc::byteswap_if_be_t(guid); - p_stream->read_lendian_t(size,p_abort); - - cfg_var_reader * var; - if (vars.query(guid,var)) { - stream_reader_limited_ref wrapper(p_stream,size); - try { - var->set_data_raw(&wrapper,size,p_abort); - } catch(exception_io_data) {} - wrapper.flush_remaining(p_abort); - } else { - p_stream->skip_object(size,p_abort); - } - } -} - -void cfg_var_writer::config_write_file(stream_writer * p_stream,abort_callback & p_abort) { - cfg_var_writer * ptr; - pfc::array_t temp; - for(ptr = g_list; ptr; ptr = ptr->m_next) { - temp.set_size(0); - ptr->get_data_raw(&stream_writer_buffer_append_ref_t >(temp),p_abort); - p_stream->write_lendian_t(ptr->m_guid,p_abort); - p_stream->write_lendian_t(pfc::downcast_guarded(temp.get_size()),p_abort); - if (temp.get_size() > 0) { - p_stream->write_object(temp.get_ptr(),temp.get_size(),p_abort); - } - } -} - - -void cfg_string::get_data_raw(stream_writer * p_stream,abort_callback & p_abort) { - p_stream->write_object(get_ptr(),length(),p_abort); -} - -void cfg_string::set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - pfc::string8_fastalloc temp; - p_stream->read_string_raw(temp,p_abort); - set_string(temp); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/cfg_var.h b/tools/vio2sf/src/foobar/foobar2000/SDK/cfg_var.h deleted file mode 100644 index e3f00388e..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/cfg_var.h +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef _FOOBAR2000_SDK_CFG_VAR_H_ -#define _FOOBAR2000_SDK_CFG_VAR_H_ - -#define CFG_VAR_ASSERT_SAFEINIT PFC_ASSERT(!core_api::are_services_available());/*imperfect check for nonstatic instantiation*/ - - -//! Reader part of cfg_var object. In most cases, you should use cfg_var instead of using cfg_var_reader directly. -class NOVTABLE cfg_var_reader { -public: - //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. - cfg_var_reader(const GUID & guid) : m_guid(guid) { CFG_VAR_ASSERT_SAFEINIT; m_next = g_list; g_list = this; } - ~cfg_var_reader() { CFG_VAR_ASSERT_SAFEINIT; } - - //! Sets state of the variable. Called only from main thread, when reading configuration file. - //! @param p_stream Stream containing new state of the variable. - //! @param p_sizehint Number of bytes contained in the stream; reading past p_sizehint bytes will fail (EOF). - virtual void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) = 0; - - //! For internal use only, do not call. - static void config_read_file(stream_reader * p_stream,abort_callback & p_abort); - - const GUID m_guid; -private: - static cfg_var_reader * g_list; - cfg_var_reader * m_next; - - PFC_CLASS_NOT_COPYABLE_EX(cfg_var_reader) -}; - -//! Writer part of cfg_var object. In most cases, you should use cfg_var instead of using cfg_var_writer directly. -class NOVTABLE cfg_var_writer { -public: - //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. - cfg_var_writer(const GUID & guid) : m_guid(guid) { CFG_VAR_ASSERT_SAFEINIT; m_next = g_list; g_list = this;} - ~cfg_var_writer() { CFG_VAR_ASSERT_SAFEINIT; } - - //! Retrieves state of the variable. Called only from main thread, when writing configuration file. - //! @param p_stream Stream receiving state of the variable. - virtual void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) = 0; - - //! For internal use only, do not call. - static void config_write_file(stream_writer * p_stream,abort_callback & p_abort); - - const GUID m_guid; -private: - static cfg_var_writer * g_list; - cfg_var_writer * m_next; - - PFC_CLASS_NOT_COPYABLE_EX(cfg_var_writer) -}; - -//! Base class for configuration variable classes; provides self-registration mechaisms and methods to set/retrieve configuration data; those methods are automatically called for all registered instances by backend when configuration file is being read or written.\n -//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). -class NOVTABLE cfg_var : public cfg_var_reader, public cfg_var_writer { -protected: - //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. - cfg_var(const GUID & p_guid) : cfg_var_reader(p_guid), cfg_var_writer(p_guid) {} -public: - GUID get_guid() const {return cfg_var_reader::m_guid;} -}; - -//! Generic integer config variable class. Template parameter can be used to specify integer type to use.\n -//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). -template -class cfg_int_t : public cfg_var { -private: - t_inttype m_val; -protected: - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {p_stream->write_lendian_t(m_val,p_abort);} - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - t_inttype temp; - p_stream->read_lendian_t(temp,p_abort);//alter member data only on success, this will throw an exception when something isn't right - m_val = temp; - } - -public: - //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. - //! @param p_default Default value of the variable. - explicit inline cfg_int_t(const GUID & p_guid,t_inttype p_default) : cfg_var(p_guid), m_val(p_default) {} - - inline const cfg_int_t & operator=(const cfg_int_t & p_val) {m_val=p_val.m_val;return *this;} - inline t_inttype operator=(t_inttype p_val) {m_val=p_val;return m_val;} - - inline operator t_inttype() const {return m_val;} - - inline t_inttype get_value() const {return m_val;} -}; - -typedef cfg_int_t cfg_int; -typedef cfg_int_t cfg_uint; -//! Since relevant byteswapping functions also understand GUIDs, this can be abused to declare a cfg_guid. -typedef cfg_int_t cfg_guid; -typedef cfg_int_t cfg_bool; - -//! String config variable. Stored in the stream with int32 header containing size in bytes, followed by non-null-terminated UTF-8 data.\n -//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). -class cfg_string : public cfg_var, public pfc::string8 -{ -protected: - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort); - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort); - -public: - //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. - //! @param p_defaultval Default/initial value of the variable. - explicit inline cfg_string(const GUID & p_guid,const char * p_defaultval) : cfg_var(p_guid), pfc::string8(p_defaultval) {} - - inline const cfg_string& operator=(const cfg_string & p_val) {set_string(p_val);return *this;} - inline const cfg_string& operator=(const char* p_val) {set_string(p_val);return *this;} - - inline operator const char * () const {return get_ptr();} - -}; - -//! Struct config variable template. Warning: not endian safe, should be used only for nonportable code.\n -//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such). -template -class cfg_struct_t : public cfg_var { -private: - t_struct m_val; -protected: - - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {p_stream->write_object(&m_val,sizeof(m_val),p_abort);} - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - t_struct temp; - p_stream->read_object(&temp,sizeof(temp),p_abort); - m_val = temp; - } -public: - //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. - inline cfg_struct_t(const GUID & p_guid,const t_struct & p_val) : cfg_var(p_guid), m_val(p_val) {} - //! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var. - inline cfg_struct_t(const GUID & p_guid,int filler) : cfg_var(p_guid) {memset(&m_val,filler,sizeof(t_struct));} - - inline const cfg_struct_t & operator=(const cfg_struct_t & p_val) {m_val = p_val.get_value();return *this;} - inline const cfg_struct_t & operator=(const t_struct & p_val) {m_val = p_val;return *this;} - - inline const t_struct& get_value() const {return m_val;} - inline t_struct& get_value() {return m_val;} - inline operator t_struct() const {return m_val;} -}; - - -template -class cfg_objList : public cfg_var, public pfc::list_t { -public: - cfg_objList(const GUID& guid) : cfg_var(guid) {} - template cfg_objList(const GUID& guid, const TSource (& source)[Count]) : cfg_var(guid) { - reset(source); - } - template void reset(const TSource (& source)[Count]) { - set_size(Count); for(t_size walk = 0; walk < Count; ++walk) (*this)[walk] = source[walk]; - } - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) { - stream_writer_formatter<> out(*p_stream,p_abort); - out << pfc::downcast_guarded(get_size()); - for(t_size walk = 0; walk < get_size(); ++walk) out << (*this)[walk]; - } - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - try { - stream_reader_formatter<> in(*p_stream,p_abort); - t_uint32 count; in >> count; - set_count(count); - for(t_uint32 walk = 0; walk < count; ++walk) in >> (*this)[walk]; - } catch(...) { - remove_all(); - throw; - } - } -}; -template -class cfg_objListEx : public cfg_var, public TList { -public: - cfg_objListEx(const GUID & guid) : cfg_var(guid) {} - void get_data_raw(stream_writer * p_stream, abort_callback & p_abort) { - stream_writer_formatter<> out(*p_stream,p_abort); - out << pfc::downcast_guarded(this->get_count()); - for(typename TList::const_iterator walk = this->first(); walk.is_valid(); ++walk) out << *walk; - } - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - remove_all(); - stream_reader_formatter<> in(*p_stream,p_abort); - t_uint32 count; in >> count; - for(t_uint32 walk = 0; walk < count; ++walk) { - typename TList::t_item item; in >> item; this->add_item(item); - } - } -}; - -template -class cfg_obj : public cfg_var, public TObj { -public: - cfg_obj(const GUID& guid) : cfg_var(guid), TObj() {} - template cfg_obj(const GUID& guid,const TInitData& initData) : cfg_var(guid), TObj(initData) {} - - TObj & val() {return *this;} - TObj const & val() const {return *this;} - - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) { - stream_writer_formatter<> out(*p_stream,p_abort); - const TObj * ptr = this; - out << *ptr; - } - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - stream_reader_formatter<> in(*p_stream,p_abort); - TObj * ptr = this; - in >> *ptr; - } -}; - -template class cfg_objListImporter : private cfg_var_reader { -public: - typedef cfg_objList TMasterVar; - cfg_objListImporter(TMasterVar & var, const GUID & guid) : m_var(var), cfg_var_reader(guid) {} - -private: - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - TImport temp; - try { - stream_reader_formatter<> in(*p_stream,p_abort); - t_uint32 count; in >> count; - m_var.set_count(count); - for(t_uint32 walk = 0; walk < count; ++walk) { - in >> temp; - m_var[walk] = temp; - } - } catch(...) { - m_var.remove_all(); - throw; - } - } - TMasterVar & m_var; -}; - -#endif diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/chapterizer.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/chapterizer.cpp deleted file mode 100644 index e933088d1..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/chapterizer.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "foobar2000.h" - -void chapter_list::copy(const chapter_list & p_source) -{ - t_size n, count = p_source.get_chapter_count(); - set_chapter_count(count); - for(n=0;n & p_out,const char * p_path,abort_callback & p_abort) -{ - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) - { - if (ptr->is_our_file(p_path,p_abort)) - { - p_out = ptr; - return true; - } - } - return false; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/chapterizer.h b/tools/vio2sf/src/foobar/foobar2000/SDK/chapterizer.h deleted file mode 100644 index 0e340aecd..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/chapterizer.h +++ /dev/null @@ -1,72 +0,0 @@ -//! Interface for object storing list of chapters. -class NOVTABLE chapter_list { -public: - //! Returns number of chapters. - virtual t_size get_chapter_count() const = 0; - //! Queries description of specified chapter. - //! @param p_chapter Index of chapter to query, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash). - //! @returns reference to file_info object describing specified chapter (length part of file_info indicates distance between beginning of this chapter and next chapter mark). Returned reference value for temporary use only, becomes invalid after any non-const operation on the chapter_list object. - virtual const file_info & get_info(t_size p_chapter) const = 0; - - //! Sets number of chapters. - virtual void set_chapter_count(t_size p_count) = 0; - //! Modifies description of specified chapter. - //! @param p_chapter_index Index of chapter to modify, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash). - //! @param p_info New chapter description. Note that length part of file_info is used to calculate chapter marks. - virtual void set_info(t_size p_chapter,const file_info & p_info) = 0; - - //! Copies contents of specified chapter_list object to this object. - void copy(const chapter_list & p_source); - - inline const chapter_list & operator=(const chapter_list & p_source) {copy(p_source); return *this;} - -protected: - chapter_list() {} - ~chapter_list() {} -}; - -//! Implements chapter_list. -class chapter_list_impl : public chapter_list -{ -public: - chapter_list_impl(const chapter_list_impl & p_source) {copy(p_source);} - chapter_list_impl(const chapter_list & p_source) {copy(p_source);} - chapter_list_impl() {} - - const chapter_list_impl & operator=(const chapter_list_impl & p_source) {copy(p_source); return *this;} - const chapter_list_impl & operator=(const chapter_list & p_source) {copy(p_source); return *this;} - - t_size get_chapter_count() const {return m_infos.get_size();} - const file_info & get_info(t_size p_chapter) const {return m_infos[p_chapter];} - - void set_chapter_count(t_size p_count) {m_infos.set_size(p_count);} - void set_info(t_size p_chapter,const file_info & p_info) {m_infos[p_chapter] = p_info;} -private: - pfc::array_t m_infos; -}; - - -//! This service implements chapter list editing operations for various file formats, e.g. for MP4 chapters or CD images with embedded cuesheets. Used by converter "encode single file with chapters" feature. -class NOVTABLE chapterizer : public service_base { -public: - //! Tests whether specified path is supported by this implementation. - //! @param p_path Path of file to examine. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual bool is_our_file(const char * p_path,abort_callback & p_abort) = 0; - - //! Writes new chapter list to specified file. - //! @param p_path Path of file to modify. - //! @param p_list New chapter list to write. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void set_chapters(const char * p_path,chapter_list const & p_list,abort_callback & p_abort) = 0; - //! Retrieves chapter list from specified file. - //! @param p_path Path of file to examine. - //! @param p_list Object receiving chapter list. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void get_chapters(const char * p_path,chapter_list & p_list,abort_callback & p_abort) = 0; - - //! Static helper, tries to find chapterizer interface that supports specified file. - static bool g_find(service_ptr_t & p_out,const char * p_path,abort_callback & p_abort); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(chapterizer); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/commandline.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/commandline.cpp deleted file mode 100644 index 34708c3dd..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/commandline.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "foobar2000.h" - -void commandline_handler_metadb_handle::on_file(const char * url) -{ - - abort_callback_dummy blah; - - { - playlist_loader_callback_impl callback(blah); - - bool fail = false; - try { - playlist_loader::g_process_path_ex(url,callback); - } catch(std::exception const & e) { - console::complain("Unhandled exception in playlist loader", e); - fail = true; - } - - if (!fail) { - t_size n,m=callback.get_count(); - for(n=0;n on_token() => deletion - scenario #2: - creation => on_token() returning RESULT_PROCESSED_EXPECT_FILES => on_file(), on_file().... => on_files_done() => deletion -*/ - -template -class commandline_handler_factory_t : public service_factory_t {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/completion_notify.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/completion_notify.cpp deleted file mode 100644 index 0a183a8b0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/completion_notify.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "foobar2000.h" - -namespace { - class main_thread_callback_myimpl : public main_thread_callback { - public: - void callback_run() { - m_notify->on_completion(m_code); - } - - main_thread_callback_myimpl(completion_notify_ptr p_notify,unsigned p_code) : m_notify(p_notify), m_code(p_code) {} - private: - completion_notify_ptr m_notify; - unsigned m_code; - }; -} - -void completion_notify::g_signal_completion_async(completion_notify_ptr p_notify,unsigned p_code) { - if (p_notify.is_valid()) { - static_api_ptr_t()->add_callback(new service_impl_t(p_notify,p_code)); - } -} - -void completion_notify::on_completion_async(unsigned p_code) { - static_api_ptr_t()->add_callback(new service_impl_t(this,p_code)); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/completion_notify.h b/tools/vio2sf/src/foobar/foobar2000/SDK/completion_notify.h deleted file mode 100644 index f16c57361..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/completion_notify.h +++ /dev/null @@ -1,89 +0,0 @@ -//! Generic service for receiving notifications about async operation completion. Used by various other services. -class completion_notify : public service_base { -public: - //! Called when an async operation has been completed. Note that on_completion is always called from main thread. You can use on_completion_async() helper if you need to signal completion while your context is in another thread.\n - //! IMPLEMENTATION WARNING: If process being completed creates a window taking caller's window as parent, you must not destroy the parent window inside on_completion(). If you need to do so, use PostMessage() or main_thread_callback to delay the deletion. - //! @param p_code Context-specific status code. Possible values depend on the operation being performed. - virtual void on_completion(unsigned p_code) = 0; - - //! Helper. Queues a notification, using main_thread_callback. - void on_completion_async(unsigned p_code); - - //! Helper. Checks for null ptr and calls on_completion_async when the ptr is not null. - static void g_signal_completion_async(service_ptr_t p_notify,unsigned p_code); - - FB2K_MAKE_SERVICE_INTERFACE(completion_notify,service_base); -}; - -//! Implementation helper. -class completion_notify_dummy : public completion_notify { -public: - void on_completion(unsigned p_code) {} -}; - -//! Implementation helper. -class completion_notify_orphanable : public completion_notify { -public: - virtual void orphan() = 0; -}; - -//! Helper implementation. -//! IMPLEMENTATION WARNING: If process being completed creates a window taking caller's window as parent, you must not destroy the parent window inside on_task_completion(). If you need to do so, use PostMessage() or main_thread_callback to delay the deletion. -template -class completion_notify_impl : public completion_notify_orphanable { -public: - void on_completion(unsigned p_code) { - if (m_receiver != NULL) { - m_receiver->on_task_completion(m_taskid,p_code); - } - } - void setup(t_receiver * p_receiver, unsigned p_task_id) {m_receiver = p_receiver; m_taskid = p_task_id;} - void orphan() {m_receiver = NULL; m_taskid = 0;} -private: - t_receiver * m_receiver; - unsigned m_taskid; -}; - -template -service_ptr_t completion_notify_create(t_receiver * p_receiver,unsigned p_taskid) { - service_ptr_t > instance = new service_impl_t >(); - instance->setup(p_receiver,p_taskid); - return instance; -} - -typedef service_ptr_t completion_notify_ptr; -typedef service_ptr_t completion_notify_orphanable_ptr; - -//! Helper base class for classes that manage nonblocking tasks and get notified back thru completion_notify interface. -class completion_notify_receiver { -public: - completion_notify_ptr create_task(unsigned p_id) { - completion_notify_orphanable_ptr ptr; - if (m_tasks.query(p_id,ptr)) ptr->orphan(); - ptr = completion_notify_create(this,p_id); - m_tasks.set(p_id,ptr); - return ptr; - } - bool have_task(unsigned p_id) const { - return m_tasks.have_item(p_id); - } - void orphan_task(unsigned p_id) { - completion_notify_orphanable_ptr ptr; - if (m_tasks.query(p_id,ptr)) { - ptr->orphan(); - m_tasks.remove(p_id); - } - } - ~completion_notify_receiver() { - orphan_all_tasks(); - } - void orphan_all_tasks() { - m_tasks.enumerate(orphanfunc); - m_tasks.remove_all(); - } - - virtual void on_task_completion(unsigned p_id,unsigned p_status) {} -private: - static void orphanfunc(unsigned,completion_notify_orphanable_ptr p_item) {p_item->orphan();} - pfc::map_t m_tasks; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/component.h b/tools/vio2sf/src/foobar/foobar2000/SDK/component.h deleted file mode 100644 index 7ae5cc556..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/component.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _COMPONENT_H_ -#define _COMPONENT_H_ - -#include "foobar2000.h" - -class NOVTABLE foobar2000_client -{ -public: - typedef service_factory_base* pservice_factory_base; - - enum {FOOBAR2000_CLIENT_VERSION_COMPATIBLE = 70, FOOBAR2000_CLIENT_VERSION = 73}; //changes everytime global compatibility is broken - virtual t_uint32 FB2KAPI get_version() = 0; - virtual pservice_factory_base FB2KAPI get_service_list() = 0; - - virtual void FB2KAPI get_config(stream_writer * p_stream,abort_callback & p_abort) = 0; - virtual void FB2KAPI set_config(stream_reader * p_stream,abort_callback & p_abort) = 0; - virtual void FB2KAPI set_library_path(const char * path,const char * name) = 0; - virtual void FB2KAPI services_init(bool val) = 0; - virtual bool is_debug() = 0; -protected: - foobar2000_client() {} - ~foobar2000_client() {} -}; - -class NOVTABLE foobar2000_api -{ -public: - virtual service_class_ref FB2KAPI service_enum_find_class(const GUID & p_guid) = 0; - virtual bool FB2KAPI service_enum_create(service_ptr_t & p_out,service_class_ref p_class,t_size p_index) = 0; - virtual t_size FB2KAPI service_enum_get_count(service_class_ref p_class) = 0; - virtual HWND FB2KAPI get_main_window()=0; - virtual bool FB2KAPI assert_main_thread()=0; - virtual bool FB2KAPI is_main_thread()=0; - virtual bool FB2KAPI is_shutting_down()=0; - virtual pcchar FB2KAPI get_profile_path()=0; - virtual bool FB2KAPI is_initializing() = 0; -protected: - foobar2000_api() {} - ~foobar2000_api() {} -}; - -extern foobar2000_api * g_api; - -#endif diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/component_client.h b/tools/vio2sf/src/foobar/foobar2000/SDK/component_client.h deleted file mode 100644 index 46aa84888..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/component_client.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _COMPONENT_CLIENT_H_ -#define _COMPONENT_CLIENT_H_ - - - -#endif //_COMPONENT_CLIENT_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/components_menu.h b/tools/vio2sf/src/foobar/foobar2000/SDK/components_menu.h deleted file mode 100644 index 835237331..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/components_menu.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _COMPONENTS_MENU_H_ -#define _COMPONENTS_MENU_H_ - -#error deprecated, see menu_item.h - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/componentversion.h b/tools/vio2sf/src/foobar/foobar2000/SDK/componentversion.h deleted file mode 100644 index 85ba58924..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/componentversion.h +++ /dev/null @@ -1,56 +0,0 @@ -//! Entrypoint interface for declaring component's version information. Instead of implementing this directly, use DECLARE_COMPONENT_VERSION(). -class NOVTABLE componentversion : public service_base { -public: - virtual void get_file_name(pfc::string_base & out)=0; - virtual void get_component_name(pfc::string_base & out)=0; - virtual void get_component_version(pfc::string_base & out)=0; - virtual void get_about_message(pfc::string_base & out)=0;//about message uses "\n" for line separators - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(componentversion); -}; - -//! Implementation helper. -class componentversion_impl_simple : public componentversion { - const char * name,*version,*about; -public: - //do not derive/override - virtual void get_file_name(pfc::string_base & out) {out.set_string(core_api::get_my_file_name());} - virtual void get_component_name(pfc::string_base & out) {out.set_string(name?name:"");} - virtual void get_component_version(pfc::string_base & out) {out.set_string(version?version:"");} - virtual void get_about_message(pfc::string_base & out) {out.set_string(about?about:"");} - explicit componentversion_impl_simple(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {} -}; - -//! Implementation helper. -class componentversion_impl_copy : public componentversion { - pfc::string8 name,version,about; -public: - //do not derive/override - virtual void get_file_name(pfc::string_base & out) {out.set_string(core_api::get_my_file_name());} - virtual void get_component_name(pfc::string_base & out) {out.set_string(name);} - virtual void get_component_version(pfc::string_base & out) {out.set_string(version);} - virtual void get_about_message(pfc::string_base & out) {out.set_string(about);} - explicit componentversion_impl_copy(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {} -}; - -typedef service_factory_single_transparent_t __componentversion_impl_simple_factory; -typedef service_factory_single_transparent_t __componentversion_impl_copy_factory; - -class componentversion_impl_simple_factory : public __componentversion_impl_simple_factory { -public: - componentversion_impl_simple_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_simple_factory(p_name,p_version,p_about) {} -}; - -class componentversion_impl_copy_factory : public __componentversion_impl_copy_factory { -public: - componentversion_impl_copy_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_copy_factory(p_name,p_version,p_about) {} -}; - -//! Use this to declare your component's version information. Parameters must ba plain const char * string constants. The ABOUT string can be NULL if you don't provide any information to show in the "About" dialog. \n -//! Example: DECLARE_COMPONENT_VERSION("blah","v1.337",NULL) -#define DECLARE_COMPONENT_VERSION(NAME,VERSION,ABOUT) \ - static componentversion_impl_simple_factory g_componentversion_service(NAME,VERSION,ABOUT); - -//! Same as DECLARE_COMPONENT_VERSION(), but parameters can be dynamically generated strings rather than compile-time constants. -#define DECLARE_COMPONENT_VERSION_COPY(NAME,VERSION,ABOUT) \ - static componentversion_impl_copy_factory g_componentversion_service(NAME,VERSION,ABOUT); diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/config_io_callback.h b/tools/vio2sf/src/foobar/foobar2000/SDK/config_io_callback.h deleted file mode 100644 index 16474a458..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/config_io_callback.h +++ /dev/null @@ -1,15 +0,0 @@ -//! Implementing this interface lets you maintain your own configuration files rather than depending on the cfg_var system. \n -//! Note that you must not make assumptions about what happens first: config_io_callback::on_read(), initialization of cfg_var values or config_io_callback::on_read() in other components. Order of these things is undefined and will change with each run. \n -//! Use service_factory_single_t to register your implementations. Do not call other people's implementations, core is responsible for doing that when appropriate. -class NOVTABLE config_io_callback : public service_base { -public: - //! Called on startup. You can read your configuration file from here. \n - //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored. - virtual void on_read() = 0; - //! Called on shutdown. You can write your configuration file from here. - //! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored. - //! @param reset If set to true, our configuration is being reset, so you should wipe your files rather than rewrite them with current configuration. - virtual void on_write(bool reset) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_io_callback); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/config_object.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/config_object.cpp deleted file mode 100644 index 058c664c0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/config_object.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include "foobar2000.h" - -void config_object_notify_manager::g_on_changed(const service_ptr_t & p_object) -{ - if (core_api::assert_main_thread()) - { - service_enum_t e; - service_ptr_t ptr; - while(e.next(ptr)) - ptr->on_changed(p_object); - } -} - -bool config_object::g_find(service_ptr_t & p_out,const GUID & p_guid) -{ - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) - { - if (ptr->get_guid() == p_guid) - { - p_out = ptr; - return true; - } - } - return false; -} - -void config_object::g_get_data_string(const GUID & p_guid,pfc::string_base & p_out) -{ - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - ptr->get_data_string(p_out); -} - -void config_object::g_set_data_string(const GUID & p_guid,const char * p_data,t_size p_length) -{ - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - ptr->set_data_string(p_data,p_length); -} - -void config_object::get_data_int32(t_int32 & p_out) -{ - t_int32 temp; - get_data_struct_t(temp); - byte_order::order_le_to_native_t(temp); - p_out = temp; -} - -void config_object::set_data_int32(t_int32 p_val) -{ - t_int32 temp = p_val; - byte_order::order_native_to_le_t(temp); - set_data_struct_t(temp); -} - -bool config_object::get_data_bool_simple(bool p_default) { - try { - bool ret = p_default; - get_data_bool(ret); - return ret; - } catch(...) {return p_default;} -} - -t_int32 config_object::get_data_int32_simple(t_int32 p_default) { - try { - t_int32 ret = p_default; - get_data_int32(ret); - return ret; - } catch(...) {return p_default;} -} - -void config_object::g_get_data_int32(const GUID & p_guid,t_int32 & p_out) { - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - ptr->get_data_int32(p_out); -} - -void config_object::g_set_data_int32(const GUID & p_guid,t_int32 p_val) { - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - ptr->set_data_int32(p_val); -} - -bool config_object::g_get_data_bool_simple(const GUID & p_guid,bool p_default) -{ - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - return ptr->get_data_bool_simple(p_default); -} - -t_int32 config_object::g_get_data_int32_simple(const GUID & p_guid,t_int32 p_default) -{ - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - return ptr->get_data_int32_simple(p_default); -} - -void config_object::get_data_bool(bool & p_out) {get_data_struct_t(p_out);} -void config_object::set_data_bool(bool p_val) {set_data_struct_t(p_val);} - -void config_object::g_get_data_bool(const GUID & p_guid,bool & p_out) {g_get_data_struct_t(p_guid,p_out);} -void config_object::g_set_data_bool(const GUID & p_guid,bool p_val) {g_set_data_struct_t(p_guid,p_val);} - -namespace { - class stream_writer_string : public stream_writer { - public: - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - m_out.add_string((const char*)p_buffer,p_bytes); - } - stream_writer_string(pfc::string_base & p_out) : m_out(p_out) {m_out.reset();} - private: - pfc::string_base & m_out; - }; - - class stream_writer_fixedbuffer : public stream_writer { - public: - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - if (p_bytes > 0) { - if (p_bytes > m_bytes - m_bytes_read) throw pfc::exception_overflow(); - memcpy((t_uint8*)m_out,p_buffer,p_bytes); - m_bytes_read += p_bytes; - } - } - stream_writer_fixedbuffer(void * p_out,t_size p_bytes,t_size & p_bytes_read) : m_out(p_out), m_bytes(p_bytes), m_bytes_read(p_bytes_read) {m_bytes_read = 0;} - private: - void * m_out; - t_size m_bytes; - t_size & m_bytes_read; - }; - - - - class stream_writer_get_length : public stream_writer { - public: - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - m_length += p_bytes; - } - stream_writer_get_length(t_size & p_length) : m_length(p_length) {m_length = 0;} - private: - t_size & m_length; - }; -}; - -t_size config_object::get_data_raw(void * p_out,t_size p_bytes) { - t_size ret = 0; - get_data(&stream_writer_fixedbuffer(p_out,p_bytes,ret),abort_callback_impl()); - return ret; -} - -t_size config_object::get_data_raw_length() { - t_size ret = 0; - get_data(&stream_writer_get_length(ret),abort_callback_impl()); - return ret; -} - -void config_object::set_data_raw(const void * p_data,t_size p_bytes, bool p_notify) { - set_data(&stream_reader_memblock_ref(p_data,p_bytes),abort_callback_impl(),p_notify); -} - -void config_object::set_data_string(const char * p_data,t_size p_length) { - set_data_raw(p_data,pfc::strlen_max(p_data,p_length)); -} - -void config_object::get_data_string(pfc::string_base & p_out) { - get_data(&stream_writer_string(p_out),abort_callback_impl()); -} - - -//config_object_impl stuff - - -void config_object_impl::get_data(stream_writer * p_stream,abort_callback & p_abort) const { - insync(m_sync); - p_stream->write_object(m_data.get_ptr(),m_data.get_size(),p_abort); -} - -void config_object_impl::set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify) { - core_api::ensure_main_thread(); - - { - insync(m_sync); - m_data.set_size(0); - enum {delta = 1024}; - t_uint8 buffer[delta]; - for(;;) - { - t_size delta_done = p_stream->read(buffer,delta,p_abort); - - if (delta_done > 0) - { - m_data.append_fromptr(buffer,delta_done); - } - - if (delta_done != delta) break; - } - } - - if (p_notify) config_object_notify_manager::g_on_changed(this); -} - -config_object_impl::config_object_impl(const GUID & p_guid,const void * p_data,t_size p_bytes) : cfg_var(p_guid) -{ - m_data.set_data_fromptr((const t_uint8*)p_data,p_bytes); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/config_object.h b/tools/vio2sf/src/foobar/foobar2000/SDK/config_object.h deleted file mode 100644 index e460dc540..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/config_object.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef _CONFIG_OBJECT_H_ -#define _CONFIG_OBJECT_H_ - -class config_object; - -class NOVTABLE config_object_notify_manager : public service_base -{ -public: - virtual void on_changed(const service_ptr_t & p_object) = 0; - static void g_on_changed(const service_ptr_t & p_object); - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object_notify_manager); -}; - -class NOVTABLE config_object : public service_base -{ -public: - //interface - virtual GUID get_guid() const = 0; - virtual void get_data(stream_writer * p_stream,abort_callback & p_abort) const = 0; - virtual void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_sendnotify = true) = 0; - - //helpers - static bool g_find(service_ptr_t & p_out,const GUID & p_guid); - - void set_data_raw(const void * p_data,t_size p_bytes,bool p_sendnotify = true); - t_size get_data_raw(void * p_out,t_size p_bytes); - t_size get_data_raw_length(); - - template void get_data_struct_t(T& p_out); - template void set_data_struct_t(const T& p_in); - template static void g_get_data_struct_t(const GUID & p_guid,T & p_out); - template static void g_set_data_struct_t(const GUID & p_guid,const T & p_in); - - void set_data_string(const char * p_data,t_size p_length); - void get_data_string(pfc::string_base & p_out); - - void get_data_bool(bool & p_out); - void set_data_bool(bool p_val); - void get_data_int32(t_int32 & p_out); - void set_data_int32(t_int32 p_val); - bool get_data_bool_simple(bool p_default); - t_int32 get_data_int32_simple(t_int32 p_default); - - static void g_get_data_string(const GUID & p_guid,pfc::string_base & p_out); - static void g_set_data_string(const GUID & p_guid,const char * p_data,t_size p_length = ~0); - - static void g_get_data_bool(const GUID & p_guid,bool & p_out); - static void g_set_data_bool(const GUID & p_guid,bool p_val); - static void g_get_data_int32(const GUID & p_guid,t_int32 & p_out); - static void g_set_data_int32(const GUID & p_guid,t_int32 p_val); - static bool g_get_data_bool_simple(const GUID & p_guid,bool p_default); - static t_int32 g_get_data_int32_simple(const GUID & p_guid,t_int32 p_default); - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object); -}; - -class standard_config_objects -{ -public: - static const GUID bool_remember_window_positions, bool_ui_always_on_top,bool_playlist_stop_after_current; - static const GUID bool_playback_follows_cursor, bool_cursor_follows_playback; - static const GUID bool_show_keyboard_shortcuts_in_menus; - static const GUID string_gui_last_directory_media,string_gui_last_directory_playlists; - static const GUID int32_dynamic_bitrate_display_rate; - - - inline static bool query_show_keyboard_shortcuts_in_menus() {return config_object::g_get_data_bool_simple(standard_config_objects::bool_show_keyboard_shortcuts_in_menus,true);} - inline static bool query_remember_window_positions() {return config_object::g_get_data_bool_simple(standard_config_objects::bool_remember_window_positions,true);} - -}; - -class config_object_notify : public service_base -{ -public: - virtual t_size get_watched_object_count() = 0; - virtual GUID get_watched_object(t_size p_index) = 0; - virtual void on_watched_object_changed(const service_ptr_t & p_object) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object_notify); -}; - -#endif _CONFIG_OBJECT_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/config_object_impl.h b/tools/vio2sf/src/foobar/foobar2000/SDK/config_object_impl.h deleted file mode 100644 index 00e3451cc..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/config_object_impl.h +++ /dev/null @@ -1,174 +0,0 @@ -#ifndef _CONFIG_OBJECT_IMPL_H_ -#define _CONFIG_OBJECT_IMPL_H_ - -//template function bodies from config_object class - -template -void config_object::get_data_struct_t(T& p_out) { - if (get_data_raw(&p_out,sizeof(T)) != sizeof(T)) throw exception_io_data_truncation(); -} - -template -void config_object::set_data_struct_t(const T& p_in) { - return set_data_raw(&p_in,sizeof(T)); -} - -template -void config_object::g_get_data_struct_t(const GUID & p_guid,T & p_out) { - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - return ptr->get_data_struct_t(p_out); -} - -template -void config_object::g_set_data_struct_t(const GUID & p_guid,const T & p_in) { - service_ptr_t ptr; - if (!g_find(ptr,p_guid)) throw exception_service_not_found(); - return ptr->set_data_struct_t(p_in); -} - - -class config_object_impl : public config_object, private cfg_var -{ -public: - GUID get_guid() const {return cfg_var::get_guid();} - void get_data(stream_writer * p_stream,abort_callback & p_abort) const ; - void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify); - - config_object_impl(const GUID & p_guid,const void * p_data,t_size p_bytes); -private: - - //cfg_var methods - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {get_data(p_stream,p_abort);} - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {set_data(p_stream,p_abort,false);} - - mutable critical_section m_sync; - pfc::array_t m_data; -}; - -typedef service_factory_single_transparent_t config_object_factory; - -template -class config_object_fixed_const_impl_t : public config_object { -public: - config_object_fixed_const_impl_t(const GUID & p_guid, const void * p_data) : m_guid(p_guid) {memcpy(m_data,p_data,p_size);} - GUID get_guid() const {return m_guid;} - - void get_data(stream_writer * p_stream, abort_callback & p_abort) const { p_stream->write_object(m_data,p_size,p_abort); } - void set_data(stream_reader * p_stream, abort_callback & p_abort, bool p_notify) { PFC_ASSERT(!"Should not get here."); } - -private: - t_uint8 m_data[p_size]; - const GUID m_guid; -}; - -template -class config_object_fixed_impl_t : public config_object, private cfg_var { -public: - GUID get_guid() const {return cfg_var::get_guid();} - - void get_data(stream_writer * p_stream,abort_callback & p_abort) const { - insync(m_sync); - p_stream->write_object(m_data,p_size,p_abort); - } - - void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify) { - core_api::ensure_main_thread(); - - { - t_uint8 temp[p_size]; - p_stream->read_object(temp,p_size,p_abort); - insync(m_sync); - memcpy(m_data,temp,p_size); - } - - if (p_notify) config_object_notify_manager::g_on_changed(this); - } - - config_object_fixed_impl_t (const GUID & p_guid,const void * p_data) - : cfg_var(p_guid) - { - memcpy(m_data,p_data,p_size); - } - -private: - //cfg_var methods - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {get_data(p_stream,p_abort);} - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {set_data(p_stream,p_abort,false);} - - mutable critical_section m_sync; - t_uint8 m_data[p_size]; - -}; - -template class _config_object_fixed_impl_switch; -template class _config_object_fixed_impl_switch { public: typedef config_object_fixed_impl_t type; }; -template class _config_object_fixed_impl_switch { public: typedef config_object_fixed_const_impl_t type; }; - -template -class config_object_fixed_factory_t : public service_factory_single_transparent_t< typename _config_object_fixed_impl_switch::type > -{ -public: - config_object_fixed_factory_t(const GUID & p_guid,const void * p_initval) - : - service_factory_single_transparent_t< typename _config_object_fixed_impl_switch::type > - (p_guid,p_initval) - {} -}; - - -class config_object_string_factory : public config_object_factory -{ -public: - config_object_string_factory(const GUID & p_guid,const char * p_string,t_size p_string_length = infinite) - : config_object_factory(p_guid,p_string,pfc::strlen_max(p_string,infinite)) {} - -}; - -template -class config_object_bool_factory_t : public config_object_fixed_factory_t<1,isConst> { -public: - config_object_bool_factory_t(const GUID & p_guid,bool p_initval) - : config_object_fixed_factory_t<1,isConst>(p_guid,&p_initval) {} -}; -typedef config_object_bool_factory_t<> config_object_bool_factory; - -template -class config_object_int_factory_t : public config_object_fixed_factory_t -{ -private: - template - struct t_initval - { - T m_initval; - t_initval(T p_initval) : m_initval(p_initval) {byte_order::order_native_to_le_t(m_initval);} - T * get_ptr() {return &m_initval;} - }; -public: - config_object_int_factory_t(const GUID & p_guid,T p_initval) - : config_object_fixed_factory_t(p_guid,t_initval(p_initval).get_ptr() ) - {} -}; - -typedef config_object_int_factory_t config_object_int32_factory; - - - -class config_object_notify_impl_simple : public config_object_notify -{ -public: - t_size get_watched_object_count() {return 1;} - GUID get_watched_object(t_size p_index) {return m_guid;} - void on_watched_object_changed(const service_ptr_t & p_object) {m_func(p_object);} - - typedef void (*t_func)(const service_ptr_t &); - - config_object_notify_impl_simple(const GUID & p_guid,t_func p_func) : m_guid(p_guid), m_func(p_func) {} -private: - GUID m_guid; - t_func m_func; -}; - -typedef service_factory_single_transparent_t config_object_notify_simple_factory; - -#endif _CONFIG_OBJECT_IMPL_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/console.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/console.cpp deleted file mode 100644 index 1becba922..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/console.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "foobar2000.h" - - -void console::info(const char * p_message) {print(p_message);} -void console::error(const char * p_message) {complain("Error", p_message);} -void console::warning(const char * p_message) {complain("Warning", p_message);} - -void console::info_location(const playable_location & src) {print_location(src);} -void console::info_location(const metadb_handle_ptr & src) {print_location(src);} - -void console::print_location(const metadb_handle_ptr & src) -{ - print_location(src->get_location()); -} - -void console::print_location(const playable_location & src) -{ - formatter() << src; -} - -void console::complain(const char * what, const char * msg) { - formatter() << what << ": " << msg; -} -void console::complain(const char * what, std::exception const & e) { - complain(what, e.what()); -} - -void console::print(const char* p_message) -{ - if (core_api::are_services_available()) { - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) ptr->print(p_message,infinite); - } -} - -void console::printf(const char* p_format,...) -{ - va_list list; - va_start(list,p_format); - printfv(p_format,list); - va_end(list); -} - -void console::printfv(const char* p_format,va_list p_arglist) -{ - pfc::string8_fastalloc temp; - uPrintfV(temp,p_format,p_arglist); - print(temp); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/console.h b/tools/vio2sf/src/foobar/foobar2000/SDK/console.h deleted file mode 100644 index 0b591c620..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/console.h +++ /dev/null @@ -1,31 +0,0 @@ -//! Namespace with functions for sending text to console. All functions are fully multi-thread safe, though they must not be called during dll initialization or deinitialization (e.g. static object constructors or destructors) when service system is not available. -namespace console -{ - void info(const char * p_message); - void error(const char * p_message); - void warning(const char * p_message); - void info_location(const playable_location & src); - void info_location(const metadb_handle_ptr & src); - void print_location(const playable_location & src); - void print_location(const metadb_handle_ptr & src); - - void print(const char*); - void printf(const char*,...); - void printfv(const char*,va_list p_arglist); - - //! Usage: console::formatter() << "blah " << somenumber << " asdf" << somestring; - class formatter : public pfc::string_formatter { - public: - ~formatter() {if (!is_empty()) console::print(get_ptr());} - }; - void complain(const char * what, const char * msg); - void complain(const char * what, std::exception const & e); -}; - -//! Interface receiving console output. Do not call directly; use console namespace functions instead. -class NOVTABLE console_receiver : public service_base { -public: - virtual void print(const char * p_message,t_size p_message_length) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(console_receiver); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/contextmenu.h b/tools/vio2sf/src/foobar/foobar2000/SDK/contextmenu.h deleted file mode 100644 index 1c601ef96..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/contextmenu.h +++ /dev/null @@ -1,242 +0,0 @@ -//! Reserved for future use. -typedef void * t_glyph; - - -class NOVTABLE contextmenu_item_node { -public: - enum t_flags { - FLAG_CHECKED = 1, - FLAG_DISABLED = 2, - FLAG_GRAYED = 4, - FLAG_DISABLED_GRAYED = FLAG_DISABLED|FLAG_GRAYED, - FLAG_RADIOCHECKED = 8, //new in 0.9.5.2 - overrides FLAG_CHECKED, set together with FLAG_CHECKED for backwards compatibility. - }; - - enum t_type { - TYPE_POPUP,TYPE_COMMAND,TYPE_SEPARATOR - }; - - virtual bool get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,metadb_handle_list_cref p_data,const GUID & p_caller) = 0; - virtual t_type get_type() = 0; - virtual void execute(metadb_handle_list_cref p_data,const GUID & p_caller) = 0; - virtual t_glyph get_glyph(metadb_handle_list_cref p_data,const GUID & p_caller) {return 0;}//RESERVED - virtual t_size get_children_count() = 0; - virtual contextmenu_item_node * get_child(t_size p_index) = 0; - virtual bool get_description(pfc::string_base & p_out) = 0; - virtual GUID get_guid() = 0; - virtual bool is_mappable_shortcut() = 0; - -protected: - contextmenu_item_node() {} - ~contextmenu_item_node() {} -}; - -class NOVTABLE contextmenu_item_node_root : public contextmenu_item_node -{ -public: - virtual ~contextmenu_item_node_root() {} -}; - -class NOVTABLE contextmenu_item_node_leaf : public contextmenu_item_node -{ -public: - t_type get_type() {return TYPE_COMMAND;} - t_size get_children_count() {return 0;} - contextmenu_item_node * get_child(t_size) {return NULL;} -}; - -class NOVTABLE contextmenu_item_node_root_leaf : public contextmenu_item_node_root -{ -public: - t_type get_type() {return TYPE_COMMAND;} - t_size get_children_count() {return 0;} - contextmenu_item_node * get_child(t_size) {return NULL;} -}; - -class NOVTABLE contextmenu_item_node_popup : public contextmenu_item_node -{ -public: - t_type get_type() {return TYPE_POPUP;} - void execute(metadb_handle_list_cref data,const GUID & caller) {} - bool get_description(pfc::string_base & p_out) {return false;} -}; - -class NOVTABLE contextmenu_item_node_root_popup : public contextmenu_item_node_root -{ -public: - t_type get_type() {return TYPE_POPUP;} - void execute(metadb_handle_list_cref data,const GUID & caller) {} - bool get_description(pfc::string_base & p_out) {return false;} -}; - -class contextmenu_item_node_separator : public contextmenu_item_node -{ -public: - t_type get_type() {return TYPE_SEPARATOR;} - void execute(metadb_handle_list_cref data,const GUID & caller) {} - bool get_description(pfc::string_base & p_out) {return false;} - t_size get_children_count() {return 0;} - bool get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,metadb_handle_list_cref p_data,const GUID & p_caller) - { - p_displayflags = 0; - p_out = "---"; - return true; - } - contextmenu_item_node * get_child(t_size) {return NULL;} - GUID get_guid() {return pfc::guid_null;} - bool is_mappable_shortcut() {return false;} -}; - -/*! -Service class for declaring context menu commands.\n -See contextmenu_item_simple for implementation helper without dynamic menu generation features.\n -All methods are valid from main app thread only. -*/ -class NOVTABLE contextmenu_item : public service_base { -public: - enum t_enabled_state { - FORCE_OFF, - DEFAULT_OFF, - DEFAULT_ON, - }; - - //! Retrieves number of menu items provided by this contextmenu_item implementation. - virtual unsigned get_num_items() = 0; - //! Instantiates a context menu item (including sub-node tree for items that contain dynamically-generated sub-items). - virtual contextmenu_item_node_root * instantiate_item(unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller) = 0; - //! Retrieves GUID of the context menu item. - virtual GUID get_item_guid(unsigned p_index) = 0; - //! Retrieves human-readable name of the context menu item. - virtual void get_item_name(unsigned p_index,pfc::string_base & p_out) = 0; - //! Retrieves default path of the context menu item ("" for root). - virtual void get_item_default_path(unsigned p_index,pfc::string_base & p_out) = 0; - //! Retrieves item's description to show in the status bar. Set p_out to the string to be displayed and return true if you provide a description, return false otherwise. - virtual bool get_item_description(unsigned p_index,pfc::string_base & p_out) = 0; - //! Signals whether the item should be forcefully hidden (FORCE_OFF), hidden by default but possible to add (DEFAULT_OFF) or shown by default (DEFAULT_ON). - virtual t_enabled_state get_enabled_state(unsigned p_index) = 0; - //! Executes the menu item command without going thru the instantiate_item path. For items with dynamically-generated sub-items, p_node is identifies of the sub-item command to execute. - virtual void item_execute_simple(unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller) = 0; - - bool item_get_display_data_root(pfc::string_base & p_out,unsigned & displayflags,unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller); - bool item_get_display_data(pfc::string_base & p_out,unsigned & displayflags,unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller); - - //! Deprecated - use caller_active_playlist_selection instead. - static const GUID caller_playlist; - - static const GUID caller_active_playlist_selection, caller_active_playlist, caller_playlist_manager, caller_now_playing, caller_keyboard_shortcut_list, caller_media_library_viewer; - static const GUID caller_undefined; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_item); -}; - -//! contextmenu_item implementation helper for implementing non-dynamically-generated context menu items; derive from this instead of from contextmenu_item directly if your menu items are static. -class NOVTABLE contextmenu_item_simple : public contextmenu_item { -private: -public: - //! Same as contextmenu_item_node::t_flags. - enum t_flags - { - FLAG_CHECKED = 1, - FLAG_DISABLED = 2, - FLAG_GRAYED = 4, - FLAG_DISABLED_GRAYED = FLAG_DISABLED|FLAG_GRAYED, - FLAG_RADIOCHECKED = 8, //new in 0.9.5.2 - overrides FLAG_CHECKED, set together with FLAG_CHECKED for backwards compatibility. - }; - - - // Functions to be overridden by implementers (some are not mandatory). - virtual t_enabled_state get_enabled_state(unsigned p_index) {return contextmenu_item::DEFAULT_ON;} - virtual unsigned get_num_items() = 0; - virtual void get_item_name(unsigned p_index,pfc::string_base & p_out) = 0; - virtual void get_item_default_path(unsigned p_index,pfc::string_base & p_out) = 0; - virtual void context_command(unsigned p_index,metadb_handle_list_cref p_data,const GUID& p_caller) = 0; - virtual bool context_get_display(unsigned p_index,metadb_handle_list_cref p_data,pfc::string_base & p_out,unsigned & p_displayflags,const GUID & p_caller) { - PFC_ASSERT(p_index>=0 && p_indexget_display_data(m_index,p_data,p_out,p_displayflags,p_caller);} - void execute(metadb_handle_list_cref p_data,const GUID & p_caller) {m_owner->context_command(m_index,p_data,p_caller);} - bool get_description(pfc::string_base & p_out) {return m_owner->get_item_description(m_index,p_out);} - GUID get_guid() {return pfc::guid_null;} - bool is_mappable_shortcut() {return m_owner->item_is_mappable_shortcut(m_index);} - private: - service_ptr_t m_owner; - unsigned m_index; - }; - - contextmenu_item_node_root * instantiate_item(unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller) - { - return new contextmenu_item_node_impl(this,p_index); - } - - - void item_execute_simple(unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller) - { - if (p_node == pfc::guid_null) - context_command(p_index,p_data,p_caller); - } - - virtual bool item_is_mappable_shortcut(unsigned p_index) - { - return true; - } - - - virtual bool get_display_data(unsigned n,metadb_handle_list_cref data,pfc::string_base & p_out,unsigned & displayflags,const GUID & caller) - { - bool rv = false; - assert(n>=0 && n0) - { - rv = context_get_display(n,data,p_out,displayflags,caller); - } - return rv; - } - -}; - - -//! Helper. -template -class contextmenu_item_factory_t : public service_factory_single_t {}; - - -//! Helper. -#define DECLARE_CONTEXT_MENU_ITEM(P_CLASSNAME,P_NAME,P_DEFAULTPATH,P_FUNC,P_GUID,P_DESCRIPTION) \ - namespace { \ - class P_CLASSNAME : public contextmenu_item_simple { \ - public: \ - unsigned get_num_items() {return 1;} \ - void get_item_name(unsigned p_index,pfc::string_base & p_out) {p_out = P_NAME;} \ - void get_item_default_path(unsigned p_index,pfc::string_base & p_out) {p_out = P_DEFAULTPATH;} \ - void context_command(unsigned p_index,metadb_handle_list_cref p_data,const GUID& p_caller) {P_FUNC(p_data);} \ - GUID get_item_guid(unsigned p_index) {return P_GUID;} \ - bool get_item_description(unsigned p_index,pfc::string_base & p_out) {if (P_DESCRIPTION[0] == 0) return false;p_out = P_DESCRIPTION; return true;} \ - }; \ - static contextmenu_item_factory_t g_##P_CLASSNAME##_factory; \ - } - - - - -//! New in 0.9.5.1. Static methods safe to use in prior versions as it will use slow fallback mode when the service isn't present. \n -//! Functionality provided by menu_item_resolver methods isn't much different from just walking all registered contextmenu_item / mainmenu_commands implementations to find the command we want, but it uses a hint map to locate the service we're looking for without walking all of them which may be significantly faster in certain scenarios. -class menu_item_resolver : public service_base { -public: - virtual bool resolve_context_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index) = 0; - virtual bool resolve_main_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index) = 0; - - static bool g_resolve_context_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index); - static bool g_resolve_main_command(const GUID & id, service_ptr_t & out, t_uint32 & out_index); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(menu_item_resolver) -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/contextmenu_manager.h b/tools/vio2sf/src/foobar/foobar2000/SDK/contextmenu_manager.h deleted file mode 100644 index 8bcbb21b0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/contextmenu_manager.h +++ /dev/null @@ -1,109 +0,0 @@ -class NOVTABLE keyboard_shortcut_manager : public service_base -{ -public: - static bool g_get(service_ptr_t & p_out) {return service_enum_create_t(p_out,0);} - - enum shortcut_type - { - TYPE_MAIN, - TYPE_CONTEXT, - TYPE_CONTEXT_PLAYLIST, - TYPE_CONTEXT_NOW_PLAYING, - }; - - - virtual bool process_keydown(shortcut_type type,const pfc::list_base_const_t & data,unsigned keycode)=0; - virtual bool process_keydown_ex(shortcut_type type,const pfc::list_base_const_t & data,unsigned keycode,const GUID & caller)=0; - bool on_keydown(shortcut_type type,WPARAM wp); - bool on_keydown_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller); - - bool on_keydown_auto(WPARAM wp); - bool on_keydown_auto_playlist(WPARAM wp); - bool on_keydown_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller); - - bool on_keydown_restricted_auto(WPARAM wp); - bool on_keydown_restricted_auto_playlist(WPARAM wp); - bool on_keydown_restricted_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller); - - virtual bool get_key_description_for_action(const GUID & p_command,const GUID & p_subcommand, pfc::string_base & out, shortcut_type type, bool is_global)=0; - - static bool is_text_key(t_uint32 vkCode); - static bool is_typing_key(t_uint32 vkCode); - static bool is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers); - static bool is_typing_modifier(t_uint32 flags); - static bool is_typing_message(HWND editbox, const MSG * msg); - static bool is_typing_message(const MSG * msg); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(keyboard_shortcut_manager); -}; - - -//! New in 0.9.5. -class keyboard_shortcut_manager_v2 : public keyboard_shortcut_manager { -public: - //! Deprecates old keyboard_shortcut_manager methods. If the action requires selected items, they're obtained from ui_selection_manager API automatically. - virtual bool process_keydown_simple(t_uint32 keycode) = 0; - - //! Helper for use with message filters. - bool pretranslate_message(const MSG * msg, HWND thisPopupWnd); - - FB2K_MAKE_SERVICE_INTERFACE(keyboard_shortcut_manager_v2,keyboard_shortcut_manager); -}; - -class NOVTABLE contextmenu_node { -public: - virtual contextmenu_item_node::t_type get_type()=0; - virtual const char * get_name()=0; - virtual t_size get_num_children()=0;//TYPE_POPUP only - virtual contextmenu_node * get_child(t_size n)=0;//TYPE_POPUP only - virtual unsigned get_display_flags()=0;//TYPE_COMMAND/TYPE_POPUP only, see contextmenu_item::FLAG_* - virtual unsigned get_id()=0;//TYPE_COMMAND only, returns zero-based index (helpful for win32 menu command ids) - virtual void execute()=0;//TYPE_COMMAND only - virtual bool get_description(pfc::string_base & out)=0;//TYPE_COMMAND only - virtual bool get_full_name(pfc::string_base & out)=0;//TYPE_COMMAND only - virtual void * get_glyph()=0;//RESERVED, do not use -protected: - contextmenu_node() {} - ~contextmenu_node() {} -}; - - - -class NOVTABLE contextmenu_manager : public service_base -{ -public: - enum - { - FLAG_SHOW_SHORTCUTS = 1, - FLAG_SHOW_SHORTCUTS_GLOBAL = 2, - }; - virtual void init_context(const pfc::list_base_const_t & data,unsigned flags)=0;//flags - see FLAG_* above - virtual void init_context_playlist(unsigned flags)=0; - virtual contextmenu_node * get_root()=0;//releasing contextmenu_manager service releaases nodes; root may be null in case of error or something - virtual contextmenu_node * find_by_id(unsigned id)=0; - virtual void set_shortcut_preference(const keyboard_shortcut_manager::shortcut_type * data,unsigned count)=0; - - - - static void g_create(service_ptr_t & p_out) {p_out = standard_api_create_t();} - -#ifdef WIN32 - static void win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id);//menu item identifiers are base_id<=N & data, const POINT * pt = 0,unsigned flags = 0); - static void win32_run_menu_context_playlist(HWND parent,const POINT * pt = 0,unsigned flags = 0); - void win32_run_menu_popup(HWND parent,const POINT * pt = 0); - void win32_build_menu(HMENU menu,int base_id,int max_id) {win32_build_menu(menu,get_root(),base_id,max_id);} - - -#endif - - virtual void init_context_ex(const pfc::list_base_const_t & data,unsigned flags,const GUID & caller)=0; - virtual bool init_context_now_playing(unsigned flags)=0;//returns false if not playing - - bool execute_by_id(unsigned id); - - bool get_description_by_id(unsigned id,pfc::string_base & out); - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_manager); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/core_api.h b/tools/vio2sf/src/foobar/foobar2000/SDK/core_api.h deleted file mode 100644 index 19fc53fd4..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/core_api.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _CORE_API_H_ -#define _CORE_API_H_ - -namespace core_api { - - //! Exception thrown by APIs locked to main app thread when called from another thread. - PFC_DECLARE_EXCEPTION(exception_wrong_thread,pfc::exception_bug_check,"This method can be called only from the main thread"); - - //! Retrieves HINSTANCE of calling DLL. - HINSTANCE get_my_instance(); - //! Retrieves filename of calling dll, excluding extension, e.g. "foo_asdf" - const char * get_my_file_name(); - //! Retrieves full path of calling dll, e.g. file://c:\blah\foobar2000\foo_asdf.dll - const char * get_my_full_path(); - //! Retrieves main app window. WARNING: this is provided for parent of dialog windows and such only; using it for anything else (such as hooking windowproc to alter app behaviors) is absolutely illegal. - HWND get_main_window(); - //! Tests whether services are available at this time. They are not available only during DLL startup or shutdown (e.g. inside static object constructors or destructors). - bool are_services_available(); - //! Tests whether calling thread is main app thread, and shows diagnostic message in debugger output if it's not. - bool assert_main_thread(); - //! Throws exception_wrong_thread if calling thread is not main app thread. - void ensure_main_thread(); - //! Returns true if calling thread is main app thread, false otherwise. - bool is_main_thread(); - //! Returns whether the app is currently shutting down. - bool is_shutting_down(); - //! Returns whether the app is currently initializing. - bool is_initializing(); - //! Returns filesystem path to directory with user settings, e.g. file://c:\documents_and_settings\username\blah\foobar2000 - const char * get_profile_path(); -}; - -#endif diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/coreversion.h b/tools/vio2sf/src/foobar/foobar2000/SDK/coreversion.h deleted file mode 100644 index f786444b4..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/coreversion.h +++ /dev/null @@ -1,36 +0,0 @@ -class NOVTABLE core_version_info : public service_base { -public: - virtual const char * get_version_string() = 0; - static const char * g_get_version_string() {return static_api_ptr_t()->get_version_string();} - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(core_version_info); -}; - -struct t_core_version_data { - t_uint32 m_major, m_minor1, m_minor2, m_minor3; -}; - -//! New (0.9.4.2) -class NOVTABLE core_version_info_v2 : public core_version_info { -public: - virtual const char * get_name() = 0;//"foobar2000" - virtual const char * get_version_as_text() = 0;//"N.N.N.N" - virtual t_core_version_data get_version() = 0; - - //! Determine whether running foobar2000 version is newer or equal to the specified version, eg. test_version(0,9,5,0) for 0.9.5. - bool test_version(t_uint32 major, t_uint32 minor1, t_uint32 minor2, t_uint32 minor3) { - const t_core_version_data v = get_version(); - if (v.m_major < major) return false; - else if (v.m_major > major) return true; - // major version matches - else if (v.m_minor1 < minor1) return false; - else if (v.m_minor1 > minor1) return true; - // minor1 version matches - else if (v.m_minor2 < minor2) return false; - else if (v.m_minor2 > minor2) return true; - // minor2 version matches - else if (v.m_minor3 < minor3) return false; - else return true; - } - - FB2K_MAKE_SERVICE_INTERFACE(core_version_info_v2, core_version_info); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/dsp.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/dsp.cpp deleted file mode 100644 index d7b39d5e0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/dsp.cpp +++ /dev/null @@ -1,395 +0,0 @@ -#include "foobar2000.h" -#include - -t_size dsp_chunk_list_impl::get_count() const {return m_data.get_count();} - -audio_chunk * dsp_chunk_list_impl::get_item(t_size n) const {return n>=0 && n=0 && idxmax) idx = max; - pfc::rcptr_t ret; - if (m_recycled.get_count()>0) - { - t_size best; - if (hint_size>0) - { - best = 0; - t_size best_found = m_recycled[0]->get_data_size(), n, total = m_recycled.get_count(); - for(n=1;nget_data_size(); - int delta_old = abs((int)best_found - (int)hint_size), delta_new = abs((int)size - (int)hint_size); - if (delta_new < delta_old) - { - best_found = size; - best = n; - } - } - } - else best = m_recycled.get_count()-1; - - ret = m_recycled.remove_by_idx(best); - ret->set_sample_count(0); - ret->set_channels(0); - ret->set_srate(0); - } - else ret = pfc::rcnew_t(); - if (idx==max) m_data.add_item(ret); - else m_data.insert_item(ret,idx); - return &*ret; -} - -void dsp_chunk_list::remove_bad_chunks() -{ - bool blah = false; - t_size idx; - for(idx=0;idxis_valid()) - { - chunk->reset(); - remove_by_idx(idx); - blah = true; - } - else idx++; - } - if (blah) console::info("one or more bad chunks removed from dsp chunk list"); -} - - -bool dsp_entry::g_instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) -{ - service_ptr_t ptr; - if (!g_get_interface(ptr,p_preset.get_owner())) return false; - return ptr->instantiate(p_out,p_preset); -} - -bool dsp_entry::g_instantiate_default(service_ptr_t & p_out,const GUID & p_guid) -{ - service_ptr_t ptr; - if (!g_get_interface(ptr,p_guid)) return false; - dsp_preset_impl preset; - if (!ptr->get_default_preset(preset)) return false; - return ptr->instantiate(p_out,preset); -} - -bool dsp_entry::g_name_from_guid(pfc::string_base & p_out,const GUID & p_guid) -{ - service_ptr_t ptr; - if (!g_get_interface(ptr,p_guid)) return false; - ptr->get_name(p_out); - return true; -} - -bool dsp_entry::g_dsp_exists(const GUID & p_guid) -{ - service_ptr_t blah; - return g_get_interface(blah,p_guid); -} - -bool dsp_entry::g_get_default_preset(dsp_preset & p_out,const GUID & p_guid) -{ - service_ptr_t ptr; - if (!g_get_interface(ptr,p_guid)) return false; - return ptr->get_default_preset(p_out); -} - -void dsp_chain_config::contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const { - t_size n, count = get_count(); - p_stream->write_lendian_t(count,p_abort); - for(n=0;nread_lendian_t(count,p_abort); - - dsp_preset_impl temp; - - for(n=0;n & p_out) -{ - p_out.remove_all(); - t_size n, m = get_count(); - for(n=0;n temp; - if (dsp_entry::g_instantiate(temp,get_item(n))) - p_out.add_item(temp); - } -} - -t_size dsp_chain_config_impl::get_count() const -{ - return m_data.get_count(); -} - -const dsp_preset & dsp_chain_config_impl::get_item(t_size p_index) const -{ - return *m_data[p_index]; -} - -void dsp_chain_config_impl::replace_item(const dsp_preset & p_data,t_size p_index) -{ - *m_data[p_index] = p_data; -} - -void dsp_chain_config_impl::insert_item(const dsp_preset & p_data,t_size p_index) -{ - m_data.insert_item(new dsp_preset_impl(p_data),p_index); -} - -void dsp_chain_config_impl::remove_mask(const bit_array & p_mask) -{ - m_data.delete_mask(p_mask); -} - -dsp_chain_config_impl::~dsp_chain_config_impl() -{ - m_data.delete_all(); -} - -void dsp_preset::contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const { - t_size size = get_data_size(); - p_stream->write_lendian_t(get_owner(),p_abort); - p_stream->write_lendian_t(size,p_abort); - if (size > 0) { - p_stream->write_object(get_data(),size,p_abort); - } -} - -void dsp_preset::contents_from_stream(stream_reader * p_stream,abort_callback & p_abort) { - t_uint32 size; - GUID guid; - p_stream->read_lendian_t(guid,p_abort); - set_owner(guid); - p_stream->read_lendian_t(size,p_abort); - if (size > 1024*1024*32) throw exception_io_data(); - set_data_from_stream(p_stream,size,p_abort); -} - -void dsp_preset::g_contents_from_stream_skip(stream_reader * p_stream,abort_callback & p_abort) { - t_uint32 size; - GUID guid; - p_stream->read_lendian_t(guid,p_abort); - p_stream->read_lendian_t(size,p_abort); - if (size > 1024*1024*32) throw exception_io_data(); - p_stream->skip_object(size,p_abort); -} - -void dsp_preset_impl::set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { - m_data.set_size(p_bytes); - if (p_bytes > 0) p_stream->read_object(m_data.get_ptr(),p_bytes,p_abort); -} - -void dsp_chain_config::copy(const dsp_chain_config & p_source) { - remove_all(); - t_size n, m = p_source.get_count(); - for(n=0;n entry; - if (!g_get_interface(entry,p_guid)) return false; - return entry->have_config_popup(); -} - -bool dsp_entry::g_have_config_popup(const dsp_preset & p_preset) -{ - return g_have_config_popup(p_preset.get_owner()); -} - -bool dsp_entry::g_show_config_popup(dsp_preset & p_preset,HWND p_parent) -{ - service_ptr_t entry; - if (!g_get_interface(entry,p_preset.get_owner())) return false; - return entry->show_config_popup(p_preset,p_parent); -} - -void dsp_entry::g_show_config_popup_v2(const dsp_preset & p_preset,HWND p_parent,dsp_preset_edit_callback & p_callback) { - service_ptr_t entry; - if (g_get_interface(entry,p_preset.get_owner())) { - service_ptr_t entry_v2; - if (entry->service_query_t(entry_v2)) { - entry_v2->show_config_popup_v2(p_preset,p_parent,p_callback); - } else { - dsp_preset_impl temp(p_preset); - if (entry->show_config_popup(temp,p_parent)) p_callback.on_preset_changed(temp); - } - } -} - -bool dsp_entry::g_get_interface(service_ptr_t & p_out,const GUID & p_guid) -{ - service_ptr_t ptr; - service_enum_t e; - e.reset(); - while(e.next(ptr)) - { - if (ptr->get_guid() == p_guid) - { - p_out = ptr; - return true; - } - } - return false; -} - -bool resampler_entry::g_get_interface(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to) -{ - service_ptr_t ptr_dsp; - service_ptr_t ptr_resampler; - service_enum_t e; - e.reset(); - float found_priority = 0; - service_ptr_t found; - while(e.next(ptr_dsp)) - { - if (ptr_dsp->service_query_t(ptr_resampler)) - { - if (p_srate_from == 0 || ptr_resampler->is_conversion_supported(p_srate_from,p_srate_to)) - { - float priority = ptr_resampler->get_priority(); - if (found.is_empty() || priority > found_priority) - { - found = ptr_resampler; - found_priority = priority; - } - } - } - } - if (found.is_empty()) return false; - p_out = found; - return true; -} - -bool resampler_entry::g_create_preset(dsp_preset & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale) -{ - service_ptr_t entry; - if (!g_get_interface(entry,p_srate_from,p_srate_to)) return false; - return entry->create_preset(p_out,p_srate_to,p_qualityscale); -} - -bool resampler_entry::g_create(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale) -{ - service_ptr_t entry; - if (!g_get_interface(entry,p_srate_from,p_srate_to)) return false; - dsp_preset_impl preset; - if (!entry->create_preset(preset,p_srate_to,p_qualityscale)) return false; - return entry->instantiate(p_out,preset); -} - - -void dsp_chain_config::get_name_list(pfc::string_base & p_out) const -{ - const t_size count = get_count(); - bool added = false; - for(unsigned n=0;n ptr; - if (dsp_entry::g_get_interface(ptr,get_item(n).get_owner())) - { - if (added) p_out += ", "; - added = true; - - pfc::string8 temp; - ptr->get_name(temp); - p_out += temp; - } - } -} - -void dsp::run_abortable(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort) { - service_ptr_t this_v2; - if (this->service_query_t(this_v2)) this_v2->run_v2(p_chunk_list,p_cur_file,p_flags,p_abort); - else run(p_chunk_list,p_cur_file,p_flags); -} - -namespace { - class dsp_preset_edit_callback_impl : public dsp_preset_edit_callback { - public: - dsp_preset_edit_callback_impl(dsp_preset & p_data) : m_data(p_data) {} - void on_preset_changed(const dsp_preset & p_data) {m_data = p_data;} - private: - dsp_preset & m_data; - }; -}; - -bool dsp_entry_v2::show_config_popup(dsp_preset & p_data,HWND p_parent) { - PFC_ASSERT(p_data.get_owner() == get_guid()); - dsp_preset_impl temp(p_data); - show_config_popup_v2(p_data,p_parent,dsp_preset_edit_callback_impl(temp)); - PFC_ASSERT(temp.get_owner() == get_guid()); - if (temp == p_data) return false; - p_data = temp; - return true; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/dsp.h b/tools/vio2sf/src/foobar/foobar2000/SDK/dsp.h deleted file mode 100644 index 8f94d5d68..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/dsp.h +++ /dev/null @@ -1,482 +0,0 @@ -//! Interface to a DSP chunk list. A DSP chunk list object is passed to the DSP chain each time, since DSPs are allowed to remove processed chunks or insert new ones. -class NOVTABLE dsp_chunk_list { -public: - virtual t_size get_count() const = 0; - virtual audio_chunk * get_item(t_size n) const = 0; - virtual void remove_by_idx(t_size idx) = 0; - virtual void remove_mask(const bit_array & mask) = 0; - virtual audio_chunk * insert_item(t_size idx,t_size hint_size=0) = 0; - - audio_chunk * add_item(t_size hint_size=0) {return insert_item(get_count(),hint_size);} - - void remove_all() {remove_mask(bit_array_true());} - - double get_duration() { - double rv = 0; - t_size n,m = get_count(); - for(n=0;nget_duration(); - return rv; - } - - void add_chunk(const audio_chunk * chunk) { - audio_chunk * dst = insert_item(get_count(),chunk->get_data_length()); - if (dst) dst->copy(*chunk); - } - - void remove_bad_chunks(); -protected: - dsp_chunk_list() {} - ~dsp_chunk_list() {} -}; - -class dsp_chunk_list_impl : public dsp_chunk_list//implementation -{ - pfc::list_t > m_data, m_recycled; -public: - t_size get_count() const; - audio_chunk * get_item(t_size n) const; - void remove_by_idx(t_size idx); - void remove_mask(const bit_array & mask); - audio_chunk * insert_item(t_size idx,t_size hint_size=0); -}; - -//! Instance of a DSP.\n -//! Implementation: Derive from dsp_impl_base instead of deriving from dsp directly.\n -//! Instantiation: Use dsp_entry static helper methods to instantiate DSPs, or dsp_chain_config / dsp_manager to deal with entire DSP chains. -class NOVTABLE dsp : public service_base { -public: - enum { - //! Flush whatever you need to when tracks change. - END_OF_TRACK = 1, - //! Flush everything. - FLUSH = 2 - }; - - //! @param p_chunk_list List of chunks to process. The implementation may alter the list in any way, inserting chunks of different sample rate / channel configuration etc. - //! @param p_cur_file Optional, location of currently decoded file. May be null. - //! @param p_flags Flags. Can be null, or a combination of END_OF_TRACK and FLUSH constants. - virtual void run(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags)=0; - - //! Flushes the DSP (reinitializes / drops any buffered data). Called after seeking, etc. - virtual void flush() = 0; - - //! Retrieves amount of data buffered by the DSP, for syncing visualisation. - //! @returns Amount of buffered audio data, in seconds. - virtual double get_latency() = 0; - //! Returns true if DSP needs to know exact track change point (eg. for crossfading, removing silence).\n - //! Signaling this will force-flush any DSPs placed before this DSP so when it gets END_OF_TRACK, relevant chunks contain last samples of the track.\n - //! Signaling this will often break regular gapless playback so don't use it unless you have reasons to. - virtual bool need_track_change_mark() = 0; - - void run_abortable(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort); - - FB2K_MAKE_SERVICE_INTERFACE(dsp,service_base); -}; - -//! Backwards-compatible extension to dsp interface, allows abortable operation. Introduced in 0.9.2. -class NOVTABLE dsp_v2 : public dsp { -public: - //! Abortable version of dsp::run(). See dsp::run() for descriptions of parameters. - virtual void run_v2(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort) = 0; -private: - void run(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags) { - run_v2(p_chunk_list,p_cur_file,p_flags,abort_callback_dummy()); - } - - FB2K_MAKE_SERVICE_INTERFACE(dsp_v2,dsp); -}; - -//! Helper class for implementing dsps. You should derive from dsp_impl_base instead of from dsp directly.\n -//! The dsp_impl_base_t template allows you to use a custom interface class as a base class for your implementation, in case you provide extended functionality.\n -//! Use dsp_factory_t<> template to register your dsp implementation. -//! The implementation - as required by dsp_factory_t<> template - must also provide following methods:\n -//! A constructor taking const dsp_preset&, initializing the DSP with specified preset data.\n -//! static void g_get_name(pfc::string_base &); - retrieving human-readable name of the DSP to display.\n -//! static bool g_get_default_preset(dsp_preset &); - retrieving default preset for this DSP. Return value is reserved for future use and should always be true.\n -//! static GUID g_get_guid(); - retrieving GUID of your DSP implementation, to be used to identify it when storing DSP chain configuration.\n -//! static bool g_have_config_popup(); - retrieving whether your DSP implementation supplies a popup dialog for configuring it.\n -//! static void g_show_config_popup(const dsp_preset & p_data,HWND p_parent, dsp_preset_edit_callback & p_callback); - displaying your DSP's settings dialog; called only when g_have_config_popup() returns true; call p_callback.on_preset_changed() whenever user has made adjustments to the preset data.\n -template -class dsp_impl_base_t : public t_baseclass { -private: - typedef dsp_impl_base_t t_self; - dsp_chunk_list * m_list; - t_size m_chunk_ptr; - metadb_handle* m_cur_file; - void run_v2(dsp_chunk_list * p_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort); -protected: - bool get_cur_file(metadb_handle_ptr & p_out) {p_out = m_cur_file; return p_out.is_valid();}// call only from on_chunk / on_endoftrack (on_endoftrack will give info on track being finished); may return null !! - - dsp_impl_base_t() : m_list(NULL), m_cur_file(NULL), m_chunk_ptr(0) {} - - audio_chunk * insert_chunk(t_size p_hint_size = 0) //call only from on_endoftrack / on_endofplayback / on_chunk - {//hint_size - optional, amout of buffer space you want to use - PFC_ASSERT(m_list != NULL); - return m_list->insert_item(m_chunk_ptr++,p_hint_size); - } - - - //! To be overridden by a DSP implementation.\n - //! Called on track change. You can use insert_chunk() to dump any data you have to flush. \n - //! Note that you must implement need_track_change_mark() to return true if you need this method called. - virtual void on_endoftrack(abort_callback & p_abort) = 0; - //! To be overridden by a DSP implementation.\n - //! Called at the end of played stream, typically at the end of last played track, to allow the DSP to return all data it has buffered-ahead.\n - //! Use insert_chunk() to return any data you have buffered.\n - //! Note that this call does not imply that the DSP will be destroyed next. \n - //! This is also called on track changes if some DSP placed after your DSP requests track change marks. - virtual void on_endofplayback(abort_callback & p_abort) = 0; - //! To be overridden by a DSP implementation.\n - //! Processes a chunk of audio data.\n - //! You can call insert_chunk() from inside on_chunk() to insert any audio data before currently processed chunk.\n - //! @param p_chunk Current chunk being processed. You can alter it in any way you like. - //! @returns True to keep p_chunk (with alterations made inside on_chunk()) in the stream, false to remove it. - virtual bool on_chunk(audio_chunk * p_chunk,abort_callback & p_abort) = 0; - -public: - //! To be overridden by a DSP implementation.\n - //! Flushes the DSP (reinitializes / drops any buffered data). Called after seeking, etc. - virtual void flush() = 0; - //! To be overridden by a DSP implementation.\n - //! Retrieves amount of data buffered by the DSP, for syncing visualisation. - //! @returns Amount of buffered audio data, in seconds. - virtual double get_latency() = 0; - //! To be overridden by a DSP implementation.\n - //! Returns true if DSP needs to know exact track change point (eg. for crossfading, removing silence).\n - //! Signaling this will force-flush any DSPs placed before this DSP so when it gets on_endoftrack(), relevant chunks contain last samples of the track.\n - //! Signaling this may interfere with gapless playback in certain scenarios (forces flush of DSPs placed before you) so don't use it unless you have reasons to. - virtual bool need_track_change_mark() = 0; -private: - dsp_impl_base_t(const t_self&) {throw pfc::exception_bug_check_v2();} - const t_self & operator=(const t_self &) {throw pfc::exception_bug_check_v2();} -}; - -template -void dsp_impl_base_t::run_v2(dsp_chunk_list * p_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort) { - pfc::vartoggle_t l_list_toggle(m_list,p_list); - pfc::vartoggle_t l_cur_file_toggle(m_cur_file,p_cur_file.get_ptr()); - - for(m_chunk_ptr = 0;m_chunk_ptrget_count();m_chunk_ptr++) { - audio_chunk * c = m_list->get_item(m_chunk_ptr); - if (c->is_empty() || !on_chunk(c,p_abort)) - m_list->remove_by_idx(m_chunk_ptr--); - } - - if (p_flags & FLUSH) { - on_endofplayback(p_abort); - } else if (p_flags & END_OF_TRACK) { - if (need_track_change_mark()) on_endoftrack(p_abort); - } -} - - -typedef dsp_impl_base_t dsp_impl_base; - -class NOVTABLE dsp_preset { -public: - virtual GUID get_owner() const = 0; - virtual void set_owner(const GUID & p_owner) = 0; - virtual const void * get_data() const = 0; - virtual t_size get_data_size() const = 0; - virtual void set_data(const void * p_data,t_size p_data_size) = 0; - virtual void set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) = 0; - - const dsp_preset & operator=(const dsp_preset & p_source) {copy(p_source); return *this;} - - void copy(const dsp_preset & p_source) {set_owner(p_source.get_owner());set_data(p_source.get_data(),p_source.get_data_size());} - - void contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const; - void contents_from_stream(stream_reader * p_stream,abort_callback & p_abort); - static void g_contents_from_stream_skip(stream_reader * p_stream,abort_callback & p_abort); - - bool operator==(const dsp_preset & p_other) const { - if (get_owner() != p_other.get_owner()) return false; - if (get_data_size() != p_other.get_data_size()) return false; - if (memcmp(get_data(),p_other.get_data(),get_data_size()) != 0) return false; - return true; - } - bool operator!=(const dsp_preset & p_other) const { - return !(*this == p_other); - } -protected: - dsp_preset() {} - ~dsp_preset() {} -}; - -class dsp_preset_writer : public stream_writer { -public: - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check(); - m_data.append_fromptr((const t_uint8 *) p_buffer,p_bytes); - } - void flush(dsp_preset & p_preset) { - p_preset.set_data(m_data.get_ptr(),m_data.get_size()); - m_data.set_size(0); - } -private: - pfc::array_t m_data; -}; - -class dsp_preset_reader : public stream_reader { -public: - dsp_preset_reader() : m_walk(0) {} - dsp_preset_reader(const dsp_preset_reader & p_source) : m_walk(0) {*this = p_source;} - void init(const dsp_preset & p_preset) { - m_data.set_data_fromptr( (const t_uint8*) p_preset.get_data(), p_preset.get_data_size() ); - m_walk = 0; - } - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check(); - t_size todo = pfc::min_t(p_bytes,m_data.get_size()-m_walk); - memcpy(p_buffer,m_data.get_ptr()+m_walk,todo); - m_walk += todo; - return todo; - } - bool is_finished() {return m_walk == m_data.get_size();} -private: - t_size m_walk; - pfc::array_t m_data; -}; - -class dsp_preset_impl : public dsp_preset -{ -public: - dsp_preset_impl() {} - dsp_preset_impl(const dsp_preset_impl & p_source) {copy(p_source);} - dsp_preset_impl(const dsp_preset & p_source) {copy(p_source);} - - const dsp_preset_impl& operator=(const dsp_preset_impl & p_source) {copy(p_source); return *this;} - const dsp_preset_impl& operator=(const dsp_preset & p_source) {copy(p_source); return *this;} - - GUID get_owner() const {return m_owner;} - void set_owner(const GUID & p_owner) {m_owner = p_owner;} - const void * get_data() const {return m_data.get_ptr();} - t_size get_data_size() const {return m_data.get_size();} - void set_data(const void * p_data,t_size p_data_size) {m_data.set_data_fromptr((const t_uint8*)p_data,p_data_size);} - void set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort); -private: - GUID m_owner; - pfc::array_t m_data; -}; - -class NOVTABLE dsp_preset_edit_callback { -public: - virtual void on_preset_changed(const dsp_preset &) = 0; -private: - dsp_preset_edit_callback(const dsp_preset_edit_callback&) {throw pfc::exception_not_implemented();} - const dsp_preset_edit_callback & operator=(const dsp_preset_edit_callback &) {throw pfc::exception_not_implemented();} -protected: - dsp_preset_edit_callback() {} - ~dsp_preset_edit_callback() {} -}; - -class NOVTABLE dsp_entry : public service_base { -public: - virtual void get_name(pfc::string_base & p_out) = 0; - virtual bool get_default_preset(dsp_preset & p_out) = 0; - virtual bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) = 0; - virtual GUID get_guid() = 0; - virtual bool have_config_popup() = 0; - virtual bool show_config_popup(dsp_preset & p_data,HWND p_parent) = 0; - - - static bool g_get_interface(service_ptr_t & p_out,const GUID & p_guid); - static bool g_instantiate(service_ptr_t & p_out,const dsp_preset & p_preset); - static bool g_instantiate_default(service_ptr_t & p_out,const GUID & p_guid); - static bool g_name_from_guid(pfc::string_base & p_out,const GUID & p_guid); - static bool g_dsp_exists(const GUID & p_guid); - static bool g_get_default_preset(dsp_preset & p_out,const GUID & p_guid); - static bool g_have_config_popup(const GUID & p_guid); - static bool g_have_config_popup(const dsp_preset & p_preset); - static bool g_show_config_popup(dsp_preset & p_preset,HWND p_parent); - - static void g_show_config_popup_v2(const dsp_preset & p_preset,HWND p_parent,dsp_preset_edit_callback & p_callback); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_entry); -}; - -class NOVTABLE dsp_entry_v2 : public dsp_entry { -public: - virtual void show_config_popup_v2(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) = 0; - -private: - bool show_config_popup(dsp_preset & p_data,HWND p_parent); - - FB2K_MAKE_SERVICE_INTERFACE(dsp_entry_v2,dsp_entry); -}; - -template -class dsp_entry_impl_nopreset_t : public t_entry { -public: - void get_name(pfc::string_base & p_out) {T::g_get_name(p_out);} - bool get_default_preset(dsp_preset & p_out) - { - p_out.set_owner(T::g_get_guid()); - p_out.set_data(0,0); - return true; - } - bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) - { - if (p_preset.get_owner() == T::g_get_guid() && p_preset.get_data_size() == 0) - { - p_out = new service_impl_t(); - return p_out.is_valid(); - } - else return false; - } - GUID get_guid() {return T::g_get_guid();} - - bool have_config_popup() {return false;} - bool show_config_popup(dsp_preset & p_data,HWND p_parent) {return false;} -}; - -template -class dsp_entry_impl_t : public t_entry { -public: - void get_name(pfc::string_base & p_out) {T::g_get_name(p_out);} - bool get_default_preset(dsp_preset & p_out) {return T::g_get_default_preset(p_out);} - bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) { - if (p_preset.get_owner() == T::g_get_guid()) { - p_out = new service_impl_t(p_preset); - return true; - } - else return false; - } - GUID get_guid() {return T::g_get_guid();} - - bool have_config_popup() {return T::g_have_config_popup();} - bool show_config_popup(dsp_preset & p_data,HWND p_parent) {return T::g_show_config_popup(p_data,p_parent);} - //void show_config_popup_v2(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) {T::g_show_config_popup(p_data,p_parent,p_callback);} -}; - -template -class dsp_entry_v2_impl_t : public t_entry { -public: - void get_name(pfc::string_base & p_out) {T::g_get_name(p_out);} - bool get_default_preset(dsp_preset & p_out) {return T::g_get_default_preset(p_out);} - bool instantiate(service_ptr_t & p_out,const dsp_preset & p_preset) { - if (p_preset.get_owner() == T::g_get_guid()) { - p_out = new service_impl_t(p_preset); - return true; - } - else return false; - } - GUID get_guid() {return T::g_get_guid();} - - bool have_config_popup() {return T::g_have_config_popup();} - //bool show_config_popup(dsp_preset & p_data,HWND p_parent) {return T::g_show_config_popup(p_data,p_parent);} - void show_config_popup_v2(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) {T::g_show_config_popup(p_data,p_parent,p_callback);} -}; - - -template -class dsp_factory_nopreset_t : public service_factory_single_t > {}; - -template -class dsp_factory_t : public service_factory_single_t > {}; - -class NOVTABLE dsp_chain_config -{ -public: - virtual t_size get_count() const = 0; - virtual const dsp_preset & get_item(t_size p_index) const = 0; - virtual void replace_item(const dsp_preset & p_data,t_size p_index) = 0; - virtual void insert_item(const dsp_preset & p_data,t_size p_index) = 0; - virtual void remove_mask(const bit_array & p_mask) = 0; - - void remove_item(t_size p_index); - void remove_all(); - void add_item(const dsp_preset & p_data); - void copy(const dsp_chain_config & p_source); - - const dsp_chain_config & operator=(const dsp_chain_config & p_source) {copy(p_source); return *this;} - - void contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const; - void contents_from_stream(stream_reader * p_stream,abort_callback & p_abort); - - void instantiate(service_list_t & p_out); - - void get_name_list(pfc::string_base & p_out) const; -}; - -FB2K_STREAM_READER_OVERLOAD(dsp_chain_config) { - value.contents_from_stream(&stream.m_stream, stream.m_abort); return stream; -} - -FB2K_STREAM_WRITER_OVERLOAD(dsp_chain_config) { - value.contents_to_stream(&stream.m_stream, stream.m_abort); return stream; -} - -class dsp_chain_config_impl : public dsp_chain_config -{ -public: - dsp_chain_config_impl() {} - dsp_chain_config_impl(const dsp_chain_config & p_source) {copy(p_source);} - dsp_chain_config_impl(const dsp_chain_config_impl & p_source) {copy(p_source);} - t_size get_count() const; - const dsp_preset & get_item(t_size p_index) const; - void replace_item(const dsp_preset & p_data,t_size p_index); - void insert_item(const dsp_preset & p_data,t_size p_index); - void remove_mask(const bit_array & p_mask); - - const dsp_chain_config_impl & operator=(const dsp_chain_config & p_source) {copy(p_source); return *this;} - const dsp_chain_config_impl & operator=(const dsp_chain_config_impl & p_source) {copy(p_source); return *this;} - - ~dsp_chain_config_impl(); -private: - pfc::ptr_list_t m_data; -}; - -class cfg_dsp_chain_config : public cfg_var { -protected: - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort); - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort); -public: - void reset(); - inline cfg_dsp_chain_config(const GUID & p_guid) : cfg_var(p_guid) {} - t_size get_count() const {return m_data.get_count();} - const dsp_preset & get_item(t_size p_index) const {return m_data.get_item(p_index);} - bool get_data(dsp_chain_config & p_data) const; - void set_data(const dsp_chain_config & p_data); -private: - dsp_chain_config_impl m_data; - -}; - - - - -//! Helper. -class dsp_preset_parser : public stream_reader_formatter<> { -public: - dsp_preset_parser(const dsp_preset & in) : m_data(in), _m_stream(in.get_data(),in.get_data_size()), stream_reader_formatter(_m_stream,_m_abort) {} - - void reset() {_m_stream.reset();} - t_size get_remaining() const {return _m_stream.get_remaining();} - - void assume_empty() const { - if (get_remaining() != 0) throw exception_io_data(); - } - - GUID get_owner() const {return m_data.get_owner();} -private: - const dsp_preset & m_data; - abort_callback_dummy _m_abort; - stream_reader_memblock_ref _m_stream; -}; - -//! Helper. -class dsp_preset_builder : public stream_writer_formatter<> { -public: - dsp_preset_builder() : stream_writer_formatter(_m_stream,_m_abort) {} - void finish(const GUID & id, dsp_preset & out) { - out.set_owner(id); - out.set_data(_m_stream.m_buffer.get_ptr(), _m_stream.m_buffer.get_size()); - } - void reset() { - _m_stream.m_buffer.set_size(0); - } -private: - abort_callback_dummy _m_abort; - stream_writer_buffer_simple _m_stream; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/dsp_manager.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/dsp_manager.cpp deleted file mode 100644 index 56a7e99de..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/dsp_manager.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#include "foobar2000.h" - -void dsp_manager::close() { - m_chain.remove_all(); - m_config_changed = true; -} - -void dsp_manager::set_config( const dsp_chain_config & p_data ) -{ - //dsp_chain_config::g_instantiate(m_dsp_list,p_data); - m_config.copy(p_data); - m_config_changed = true; -} - -void dsp_manager::dsp_run(t_dsp_chain::const_iterator p_iter,dsp_chunk_list * p_list,const metadb_handle_ptr & cur_file,unsigned flags,double & latency,abort_callback & p_abort) -{ - p_list->remove_bad_chunks(); - - TRACK_CODE("dsp::run",p_iter->m_dsp->run_abortable(p_list,cur_file,flags,p_abort)); - TRACK_CODE("dsp::get_latency",latency += p_iter->m_dsp->get_latency()); -} - -double dsp_manager::run(dsp_chunk_list * p_list,const metadb_handle_ptr & p_cur_file,unsigned p_flags,abort_callback & p_abort) { - TRACK_CALL_TEXT("dsp_manager::run"); - - try { - fpu_control_default l_fpu_control; - - double latency=0; - bool done = false; - - t_dsp_chain::const_iterator flush_mark; - if ((p_flags & dsp::END_OF_TRACK) && ! (p_flags & dsp::FLUSH)) { - for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { - if (iter->m_dsp->need_track_change_mark()) flush_mark = iter; - } - } - - if (m_config_changed) - { - t_dsp_chain newchain; - bool recycle_available = true; - - for(t_size n=0;n temp; - - const dsp_preset & preset = m_config.get_item(n); - if (dsp_entry::g_dsp_exists(preset.get_owner())) { - t_dsp_chain::iterator iter = newchain.insert_last(); - iter->m_preset = m_config.get_item(n); - iter->m_recycle_flag = false; - } - } - - - //HACK: recycle existing DSPs in a special case when user has apparently only altered settings of one of DSPs. - if (newchain.get_count() == m_chain.get_count()) { - t_size data_mismatch_count = 0; - t_size owner_mismatch_count = 0; - t_dsp_chain::iterator iter_src, iter_dst; - iter_src = m_chain.first(); iter_dst = newchain.first(); - while(iter_src.is_valid() && iter_dst.is_valid()) { - if (iter_src->m_preset.get_owner() != iter_dst->m_preset.get_owner()) { - owner_mismatch_count++; - } else if (iter_src->m_preset != iter_dst->m_preset) { - data_mismatch_count++; - } - ++iter_src; ++iter_dst; - } - recycle_available = (owner_mismatch_count == 0 && data_mismatch_count <= 1); - } else { - recycle_available = false; - } - - if (recycle_available) { - t_dsp_chain::iterator iter_src, iter_dst; - iter_src = m_chain.first(); iter_dst = newchain.first(); - while(iter_src.is_valid() && iter_dst.is_valid()) { - if (iter_src->m_preset == iter_dst->m_preset) { - iter_src->m_recycle_flag = true; - iter_dst->m_dsp = iter_src->m_dsp; - } - ++iter_src; ++iter_dst; - } - } - - for(t_dsp_chain::iterator iter = newchain.first(); iter.is_valid(); ++iter) { - if (iter->m_dsp.is_empty()) { - if (!dsp_entry::g_instantiate(iter->m_dsp,iter->m_preset)) throw pfc::exception_bug_check_v2(); - } - } - - if (m_chain.get_count()>0) { - bool flushflag = flush_mark.is_valid(); - for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { - unsigned flags2 = p_flags; - if (iter == flush_mark) flushflag = false; - if (flushflag || !iter->m_recycle_flag) flags2|=dsp::FLUSH; - dsp_run(iter,p_list,p_cur_file,flags2,latency,p_abort); - } - done = true; - } - - m_chain = newchain; - m_config_changed = false; - } - - if (!done) - { - bool flushflag = flush_mark.is_valid(); - for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { - unsigned flags2 = p_flags; - if (iter == flush_mark) flushflag = false; - if (flushflag) flags2|=dsp::FLUSH; - dsp_run(iter,p_list,p_cur_file,flags2,latency,p_abort); - } - done = true; - } - - p_list->remove_bad_chunks(); - - return latency; - } catch(...) { - p_list->remove_all(); - throw; - } -} - -void dsp_manager::flush() -{ - for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) { - TRACK_CODE("dsp::flush",iter->m_dsp->flush()); - } -} - - -bool dsp_manager::is_active() const {return m_config.get_count()>0;} - -void dsp_config_manager::core_enable_dsp(const dsp_preset & preset) { - dsp_chain_config_impl cfg; - get_core_settings(cfg); - - bool found = false; - bool changed = false; - t_size n,m = cfg.get_count(); - for(n=0;n m_dsp; - dsp_preset_impl m_preset; - bool m_recycle_flag; - }; - typedef pfc::chain_list_v2_t t_dsp_chain; - - t_dsp_chain m_chain; - dsp_chain_config_impl m_config; - bool m_config_changed; - - void dsp_run(t_dsp_chain::const_iterator p_iter,dsp_chunk_list * list,const metadb_handle_ptr & cur_file,unsigned flags,double & latency,abort_callback&); - - dsp_manager(const dsp_manager &) {throw pfc::exception_not_implemented();} - const dsp_manager & operator=(const dsp_manager&) {throw pfc::exception_not_implemented();} -}; - -//! Core API for accessing core playback DSP settings as well as spawning DSP configuration dialogs. \n -//! Use static_api_ptr_t() to instantiate. -class dsp_config_manager : public service_base { - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_config_manager); -public: - //! Retrieves current core playback DSP settings. - virtual void get_core_settings(dsp_chain_config & p_out) = 0; - //! Changes current core playback DSP settings. - virtual void set_core_settings(const dsp_chain_config & p_data) = 0; - - //! Runs a modal DSP settings dialog. - //! @param p_data DSP chain configuration to edit - contains initial configuration to put in the dialog when called, receives the new configuration on successful edit. - //! @returns True when user approved DSP configuration changes (pressed the "OK" button), false when the user cancelled them ("Cancel" button). - virtual bool configure_popup(dsp_chain_config & p_data,HWND p_parent,const char * p_title) = 0; - - //! Spawns an embedded DSP settings dialog. - //! @param p_initdata Initial DSP chain configuration to put in the dialog. - //! @param p_parent Parent window to contain the embedded dialog. - //! @param p_id Control ID of the embedded dialog. The parent window will receive a WM_COMMAND with BN_CLICKED and this identifier when user changes settings in the embedded dialog. - //! @param p_from_modal Must be set to true when the parent window is a modal dialog, false otherwise. - virtual HWND configure_embedded(const dsp_chain_config & p_initdata,HWND p_parent,unsigned p_id,bool p_from_modal) = 0; - //! Retrieves current settings from an embedded DSP settings dialog. See also: configure_embedded(). - virtual void configure_embedded_retrieve(HWND wnd,dsp_chain_config & p_data) = 0; - //! Changes current settings in an embedded DSP settings dialog. See also: configure_embedded(). - virtual void configure_embedded_change(HWND wnd,const dsp_chain_config & p_data) = 0; - - - //! Helper - enables a DSP in core playback settings. - void core_enable_dsp(const dsp_preset & preset); - //! Helper - disables a DSP in core playback settings. - void core_disable_dsp(const GUID & id); - //! Helper - if a DSP with the specified identifier is present in playback settings, retrieves its configuration and returns true, otherwise returns false. - bool core_query_dsp(const GUID & id, dsp_preset & out); -}; - -//! Callback class for getting notified about core playback DSP settings getting altered. \n -//! Register your implementations with static service_factory_single_t g_myclass_factory; -class NOVTABLE dsp_config_callback : public service_base { - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_config_callback); -public: - //! Called when core playback DSP settings change. \n - //! Note: you must not try to alter core playback DSP settings inside this callback, or call anything else that possibly alters core playback DSP settings. - virtual void on_core_settings_change(const dsp_chain_config & p_newdata) = 0; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/event_logger.h b/tools/vio2sf/src/foobar/foobar2000/SDK/event_logger.h deleted file mode 100644 index 20e3f7c58..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/event_logger.h +++ /dev/null @@ -1,19 +0,0 @@ -class NOVTABLE event_logger : public service_base { - FB2K_MAKE_SERVICE_INTERFACE(event_logger, service_base); -public: - enum { - severity_status, - severity_warning, - severity_error - }; - void log_status(const char * line) {log_entry(line, severity_status);} - void log_warning(const char * line) {log_entry(line, severity_warning);} - void log_error(const char * line) {log_entry(line, severity_error);} - - virtual void log_entry(const char * line, unsigned severity) = 0; -}; - -class event_logger_fallback : public event_logger { -public: - void log_entry(const char * line, unsigned) {console::print(line);} -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/file_info.cpp deleted file mode 100644 index 11275416b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info.cpp +++ /dev/null @@ -1,451 +0,0 @@ -#include "foobar2000.h" - -t_size file_info::meta_find_ex(const char * p_name,t_size p_name_length) const -{ - t_size n, m = meta_get_count(); - for(n=0;n= max) return 0; - return meta_enum_value(index,p_index); -} - -const char * file_info::info_get_ex(const char * p_name,t_size p_name_length) const -{ - t_size index = info_find_ex(p_name,p_name_length); - if (index == infinite) return 0; - return info_enum_value(index); -} - -t_int64 file_info::info_get_int(const char * name) const -{ - PFC_ASSERT(pfc::is_valid_utf8(name)); - const char * val = info_get(name); - if (val==0) return 0; - return _atoi64(val); -} - -t_int64 file_info::info_get_length_samples() const -{ - t_int64 ret = 0; - double len = get_length(); - t_int64 srate = info_get_int("samplerate"); - - if (srate>0 && len>0) - { - ret = audio_math::time_to_samples(len,(unsigned)srate); - } - return ret; -} - -double file_info::info_get_float(const char * name) const -{ - const char * ptr = info_get(name); - if (ptr) return pfc::string_to_float(ptr); - else return 0; -} - -void file_info::info_set_int(const char * name,t_int64 value) -{ - PFC_ASSERT(pfc::is_valid_utf8(name)); - info_set(name,pfc::format_int(value)); -} - -void file_info::info_set_float(const char * name,double value,unsigned precision,bool force_sign,const char * unit) -{ - PFC_ASSERT(pfc::is_valid_utf8(name)); - PFC_ASSERT(unit==0 || strlen(unit) <= 64); - char temp[128]; - pfc::float_to_string(temp,64,value,precision,force_sign); - temp[63] = 0; - if (unit) - { - strcat(temp," "); - strcat(temp,unit); - } - info_set(name,temp); -} - - -void file_info::info_set_replaygain_album_gain(float value) -{ - replaygain_info temp = get_replaygain(); - temp.m_album_gain = value; - set_replaygain(temp); -} - -void file_info::info_set_replaygain_album_peak(float value) -{ - replaygain_info temp = get_replaygain(); - temp.m_album_peak = value; - set_replaygain(temp); -} - -void file_info::info_set_replaygain_track_gain(float value) -{ - replaygain_info temp = get_replaygain(); - temp.m_track_gain = value; - set_replaygain(temp); -} - -void file_info::info_set_replaygain_track_peak(float value) -{ - replaygain_info temp = get_replaygain(); - temp.m_track_peak = value; - set_replaygain(temp); -} - - -static bool is_valid_bps(t_int64 val) -{ - return val>0 && val<=256; -} - -unsigned file_info::info_get_decoded_bps() const -{ - t_int64 val = info_get_int("decoded_bitspersample"); - if (is_valid_bps(val)) return (unsigned)val; - val = info_get_int("bitspersample"); - if (is_valid_bps(val)) return (unsigned)val; - return 0; - -} - -void file_info::reset() -{ - info_remove_all(); - meta_remove_all(); - set_length(0); - reset_replaygain(); -} - -void file_info::reset_replaygain() -{ - replaygain_info temp; - temp.reset(); - set_replaygain(temp); -} - -void file_info::copy_meta_single_rename_ex(const file_info & p_source,t_size p_index,const char * p_new_name,t_size p_new_name_length) -{ - t_size n, m = p_source.meta_enum_value_count(p_index); - t_size new_index = infinite; - for(n=0;n 0); - for(val=0;val 0) out += separator; - out += meta_enum_value(index,val); - } -} - -bool file_info::meta_format(const char * p_name,pfc::string_base & p_out, const char * separator) const { - p_out.reset(); - t_size index = meta_find(p_name); - if (index == infinite) return false; - meta_format_entry(index, p_out, separator); - return true; -} - -void file_info::info_calculate_bitrate(t_filesize p_filesize,double p_length) -{ - info_set_bitrate((unsigned)floor((double)p_filesize * 8 / (p_length * 1000) + 0.5)); -} - -bool file_info::is_encoding_lossy() const { - const char * encoding = info_get("encoding"); - if (encoding != NULL) { - if (pfc::stricmp_ascii(encoding,"lossy") == 0 /*|| pfc::stricmp_ascii(encoding,"hybrid") == 0*/) return true; - } else { - //the old way - if (info_get("bitspersample") == NULL) return true; - } - return false; -} - -bool file_info::g_is_meta_equal(const file_info & p_item1,const file_info & p_item2) { - const t_size count = p_item1.meta_get_count(); - if (count != p_item2.meta_get_count()) { - //uDebugLog() << "meta count mismatch"; - return false; - } - pfc::map_t item2_meta_map; - for(t_size n=0; n= 32 && p_char < 127 && p_char != '=' && p_char != '%' && p_char != '<' && p_char != '>'; -} - -bool file_info::g_is_valid_field_name(const char * p_name,t_size p_length) { - t_size walk; - for(walk = 0; walk < p_length && p_name[walk] != 0; walk++) { - if (!is_valid_field_name_char(p_name[walk])) return false; - } - return walk > 0; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info.h b/tools/vio2sf/src/foobar/foobar2000/SDK/file_info.h deleted file mode 100644 index 9ffa6f6c9..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info.h +++ /dev/null @@ -1,230 +0,0 @@ -#ifndef _FILE_INFO_H_ -#define _FILE_INFO_H_ - -//! Structure containing ReplayGain scan results from some playable object, also providing various helper methods to manipulate those results. -struct replaygain_info -{ - float m_album_gain,m_track_gain; - float m_album_peak,m_track_peak; - - enum {text_buffer_size = 16 }; - typedef char t_text_buffer[text_buffer_size]; - - enum { peak_invalid = -1, gain_invalid = -1000 }; - - static bool g_format_gain(float p_value,char p_buffer[text_buffer_size]); - static bool g_format_peak(float p_value,char p_buffer[text_buffer_size]); - - inline bool format_album_gain(char p_buffer[text_buffer_size]) const {return g_format_gain(m_album_gain,p_buffer);} - inline bool format_track_gain(char p_buffer[text_buffer_size]) const {return g_format_gain(m_track_gain,p_buffer);} - inline bool format_album_peak(char p_buffer[text_buffer_size]) const {return g_format_peak(m_album_peak,p_buffer);} - inline bool format_track_peak(char p_buffer[text_buffer_size]) const {return g_format_peak(m_track_peak,p_buffer);} - - void set_album_gain_text(const char * p_text,t_size p_text_len = infinite); - void set_track_gain_text(const char * p_text,t_size p_text_len = infinite); - void set_album_peak_text(const char * p_text,t_size p_text_len = infinite); - void set_track_peak_text(const char * p_text,t_size p_text_len = infinite); - - static bool g_is_meta_replaygain(const char * p_name,t_size p_name_len = infinite); - bool set_from_meta_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); - inline bool set_from_meta(const char * p_name,const char * p_value) {return set_from_meta_ex(p_name,infinite,p_value,infinite);} - - inline bool is_album_gain_present() const {return m_album_gain != gain_invalid;} - inline bool is_track_gain_present() const {return m_track_gain != gain_invalid;} - inline bool is_album_peak_present() const {return m_album_peak != peak_invalid;} - inline bool is_track_peak_present() const {return m_track_peak != peak_invalid;} - - inline void remove_album_gain() {m_album_gain = gain_invalid;} - inline void remove_track_gain() {m_track_gain = gain_invalid;} - inline void remove_album_peak() {m_album_peak = peak_invalid;} - inline void remove_track_peak() {m_track_peak = peak_invalid;} - - t_size get_value_count(); - - static replaygain_info g_merge(replaygain_info r1,replaygain_info r2); - - static bool g_equal(const replaygain_info & item1,const replaygain_info & item2); - - void reset(); -}; - -inline bool operator==(const replaygain_info & item1,const replaygain_info & item2) {return replaygain_info::g_equal(item1,item2);} -inline bool operator!=(const replaygain_info & item1,const replaygain_info & item2) {return !replaygain_info::g_equal(item1,item2);} - -static const replaygain_info replaygain_info_invalid = {replaygain_info::gain_invalid,replaygain_info::gain_invalid,replaygain_info::peak_invalid,replaygain_info::peak_invalid}; - - -//! Main interface class for information about some playable object. -class NOVTABLE file_info { -public: - //! Retrieves length, in seconds. - virtual double get_length() const = 0; - //! Sets length, in seconds. - virtual void set_length(double p_length) = 0; - - //! Sets ReplayGain information. - virtual void set_replaygain(const replaygain_info & p_info) = 0; - //! Retrieves ReplayGain information. - virtual replaygain_info get_replaygain() const = 0; - - //! Retrieves count of metadata entries. - virtual t_size meta_get_count() const = 0; - //! Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 encoded string. - virtual const char* meta_enum_name(t_size p_index) const = 0; - //! Retrieves count of values in metadata entry of specified index. The value is always equal to or greater than 1. - virtual t_size meta_enum_value_count(t_size p_index) const = 0; - //! Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 encoded string. - virtual const char* meta_enum_value(t_size p_index,t_size p_value_number) const = 0; - //! Finds index of metadata entry of specified name. Returns infinite when not found. - virtual t_size meta_find_ex(const char * p_name,t_size p_name_length) const; - //! Creates a new metadata entry of specified name with specified value. If an entry of same name already exists, it is erased. Return value is the index of newly created metadata entry. - virtual t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; - //! Inserts a new value into specified metadata entry. - virtual void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) = 0; - //! Removes metadata entries according to specified bit mask. - virtual void meta_remove_mask(const bit_array & p_mask) = 0; - //! Reorders metadata entries according to specified permutation. - virtual void meta_reorder(const t_size * p_order) = 0; - //! Removes values according to specified bit mask from specified metadata entry. If all values are removed, entire metadata entry is removed as well. - virtual void meta_remove_values(t_size p_index,const bit_array & p_mask) = 0; - //! Alters specified value in specified metadata entry. - virtual void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) = 0; - - //! Retrieves number of technical info entries. - virtual t_size info_get_count() const = 0; - //! Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded string. - virtual const char* info_enum_name(t_size p_index) const = 0; - //! Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encoded string. - virtual const char* info_enum_value(t_size p_index) const = 0; - //! Creates a new technical info entry with specified name and specified value. If an entry of the same name already exists, it is erased. Return value is the index of newly created entry. - virtual t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; - //! Removes technical info entries indicated by specified bit mask. - virtual void info_remove_mask(const bit_array & p_mask) = 0; - //! Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure. - virtual t_size info_find_ex(const char * p_name,t_size p_name_length) const; - - //! Copies entire file_info contents from specified file_info object. - virtual void copy(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass - //! Copies metadata from specified file_info object. - virtual void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass - //! Copies technical info from specified file_info object. - virtual void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass - - bool meta_exists_ex(const char * p_name,t_size p_name_length) const; - void meta_remove_field_ex(const char * p_name,t_size p_name_length); - void meta_remove_index(t_size p_index); - void meta_remove_all(); - void meta_remove_value(t_size p_index,t_size p_value); - const char * meta_get_ex(const char * p_name,t_size p_name_length,t_size p_index) const; - t_size meta_get_count_by_name_ex(const char * p_name,t_size p_name_length) const; - void meta_add_value_ex(t_size p_index,const char * p_value,t_size p_value_length); - t_size meta_add_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); - t_size meta_calc_total_value_count() const; - bool meta_format(const char * p_name,pfc::string_base & p_out, const char * separator = ", ") const; - void meta_format_entry(t_size index, pfc::string_base & p_out, const char * separator = ", ") const;//same as meta_format but takes index instead of meta name. - - - bool info_exists_ex(const char * p_name,t_size p_name_length) const; - void info_remove_index(t_size p_index); - void info_remove_all(); - bool info_remove_ex(const char * p_name,t_size p_name_length); - const char * info_get_ex(const char * p_name,t_size p_name_length) const; - - inline t_size meta_find(const char * p_name) const {return meta_find_ex(p_name,infinite);} - inline bool meta_exists(const char * p_name) const {return meta_exists_ex(p_name,infinite);} - inline void meta_remove_field(const char * p_name) {meta_remove_field_ex(p_name,infinite);} - inline t_size meta_set(const char * p_name,const char * p_value) {return meta_set_ex(p_name,infinite,p_value,infinite);} - inline void meta_insert_value(t_size p_index,t_size p_value_index,const char * p_value) {meta_insert_value_ex(p_index,p_value_index,p_value,infinite);} - inline void meta_add_value(t_size p_index,const char * p_value) {meta_add_value_ex(p_index,p_value,infinite);} - inline const char* meta_get(const char * p_name,t_size p_index) const {return meta_get_ex(p_name,infinite,p_index);} - inline t_size meta_get_count_by_name(const char * p_name) const {return meta_get_count_by_name_ex(p_name,infinite);} - inline t_size meta_add(const char * p_name,const char * p_value) {return meta_add_ex(p_name,infinite,p_value,infinite);} - inline void meta_modify_value(t_size p_index,t_size p_value_index,const char * p_value) {meta_modify_value_ex(p_index,p_value_index,p_value,infinite);} - - - - inline t_size info_set(const char * p_name,const char * p_value) {return info_set_ex(p_name,infinite,p_value,infinite);} - inline t_size info_find(const char * p_name) const {return info_find_ex(p_name,infinite);} - inline t_size info_exists(const char * p_name) const {return info_exists_ex(p_name,infinite);} - inline bool info_remove(const char * p_name) {return info_remove_ex(p_name,infinite);} - inline const char * info_get(const char * p_name) const {return info_get_ex(p_name,infinite);} - - bool info_set_replaygain_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); - inline bool info_set_replaygain(const char * p_name,const char * p_value) {return info_set_replaygain_ex(p_name,infinite,p_value,infinite);} - void info_set_replaygain_auto_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); - inline void info_set_replaygain_auto(const char * p_name,const char * p_value) {info_set_replaygain_auto_ex(p_name,infinite,p_value,infinite);} - - - - void copy_meta_single(const file_info & p_source,t_size p_index); - void copy_info_single(const file_info & p_source,t_size p_index); - void copy_meta_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length); - void copy_info_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length); - inline void copy_meta_single_by_name(const file_info & p_source,const char * p_name) {copy_meta_single_by_name_ex(p_source,p_name,infinite);} - inline void copy_info_single_by_name(const file_info & p_source,const char * p_name) {copy_info_single_by_name_ex(p_source,p_name,infinite);} - void reset(); - void reset_replaygain(); - void copy_meta_single_rename_ex(const file_info & p_source,t_size p_index,const char * p_new_name,t_size p_new_name_length); - inline void copy_meta_single_rename(const file_info & p_source,t_size p_index,const char * p_new_name) {copy_meta_single_rename_ex(p_source,p_index,p_new_name,infinite);} - void overwrite_info(const file_info & p_source); - - t_int64 info_get_int(const char * name) const; - t_int64 info_get_length_samples() const; - double info_get_float(const char * name) const; - void info_set_int(const char * name,t_int64 value); - void info_set_float(const char * name,double value,unsigned precision,bool force_sign = false,const char * unit = 0); - void info_set_replaygain_track_gain(float value); - void info_set_replaygain_album_gain(float value); - void info_set_replaygain_track_peak(float value); - void info_set_replaygain_album_peak(float value); - - inline t_int64 info_get_bitrate_vbr() const {return info_get_int("bitrate_dynamic");} - inline void info_set_bitrate_vbr(t_int64 val) {info_set_int("bitrate_dynamic",val);} - inline t_int64 info_get_bitrate() const {return info_get_int("bitrate");} - inline void info_set_bitrate(t_int64 val) {info_set_int("bitrate",val);} - bool is_encoding_lossy() const; - - void info_calculate_bitrate(t_filesize p_filesize,double p_length); - - unsigned info_get_decoded_bps() const;//what bps the stream originally was (before converting to audio_sample), 0 if unknown - - void merge(const pfc::list_base_const_t & p_sources); - - bool are_meta_fields_identical(t_size p_index1,t_size p_index2) const; - - inline const file_info & operator=(const file_info & p_source) {copy(p_source);return *this;} - - static bool g_is_meta_equal(const file_info & p_item1,const file_info & p_item2); - static bool g_is_info_equal(const file_info & p_item1,const file_info & p_item2); - - //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. - t_size __meta_add_unsafe_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);} - //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. - t_size __meta_add_unsafe(const char * p_name,const char * p_value) {return meta_set_nocheck_ex(p_name,infinite,p_value,infinite);} - - //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. - t_size __info_add_unsafe_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);} - //! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally. - t_size __info_add_unsafe(const char * p_name,const char * p_value) {return info_set_nocheck_ex(p_name,infinite,p_value,infinite);} - - static bool g_is_valid_field_name(const char * p_name,t_size p_length = infinite); - //typedef pfc::comparator_stricmp_ascii field_name_comparator; - typedef pfc::string::comparatorCaseInsensitiveASCII field_name_comparator; -protected: - file_info() {} - ~file_info() {} - void copy_meta_single_nocheck(const file_info & p_source,t_size p_index); - void copy_info_single_nocheck(const file_info & p_source,t_size p_index); - void copy_meta_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length); - void copy_info_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length); - inline void copy_meta_single_by_name_nocheck(const file_info & p_source,const char * p_name) {copy_meta_single_by_name_nocheck_ex(p_source,p_name,infinite);} - inline void copy_info_single_by_name_nocheck(const file_info & p_source,const char * p_name) {copy_info_single_by_name_nocheck_ex(p_source,p_name,infinite);} - - virtual t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; - virtual t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; - inline t_size meta_set_nocheck(const char * p_name,const char * p_value) {return meta_set_nocheck_ex(p_name,infinite,p_value,infinite);} - inline t_size info_set_nocheck(const char * p_name,const char * p_value) {return info_set_nocheck_ex(p_name,infinite,p_value,infinite);} -}; - - -#endif //_FILE_INFO_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info_impl.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/file_info_impl.cpp deleted file mode 100644 index f55be0ec2..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info_impl.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include "foobar2000.h" - - -t_size file_info_impl::meta_get_count() const -{ - return m_meta.get_count(); -} - -const char* file_info_impl::meta_enum_name(t_size p_index) const -{ - return m_meta.get_name(p_index); -} - -t_size file_info_impl::meta_enum_value_count(t_size p_index) const -{ - return m_meta.get_value_count(p_index); -} - -const char* file_info_impl::meta_enum_value(t_size p_index,t_size p_value_number) const -{ - return m_meta.get_value(p_index,p_value_number); -} - -t_size file_info_impl::meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) -{ - meta_remove_field_ex(p_name,p_name_length); - return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length); -} - -t_size file_info_impl::meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) -{ - return m_meta.add_entry(p_name,p_name_length,p_value,p_value_length); -} - -void file_info_impl::meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) -{ - m_meta.insert_value(p_index,p_value_index,p_value,p_value_length); -} - -void file_info_impl::meta_remove_mask(const bit_array & p_mask) -{ - m_meta.remove_mask(p_mask); -} - -void file_info_impl::meta_reorder(const t_size * p_order) -{ - m_meta.reorder(p_order); -} - -void file_info_impl::meta_remove_values(t_size p_index,const bit_array & p_mask) -{ - m_meta.remove_values(p_index,p_mask); - if (m_meta.get_value_count(p_index) == 0) - m_meta.remove_mask(bit_array_one(p_index)); -} - -t_size file_info_impl::info_get_count() const -{ - return m_info.get_count(); -} - -const char* file_info_impl::info_enum_name(t_size p_index) const -{ - return m_info.get_name(p_index); -} - -const char* file_info_impl::info_enum_value(t_size p_index) const -{ - return m_info.get_value(p_index); -} - -t_size file_info_impl::info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) -{ - info_remove_ex(p_name,p_name_length); - return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length); -} - -t_size file_info_impl::info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) -{ - return m_info.add_item(p_name,p_name_length,p_value,p_value_length); -} - -void file_info_impl::info_remove_mask(const bit_array & p_mask) -{ - m_info.remove_mask(p_mask); -} - - -file_info_impl::file_info_impl(const file_info & p_source) : m_length(0) -{ - copy(p_source); -} - -file_info_impl::file_info_impl(const file_info_impl & p_source) : m_length(0) -{ - copy(p_source); -} - -const file_info_impl & file_info_impl::operator=(const file_info_impl & p_source) -{ - copy(p_source); - return *this; -} - -file_info_impl::file_info_impl() : m_length(0) -{ - m_replaygain.reset(); -} - -double file_info_impl::get_length() const -{ - return m_length; -} - -void file_info_impl::set_length(double p_length) -{ - m_length = p_length; -} - -void file_info_impl::meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) -{ - m_meta.modify_value(p_index,p_value_index,p_value,p_value_length); -} - -replaygain_info file_info_impl::get_replaygain() const -{ - return m_replaygain; -} - -void file_info_impl::set_replaygain(const replaygain_info & p_info) -{ - m_replaygain = p_info; -} - - - - -file_info_impl::~file_info_impl() -{ -} - -t_size file_info_impl_utils::info_storage::add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) { - t_size index = m_info.get_size(); - m_info.set_size(index + 1); - m_info[index].init(p_name,p_name_length,p_value,p_value_length); - return index; -} - -void file_info_impl_utils::info_storage::remove_mask(const bit_array & p_mask) { - pfc::remove_mask_t(m_info,p_mask); -} - - - -t_size file_info_impl_utils::meta_storage::add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) -{ - meta_entry temp(p_name,p_name_length,p_value,p_value_length); - return pfc::append_swap_t(m_data,temp); -} - -void file_info_impl_utils::meta_storage::insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) -{ - m_data[p_index].insert_value(p_value_index,p_value,p_value_length); -} - -void file_info_impl_utils::meta_storage::modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) -{ - m_data[p_index].modify_value(p_value_index,p_value,p_value_length); -} - -void file_info_impl_utils::meta_storage::remove_values(t_size p_index,const bit_array & p_mask) -{ - m_data[p_index].remove_values(p_mask); -} - -void file_info_impl_utils::meta_storage::remove_mask(const bit_array & p_mask) -{ - pfc::remove_mask_t(m_data,p_mask); -} - - -file_info_impl_utils::meta_entry::meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) -{ - m_name.set_string(p_name,p_name_len); - m_values.set_size(1); - m_values[0].set_string(p_value,p_value_len); -} - - -void file_info_impl_utils::meta_entry::remove_values(const bit_array & p_mask) -{ - pfc::remove_mask_t(m_values,p_mask); -} - -void file_info_impl_utils::meta_entry::insert_value(t_size p_value_index,const char * p_value,t_size p_value_length) -{ - pfc::string_simple temp; - temp.set_string(p_value,p_value_length); - pfc::insert_swap_t(m_values,temp,p_value_index); -} - -void file_info_impl_utils::meta_entry::modify_value(t_size p_value_index,const char * p_value,t_size p_value_length) -{ - m_values[p_value_index].set_string(p_value,p_value_length); -} - -void file_info_impl_utils::meta_storage::reorder(const t_size * p_order) -{ - pfc::reorder_t(m_data,p_order,m_data.get_size()); -} - -void file_info_impl::copy_meta(const file_info & p_source) -{ - m_meta.copy_from(p_source); -} - -void file_info_impl::copy_info(const file_info & p_source) -{ - m_info.copy_from(p_source); -} - -void file_info_impl_utils::meta_storage::copy_from(const file_info & p_info) -{ - t_size meta_index,meta_count = p_info.meta_get_count(); - m_data.set_size(meta_count); - for(meta_index=0;meta_index info_entry_array; - -} - -namespace pfc { - template<> class traits_t : public traits_t {}; -}; - - -namespace file_info_impl_utils { - class info_storage - { - public: - t_size add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); - void remove_mask(const bit_array & p_mask); - inline t_size get_count() const {return m_info.get_count();} - inline const char * get_name(t_size p_index) const {return m_info[p_index].get_name();} - inline const char * get_value(t_size p_index) const {return m_info[p_index].get_value();} - void copy_from(const file_info & p_info); - private: - info_entry_array m_info; - }; -} - - -namespace file_info_impl_utils { - typedef pfc::array_hybrid_t meta_value_array; - struct meta_entry { - meta_entry() {} - meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len); - - void remove_values(const bit_array & p_mask); - void insert_value(t_size p_value_index,const char * p_value,t_size p_value_length); - void modify_value(t_size p_value_index,const char * p_value,t_size p_value_length); - - inline const char * get_name() const {return m_name;} - inline const char * get_value(t_size p_index) const {return m_values[p_index];} - inline t_size get_value_count() const {return m_values.get_size();} - - - pfc::string_simple m_name; - meta_value_array m_values; - }; - typedef pfc::array_hybrid_t meta_entry_array; -} -namespace pfc { - template<> class traits_t : public pfc::traits_combined {}; -} - - -namespace file_info_impl_utils { - class meta_storage - { - public: - t_size add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); - void insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); - void modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); - void remove_values(t_size p_index,const bit_array & p_mask); - void remove_mask(const bit_array & p_mask); - void copy_from(const file_info & p_info); - - inline void reorder(const t_size * p_order); - - inline t_size get_count() const {return m_data.get_size();} - - inline const char * get_name(t_size p_index) const {assert(p_index < m_data.get_size()); return m_data[p_index].get_name();} - inline const char * get_value(t_size p_index,t_size p_value_index) const {assert(p_index < m_data.get_size()); return m_data[p_index].get_value(p_value_index);} - inline t_size get_value_count(t_size p_index) const {assert(p_index < m_data.get_size()); return m_data[p_index].get_value_count();} - - private: - meta_entry_array m_data; - }; -} - -//! Implements file_info. -class file_info_impl : public file_info -{ -public: - file_info_impl(const file_info_impl & p_source); - file_info_impl(const file_info & p_source); - file_info_impl(); - ~file_info_impl(); - - double get_length() const; - void set_length(double p_length); - - void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass - void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass - - t_size meta_get_count() const; - const char* meta_enum_name(t_size p_index) const; - t_size meta_enum_value_count(t_size p_index) const; - const char* meta_enum_value(t_size p_index,t_size p_value_number) const; - t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); - void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); - void meta_remove_mask(const bit_array & p_mask); - void meta_reorder(const t_size * p_order); - void meta_remove_values(t_size p_index,const bit_array & p_mask); - void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length); - - t_size info_get_count() const; - const char* info_enum_name(t_size p_index) const; - const char* info_enum_value(t_size p_index) const; - t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); - void info_remove_mask(const bit_array & p_mask); - - const file_info_impl & operator=(const file_info_impl & p_source); - - replaygain_info get_replaygain() const; - void set_replaygain(const replaygain_info & p_info); - -protected: - t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); - t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length); -private: - - - file_info_impl_utils::meta_storage m_meta; - file_info_impl_utils::info_storage m_info; - - - double m_length; - - replaygain_info m_replaygain; -}; - -#endif diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info_merge.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/file_info_merge.cpp deleted file mode 100644 index e7aba0d2c..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/file_info_merge.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "foobar2000.h" - -static t_size merge_tags_calc_rating_by_index(const file_info & p_info,t_size p_index) { - t_size n,m = p_info.meta_enum_value_count(p_index); - t_size ret = 0; - for(n=0;ninfo_get(field); - if (val) to->info_set(field,val); -} - -namespace { - struct meta_merge_entry { - meta_merge_entry() : m_rating(0) {} - t_size m_rating; - pfc::array_t m_data; - }; - - class meta_merge_map_enumerator { - public: - meta_merge_map_enumerator(file_info & p_out) : m_out(p_out) { - m_out.meta_remove_all(); - } - void operator() (const char * p_name, const meta_merge_entry & p_entry) { - if (p_entry.m_data.get_size() > 0) { - t_size index = m_out.__meta_add_unsafe(p_name,p_entry.m_data[0]); - for(t_size walk = 1; walk < p_entry.m_data.get_size(); ++walk) { - m_out.meta_add_value(index,p_entry.m_data[walk]); - } - } - } - private: - file_info & m_out; - }; -} - -static void merge_meta(file_info & p_out,const pfc::list_base_const_t & p_in) { - pfc::map_t map; - for(t_size in_walk = 0; in_walk < p_in.get_count(); in_walk++) { - const file_info & in = * p_in[in_walk]; - for(t_size meta_walk = 0, meta_count = in.meta_get_count(); meta_walk < meta_count; meta_walk++ ) { - meta_merge_entry & entry = map.find_or_add(in.meta_enum_name(meta_walk)); - t_size rating = merge_tags_calc_rating_by_index(in,meta_walk); - if (rating > entry.m_rating) { - entry.m_rating = rating; - const t_size value_count = in.meta_enum_value_count(meta_walk); - entry.m_data.set_size(value_count); - for(t_size value_walk = 0; value_walk < value_count; value_walk++ ) { - entry.m_data[value_walk] = in.meta_enum_value(meta_walk,value_walk); - } - } - } - } - - map.enumerate(meta_merge_map_enumerator(p_out)); -} - -void file_info::merge(const pfc::list_base_const_t & p_in) -{ - t_size in_count = p_in.get_count(); - if (in_count == 0) - { - meta_remove_all(); - return; - } - else if (in_count == 1) - { - const file_info * info = p_in[0]; - - copy_meta(*info); - - set_replaygain(replaygain_info::g_merge(get_replaygain(),info->get_replaygain())); - - overwrite_info(*info); - - //copy_info_single_by_name(*info,"tagtype"); - - return; - } - - merge_meta(*this,p_in); - - { - pfc::string8_fastalloc tagtype; - replaygain_info rg = get_replaygain(); - t_size in_ptr; - for(in_ptr = 0; in_ptr < in_count; in_ptr++ ) - { - const file_info * info = p_in[in_ptr]; - rg = replaygain_info::g_merge(rg, info->get_replaygain()); - t_size field_ptr, field_max = info->info_get_count(); - for(field_ptr = 0; field_ptr < field_max; field_ptr++ ) - { - const char * field_name = info->info_enum_name(field_ptr), * field_value = info->info_enum_value(field_ptr); - if (*field_value) - { - if (!stricmp_utf8(field_name,"tagtype")) - { - if (!tagtype.is_empty()) tagtype += "|"; - tagtype += field_value; - } - } - } - } - if (!tagtype.is_empty()) info_set("tagtype",tagtype); - set_replaygain(rg); - } -} - -void file_info::overwrite_info(const file_info & p_source) { - t_size count = p_source.info_get_count(); - for(t_size n=0;n & p_items) -{ - static_api_ptr_t()->on_files_deleted_sorted(p_items); - static_api_ptr_t()->on_files_deleted_sorted(p_items); - - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) - { - ptr->on_files_deleted_sorted(p_items); - } -} - -static void g_on_files_moved_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) -{ - static_api_ptr_t()->on_files_moved_sorted(p_from,p_to); - static_api_ptr_t()->on_files_deleted_sorted(p_from); - - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) - { - ptr->on_files_moved_sorted(p_from,p_to); - } -} - -static void g_on_files_copied_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) -{ - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) - { - ptr->on_files_copied_sorted(p_from,p_to); - } -} - -void file_operation_callback::g_on_files_deleted(const pfc::list_base_const_t & p_items) -{ - core_api::ensure_main_thread(); - t_size count = p_items.get_count(); - if (count > 0) - { - if (count == 1) g_on_files_deleted_sorted(p_items); - else - { - pfc::array_t order; order.set_size(count); - order_helper::g_fill(order); - p_items.sort_get_permutation_t(metadb::path_compare,order.get_ptr()); - g_on_files_deleted_sorted(pfc::list_permutation_t(p_items,order.get_ptr(),count)); - } - } -} - -void file_operation_callback::g_on_files_moved(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) -{ - core_api::ensure_main_thread(); - pfc::dynamic_assert(p_from.get_count() == p_to.get_count()); - t_size count = p_from.get_count(); - if (count > 0) - { - if (count == 1) g_on_files_moved_sorted(p_from,p_to); - else - { - pfc::array_t order; order.set_size(count); - order_helper::g_fill(order); - p_from.sort_get_permutation_t(metadb::path_compare,order.get_ptr()); - g_on_files_moved_sorted(pfc::list_permutation_t(p_from,order.get_ptr(),count),pfc::list_permutation_t(p_to,order.get_ptr(),count)); - } - } -} - -void file_operation_callback::g_on_files_copied(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) -{ - if (core_api::assert_main_thread()) - { - assert(p_from.get_count() == p_to.get_count()); - t_size count = p_from.get_count(); - if (count > 0) - { - if (count == 1) g_on_files_copied_sorted(p_from,p_to); - else - { - pfc::array_t order; order.set_size(count); - order_helper::g_fill(order); - p_from.sort_get_permutation_t(metadb::path_compare,order.get_ptr()); - g_on_files_copied_sorted(pfc::list_permutation_t(p_from,order.get_ptr(),count),pfc::list_permutation_t(p_to,order.get_ptr(),count)); - } - } - } -} -bool file_operation_callback::g_search_sorted_list(const pfc::list_base_const_t & p_list,const char * p_string,t_size & p_index) { - return pfc::binarySearch::run(p_list,0,p_list.get_count(),p_string,p_index); -} - -bool file_operation_callback::g_update_list_on_moved_ex(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to, metadb_handle_list_ref itemsAdded, metadb_handle_list_ref itemsRemoved) { - static_api_ptr_t api; - bool changed = false; - itemsAdded.remove_all(); itemsRemoved.remove_all(); - for(t_size walk = 0; walk < p_list.get_count(); ++walk) { - metadb_handle_ptr item = p_list[walk]; - t_size index; - if (g_search_sorted_list(p_from,item->get_path(),index)) { - metadb_handle_ptr newItem; - api->handle_create_replace_path_canonical(newItem,item,p_to[index]); - p_list.replace_item(walk,newItem); - changed = true; - itemsAdded.add_item(newItem); itemsRemoved.add_item(item); - } - } - return changed; -} -bool file_operation_callback::g_update_list_on_moved(metadb_handle_list_ref p_list,const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) { - static_api_ptr_t api; - bool changed = false; - for(t_size walk = 0; walk < p_list.get_count(); ++walk) { - metadb_handle_ptr item = p_list[walk]; - t_size index; - if (g_search_sorted_list(p_from,item->get_path(),index)) { - metadb_handle_ptr newItem; - api->handle_create_replace_path_canonical(newItem,item,p_to[index]); - p_list.replace_item(walk,newItem); - changed = true; - } - } - return changed; -} - - -bool file_operation_callback::g_mark_dead_entries(metadb_handle_list_cref items, bit_array_var & mask, t_pathlist deadPaths) { - bool found = false; - const t_size total = items.get_count(); - for(t_size walk = 0; walk < total; ++walk) { - t_size index; - if (g_search_sorted_list(deadPaths,items[walk]->get_path(),index)) { - mask.set(walk,true); found = true; - } else { - mask.set(walk,false); - } - } - return found; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/file_operation_callback.h b/tools/vio2sf/src/foobar/foobar2000/SDK/file_operation_callback.h deleted file mode 100644 index 7118e5050..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/file_operation_callback.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _FILE_OPERATION_CALLBACK_H_ -#define _FILE_OPERATION_CALLBACK_H_ - -//! Interface to notify component system about files being deleted or moved. Operates in app's main thread only. - -class NOVTABLE file_operation_callback : public service_base { -public: - typedef const pfc::list_base_const_t & t_pathlist; - //! p_items is a metadb::path_compare sorted list of files that have been deleted. - virtual void on_files_deleted_sorted(t_pathlist p_items) = 0; - //! p_from is a metadb::path_compare sorted list of files that have been moved, p_to is a list of corresponding target locations. - virtual void on_files_moved_sorted(t_pathlist p_from,t_pathlist p_to) = 0; - //! p_from is a metadb::path_compare sorted list of files that have been copied, p_to is a list of corresponding target locations. - virtual void on_files_copied_sorted(t_pathlist p_from,t_pathlist p_to) = 0; - - static void g_on_files_deleted(const pfc::list_base_const_t & p_items); - static void g_on_files_moved(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to); - static void g_on_files_copied(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to); - - static bool g_search_sorted_list(const pfc::list_base_const_t & p_list,const char * p_string,t_size & p_index); - static bool g_update_list_on_moved(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to); - - static bool g_update_list_on_moved_ex(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to, metadb_handle_list_ref itemsAdded, metadb_handle_list_ref itemsRemoved); - - static bool g_mark_dead_entries(metadb_handle_list_cref items, bit_array_var & mask, t_pathlist deadPaths); - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(file_operation_callback); -}; - - - -//! New in 0.9.5. -class NOVTABLE file_operation_callback_dynamic { -public: - //! p_items is a metadb::path_compare sorted list of files that have been deleted. - virtual void on_files_deleted_sorted(const pfc::list_base_const_t & p_items) = 0; - //! p_from is a metadb::path_compare sorted list of files that have been moved, p_to is a list of corresponding target locations. - virtual void on_files_moved_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) = 0; - //! p_from is a metadb::path_compare sorted list of files that have been copied, p_to is a list of corresponding target locations. - virtual void on_files_copied_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) = 0; -}; - -//! New in 0.9.5. -class NOVTABLE file_operation_callback_dynamic_manager : public service_base { -public: - virtual void register_callback(file_operation_callback_dynamic * p_callback) = 0; - virtual void unregister_callback(file_operation_callback_dynamic * p_callback) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(file_operation_callback_dynamic_manager); -}; - -//! New in 0.9.5. -class file_operation_callback_dynamic_impl_base : public file_operation_callback_dynamic { -public: - file_operation_callback_dynamic_impl_base() {static_api_ptr_t()->register_callback(this);} - ~file_operation_callback_dynamic_impl_base() {static_api_ptr_t()->unregister_callback(this);} - - void on_files_deleted_sorted(const pfc::list_base_const_t & p_items) {} - void on_files_moved_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) {} - void on_files_copied_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) {} - - PFC_CLASS_NOT_COPYABLE_EX(file_operation_callback_dynamic_impl_base); -}; - -#endif //_FILE_OPERATION_CALLBACK_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem.cpp deleted file mode 100644 index 1f3517fbd..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem.cpp +++ /dev/null @@ -1,863 +0,0 @@ -#include "foobar2000.h" - - -void unpacker::g_open(service_ptr_t & p_out,const service_ptr_t & p,abort_callback & p_abort) -{ - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - p->reopen(p_abort); - try { - ptr->open(p_out,p,p_abort); - return; - } catch(exception_io_data const &) {} - } while(e.next(ptr)); - throw exception_io_data(); -} - -void file::seek_ex(t_sfilesize p_position, file::t_seek_mode p_mode, abort_callback &p_abort) { - switch(p_mode) { - case seek_from_beginning: - seek(p_position,p_abort); - break; - case seek_from_current: - seek(p_position + get_position(p_abort),p_abort); - break; - case seek_from_eof: - seek(p_position + get_size_ex(p_abort),p_abort); - break; - default: - throw exception_io_data(); - } -} - -t_filesize file::g_transfer(stream_reader * p_src,stream_writer * p_dst,t_filesize p_bytes,abort_callback & p_abort) { - enum {BUFSIZE = 1024*1024*8}; - pfc::array_t temp; - temp.set_size((t_size)pfc::min_t(BUFSIZE,p_bytes)); - void* ptr = temp.get_ptr(); - t_filesize done = 0; - while(done(BUFSIZE,p_bytes-done); - delta = p_src->read(ptr,delta,p_abort); - if (delta<=0) break; - p_dst->write(ptr,delta,p_abort); - done += delta; - } - return done; -} - -void file::g_transfer_object(stream_reader * p_src,stream_writer * p_dst,t_filesize p_bytes,abort_callback & p_abort) { - if (g_transfer(p_src,p_dst,p_bytes,p_abort) != p_bytes) - throw exception_io_data_truncation(); -} - - -void filesystem::g_get_canonical_path(const char * path,pfc::string_base & out) -{ - TRACK_CALL_TEXT("filesystem::g_get_canonical_path"); - - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - if (ptr->get_canonical_path(path,out)) return; - } while(e.next(ptr)); - //no one wants to process this, let's copy over - out = path; -} - -void filesystem::g_get_display_path(const char * path,pfc::string_base & out) -{ - TRACK_CALL_TEXT("filesystem::g_get_display_path"); - service_ptr_t ptr; - if (!g_get_interface(ptr,path)) - { - //no one wants to process this, let's copy over - out = path; - } - else - { - if (!ptr->get_display_path(path,out)) - out = path; - } -} - -bool filesystem::g_get_interface(service_ptr_t & p_out,const char * path) -{ - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - if (ptr->is_our_path(path)) - { - p_out = ptr; - return true; - } - } while(e.next(ptr)); - return false; -} - - -void filesystem::g_open(service_ptr_t & p_out,const char * path,t_open_mode mode,abort_callback & p_abort) -{ - TRACK_CALL_TEXT("filesystem::g_open"); - service_ptr_t fs; - if (!g_get_interface(fs,path)) throw exception_io_no_handler_for_path(); - fs->open(p_out,path,mode,p_abort); -} - -void filesystem::g_open_timeout(service_ptr_t & p_out,const char * p_path,t_open_mode p_mode,double p_timeout,abort_callback & p_abort) { - pfc::lores_timer timer; - timer.start(); - for(;;) { - try { - g_open(p_out,p_path,p_mode,p_abort); - break; - } catch(exception_io_sharing_violation) { - if (timer.query() > p_timeout) throw; - p_abort.sleep(0.01); - } - } -} - -bool filesystem::g_exists(const char * p_path,abort_callback & p_abort) -{ - t_filestats stats; - bool dummy; - try { - g_get_stats(p_path,stats,dummy,p_abort); - } catch(exception_io_not_found) {return false;} - return true; -} - -bool filesystem::g_exists_writeable(const char * p_path,abort_callback & p_abort) -{ - t_filestats stats; - bool writeable; - try { - g_get_stats(p_path,stats,writeable,p_abort); - } catch(exception_io_not_found) {return false;} - return writeable; -} - -void filesystem::g_remove(const char * p_path,abort_callback & p_abort) { - service_ptr_t fs; - if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path(); - fs->remove(p_path,p_abort); -} - -void filesystem::g_remove_timeout(const char * p_path,double p_timeout,abort_callback & p_abort) { - pfc::lores_timer timer; - timer.start(); - for(;;) { - try { - g_remove(p_path,p_abort); - break; - } catch(exception_io_sharing_violation) { - if (timer.query() > p_timeout) throw; - p_abort.sleep(0.01); - } - } -} - -void filesystem::g_move_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort) { - pfc::lores_timer timer; - timer.start(); - for(;;) { - try { - g_move(p_src,p_dst,p_abort); - break; - } catch(exception_io_sharing_violation) { - if (timer.query() > p_timeout) throw; - p_abort.sleep(0.01); - } - } -} - -void filesystem::g_copy_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort) { - pfc::lores_timer timer; - timer.start(); - for(;;) { - try { - g_copy(p_src,p_dst,p_abort); - break; - } catch(exception_io_sharing_violation) { - if (timer.query() > p_timeout) throw; - p_abort.sleep(0.01); - } - } -} - -void filesystem::g_create_directory(const char * p_path,abort_callback & p_abort) -{ - service_ptr_t fs; - if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path(); - fs->create_directory(p_path,p_abort); -} - -void filesystem::g_move(const char * src,const char * dst,abort_callback & p_abort) { - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - if (ptr->is_our_path(src) && ptr->is_our_path(dst)) { - ptr->move(src,dst,p_abort); - return; - } - } while(e.next(ptr)); - throw exception_io_no_handler_for_path(); -} - -void filesystem::g_list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort) -{ - TRACK_CALL_TEXT("filesystem::g_list_directory"); - service_ptr_t ptr; - if (!g_get_interface(ptr,p_path)) throw exception_io_no_handler_for_path(); - ptr->list_directory(p_path,p_out,p_abort); -} - - -static void path_pack_string(pfc::string_base & out,const char * src) -{ - out.add_char('|'); - out << strlen(src); - out.add_char('|'); - out << src; - out.add_char('|'); -} - -static int path_unpack_string(pfc::string8 & out,const char * src) -{ - int ptr=0; - if (src[ptr++]!='|') return -1; - int len = atoi(src+ptr); - if (len<=0) return -1; - while(src[ptr]!=0 && src[ptr]!='|') ptr++; - if (src[ptr]!='|') return -1; - ptr++; - int start = ptr; - while(ptr-start & p_out,const char * p_path,abort_callback & p_abort) { - service_ptr_t fs; - if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path(); - if (fs->is_remote(p_path)) throw exception_io_object_is_remote(); - fs->open(p_out,p_path,open_mode_read,p_abort); -} - -bool filesystem::g_is_remote(const char * p_path) { - service_ptr_t fs; - if (g_get_interface(fs,p_path)) return fs->is_remote(p_path); - else throw exception_io_no_handler_for_path(); -} - -bool filesystem::g_is_recognized_and_remote(const char * p_path) { - service_ptr_t fs; - if (g_get_interface(fs,p_path)) return fs->is_remote(p_path); - else return false; -} - -bool filesystem::g_is_remote_or_unrecognized(const char * p_path) { - service_ptr_t fs; - if (g_get_interface(fs,p_path)) return fs->is_remote(p_path); - else return true; -} - -bool filesystem::g_relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) -{ - - bool rv = false; - service_ptr_t fs; - - if (g_get_interface(fs,file_path)) - rv = fs->relative_path_create(file_path,playlist_path,out); - - return rv; -} - -bool filesystem::g_relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out) -{ - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - if (ptr->relative_path_parse(relative_path,playlist_path,out)) return true; - } while(e.next(ptr)); - return false; -} - - - -bool archive_impl::get_canonical_path(const char * path,pfc::string_base & out) -{ - if (is_our_path(path)) - { - pfc::string8 archive,file,archive_canonical; - if (g_parse_unpack_path(path,archive,file)) - { - g_get_canonical_path(archive,archive_canonical); - make_unpack_path(out,archive_canonical,file); - - return true; - } - else return false; - } - else return false; -} - -bool archive_impl::is_our_path(const char * path) -{ - if (strncmp(path,"unpack://",9)) return false; - const char * type = get_archive_type(); - path += 9; - while(*type) - { - if (*type!=*path) return false; - type++; - path++; - } - if (*path!='|') return false; - return true; -} - -bool archive_impl::get_display_path(const char * path,pfc::string_base & out) -{ - pfc::string8 archive,file; - if (g_parse_unpack_path(path,archive,file)) - { - g_get_display_path(archive,out); - out.add_string("|"); - out.add_string(file); - return true; - } - else return false; -} - -void archive_impl::open(service_ptr_t & p_out,const char * path,t_open_mode mode, abort_callback & p_abort) -{ - if (mode != open_mode_read) throw exception_io_denied(); - pfc::string8 archive,file; - if (!g_parse_unpack_path(path,archive,file)) throw exception_io_not_found(); - open_archive(p_out,archive,file,p_abort); -} - - -void archive_impl::remove(const char * path,abort_callback & p_abort) { - throw exception_io_denied(); -} - -void archive_impl::move(const char * src,const char * dst,abort_callback & p_abort) { - throw exception_io_denied(); -} - -bool archive_impl::is_remote(const char * src) { - pfc::string8 archive,file; - if (g_parse_unpack_path(src,archive,file)) return g_is_remote(archive); - else throw exception_io_not_found(); -} - -bool archive_impl::relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) { - pfc::string8 archive,file; - if (g_parse_unpack_path(file_path,archive,file)) - { - pfc::string8 archive_rel; - if (g_relative_path_create(archive,playlist_path,archive_rel)) - { - pfc::string8 out_path; - make_unpack_path(out_path,archive_rel,file); - out.set_string(out_path); - return true; - } - } - return false; -} - -bool archive_impl::relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out) -{ - if (!is_our_path(relative_path)) return false; - pfc::string8 archive_rel,file; - if (g_parse_unpack_path(relative_path,archive_rel,file)) - { - pfc::string8 archive; - if (g_relative_path_parse(archive_rel,playlist_path,archive)) - { - pfc::string8 out_path; - make_unpack_path(out_path,archive,file); - out.set_string(out_path); - return true; - } - } - return false; -} - -bool archive_impl::g_parse_unpack_path(const char * path,pfc::string8 & archive,pfc::string8 & file) -{ - path = strchr(path,'|'); - if (!path) return false; - int delta = path_unpack_string(archive,path); - if (delta<0) return false; - path += delta; - file = path; - return true; -} - -void archive_impl::g_make_unpack_path(pfc::string_base & path,const char * archive,const char * file,const char * name) -{ - path = "unpack://"; - path += name; - path_pack_string(path,archive); - path += file; -} - -void archive_impl::make_unpack_path(pfc::string_base & path,const char * archive,const char * file) {g_make_unpack_path(path,archive,file,get_archive_type());} - - -FILE * filesystem::streamio_open(const char * path,const char * flags) -{ - FILE * ret = 0; - pfc::string8 temp; - g_get_canonical_path(path,temp); - if (!strncmp(temp,"file://",7)) - { - ret = _wfopen(pfc::stringcvt::string_wide_from_utf8(path+7),pfc::stringcvt::string_wide_from_utf8(flags)); - } - return ret; -} - - -namespace { - - class directory_callback_isempty : public directory_callback - { - bool m_isempty; - public: - directory_callback_isempty() : m_isempty(true) {} - bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) - { - m_isempty = false; - return false; - } - bool isempty() {return m_isempty;} - }; - - class directory_callback_dummy : public directory_callback - { - public: - bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) {return false;} - }; - -} - -bool filesystem::g_is_empty_directory(const char * path,abort_callback & p_abort) -{ - directory_callback_isempty callback; - try { - g_list_directory(path,callback,p_abort); - } catch(exception_io const &) {return false;} - return callback.isempty(); -} - -bool filesystem::g_is_valid_directory(const char * path,abort_callback & p_abort) { - try { - g_list_directory(path,directory_callback_dummy(),p_abort); - return true; - } catch(exception_io const &) {return false;} -} - -bool directory_callback_impl::on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) { - p_abort.check_e(); - if (is_subdirectory) { - if (m_recur) { - try { - owner->list_directory(url,*this,p_abort); - } catch(exception_io const &) {} - } - } else { - m_data.add_item(pfc::rcnew_t(url,p_stats)); - } - return true; -} - -namespace { - class directory_callback_impl_copy : public directory_callback - { - public: - directory_callback_impl_copy(const char * p_target) - { - m_target = p_target; - m_target.fix_dir_separator('\\'); - } - - bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) { - const char * fn = url + pfc::scan_filename(url); - t_size truncat = m_target.length(); - m_target += fn; - if (is_subdirectory) { - try { - filesystem::g_create_directory(m_target,p_abort); - } catch(exception_io_already_exists) {} - m_target += "\\"; - owner->list_directory(url,*this,p_abort); - } else { - filesystem::g_copy(url,m_target,p_abort); - } - m_target.truncate(truncat); - return true; - } - private: - pfc::string8_fastalloc m_target; - }; -} - -void filesystem::g_copy_directory(const char * src,const char * dst,abort_callback & p_abort) { - //UNTESTED - filesystem::g_list_directory(src,directory_callback_impl_copy(dst),p_abort); -} - -void filesystem::g_copy(const char * src,const char * dst,abort_callback & p_abort) { - service_ptr_t r_src,r_dst; - t_filesize size; - - g_open(r_src,src,open_mode_read,p_abort); - size = r_src->get_size_ex(p_abort); - g_open(r_dst,dst,open_mode_write_new,p_abort); - - if (size > 0) { - try { - file::g_transfer_object(r_src,r_dst,size,p_abort); - } catch(...) { - r_dst.release(); - try {g_remove(dst,abort_callback_impl());} catch(...) {} - throw; - } - } -} - -void stream_reader::read_object(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - if (read(p_buffer,p_bytes,p_abort) != p_bytes) throw exception_io_data_truncation(); -} - -t_filestats file::get_stats(abort_callback & p_abort) -{ - t_filestats temp; - temp.m_size = get_size(p_abort); - temp.m_timestamp = get_timestamp(p_abort); - return temp; -} - -t_filesize stream_reader::skip(t_filesize p_bytes,abort_callback & p_abort) -{ - t_uint8 temp[256]; - t_filesize todo = p_bytes, done = 0; - while(todo > 0) { - t_size delta,deltadone; - delta = sizeof(temp); - if (delta > todo) delta = (t_size) todo; - deltadone = read(temp,delta,p_abort); - done += deltadone; - todo -= deltadone; - if (deltadone < delta) break; - } - return done; -} - -void stream_reader::skip_object(t_filesize p_bytes,abort_callback & p_abort) { - if (skip(p_bytes,p_abort) != p_bytes) throw exception_io_data_truncation(); -} - -void filesystem::g_open_write_new(service_ptr_t & p_out,const char * p_path,abort_callback & p_abort) { - g_open(p_out,p_path,open_mode_write_new,p_abort); -} -void file::g_transfer_file(const service_ptr_t & p_from,const service_ptr_t & p_to,abort_callback & p_abort) { - t_filesize length = p_from->get_size_ex(p_abort); - p_from->seek(0,p_abort); - p_to->seek(0,p_abort); - p_to->set_eof(p_abort); - if (length > 0) { - g_transfer_object(p_from,p_to,length,p_abort); - } -} - -void filesystem::g_open_temp(service_ptr_t & p_out,abort_callback & p_abort) { - g_open(p_out,"tempfile://",open_mode_write_new,p_abort); -} - -void filesystem::g_open_tempmem(service_ptr_t & p_out,abort_callback & p_abort) { - g_open(p_out,"tempmem://",open_mode_write_new,p_abort); -} - -void archive_impl::list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort) { - throw exception_io_not_found(); -} - -void archive_impl::create_directory(const char * path,abort_callback &) { - throw exception_io_denied(); -} - -void filesystem::g_get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) { - TRACK_CALL_TEXT("filesystem::g_get_stats"); - service_ptr_t fs; - if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path(); - return fs->get_stats(p_path,p_stats,p_is_writeable,p_abort); -} - -void archive_impl::get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) { - pfc::string8 archive,file; - if (g_parse_unpack_path(p_path,archive,file)) { - if (g_is_remote(archive)) throw exception_io_object_is_remote(); - p_is_writeable = false; - p_stats = get_stats_in_archive(archive,file,p_abort); - } - else throw exception_io_not_found(); -} - - -bool file::is_eof(abort_callback & p_abort) { - t_filesize position,size; - position = get_position(p_abort); - size = get_size(p_abort); - if (size == filesize_invalid) return false; - return position >= size; -} - - -t_filetimestamp foobar2000_io::filetimestamp_from_system_timer() -{ - t_filetimestamp ret; - GetSystemTimeAsFileTime((FILETIME*)&ret); - return ret; -} - -void stream_reader::read_string_ex(pfc::string_base & p_out,t_size p_bytes,abort_callback & p_abort) { - char * ptr = p_out.lock_buffer(p_bytes); - try { - read_object(ptr,p_bytes,p_abort); - } catch(...) { - p_out.unlock_buffer(); - throw; - } - p_out.unlock_buffer(); -} -void stream_reader::read_string(pfc::string_base & p_out,abort_callback & p_abort) -{ - t_uint32 length; - read_lendian_t(length,p_abort); - read_string_ex(p_out,length,p_abort); -} - -void stream_reader::read_string_raw(pfc::string_base & p_out,abort_callback & p_abort) { - enum {delta = 256}; - char buffer[delta]; - p_out.reset(); - for(;;) { - t_size delta_done; - delta_done = read(buffer,delta,p_abort); - p_out.add_string(buffer,delta_done); - if (delta_done < delta) break; - } -} -void stream_writer::write_string(const char * p_string,t_size p_len,abort_callback & p_abort) { - t_uint32 len = pfc::downcast_guarded(pfc::strlen_max(p_string,p_len)); - write_lendian_t(len,p_abort); - write_object(p_string,len,p_abort); -} - -void stream_writer::write_string(const char * p_string,abort_callback & p_abort) { - write_string(p_string,infinite,p_abort); -} - -void stream_writer::write_string_raw(const char * p_string,abort_callback & p_abort) { - write_object(p_string,strlen(p_string),p_abort); -} - -void file::truncate(t_uint64 p_position,abort_callback & p_abort) { - if (p_position < get_size(p_abort)) resize(p_position,p_abort); -} - - -#ifdef _WIN32 -namespace { - //rare/weird win32 errors that didn't make it to the main API - PFC_DECLARE_EXCEPTION(exception_io_device_not_ready, exception_io,"Device not ready"); - PFC_DECLARE_EXCEPTION(exception_io_invalid_drive, exception_io_not_found,"Drive not found"); - PFC_DECLARE_EXCEPTION(exception_io_win32, exception_io,"Generic win32 I/O error"); - PFC_DECLARE_EXCEPTION(exception_io_buffer_overflow, exception_io,"The file name is too long"); - PFC_DECLARE_EXCEPTION(exception_io_invalid_path_syntax, exception_io,"Invalid path syntax"); - - class exception_io_win32_ex : public exception_io_win32 { - public: - exception_io_win32_ex(DWORD p_code) : m_msg(pfc::string_formatter() << "I/O error (win32 #" << (t_uint32)p_code << ")") {} - exception_io_win32_ex(const exception_io_win32_ex & p_other) {*this = p_other;} - const char * what() const throw() {return m_msg;} - private: - pfc::string8 m_msg; - }; -} -void foobar2000_io::exception_io_from_win32(DWORD p_code) { - switch(p_code) { - case ERROR_ALREADY_EXISTS: - case ERROR_FILE_EXISTS: - throw exception_io_already_exists(); - case ERROR_NETWORK_ACCESS_DENIED: - case ERROR_ACCESS_DENIED: - throw exception_io_denied(); - case ERROR_WRITE_PROTECT: - throw exception_io_write_protected(); - case ERROR_BUSY: - case ERROR_PATH_BUSY: - case ERROR_SHARING_VIOLATION: - case ERROR_LOCK_VIOLATION: - throw exception_io_sharing_violation(); - case ERROR_HANDLE_DISK_FULL: - case ERROR_DISK_FULL: - throw exception_io_device_full(); - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - throw exception_io_not_found(); - case ERROR_BROKEN_PIPE: - case ERROR_NO_DATA: - throw exception_io_no_data(); - case ERROR_NETWORK_UNREACHABLE: - case ERROR_NETNAME_DELETED: - throw exception_io_network_not_reachable(); - case ERROR_NOT_READY: - throw exception_io_device_not_ready(); - case ERROR_INVALID_DRIVE: - throw exception_io_invalid_drive(); - case ERROR_CRC: - case ERROR_FILE_CORRUPT: - case ERROR_DISK_CORRUPT: - throw exception_io_file_corrupted(); - case ERROR_BUFFER_OVERFLOW: - throw exception_io_buffer_overflow(); - case ERROR_DISK_CHANGE: - throw exception_io_disk_change(); - case ERROR_DIR_NOT_EMPTY: - throw exception_io_directory_not_empty(); - case ERROR_INVALID_NAME: - throw exception_io_invalid_path_syntax(); - default: - throw exception_io_win32_ex(p_code); - } -} -#endif - -t_filesize file::get_size_ex(abort_callback & p_abort) { - t_filesize temp = get_size(p_abort); - if (temp == filesize_invalid) throw exception_io_no_length(); - return temp; -} - -void file::ensure_local() { - if (is_remote()) throw exception_io_object_is_remote(); -} - -void file::ensure_seekable() { - if (!can_seek()) throw exception_io_object_not_seekable(); -} - -bool filesystem::g_is_recognized_path(const char * p_path) { - return g_get_interface(service_ptr_t(),p_path); -} - -t_filesize file::get_remaining(abort_callback & p_abort) { - t_filesize length = get_size_ex(p_abort); - t_filesize position = get_position(p_abort); - pfc::dynamic_assert(position <= length); - return length - position; -} - - -t_filesize file::g_transfer(service_ptr_t p_src,service_ptr_t p_dst,t_filesize p_bytes,abort_callback & p_abort) { - return g_transfer(pfc::safe_cast(p_src.get_ptr()),pfc::safe_cast(p_dst.get_ptr()),p_bytes,p_abort); -} - -void file::g_transfer_object(service_ptr_t p_src,service_ptr_t p_dst,t_filesize p_bytes,abort_callback & p_abort) { - if (p_bytes > 1024) /* don't bother on small objects */ - { - t_filesize oldsize = p_dst->get_size(p_abort); - if (oldsize != filesize_invalid) { - t_filesize newpos = p_dst->get_position(p_abort) + p_bytes; - if (newpos > oldsize) p_dst->resize(newpos ,p_abort); - } - } - g_transfer_object(pfc::safe_cast(p_src.get_ptr()),pfc::safe_cast(p_dst.get_ptr()),p_bytes,p_abort); -} - - -void foobar2000_io::generate_temp_location_for_file(pfc::string_base & p_out, const char * p_origpath,const char * p_extension,const char * p_magic) { - hasher_md5_result hash; - { - static_api_ptr_t hasher; - hasher_md5_state state; - hasher->initialize(state); - hasher->process(state,p_origpath,strlen(p_origpath)); - hasher->process(state,p_extension,strlen(p_extension)); - hasher->process(state,p_magic,strlen(p_magic)); - hash = hasher->get_result(state); - } - - p_out = p_origpath; - p_out.truncate(p_out.scan_filename()); - p_out += "temp-"; - p_out += pfc::format_hexdump(hash.m_data,sizeof(hash.m_data),""); - p_out += "."; - p_out += p_extension; -} - - -t_filesize file::skip(t_filesize p_bytes,abort_callback & p_abort) { - if (p_bytes > 1024 && can_seek()) { - const t_filesize size = get_size(p_abort); - if (size != filesize_invalid) { - const t_filesize position = get_position(p_abort); - const t_filesize toskip = pfc::min_t( p_bytes, size - position ); - seek(position + toskip,p_abort); - return toskip; - } - } - return stream_reader::skip(p_bytes,p_abort); -} - -bool foobar2000_io::_extract_native_path_ptr(const char * & p_fspath) { - static const char header[] = "file://"; static const t_size headerLen = 7; - if (strncmp(p_fspath,header,headerLen) != 0) return false; - p_fspath += headerLen; - return true; -} -bool foobar2000_io::extract_native_path(const char * p_fspath,pfc::string_base & p_native) { - if (!_extract_native_path_ptr(p_fspath)) return false; - p_native = p_fspath; - return true; -} - -bool foobar2000_io::extract_native_path_ex(const char * p_fspath, pfc::string_base & p_native) { - if (!_extract_native_path_ptr(p_fspath)) return false; - if (p_fspath[0] != '\\' || p_fspath[0] != '\\') { - p_native = "\\\\?\\"; - p_native += p_fspath; - } else { - p_native = p_fspath; - } - return true; -} - -pfc::string stream_reader::read_string(abort_callback & p_abort) { - t_uint32 len; - read_lendian_t(len,p_abort); - return read_string_ex(len,p_abort); -} -pfc::string stream_reader::read_string_ex(t_size p_len,abort_callback & p_abort) { - pfc::rcptr_t temp; temp.new_t(); - read_object(temp->lock_buffer(p_len),p_len,p_abort); - temp->unlock_buffer(); - return pfc::string::t_data(temp); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem.h b/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem.h deleted file mode 100644 index 7404e0d98..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem.h +++ /dev/null @@ -1,598 +0,0 @@ -class file_info; - -//! Contains various I/O related structures and interfaces. - -namespace foobar2000_io -{ - //! Type used for file size related variables. - typedef t_uint64 t_filesize; - //! Type used for file size related variables when signed value is needed. - typedef t_int64 t_sfilesize; - //! Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601; 0 for invalid/unknown time. - typedef t_uint64 t_filetimestamp; - //! Invalid/unknown file timestamp constant. Also see: t_filetimestamp. - const t_filetimestamp filetimestamp_invalid = 0; - //! Invalid/unknown file size constant. Also see: t_filesize. - static const t_filesize filesize_invalid = (t_filesize)(~0); - - static const t_filetimestamp filetimestamp_1second_increment = 10000000; - - //! Generic I/O error. Root class for I/O failure exception. See relevant default message for description of each derived exception class. - PFC_DECLARE_EXCEPTION(exception_io, pfc::exception,"I/O error"); - //! Object not found. - PFC_DECLARE_EXCEPTION(exception_io_not_found, exception_io,"Object not found"); - //! Access denied. - PFC_DECLARE_EXCEPTION(exception_io_denied, exception_io,"Access denied"); - //! Unsupported format or corrupted file (unexpected data encountered). - PFC_DECLARE_EXCEPTION(exception_io_data, exception_io,"Unsupported format or corrupted file"); - //! Unsupported format or corrupted file (truncation encountered). - PFC_DECLARE_EXCEPTION(exception_io_data_truncation, exception_io_data,"Unsupported format or corrupted file"); - //! Unsupported format (a subclass of "unsupported format or corrupted file" exception). - PFC_DECLARE_EXCEPTION(exception_io_unsupported_format, exception_io_data,"Unsupported file format"); - //! Object is remote, while specific operation is supported only for local objects. - PFC_DECLARE_EXCEPTION(exception_io_object_is_remote, exception_io,"This operation is not supported on remote objects"); - //! Sharing violation. - PFC_DECLARE_EXCEPTION(exception_io_sharing_violation, exception_io,"Sharing violation"); - //! Device full. - PFC_DECLARE_EXCEPTION(exception_io_device_full, exception_io,"Device full"); - //! Attempt to seek outside valid range. - PFC_DECLARE_EXCEPTION(exception_io_seek_out_of_range, exception_io,"Seek offset out of range"); - //! This operation requires a seekable object. - PFC_DECLARE_EXCEPTION(exception_io_object_not_seekable, exception_io,"Object is not seekable"); - //! This operation requires an object with known length. - PFC_DECLARE_EXCEPTION(exception_io_no_length, exception_io,"Length of object is unknown"); - //! Invalid path. - PFC_DECLARE_EXCEPTION(exception_io_no_handler_for_path, exception_io,"Invalid path"); - //! Object already exists. - PFC_DECLARE_EXCEPTION(exception_io_already_exists, exception_io,"Object already exists"); - //! Pipe error. - PFC_DECLARE_EXCEPTION(exception_io_no_data, exception_io,"The process receiving or sending data has terminated"); - //! Network not reachable. - PFC_DECLARE_EXCEPTION(exception_io_network_not_reachable,exception_io,"Network not reachable"); - //! Media is write protected. - PFC_DECLARE_EXCEPTION(exception_io_write_protected, exception_io_denied,"The media is write protected"); - //! File is corrupted. This indicates filesystem call failure, not actual invalid data being read by the app. - PFC_DECLARE_EXCEPTION(exception_io_file_corrupted, exception_io,"The file is corrupted"); - //! The disc required for requested operation is not available. - PFC_DECLARE_EXCEPTION(exception_io_disk_change, exception_io,"Disc not available"); - //! The directory is not empty. - PFC_DECLARE_EXCEPTION(exception_io_directory_not_empty, exception_io,"Directory not empty"); - - //! Stores file stats (size and timestamp). - struct t_filestats { - //! Size of the file. - t_filesize m_size; - //! Time of last file modification. - t_filetimestamp m_timestamp; - - inline bool operator==(const t_filestats & param) const {return m_size == param.m_size && m_timestamp == param.m_timestamp;} - inline bool operator!=(const t_filestats & param) const {return m_size != param.m_size || m_timestamp != param.m_timestamp;} - }; - - //! Invalid/unknown file stats constant. See: t_filestats. - static const t_filestats filestats_invalid = {filesize_invalid,filetimestamp_invalid}; - -#ifdef _WIN32 - void exception_io_from_win32(DWORD p_code); -#define WIN32_IO_OP(X) {SetLastError(NO_ERROR); if (!(X)) exception_io_from_win32(GetLastError());} -#endif - - //! Generic interface to read data from a nonseekable stream. Also see: stream_writer, file. \n - //! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled. - class NOVTABLE stream_reader { - public: - //! Attempts to reads specified number of bytes from the stream. - //! @param p_buffer Receives data being read. Must have at least p_bytes bytes of space allocated. - //! @param p_bytes Number of bytes to read. - //! @param p_abort abort_callback object signaling user aborting the operation. - //! @returns Number of bytes actually read. May be less than requested when EOF was reached. - virtual t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) = 0; - //! Reads specified number of bytes from the stream. If requested amount of bytes can't be read (e.g. EOF), throws exception_io_data_truncation. - //! @param p_buffer Receives data being read. Must have at least p_bytes bytes of space allocated. - //! @param p_bytes Number of bytes to read. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void read_object(void * p_buffer,t_size p_bytes,abort_callback & p_abort); - //! Attempts to skip specified number of bytes in the stream. - //! @param p_bytes Number of bytes to skip. - //! @param p_abort abort_callback object signaling user aborting the operation. - //! @returns Number of bytes actually skipped, May be less than requested when EOF was reached. - virtual t_filesize skip(t_filesize p_bytes,abort_callback & p_abort); - //! Skips specified number of bytes in the stream. If requested amount of bytes can't be skipped (e.g. EOF), throws exception_io_data_truncation. - //! @param p_bytes Number of bytes to skip. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void skip_object(t_filesize p_bytes,abort_callback & p_abort); - - //! Helper template built around read_object. Reads single raw object from the stream. - //! @param p_object Receives object read from the stream on success. - //! @param p_abort abort_callback object signaling user aborting the operation. - template inline void read_object_t(T& p_object,abort_callback & p_abort) {pfc::assert_raw_type(); read_object(&p_object,sizeof(p_object),p_abort);} - //! Helper template built around read_object. Reads single raw object from the stream; corrects byte order assuming stream uses little endian order. - //! @param p_object Receives object read from the stream on success. - //! @param p_abort abort_callback object signaling user aborting the operation. - template inline void read_lendian_t(T& p_object,abort_callback & p_abort) {read_object_t(p_object,p_abort); byte_order::order_le_to_native_t(p_object);} - //! Helper template built around read_object. Reads single raw object from the stream; corrects byte order assuming stream uses big endian order. - //! @param p_object Receives object read from the stream on success. - //! @param p_abort abort_callback object signaling user aborting the operation. - template inline void read_bendian_t(T& p_object,abort_callback & p_abort) {read_object_t(p_object,p_abort); byte_order::order_be_to_native_t(p_object);} - - //! Helper function; reads a string (with a 32-bit header indicating length in bytes followed by UTF-8 encoded data without a null terminator). - void read_string(pfc::string_base & p_out,abort_callback & p_abort); - //! Helper function; alternate way of storing strings; assumes string takes space up to end of stream. - void read_string_raw(pfc::string_base & p_out,abort_callback & p_abort); - //! Helper function; reads a string (with a 32-bit header indicating length in bytes followed by UTF-8 encoded data without a null terminator). - pfc::string read_string(abort_callback & p_abort); - - //! Helper function; reads a string of specified length from the stream. - void read_string_ex(pfc::string_base & p_out,t_size p_bytes,abort_callback & p_abort); - //! Helper function; reads a string of specified length from the stream. - pfc::string read_string_ex(t_size p_len,abort_callback & p_abort); - protected: - stream_reader() {} - ~stream_reader() {} - }; - - - //! Generic interface to write data to a nonseekable stream. Also see: stream_reader, file. \n - //! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled. - class NOVTABLE stream_writer { - public: - //! Writes specified number of bytes from specified buffer to the stream. - //! @param p_buffer Buffer with data to write. Must contain at least p_bytes bytes. - //! @param p_bytes Number of bytes to write. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) = 0; - - //! Helper. Same as write(), provided for consistency. - inline void write_object(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {write(p_buffer,p_bytes,p_abort);} - - //! Helper template. Writes single raw object to the stream. - //! @param p_object Object to write. - //! @param p_abort abort_callback object signaling user aborting the operation. - template inline void write_object_t(const T & p_object, abort_callback & p_abort) {pfc::assert_raw_type(); write_object(&p_object,sizeof(p_object),p_abort);} - //! Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses little endian order. - //! @param p_object Object to write. - //! @param p_abort abort_callback object signaling user aborting the operation. - template inline void write_lendian_t(const T & p_object, abort_callback & p_abort) {T temp = p_object; byte_order::order_native_to_le_t(temp); write_object_t(temp,p_abort);} - //! Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses big endian order. - //! @param p_object Object to write. - //! @param p_abort abort_callback object signaling user aborting the operation. - template inline void write_bendian_t(const T & p_object, abort_callback & p_abort) {T temp = p_object; byte_order::order_native_to_be_t(temp); write_object_t(temp,p_abort);} - - //! Helper function; writes string (with 32-bit header indicating length in bytes followed by UTF-8 encoded data without null terminator). - void write_string(const char * p_string,abort_callback & p_abort); - void write_string(const char * p_string,t_size p_len,abort_callback & p_abort); - - template - void write_string(const T& val,abort_callback & p_abort) {write_string(pfc::stringToPtr(val),p_abort);} - - //! Helper function; writes raw string to the stream, with no length info or null terminators. - void write_string_raw(const char * p_string,abort_callback & p_abort); - protected: - stream_writer() {} - ~stream_writer() {} - }; - - //! A class providing abstraction for an open file object, with reading/writing/seeking methods. See also: stream_reader, stream_writer (which it inherits read/write methods from). \n - //! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled. - class NOVTABLE file : public service_base, public stream_reader, public stream_writer { - public: - - //! Seeking mode constants. Note: these are purposedly defined to same values as standard C SEEK_* constants - enum t_seek_mode { - //! Seek relative to beginning of file (same as seeking to absolute offset). - seek_from_beginning = 0, - //! Seek relative to current position. - seek_from_current = 1, - //! Seek relative to end of file. - seek_from_eof = 2, - }; - - //! Retrieves size of the file. - //! @param p_abort abort_callback object signaling user aborting the operation. - //! @returns File size on success; filesize_invalid if unknown (nonseekable stream etc). - virtual t_filesize get_size(abort_callback & p_abort) = 0; - - - //! Retrieves read/write cursor position in the file. In case of non-seekable stream, this should return number of bytes read so far since open/reopen call. - //! @param p_abort abort_callback object signaling user aborting the operation. - //! @returns Read/write cursor position - virtual t_filesize get_position(abort_callback & p_abort) = 0; - - //! Resizes file to the specified size in bytes. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void resize(t_filesize p_size,abort_callback & p_abort) = 0; - - //! Sets read/write cursor position to the specified offset. - //! @param p_position position to seek to. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void seek(t_filesize p_position,abort_callback & p_abort) = 0; - - - //! Sets read/write cursor position to the specified offset; extended form allowing seeking relative to current position or to end of file. - //! @param p_position Position to seek to; interpretation of this value depends on p_mode parameter. - //! @param p_mode Seeking mode; see t_seek_mode enum values for further description. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void seek_ex(t_sfilesize p_position,t_seek_mode p_mode,abort_callback & p_abort); - - //! Returns whether the file is seekable or not. If can_seek() returns false, all seek() or seek_ex() calls will fail; reopen() is still usable on nonseekable streams. - virtual bool can_seek() = 0; - - //! Retrieves mime type of the file. - //! @param p_out Receives content type string on success. - virtual bool get_content_type(pfc::string_base & p_out) = 0; - - //! Hint, returns whether the file is already fully buffered into memory. - virtual bool is_in_memory() {return false;} - - //! Optional, called by owner thread before sleeping. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void on_idle(abort_callback & p_abort) {} - - //! Retrieves last modification time of the file. - //! @param p_abort abort_callback object signaling user aborting the operation. - //! @returns Last modification time o fthe file; filetimestamp_invalid if N/A. - virtual t_filetimestamp get_timestamp(abort_callback & p_abort) {return filetimestamp_invalid;} - - //! Resets non-seekable stream, or seeks to zero on seekable file. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void reopen(abort_callback & p_abort) = 0; - - //! Indicates whether the file is a remote resource and non-sequential access may be slowed down by lag. This is typically returns to true on non-seekable sources but may also return true on seekable sources indicating that seeking is supported but will be relatively slow. - virtual bool is_remote() = 0; - - //! Retrieves file stats structure. Usese get_size() and get_timestamp(). - t_filestats get_stats(abort_callback & p_abort); - - //! Returns whether read/write cursor position is at the end of file. - bool is_eof(abort_callback & p_abort); - - //! Truncates file to specified size (while preserving read/write cursor position if possible); uses set_eof(). - void truncate(t_filesize p_position,abort_callback & p_abort); - - //! Truncates the file at current read/write cursor position. - void set_eof(abort_callback & p_abort) {resize(get_position(p_abort),p_abort);} - - - //! Helper; retrieves size of the file. If size is not available (get_size() returns filesize_invalid), throws exception_io_no_length. - t_filesize get_size_ex(abort_callback & p_abort); - - //! Helper; retrieves amount of bytes between read/write cursor position and end of file. Fails when length can't be determined. - t_filesize get_remaining(abort_callback & p_abort); - - //! Helper; throws exception_io_object_not_seekable if file is not seekable. - void ensure_seekable(); - - //! Helper; throws exception_io_object_is_remote if the file is remote. - void ensure_local(); - - //! Helper; transfers specified number of bytes between streams. - //! @returns number of bytes actually transferred. May be less than requested if e.g. EOF is reached. - static t_filesize g_transfer(stream_reader * src,stream_writer * dst,t_filesize bytes,abort_callback & p_abort); - //! Helper; transfers specified number of bytes between streams. Throws exception if requested number of bytes could not be read (EOF). - static void g_transfer_object(stream_reader * src,stream_writer * dst,t_filesize bytes,abort_callback & p_abort); - //! Helper; transfers entire file content from one file to another, erasing previous content. - static void g_transfer_file(const service_ptr_t & p_from,const service_ptr_t & p_to,abort_callback & p_abort); - - //! Helper; improved performance over g_transfer on streams (avoids disk fragmentation when transferring large blocks). - static t_filesize g_transfer(service_ptr_t p_src,service_ptr_t p_dst,t_filesize p_bytes,abort_callback & p_abort); - //! Helper; improved performance over g_transfer_file on streams (avoids disk fragmentation when transferring large blocks). - static void g_transfer_object(service_ptr_t p_src,service_ptr_t p_dst,t_filesize p_bytes,abort_callback & p_abort); - - - t_filesize skip(t_filesize p_bytes,abort_callback & p_abort); - - FB2K_MAKE_SERVICE_INTERFACE(file,service_base); - }; - - typedef service_ptr_t file_ptr; - - //! Special hack for shoutcast metadata nonsense handling. Documentme. - class file_dynamicinfo : public file { - public: - //! Retrieves "static" info that doesn't change in the middle of stream, such as station names etc. Returns true on success; false when static info is not available. - virtual bool get_static_info(class file_info & p_out) = 0; - //! Returns whether dynamic info is available on this stream or not. - virtual bool is_dynamic_info_enabled()=0; - //! Retrieves dynamic stream info (e.g. online stream track titles). Returns true on success, false when info has not changed since last call. - virtual bool get_dynamic_info(class file_info & p_out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(file_dynamicinfo,file); - }; - - //! Implementation helper - contains dummy implementations of methods that modify the file - template class file_readonly_t : public t_base { - public: - void resize(t_filesize p_size,abort_callback & p_abort) {throw exception_io_denied();} - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {throw exception_io_denied();} - }; - typedef file_readonly_t file_readonly; - - class filesystem; - - class NOVTABLE directory_callback { - public: - //! @returns true to continue enumeration, false to abort. - virtual bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats)=0; - }; - - - //! Entrypoint service for all filesystem operations.\n - //! Implementation: standard implementations for local filesystem etc are provided by core.\n - //! Instantiation: use static helper functions rather than calling filesystem interface methods directly, e.g. filesystem::g_open() to open a file. - class NOVTABLE filesystem : public service_base { - public: - //! Enumeration specifying how to open a file. See: filesystem::open(), filesystem::g_open(). - enum t_open_mode { - //! Opens an existing file for reading; if the file does not exist, the operation will fail. - open_mode_read, - //! Opens an existing file for writing; if the file does not exist, the operation will fail. - open_mode_write_existing, - //! Opens a new file for writing; if the file exists, its contents will be wiped. - open_mode_write_new, - }; - - virtual bool get_canonical_path(const char * p_path,pfc::string_base & p_out)=0; - virtual bool is_our_path(const char * p_path)=0; - virtual bool get_display_path(const char * p_path,pfc::string_base & p_out)=0; - - virtual void open(service_ptr_t & p_out,const char * p_path, t_open_mode p_mode,abort_callback & p_abort)=0; - virtual void remove(const char * p_path,abort_callback & p_abort)=0; - virtual void move(const char * p_src,const char * p_dst,abort_callback & p_abort)=0; - //! Queries whether a file at specified path belonging to this filesystem is a remove object or not. - virtual bool is_remote(const char * p_src) = 0; - - //! Retrieves stats of a file at specified path. - virtual void get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) = 0; - - virtual bool relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) {return false;} - virtual bool relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out) {return false;} - - //! Creates a directory. - virtual void create_directory(const char * p_path,abort_callback & p_abort) = 0; - - virtual void list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort)=0; - - //! Hint; returns whether this filesystem supports mime types. \n - //! When this returns false, all file::get_content_type() calls on files opened thru this filesystem implementation will return false; otherwise, file::get_content_type() calls may return true depending on the file. - virtual bool supports_content_types() = 0; - - static void g_get_canonical_path(const char * path,pfc::string_base & out); - static void g_get_display_path(const char * path,pfc::string_base & out); - - static bool g_get_interface(service_ptr_t & p_out,const char * path);//path is AFTER get_canonical_path - static bool g_is_remote(const char * p_path);//path is AFTER get_canonical_path - static bool g_is_recognized_and_remote(const char * p_path);//path is AFTER get_canonical_path - static bool g_is_remote_safe(const char * p_path) {return g_is_recognized_and_remote(p_path);} - static bool g_is_remote_or_unrecognized(const char * p_path); - static bool g_is_recognized_path(const char * p_path); - - //! Opens file at specified path, with specified access privileges. - static void g_open(service_ptr_t & p_out,const char * p_path,t_open_mode p_mode,abort_callback & p_abort); - //! Attempts to open file at specified path; if the operation fails with sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time. - static void g_open_timeout(service_ptr_t & p_out,const char * p_path,t_open_mode p_mode,double p_timeout,abort_callback & p_abort); - static void g_open_write_new(service_ptr_t & p_out,const char * p_path,abort_callback & p_abort); - static void g_open_read(service_ptr_t & p_out,const char * path,abort_callback & p_abort) {return g_open(p_out,path,open_mode_read,p_abort);} - static void g_open_precache(service_ptr_t & p_out,const char * path,abort_callback & p_abort);//open only for precaching data (eg. will fail on http etc) - static bool g_exists(const char * p_path,abort_callback & p_abort); - static bool g_exists_writeable(const char * p_path,abort_callback & p_abort); - //! Removes file at specified path. - static void g_remove(const char * p_path,abort_callback & p_abort); - //! Attempts to remove file at specified path; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time. - static void g_remove_timeout(const char * p_path,double p_timeout,abort_callback & p_abort); - //! Moves file from one path to another. - static void g_move(const char * p_src,const char * p_dst,abort_callback & p_abort); - //! Attempts to move file from one path to another; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time. - static void g_move_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort); - - static void g_copy(const char * p_src,const char * p_dst,abort_callback & p_abort);//needs canonical path - static void g_copy_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort);//needs canonical path - static void g_copy_directory(const char * p_src,const char * p_dst,abort_callback & p_abort);//needs canonical path - static void g_get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort); - static bool g_relative_path_create(const char * p_file_path,const char * p_playlist_path,pfc::string_base & out); - static bool g_relative_path_parse(const char * p_relative_path,const char * p_playlist_path,pfc::string_base & out); - - static void g_create_directory(const char * p_path,abort_callback & p_abort); - - //! If for some bloody reason you ever need stream io compatibility, use this, INSTEAD of calling fopen() on the path string you've got; will only work with file:// (and not with http://, unpack:// or whatever) - static FILE * streamio_open(const char * p_path,const char * p_flags); - - static void g_open_temp(service_ptr_t & p_out,abort_callback & p_abort); - static void g_open_tempmem(service_ptr_t & p_out,abort_callback & p_abort); - - static void g_list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort);// path must be canonical - - static bool g_is_valid_directory(const char * path,abort_callback & p_abort); - static bool g_is_empty_directory(const char * path,abort_callback & p_abort); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(filesystem); - }; - - class directory_callback_impl : public directory_callback - { - struct t_entry - { - pfc::string_simple m_path; - t_filestats m_stats; - t_entry(const char * p_path, const t_filestats & p_stats) : m_path(p_path), m_stats(p_stats) {} - }; - - - pfc::list_t > m_data; - bool m_recur; - - static int sortfunc(const pfc::rcptr_t & p1, const pfc::rcptr_t & p2) {return stricmp_utf8(p1->m_path,p2->m_path);} - public: - bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats); - - directory_callback_impl(bool p_recur) : m_recur(p_recur) {} - t_size get_count() {return m_data.get_count();} - const char * operator[](t_size n) const {return m_data[n]->m_path;} - const char * get_item(t_size n) const {return m_data[n]->m_path;} - const t_filestats & get_item_stats(t_size n) const {return m_data[n]->m_stats;} - void sort() {m_data.sort_t(sortfunc);} - }; - - class archive; - - class NOVTABLE archive_callback : public abort_callback { - public: - virtual bool on_entry(archive * owner,const char * url,const t_filestats & p_stats,const service_ptr_t & p_reader) = 0; - }; - - //! Interface for archive reader services. When implementing, derive from archive_impl rather than from deriving from archive directly. - class NOVTABLE archive : public filesystem { - public: - virtual void archive_list(const char * p_path,const service_ptr_t & p_reader,archive_callback & p_callback,bool p_want_readers) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(archive,filesystem); - }; - - //! Root class for archive implementations. Derive from this instead of from archive directly. - class NOVTABLE archive_impl : public archive { - private: - //do not override these - bool get_canonical_path(const char * path,pfc::string_base & out); - bool is_our_path(const char * path); - bool get_display_path(const char * path,pfc::string_base & out); - void remove(const char * path,abort_callback & p_abort); - void move(const char * src,const char * dst,abort_callback & p_abort); - bool is_remote(const char * src); - bool relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out); - bool relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out); - void open(service_ptr_t & p_out,const char * path, t_open_mode mode,abort_callback & p_abort); - void create_directory(const char * path,abort_callback &); - void list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort); - void get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort); - protected: - //override these - virtual const char * get_archive_type()=0;//eg. "zip", must be lowercase - virtual t_filestats get_stats_in_archive(const char * p_archive,const char * p_file,abort_callback & p_abort) = 0; - virtual void open_archive(service_ptr_t & p_out,const char * archive,const char * file, abort_callback & p_abort)=0;//opens for reading - public: - //override these - - virtual void archive_list(const char * path,const service_ptr_t & p_reader,archive_callback & p_out,bool p_want_readers)=0; - - static bool g_parse_unpack_path(const char * path,pfc::string8 & archive,pfc::string8 & file); - static void g_make_unpack_path(pfc::string_base & path,const char * archive,const char * file,const char * name); - void make_unpack_path(pfc::string_base & path,const char * archive,const char * file); - - - }; - - template - class archive_factory_t : public service_factory_single_t {}; - - - t_filetimestamp filetimestamp_from_system_timer(); - -#ifdef _WIN32 - inline t_filetimestamp import_filetimestamp(FILETIME ft) { - return *reinterpret_cast(&ft); - } -#endif - - void generate_temp_location_for_file(pfc::string_base & p_out, const char * p_origpath,const char * p_extension,const char * p_magic); - - - static file_ptr fileOpen(const char * p_path,filesystem::t_open_mode p_mode,abort_callback & p_abort,double p_timeout) { - file_ptr temp; filesystem::g_open_timeout(temp,p_path,p_mode,p_timeout,p_abort); PFC_ASSERT(temp.is_valid()); return temp; - } - - static file_ptr fileOpenReadExisting(const char * p_path,abort_callback & p_abort,double p_timeout = 0) { - return fileOpen(p_path,filesystem::open_mode_read,p_abort,p_timeout); - } - static file_ptr fileOpenWriteExisting(const char * p_path,abort_callback & p_abort,double p_timeout = 0) { - return fileOpen(p_path,filesystem::open_mode_write_existing,p_abort,p_timeout); - } - static file_ptr fileOpenWriteNew(const char * p_path,abort_callback & p_abort,double p_timeout = 0) { - return fileOpen(p_path,filesystem::open_mode_write_new,p_abort,p_timeout); - } - - template - class directory_callback_retrieveList : public directory_callback { - public: - directory_callback_retrieveList(t_list & p_list,bool p_getFiles,bool p_getSubDirectories) : m_list(p_list), m_getFiles(p_getFiles), m_getSubDirectories(p_getSubDirectories) {} - bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) { - p_abort.check(); - if (p_is_subdirectory ? m_getSubDirectories : m_getFiles) { - m_list.add_item(p_url); - } - return true; - } - private: - const bool m_getSubDirectories; - const bool m_getFiles; - t_list & m_list; - }; - template - class directory_callback_retrieveListEx : public directory_callback { - public: - directory_callback_retrieveListEx(t_list & p_files, t_list & p_directories) : m_files(p_files), m_directories(p_directories) {} - bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) { - p_abort.check(); - if (p_is_subdirectory) m_directories += p_url; - else m_files += p_url; - return true; - } - private: - t_list & m_files; - t_list & m_directories; - }; - template class directory_callback_retrieveListRecur : public directory_callback { - public: - directory_callback_retrieveListRecur(t_list & p_list) : m_list(p_list) {} - bool on_entry(filesystem * owner,abort_callback & p_abort,const char * path, bool isSubdir, const t_filestats&) { - if (isSubdir) { - try { owner->list_directory(path,*this,p_abort); } catch(exception_io) {} - } else { - m_list.add_item(path); - } - return true; - } - private: - t_list & m_list; - }; - - template - static void listFiles(const char * p_path,t_list & p_out,abort_callback & p_abort) { - directory_callback_retrieveList callback(p_out,true,false); - filesystem::g_list_directory(p_path,callback,p_abort); - } - template - static void listDirectories(const char * p_path,t_list & p_out,abort_callback & p_abort) { - directory_callback_retrieveList callback(p_out,false,true); - filesystem::g_list_directory(p_path,callback,p_abort); - } - template - static void listFilesAndDirectories(const char * p_path,t_list & p_files,t_list & p_directories,abort_callback & p_abort) { - directory_callback_retrieveListEx callback(p_files,p_directories); - filesystem::g_list_directory(p_path,callback,p_abort); - } - template - static void listFilesRecur(const char * p_path,t_list & p_out,abort_callback & p_abort) { - directory_callback_retrieveListRecur callback(p_out); - filesystem::g_list_directory(p_path,callback,p_abort); - } - - bool extract_native_path(const char * p_fspath,pfc::string_base & p_native); - bool _extract_native_path_ptr(const char * & p_fspath); - bool extract_native_path_ex(const char * p_fspath, pfc::string_base & p_native);//prepends \\?\ where needed - - template - pfc::string getPathDisplay(const T& source) { - pfc::string_formatter temp; - filesystem::g_get_display_path(pfc::stringToPtr(source),temp); - return temp.toString(); - } - template - pfc::string getPathCanonical(const T& source) { - pfc::string_formatter temp; - filesystem::g_get_canonical_path(pfc::stringToPtr(source),temp); - return temp.toString(); - } -} - -using namespace foobar2000_io; - -#include "filesystem_helper.h" diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem_helper.cpp deleted file mode 100644 index e8feb4e2c..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem_helper.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "foobar2000.h" - -void stream_writer_chunk::write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - t_size remaining = p_bytes, written = 0; - while(remaining > 0) { - t_size delta = sizeof(m_buffer) - m_buffer_state; - if (delta > remaining) delta = remaining; - memcpy(m_buffer,(const t_uint8*)p_buffer + written,delta); - written += delta; - remaining -= delta; - - if (m_buffer_state == sizeof(m_buffer)) { - m_writer->write_lendian_t((t_uint8)m_buffer_state,p_abort); - m_writer->write_object(m_buffer,m_buffer_state,p_abort); - m_buffer_state = 0; - } - } -} - -void stream_writer_chunk::flush(abort_callback & p_abort) -{ - m_writer->write_lendian_t((t_uint8)m_buffer_state,p_abort); - if (m_buffer_state > 0) { - m_writer->write_object(m_buffer,m_buffer_state,p_abort); - m_buffer_state = 0; - } -} - -/* - stream_writer * m_writer; - unsigned m_buffer_state; - unsigned char m_buffer[255]; -*/ - -t_size stream_reader_chunk::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) -{ - t_size todo = p_bytes, done = 0; - while(todo > 0) { - if (m_buffer_size == m_buffer_state) { - if (m_eof) break; - t_uint8 temp; - m_reader->read_lendian_t(temp,p_abort); - m_buffer_size = temp; - if (temp != sizeof(m_buffer)) m_eof = true; - m_buffer_state = 0; - if (m_buffer_size>0) { - m_reader->read_object(m_buffer,m_buffer_size,p_abort); - } - } - - - t_size delta = m_buffer_size - m_buffer_state; - if (delta > todo) delta = todo; - if (delta > 0) { - memcpy((unsigned char*)p_buffer + done,m_buffer + m_buffer_state,delta); - todo -= delta; - done += delta; - m_buffer_state += delta; - } - } - return done; -} - -void stream_reader_chunk::flush(abort_callback & p_abort) { - while(!m_eof) { - p_abort.check_e(); - t_uint8 temp; - m_reader->read_lendian_t(temp,p_abort); - m_buffer_size = temp; - if (temp != sizeof(m_buffer)) m_eof = true; - m_buffer_state = 0; - if (m_buffer_size>0) { - m_reader->skip_object(m_buffer_size,p_abort); - } - } -} - -/* - stream_reader * m_reader; - unsigned m_buffer_state, m_buffer_size; - bool m_eof; - unsigned char m_buffer[255]; -*/ - -void stream_reader_chunk::g_skip(stream_reader * p_stream,abort_callback & p_abort) { - stream_reader_chunk(p_stream).flush(p_abort); -} - -t_size reader_membuffer_base::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check_e(); - t_size max = get_buffer_size(); - if (max < m_offset) throw pfc::exception_bug_check_v2(); - max -= m_offset; - t_size delta = p_bytes; - if (delta > max) delta = max; - memcpy(p_buffer,(char*)get_buffer() + m_offset,delta); - m_offset += delta; - return delta; -} - -void reader_membuffer_base::seek(t_filesize position,abort_callback & p_abort) { - p_abort.check_e(); - t_filesize max = get_buffer_size(); - if (position == filesize_invalid || position > max) throw exception_io_seek_out_of_range(); - m_offset = (t_size)position; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem_helper.h b/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem_helper.h deleted file mode 100644 index 579e426aa..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/filesystem_helper.h +++ /dev/null @@ -1,579 +0,0 @@ -//helper -class file_path_canonical { -public: - file_path_canonical(const char * src) {filesystem::g_get_canonical_path(src,m_data);} - operator const char * () const {return m_data.get_ptr();} - const char * get_ptr() const {return m_data.get_ptr();} - t_size get_length() const {return m_data.get_length();} -private: - pfc::string8 m_data; -}; - -class file_path_display { -public: - file_path_display(const char * src) {filesystem::g_get_display_path(src,m_data);} - operator const char * () const {return m_data.get_ptr();} - const char * get_ptr() const {return m_data.get_ptr();} - t_size get_length() const {return m_data.get_length();} -private: - pfc::string8 m_data; -}; - - -class NOVTABLE reader_membuffer_base : public file_readonly { -public: - reader_membuffer_base() : m_offset(0) {} - - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort); - - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {throw exception_io_denied();} - - t_filesize get_size(abort_callback & p_abort) {return get_buffer_size();} - t_filesize get_position(abort_callback & p_abort) {return m_offset;} - void seek(t_filesize position,abort_callback & p_abort); - void reopen(abort_callback & p_abort) {seek(0,p_abort);} - - bool can_seek() {return true;} - bool is_in_memory() {return true;} - -protected: - virtual const void * get_buffer() = 0; - virtual t_size get_buffer_size() = 0; - virtual t_filetimestamp get_timestamp(abort_callback & p_abort) = 0; - virtual bool get_content_type(pfc::string_base &) {return false;} - inline void seek_internal(t_size p_offset) {if (p_offset > get_buffer_size()) throw exception_io_seek_out_of_range(); m_offset = p_offset;} -private: - t_size m_offset; -}; - -class reader_membuffer_mirror : public reader_membuffer_base -{ -public: - t_filetimestamp get_timestamp(abort_callback & p_abort) {return m_timestamp;} - bool is_remote() {return m_remote;} - - //! Returns false when the object could not be mirrored (too big) or did not need mirroring. - static bool g_create(service_ptr_t & p_out,const service_ptr_t & p_src,abort_callback & p_abort) { - service_ptr_t ptr = new service_impl_t(); - if (!ptr->init(p_src,p_abort)) return false; - p_out = ptr.get_ptr(); - return true; - } - -private: - const void * get_buffer() {return m_buffer.get_ptr();} - t_size get_buffer_size() {return m_buffer.get_size();} - - bool init(const service_ptr_t & p_src,abort_callback & p_abort) { - if (p_src->is_in_memory()) return false;//already buffered - m_remote = p_src->is_remote(); - - t_size size = pfc::downcast_guarded(p_src->get_size(p_abort)); - - m_buffer.set_size(size); - - p_src->reopen(p_abort); - - p_src->read_object(m_buffer.get_ptr(),size,p_abort); - - m_timestamp = p_src->get_timestamp(p_abort); - - return true; - } - - - t_filetimestamp m_timestamp; - pfc::array_t m_buffer; - bool m_remote; - -}; - -class reader_limited : public file_readonly { - service_ptr_t r; - t_filesize begin; - t_filesize end; - -public: - static file::ptr g_create(file::ptr base, t_filesize offset, t_filesize size, abort_callback & abort) { - service_ptr_t r = new service_impl_t(); - if (offset + size < offset) throw pfc::exception_overflow(); - r->init(base, offset, offset + size, abort); - return r; - } - reader_limited() {begin=0;end=0;} - reader_limited(const service_ptr_t & p_r,t_filesize p_begin,t_filesize p_end,abort_callback & p_abort) { - r = p_r; - begin = p_begin; - end = p_end; - r->seek(begin,p_abort); - } - - void init(const service_ptr_t & p_r,t_filesize p_begin,t_filesize p_end,abort_callback & p_abort) { - r = p_r; - begin = p_begin; - end = p_end; - r->seek(begin,p_abort); - } - - t_filetimestamp get_timestamp(abort_callback & p_abort) {return r->get_timestamp(p_abort);} - - t_size read(void *p_buffer, t_size p_bytes,abort_callback & p_abort) { - t_filesize pos; - pos = r->get_position(p_abort); - if (p_bytes > end - pos) p_bytes = (t_size)(end - pos); - return r->read(p_buffer,p_bytes,p_abort); - } - - t_filesize get_size(abort_callback & p_abort) {return end-begin;} - - t_filesize get_position(abort_callback & p_abort) { - return r->get_position(p_abort) - begin; - } - - void seek(t_filesize position,abort_callback & p_abort) { - r->seek(position+begin,p_abort); - } - bool can_seek() {return r->can_seek();} - bool is_remote() {return r->is_remote();} - - bool get_content_type(pfc::string_base &) {return false;} - - void reopen(abort_callback & p_abort) {seek(0,p_abort);} -}; - -class stream_reader_memblock_ref : public stream_reader -{ -public: - template stream_reader_memblock_ref(const t_array & p_array) : m_data(p_array.get_ptr()), m_data_size(p_array.get_size()), m_pointer(0) { - pfc::assert_byte_type(); - } - stream_reader_memblock_ref(const void * p_data,t_size p_data_size) : m_data((const unsigned char*)p_data), m_data_size(p_data_size), m_pointer(0) {} - stream_reader_memblock_ref() : m_data(NULL), m_data_size(0), m_pointer(0) {} - - template void set_data(const t_array & data) { - pfc::assert_byte_type(); - set_data(data.get_ptr(), data.get_size()); - } - - void set_data(const void * data, t_size dataSize) { - m_pointer = 0; - m_data = reinterpret_cast(data); - m_data_size = dataSize; - } - - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - t_size remaining = m_data_size - m_pointer; - t_size toread = p_bytes; - if (toread > remaining) toread = remaining; - if (toread > 0) { - memcpy(p_buffer,m_data+m_pointer,toread); - m_pointer += toread; - } - - return toread; - } - t_size get_remaining() const {return m_data_size - m_pointer;} - void reset() {m_pointer = 0;} -private: - const unsigned char * m_data; - t_size m_data_size,m_pointer; -}; - -class stream_writer_buffer_simple : public stream_writer { -public: - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check(); - t_size base = m_buffer.get_size(); - if (base + p_bytes < base) throw std::bad_alloc(); - m_buffer.set_size(base + p_bytes); - memcpy( (t_uint8*) m_buffer.get_ptr() + base, p_buffer, p_bytes ); - } - - typedef pfc::array_t t_buffer; - - pfc::array_t m_buffer; -}; - -template -class stream_writer_buffer_append_ref_t : public stream_writer -{ -public: - stream_writer_buffer_append_ref_t(t_storage & p_output) : m_output(p_output) {} - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - pfc::static_assert< sizeof(m_output[0]) == 1>(); - p_abort.check(); - t_size base = m_output.get_size(); - if (base + p_bytes < base) throw std::bad_alloc(); - m_output.set_size(base + p_bytes); - memcpy( (t_uint8*) m_output.get_ptr() + base, p_buffer, p_bytes ); - } -private: - t_storage & m_output; -}; - -class stream_reader_limited_ref : public stream_reader { -public: - stream_reader_limited_ref(stream_reader * p_reader,t_filesize p_limit) : m_reader(p_reader), m_remaining(p_limit) {} - - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - if (p_bytes > m_remaining) p_bytes = (t_size)m_remaining; - - t_size done = m_reader->read(p_buffer,p_bytes,p_abort); - m_remaining -= done; - return done; - } - - inline t_filesize get_remaining() const {return m_remaining;} - - t_filesize skip(t_filesize p_bytes,abort_callback & p_abort) { - if (p_bytes > m_remaining) p_bytes = m_remaining; - t_filesize done = m_reader->skip(p_bytes,p_abort); - m_remaining -= done; - return done; - } - - void flush_remaining(abort_callback & p_abort) { - if (m_remaining > 0) skip_object(m_remaining,p_abort); - } - -private: - stream_reader * m_reader; - t_filesize m_remaining; -}; - -class stream_writer_chunk_dwordheader : public stream_writer -{ -public: - stream_writer_chunk_dwordheader(const service_ptr_t & p_writer) : m_writer(p_writer) {} - - void initialize(abort_callback & p_abort) { - m_headerposition = m_writer->get_position(p_abort); - m_written = 0; - m_writer->write_lendian_t((t_uint32)0,p_abort); - } - - void finalize(abort_callback & p_abort) { - t_filesize end_offset; - end_offset = m_writer->get_position(p_abort); - m_writer->seek(m_headerposition,p_abort); - m_writer->write_lendian_t(pfc::downcast_guarded(m_written),p_abort); - m_writer->seek(end_offset,p_abort); - } - - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - m_writer->write(p_buffer,p_bytes,p_abort); - m_written += p_bytes; - } - -private: - service_ptr_t m_writer; - t_filesize m_headerposition; - t_filesize m_written; -}; - -class stream_writer_chunk : public stream_writer -{ -public: - stream_writer_chunk(stream_writer * p_writer) : m_writer(p_writer), m_buffer_state(0) {} - - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort); - - void flush(abort_callback & p_abort);//must be called after writing before object is destroyed - -private: - stream_writer * m_writer; - unsigned m_buffer_state; - unsigned char m_buffer[255]; -}; - -class stream_reader_chunk : public stream_reader -{ -public: - stream_reader_chunk(stream_reader * p_reader) : m_reader(p_reader), m_buffer_state(0), m_buffer_size(0), m_eof(false) {} - - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort); - - void flush(abort_callback & p_abort);//must be called after reading before object is destroyed - - static void g_skip(stream_reader * p_stream,abort_callback & p_abort); - -private: - stream_reader * m_reader; - t_size m_buffer_state, m_buffer_size; - bool m_eof; - unsigned char m_buffer[255]; -}; - -class stream_reader_dummy : public stream_reader { t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) {return 0;} }; - - - - - - - - - - - - - - - - - - -template class stream_reader_formatter { -public: - stream_reader_formatter(stream_reader & p_stream,abort_callback & p_abort) : m_stream(p_stream), m_abort(p_abort) {} - - template void read_int(t_int & p_out) { - if (isBigEndian) m_stream.read_bendian_t(p_out,m_abort); - else m_stream.read_lendian_t(p_out,m_abort); - } - - void read_raw(void * p_buffer,t_size p_bytes) { - m_stream.read_object(p_buffer,p_bytes,m_abort); - } - - void skip(t_size p_bytes) {m_stream.skip_object(p_bytes,m_abort);} - - template void read_raw(TArray& data) { - pfc::assert_byte_type(); - read_raw(data.get_ptr(),data.get_size()); - } - template void read_byte_block(TArray & data) { - pfc::assert_byte_type(); - t_uint32 size; read_int(size); data.set_size(size); - read_raw(data); - } - template void read_array(TArray & data) { - t_uint32 size; *this >> size; data.set_size(size); - for(t_uint32 walk = 0; walk < size; ++walk) *this >> data[walk]; - } - - stream_reader & m_stream; - abort_callback & m_abort; -}; - -template class stream_writer_formatter { -public: - stream_writer_formatter(stream_writer & p_stream,abort_callback & p_abort) : m_stream(p_stream), m_abort(p_abort) {} - - template void write_int(t_int p_int) { - if (isBigEndian) m_stream.write_bendian_t(p_int,m_abort); - else m_stream.write_lendian_t(p_int,m_abort); - } - - void write_raw(const void * p_buffer,t_size p_bytes) { - m_stream.write_object(p_buffer,p_bytes,m_abort); - } - template void write_raw(const TArray& data) { - pfc::assert_byte_type(); - write_raw(data.get_ptr(),data.get_size()); - } - - template void write_byte_block(const TArray& data) { - pfc::assert_byte_type(); - write_int( pfc::downcast_guarded(data.get_size()) ); - write_raw( data ); - } - template void write_array(const TArray& data) { - const t_uint32 size = pfc::downcast_guarded(data.get_size()); - *this << size; - for(t_uint32 walk = 0; walk < size; ++walk) *this << data[walk]; - } - - void write_string(const char * str) { - const t_size len = strlen(str); - *this << pfc::downcast_guarded(len); - write_raw(str, len); - } - void write_string(const char * str, t_size len_) { - const t_size len = pfc::strlen_max(str, len_); - *this << pfc::downcast_guarded(len); - write_raw(str, len); - } - - stream_writer & m_stream; - abort_callback & m_abort; -}; - -#define __DECLARE_UINT_OVERLOADS(TYPE) \ - template inline stream_reader_formatter & operator>>(stream_reader_formatter & p_stream,TYPE & p_int) {p_stream.read_int(p_int); return p_stream;} \ - template inline stream_writer_formatter & operator<<(stream_writer_formatter & p_stream,TYPE p_int) {p_stream.write_int(p_int); return p_stream;} - -__DECLARE_UINT_OVERLOADS(t_uint8); -__DECLARE_UINT_OVERLOADS(t_uint16); -__DECLARE_UINT_OVERLOADS(t_uint32); -__DECLARE_UINT_OVERLOADS(t_uint64); - -#ifdef _MSC_VER -//SPECIAL FIX -__DECLARE_UINT_OVERLOADS(unsigned long); -#endif - -#undef __DECLARE_UINT_OVERLOADS - -#define __DECLARE_INT_OVERLOADS(TYPE) \ - template inline stream_reader_formatter & operator>>(stream_reader_formatter & p_stream,TYPE & p_int) {typename pfc::sized_int_t::t_unsigned temp;p_stream.read_int(temp); p_int = (TYPE) temp; return p_stream;} \ - template inline stream_writer_formatter & operator<<(stream_writer_formatter & p_stream,TYPE p_int) {p_stream.write_int((typename pfc::sized_int_t::t_unsigned)p_int); return p_stream;} - -__DECLARE_INT_OVERLOADS(t_int8); -__DECLARE_INT_OVERLOADS(t_int16); -__DECLARE_INT_OVERLOADS(t_int32); -__DECLARE_INT_OVERLOADS(t_int64); - -#ifdef _MSC_VER -//SPECIAL FIX -__DECLARE_INT_OVERLOADS(long); -#endif - -#undef __DECLARE_INT_OVERLOADS - -template class __IsTypeByte { -public: - enum {value = pfc::is_same_type::value || pfc::is_same_type::value}; -}; - -template stream_reader_formatter & operator>>(stream_reader_formatter & p_stream,TVal (& p_array)[Count]) { - if (__IsTypeByte::value) { - p_stream.read_raw(p_array,Count); - } else { - for(t_size walk = 0; walk < Count; ++walk) p_stream >> p_array[walk]; - } - return p_stream; -} - -template stream_writer_formatter & operator<<(stream_writer_formatter & p_stream,TVal const (& p_array)[Count]) { - if (__IsTypeByte::value) { - p_stream.write_raw(p_array,Count); - } else { - for(t_size walk = 0; walk < Count; ++walk) p_stream << p_array[walk]; - } - return p_stream; -} - -#define FB2K_STREAM_READER_OVERLOAD(type) \ - template stream_reader_formatter & operator>>(stream_reader_formatter & stream,type & value) - -#define FB2K_STREAM_WRITER_OVERLOAD(type) \ - template stream_writer_formatter & operator<<(stream_writer_formatter & stream,const type & value) - -FB2K_STREAM_READER_OVERLOAD(GUID) { - return stream >> value.Data1 >> value.Data2 >> value.Data3 >> value.Data4; -} - -FB2K_STREAM_WRITER_OVERLOAD(GUID) { - return stream << value.Data1 << value.Data2 << value.Data3 << value.Data4; -} - -FB2K_STREAM_READER_OVERLOAD(pfc::string) { - t_uint32 len; stream >> len; - value = stream.m_stream.read_string_ex(len,stream.m_abort); - return stream; -} - -FB2K_STREAM_WRITER_OVERLOAD(pfc::string) { - stream << pfc::downcast_guarded(value.length()); - stream.write_raw(value.ptr(),value.length()); - return stream; -} - -FB2K_STREAM_READER_OVERLOAD(pfc::string_base) { - t_uint32 len; stream >> len; - try { - char * buf = value.lock_buffer(len); - stream.read_raw(buf,len); - } catch(...) { - value.unlock_buffer(); throw; - } - value.unlock_buffer(); - return stream; -} -FB2K_STREAM_WRITER_OVERLOAD(pfc::string_base) { - const char * val = value.get_ptr(); - const t_size len = strlen(val); - stream << pfc::downcast_guarded(len); - stream.write_raw(val,len); - return stream; -} - - -FB2K_STREAM_WRITER_OVERLOAD(float) { - union { - float f; t_uint32 i; - } u; u.f = value; - return stream << u.i; -} - -FB2K_STREAM_READER_OVERLOAD(float) { - union { float f; t_uint32 i;} u; - stream >> u.i; value = u.f; - return stream; -} - -FB2K_STREAM_WRITER_OVERLOAD(double) { - union { - double f; t_uint64 i; - } u; u.f = value; - return stream << u.i; -} - -FB2K_STREAM_READER_OVERLOAD(double) { - union { double f; t_uint64 i;} u; - stream >> u.i; value = u.f; - return stream; -} - - -template -class stream_writer_formatter_simple : public stream_writer_formatter { -public: - stream_writer_formatter_simple() : stream_writer_formatter(_m_stream,_m_abort), m_buffer(_m_stream.m_buffer) {} - - typedef stream_writer_buffer_simple::t_buffer t_buffer; - t_buffer & m_buffer; -private: - stream_writer_buffer_simple _m_stream; - abort_callback_dummy _m_abort; -}; - -template -class stream_reader_formatter_simple_ref : public stream_reader_formatter { -public: - stream_reader_formatter_simple_ref(const void * source, t_size sourceSize) : stream_reader_formatter(_m_stream,_m_abort), _m_stream(source,sourceSize) {} - template stream_reader_formatter_simple_ref(const TSource& source) : stream_reader_formatter(_m_stream,_m_abort), _m_stream(source) {} - stream_reader_formatter_simple_ref() : stream_reader_formatter(_m_stream,_m_abort) {} - - void set_data(const void * source, t_size sourceSize) {_m_stream.set_data(source,sourceSize);} - template void set_data(const TSource & source) {_m_stream.set_data(source);} - - void reset() {_m_stream.reset();} - t_size get_remaining() {return _m_stream.get_remaining();} -private: - stream_reader_memblock_ref _m_stream; - abort_callback_dummy _m_abort; -}; - -template -class stream_reader_formatter_simple : public stream_reader_formatter_simple_ref { -public: - stream_reader_formatter_simple() {} - stream_reader_formatter_simple(const void * source, t_size sourceSize) {set_data(source,sourceSize);} - template stream_reader_formatter_simple(const TSource & source) {set_data(source);} - - void set_data(const void * source, t_size sourceSize) { - m_content.set_data_fromptr(reinterpret_cast(source), sourceSize); - onContentChange(); - } - template void set_data(const TSource & source) { - m_content = source; - onContentChange(); - } -private: - void onContentChange() { - stream_reader_formatter_simple_ref::set_data(m_content); - } - pfc::array_t m_content; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/foobar2000.h b/tools/vio2sf/src/foobar/foobar2000/SDK/foobar2000.h deleted file mode 100644 index 07191c7d0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/foobar2000.h +++ /dev/null @@ -1,95 +0,0 @@ -// This is the master foobar2000 SDK header file; it includes headers for all functionality exposed through the SDK project. #include this in your source code, never reference any of the other headers directly. - -#ifndef _FOOBAR2000_H_ -#define _FOOBAR2000_H_ - -#ifndef UNICODE -#error Only UNICODE environment supported. -#endif - -#include "../../pfc/pfc.h" - -#include "../shared/shared.h" - -#ifndef NOTHROW -#ifdef _MSC_VER -#define NOTHROW __declspec(nothrow) -#else -#define NOTHROW -#endif -#endif - -#define FB2KAPI /*NOTHROW*/ - -typedef const char * pcchar; - -#include "core_api.h" -#include "service.h" - -#include "completion_notify.h" -#include "abort_callback.h" -#include "componentversion.h" -#include "preferences_page.h" -#include "coreversion.h" -#include "filesystem.h" -#include "audio_chunk.h" -#include "cfg_var.h" -#include "mem_block_container.h" -#include "audio_postprocessor.h" -#include "playable_location.h" -#include "file_info.h" -#include "file_info_impl.h" -#include "metadb_handle.h" -#include "metadb.h" -#include "console.h" -#include "dsp.h" -#include "dsp_manager.h" -#include "initquit.h" -#include "event_logger.h" -#include "input.h" -#include "input_impl.h" -#include "menu.h" -#include "contextmenu.h" -#include "contextmenu_manager.h" -#include "menu_helpers.h" -#include "modeless_dialog.h" -#include "playback_control.h" -#include "play_callback.h" -#include "playlist.h" -#include "playlist_loader.h" -#include "replaygain.h" -#include "resampler.h" -#include "tag_processor.h" -#include "titleformat.h" -#include "ui.h" -#include "unpack.h" -#include "vis.h" -#include "packet_decoder.h" -#include "commandline.h" -#include "genrand.h" -#include "file_operation_callback.h" -#include "library_manager.h" -#include "config_io_callback.h" -#include "popup_message.h" -#include "app_close_blocker.h" -#include "config_object.h" -#include "config_object_impl.h" -#include "threaded_process.h" -#include "hasher_md5.h" -#include "message_loop.h" -#include "input_file_type.h" -#include "chapterizer.h" -#include "link_resolver.h" -#include "main_thread_callback.h" -#include "advconfig.h" -#include "info_lookup_handler.h" -#include "track_property.h" - -#include "album_art.h" -#include "icon_remap.h" -#include "ole_interaction.h" -#include "search_tools.h" -#include "autoplaylist.h" -#include "replaygain_scanner.h" - -#endif //_FOOBAR2000_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/foobar2000_SDK.vcproj b/tools/vio2sf/src/foobar/foobar2000/SDK/foobar2000_SDK.vcproj deleted file mode 100644 index 25a4a28b5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/foobar2000_SDK.vcproj +++ /dev/null @@ -1,1810 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/genrand.h b/tools/vio2sf/src/foobar/foobar2000/SDK/genrand.h deleted file mode 100644 index 430754024..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/genrand.h +++ /dev/null @@ -1,13 +0,0 @@ -//! PRNG service. Implemented by the core, do not reimplement. Use g_create() helper function to instantiate. -class NOVTABLE genrand_service : public service_base -{ -public: - //! Seeds the PRNG with specified value. - virtual void seed(unsigned val) = 0; - //! Returns random value N, where 0 <= N < range. - virtual unsigned genrand(unsigned range)=0; - - static service_ptr_t g_create() {return standard_api_create_t();} - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(genrand_service); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/guids.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/guids.cpp deleted file mode 100644 index 8f8920820..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/guids.cpp +++ /dev/null @@ -1,1115 +0,0 @@ -#include "foobar2000.h" - -// {4B897EC8-A2F9-478d-A95E-1A2110A40078} -FOOGUIDDECL const GUID hasher_md5::class_guid = -{ 0x4b897ec8, 0xa2f9, 0x478d, { 0xa9, 0x5e, 0x1a, 0x21, 0x10, 0xa4, 0x0, 0x78 } }; - -// {74497D81-6158-48ba-9657-386A5520D0FF} -FOOGUIDDECL const GUID config_io_callback::class_guid = -{ 0x74497d81, 0x6158, 0x48ba, { 0x96, 0x57, 0x38, 0x6a, 0x55, 0x20, 0xd0, 0xff } }; - -// {10BB3EBD-DDF7-4975-A3CC-23084829453E} -FOOGUIDDECL const GUID componentversion::class_guid = -{ 0x10bb3ebd, 0xddf7, 0x4975, { 0xa3, 0xcc, 0x23, 0x8, 0x48, 0x29, 0x45, 0x3e } }; - -// {7255E8D0-3FCF-4781-B93B-D06CB88DFAFA} -FOOGUIDDECL const GUID preferences_page::class_guid = -{ 0x7255e8d0, 0x3fcf, 0x4781, { 0xb9, 0x3b, 0xd0, 0x6c, 0xb8, 0x8d, 0xfa, 0xfa } }; - -// {8146A883-F146-401b-BAF6-4FB2E306F2EB} -FOOGUIDDECL const GUID preferences_branch::class_guid = -{ 0x8146a883, 0xf146, 0x401b, { 0xba, 0xf6, 0x4f, 0xb2, 0xe3, 0x6, 0xf2, 0xeb } }; - -// {90DF5270-65BB-4dba-BAF5-86BE9E59DC20} -FOOGUIDDECL const GUID console_receiver::class_guid = -{ 0x90df5270, 0x65bb, 0x4dba, { 0xba, 0xf5, 0x86, 0xbe, 0x9e, 0x59, 0xdc, 0x20 } }; - -// {0C36A649-9EA0-4f48-B229-0CB2AA9AB6F4} -FOOGUIDDECL const GUID core_version_info::class_guid = -{ 0xc36a649, 0x9ea0, 0x4f48, { 0xb2, 0x29, 0xc, 0xb2, 0xaa, 0x9a, 0xb6, 0xf4 } }; - -// {61C4E6E4-C31E-4c89-A759-BF0949DFC528} -FOOGUIDDECL const GUID audio_postprocessor::class_guid = -{ 0x61c4e6e4, 0xc31e, 0x4c89, { 0xa7, 0x59, 0xbf, 0x9, 0x49, 0xdf, 0xc5, 0x28 } }; - -// {EE65D408-70D6-40f6-940D-D9F537F1BEF1} -FOOGUIDDECL const GUID dsp_config_manager::class_guid = -{ 0xee65d408, 0x70d6, 0x40f6, { 0x94, 0xd, 0xd9, 0xf5, 0x37, 0xf1, 0xbe, 0xf1 } }; - -// {F8F03D26-C2DA-47ed-8748-1DBACBCEA508} -FOOGUIDDECL const GUID dsp_config_callback::class_guid = -{ 0xf8f03d26, 0xc2da, 0x47ed, { 0x87, 0x48, 0x1d, 0xba, 0xcb, 0xce, 0xa5, 0x8 } }; - -// {0D048731-8AA8-4704-8AD6-189E24D48C88} -FOOGUIDDECL const GUID dsp_entry::class_guid = -{ 0xd048731, 0x8aa8, 0x4704, { 0x8a, 0xd6, 0x18, 0x9e, 0x24, 0xd4, 0x8c, 0x88 } }; - -// {2A42AFEA-940B-455b-AEFF-CFDACAF52AFF} -FOOGUIDDECL const GUID dsp::class_guid = -{ 0x2a42afea, 0x940b, 0x455b, { 0xae, 0xff, 0xcf, 0xda, 0xca, 0xf5, 0x2a, 0xff } }; - -// {113773C4-B387-4b48-8BDF-AB58BC6CE538} -FOOGUIDDECL const GUID initquit::class_guid = -{ 0x113773c4, 0xb387, 0x4b48, { 0x8b, 0xdf, 0xab, 0x58, 0xbc, 0x6c, 0xe5, 0x38 } }; - -FOOGUIDDECL const GUID metadb_display_field_provider::class_guid = { 0x5923fa2a, 0x504b, 0x4022, { 0xb2, 0x86, 0x0, 0x22, 0x75, 0x38, 0x45, 0x5e } }; - -// {609D48C8-C6A6-4784-8BBD-FDD32BF0740E} -FOOGUIDDECL const GUID metadb::class_guid = -{ 0x609d48c8, 0xc6a6, 0x4784, { 0x8b, 0xbd, 0xfd, 0xd3, 0x2b, 0xf0, 0x74, 0xe } }; - -// {D5286BB4-FDED-47ef-A623-4C3FF056DEC1} -FOOGUIDDECL const GUID metadb_io_callback::class_guid = -{ 0xd5286bb4, 0xfded, 0x47ef, { 0xa6, 0x23, 0x4c, 0x3f, 0xf0, 0x56, 0xde, 0xc1 } }; - -// {1C0802F7-CF24-49ef-B914-8B9866F19779} -FOOGUIDDECL const GUID contextmenu_item::class_guid = -{ 0x1c0802f7, 0xcf24, 0x49ef, { 0xb9, 0x14, 0x8b, 0x98, 0x66, 0xf1, 0x97, 0x79 } }; - -// {98B00B13-8C0E-49ff-B17C-5E537D3AE4B7} -FOOGUIDDECL const GUID visualisation_manager::class_guid = -{ 0x98b00b13, 0x8c0e, 0x49ff, { 0xb1, 0x7c, 0x5e, 0x53, 0x7d, 0x3a, 0xe4, 0xb7 } }; - -// {4A4B1DD8-82FF-4071-A6E2-BD043F4C251C} -FOOGUIDDECL const GUID visualisation_stream::class_guid = -{ 0x4a4b1dd8, 0x82ff, 0x4071, { 0xa6, 0xe2, 0xbd, 0x4, 0x3f, 0x4c, 0x25, 0x1c } }; - -// {015A6C0E-1571-49bd-A367-30B4BD889C34} -FOOGUIDDECL const GUID packet_decoder::class_guid = -{ 0x15a6c0e, 0x1571, 0x49bd, { 0xa3, 0x67, 0x30, 0xb4, 0xbd, 0x88, 0x9c, 0x34 } }; - -// {D815032D-AFEB-46c6-8AA3-6FD530A4CE67} -FOOGUIDDECL const GUID packet_decoder_streamparse::class_guid = -{ 0xd815032d, 0xafeb, 0x46c6, { 0x8a, 0xa3, 0x6f, 0xd5, 0x30, 0xa4, 0xce, 0x67 } }; - -// {53006A71-C03C-4c38-822F-9A34A5655095} -FOOGUIDDECL const GUID packet_decoder_entry::class_guid = -{ 0x53006a71, 0xc03c, 0x4c38, { 0x82, 0x2f, 0x9a, 0x34, 0xa5, 0x65, 0x50, 0x95 } }; - -// {D3BD5F53-A6D6-4346-991F-CF14DFAD2B3A} -FOOGUIDDECL const GUID contextmenu_manager::class_guid = -{ 0xd3bd5f53, 0xa6d6, 0x4346, { 0x99, 0x1f, 0xcf, 0x14, 0xdf, 0xad, 0x2b, 0x3a } }; - -// {640E006E-2934-4d6c-8327-4FA9F341ECF2} -FOOGUIDDECL const GUID input_file_type::class_guid = -{ 0x640e006e, 0x2934, 0x4d6c, { 0x83, 0x27, 0x4f, 0xa9, 0xf3, 0x41, 0xec, 0xf2 } }; - -// {8835B30A-36A6-49bc-B96D-D0609B0EF2BA} -FOOGUIDDECL const GUID input_file_type_v2::class_guid = -{ 0x8835b30a, 0x36a6, 0x49bc, { 0xb9, 0x6d, 0xd0, 0x60, 0x9b, 0xe, 0xf2, 0xba } }; - -// {2DC57FF7-476D-42f5-A05A-60499896134A} -FOOGUIDDECL const GUID ui_control::class_guid = -{ 0x2dc57ff7, 0x476d, 0x42f5, { 0xa0, 0x5a, 0x60, 0x49, 0x98, 0x96, 0x13, 0x4a } }; - -// {392B88DE-50FC-43b0-9F03-2D79B071CAF6} -FOOGUIDDECL const GUID ui_status_text_override::class_guid = -{ 0x392b88de, 0x50fc, 0x43b0, { 0x9f, 0x3, 0x2d, 0x79, 0xb0, 0x71, 0xca, 0xf6 } }; - -// {52BD7A17-540C-4a97-B812-72BC84EC4FF5} -FOOGUIDDECL const GUID ui_drop_item_callback::class_guid = -{ 0x52bd7a17, 0x540c, 0x4a97, { 0xb8, 0x12, 0x72, 0xbc, 0x84, 0xec, 0x4f, 0xf5 } }; - -// {550B3A19-42A4-4c0f-91F2-90550189CBFF} -FOOGUIDDECL const GUID commandline_handler::class_guid = -{ 0x550b3a19, 0x42a4, 0x4c0f, { 0x91, 0xf2, 0x90, 0x55, 0x1, 0x89, 0xcb, 0xff } }; - -// {C71B99BD-12C5-48fe-A9C0-469F6FEA88BF} -FOOGUIDDECL const GUID modeless_dialog_manager::class_guid = -{ 0xc71b99bd, 0x12c5, 0x48fe, { 0xa9, 0xc0, 0x46, 0x9f, 0x6f, 0xea, 0x88, 0xbf } }; - -// {78BCBFA1-DFB9-487f-AB16-CD82BF90CCF7} -FOOGUIDDECL const GUID play_callback_manager::class_guid = -{ 0x78bcbfa1, 0xdfb9, 0x487f, { 0xab, 0x16, 0xcd, 0x82, 0xbf, 0x90, 0xcc, 0xf7 } }; - -// {8E4EED7A-C6B8-49c7-99FE-97E04AAA63A8} -FOOGUIDDECL const GUID play_callback_static::class_guid = -{ 0x8e4eed7a, 0xc6b8, 0x49c7, { 0x99, 0xfe, 0x97, 0xe0, 0x4a, 0xaa, 0x63, 0xa8 } }; - -// {BF803668-2977-4c71-B9AB-5C77C338C970} -FOOGUIDDECL const GUID playback_control::class_guid = -{ 0xbf803668, 0x2977, 0x4c71, { 0xb9, 0xab, 0x5c, 0x77, 0xc3, 0x38, 0xc9, 0x70 } }; - -// {242D9341-211A-4637-A69F-F6684B52F9D6} -FOOGUIDDECL const GUID playlist_callback_static::class_guid = -{ 0x242d9341, 0x211a, 0x4637, { 0xa6, 0x9f, 0xf6, 0x68, 0x4b, 0x52, 0xf9, 0xd6 } }; - -// {95E9F11B-4C99-4d0a-AB9F-367196B10925} -FOOGUIDDECL const GUID playlist_callback_single_static::class_guid = -{ 0x95e9f11b, 0x4c99, 0x4d0a, { 0xab, 0x9f, 0x36, 0x71, 0x96, 0xb1, 0x9, 0x25 } }; - -// {88D7EDB1-A850-42a4-BBAB-49E955F4B81F} -FOOGUIDDECL const GUID playlist_lock::class_guid = -{ 0x88d7edb1, 0xa850, 0x42a4, { 0xbb, 0xab, 0x49, 0xe9, 0x55, 0xf4, 0xb8, 0x1f } }; - -// {D2E5F92B-3424-4822-AE60-8663E6D26EAB} -FOOGUIDDECL const GUID playlist_loader::class_guid = -{ 0xd2e5f92b, 0x3424, 0x4822, { 0xae, 0x60, 0x86, 0x63, 0xe6, 0xd2, 0x6e, 0xab } }; - -// {2FBCE1E5-902E-49e0-B9CF-CE0FBA765348} -FOOGUIDDECL const GUID filesystem::class_guid = -{ 0x2fbce1e5, 0x902e, 0x49e0, { 0xb9, 0xcf, 0xce, 0xf, 0xba, 0x76, 0x53, 0x48 } }; - -// {9098AF12-61A3-4caa-8AA9-BB95C2EF8346} -FOOGUIDDECL const GUID unpacker::class_guid = -{ 0x9098af12, 0x61a3, 0x4caa, { 0x8a, 0xa9, 0xbb, 0x95, 0xc2, 0xef, 0x83, 0x46 } }; - -// {EC707440-FA3E-4d12-9876-FC369F04D4A4} -FOOGUIDDECL const GUID archive::class_guid = -{ 0xec707440, 0xfa3e, 0x4d12, { 0x98, 0x76, 0xfc, 0x36, 0x9f, 0x4, 0xd4, 0xa4 } }; - -// {B2F9FC40-3E55-4b23-A2C9-22BAAD8795B1} -FOOGUIDDECL const GUID file::class_guid = -{ 0xb2f9fc40, 0x3e55, 0x4b23, { 0xa2, 0xc9, 0x22, 0xba, 0xad, 0x87, 0x95, 0xb1 } }; - -// {6374340F-82D4-4471-A24B-A754B1398285} -FOOGUIDDECL const GUID file_dynamicinfo::class_guid = -{ 0x6374340f, 0x82d4, 0x4471, { 0xa2, 0x4b, 0xa7, 0x54, 0xb1, 0x39, 0x82, 0x85 } }; - -// {A00CB77D-ED72-4031-806B-4E45AF995241} -FOOGUIDDECL const GUID replaygain_manager::class_guid = -{ 0xa00cb77d, 0xed72, 0x4031, { 0x80, 0x6b, 0x4e, 0x45, 0xaf, 0x99, 0x52, 0x41 } }; - -// {3FEED4FC-A400-4a30-8E73-F0ECD114D7E8} -FOOGUIDDECL const GUID resampler_entry::class_guid = -{ 0x3feed4fc, 0xa400, 0x4a30, { 0x8e, 0x73, 0xf0, 0xec, 0xd1, 0x14, 0xd7, 0xe8 } }; - -// {3F7674AB-044C-4796-8801-6C443C244D88} -FOOGUIDDECL const GUID titleformat_compiler::class_guid = -{ 0x3f7674ab, 0x44c, 0x4796, { 0x88, 0x1, 0x6c, 0x44, 0x3c, 0x24, 0x4d, 0x88 } }; - -// {1ADD4DC4-B278-4a0c-A105-2629F4B312F4} -FOOGUIDDECL const GUID user_interface::class_guid = -{ 0x1add4dc4, 0xb278, 0x4a0c, { 0xa1, 0x5, 0x26, 0x29, 0xf4, 0xb3, 0x12, 0xf4 } }; - -// {994C0D0E-319E-45f3-92FC-518616E73ADC} -FOOGUIDDECL const GUID contextmenu_item::caller_now_playing = -{ 0x994c0d0e, 0x319e, 0x45f3, { 0x92, 0xfc, 0x51, 0x86, 0x16, 0xe7, 0x3a, 0xdc } }; - -// {47502BA1-816D-4a3e-ADE5-A7A9860A67DB} -FOOGUIDDECL const GUID contextmenu_item::caller_active_playlist_selection = -{ 0x47502ba1, 0x816d, 0x4a3e, { 0xad, 0xe5, 0xa7, 0xa9, 0x86, 0xa, 0x67, 0xdb } }; - -// Deprecated. -FOOGUIDDECL const GUID contextmenu_item::caller_playlist = caller_active_playlist_selection; - -// {B3CC1030-EF26-45cf-A84A-7FC169BC9FFB} -FOOGUIDDECL const GUID contextmenu_item::caller_active_playlist = -{ 0xb3cc1030, 0xef26, 0x45cf, { 0xa8, 0x4a, 0x7f, 0xc1, 0x69, 0xbc, 0x9f, 0xfb } }; - -// {5FDCD5E8-6EB2-4454-9EDA-527522893BED} -FOOGUIDDECL const GUID contextmenu_item::caller_playlist_manager = -{ 0x5fdcd5e8, 0x6eb2, 0x4454, { 0x9e, 0xda, 0x52, 0x75, 0x22, 0x89, 0x3b, 0xed } }; - -// {00000000-0000-0000-0000-000000000000} -FOOGUIDDECL const GUID contextmenu_item::caller_undefined = -{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; - -// {FABEE3E9-8901-4df4-A2D7-B9898D86C39B} -FOOGUIDDECL const GUID contextmenu_item::caller_keyboard_shortcut_list = -{ 0xfabee3e9, 0x8901, 0x4df4, { 0xa2, 0xd7, 0xb9, 0x89, 0x8d, 0x86, 0xc3, 0x9b } }; - -// {FDA07C56-05D0-4b84-9FBD-A8BE556D474D} -FOOGUIDDECL const GUID contextmenu_item::caller_media_library_viewer = -{ 0xfda07c56, 0x5d0, 0x4b84, { 0x9f, 0xbd, 0xa8, 0xbe, 0x55, 0x6d, 0x47, 0x4d } }; - -// {95DE5842-30F5-4f72-B40C-191663782F80} -FOOGUIDDECL const GUID keyboard_shortcut_manager::class_guid = -{ 0x95de5842, 0x30f5, 0x4f72, { 0xb4, 0xc, 0x19, 0x16, 0x63, 0x78, 0x2f, 0x80 } }; - -// {CD19C870-DA6A-4b8a-A118-732A8102D07D} -FOOGUIDDECL const GUID keyboard_shortcut_manager_v2::class_guid = -{ 0xcd19c870, 0xda6a, 0x4b8a, { 0xa1, 0x18, 0x73, 0x2a, 0x81, 0x2, 0xd0, 0x7d } }; - -// {30F95BEB-FDF4-4a75-B597-60CAF93B39C4} -FOOGUIDDECL const GUID packet_decoder::owner_MP4 = -{ 0x30f95beb, 0xfdf4, 0x4a75, { 0xb5, 0x97, 0x60, 0xca, 0xf9, 0x3b, 0x39, 0xc4 } }; - -// {8F450CB3-A083-4b83-8D85-ADCE5EA6D57F} -FOOGUIDDECL const GUID packet_decoder::owner_MP4_ALAC = -{ 0x8f450cb3, 0xa083, 0x4b83, { 0x8d, 0x85, 0xad, 0xce, 0x5e, 0xa6, 0xd5, 0x7f } }; - -// {40017871-50A9-48b6-BF60-BD181A227F9B} -FOOGUIDDECL const GUID packet_decoder::owner_MP4_AMR = -{ 0x40017871, 0x50a9, 0x48b6, { 0xbf, 0x60, 0xbd, 0x18, 0x1a, 0x22, 0x7f, 0x9b } }; - -// {2E729EA0-6BEB-4392-BF24-75C69B60166D} -FOOGUIDDECL const GUID packet_decoder::owner_MP4_AMR_WB = -{ 0x2e729ea0, 0x6beb, 0x4392, { 0xbf, 0x24, 0x75, 0xc6, 0x9b, 0x60, 0x16, 0x6d } }; - -// {AF5B7CB0-A08E-404a-A3C0-5C5EA1A8A05C} -FOOGUIDDECL const GUID packet_decoder::owner_ADTS = -{ 0xaf5b7cb0, 0xa08e, 0x404a, { 0xa3, 0xc0, 0x5c, 0x5e, 0xa1, 0xa8, 0xa0, 0x5c } }; - -// {F72D2EAE-835C-4dfb-97C6-624343EFAFB0} -FOOGUIDDECL const GUID packet_decoder::owner_ADIF = -{ 0xf72d2eae, 0x835c, 0x4dfb, { 0x97, 0xc6, 0x62, 0x43, 0x43, 0xef, 0xaf, 0xb0 } }; - -// {5C2DE804-EAEE-4b8e-8C14-9207A2549BBE} -FOOGUIDDECL const GUID packet_decoder::owner_matroska = -{ 0x5c2de804, 0xeaee, 0x4b8e, { 0x8c, 0x14, 0x92, 0x7, 0xa2, 0x54, 0x9b, 0xbe } }; - -// {7B741A69-1AC7-440d-A01D-88536DD4DE1C} -FOOGUIDDECL const GUID packet_decoder::owner_MP3 = -{ 0x7b741a69, 0x1ac7, 0x440d, { 0xa0, 0x1d, 0x88, 0x53, 0x6d, 0xd4, 0xde, 0x1c } }; - -// {17B300A0-3110-4400-A434-C18FBEEABA81} -FOOGUIDDECL const GUID packet_decoder::owner_MP2 = -{ 0x17b300a0, 0x3110, 0x4400, { 0xa4, 0x34, 0xc1, 0x8f, 0xbe, 0xea, 0xba, 0x81 } }; - -// {1C068E5E-DD65-4639-BF85-78B297C8FFAC} -FOOGUIDDECL const GUID packet_decoder::owner_MP1 = -{ 0x1c068e5e, 0xdd65, 0x4639, { 0xbf, 0x85, 0x78, 0xb2, 0x97, 0xc8, 0xff, 0xac } }; - -// {BC73F9FC-0107-480e-BF0E-BE58AF7AF328} -FOOGUIDDECL const GUID packet_decoder::property_samplerate = -{ 0xbc73f9fc, 0x107, 0x480e, { 0xbf, 0xe, 0xbe, 0x58, 0xaf, 0x7a, 0xf3, 0x28 } }; - -// {E5D19AAD-931B-48ac-AA6E-95E2C23BEC37} -FOOGUIDDECL const GUID packet_decoder::property_bitspersample = -{ 0xe5d19aad, 0x931b, 0x48ac, { 0xaa, 0x6e, 0x95, 0xe2, 0xc2, 0x3b, 0xec, 0x37 } }; - -// {1AFA1145-E774-4c26-91D6-3F5DD61E260E} -FOOGUIDDECL const GUID packet_decoder::property_channels = -{ 0x1afa1145, 0xe774, 0x4c26, { 0x91, 0xd6, 0x3f, 0x5d, 0xd6, 0x1e, 0x26, 0xe } }; - -// {29C556DA-065A-4d24-8A11-0F9DBC05A817} -FOOGUIDDECL const GUID packet_decoder::property_byteorder = -{ 0x29c556da, 0x65a, 0x4d24, { 0x8a, 0x11, 0xf, 0x9d, 0xbc, 0x5, 0xa8, 0x17 } }; - -// {0759C32F-E78E-4479-B0C0-B653DFA014D8} -FOOGUIDDECL const GUID packet_decoder::property_signed = -{ 0x759c32f, 0xe78e, 0x4479, { 0xb0, 0xc0, 0xb6, 0x53, 0xdf, 0xa0, 0x14, 0xd8 } }; - -// {BB31669E-0C30-4c5f-AAF0-20CD49D46058} -FOOGUIDDECL const GUID packet_decoder::property_channelmask = -{ 0xbb31669e, 0xc30, 0x4c5f, { 0xaa, 0xf0, 0x20, 0xcd, 0x49, 0xd4, 0x60, 0x58 } }; - -// {6F441057-1D18-4a58-9AC4-8F409CDA7DFD} -FOOGUIDDECL const GUID standard_commands::guid_context_file_properties = -{ 0x6f441057, 0x1d18, 0x4a58, { 0x9a, 0xc4, 0x8f, 0x40, 0x9c, 0xda, 0x7d, 0xfd } }; - -// {EFC1E9C8-EEEF-427a-8F42-E5781605846D} -FOOGUIDDECL const GUID standard_commands::guid_context_file_open_directory = -{ 0xefc1e9c8, 0xeeef, 0x427a, { 0x8f, 0x42, 0xe5, 0x78, 0x16, 0x5, 0x84, 0x6d } }; - -// {FFE18008-BCA2-4b29-AB88-8816B492C434} -FOOGUIDDECL const GUID standard_commands::guid_context_copy_names = -{ 0xffe18008, 0xbca2, 0x4b29, { 0xab, 0x88, 0x88, 0x16, 0xb4, 0x92, 0xc4, 0x34 } }; - -// {44B8F02B-5408-4361-8240-18DEC881B95E} -FOOGUIDDECL const GUID standard_commands::guid_context_send_to_playlist = -{ 0x44b8f02b, 0x5408, 0x4361, { 0x82, 0x40, 0x18, 0xde, 0xc8, 0x81, 0xb9, 0x5e } }; - -// {8C3BA2CB-BC4D-4752-8282-C6F9AED75A78} -FOOGUIDDECL const GUID standard_commands::guid_context_reload_info = -{ 0x8c3ba2cb, 0xbc4d, 0x4752, { 0x82, 0x82, 0xc6, 0xf9, 0xae, 0xd7, 0x5a, 0x78 } }; - -// {BD045EA4-E5E9-4206-8FF9-12AD9F5DCDE1} -FOOGUIDDECL const GUID standard_commands::guid_context_reload_info_if_changed = -{ 0xbd045ea4, 0xe5e9, 0x4206, { 0x8f, 0xf9, 0x12, 0xad, 0x9f, 0x5d, 0xcd, 0xe1 } }; - -// {684D9FBB-4383-44a2-9789-7EE1376209C6} -FOOGUIDDECL const GUID standard_commands::guid_context_rewrite_info = -{ 0x684d9fbb, 0x4383, 0x44a2, { 0x97, 0x89, 0x7e, 0xe1, 0x37, 0x62, 0x9, 0xc6 } }; - -// {860179B7-962F-4340-ACAD-0DDAF060A6B8} -FOOGUIDDECL const GUID standard_commands::guid_context_remove_tags = -{ 0x860179b7, 0x962f, 0x4340, { 0xac, 0xad, 0xd, 0xda, 0xf0, 0x60, 0xa6, 0xb8 } }; - -// {A7E7ECB7-1943-4907-83B3-60E92353C7FA} -FOOGUIDDECL const GUID standard_commands::guid_context_convert_run = -{ 0xa7e7ecb7, 0x1943, 0x4907, { 0x83, 0xb3, 0x60, 0xe9, 0x23, 0x53, 0xc7, 0xfa } }; - -// {BED4FB6E-C4F2-40dd-B528-1DE1450DDFE9} -FOOGUIDDECL const GUID standard_commands::guid_context_convert_run_withcue = -{ 0xbed4fb6e, 0xc4f2, 0x40dd, { 0xb5, 0x28, 0x1d, 0xe1, 0x45, 0xd, 0xdf, 0xe9 } }; - -// {A58AE6EA-A34F-4879-B25C-F31F2CBC4DA9} -FOOGUIDDECL const GUID standard_commands::guid_context_convert_run_singlefile = -{ 0xa58ae6ea, 0xa34f, 0x4879, { 0xb2, 0x5c, 0xf3, 0x1f, 0x2c, 0xbc, 0x4d, 0xa9 } }; - -// {A8EFA42D-76CB-42bc-8803-70516567B13D} -FOOGUIDDECL const GUID standard_commands::guid_context_write_cd = -{ 0xa8efa42d, 0x76cb, 0x42bc, { 0x88, 0x3, 0x70, 0x51, 0x65, 0x67, 0xb1, 0x3d } }; - -// {487DAED1-02FB-4336-A813-5E90317AB041} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_track = -{ 0x487daed1, 0x2fb, 0x4336, { 0xa8, 0x13, 0x5e, 0x90, 0x31, 0x7a, 0xb0, 0x41 } }; - -// {3850F34C-F619-4296-B8A0-26C617B1D16C} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_album = -{ 0x3850f34c, 0xf619, 0x4296, { 0xb8, 0xa0, 0x26, 0xc6, 0x17, 0xb1, 0xd1, 0x6c } }; - -// {6A2DBA02-260C-436f-8F41-0190A4298266} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_album_multi = -{ 0x6a2dba02, 0x260c, 0x436f, { 0x8f, 0x41, 0x1, 0x90, 0xa4, 0x29, 0x82, 0x66 } }; - -// {54C82A92-5824-4381-8D1B-79FBB1E2ABB8} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_remove = -{ 0x54c82a92, 0x5824, 0x4381, { 0x8d, 0x1b, 0x79, 0xfb, 0xb1, 0xe2, 0xab, 0xb8 } }; - -// {69EAA594-13D9-4237-9BD7-11A39FDD1454} -FOOGUIDDECL const GUID standard_commands::guid_context_save_playlist = -{ 0x69eaa594, 0x13d9, 0x4237, { 0x9b, 0xd7, 0x11, 0xa3, 0x9f, 0xdd, 0x14, 0x54 } }; - -// {2BEB6836-C657-40ef-BB6E-D5B222AB89CE} -FOOGUIDDECL const GUID standard_commands::guid_context_masstag_edit = -{ 0x2beb6836, 0xc657, 0x40ef, { 0xbb, 0x6e, 0xd5, 0xb2, 0x22, 0xab, 0x89, 0xce } }; - -// {A579FF07-5D0B-48ed-A071-B6FCE4385AA9} -FOOGUIDDECL const GUID standard_commands::guid_context_masstag_rename = -{ 0xa579ff07, 0x5d0b, 0x48ed, { 0xa0, 0x71, 0xb6, 0xfc, 0xe4, 0x38, 0x5a, 0xa9 } }; - -// {77CFBCD0-98DC-4015-B327-D7142C664806} -FOOGUIDDECL const GUID standard_commands::guid_main_always_on_top = -{ 0x77cfbcd0, 0x98dc, 0x4015, { 0xb3, 0x27, 0xd7, 0x14, 0x2c, 0x66, 0x48, 0x6 } }; - -// {11213A01-9F36-4e69-A1BB-7A72F418DE3A} -FOOGUIDDECL const GUID standard_commands::guid_main_preferences = -{ 0x11213a01, 0x9f36, 0x4e69, { 0xa1, 0xbb, 0x7a, 0x72, 0xf4, 0x18, 0xde, 0x3a } }; - -// {EDA23441-5D38-4499-A22C-FE0CE0A987D9} -FOOGUIDDECL const GUID standard_commands::guid_main_about = -{ 0xeda23441, 0x5d38, 0x4499, { 0xa2, 0x2c, 0xfe, 0xc, 0xe0, 0xa9, 0x87, 0xd9 } }; - -// {6D38C73A-15D8-472c-8E68-6F946B82ECB4} -FOOGUIDDECL const GUID standard_commands::guid_main_exit = -{ 0x6d38c73a, 0x15d8, 0x472c, { 0x8e, 0x68, 0x6f, 0x94, 0x6b, 0x82, 0xec, 0xb4 } }; - -// {EF9B60FE-CB03-4c40-A8FD-3F1821020B37} -FOOGUIDDECL const GUID standard_commands::guid_main_restart = -{ 0xef9b60fe, 0xcb03, 0x4c40, { 0xa8, 0xfd, 0x3f, 0x18, 0x21, 0x2, 0xb, 0x37 } }; - -// {90500F09-F16F-415e-A047-AC5045C95FFE} -FOOGUIDDECL const GUID standard_commands::guid_main_activate = -{ 0x90500f09, 0xf16f, 0x415e, { 0xa0, 0x47, 0xac, 0x50, 0x45, 0xc9, 0x5f, 0xfe } }; - -// {13C17E8D-0D6F-41a4-B24A-59371043E925} -FOOGUIDDECL const GUID standard_commands::guid_main_hide = -{ 0x13c17e8d, 0xd6f, 0x41a4, { 0xb2, 0x4a, 0x59, 0x37, 0x10, 0x43, 0xe9, 0x25 } }; - -// {D9473FB2-BF11-4be0-972F-0E43F166A118} -FOOGUIDDECL const GUID standard_commands::guid_main_activate_or_hide = -{ 0xd9473fb2, 0xbf11, 0x4be0, { 0x97, 0x2f, 0xe, 0x43, 0xf1, 0x66, 0xa1, 0x18 } }; - -// {91E349DA-8800-42e5-BC8C-F3A92577AE84} -FOOGUIDDECL const GUID standard_commands::guid_main_titleformat_help = -{ 0x91e349da, 0x8800, 0x42e5, { 0xbc, 0x8c, 0xf3, 0xa9, 0x25, 0x77, 0xae, 0x84 } }; - -// {FBCFE01C-6C57-4e6a-A9F1-62334640DC91} -FOOGUIDDECL const GUID standard_commands::guid_main_playback_follows_cursor= -{ 0xfbcfe01c, 0x6c57, 0x4e6a, { 0xa9, 0xf1, 0x62, 0x33, 0x46, 0x40, 0xdc, 0x91 } }; - -// {0E1C730A-1EA9-41cc-9C30-25700ABDD9FA} -FOOGUIDDECL const GUID standard_commands::guid_main_cursor_follows_playback= -{ 0xe1c730a, 0x1ea9, 0x41cc, { 0x9c, 0x30, 0x25, 0x70, 0xa, 0xbd, 0xd9, 0xfa } }; - -// {E58895A0-A2F0-45b6-8799-1440E4DB7284} -FOOGUIDDECL const GUID standard_commands::guid_main_next = -{ 0xe58895a0, 0xa2f0, 0x45b6, { 0x87, 0x99, 0x14, 0x40, 0xe4, 0xdb, 0x72, 0x84 } }; - -// {059C4566-4708-4ebf-8139-6A8EA5A9DFC8} -FOOGUIDDECL const GUID standard_commands::guid_main_previous = -{ 0x59c4566, 0x4708, 0x4ebf, { 0x81, 0x39, 0x6a, 0x8e, 0xa5, 0xa9, 0xdf, 0xc8 } }; - -// {18B1278A-F1BB-4b48-BC3D-6EC9EF80AD19} -FOOGUIDDECL const GUID standard_commands::guid_main_next_or_random = -{ 0x18b1278a, 0xf1bb, 0x4b48, { 0xbc, 0x3d, 0x6e, 0xc9, 0xef, 0x80, 0xad, 0x19 } }; - -// {42BDA765-30A8-40fa-BFA4-6A4E2F2B2CE9} -FOOGUIDDECL const GUID standard_commands::guid_main_random = -{ 0x42bda765, 0x30a8, 0x40fa, { 0xbf, 0xa4, 0x6a, 0x4e, 0x2f, 0x2b, 0x2c, 0xe9 } }; - -// {FCEF5262-7FA5-452e-A527-C14E0CB582DE} -FOOGUIDDECL const GUID standard_commands::guid_main_pause = -{ 0xfcef5262, 0x7fa5, 0x452e, { 0xa5, 0x27, 0xc1, 0x4e, 0xc, 0xb5, 0x82, 0xde } }; - -// {D3F83B15-D4AF-4586-8BD0-4EA415E31FE1} -FOOGUIDDECL const GUID standard_commands::guid_main_play = -{ 0xd3f83b15, 0xd4af, 0x4586, { 0x8b, 0xd0, 0x4e, 0xa4, 0x15, 0xe3, 0x1f, 0xe1 } }; - -// {8DEBC44E-EDA2-48d4-8696-31FC29D1F383} -FOOGUIDDECL const GUID standard_commands::guid_main_play_or_pause = -{ 0x8debc44e, 0xeda2, 0x48d4, { 0x86, 0x96, 0x31, 0xfc, 0x29, 0xd1, 0xf3, 0x83 } }; - -// {2DF17F25-80B9-4a43-B21D-620458FDDE1E} -FOOGUIDDECL const GUID standard_commands::guid_main_rg_set_album = -{ 0x2df17f25, 0x80b9, 0x4a43, { 0xb2, 0x1d, 0x62, 0x4, 0x58, 0xfd, 0xde, 0x1e } }; - -// {C26F1955-5753-4836-887F-84A563DD6DD9} -FOOGUIDDECL const GUID standard_commands::guid_main_rg_set_track = -{ 0xc26f1955, 0x5753, 0x4836, { 0x88, 0x7f, 0x84, 0xa5, 0x63, 0xdd, 0x6d, 0xd9 } }; - -// {8D2D808E-6AA2-455b-A2F1-CDB019328140} -FOOGUIDDECL const GUID standard_commands::guid_main_rg_disable = -{ 0x8d2d808e, 0x6aa2, 0x455b, { 0xa2, 0xf1, 0xcd, 0xb0, 0x19, 0x32, 0x81, 0x40 } }; - -// {C3378028-165F-4374-966C-2FA2E0FCD3A8} -FOOGUIDDECL const GUID standard_commands::guid_main_stop = -{ 0xc3378028, 0x165f, 0x4374, { 0x96, 0x6c, 0x2f, 0xa2, 0xe0, 0xfc, 0xd3, 0xa8 } }; - -// {EE057982-22F9-4862-A986-859E463316FB} -FOOGUIDDECL const GUID standard_commands::guid_main_stop_after_current = -{ 0xee057982, 0x22f9, 0x4862, { 0xa9, 0x86, 0x85, 0x9e, 0x46, 0x33, 0x16, 0xfb } }; - -// {11DC6526-73C4-44f0-91B1-DE5C2D26B0C7} -FOOGUIDDECL const GUID standard_commands::guid_main_volume_down = -{ 0x11dc6526, 0x73c4, 0x44f0, { 0x91, 0xb1, 0xde, 0x5c, 0x2d, 0x26, 0xb0, 0xc7 } }; - -// {A313E630-A04A-4ae8-B5B4-0A944AC964FF} -FOOGUIDDECL const GUID standard_commands::guid_main_volume_up = -{ 0xa313e630, 0xa04a, 0x4ae8, { 0xb5, 0xb4, 0xa, 0x94, 0x4a, 0xc9, 0x64, 0xff } }; - -// {4A36285B-B4AF-46ed-A1AA-6333057F485B} -FOOGUIDDECL const GUID standard_commands::guid_main_volume_mute = -{ 0x4a36285b, 0xb4af, 0x46ed, { 0xa1, 0xaa, 0x63, 0x33, 0x5, 0x7f, 0x48, 0x5b } }; - -// {2DC43C22-CA09-4ef9-A61E-7A0C1DAAE21E} -FOOGUIDDECL const GUID standard_commands::guid_main_add_directory = -{ 0x2dc43c22, 0xca09, 0x4ef9, { 0xa6, 0x1e, 0x7a, 0xc, 0x1d, 0xaa, 0xe2, 0x1e } }; - -// {FC89C278-4475-4853-96C9-F7F05E8CC837} -FOOGUIDDECL const GUID standard_commands::guid_main_add_files = -{ 0xfc89c278, 0x4475, 0x4853, { 0x96, 0xc9, 0xf7, 0xf0, 0x5e, 0x8c, 0xc8, 0x37 } }; - -// {9CA39D38-AC9B-4cca-B0CE-C0F62D188114} -FOOGUIDDECL const GUID standard_commands::guid_main_add_location = -{ 0x9ca39d38, 0xac9b, 0x4cca, { 0xb0, 0xce, 0xc0, 0xf6, 0x2d, 0x18, 0x81, 0x14 } }; - -// {73D6E69D-0DC9-4d5c-A7EE-FF4BE3896B08} -FOOGUIDDECL const GUID standard_commands::guid_main_add_playlist = -{ 0x73d6e69d, 0xdc9, 0x4d5c, { 0xa7, 0xee, 0xff, 0x4b, 0xe3, 0x89, 0x6b, 0x8 } }; - -// {55559142-7AEA-4c20-9B72-1D48E970A274} -FOOGUIDDECL const GUID standard_commands::guid_main_clear_playlist = -{ 0x55559142, 0x7aea, 0x4c20, { 0x9b, 0x72, 0x1d, 0x48, 0xe9, 0x70, 0xa2, 0x74 } }; - -// {BF72488F-36AC-46b3-A36D-193E60C79BC5} -FOOGUIDDECL const GUID standard_commands::guid_main_create_playlist = -{ 0xbf72488f, 0x36ac, 0x46b3, { 0xa3, 0x6d, 0x19, 0x3e, 0x60, 0xc7, 0x9b, 0xc5 } }; - -// {59E99BEE-42A3-4526-B06D-56C0C49F0BC1} -FOOGUIDDECL const GUID standard_commands::guid_main_highlight_playing = -{ 0x59e99bee, 0x42a3, 0x4526, { 0xb0, 0x6d, 0x56, 0xc0, 0xc4, 0x9f, 0xb, 0xc1 } }; - -// {D94393D4-9DBB-4e5c-BE8C-BE9CA80E214D} -FOOGUIDDECL const GUID standard_commands::guid_main_load_playlist = -{ 0xd94393d4, 0x9dbb, 0x4e5c, { 0xbe, 0x8c, 0xbe, 0x9c, 0xa8, 0xe, 0x21, 0x4d } }; - -// {EE1308C5-EBD2-48f1-959D-2627069C2E0F} -FOOGUIDDECL const GUID standard_commands::guid_main_next_playlist = -{ 0xee1308c5, 0xebd2, 0x48f1, { 0x95, 0x9d, 0x26, 0x27, 0x6, 0x9c, 0x2e, 0xf } }; - -// {486ECDA3-7BA2-49e9-BB44-4DB9DF9320C7} -FOOGUIDDECL const GUID standard_commands::guid_main_previous_playlist = -{ 0x486ecda3, 0x7ba2, 0x49e9, { 0xbb, 0x44, 0x4d, 0xb9, 0xdf, 0x93, 0x20, 0xc7 } }; - -// {69C778AA-B836-40a0-89CD-7A2E50C102CB} -FOOGUIDDECL const GUID standard_commands::guid_main_open = -{ 0x69c778aa, 0xb836, 0x40a0, { 0x89, 0xcd, 0x7a, 0x2e, 0x50, 0xc1, 0x2, 0xcb } }; - -// {EB7FB5A4-5904-4d2c-B66C-D882A3B15277} -FOOGUIDDECL const GUID standard_commands::guid_main_remove_playlist = -{ 0xeb7fb5a4, 0x5904, 0x4d2c, { 0xb6, 0x6c, 0xd8, 0x82, 0xa3, 0xb1, 0x52, 0x77 } }; - -// {C297BADB-8098-45a9-A5E8-B53A0D780CE3} -FOOGUIDDECL const GUID standard_commands::guid_main_remove_dead_entries = -{ 0xc297badb, 0x8098, 0x45a9, { 0xa5, 0xe8, 0xb5, 0x3a, 0xd, 0x78, 0xc, 0xe3 } }; - -// {D08C2921-7750-4979-98F9-3A513A31FF96} -FOOGUIDDECL const GUID standard_commands::guid_main_remove_duplicates = -{ 0xd08c2921, 0x7750, 0x4979, { 0x98, 0xf9, 0x3a, 0x51, 0x3a, 0x31, 0xff, 0x96 } }; - -// {D3A25E47-BA98-4e6b-95AD-A7502919EB75} -FOOGUIDDECL const GUID standard_commands::guid_main_rename_playlist = -{ 0xd3a25e47, 0xba98, 0x4e6b, { 0x95, 0xad, 0xa7, 0x50, 0x29, 0x19, 0xeb, 0x75 } }; - -// {0FDCFC65-9B39-445a-AA88-4D245F217480} -FOOGUIDDECL const GUID standard_commands::guid_main_save_all_playlists = -{ 0xfdcfc65, 0x9b39, 0x445a, { 0xaa, 0x88, 0x4d, 0x24, 0x5f, 0x21, 0x74, 0x80 } }; - -// {370B720B-4CF7-465b-908C-2D2ADD027900} -FOOGUIDDECL const GUID standard_commands::guid_main_save_playlist = -{ 0x370b720b, 0x4cf7, 0x465b, { 0x90, 0x8c, 0x2d, 0x2a, 0xdd, 0x2, 0x79, 0x0 } }; - -// {A6CFC2A8-56B3-4d12-88E7-0237961AC47E} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_search = -{ 0xa6cfc2a8, 0x56b3, 0x4d12, { 0x88, 0xe7, 0x2, 0x37, 0x96, 0x1a, 0xc4, 0x7e } }; - -// {383D4E8D-7E30-4fb8-B5DD-8C975D89E58E} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_crop = -{ 0x383d4e8d, 0x7e30, 0x4fb8, { 0xb5, 0xdd, 0x8c, 0x97, 0x5d, 0x89, 0xe5, 0x8e } }; - -// {E0EEA319-E282-4e6c-8B82-4DFD42A1D4ED} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_remove = -{ 0xe0eea319, 0xe282, 0x4e6c, { 0x8b, 0x82, 0x4d, 0xfd, 0x42, 0xa1, 0xd4, 0xed } }; - -// {F0845920-7F6D-40ac-B2EB-3D00C2C8260B} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_invert = -{ 0xf0845920, 0x7f6d, 0x40ac, { 0xb2, 0xeb, 0x3d, 0x0, 0xc2, 0xc8, 0x26, 0xb } }; - -// {29910B33-79E9-40da-992B-5A4AA4281F78} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_undo = -{ 0x29910b33, 0x79e9, 0x40da, { 0x99, 0x2b, 0x5a, 0x4a, 0xa4, 0x28, 0x1f, 0x78 } }; - -// {7A9D9450-A8BF-4a88-B44F-DCD83A49DD7A} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_redo = -{ 0x7a9d9450, 0xa8bf, 0x4a88, { 0xb4, 0x4f, 0xdc, 0xd8, 0x3a, 0x49, 0xdd, 0x7a } }; - -// {02D89A8A-5F7D-41c3-A215-6731D8621036} -FOOGUIDDECL const GUID standard_commands::guid_main_show_console = -{ 0x2d89a8a, 0x5f7d, 0x41c3, { 0xa2, 0x15, 0x67, 0x31, 0xd8, 0x62, 0x10, 0x36 } }; - -// {E6970E91-33BE-4288-AC01-4B02F07B5D38} -FOOGUIDDECL const GUID standard_commands::guid_main_play_cd = -{ 0xe6970e91, 0x33be, 0x4288, { 0xac, 0x1, 0x4b, 0x2, 0xf0, 0x7b, 0x5d, 0x38 } }; - -// {1073AB1D-38ED-4957-8B06-38BC878C1F40} -FOOGUIDDECL const GUID standard_commands::guid_main_restart_resetconfig = -{ 0x1073ab1d, 0x38ed, 0x4957, { 0x8b, 0x6, 0x38, 0xbc, 0x87, 0x8c, 0x1f, 0x40 } }; - -// {FDC8A1C2-93EF-4415-8C20-60B6517F0B5F} -FOOGUIDDECL const GUID standard_commands::guid_main_record = -{ 0xfdc8a1c2, 0x93ef, 0x4415, { 0x8c, 0x20, 0x60, 0xb6, 0x51, 0x7f, 0xb, 0x5f } }; - -// {45EB37D2-3CD9-4f0a-9B20-8EAE649D7A9F} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_moveback = -{ 0x45eb37d2, 0x3cd9, 0x4f0a, { 0x9b, 0x20, 0x8e, 0xae, 0x64, 0x9d, 0x7a, 0x9f } }; - -// {02298938-596A-41f7-A398-19766A06E6EB} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_moveforward = -{ 0x2298938, 0x596a, 0x41f7, { 0xa3, 0x98, 0x19, 0x76, 0x6a, 0x6, 0xe6, 0xeb } }; - -// {E910ACC6-A81A-4a20-9F62-19015BCD1013} -FOOGUIDDECL const GUID standard_commands::guid_main_saveconfig = -{ 0xe910acc6, 0xa81a, 0x4a20, { 0x9f, 0x62, 0x19, 0x1, 0x5b, 0xcd, 0x10, 0x13 } }; - -// {03445FCC-71D9-4e01-AE02-A557D30B4CD7} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_select_all = -{ 0x3445fcc, 0x71d9, 0x4e01, { 0xae, 0x2, 0xa5, 0x57, 0xd3, 0xb, 0x4c, 0xd7 } }; - -// {919FA72B-1DF9-49ee-A8F1-D8BA1DEAA7E9} -FOOGUIDDECL const GUID standard_commands::guid_main_show_now_playing = -{ 0x919fa72b, 0x1df9, 0x49ee, { 0xa8, 0xf1, 0xd8, 0xba, 0x1d, 0xea, 0xa7, 0xe9 } }; - -// {D8D51855-D79D-49b8-97A8-065785FA2426} -FOOGUIDDECL const GUID playlist_manager::class_guid= -{ 0xd8d51855, 0xd79d, 0x49b8, { 0x97, 0xa8, 0x6, 0x57, 0x85, 0xfa, 0x24, 0x26 } }; - -// {C303A0F1-8E88-4539-87E5-9E455B7D548C} -FOOGUIDDECL const GUID genrand_service::class_guid= -{ 0xc303a0f1, 0x8e88, 0x4539, { 0x87, 0xe5, 0x9e, 0x45, 0x5b, 0x7d, 0x54, 0x8c } }; - -// {EB8FA333-F365-46ad-8621-345671567BAA} -FOOGUIDDECL const GUID playlist_incoming_item_filter::class_guid= -{ 0xeb8fa333, 0xf365, 0x46ad, { 0x86, 0x21, 0x34, 0x56, 0x71, 0x56, 0x7b, 0xaa } }; - -// {FEBD85B5-C12D-45b5-B55D-0D3F432B0C6B} -FOOGUIDDECL const GUID library_manager::class_guid= -{ 0xfebd85b5, 0xc12d, 0x45b5, { 0xb5, 0x5d, 0xd, 0x3f, 0x43, 0x2b, 0xc, 0x6b } }; - -// {9A08B50F-E8C6-40c0-88C3-7530CF2C3115} -FOOGUIDDECL const GUID library_callback::class_guid= -{ 0x9a08b50f, 0xe8c6, 0x40c0, { 0x88, 0xc3, 0x75, 0x30, 0xcf, 0x2c, 0x31, 0x15 } }; - -// {D5CAC75A-3023-4dce-8B0D-B502BD056A7C} -FOOGUIDDECL const GUID popup_message::class_guid= -{ 0xd5cac75a, 0x3023, 0x4dce, { 0x8b, 0xd, 0xb5, 0x2, 0xbd, 0x5, 0x6a, 0x7c } }; - -// {13F9CB11-0EAE-4417-AF0C-8894DEB65E8B} -FOOGUIDDECL const GUID app_close_blocker::class_guid= -{ 0x13f9cb11, 0xeae, 0x4417, { 0xaf, 0xc, 0x88, 0x94, 0xde, 0xb6, 0x5e, 0x8b } }; - -// {5570A2D2-8F9E-48a7-AFAC-DAC00A3C1636} -FOOGUIDDECL const GUID file_operation_callback::class_guid= -{ 0x5570a2d2, 0x8f9e, 0x48a7, { 0xaf, 0xac, 0xda, 0xc0, 0xa, 0x3c, 0x16, 0x36 } }; - -// {340099D1-7BEC-4ac6-92A4-77FF01507891} -FOOGUIDDECL const GUID config_object::class_guid= -{ 0x340099d1, 0x7bec, 0x4ac6, { 0x92, 0xa4, 0x77, 0xff, 0x1, 0x50, 0x78, 0x91 } }; - -// {1BA04122-DE9A-4a90-9FC3-A6A7EC8F9626} -FOOGUIDDECL const GUID config_object_notify_manager::class_guid= -{ 0x1ba04122, 0xde9a, 0x4a90, { 0x9f, 0xc3, 0xa6, 0xa7, 0xec, 0x8f, 0x96, 0x26 } }; - -// {AD5138E6-CF8F-4482-89B2-B2EAAEDF3B4C} -FOOGUIDDECL const GUID standard_config_objects::bool_show_keyboard_shortcuts_in_menus= -{ 0xad5138e6, 0xcf8f, 0x4482, { 0x89, 0xb2, 0xb2, 0xea, 0xae, 0xdf, 0x3b, 0x4c } }; - -// {E91F618C-5741-470f-A178-21272C3ECA90} -FOOGUIDDECL const GUID standard_config_objects::bool_remember_window_positions= -{ 0xe91f618c, 0x5741, 0x470f, { 0xa1, 0x78, 0x21, 0x27, 0x2c, 0x3e, 0xca, 0x90 } }; - -// {5497FAA9-690C-4fb4-8BC0-678CEBCBBDC4} -FOOGUIDDECL const GUID standard_config_objects::bool_playback_follows_cursor= -{ 0x5497faa9, 0x690c, 0x4fb4, { 0x8b, 0xc0, 0x67, 0x8c, 0xeb, 0xcb, 0xbd, 0xc4 } }; - -// {58D3E2D6-DD6D-48dd-98EB-4EABF0ACFEB8} -FOOGUIDDECL const GUID standard_config_objects::bool_cursor_follows_playback= -{ 0x58d3e2d6, 0xdd6d, 0x48dd, { 0x98, 0xeb, 0x4e, 0xab, 0xf0, 0xac, 0xfe, 0xb8 } }; - -// {2DF7194D-86FC-4312-98DA-E820DA3E710D} -FOOGUIDDECL const GUID standard_config_objects::bool_ui_always_on_top= -{ 0x2df7194d, 0x86fc, 0x4312, { 0x98, 0xda, 0xe8, 0x20, 0xda, 0x3e, 0x71, 0xd } }; - -// {B572C86F-4206-40a0-8476-C7B27E74DB2D} -FOOGUIDDECL const GUID standard_config_objects::bool_playlist_stop_after_current= -{ 0xb572c86f, 0x4206, 0x40a0, { 0x84, 0x76, 0xc7, 0xb2, 0x7e, 0x74, 0xdb, 0x2d } }; - -// {FFDFDA96-699C-4617-A977-22DC2F039B00} -FOOGUIDDECL const GUID standard_config_objects::string_gui_last_directory_media= -{ 0xffdfda96, 0x699c, 0x4617, { 0xa9, 0x77, 0x22, 0xdc, 0x2f, 0x3, 0x9b, 0x0 } }; - -// {915D3B21-81CB-4b96-9762-1C90FBF371DF} -FOOGUIDDECL const GUID standard_config_objects::string_gui_last_directory_playlists= -{ 0x915d3b21, 0x81cb, 0x4b96, { 0x97, 0x62, 0x1c, 0x90, 0xfb, 0xf3, 0x71, 0xdf } }; - -// {338B6871-EB1F-4384-BF83-6BFACE5B66BC} -FOOGUIDDECL const GUID standard_config_objects::int32_dynamic_bitrate_display_rate= -{ 0x338b6871, 0xeb1f, 0x4384, { 0xbf, 0x83, 0x6b, 0xfa, 0xce, 0x5b, 0x66, 0xbc } }; - -// {3E35D949-DCDB-44e1-8013-9D1633C09756} -FOOGUIDDECL const GUID config_object_notify::class_guid= -{ 0x3e35d949, 0xdcdb, 0x44e1, { 0x80, 0x13, 0x9d, 0x16, 0x33, 0xc0, 0x97, 0x56 } }; - -// {4AC9408E-4D9C-4135-ACB5-2CAB35376FC9} -FOOGUIDDECL const GUID titleformat_object::class_guid= -{ 0x4ac9408e, 0x4d9c, 0x4135, { 0xac, 0xb5, 0x2c, 0xab, 0x35, 0x37, 0x6f, 0xc9 } }; - -// {25B0D20D-9BA3-4a7b-8D0E-89FAF75F916F} -FOOGUIDDECL const GUID tag_processor_id3v2::class_guid= -{ 0x25b0d20d, 0x9ba3, 0x4a7b, { 0x8d, 0xe, 0x89, 0xfa, 0xf7, 0x5f, 0x91, 0x6f } }; - -// {AD537D40-499D-4c29-81D4-C0FA496DD58C} -FOOGUIDDECL const GUID tag_processor_trailing::class_guid= -{ 0xad537d40, 0x499d, 0x4c29, { 0x81, 0xd4, 0xc0, 0xfa, 0x49, 0x6d, 0xd5, 0x8c } }; - -// {160885C6-3AA3-4f60-8718-1240615E6414} -FOOGUIDDECL const GUID metadb_handle::class_guid= -{ 0x160885c6, 0x3aa3, 0x4f60, { 0x87, 0x18, 0x12, 0x40, 0x61, 0x5e, 0x64, 0x14 } }; - -// {9DBC262F-4795-4292-824B-23A655011A3E} -FOOGUIDDECL const GUID threaded_process::class_guid= -{ 0x9dbc262f, 0x4795, 0x4292, { 0x82, 0x4b, 0x23, 0xa6, 0x55, 0x1, 0x1a, 0x3e } }; - -// {7B69141B-4271-4070-8998-10CD39249C12} -FOOGUIDDECL const GUID threaded_process_callback::class_guid= -{ 0x7b69141b, 0x4271, 0x4070, { 0x89, 0x98, 0x10, 0xcd, 0x39, 0x24, 0x9c, 0x12 } }; - - -// {64D18B80-5E97-40e4-A30C-A4640C60BCE5} -FOOGUIDDECL const GUID metadb_io::class_guid= -{ 0x64d18b80, 0x5e97, 0x40e4, { 0xa3, 0xc, 0xa4, 0x64, 0xc, 0x60, 0xbc, 0xe5 } }; - -FOOGUIDDECL const GUID preferences_page::guid_tagging = { 0x563107c3, 0xfc7d, 0x4022, { 0xa8, 0x72, 0xa8, 0x2a, 0x2b, 0x3f, 0xd5, 0x25 } }; - -// {B9218D23-F73D-4b61-A1D9-BFD420CDAC77} -FOOGUIDDECL const GUID preferences_page::guid_root= -{ 0xb9218d23, 0xf73d, 0x4b61, { 0xa1, 0xd9, 0xbf, 0xd4, 0x20, 0xcd, 0xac, 0x77 } }; - -// {2F0E2232-A5FD-43e4-B6AB-3839B8D1A707} -FOOGUIDDECL const GUID preferences_page::guid_hidden= -{ 0x2f0e2232, 0xa5fd, 0x43e4, { 0xb6, 0xab, 0x38, 0x39, 0xb8, 0xd1, 0xa7, 0x7 } }; - -// {627C0767-0793-44f8-8087-BE4934311282} -FOOGUIDDECL const GUID preferences_page::guid_tools= -{ 0x627c0767, 0x793, 0x44f8, { 0x80, 0x87, 0xbe, 0x49, 0x34, 0x31, 0x12, 0x82 } }; - -// {6AAA67B6-732F-4967-899A-18C5F8C70017} -FOOGUIDDECL const GUID preferences_page::guid_display= -{ 0x6aaa67b6, 0x732f, 0x4967, { 0x89, 0x9a, 0x18, 0xc5, 0xf8, 0xc7, 0x0, 0x17 } }; - -// {67508677-CFCC-4a1c-921C-49B39CC5B986} -FOOGUIDDECL const GUID preferences_page::guid_playback= -{ 0x67508677, 0xcfcc, 0x4a1c, { 0x92, 0x1c, 0x49, 0xb3, 0x9c, 0xc5, 0xb9, 0x86 } }; - -// {494326C8-88FF-4265-B2B2-E6470BEE13B3} -FOOGUIDDECL const GUID preferences_page::guid_visualisations= -{ 0x494326c8, 0x88ff, 0x4265, { 0xb2, 0xb2, 0xe6, 0x47, 0xb, 0xee, 0x13, 0xb3 } }; - -// {FC01B529-4BD7-47cd-BAF7-2FB632F0DBB6} -FOOGUIDDECL const GUID preferences_page::guid_input= -{ 0xfc01b529, 0x4bd7, 0x47cd, { 0xba, 0xf7, 0x2f, 0xb6, 0x32, 0xf0, 0xdb, 0xb6 } }; - -// {2E8E9647-4174-41b2-9EC4-910BE128082E} -FOOGUIDDECL const GUID preferences_page::guid_core= -{ 0x2e8e9647, 0x4174, 0x41b2, { 0x9e, 0xc4, 0x91, 0xb, 0xe1, 0x28, 0x8, 0x2e } }; - -// {7D0334E5-ADD7-4ff5-9DB8-A618B4824028} -FOOGUIDDECL const GUID preferences_page::guid_tag_writing= -{ 0x7d0334e5, 0xadd7, 0x4ff5, { 0x9d, 0xb8, 0xa6, 0x18, 0xb4, 0x82, 0x40, 0x28 } }; - -// {2D269FA9-6F78-4cec-9F1F-0A176EFCE77A} -FOOGUIDDECL const GUID preferences_page::guid_media_library= -{ 0x2d269fa9, 0x6f78, 0x4cec, { 0x9f, 0x1f, 0xa, 0x17, 0x6e, 0xfc, 0xe7, 0x7a } }; - -// {B8C5CEEA-A5F4-4278-AA2D-798E4403001F} -FOOGUIDDECL const GUID library_viewer::class_guid= -{ 0xb8c5ceea, 0xa5f4, 0x4278, { 0xaa, 0x2d, 0x79, 0x8e, 0x44, 0x3, 0x0, 0x1f } }; - -// {5CD49B5D-D604-4c07-A8FA-FFD8512AFD2B} -FOOGUIDDECL const GUID message_loop::class_guid= -{ 0x5cd49b5d, 0xd604, 0x4c07, { 0xa8, 0xfa, 0xff, 0xd8, 0x51, 0x2a, 0xfd, 0x2b } }; - -// {932EC96D-4DFD-4ed7-A07C-2A22BE770185} -FOOGUIDDECL const GUID chapterizer::class_guid= -{ 0x932ec96d, 0x4dfd, 0x4ed7, { 0xa0, 0x7c, 0x2a, 0x22, 0xbe, 0x77, 0x1, 0x85 } }; - -// {7EB442CD-FAD7-4a26-AD7E-16F6FC89207B} -FOOGUIDDECL const GUID input_decoder::class_guid = -{ 0x7eb442cd, 0xfad7, 0x4a26, { 0xad, 0x7e, 0x16, 0xf6, 0xfc, 0x89, 0x20, 0x7b } }; - -// {8E9BB1D4-A52B-4df6-A929-1AAE4075388A} -FOOGUIDDECL const GUID input_info_reader::class_guid = -{ 0x8e9bb1d4, 0xa52b, 0x4df6, { 0xa9, 0x29, 0x1a, 0xae, 0x40, 0x75, 0x38, 0x8a } }; - -// {FE40FF66-64C9-4234-B639-028DC8060CF7} -FOOGUIDDECL const GUID input_info_writer::class_guid = -{ 0xfe40ff66, 0x64c9, 0x4234, { 0xb6, 0x39, 0x2, 0x8d, 0xc8, 0x6, 0xc, 0xf7 } }; - -// {436547FC-C4EF-4322-B59E-E696A25FAB2C} -FOOGUIDDECL const GUID input_entry::class_guid = -{ 0x436547fc, 0xc4ef, 0x4322, { 0xb5, 0x9e, 0xe6, 0x96, 0xa2, 0x5f, 0xab, 0x2c } }; - -// {3296219B-EBA5-4c32-A193-C9BB174801DA} -FOOGUIDDECL const GUID link_resolver::class_guid = -{ 0x3296219b, 0xeba5, 0x4c32, { 0xa1, 0x93, 0xc9, 0xbb, 0x17, 0x48, 0x1, 0xda } }; - -// {A49E087E-D064-4b2e-A08D-11264F691FFE} -FOOGUIDDECL const GUID playback_queue_callback::class_guid = -{ 0xa49e087e, 0xd064, 0x4b2e, { 0xa0, 0x8d, 0x11, 0x26, 0x4f, 0x69, 0x1f, 0xfe } }; - -// {1131D64B-04CB-43ee-95EB-24D18B753248} -FOOGUIDDECL const GUID main_thread_callback_manager::class_guid = -{ 0x1131d64b, 0x4cb, 0x43ee, { 0x95, 0xeb, 0x24, 0xd1, 0x8b, 0x75, 0x32, 0x48 } }; - -// {87D2C583-7AFB-4e58-B21E-FBD3E6E8F5E7} -FOOGUIDDECL const GUID main_thread_callback::class_guid = -{ 0x87d2c583, 0x7afb, 0x4e58, { 0xb2, 0x1e, 0xfb, 0xd3, 0xe6, 0xe8, 0xf5, 0xe7 } }; - - - -// {21656AB9-0255-4f8c-8FB9-1A7748BCE93A} -FOOGUIDDECL const GUID mainmenu_group::class_guid = -{ 0x21656ab9, 0x255, 0x4f8c, { 0x8f, 0xb9, 0x1a, 0x77, 0x48, 0xbc, 0xe9, 0x3a } }; - -// {2E673A2E-A4EE-419c-94C8-9C838660414C} -FOOGUIDDECL const GUID mainmenu_group_popup::class_guid = -{ 0x2e673a2e, 0xa4ee, 0x419c, { 0x94, 0xc8, 0x9c, 0x83, 0x86, 0x60, 0x41, 0x4c } }; - -// {35077B8C-6E70-47ba-B9DD-D51500E12F2E} -FOOGUIDDECL const GUID mainmenu_commands::class_guid = -{ 0x35077b8c, 0x6e70, 0x47ba, { 0xb9, 0xdd, 0xd5, 0x15, 0x0, 0xe1, 0x2f, 0x2e } }; - -// {350B3EA8-6B3E-4346-B6D2-799E98EFC920} -FOOGUIDDECL const GUID mainmenu_manager::class_guid = -{ 0x350b3ea8, 0x6b3e, 0x4346, { 0xb6, 0xd2, 0x79, 0x9e, 0x98, 0xef, 0xc9, 0x20 } }; - - -// {8F487F1F-419F-47a7-8ECF-EC44AF4449A3} -FOOGUIDDECL const GUID mainmenu_groups::file = -{ 0x8f487f1f, 0x419f, 0x47a7, { 0x8e, 0xcf, 0xec, 0x44, 0xaf, 0x44, 0x49, 0xa3 } }; - -// {F8BE5604-165F-4bb9-B6A9-15E55E0E0D3A} -FOOGUIDDECL const GUID mainmenu_groups::view = -{ 0xf8be5604, 0x165f, 0x4bb9, { 0xb6, 0xa9, 0x15, 0xe5, 0x5e, 0xe, 0xd, 0x3a } }; - -// {8CDA6B10-0613-4cfd-8730-3B9CBF4C6A39} -FOOGUIDDECL const GUID mainmenu_groups::edit = -{ 0x8cda6b10, 0x613, 0x4cfd, { 0x87, 0x30, 0x3b, 0x9c, 0xbf, 0x4c, 0x6a, 0x39 } }; - -// {D8A4FC46-5E3D-47aa-97B7-947988228246} -FOOGUIDDECL const GUID mainmenu_groups::edit_part1 = -{ 0xd8a4fc46, 0x5e3d, 0x47aa, { 0x97, 0xb7, 0x94, 0x79, 0x88, 0x22, 0x82, 0x46 } }; - -// {007682CE-2A99-4b70-8F63-DE765D1C5555} -FOOGUIDDECL const GUID mainmenu_groups::edit_part2 = -{ 0x7682ce, 0x2a99, 0x4b70, { 0x8f, 0x63, 0xde, 0x76, 0x5d, 0x1c, 0x55, 0x55 } }; - -// {1F572090-D620-4940-85EC-0EFE499FAC03} -FOOGUIDDECL const GUID mainmenu_groups::edit_part3 = -{ 0x1f572090, 0xd620, 0x4940, { 0x85, 0xec, 0xe, 0xfe, 0x49, 0x9f, 0xac, 0x3 } }; - -// {65FA047A-1599-4b9c-B53D-C3FEB716339D} -FOOGUIDDECL const GUID mainmenu_groups::edit_part2_selection = -{ 0x65fa047a, 0x1599, 0x4b9c, { 0xb5, 0x3d, 0xc3, 0xfe, 0xb7, 0x16, 0x33, 0x9d } }; - -// {5B8AEF2C-6E1A-420d-B488-3E3A00E39E28} -FOOGUIDDECL const GUID mainmenu_groups::edit_part2_sort = -{ 0x5b8aef2c, 0x6e1a, 0x420d, { 0xb4, 0x88, 0x3e, 0x3a, 0x0, 0xe3, 0x9e, 0x28 } }; - -// {EE9D6F72-7BC7-4a60-8C28-B96DED252BD3} -FOOGUIDDECL const GUID mainmenu_groups::edit_part2_selection_sort = -{ 0xee9d6f72, 0x7bc7, 0x4a60, { 0x8c, 0x28, 0xb9, 0x6d, 0xed, 0x25, 0x2b, 0xd3 } }; - -// {53FA5B8A-FCBC-4296-B968-45BAE6888845} -FOOGUIDDECL const GUID mainmenu_groups::playback = -{ 0x53fa5b8a, 0xfcbc, 0x4296, { 0xb9, 0x68, 0x45, 0xba, 0xe6, 0x88, 0x88, 0x45 } }; - -// {15D22753-9D30-4929-AA14-5124016F7E68} -FOOGUIDDECL const GUID mainmenu_groups::library = -{ 0x15d22753, 0x9d30, 0x4929, { 0xaa, 0x14, 0x51, 0x24, 0x1, 0x6f, 0x7e, 0x68 } }; - -// {25DC3DB7-996A-4f48-AF53-712032EFA04F} -FOOGUIDDECL const GUID mainmenu_groups::help = -{ 0x25dc3db7, 0x996a, 0x4f48, { 0xaf, 0x53, 0x71, 0x20, 0x32, 0xef, 0xa0, 0x4f } }; - -// {8EED252D-0A0F-4fc9-9D81-8CF7209A8BF2} -FOOGUIDDECL const GUID mainmenu_groups::file_open = -{ 0x8eed252d, 0xa0f, 0x4fc9, { 0x9d, 0x81, 0x8c, 0xf7, 0x20, 0x9a, 0x8b, 0xf2 } }; - -// {9E650B8E-C3F3-4495-AF15-6B656060C3B9} -FOOGUIDDECL const GUID mainmenu_groups::file_add = -{ 0x9e650b8e, 0xc3f3, 0x4495, { 0xaf, 0x15, 0x6b, 0x65, 0x60, 0x60, 0xc3, 0xb9 } }; - -// {9995FAE6-B1C4-457f-A747-5BD120930210} -FOOGUIDDECL const GUID mainmenu_groups::file_playlist = -{ 0x9995fae6, 0xb1c4, 0x457f, { 0xa7, 0x47, 0x5b, 0xd1, 0x20, 0x93, 0x2, 0x10 } }; - -// {8A324F18-6173-42ec-A640-5E296AD446B3} -FOOGUIDDECL const GUID mainmenu_groups::file_etc = -{ 0x8a324f18, 0x6173, 0x42ec, { 0xa6, 0x40, 0x5e, 0x29, 0x6a, 0xd4, 0x46, 0xb3 } }; - -// {12F5E247-5A81-4734-8119-8F9BC114FE74} -FOOGUIDDECL const GUID mainmenu_groups::playback_controls = -{ 0x12f5e247, 0x5a81, 0x4734, { 0x81, 0x19, 0x8f, 0x9b, 0xc1, 0x14, 0xfe, 0x74 } }; - -// {1169B3EB-81B5-4199-8929-7D3EAFD4809F} -FOOGUIDDECL const GUID mainmenu_groups::playback_etc = -{ 0x1169b3eb, 0x81b5, 0x4199, { 0x89, 0x29, 0x7d, 0x3e, 0xaf, 0xd4, 0x80, 0x9f } }; - -// {29272FEC-21C7-4b00-A9A7-01A8CE675EBF} -FOOGUIDDECL const GUID mainmenu_groups::view_visualisations = -{ 0x29272fec, 0x21c7, 0x4b00, { 0xa9, 0xa7, 0x1, 0xa8, 0xce, 0x67, 0x5e, 0xbf } }; - -// {2DA055D4-0257-40b2-8281-7967866B485C} -FOOGUIDDECL const GUID mainmenu_groups::file_etc_preferences = -{ 0x2da055d4, 0x257, 0x40b2, { 0x82, 0x81, 0x79, 0x67, 0x86, 0x6b, 0x48, 0x5c } }; - -// {517BFAE8-A148-4cb2-8CCE-1AD2179FB910} -FOOGUIDDECL const GUID mainmenu_groups::file_etc_exit = -{ 0x517bfae8, 0xa148, 0x4cb2, { 0x8c, 0xce, 0x1a, 0xd2, 0x17, 0x9f, 0xb9, 0x10 } }; - -// {61190F78-3B3A-4fda-A431-2CF7DA1C96CE} -FOOGUIDDECL const GUID mainmenu_groups::view_alwaysontop = -{ 0x61190f78, 0x3b3a, 0x4fda, { 0xa4, 0x31, 0x2c, 0xf7, 0xda, 0x1c, 0x96, 0xce } }; - -// {E55F8D65-AE51-47bf-99F9-BB113421CB19} -FOOGUIDDECL const GUID mainmenu_groups::help_about = -{ 0xe55f8d65, 0xae51, 0x47bf, { 0x99, 0xf9, 0xbb, 0x11, 0x34, 0x21, 0xcb, 0x19 } }; - -// {696DF823-B7AE-4b73-95C8-C1E9A9410726} -FOOGUIDDECL const GUID mainmenu_groups::library_refresh= -{ 0x696df823, 0xb7ae, 0x4b73, { 0x95, 0xc8, 0xc1, 0xe9, 0xa9, 0x41, 0x7, 0x26 } }; - -// {004BF6ED-2F88-464f-BDC1-278F6E610C2F} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_1s = -{ 0x4bf6ed, 0x2f88, 0x464f, { 0xbd, 0xc1, 0x27, 0x8f, 0x6e, 0x61, 0xc, 0x2f } }; - -// {5B56D124-2ECA-4b0f-9895-2A533B31D29E} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_5s = -{ 0x5b56d124, 0x2eca, 0x4b0f, { 0x98, 0x95, 0x2a, 0x53, 0x3b, 0x31, 0xd2, 0x9e } }; - -// {B582E3CA-D86D-4568-8380-68BC9C93ED0E} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_10s = -{ 0xb582e3ca, 0xd86d, 0x4568, { 0x83, 0x80, 0x68, 0xbc, 0x9c, 0x93, 0xed, 0xe } }; - -// {DE6B96B7-3074-4da9-A260-988E31CEE0F9} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_30s = -{ 0xde6b96b7, 0x3074, 0x4da9, { 0xa2, 0x60, 0x98, 0x8e, 0x31, 0xce, 0xe0, 0xf9 } }; - -// {FEED4AD7-13D2-4846-8833-D91B5F8B4E94} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_1min = -{ 0xfeed4ad7, 0x13d2, 0x4846, { 0x88, 0x33, 0xd9, 0x1b, 0x5f, 0x8b, 0x4e, 0x94 } }; - -// {ECCF4904-03CF-429a-9D99-7A87FA62FD10} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_2min = -{ 0xeccf4904, 0x3cf, 0x429a, { 0x9d, 0x99, 0x7a, 0x87, 0xfa, 0x62, 0xfd, 0x10 } }; - -// {5F0F0AF7-F519-41e6-A8DB-04DF1390E69D} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_5min = -{ 0x5f0f0af7, 0xf519, 0x41e6, { 0xa8, 0xdb, 0x4, 0xdf, 0x13, 0x90, 0xe6, 0x9d } }; - -// {9ABA4292-1B8F-42ac-93AC-34B2A74C6320} -FOOGUIDDECL const GUID standard_commands::guid_seek_ahead_10min = -{ 0x9aba4292, 0x1b8f, 0x42ac, { 0x93, 0xac, 0x34, 0xb2, 0xa7, 0x4c, 0x63, 0x20 } }; - -// {2F89AB1C-5646-4997-8E3F-92BEE0322A41} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_1s = -{ 0x2f89ab1c, 0x5646, 0x4997, { 0x8e, 0x3f, 0x92, 0xbe, 0xe0, 0x32, 0x2a, 0x41 } }; - -// {0CE84538-2E21-4482-BFE1-BCEC471467CC} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_5s = -{ 0xce84538, 0x2e21, 0x4482, { 0xbf, 0xe1, 0xbc, 0xec, 0x47, 0x14, 0x67, 0xcc } }; - -// {9F504218-AF5D-41a8-BCE3-26313FAE65EE} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_10s = -{ 0x9f504218, 0xaf5d, 0x41a8, { 0xbc, 0xe3, 0x26, 0x31, 0x3f, 0xae, 0x65, 0xee } }; - -// {98239B89-F66E-4160-B650-D9B068C59E63} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_30s = -{ 0x98239b89, 0xf66e, 0x4160, { 0xb6, 0x50, 0xd9, 0xb0, 0x68, 0xc5, 0x9e, 0x63 } }; - -// {6633226B-9AA9-4810-AFDA-185A281D9FE2} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_1min = -{ 0x6633226b, 0x9aa9, 0x4810, { 0xaf, 0xda, 0x18, 0x5a, 0x28, 0x1d, 0x9f, 0xe2 } }; - -// {E2F8B8BB-C539-44f3-A300-13185DE52227} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_2min = -{ 0xe2f8b8bb, 0xc539, 0x44f3, { 0xa3, 0x0, 0x13, 0x18, 0x5d, 0xe5, 0x22, 0x27 } }; - -// {7B41A130-01D2-4a1b-9CAD-6314633C61C4} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_5min = -{ 0x7b41a130, 0x1d2, 0x4a1b, { 0x9c, 0xad, 0x63, 0x14, 0x63, 0x3c, 0x61, 0xc4 } }; - -// {0B012852-BAF9-4f6b-B947-FAB89AE76B79} -FOOGUIDDECL const GUID standard_commands::guid_seek_back_10min = -{ 0xb012852, 0xbaf9, 0x4f6b, { 0xb9, 0x47, 0xfa, 0xb8, 0x9a, 0xe7, 0x6b, 0x79 } }; - -// {97215C5E-7228-4237-B52C-A2B5504EF726} -FOOGUIDDECL const GUID playback_statistics_collector::class_guid = -{ 0x97215c5e, 0x7228, 0x4237, { 0xb5, 0x2c, 0xa2, 0xb5, 0x50, 0x4e, 0xf7, 0x26 } }; - -// {9FB1DA49-AF6F-4fd2-9C73-48A8A109003B} -FOOGUIDDECL const GUID dsp_v2::class_guid = -{ 0x9fb1da49, 0xaf6f, 0x4fd2, { 0x9c, 0x73, 0x48, 0xa8, 0xa1, 0x9, 0x0, 0x3b } }; - -// {9EC5D45E-10F5-46a7-9546-F3ACEC68B149} -FOOGUIDDECL const GUID dsp_entry_v2::class_guid = -{ 0x9ec5d45e, 0x10f5, 0x46a7, { 0x95, 0x46, 0xf3, 0xac, 0xec, 0x68, 0xb1, 0x49 } }; - - -FOOGUIDDECL const GUID advconfig_entry::guid_root = { 0x34949f34, 0xe655, 0x4f09, { 0xba, 0x50, 0xfa, 0xeb, 0x4d, 0x9b, 0x77, 0x69 } }; -FOOGUIDDECL const GUID advconfig_entry::class_guid = { 0x7e84602e, 0xdc49, 0x4047, { 0xaa, 0xee, 0x63, 0x71, 0x8b, 0xbc, 0x5a, 0x1f } }; -FOOGUIDDECL const GUID advconfig_branch::class_guid = { 0x6a60b472, 0x91ac, 0x4681, { 0x9d, 0xc2, 0x76, 0xc9, 0x94, 0x0, 0x5b, 0x63 } }; -FOOGUIDDECL const GUID advconfig_entry_checkbox::class_guid = { 0x5243aba4, 0x2a3d, 0x4627, { 0x88, 0xef, 0xce, 0xe3, 0x76, 0x1c, 0x7, 0x9c } }; -FOOGUIDDECL const GUID advconfig_entry::guid_branch_tagging = { 0xe8fe273f, 0xdd00, 0x476e, { 0xa7, 0x90, 0xe5, 0x9d, 0xf6, 0xb8, 0xf8, 0xd4 } }; -FOOGUIDDECL const GUID advconfig_entry::guid_branch_decoding = { 0x904c272b, 0x2317, 0x4c3c, { 0xb2, 0xff, 0xc5, 0xa0, 0x12, 0x5e, 0x2c, 0xc2 } }; -FOOGUIDDECL const GUID advconfig_entry_string::class_guid = { 0x185d582d, 0xfbd8, 0x4db3, { 0xbe, 0x23, 0x47, 0xaa, 0xc6, 0x75, 0xfc, 0x11 } }; -FOOGUIDDECL const GUID advconfig_entry::guid_branch_tools = { 0x35365484, 0xcc58, 0x4926, { 0x97, 0xe1, 0x5e, 0x63, 0xf3, 0xab, 0xb9, 0xe2 } }; -FOOGUIDDECL const GUID advconfig_entry::guid_branch_playback = { 0xc48d430d, 0x112, 0x4922, { 0x97, 0x23, 0x28, 0x38, 0xc7, 0xd9, 0x7d, 0xd7 } }; -FOOGUIDDECL const GUID advconfig_entry::guid_branch_display = { 0x6c4bc1c8, 0xbaf4, 0x40c3, { 0x9d, 0xb1, 0x9, 0x50, 0x7f, 0xc, 0xc, 0xb9 } }; - - - -FOOGUIDDECL const GUID playback_control_v2::class_guid = { 0x1eb67bda, 0x1345, 0x49ae, { 0x8e, 0x89, 0x50, 0x5, 0xd9, 0x1, 0x62, 0x89 } }; - -FOOGUIDDECL const GUID preferences_page_v2::class_guid = { 0xce4ebc9e, 0xab20, 0x46f9, { 0x92, 0x5f, 0x88, 0x3b, 0x8, 0x4f, 0x5, 0x69 } }; -FOOGUIDDECL const GUID preferences_branch_v2::class_guid = { 0x167ebeb9, 0x8334, 0x4b21, { 0xaf, 0x58, 0xa7, 0x40, 0xa5, 0xd5, 0xb6, 0x66 } }; - - - -FOOGUIDDECL const GUID advconfig_entry_enum::class_guid = { 0xb1451540, 0x98ec, 0x4d36, { 0x9f, 0x19, 0xe3, 0x10, 0xfb, 0xa7, 0xab, 0x5a } }; - -FOOGUIDDECL const GUID info_lookup_handler::class_guid = { 0x4fcfdab7, 0x55b5, 0x47d6, { 0xb1, 0x9d, 0xa4, 0xdc, 0x9f, 0xd7, 0x69, 0x4c } }; - -FOOGUIDDECL const GUID completion_notify::class_guid = { 0xdf26d586, 0xf7ec, 0x40c3, { 0x9f, 0xe8, 0x2e, 0xa0, 0x72, 0x5d, 0x76, 0xc0 } }; - -FOOGUIDDECL const GUID metadb_io_v2::class_guid = { 0x265c4ece, 0xffb2, 0x4299, { 0x91, 0xb5, 0x6c, 0xa6, 0x60, 0x3d, 0xa1, 0x53 } }; - -FOOGUIDDECL const GUID file_info_filter::class_guid = { 0x45d0b800, 0xde83, 0x4a77, { 0xad, 0x34, 0x3f, 0x84, 0x2d, 0x40, 0xe7, 0x95 } }; - -FOOGUIDDECL const GUID metadb_hint_list::class_guid = { 0x719dc072, 0x8d4d, 0x4aa6, { 0xa6, 0xf3, 0x90, 0x73, 0x7, 0xe5, 0xbc, 0xee } }; - -FOOGUIDDECL const GUID playlist_incoming_item_filter_v2::class_guid = { 0xf335802b, 0xa522, 0x434d, { 0xbe, 0x89, 0xe8, 0x6d, 0x59, 0x56, 0x16, 0x48 } }; - -FOOGUIDDECL const GUID process_locations_notify::class_guid = { 0x7d7eddac, 0xf93e, 0x4707, { 0x96, 0x9b, 0xcf, 0x44, 0xa9, 0xe1, 0xfb, 0x78 } }; - -FOOGUIDDECL const GUID library_manager_v2::class_guid = { 0x900eae79, 0x68d0, 0x4900, { 0xa4, 0xd8, 0x18, 0x20, 0x5, 0xae, 0x33, 0x7e } }; - -FOOGUIDDECL const GUID packet_decoder::owner_Ogg = { 0x8fa27457, 0xa021, 0x43b9, { 0xad, 0x20, 0xa7, 0x96, 0xdb, 0x94, 0x7c, 0xd1 } }; - -FOOGUIDDECL const GUID packet_decoder::property_ogg_header = { 0xbeb22c78, 0xeb49, 0x4f9e, { 0x9e, 0x37, 0x57, 0xd8, 0x87, 0x40, 0xfb, 0x4c } }; - -FOOGUIDDECL const GUID packet_decoder::property_ogg_query_sample_rate = { 0x6226bf73, 0x1c37, 0x4aa1, { 0xae, 0xb1, 0x18, 0x8b, 0x4a, 0xf3, 0xae, 0xf7 } }; - -FOOGUIDDECL const GUID packet_decoder::property_ogg_packet = { 0xade740be, 0x8e2e, 0x4d0b, { 0xa4, 0x0, 0x3f, 0x6e, 0x8a, 0xf7, 0x71, 0xe4 } }; - -FOOGUIDDECL const GUID track_property_provider::class_guid = { 0xefcdd365, 0x81fc, 0x4c82, { 0x96, 0x1c, 0xa2, 0xb5, 0x76, 0x1a, 0xf8, 0xb7 } }; - -FOOGUIDDECL const GUID track_property_provider_v2::class_guid = { 0x78e86595, 0xcffd, 0x4d10, { 0x85, 0x66, 0xbc, 0xf6, 0x6c, 0x89, 0x11, 0x16 } }; - - -FOOGUIDDECL const GUID library_manager_v3::class_guid = { 0x33dc0f1f, 0x16f0, 0x4e27, { 0xa7, 0x3, 0x63, 0x57, 0x72, 0x35, 0xb0, 0x1c } }; - -FOOGUIDDECL const GUID metadb_io_v3::class_guid = { 0x10e80560, 0xb1ef, 0x4e5e, { 0xb4, 0xc, 0x5d, 0xfc, 0x2e, 0x9a, 0xf1, 0x11 } }; - -FOOGUIDDECL const GUID search_filter::class_guid = { 0x4134bb34, 0xed5, 0x49f3, { 0x9c, 0xef, 0x43, 0xe3, 0xa4, 0xa3, 0xa8, 0xae } }; - -FOOGUIDDECL const GUID search_filter_manager::class_guid = { 0xad0baa03, 0xebd4, 0x4a72, { 0xa0, 0xa7, 0x98, 0x3, 0xa9, 0xe1, 0xe4, 0xf4 } }; - -FOOGUIDDECL const GUID playlist_manager_v2::class_guid = { 0x7fe9052a, 0x8ec2, 0x4054, { 0xa8, 0xcf, 0x77, 0xef, 0xb5, 0x2f, 0xe4, 0x8 } }; - -FOOGUIDDECL const GUID playlist_manager_v3::class_guid = { 0x3b6575c8, 0x21a, 0x4474, { 0xbb, 0x60, 0x6c, 0xfc, 0xfe, 0x33, 0xc3, 0x4f } }; - -FOOGUIDDECL const GUID titleformat_common_methods::class_guid = { 0x432fe059, 0xf087, 0x4785, { 0xa5, 0x18, 0xcb, 0xc1, 0x8b, 0x84, 0x9a, 0xc1 } }; - -FOOGUIDDECL const GUID core_version_info_v2::class_guid = { 0x273704d7, 0x99ba, 0x4b58, { 0xa0, 0x60, 0x82, 0xab, 0x1, 0xb4, 0x92, 0x25 } }; - -FOOGUIDDECL const GUID visualisation_stream_v2::class_guid = { 0xeb5b35b5, 0x267b, 0x443c, { 0xbe, 0x37, 0xc, 0x25, 0x73, 0x81, 0xa8, 0x6a } }; - -FOOGUIDDECL const GUID visualisation_stream_v3::class_guid = { 0xe1fd8e8b, 0x68f1, 0x4cea, { 0xa0, 0xe6, 0x61, 0x91, 0x1d, 0x14, 0x65, 0x42 } }; - -FOOGUIDDECL const GUID album_art_data::class_guid = { 0x9ddce05c, 0xaa3f, 0x4565, { 0xb3, 0x3a, 0xbd, 0x6a, 0xdc, 0xdd, 0x90, 0x37 } }; -FOOGUIDDECL const GUID album_art_manager::class_guid = { 0xab90fd55, 0xb6f, 0x47b2, { 0x8c, 0xd7, 0x61, 0x1d, 0x58, 0x6c, 0x4c, 0x45 } }; -FOOGUIDDECL const GUID album_art_manager_instance::class_guid = { 0x3c7b403b, 0xff99, 0x4d86, { 0x84, 0x4a, 0xd3, 0xea, 0xbb, 0xd6, 0x1f, 0x66 } }; -FOOGUIDDECL const GUID album_art_extractor::class_guid = { 0xe19ca3d3, 0x6267, 0x4271, { 0xb7, 0x89, 0x6a, 0x3f, 0x87, 0xfb, 0x3e, 0xbf } }; -FOOGUIDDECL const GUID album_art_extractor_instance::class_guid = { 0xf673700e, 0x3b6e, 0x4f70, { 0xa1, 0x6, 0xab, 0x74, 0x5c, 0x20, 0x20, 0x60 } }; -FOOGUIDDECL const GUID album_art_editor::class_guid = { 0x36b34487, 0xd7b9, 0x4533, { 0xa7, 0x3f, 0x39, 0x6e, 0x2d, 0x9f, 0x41, 0x5e } }; -FOOGUIDDECL const GUID album_art_editor_instance::class_guid = { 0x642a2ae1, 0x2259, 0x48f5, { 0xab, 0xdc, 0x63, 0xed, 0x4e, 0xb5, 0x90, 0x76 } }; - - -FOOGUIDDECL const GUID icon_remapping::class_guid = { 0x7c6aea96, 0x4a19, 0x471b, { 0x92, 0x5a, 0xa7, 0xc8, 0xb2, 0x8a, 0x59, 0xe7 } }; - -//FOOGUIDDECL const GUID now_playing_album_art_callback_manager::class_guid = { 0x6bd2ef21, 0x1e3f, 0x44b0, { 0xb5, 0x5c, 0xeb, 0xc9, 0x88, 0x56, 0x48, 0xaa } }; - -FOOGUIDDECL const GUID file_operation_callback_dynamic_manager::class_guid = { 0x1cb3a4dc, 0x7d79, 0x45cf, { 0x82, 0x2e, 0xf8, 0x67, 0x7b, 0x8d, 0xde, 0x37 } }; - -FOOGUIDDECL const GUID ui_selection_holder::class_guid = { 0x2ec9b7a, 0x93a5, 0x434d, { 0x85, 0x46, 0xed, 0x1d, 0xbb, 0x24, 0x35, 0xd0 } }; -FOOGUIDDECL const GUID ui_selection_manager::class_guid = { 0xd8ee46c7, 0x27ad, 0x4881, { 0xb1, 0x33, 0x14, 0x96, 0xc0, 0xe7, 0xee, 0x67 } }; - -FOOGUIDDECL const GUID ole_interaction::class_guid = { 0xfbee40c9, 0xef36, 0x410b, { 0x9d, 0x52, 0x7e, 0x56, 0x39, 0x59, 0xf3, 0xd1 } }; - -FOOGUIDDECL const GUID tag_processor_album_art_utils::class_guid = { 0x58768713, 0xc13c, 0x4406, { 0x97, 0x98, 0x21, 0x47, 0xcb, 0x97, 0x33, 0x2a } }; - -FOOGUIDDECL const GUID playlist_incoming_item_filter_v3::class_guid = { 0xd3332054, 0xbccd, 0x45cb, { 0xbc, 0x2, 0x0, 0xa1, 0x3a, 0x80, 0x25, 0x9f } }; - -FOOGUIDDECL const GUID menu_item_resolver::class_guid = { 0xac70ecdc, 0xe1d, 0x4db2, { 0x9c, 0xd0, 0xc9, 0xb8, 0xa9, 0xcd, 0x28, 0xfa } }; - -FOOGUIDDECL const GUID app_close_blocking_task_manager::class_guid = { 0x213f1454, 0x8a62, 0x44b6, { 0xb0, 0xcb, 0xc1, 0xe1, 0x5d, 0xa7, 0x3b, 0xc8 } }; - -FOOGUIDDECL const GUID message_loop_v2::class_guid = { 0x5d438080, 0xb269, 0x406d, { 0x94, 0xaf, 0xef, 0xd9, 0x29, 0x9f, 0x32, 0x5c } }; - - -FOOGUIDDECL const GUID autoplaylist_client::class_guid = { 0x7c90bda0, 0xf93d, 0x4a73, { 0x98, 0x51, 0xa0, 0x33, 0x6, 0x7, 0xcb, 0x28 } }; - -FOOGUIDDECL const GUID autoplaylist_client_factory::class_guid = { 0x764200cb, 0xe283, 0x4efd, { 0x88, 0xa5, 0x80, 0x38, 0xdd, 0xee, 0x77, 0xdb } }; - -FOOGUIDDECL const GUID autoplaylist_manager::class_guid = { 0x1571d0d, 0xc1e1, 0x44bf, { 0xb5, 0x29, 0x7a, 0xe, 0x4e, 0x89, 0x15, 0xbc } }; - - -FOOGUIDDECL const GUID replaygain_result::class_guid = { 0xe7f43102, 0xbc6e, 0x400b, { 0xbb, 0x81, 0x2d, 0x9b, 0xe4, 0x30, 0x3e, 0xcc } }; -FOOGUIDDECL const GUID replaygain_scanner::class_guid = { 0x2a40fcf9, 0xf1f7, 0x41da, { 0xad, 0x76, 0x29, 0xf7, 0x51, 0xed, 0xd3, 0x8a } }; -FOOGUIDDECL const GUID replaygain_scanner_entry::class_guid = { 0x278380f3, 0x6fc0, 0x4176, { 0x8a, 0x98, 0x1f, 0x66, 0x3a, 0x94, 0x79, 0xc5 } }; - - -FOOGUIDDECL const GUID search_filter_manager_v2::class_guid = { 0xac62a380, 0x7771, 0x4dc9, { 0x8a, 0x26, 0x41, 0x41, 0x39, 0xb4, 0x3e, 0xe2 } }; -FOOGUIDDECL const GUID search_filter_v2::class_guid = { 0xb7ca3c8, 0xaf23, 0x4a52, { 0x82, 0x66, 0xfe, 0x5, 0x4c, 0x49, 0xeb, 0x23 } }; - - -FOOGUIDDECL const GUID autoplaylist_client_v2::class_guid = { 0xfaa716f7, 0xebb1, 0x473c, { 0xbc, 0xf1, 0xb0, 0x1b, 0x8c, 0x9f, 0x1b, 0x95 } }; - -FOOGUIDDECL const GUID library_search_ui::class_guid = { 0xe5eb14fa, 0xbb08, 0x4564, { 0xaf, 0xfa, 0x6f, 0x27, 0x3f, 0x37, 0xbd, 0x3d } }; - -FOOGUIDDECL const GUID search_filter_v3::class_guid = { 0xdd6bc035, 0x7e33, 0x425a, { 0x89, 0x32, 0x6, 0xb5, 0xea, 0xb0, 0x39, 0xbc } }; - -FOOGUIDDECL const GUID input_decoder_v2::class_guid = { 0x2c5489eb, 0xd3c1, 0x4ad4, { 0xbe, 0xa3, 0xcf, 0x40, 0x8e, 0x16, 0x1b, 0x9b } }; - -FOOGUIDDECL const GUID event_logger::class_guid = { 0x5d336782, 0x69d6, 0x4225, { 0x9e, 0xa8, 0xcc, 0x29, 0x35, 0x7, 0xf9, 0xfe } }; - -FOOGUIDDECL const GUID playlist_manager_v4::class_guid = { 0xcea7b49e, 0xacf2, 0x4ea2, { 0x99, 0x86, 0x95, 0xa, 0x56, 0xa2, 0xc0, 0xef } }; - -FOOGUIDDECL const GUID ole_interaction_v2::class_guid = { 0x55738cab, 0x311d, 0x4dbe, { 0xa0, 0xbc, 0x51, 0xc1, 0xba, 0x27, 0xfe, 0x95 } }; - -FOOGUIDDECL const GUID autoplaylist_manager_v2::class_guid = { 0x67882220, 0xeea5, 0x4dbc, { 0x9a, 0xa3, 0x63, 0xde, 0x8c, 0xdd, 0x40, 0x82 } }; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/hasher_md5.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/hasher_md5.cpp deleted file mode 100644 index dc738310d..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/hasher_md5.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "foobar2000.h" - -GUID hasher_md5::guid_from_result(const hasher_md5_result & param) -{ - assert(sizeof(GUID) == sizeof(hasher_md5_result)); - GUID temp = * reinterpret_cast(¶m); - byte_order::order_le_to_native_t(temp); - return temp; -} - -hasher_md5_result hasher_md5::process_single(const void * p_buffer,t_size p_bytes) -{ - hasher_md5_state state; - initialize(state); - process(state,p_buffer,p_bytes); - return get_result(state); -} - -GUID hasher_md5::process_single_guid(const void * p_buffer,t_size p_bytes) -{ - return guid_from_result(process_single(p_buffer,p_bytes)); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/hasher_md5.h b/tools/vio2sf/src/foobar/foobar2000/SDK/hasher_md5.h deleted file mode 100644 index 8cfceeed4..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/hasher_md5.h +++ /dev/null @@ -1,73 +0,0 @@ -struct hasher_md5_state { - char m_data[128]; -}; - -struct hasher_md5_result { - char m_data[16]; -}; - -inline bool operator==(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) == 0;} -inline bool operator!=(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) != 0;} - -namespace pfc { - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; -} - -class NOVTABLE hasher_md5 : public service_base -{ -public: - - virtual void initialize(hasher_md5_state & p_state) = 0; - virtual void process(hasher_md5_state & p_state,const void * p_buffer,t_size p_bytes) = 0; - virtual hasher_md5_result get_result(const hasher_md5_state & p_state) = 0; - - - static GUID guid_from_result(const hasher_md5_result & param); - - hasher_md5_result process_single(const void * p_buffer,t_size p_bytes); - GUID process_single_guid(const void * p_buffer,t_size p_bytes); - GUID get_result_guid(const hasher_md5_state & p_state) {return guid_from_result(get_result(p_state));} - - - //! Helper - void process_string(hasher_md5_state & p_state,const char * p_string,t_size p_length = infinite) {return process(p_state,p_string,pfc::strlen_max(p_string,p_length));} - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(hasher_md5); -}; - - -class stream_writer_hasher_md5 : public stream_writer { -public: - stream_writer_hasher_md5() { - m_hasher->initialize(m_state); - } - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check(); - m_hasher->process(m_state,p_buffer,p_bytes); - } - hasher_md5_result result() const { - return m_hasher->get_result(m_state); - } - GUID resultGuid() const { - return hasher_md5::guid_from_result(result()); - } -private: - hasher_md5_state m_state; - static_api_ptr_t m_hasher; -}; -template -class stream_formatter_hasher_md5 : public stream_writer_formatter { -public: - stream_formatter_hasher_md5() : stream_writer_formatter(_m_stream,_m_abort) {} - - hasher_md5_result result() const { - return _m_stream.result(); - } - GUID resultGuid() const { - return hasher_md5::guid_from_result(result()); - } -private: - abort_callback_dummy _m_abort; - stream_writer_hasher_md5 _m_stream; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/icon_remap.h b/tools/vio2sf/src/foobar/foobar2000/SDK/icon_remap.h deleted file mode 100644 index 0df7f77b5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/icon_remap.h +++ /dev/null @@ -1,26 +0,0 @@ -//! New in 0.9.5; allows your file format to use another icon than .ico when registering the file type with Windows shell. \n -//! Implementation: use icon_remapping_impl, or simply: static service_factory_single_t myicon("ext","iconname.ico"); -class icon_remapping : public service_base { -public: - //! @param p_extension File type extension being queried. - //! @param p_iconname Receives the icon name to use, including the .ico extension. - //! @returns True when p_iconname has been set, false if we don't recognize the specified extension. - virtual bool query(const char * p_extension,pfc::string_base & p_iconname) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(icon_remapping); -}; - -//! Standard implementation of icon_remapping. -class icon_remapping_impl : public icon_remapping { -public: - icon_remapping_impl(const char * p_extension,const char * p_iconname) : m_extension(p_extension), m_iconname(p_iconname) {} - bool query(const char * p_extension,pfc::string_base & p_iconname) { - if (stricmp_utf8(p_extension,m_extension) == 0) { - p_iconname = m_iconname; return true; - } else { - return false; - } - } -private: - pfc::string8 m_extension,m_iconname; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/info_lookup_handler.h b/tools/vio2sf/src/foobar/foobar2000/SDK/info_lookup_handler.h deleted file mode 100644 index fc68591cf..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/info_lookup_handler.h +++ /dev/null @@ -1,24 +0,0 @@ -//! Service used to access various external (online) track info lookup services, such as freedb, to update file tags with info retrieved from those services. -class NOVTABLE info_lookup_handler : public service_base { -public: - enum { - flag_album_lookup = 1 << 0, - flag_track_lookup = 1 << 1, - }; - - //! Retrieves human-readable name of the lookup handler to display in user interface. - virtual void get_name(pfc::string_base & p_out) = 0; - - //! Returns one or more of flag_track_lookup, and flag_album_lookup. - virtual t_uint32 get_flags() = 0; - - virtual HICON get_icon(int p_width, int p_height) = 0; - - //! Performs a lookup. Creates a modeless dialog and returns immediately. - //! @param p_items Items to look up. - //! @param p_notify Callback to notify caller when the operation has completed. Call on_completion with status code 0 to signal failure/abort, or with code 1 to signal success / new infos in metadb. - //! @param p_parent Parent window for the lookup dialog. Caller will typically disable the window while lookup is in progress and enable it back when completion is signaled. - virtual void lookup(const pfc::list_base_const_t & p_items,completion_notify_ptr p_notify,HWND p_parent) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(info_lookup_handler); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/initquit.h b/tools/vio2sf/src/foobar/foobar2000/SDK/initquit.h deleted file mode 100644 index 5edd5f1f9..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/initquit.h +++ /dev/null @@ -1,13 +0,0 @@ -//! Basic callback startup/shutdown callback, on_init is called after the main window has been created, on_quit is called before the main window is destroyed. -//! To register: static initquit_factory_t myclass_factory; -class NOVTABLE initquit : public service_base -{ -public: - virtual void on_init() {} - virtual void on_quit() {} - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(initquit); -}; - -template -class initquit_factory_t : public service_factory_single_t {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/input.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/input.cpp deleted file mode 100644 index ffb801820..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/input.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "foobar2000.h" - - -bool input_entry::g_find_service_by_path(service_ptr_t & p_out,const char * p_path) -{ - service_ptr_t ptr; - service_enum_t e; - pfc::string_extension ext(p_path); - while(e.next(ptr)) - { - if (ptr->is_our_path(p_path,ext)) - { - p_out = ptr; - return true; - } - } - return false; -} - -bool input_entry::g_find_service_by_content_type(service_ptr_t & p_out,const char * p_content_type) -{ - service_ptr_t ptr; - service_enum_t e; - while(e.next(ptr)) - { - if (ptr->is_our_content_type(p_content_type)) - { - p_out = ptr; - return true; - } - } - return false; -} - - - -static void prepare_for_open(service_ptr_t & p_service,service_ptr_t & p_file,const char * p_path,filesystem::t_open_mode p_open_mode,abort_callback & p_abort,bool p_from_redirect) -{ - if (p_file.is_empty()) - { - service_ptr_t fs; - if (filesystem::g_get_interface(fs,p_path)) { - if (fs->supports_content_types()) { - fs->open(p_file,p_path,p_open_mode,p_abort); - } - } - } - - if (p_file.is_valid()) - { - pfc::string8 content_type; - if (p_file->get_content_type(content_type)) - { - if (input_entry::g_find_service_by_content_type(p_service,content_type)) - return; - } - } - - if (input_entry::g_find_service_by_path(p_service,p_path)) - { - if (p_from_redirect && p_service->is_redirect()) throw exception_io_unsupported_format(); - return; - } - - throw exception_io_unsupported_format(); -} - -namespace { - - bool g_find_inputs_by_content_type(pfc::list_base_t > & p_out,const char * p_content_type,bool p_from_redirect) { - service_enum_t e; - service_ptr_t ptr; - bool ret = false; - while(e.next(ptr)) { - if (!(p_from_redirect && ptr->is_redirect())) { - if (ptr->is_our_content_type(p_content_type)) {p_out.add_item(ptr); ret = true;} - } - } - return ret; - } - - bool g_find_inputs_by_path(pfc::list_base_t > & p_out,const char * p_path,bool p_from_redirect) { - service_enum_t e; - service_ptr_t ptr; - pfc::string_extension extension(p_path); - bool ret = false; - while(e.next(ptr)) { - if (!(p_from_redirect && ptr->is_redirect())) { - if (ptr->is_our_path(p_path,extension)) {p_out.add_item(ptr); ret = true;} - } - } - return ret; - } - - template void g_open_from_list(service_ptr_t & p_instance,pfc::list_base_const_t > const & p_list,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort) { - const t_size count = p_list.get_count(); - if (count == 1) { - p_list[0]->open(p_instance,p_filehint,p_path,p_abort); - } else { - bool got_bad_data = false, got_bad_data_multi = false; - bool done = false; - pfc::string8 bad_data_message; - for(t_size n=0;nopen(p_instance,p_filehint,p_path,p_abort); - done = true; - } catch(exception_io_unsupported_format) { - //do nothing, skip over - } catch(exception_io_data const & e) { - if (!got_bad_data) bad_data_message = e.what(); - else got_bad_data_multi = true; - got_bad_data = true; - } - } - if (!done) { - if (got_bad_data_multi) throw exception_io_data(); - else if (got_bad_data) throw exception_io_data(bad_data_message); - else throw exception_io_unsupported_format(); - } - } - } - - template bool needs_write_access() {return false;} - template<> bool needs_write_access() {return true;} - - template void g_open_t(service_ptr_t & p_instance,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) { - service_ptr_t l_file = p_filehint; - if (l_file.is_empty()) { - service_ptr_t fs; - if (filesystem::g_get_interface(fs,p_path)) { - if (fs->supports_content_types()) { - fs->open(l_file,p_path,needs_write_access() ? filesystem::open_mode_write_existing : filesystem::open_mode_read,p_abort); - } - } - } - - if (l_file.is_valid()) { - pfc::string8 content_type; - if (l_file->get_content_type(content_type)) { - pfc::list_hybrid_t,4> list; - if (g_find_inputs_by_content_type(list,content_type,p_from_redirect)) { - g_open_from_list(p_instance,list,l_file,p_path,p_abort); - return; - } - } - } - - { - pfc::list_hybrid_t,4> list; - if (g_find_inputs_by_path(list,p_path,p_from_redirect)) { - g_open_from_list(p_instance,list,l_file,p_path,p_abort); - return; - } - } - - throw exception_io_unsupported_format(); - } -}; - -void input_entry::g_open_for_decoding(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) { - TRACK_CALL_TEXT("input_entry::g_open_for_decoding"); -#if 1 - g_open_t(p_instance,p_filehint,p_path,p_abort,p_from_redirect); -#else - service_ptr_t filehint = p_filehint; - service_ptr_t entry; - - prepare_for_open(entry,filehint,p_path,filesystem::open_mode_read,p_abort,p_from_redirect); - - entry->open_for_decoding(p_instance,filehint,p_path,p_abort); -#endif - -} - -void input_entry::g_open_for_info_read(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) { - TRACK_CALL_TEXT("input_entry::g_open_for_info_read"); -#if 1 - g_open_t(p_instance,p_filehint,p_path,p_abort,p_from_redirect); -#else - service_ptr_t filehint = p_filehint; - service_ptr_t entry; - - prepare_for_open(entry,filehint,p_path,filesystem::open_mode_read,p_abort,p_from_redirect); - - entry->open_for_info_read(p_instance,filehint,p_path,p_abort); -#endif -} - -void input_entry::g_open_for_info_write(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) { - TRACK_CALL_TEXT("input_entry::g_open_for_info_write"); -#if 1 - g_open_t(p_instance,p_filehint,p_path,p_abort,p_from_redirect); -#else - service_ptr_t filehint = p_filehint; - service_ptr_t entry; - - prepare_for_open(entry,filehint,p_path,filesystem::open_mode_write_existing,p_abort,p_from_redirect); - - entry->open_for_info_write(p_instance,filehint,p_path,p_abort); -#endif -} - -void input_entry::g_open_for_info_write_timeout(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,double p_timeout,bool p_from_redirect) { - pfc::lores_timer timer; - timer.start(); - for(;;) { - try { - g_open_for_info_write(p_instance,p_filehint,p_path,p_abort,p_from_redirect); - break; - } catch(exception_io_sharing_violation) { - if (timer.query() > p_timeout) throw; - p_abort.sleep(0.01); - } - } -} - -bool input_entry::g_is_supported_path(const char * p_path) -{ - service_ptr_t ptr; - service_enum_t e; - pfc::string_extension ext(p_path); - while(e.next(ptr)) - { - if (ptr->is_our_path(p_path,ext)) return true; - } - return false; -} - - - -void input_open_file_helper(service_ptr_t & p_file,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) -{ - if (p_file.is_empty()) { - switch(p_reason) { - default: - throw pfc::exception_bug_check_v2(); - case input_open_info_read: - case input_open_decode: - filesystem::g_open(p_file,p_path,filesystem::open_mode_read,p_abort); - break; - case input_open_info_write: - filesystem::g_open(p_file,p_path,filesystem::open_mode_write_existing,p_abort); - break; - } - } else { - p_file->reopen(p_abort); - } -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/input.h b/tools/vio2sf/src/foobar/foobar2000/SDK/input.h deleted file mode 100644 index 80297e76f..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/input.h +++ /dev/null @@ -1,189 +0,0 @@ -enum { - input_flag_no_seeking = 1 << 0, - input_flag_no_looping = 1 << 1, - input_flag_playback = 1 << 2, - input_flag_testing_integrity = 1 << 3, - input_flag_allow_inaccurate_seeking = 1 << 4, - - input_flag_simpledecode = input_flag_no_seeking|input_flag_no_looping, -}; - -//! Class providing interface for retrieval of information (metadata, duration, replaygain, other tech infos) from files. Also see: file_info. \n -//! Instantiating: see input_entry.\n -//! Implementing: see input_impl. - -class NOVTABLE input_info_reader : public service_base -{ -public: - //! Retrieves count of subsongs in the file. 1 for non-multisubsong-enabled inputs. - //! Note: multi-subsong handling is disabled for remote files (see: filesystem::is_remote) for performance reasons. Remote files are always assumed to be single-subsong, with null index. - virtual t_uint32 get_subsong_count() = 0; - - //! Retrieves identifier of specified subsong; this identifier is meant to be used in playable_location as well as a parameter for input_info_reader::get_info(). - //! @param p_index Index of subsong to query. Must be >=0 and < get_subsong_count(). - virtual t_uint32 get_subsong(t_uint32 p_index) = 0; - - //! Retrieves information about specified subsong. - //! @param p_subsong Identifier of the subsong to query. See: input_info_reader::get_subsong(), playable_location. - //! @param p_info file_info object to fill. Must be empty on entry. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) = 0; - - //! Retrieves file stats. Equivalent to calling get_stats() on file object. - virtual t_filestats get_file_stats(abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(input_info_reader,service_base); -}; - -//! Class providing interface for retrieval of PCM audio data from files.\n -//! Instantiating: see input_entry.\n -//! Implementing: see input_impl. - -class NOVTABLE input_decoder : public input_info_reader -{ -public: - //! Prepares to decode specified subsong; resets playback position to the beginning of specified subsong. This must be called first, before any other input_decoder methods (other than those inherited from input_info_reader). \n - //! It is legal to set initialize() more than once, with same or different subsong, to play either the same subsong again or another subsong from same file without full reopen.\n - //! Warning: this interface inherits from input_info_reader, it is legal to call any input_info_reader methods even during decoding! Call order is not defined, other than initialize() requirement before calling other input_decoder methods.\n - //! @param p_subsong Subsong to decode. Should always be 0 for non-multi-subsong-enabled inputs. - //! @param p_flags Specifies additional hints for decoding process. It can be null, or a combination of one or more following constants: \n - //! input_flag_no_seeking - Indicates that seek() will never be called. Can be used to avoid building potentially expensive seektables when only sequential reading is needed.\n - //! input_flag_no_looping - Certain input implementations can be configured to utilize looping info from file formats they process and keep playing single file forever, or keep repeating it specified number of times. This flag indicates that such features should be disabled, for e.g. ReplayGain scan or conversion.\n - //! input_flag_playback - Indicates that decoding process will be used for realtime playback rather than conversion. This can be used to reconfigure features that are relevant only for conversion and take a lot of resources, such as very slow secure CDDA reading. \n - //! input_flag_testing_integrity - Indicates that we're testing integrity of the file. Any recoverable problems where decoding would normally continue should cause decoder to fail with exception_io_data. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) = 0; - - //! Reads/decodes one chunk of audio data. Use false return value to signal end of file (no more data to return). Before calling run(), decoding must be initialized by initialize() call. - //! @param p_chunk audio_chunk object receiving decoded data. Contents are valid only the method returns true. - //! @param p_abort abort_callback object signaling user aborting the operation. - //! @returns true on success (new data decoded), false on EOF. - virtual bool run(audio_chunk & p_chunk,abort_callback & p_abort) = 0; - - //! Seeks to specified time offset. Before seeking or other decoding calls, decoding must be initialized with initialize() call. - //! @param p_seconds Time to seek to, in seconds. If p_seconds exceeds length of the object being decoded, succeed, and then return false from next run() call. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void seek(double p_seconds,abort_callback & p_abort) = 0; - - //! Queries whether resource being read/decoded is seekable. If p_value is set to false, all seek() calls will fail. Before calling can_seek() or other decoding calls, decoding must be initialized with initialize() call. - virtual bool can_seek() = 0; - - //! This function is used to signal dynamic VBR bitrate, etc. Called after each run() (or not called at all if caller doesn't care about dynamic info). - //! @param p_out Initially contains currently displayed info (either last get_dynamic_info result or current cached info), use this object to return changed info. - //! @param p_timestamp_delta Indicates when returned info should be displayed (in seconds, relative to first sample of last decoded chunk), initially set to 0. - //! @returns false to keep old info, or true to indicate that changes have been made to p_info and those should be displayed. - virtual bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) = 0; - - //! This function is used to signal dynamic live stream song titles etc. Called after each run() (or not called at all if caller doesn't care about dynamic info). The difference between this and get_dynamic_info() is frequency and relevance of dynamic info changes - get_dynamic_info_track() returns new info only on track change in the stream, returning new titles etc. - //! @param p_out Initially contains currently displayed info (either last get_dynamic_info_track result or current cached info), use this object to return changed info. - //! @param p_timestamp_delta Indicates when returned info should be displayed (in seconds, relative to first sample of last decoded chunk), initially set to 0. - //! @returns false to keep old info, or true to indicate that changes have been made to p_info and those should be displayed. - virtual bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) = 0; - - //! Called from playback thread before sleeping. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void on_idle(abort_callback & p_abort) = 0; - - - FB2K_MAKE_SERVICE_INTERFACE(input_decoder,input_info_reader); -}; - - -class NOVTABLE input_decoder_v2 : public input_decoder { - FB2K_MAKE_SERVICE_INTERFACE(input_decoder_v2, input_decoder) -public: - - //! OPTIONAL, throws pfc::exception_not_implemented() when not supported by this implementation. - //! Special version of run(). Returns an audio_chunk object as well as a raw data block containing original PCM stream. This is mainly used for MD5 checks on lossless formats. \n - //! If you set a "MD5" tech info entry in get_info(), you should make sure that run_raw() returns data stream that can be used to verify it. \n - //! Returned raw data should be possible to cut into individual samples; size in bytes should be divisible by audio_chunk's sample count for splitting in case partial output is needed (with cuesheets etc). - virtual bool run_raw(audio_chunk & out, mem_block_container & outRaw, abort_callback & abort) = 0; - - //! OPTIONAL, the call is ignored if this implementation doesn't support status logging. \n - //! Mainly used to generate logs when ripping CDs etc. - virtual void set_logger(event_logger::ptr ptr) = 0; -}; - -//! Class providing interface for writing metadata and replaygain info to files. Also see: file_info. \n -//! Instantiating: see input_entry.\n -//! Implementing: see input_impl. - -class NOVTABLE input_info_writer : public input_info_reader -{ -public: - //! Tells the service to update file tags with new info for specified subsong. - //! @param p_subsong Subsong to update. Should be always 0 for non-multisubsong-enabled inputs. - //! @param p_info New info to write. Sometimes not all contents of p_info can be written. Caller will typically read info back after successful write, so e.g. tech infos that change with retag are properly maintained. - //! @param p_abort abort_callback object signaling user aborting the operation. WARNING: abort_callback object is provided for consistency; if writing tags actually gets aborted, user will be likely left with corrupted file. Anything calling this should make sure that aborting is either impossible, or gives appropriate warning to the user first. - virtual void set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) = 0; - - //! Commits pending updates. In case of multisubsong inputs, set_info should queue the update and perform actual file access in commit(). Otherwise, actual writing can be done in set_info() and then Commit() can just do nothing and always succeed. - //! @param p_abort abort_callback object signaling user aborting the operation. WARNING: abort_callback object is provided for consistency; if writing tags actually gets aborted, user will be likely left with corrupted file. Anything calling this should make sure that aborting is either impossible, or gives appropriate warning to the user first. - virtual void commit(abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(input_info_writer,input_info_reader); -}; - -class NOVTABLE input_entry : public service_base -{ -public: - //! Determines whether specified content type can be handled by this input. - //! @param p_type Content type string to test. - virtual bool is_our_content_type(const char * p_type)=0; - - //! Determines whether specified file type can be handled by this input. This must not use any kind of file access; the result should be only based on file path / extension. - //! @param p_full_path Full URL of file being tested. - //! @param p_extension Extension of file being tested, provided by caller for performance reasons. - virtual bool is_our_path(const char * p_full_path,const char * p_extension)=0; - - //! Opens specified resource for decoding. - //! @param p_instance Receives new input_decoder instance if successful. - //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). - //! @param p_path URL of resource being opened. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void open_for_decoding(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) = 0; - - //! Opens specified file for reading info. - //! @param p_instance Receives new input_info_reader instance if successful. - //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). - //! @param p_path URL of resource being opened. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void open_for_info_read(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) = 0; - - //! Opens specified file for writing info. - //! @param p_instance Receives new input_info_writer instance if successful. - //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). - //! @param p_path URL of resource being opened. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void open_for_info_write(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) = 0; - - //! Reserved for future use. Do nothing and return until specifications are finalized. - virtual void get_extended_data(service_ptr_t p_filehint,const playable_location & p_location,const GUID & p_guid,mem_block_container & p_out,abort_callback & p_abort) = 0; - - enum { - //! Indicates that this service implements some kind of redirector that opens another input for decoding, used to avoid circular call possibility. - flag_redirect = 1, - //! Indicates that multi-CPU optimizations should not be used. - flag_parallel_reads_slow = 2, - }; - //! See flag_* enums. - virtual unsigned get_flags() = 0; - - inline bool is_redirect() {return (get_flags() & flag_redirect) != 0;} - inline bool are_parallel_reads_slow() {return (get_flags() & flag_parallel_reads_slow) != 0;} - - static bool g_find_service_by_path(service_ptr_t & p_out,const char * p_path); - static bool g_find_service_by_content_type(service_ptr_t & p_out,const char * p_content_type); - static void g_open_for_decoding(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false); - static void g_open_for_info_read(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false); - static void g_open_for_info_write(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false); - static void g_open_for_info_write_timeout(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort,double p_timeout,bool p_from_redirect = false); - static bool g_is_supported_path(const char * p_path); - - - void open(service_ptr_t & p_instance,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_decoding(p_instance,p_filehint,p_path,p_abort);} - void open(service_ptr_t & p_instance,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_info_read(p_instance,p_filehint,p_path,p_abort);} - void open(service_ptr_t & p_instance,service_ptr_t const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_info_write(p_instance,p_filehint,p_path,p_abort);} - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_entry); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/input_file_type.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/input_file_type.cpp deleted file mode 100644 index 749254bbc..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/input_file_type.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "foobar2000.h" - -typedef pfc::avltree_t t_fnList; - -static void formatMaskList(pfc::string_base & out, t_fnList const & in) { - pfc::const_iterator walk = in.first(); - if (walk.is_valid()) { - out << *walk; ++walk; - while(walk.is_valid()) { - out << ";" << *walk; ++walk; - } - } -} -static void formatMaskList(pfc::string_base & out, t_fnList const & in, const char * label) { - if (in.get_count() > 0) { - out << label << "|"; - formatMaskList(out,in); - out << "|"; - } -} - -void input_file_type::build_openfile_mask(pfc::string_base & out, bool b_include_playlists) -{ - t_fnList extensionsAll, extensionsPl;; - - if (b_include_playlists) { - service_enum_t e; service_ptr_t ptr; - while(e.next(ptr)) { - if (ptr->is_associatable()) { - pfc::string_formatter temp; temp << "*." << ptr->get_extension(); - extensionsPl += temp; - extensionsAll += temp; - } - } - } - - typedef pfc::map_t t_masks; - t_masks masks; - { - service_enum_t e; - service_ptr_t ptr; - pfc::string_formatter name, mask; - while(e.next(ptr)) { - const unsigned count = ptr->get_count(); - for(unsigned n=0;nget_name(n,name) && ptr->get_mask(n,mask)) { - if (!strchr(name,'|') && !strchr(mask,'|')) { - masks.find_or_add(name) += mask; - extensionsAll += mask; - } - } - } - } - } - pfc::string_formatter outBuf; - outBuf << "All files|*.*|"; - formatMaskList(outBuf, extensionsAll, "All supported types"); - formatMaskList(outBuf, extensionsPl, "Playlists"); - for(t_masks::const_iterator walk = masks.first(); walk.is_valid(); ++walk) { - formatMaskList(outBuf,walk->m_value,walk->m_key); - } - out = outBuf; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/input_file_type.h b/tools/vio2sf/src/foobar/foobar2000/SDK/input_file_type.h deleted file mode 100644 index f7608c836..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/input_file_type.h +++ /dev/null @@ -1,94 +0,0 @@ -//! Entrypoint interface for registering media file types that can be opened through "open file" dialogs or associated with foobar2000 application in Windows shell. \n -//! Instead of implementing this directly, use DECLARE_FILE_TYPE() / DECLARE_FILE_TYPE_EX() macros. -class input_file_type : public service_base { -public: - virtual unsigned get_count()=0; - virtual bool get_name(unsigned idx,pfc::string_base & out)=0;//eg. "MPEG files" - virtual bool get_mask(unsigned idx,pfc::string_base & out)=0;//eg. "*.MP3;*.MP2"; separate with semicolons - virtual bool is_associatable(unsigned idx) = 0; - - static void build_openfile_mask(pfc::string_base & out,bool b_include_playlists=true); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_file_type); -}; - -//! Extended interface for registering media file types that can be associated with foobar2000 application in Windows shell. \n -//! Instead of implementing this directly, use DECLARE_FILE_TYPE() / DECLARE_FILE_TYPE_EX() macros. -class input_file_type_v2 : public input_file_type { -public: - virtual void get_format_name(unsigned idx, pfc::string_base & out, bool isPlural) = 0; - virtual void get_extensions(unsigned idx, pfc::string_base & out) = 0; - - //Deprecated input_file_type method implementations: - bool get_name(unsigned idx, pfc::string_base & out) {get_format_name(idx, out, true); return true;} - bool get_mask(unsigned idx, pfc::string_base & out) { - pfc::string_formatter temp; get_extensions(idx,temp); - pfc::chain_list_v2_t exts; pfc::splitStringSimple_toList(exts,";",temp); - if (exts.get_count() == 0) return false;//should not happen - temp.reset(); - for(pfc::const_iterator walk = exts.first(); walk.is_valid(); ++walk) { - if (!temp.is_empty()) temp << ";"; - temp << "*." << walk->get_ptr(); - } - out = temp; - return true; - } - - FB2K_MAKE_SERVICE_INTERFACE(input_file_type_v2,input_file_type) -}; - - -//! Implementation helper. -class input_file_type_impl : public service_impl_single_t -{ - const char * name, * mask; - bool m_associatable; -public: - input_file_type_impl(const char * p_name, const char * p_mask,bool p_associatable) : name(p_name), mask(p_mask), m_associatable(p_associatable) {} - unsigned get_count() {return 1;} - bool get_name(unsigned idx,pfc::string_base & out) {if (idx==0) {out = name; return true;} else return false;} - bool get_mask(unsigned idx,pfc::string_base & out) {if (idx==0) {out = mask; return true;} else return false;} - bool is_associatable(unsigned idx) {return m_associatable;} -}; - - -//! Helper macro for registering our media file types. -//! Usage: DECLARE_FILE_TYPE("Blah files","*.blah;*.bleh"); -#define DECLARE_FILE_TYPE(NAME,MASK) \ - namespace { static input_file_type_impl g_filetype_instance(NAME,MASK,true); \ - static service_factory_single_ref_t g_filetype_service(g_filetype_instance); } - - - - -//! Implementation helper. -//! Usage: static input_file_type_factory mytype("blah type","*.bla;*.meh",true); -class input_file_type_factory : private service_factory_single_transparent_t -{ -public: - input_file_type_factory(const char * p_name,const char * p_mask,bool p_associatable) - : service_factory_single_transparent_t(p_name,p_mask,p_associatable) {} -}; - - - -class input_file_type_v2_impl : public input_file_type_v2 { -public: - input_file_type_v2_impl(const char * extensions,const char * name, const char * namePlural) : m_extensions(extensions), m_name(name), m_namePlural(namePlural) {} - unsigned get_count() {return 1;} - bool is_associatable(unsigned idx) {return true;} - void get_format_name(unsigned idx, pfc::string_base & out, bool isPlural) { - out = isPlural ? m_namePlural : m_name; - } - void get_extensions(unsigned idx, pfc::string_base & out) { - out = m_extensions; - } - -private: - const pfc::string8 m_name, m_namePlural, m_extensions; -}; - -//! Helper macro for registering our media file types, extended version providing separate singular/plural type names. -//! Usage: DECLARE_FILE_TYPE_EX("mp1;mp2;mp3","MPEG file","MPEG files") -#define DECLARE_FILE_TYPE_EX(extensions, name, namePlural) \ - namespace { static service_factory_single_t g_myfiletype(extensions, name, namePlural); } diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/input_impl.h b/tools/vio2sf/src/foobar/foobar2000/SDK/input_impl.h deleted file mode 100644 index df3a9d3b5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/input_impl.h +++ /dev/null @@ -1,314 +0,0 @@ -enum t_input_open_reason { - input_open_info_read, - input_open_decode, - input_open_info_write -}; - -//! Helper function for input implementation use; ensures that file is open with relevant access mode. This is typically called from input_impl::open() and such. -//! @param p_file File object pointer to process. If passed pointer is non-null, the function does nothing and always succeeds; otherwise it attempts to open the file using filesystem API methods. -//! @param p_path Path to the file. -//! @param p_reason Type of input operation requested. See: input_impl::open() parameters. -//! @param p_abort abort_callback object signaling user aborting the operation. -void input_open_file_helper(service_ptr_t & p_file,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort); - - -//! This is a class that just declares prototypes of functions that each input needs to implement. See input_decoder / input_info_reader / input_info_writer interfaces for full descriptions of member functions. Since input implementation class is instantiated using a template, you don't need to derive from input_impl as virtual functions are not used on implementation class level. Use input_factory_t template to register input class based on input_impl. -class input_impl -{ -public: - //! Opens specified file for info read / decoding / info write. This is called only once, immediately after object creation, before any other methods, and no other methods are called if open() fails. - //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the implementation should handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). Typically, an input implementation that requires file access calls input_open_file_helper() function to ensure that file is open with relevant access mode (read or read/write). - //! @param p_path URL of resource being opened. - //! @param p_reason Type of operation requested. Possible values are: \n - //! - input_open_info_read - info retrieval methods are valid; \n - //! - input_open_decode - info retrieval and decoding methods are valid; \n - //! - input_open_info_write - info retrieval and retagging methods are valid; \n - //! Note that info retrieval methods are valid in all cases, and they may be called at any point of decoding/retagging process. Results of info retrieval methods (other than get_subsong_count() / get_subsong()) between retag_set_info() and retag_commit() are undefined however; those should not be called during that period. - //! @param p_abort abort_callback object signaling user aborting the operation. - void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort); - - //! See: input_info_reader::get_subsong_count(). Valid after open() with any reason. - unsigned get_subsong_count(); - //! See: input_info_reader::get_subsong(). Valid after open() with any reason. - t_uint32 get_subsong(unsigned p_index); - //! See: input_info_reader::get_info(). Valid after open() with any reason. - void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort); - //! See: input_info_reader::get_file_stats(). Valid after open() with any reason. - t_filestats get_file_stats(abort_callback & p_abort); - - //! See: input_decoder::initialize(). Valid after open() with input_open_decode reason. - void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort); - //! See: input_decoder::run(). Valid after decode_initialize(). - bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort); - //! See: input_decoder::seek(). Valid after decode_initialize(). - void decode_seek(double p_seconds,abort_callback & p_abort); - //! See: input_decoder::can_seek(). Valid after decode_initialize(). - bool decode_can_seek(); - //! See: input_decoder::get_dynamic_info(). Valid after decode_initialize(). - bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta); - //! See: input_decoder::get_dynamic_info_track(). Valid after decode_initialize(). - bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta); - //! See: input_decoder::on_idle(). Valid after decode_initialize(). - void decode_on_idle(abort_callback & p_abort); - - //! See: input_info_writer::set_info(). Valid after open() with input_open_info_write reason. - void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort); - //! See: input_info_writer::commit(). Valid after open() with input_open_info_write reason. - void retag_commit(abort_callback & p_abort); - - //! See: input_entry::is_our_content_type(). - static bool g_is_our_content_type(const char * p_content_type); - //! See: input_entry::is_our_path(). - static bool g_is_our_path(const char * p_path,const char * p_extension); - -protected: - input_impl() {} - ~input_impl() {} -}; - -//! This is a class that just declares prototypes of functions that each non-multitrack-enabled input needs to implement. See input_decoder / input_info_reader / input_info_writer interfaces for full descriptions of member functions. Since input implementation class is instantiated using a template, you don't need to derive from input_singletrack_impl as virtual functions are not used on implementation class level. Use input_singletrack_factory_t template to register input class based on input_singletrack_impl. -class input_singletrack_impl -{ -public: - //! Opens specified file for info read / decoding / info write. This is called only once, immediately after object creation, before any other methods, and no other methods are called if open() fails. - //! @param p_filehint Optional; passes file object to use for the operation; if set to null, the implementation should handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). Typically, an input implementation that requires file access calls input_open_file_helper() function to ensure that file is open with relevant access mode (read or read/write). - //! @param p_path URL of resource being opened. - //! @param p_reason Type of operation requested. Possible values are: \n - //! - input_open_info_read - info retrieval methods are valid; \n - //! - input_open_decode - info retrieval and decoding methods are valid; \n - //! - input_open_info_write - info retrieval and retagging methods are valid; \n - //! Note that info retrieval methods are valid in all cases, and they may be called at any point of decoding/retagging process. Results of info retrieval methods (other than get_subsong_count() / get_subsong()) between retag_set_info() and retag_commit() are undefined however; those should not be called during that period. - //! @param p_abort abort_callback object signaling user aborting the operation. - void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort); - - //! See: input_info_reader::get_info(). Valid after open() with any reason. \n - //! Implementation warning: this is typically also called immediately after tag update and should return newly written content then. - void get_info(file_info & p_info,abort_callback & p_abort); - //! See: input_info_reader::get_file_stats(). Valid after open() with any reason. \n - //! Implementation warning: this is typically also called immediately after tag update and should return new values then. - t_filestats get_file_stats(abort_callback & p_abort); - - //! See: input_decoder::initialize(). Valid after open() with input_open_decode reason. - void decode_initialize(unsigned p_flags,abort_callback & p_abort); - //! See: input_decoder::run(). Valid after decode_initialize(). - bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort); - //! See: input_decoder::seek(). Valid after decode_initialize(). - void decode_seek(double p_seconds,abort_callback & p_abort); - //! See: input_decoder::can_seek(). Valid after decode_initialize(). - bool decode_can_seek(); - //! See: input_decoder::get_dynamic_info(). Valid after decode_initialize(). - bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta); - //! See: input_decoder::get_dynamic_info_track(). Valid after decode_initialize(). - bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta); - //! See: input_decoder::on_idle(). Valid after decode_initialize(). - void decode_on_idle(abort_callback & p_abort); - - //! See: input_info_writer::set_info(). Note that input_info_writer::commit() call isn't forwarded because it's useless in case of non-multitrack-enabled inputs. Valid after open() with input_open_info_write reason. - void retag(const file_info & p_info,abort_callback & p_abort); - - //! See: input_entry::is_our_content_type(). - static bool g_is_our_content_type(const char * p_content_type); - //! See: input_entry::is_our_path(). - static bool g_is_our_path(const char * p_path,const char * p_extension); - -protected: - input_singletrack_impl() {} - ~input_singletrack_impl() {} -}; - - -//! Used internally by standard input_entry implementation; do not use directly. Translates input_decoder / input_info_reader / input_info_writer calls to input_impl calls. -template -class input_impl_interface_wrapper_t : public t_base -{ -public: - void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) { - m_instance.open(p_filehint,p_path,p_reason,p_abort); - } - - // input_info_reader methods - - t_uint32 get_subsong_count() { - return m_instance.get_subsong_count(); - } - - t_uint32 get_subsong(t_uint32 p_index) { - return m_instance.get_subsong(p_index); - } - - - void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { - m_instance.get_info(p_subsong,p_info,p_abort); - } - - t_filestats get_file_stats(abort_callback & p_abort) { - return m_instance.get_file_stats(p_abort); - } - - // input_decoder methods - - void initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { - m_instance.decode_initialize(p_subsong,p_flags,p_abort); - } - - bool run(audio_chunk & p_chunk,abort_callback & p_abort) { - return m_instance.decode_run(p_chunk,p_abort); - } - - bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { - return m_instance.decode_run_raw(p_chunk, p_raw, p_abort); - } - - void seek(double p_seconds,abort_callback & p_abort) { - m_instance.decode_seek(p_seconds,p_abort); - } - - bool can_seek() { - return m_instance.decode_can_seek(); - } - - bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) { - return m_instance.decode_get_dynamic_info(p_out,p_timestamp_delta); - } - - bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) { - return m_instance.decode_get_dynamic_info_track(p_out,p_timestamp_delta); - } - - void on_idle(abort_callback & p_abort) { - m_instance.decode_on_idle(p_abort); - } - - void set_logger(event_logger::ptr ptr) { - m_instance.set_logger(ptr); - } - - // input_info_writer methods - - void set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) { - m_instance.retag_set_info(p_subsong,p_info,p_abort); - } - - void commit(abort_callback & p_abort) { - m_instance.retag_commit(p_abort); - } - -private: - I m_instance; -}; - -//! Helper used by input_singletrack_factory_t, do not use directly. Translates input_impl calls to input_singletrack_impl calls. -template -class input_wrapper_singletrack_t -{ -public: - input_wrapper_singletrack_t() {} - - void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) { - m_instance.open(p_filehint,p_path,p_reason,p_abort); - } - - void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { - if (p_subsong != 0) throw exception_io_data(); - m_instance.get_info(p_info,p_abort); - } - - t_uint32 get_subsong_count() { - return 1; - } - - t_uint32 get_subsong(t_uint32 p_index) { - assert(p_index == 0); - return 0; - } - - t_filestats get_file_stats(abort_callback & p_abort) { - return m_instance.get_file_stats(p_abort); - } - - void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { - if (p_subsong != 0) throw exception_io_data(); - m_instance.decode_initialize(p_flags,p_abort); - } - - bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) {return m_instance.decode_run(p_chunk,p_abort);} - void decode_seek(double p_seconds,abort_callback & p_abort) {m_instance.decode_seek(p_seconds,p_abort);} - bool decode_can_seek() {return m_instance.decode_can_seek();} - bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {return m_instance.decode_get_dynamic_info(p_out,p_timestamp_delta);} - bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {return m_instance.decode_get_dynamic_info_track(p_out,p_timestamp_delta);} - void decode_on_idle(abort_callback & p_abort) {m_instance.decode_on_idle(p_abort);} - - void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) { - if (p_subsong != 0) throw exception_io_data(); - m_instance.retag(p_info,p_abort); - } - - bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { - return m_instance.decode_run_raw(p_chunk, p_raw, p_abort); - } - - void set_logger(event_logger::ptr ptr) {m_instance.set_logger(ptr);} - - void retag_commit(abort_callback & p_abort) {} - - static bool g_is_our_content_type(const char * p_content_type) {return I::g_is_our_content_type(p_content_type);} - static bool g_is_our_path(const char * p_path,const char * p_extension) {return I::g_is_our_path(p_path,p_extension);} - - -private: - I m_instance; -}; - -//! Helper; standard input_entry implementation. Do not instantiate this directly, use input_factory_t or one of other input_*_factory_t helpers instead. -template -class input_entry_impl_t : public input_entry -{ -private: - - template - void instantiate_t(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) - { - service_ptr_t< service_impl_t > > temp; - temp = new service_impl_t >(); - temp->open(p_filehint,p_path,p_reason,p_abort); - p_instance = temp.get_ptr(); - } -public: - bool is_our_content_type(const char * p_type) {return I::g_is_our_content_type(p_type);} - bool is_our_path(const char * p_full_path,const char * p_extension) {return I::g_is_our_path(p_full_path,p_extension);} - - void open_for_decoding(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) { - instantiate_t(p_instance,p_filehint,p_path,input_open_decode,p_abort); - } - - void open_for_info_read(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) { - instantiate_t(p_instance,p_filehint,p_path,input_open_info_read,p_abort); - } - - void open_for_info_write(service_ptr_t & p_instance,service_ptr_t p_filehint,const char * p_path,abort_callback & p_abort) { - instantiate_t(p_instance,p_filehint,p_path,input_open_info_write,p_abort); - } - - void get_extended_data(service_ptr_t p_filehint,const playable_location & p_location,const GUID & p_guid,mem_block_container & p_out,abort_callback & p_abort) { - p_out.reset(); - } - - unsigned get_flags() {return t_flags;} -}; - - -//! Stardard input factory. For reference of functions that must be supported by registered class, see input_impl.\n Usage: static input_factory_t g_myinputclass_factory;\n Note that input classes can't be registered through service_factory_t template directly. -template -class input_factory_t : public service_factory_single_t > {}; - -//! Non-multitrack-enabled input factory (helper) - hides multitrack management functions from input implementation; use this for inputs that handle file types where each physical file can contain only one user-visible playable track. For reference of functions that must be supported by registered class, see input_singletrack_impl.\n Usage: static input_singletrack_factory_t g_myinputclass_factory;\n Note that input classes can't be registered through service_factory_t template directly.template -template -class input_singletrack_factory_t : public service_factory_single_t,0> > {}; - -//! Extended version of input_factory_t, with non-default flags and supported interfaces. See: input_factory_t, input_entry::get_flags(). -template -class input_factory_ex_t : public service_factory_single_t > {}; - -//! Extended version of input_singletrack_factory_t, with non-default flags and supported interfaces. See: input_singletrack_factory_t, input_entry::get_flags(). -template -class input_singletrack_factory_ex_t : public service_factory_single_t,t_flags, t_decoder, t_inforeader, t_infowriter> > {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/library_manager.h b/tools/vio2sf/src/foobar/foobar2000/SDK/library_manager.h deleted file mode 100644 index fa8203290..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/library_manager.h +++ /dev/null @@ -1,181 +0,0 @@ -/*! -This service implements methods allowing you to interact with the Media Library.\n -All methods are valid from main thread only, unless noted otherwise.\n -To avoid race conditions, methods that alter library contents should not be called from inside global callbacks.\n -Usage: Use static_api_ptr_t to instantiate. \n - -Future compatibility notes: \n -In 0.9.6, the Media Library backend will be entirely reimplemented to perform tracking of folder content changes on its own. This API will still be provided for backwards compatibility, though most of methods will become stubs as their original purpose will be no longer valid. \n -To keep your component working sanely in future foobar2000 releases, do not depend on functions flagged as scheduled to be dropped - you can still call them, but keep in mind that they will become meaningless in the next major release. -*/ - -class NOVTABLE library_manager : public service_base { -public: - //! Interface for use with library_manager::enum_items(). - class NOVTABLE enum_callback { - public: - //! Return true to continue enumeration, false to abort. - virtual bool on_item(const metadb_handle_ptr & p_item) = 0; - }; - - //! Returns whether the specified item is in the Media Library or not. - virtual bool is_item_in_library(const metadb_handle_ptr & p_item) = 0; - //! Returns whether current user settings allow the specified item to be added to the Media Library or not. - virtual bool is_item_addable(const metadb_handle_ptr & p_item) = 0; - //! Returns whether current user settings allow the specified item path to be added to the Media Library or not. - virtual bool is_path_addable(const char * p_path) = 0; - //! Retrieves path of the specified item relative to the Media Library folder it is in. Returns true on success, false when the item is not in the Media Library. - //! SPECIAL WARNING: to allow multi-CPU optimizations to parse relative track paths, this API works in threads other than the main app thread. Main thread MUST be blocked while working in such scenarios, it's NOT safe to call from worker threads while the Media Library content/configuration might be getting altered. - virtual bool get_relative_path(const metadb_handle_ptr & p_item,pfc::string_base & p_out) = 0; - //! Calls callback method for every item in the Media Library. Note that order of items in Media Library is undefined. - virtual void enum_items(enum_callback & p_callback) = 0; - //! Scheduled to be dropped in 0.9.6 (will do nothing). \n - //! Adds specified items to the Media Library (items actually added will be filtered according to user settings). - virtual void add_items(const pfc::list_base_const_t & p_data) = 0; - //! Scheduled to be dropped in 0.9.6 (will do nothing). \n - //! Removes specified items from the Media Library (does nothing if specific item is not in the Media Library). - virtual void remove_items(const pfc::list_base_const_t & p_data) = 0; - //! Scheduled to be dropped in 0.9.6 (will do nothing). \n - //! Adds specified items to the Media Library (items actually added will be filtered according to user settings). The difference between this and add_items() is that items are not added immediately; the operation is queued and executed later, so it is safe to call from e.g. global callbacks. - virtual void add_items_async(const pfc::list_base_const_t & p_data) = 0; - - //! Scheduled to be dropped in 0.9.6 (will do nothing). \n - //! For internal use only; p_data must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly. - virtual void on_files_deleted_sorted(const pfc::list_base_const_t & p_data) = 0; - - //! Retrieves the entire Media Library content. - virtual void get_all_items(pfc::list_base_t & p_out) = 0; - - //! Returns whether Media Library functionality is enabled or not (to be exact: whether there's at least one Media Library folder present in settings), for e.g. notifying the user to change settings when trying to use a Media Library viewer without having configured the Media Library first. - virtual bool is_library_enabled() = 0; - //! Pops up the Media Library preferences page. - virtual void show_preferences() = 0; - - //! Scheduled to be dropped in 0.9.6. \n - //! Deprecated; use library_manager_v2::rescan_async() when possible.\n - //! Rescans user-specified Media Library directories for new files and removes references to files that no longer exist from the Media Library.\n - //! Note that this function creates modal dialog and does not return until the operation has completed.\n - virtual void rescan() = 0; - - //! Scheduled to be dropped in 0.9.6. \n - //! Deprecated; use library_manager_v2::check_dead_entries_async() when possible.\n - //! Hints Media Library about possible dead items, typically used for "remove dead entries" context action in ML viewers. The implementation will verify whether the items are actually dead before ML contents are altered.\n - //! Note that this function creates modal dialog and does not return until the operation has completed.\n - virtual void check_dead_entries(const pfc::list_base_t & p_list) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_manager); -}; - -//! \since 0.9.3 -class NOVTABLE library_manager_v2 : public library_manager { -public: - //! Scheduled to be dropped in 0.9.6 (will always return false). \n - //! Returns whether a rescan process is currently running. - virtual bool is_rescan_running() = 0; - - //! Scheduled to be dropped in 0.9.6 (will do nothing and instantly signal completion). \n - //! Starts an async rescan process. Note that if another process is already running, the process is silently aborted. - //! @param p_parent Parent window for displayed progress dialog. - //! @param p_notify Allows caller to receive notifications about the process finishing. Status code: 1 on success, 0 on user abort. Pass NULL if caller doesn't care. - virtual void rescan_async(HWND p_parent,completion_notify_ptr p_notify) = 0; - - //! Scheduled to be dropped in 0.9.6 (will do nothing and instantly signal completion). \n - //! Hints Media Library about possible dead items, typically used for "remove dead entries" context action in ML viewers. The implementation will verify whether the items are actually dead before ML contents are altered.\n - //! @param p_list List of items to process. - //! @param p_parent Parent window for displayed progress dialog. - //! @param p_notify Allows caller to receive notifications about the process finishing. Status code: 1 on success, 0 on user abort. Pass NULL if caller doesn't care. - virtual void check_dead_entries_async(const pfc::list_base_const_t & p_list,HWND p_parent,completion_notify_ptr p_notify) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(library_manager_v2,library_manager); -}; - - -class NOVTABLE library_callback_dynamic { -public: - //! Called when new items are added to the Media Library. - virtual void on_items_added(const pfc::list_base_const_t & p_data) = 0; - //! Called when some items have been removed from the Media Library. - virtual void on_items_removed(const pfc::list_base_const_t & p_data) = 0; - //! Called when some items in the Media Library have been modified. - virtual void on_items_modified(const pfc::list_base_const_t & p_data) = 0; -}; - -//! \since 0.9.5 -class NOVTABLE library_manager_v3 : public library_manager_v2 { -public: - //! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved tracks. - //! @returns True on success, false when the feature has not been configured. - virtual bool get_new_file_pattern_tracks(pfc::string_base & p_directory,pfc::string_base & p_format) = 0; - //! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved full album images. - //! @returns True on success, false when the feature has not been configured. - virtual bool get_new_file_pattern_images(pfc::string_base & p_directory,pfc::string_base & p_format) = 0; - - virtual void register_callback(library_callback_dynamic * p_callback) = 0; - virtual void unregister_callback(library_callback_dynamic * p_callback) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(library_manager_v3,library_manager_v2); -}; - -class library_callback_dynamic_impl_base : public library_callback_dynamic { -public: - library_callback_dynamic_impl_base() {static_api_ptr_t()->register_callback(this);} - ~library_callback_dynamic_impl_base() {static_api_ptr_t()->unregister_callback(this);} - - //stub implementations - avoid pure virtual function call issues - void on_items_added(metadb_handle_list_cref p_data) {} - void on_items_removed(metadb_handle_list_cref p_data) {} - void on_items_modified(metadb_handle_list_cref p_data) {} - - PFC_CLASS_NOT_COPYABLE_EX(library_callback_dynamic_impl_base); -}; - -//! Callback service receiving notifications about Media Library content changes. Methods called only from main thread.\n -//! Use library_callback_factory_t template to register. -class NOVTABLE library_callback : public service_base { -public: - //! Called when new items are added to the Media Library. - virtual void on_items_added(const pfc::list_base_const_t & p_data) = 0; - //! Called when some items have been removed from the Media Library. - virtual void on_items_removed(const pfc::list_base_const_t & p_data) = 0; - //! Called when some items in the Media Library have been modified. - virtual void on_items_modified(const pfc::list_base_const_t & p_data) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_callback); -}; - -template -class library_callback_factory_t : public service_factory_single_t {}; - -//! Implement this service to appear on "library viewers" list in Media Library preferences page.\n -//! Use library_viewer_factory_t to register. -class NOVTABLE library_viewer : public service_base { -public: - //! Retrieves GUID of your preferences page (pfc::guid_null if you don't have one). - virtual GUID get_preferences_page() = 0; - //! Queries whether "activate" action is supported (relevant button will be disabled if it's not). - virtual bool have_activate() = 0; - //! Activates your Media Library viewer component (e.g. shows its window). - virtual void activate() = 0; - //! Retrieves GUID of your library_viewer implementation, for internal identification. Note that this not the same as preferences page GUID. - virtual GUID get_guid() = 0; - //! Retrieves name of your Media Library viewer, a null-terminated UTF-8 encoded string. - virtual const char * get_name() = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_viewer); -}; - -template -class library_viewer_factory_t : public service_factory_single_t {}; - - - - -//! \since 0.9.5.4 -//! Allows you to spawn a popup Media Library Search window with any query string that you specify. \n -//! Usage: static_api_ptr_t()->show("querygoeshere"); -class NOVTABLE library_search_ui : public service_base { -public: - virtual void show(const char * query) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_search_ui) -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/link_resolver.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/link_resolver.cpp deleted file mode 100644 index 26c6c3ed4..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/link_resolver.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "foobar2000.h" - -bool link_resolver::g_find(service_ptr_t & p_out,const char * p_path) -{ - service_enum_t e; - service_ptr_t ptr; - pfc::string_extension ext(p_path); - while(e.next(ptr)) - { - if (ptr->is_our_path(p_path,ext)) - { - p_out = ptr; - return true; - } - } - return false; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/link_resolver.h b/tools/vio2sf/src/foobar/foobar2000/SDK/link_resolver.h deleted file mode 100644 index 8f09a1e02..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/link_resolver.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _foobar2000_sdk_link_resolver_h_ -#define _foobar2000_sdk_link_resolver_h_ - -//! Interface for resolving different sorts of link files. -//! Utilized by mechanisms that convert filesystem path into list of playable locations. -//! For security reasons, link may only point to playable object path, not to a playlist or another link. - -class NOVTABLE link_resolver : public service_base -{ -public: - - //! Tests whether specified file is supported by this link_resolver service. - //! @param p_path Path of file being queried. - //! @param p_extension Extension of file being queried. This is provided for performance reasons, path already includes it. - virtual bool is_our_path(const char * p_path,const char * p_extension) = 0; - - //! Resolves a link file. Before this is called, path must be accepted by is_our_path(). - //! @param p_filehint Optional file interface to use. If null/empty, implementation should open file by itself. - //! @param p_path Path of link file to resolve. - //! @param p_out Receives path the link is pointing to. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void resolve(service_ptr_t p_filehint,const char * p_path,pfc::string_base & p_out,abort_callback & p_abort) = 0; - - //! Helper function; finds link_resolver interface that supports specified link file. - //! @param p_out Receives link_resolver interface on success. - //! @param p_path Path of file to query. - //! @returns True on success, false on failure (no interface that supports specified path could be found). - static bool g_find(service_ptr_t & p_out,const char * p_path); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(link_resolver); -}; - -#endif //_foobar2000_sdk_link_resolver_h_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/main_thread_callback.h b/tools/vio2sf/src/foobar/foobar2000/SDK/main_thread_callback.h deleted file mode 100644 index d5c6d89ac..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/main_thread_callback.h +++ /dev/null @@ -1,20 +0,0 @@ -//! Callback object class for main_thread_callback_manager service. -class NOVTABLE main_thread_callback : public service_base { -public: - //! Gets called from main app thread. See main_thread_callback_manager description for more info. - virtual void callback_run() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(main_thread_callback,service_base); -}; - -/*! -Allows you to queue a callback object to be called from main app thread. This is commonly used to trigger main-thread-only API calls from worker threads.\n -This can be also used from main app thread, to avoid race conditions when trying to use APIs that dispatch global callbacks from inside some other global callback, or using message loops / modal dialogs inside global callbacks. -*/ -class NOVTABLE main_thread_callback_manager : public service_base { -public: - //! Queues a callback object. This can be called from any thread, implementation ensures multithread safety. Implementation will call p_callback->callback_run() once later. To get it called repeatedly, you would need to add your callback again. - virtual void add_callback(service_ptr_t p_callback) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(main_thread_callback_manager); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/mainmenu.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/mainmenu.cpp deleted file mode 100644 index 454b292ba..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/mainmenu.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "foobar2000.h" - -bool mainmenu_commands::g_execute(const GUID & p_guid,service_ptr_t p_callback) { - service_enum_t e; - service_ptr_t ptr; - while(e.next(ptr)) { - const t_uint32 count = ptr->get_command_count(); - for(t_uint32 n=0;nget_command(n) == p_guid) { - ptr->execute(n,p_callback); - return true; - } - } - } - return false; -} - -bool mainmenu_commands::g_find_by_name(const char * p_name,GUID & p_guid) { - service_enum_t e; - service_ptr_t ptr; - pfc::string8_fastalloc temp; - while(e.next(ptr)) { - const t_uint32 count = ptr->get_command_count(); - for(t_uint32 n=0;nget_name(n,temp); - if (stricmp_utf8(temp,p_name) == 0) { - p_guid = ptr->get_command(n); - return true; - } - } - } - return false; - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/mem_block_container.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/mem_block_container.cpp deleted file mode 100644 index a1961b94a..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/mem_block_container.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "foobar2000.h" - -void mem_block_container::from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) { - if (p_bytes == 0) {set_size(0);} - set_size(p_bytes); - p_stream->read_object(get_ptr(),p_bytes,p_abort); -} - -void mem_block_container::set(const void * p_buffer,t_size p_size) { - set_size(p_size); - memcpy(get_ptr(),p_buffer,p_size); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/mem_block_container.h b/tools/vio2sf/src/foobar/foobar2000/SDK/mem_block_container.h deleted file mode 100644 index b1309ff25..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/mem_block_container.h +++ /dev/null @@ -1,68 +0,0 @@ -//! Generic interface for a memory block; used by various other interfaces to return memory blocks while allowing caller to allocate. -class NOVTABLE mem_block_container { -public: - virtual const void * get_ptr() const = 0; - virtual void * get_ptr() = 0; - virtual t_size get_size() const = 0; - virtual void set_size(t_size p_size) = 0; - - void from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort); - - void set(const void * p_buffer,t_size p_size); - void set(const mem_block_container & source) {copy(source);} - template void set(const t_source & source) { - pfc::static_assert(); - set(source.get_ptr(), source.get_size()); - } - - inline void copy(const mem_block_container & p_source) {set(p_source.get_ptr(),p_source.get_size());} - inline void reset() {set_size(0);} - - const mem_block_container & operator=(const mem_block_container & p_source) {copy(p_source);return *this;} - -protected: - mem_block_container() {} - ~mem_block_container() {} -}; - -//! mem_block_container implementation. -template class t_alloc = pfc::alloc_standard> -class mem_block_container_impl_t : public mem_block_container { -public: - const void * get_ptr() const {return m_data.get_ptr();} - void * get_ptr() {return m_data.get_ptr();} - t_size get_size() const {return m_data.get_size();} - void set_size(t_size p_size) { - m_data.set_size(p_size); - } -private: - pfc::array_t m_data; -}; - -typedef mem_block_container_impl_t<> mem_block_container_impl; - -class mem_block_container_temp_impl : public mem_block_container { -public: - mem_block_container_temp_impl(void * p_buffer,t_size p_size) : m_buffer(p_buffer), m_buffer_size(p_size), m_size(0) {} - const void * get_ptr() const {return m_buffer;} - void * get_ptr() {return m_buffer;} - t_size get_size() const {return m_size;} - void set_size(t_size p_size) {if (p_size > m_buffer_size) throw pfc::exception_overflow(); m_size = p_size;} -private: - t_size m_size,m_buffer_size; - void * m_buffer; -}; - -template -class mem_block_container_ref_impl : public mem_block_container { -public: - mem_block_container_ref_impl(t_ref & ref) : m_ref(ref) { - pfc::static_assert(); - } - const void * get_ptr() const {return m_ref.get_ptr();} - void * get_ptr() {return m_ref.get_ptr();} - t_size get_size() const {return m_ref.get_size();} - void set_size(t_size p_size) {m_ref.set_size(p_size);} -private: - t_ref & m_ref; -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/menu.h b/tools/vio2sf/src/foobar/foobar2000/SDK/menu.h deleted file mode 100644 index 42fc903d1..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/menu.h +++ /dev/null @@ -1,128 +0,0 @@ -class NOVTABLE mainmenu_group : public service_base { -public: - virtual GUID get_guid() = 0; - virtual GUID get_parent() = 0; - virtual t_uint32 get_sort_priority() = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_group); -}; - -class NOVTABLE mainmenu_group_popup : public mainmenu_group { -public: - virtual void get_display_string(pfc::string_base & p_out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(mainmenu_group_popup,mainmenu_group); -}; - -class NOVTABLE mainmenu_commands : public service_base { -public: - enum { - flag_disabled = 1<<0, - flag_checked = 1<<1, - flag_radiochecked = 1<<2, - sort_priority_base = 0x10000, - sort_priority_dontcare = 0x80000000, - sort_priority_last = infinite, - }; - - //! Retrieves number of implemented commands. Index parameter of other methods must be in 0....command_count-1 range. - virtual t_uint32 get_command_count() = 0; - //! Retrieves GUID of specified command. - virtual GUID get_command(t_uint32 p_index) = 0; - //! Retrieves name of item, for list of commands to assign keyboard shortcuts to etc. - virtual void get_name(t_uint32 p_index,pfc::string_base & p_out) = 0; - //! Retrieves item's description for statusbar etc. - virtual bool get_description(t_uint32 p_index,pfc::string_base & p_out) = 0; - //! Retrieves GUID of owning menu group. - virtual GUID get_parent() = 0; - //! Retrieves sorting priority of the command; the lower the number, the upper in the menu your commands will appear. Third party components should use sorting_priority_base and up (values below are reserved for internal use). In case of equal priority, order is undefined. - virtual t_uint32 get_sort_priority() {return sort_priority_dontcare;} - //! Retrieves display string and display flags to use when menu is about to be displayed. If returns false, menu item won't be displayed. You can create keyboard-shortcut-only commands by always returning false from get_display(). - virtual bool get_display(t_uint32 p_index,pfc::string_base & p_text,t_uint32 & p_flags) {p_flags = 0;get_name(p_index,p_text);return true;} - //! Executes the command. p_callback parameter is reserved for future use and should be ignored / set to null pointer. - virtual void execute(t_uint32 p_index,service_ptr_t p_callback) = 0; - - static bool g_execute(const GUID & p_guid,service_ptr_t p_callback = service_ptr_t()); - static bool g_find_by_name(const char * p_name,GUID & p_guid); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_commands); -}; - -class NOVTABLE mainmenu_manager : public service_base { -public: - enum { - flag_show_shortcuts = 1 << 0, - flag_show_shortcuts_global = 1 << 1, - }; - - virtual void instantiate(const GUID & p_root) = 0; - -#ifdef _WIN32 - virtual void generate_menu_win32(HMENU p_menu,t_uint32 p_id_base,t_uint32 p_id_count,t_uint32 p_flags) = 0; -#else -#error portme -#endif - //@param p_id Identifier of command to execute, relative to p_id_base of generate_menu_*() - //@returns true if command was executed successfully, false if not (e.g. command with given identifier not found). - virtual bool execute_command(t_uint32 p_id,service_ptr_t p_callback = service_ptr_t()) = 0; - - virtual bool get_description(t_uint32 p_id,pfc::string_base & p_out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_manager); -}; - -class mainmenu_groups { -public: - static const GUID file,view,edit,playback,library,help; - static const GUID file_open,file_add,file_playlist,file_etc; - static const GUID playback_controls,playback_etc; - static const GUID view_visualisations, view_alwaysontop; - static const GUID edit_part1,edit_part2,edit_part3; - static const GUID edit_part2_selection,edit_part2_sort,edit_part2_selection_sort; - static const GUID file_etc_preferences, file_etc_exit; - static const GUID help_about; - static const GUID library_refresh; - - enum {priority_edit_part1,priority_edit_part2,priority_edit_part3}; - enum {priority_edit_part2_commands,priority_edit_part2_selection,priority_edit_part2_sort}; - enum {priority_edit_part2_selection_commands,priority_edit_part2_selection_sort}; - enum {priority_file_open,priority_file_add,priority_file_playlist,priority_file_etc = mainmenu_commands::sort_priority_last}; -}; - - -class mainmenu_group_impl : public mainmenu_group { -public: - mainmenu_group_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority) {} - GUID get_guid() {return m_guid;} - GUID get_parent() {return m_parent;} - t_uint32 get_sort_priority() {return m_priority;} -private: - GUID m_guid,m_parent; t_uint32 m_priority; -}; - -class mainmenu_group_popup_impl : public mainmenu_group_popup { -public: - mainmenu_group_popup_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority), m_name(p_name) {} - GUID get_guid() {return m_guid;} - GUID get_parent() {return m_parent;} - t_uint32 get_sort_priority() {return m_priority;} - void get_display_string(pfc::string_base & p_out) {p_out = m_name;} -private: - GUID m_guid,m_parent; t_uint32 m_priority; pfc::string8 m_name; -}; - -typedef service_factory_single_t __mainmenu_group_factory; -typedef service_factory_single_t __mainmenu_group_popup_factory; - -class mainmenu_group_factory : public __mainmenu_group_factory { -public: - inline mainmenu_group_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : __mainmenu_group_factory(p_guid,p_parent,p_priority) {} -}; - -class mainmenu_group_popup_factory : public __mainmenu_group_popup_factory { -public: - inline mainmenu_group_popup_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : __mainmenu_group_popup_factory(p_guid,p_parent,p_priority,p_name) {} -}; - -template -class mainmenu_commands_factory_t : public service_factory_single_t {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_helpers.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/menu_helpers.cpp deleted file mode 100644 index e3d8d39e5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_helpers.cpp +++ /dev/null @@ -1,326 +0,0 @@ -#include "foobar2000.h" - - -bool menu_helpers::context_get_description(const GUID& p_guid,pfc::string_base & out) { - service_ptr_t ptr; t_uint32 index; - if (!menu_item_resolver::g_resolve_context_command(p_guid, ptr, index)) return false; - bool rv = ptr->get_item_description(index, out); - if (!rv) out.reset(); - return rv; -} - -static bool run_context_command_internal(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller) { - if (data.get_count() == 0) return false; - service_ptr_t ptr; t_uint32 index; - if (!menu_item_resolver::g_resolve_context_command(p_command, ptr, index)) return false; - - { - TRACK_CALL_TEXT("menu_helpers::run_command(), by GUID"); - ptr->item_execute_simple(index, p_subcommand, data, caller); - } - - return true; -} - -bool menu_helpers::run_command_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data) -{ - return run_context_command_internal(p_command,p_subcommand,data,contextmenu_item::caller_undefined); -} - -bool menu_helpers::run_command_context_ex(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller) -{ - return run_context_command_internal(p_command,p_subcommand,data,caller); -} - -bool menu_helpers::test_command_context(const GUID & p_guid) -{ - service_ptr_t ptr; t_uint32 index; - return menu_item_resolver::g_resolve_context_command(p_guid, ptr, index); -} - -static bool g_is_checked(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller) -{ - service_ptr_t ptr; t_uint32 index; - if (!menu_item_resolver::g_resolve_context_command(p_command, ptr, index)) return false; - - unsigned displayflags = 0; - pfc::string_formatter dummystring; - if (!ptr->item_get_display_data(dummystring,displayflags,index,p_subcommand,data,caller)) return false; - return (displayflags & contextmenu_item_node::FLAG_CHECKED) != 0; - -} - -bool menu_helpers::is_command_checked_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data) -{ - return g_is_checked(p_command,p_subcommand,data,contextmenu_item::caller_undefined); -} - -bool menu_helpers::is_command_checked_context_playlist(const GUID & p_command,const GUID & p_subcommand) -{ - metadb_handle_list temp; - static_api_ptr_t api; - api->activeplaylist_get_selected_items(temp); - return g_is_checked(p_command,p_subcommand,temp,contextmenu_item::caller_playlist); -} - - - - - - - -bool menu_helpers::run_command_context_playlist(const GUID & p_command,const GUID & p_subcommand) -{ - metadb_handle_list temp; - static_api_ptr_t api; - api->activeplaylist_get_selected_items(temp); - return run_command_context_ex(p_command,p_subcommand,temp,contextmenu_item::caller_playlist); -} - -bool menu_helpers::run_command_context_now_playing(const GUID & p_command,const GUID & p_subcommand) -{ - metadb_handle_ptr item; - if (!static_api_ptr_t()->get_now_playing(item)) return false;//not playing - return run_command_context_ex(p_command,p_subcommand,pfc::list_single_ref_t(item),contextmenu_item::caller_now_playing); -} - - -bool menu_helpers::guid_from_name(const char * p_name,unsigned p_name_len,GUID & p_out) -{ - service_enum_t e; - service_ptr_t ptr; - pfc::string8_fastalloc nametemp; - while(e.next(ptr)) - { - unsigned n, m = ptr->get_num_items(); - for(n=0;nget_item_name(n,nametemp); - if (!strcmp_ex(nametemp,infinite,p_name,p_name_len)) - { - p_out = ptr->get_item_guid(n); - return true; - } - } - } - return false; -} - -bool menu_helpers::name_from_guid(const GUID & p_guid,pfc::string_base & p_out) { - service_ptr_t ptr; t_uint32 index; - if (!menu_item_resolver::g_resolve_context_command(p_guid, ptr, index)) return false; - ptr->get_item_name(index, p_out); - return true; -} - - -static unsigned calc_total_action_count() -{ - service_enum_t e; - service_ptr_t ptr; - unsigned ret = 0; - while(e.next(ptr)) - ret += ptr->get_num_items(); - return ret; -} - - -const char * menu_helpers::guid_to_name_table::search(const GUID & p_guid) -{ - if (!m_inited) - { - m_data.set_size(calc_total_action_count()); - t_size dataptr = 0; - pfc::string8_fastalloc nametemp; - - service_enum_t e; - service_ptr_t ptr; - while(e.next(ptr)) - { - unsigned n, m = ptr->get_num_items(); - for(n=0;nget_item_name(n,nametemp); - m_data[dataptr].m_name = _strdup(nametemp); - m_data[dataptr].m_guid = ptr->get_item_guid(n); - dataptr++; - } - } - assert(dataptr == m_data.get_size()); - - pfc::sort_t(m_data,entry_compare,m_data.get_size()); - m_inited = true; - } - t_size index; - if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,p_guid,index)) - return m_data[index].m_name; - else - return 0; -} - -int menu_helpers::guid_to_name_table::entry_compare_search(const entry & entry1,const GUID & entry2) -{ - return pfc::guid_compare(entry1.m_guid,entry2); -} - -int menu_helpers::guid_to_name_table::entry_compare(const entry & entry1,const entry & entry2) -{ - return pfc::guid_compare(entry1.m_guid,entry2.m_guid); -} - -menu_helpers::guid_to_name_table::guid_to_name_table() -{ - m_inited = false; -} - -menu_helpers::guid_to_name_table::~guid_to_name_table() -{ - t_size n, m = m_data.get_size(); - for(n=0;n e; - service_ptr_t ptr; - while(e.next(ptr)) - { - unsigned n, m = ptr->get_num_items(); - for(n=0;nget_item_name(n,nametemp); - m_data[dataptr].m_name = _strdup(nametemp); - m_data[dataptr].m_guid = ptr->get_item_guid(n); - dataptr++; - } - } - assert(dataptr == m_data.get_size()); - - pfc::sort_t(m_data,entry_compare,m_data.get_size()); - m_inited = true; - } - t_size index; - search_entry temp = {p_name,p_name_len}; - if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,temp,index)) - { - p_out = m_data[index].m_guid; - return true; - } - else - return false; -} - -menu_helpers::name_to_guid_table::name_to_guid_table() -{ - m_inited = false; -} - -menu_helpers::name_to_guid_table::~name_to_guid_table() -{ - t_size n, m = m_data.get_size(); - for(n=0;n & p_item,unsigned & p_index) -{ - pfc::string8_fastalloc path,name; - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { -// if (ptr->get_type()==type) - { - unsigned action,num_actions = ptr->get_num_items(); - for(action=0;actionget_item_default_path(action,path); ptr->get_item_name(action,name); - if (!path.is_empty()) path += "/"; - path += name; - if (!stricmp_utf8(p_name,path)) - { - p_item = ptr; - p_index = action; - return true; - } - } - } - } while(e.next(ptr)); - return false; - -} - -bool menu_helpers::find_command_by_name(const char * p_name,GUID & p_command) -{ - service_ptr_t item; - unsigned index; - bool ret = find_command_by_name(p_name,item,index); - if (ret) p_command = item->get_item_guid(index); - return ret; -} - - -bool standard_commands::run_main(const GUID & p_guid) { - t_uint32 index; - mainmenu_commands::ptr ptr; - if (!menu_item_resolver::g_resolve_main_command(p_guid, ptr, index)) return false; - ptr->execute(index,service_ptr_t()); - return true; -} - -bool menu_item_resolver::g_resolve_context_command(const GUID & id, contextmenu_item::ptr & out, t_uint32 & out_index) { - menu_item_resolver::ptr api; - if (service_enum_t().first(api)) { - return api->resolve_context_command(id, out, out_index); - } else { - service_enum_t e; service_ptr_t ptr; - while(e.next(ptr)) { - const unsigned num_actions = ptr->get_num_items(); - for(unsigned action=0;actionget_item_guid(action)) { - out_index = action; out = ptr; return true; - } - } - } - return false; - } -} -bool menu_item_resolver::g_resolve_main_command(const GUID & id, mainmenu_commands::ptr & out, t_uint32 & out_index) { - menu_item_resolver::ptr api; - if (service_enum_t().first(api)) { - return api->resolve_main_command(id, out, out_index); - } else { - service_enum_t e; service_ptr_t ptr; - while(e.next(ptr)) { - const t_uint32 total = ptr->get_command_count(); - for(t_uint32 walk = 0; walk < total; ++walk) { - if (id == ptr->get_command(walk)) { - out_index = walk; out = ptr; return true; - } - } - } - return false; - } -} - diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_helpers.h b/tools/vio2sf/src/foobar/foobar2000/SDK/menu_helpers.h deleted file mode 100644 index 623324528..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_helpers.h +++ /dev/null @@ -1,182 +0,0 @@ -namespace menu_helpers { -#ifdef _WIN32 - void win32_auto_mnemonics(HMENU menu); -#endif - - bool run_command_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data); - bool run_command_context_ex(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data,const GUID & caller); - bool run_command_context_playlist(const GUID & p_command,const GUID & p_subcommand); - bool run_command_context_now_playing(const GUID & p_command,const GUID & p_subcommand); - - bool test_command_context(const GUID & p_guid); - - bool is_command_checked_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t & data); - bool is_command_checked_context_playlist(const GUID & p_command,const GUID & p_subcommand); - - bool find_command_by_name(const char * p_name,service_ptr_t & p_item,unsigned & p_index); - bool find_command_by_name(const char * p_name,GUID & p_command); - - bool context_get_description(const GUID& p_guid,pfc::string_base & out); - - bool guid_from_name(const char * p_name,unsigned p_name_len,GUID & p_out); - bool name_from_guid(const GUID & p_guid,pfc::string_base & p_out); - - class guid_to_name_table - { - public: - guid_to_name_table(); - ~guid_to_name_table(); - const char * search(const GUID & p_guid); - private: - struct entry { - char* m_name; - GUID m_guid; - }; - pfc::array_t m_data; - bool m_inited; - - static int entry_compare_search(const entry & entry1,const GUID & entry2); - static int entry_compare(const entry & entry1,const entry & entry2); - }; - - class name_to_guid_table - { - public: - name_to_guid_table(); - ~name_to_guid_table(); - bool search(const char * p_name,unsigned p_name_len,GUID & p_out); - private: - struct entry { - char* m_name; - GUID m_guid; - }; - pfc::array_t m_data; - bool m_inited; - struct search_entry { - const char * m_name; unsigned m_name_len; - }; - - static int entry_compare_search(const entry & entry1,const search_entry & entry2); - static int entry_compare(const entry & entry1,const entry & entry2); - }; - -}; - - - -class standard_commands -{ -public: - static const GUID - guid_context_file_properties, guid_context_file_open_directory, guid_context_copy_names, - guid_context_send_to_playlist, guid_context_reload_info, guid_context_reload_info_if_changed, - guid_context_rewrite_info, guid_context_remove_tags, - guid_context_convert_run, guid_context_convert_run_singlefile,guid_context_convert_run_withcue, - guid_context_write_cd, - guid_context_rg_scan_track, guid_context_rg_scan_album, guid_context_rg_scan_album_multi, - guid_context_rg_remove, guid_context_save_playlist, guid_context_masstag_edit, - guid_context_masstag_rename, - guid_main_always_on_top, guid_main_preferences, guid_main_about, - guid_main_exit, guid_main_restart, guid_main_activate, - guid_main_hide, guid_main_activate_or_hide, guid_main_titleformat_help, - guid_main_next, guid_main_previous, - guid_main_next_or_random, guid_main_random, guid_main_pause, - guid_main_play, guid_main_play_or_pause, guid_main_rg_set_album, - guid_main_rg_set_track, guid_main_rg_disable, guid_main_stop, - guid_main_stop_after_current, guid_main_volume_down, guid_main_volume_up, - guid_main_volume_mute, guid_main_add_directory, guid_main_add_files, - guid_main_add_location, guid_main_add_playlist, guid_main_clear_playlist, - guid_main_create_playlist, guid_main_highlight_playing, guid_main_load_playlist, - guid_main_next_playlist, guid_main_previous_playlist, guid_main_open, - guid_main_remove_playlist, guid_main_remove_dead_entries, guid_main_remove_duplicates, - guid_main_rename_playlist, guid_main_save_all_playlists, guid_main_save_playlist, - guid_main_playlist_search, guid_main_playlist_sel_crop, guid_main_playlist_sel_remove, - guid_main_playlist_sel_invert, guid_main_playlist_undo, guid_main_show_console, - guid_main_play_cd, guid_main_restart_resetconfig, guid_main_record, - guid_main_playlist_moveback, guid_main_playlist_moveforward, guid_main_playlist_redo, - guid_main_playback_follows_cursor, guid_main_cursor_follows_playback, guid_main_saveconfig, - guid_main_playlist_select_all, guid_main_show_now_playing, - - guid_seek_ahead_1s, guid_seek_ahead_5s, guid_seek_ahead_10s, guid_seek_ahead_30s, - guid_seek_ahead_1min, guid_seek_ahead_2min, guid_seek_ahead_5min, guid_seek_ahead_10min, - - guid_seek_back_1s, guid_seek_back_5s, guid_seek_back_10s, guid_seek_back_30s, - guid_seek_back_1min, guid_seek_back_2min, guid_seek_back_5min, guid_seek_back_10min - ; - - static bool run_main(const GUID & guid); - static inline bool run_context(const GUID & guid,const pfc::list_base_const_t &data) {return menu_helpers::run_command_context(guid,pfc::guid_null,data);} - static inline bool run_context(const GUID & guid,const pfc::list_base_const_t &data,const GUID& caller) {return menu_helpers::run_command_context_ex(guid,pfc::guid_null,data,caller);} - - static inline bool context_file_properties(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_properties,data,caller);} - static inline bool context_file_open_directory(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_open_directory,data,caller);} - static inline bool context_copy_names(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_copy_names,data,caller);} - static inline bool context_send_to_playlist(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_send_to_playlist,data,caller);} - static inline bool context_reload_info(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info,data,caller);} - static inline bool context_reload_info_if_changed(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info_if_changed,data,caller);} - static inline bool context_rewrite_info(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rewrite_info,data,caller);} - static inline bool context_remove_tags(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_remove_tags,data,caller);} - static inline bool context_convert_run(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run,data,caller);} - static inline bool context_convert_run_singlefile(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run_singlefile,data,caller);} - static inline bool context_write_cd(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_write_cd,data,caller);} - static inline bool context_rg_scan_track(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_track,data,caller);} - static inline bool context_rg_scan_album(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album,data,caller);} - static inline bool context_rg_scan_album_multi(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album_multi,data,caller);} - static inline bool context_rg_remove(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_remove,data,caller);} - static inline bool context_save_playlist(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_save_playlist,data,caller);} - static inline bool context_masstag_edit(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_edit,data,caller);} - static inline bool context_masstag_rename(const pfc::list_base_const_t &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_rename,data,caller);} - static inline bool main_always_on_top() {return run_main(guid_main_always_on_top);} - static inline bool main_preferences() {return run_main(guid_main_preferences);} - static inline bool main_about() {return run_main(guid_main_about);} - static inline bool main_exit() {return run_main(guid_main_exit);} - static inline bool main_restart() {return run_main(guid_main_restart);} - static inline bool main_activate() {return run_main(guid_main_activate);} - static inline bool main_hide() {return run_main(guid_main_hide);} - static inline bool main_activate_or_hide() {return run_main(guid_main_activate_or_hide);} - static inline bool main_titleformat_help() {return run_main(guid_main_titleformat_help);} - static inline bool main_playback_follows_cursor() {return run_main(guid_main_playback_follows_cursor);} - static inline bool main_next() {return run_main(guid_main_next);} - static inline bool main_previous() {return run_main(guid_main_previous);} - static inline bool main_next_or_random() {return run_main(guid_main_next_or_random);} - static inline bool main_random() {return run_main(guid_main_random);} - static inline bool main_pause() {return run_main(guid_main_pause);} - static inline bool main_play() {return run_main(guid_main_play);} - static inline bool main_play_or_pause() {return run_main(guid_main_play_or_pause);} - static inline bool main_rg_set_album() {return run_main(guid_main_rg_set_album);} - static inline bool main_rg_set_track() {return run_main(guid_main_rg_set_track);} - static inline bool main_rg_disable() {return run_main(guid_main_rg_disable);} - static inline bool main_stop() {return run_main(guid_main_stop);} - static inline bool main_stop_after_current() {return run_main(guid_main_stop_after_current);} - static inline bool main_volume_down() {return run_main(guid_main_volume_down);} - static inline bool main_volume_up() {return run_main(guid_main_volume_up);} - static inline bool main_volume_mute() {return run_main(guid_main_volume_mute);} - static inline bool main_add_directory() {return run_main(guid_main_add_directory);} - static inline bool main_add_files() {return run_main(guid_main_add_files);} - static inline bool main_add_location() {return run_main(guid_main_add_location);} - static inline bool main_add_playlist() {return run_main(guid_main_add_playlist);} - static inline bool main_clear_playlist() {return run_main(guid_main_clear_playlist);} - static inline bool main_create_playlist() {return run_main(guid_main_create_playlist);} - static inline bool main_highlight_playing() {return run_main(guid_main_highlight_playing);} - static inline bool main_load_playlist() {return run_main(guid_main_load_playlist);} - static inline bool main_next_playlist() {return run_main(guid_main_next_playlist);} - static inline bool main_previous_playlist() {return run_main(guid_main_previous_playlist);} - static inline bool main_open() {return run_main(guid_main_open);} - static inline bool main_remove_playlist() {return run_main(guid_main_remove_playlist);} - static inline bool main_remove_dead_entries() {return run_main(guid_main_remove_dead_entries);} - static inline bool main_remove_duplicates() {return run_main(guid_main_remove_duplicates);} - static inline bool main_rename_playlist() {return run_main(guid_main_rename_playlist);} - static inline bool main_save_all_playlists() {return run_main(guid_main_save_all_playlists);} - static inline bool main_save_playlist() {return run_main(guid_main_save_playlist);} - static inline bool main_playlist_search() {return run_main(guid_main_playlist_search);} - static inline bool main_playlist_sel_crop() {return run_main(guid_main_playlist_sel_crop);} - static inline bool main_playlist_sel_remove() {return run_main(guid_main_playlist_sel_remove);} - static inline bool main_playlist_sel_invert() {return run_main(guid_main_playlist_sel_invert);} - static inline bool main_playlist_undo() {return run_main(guid_main_playlist_undo);} - static inline bool main_show_console() {return run_main(guid_main_show_console);} - static inline bool main_play_cd() {return run_main(guid_main_play_cd);} - static inline bool main_restart_resetconfig() {return run_main(guid_main_restart_resetconfig);} - static inline bool main_playlist_moveback() {return run_main(guid_main_playlist_moveback);} - static inline bool main_playlist_moveforward() {return run_main(guid_main_playlist_moveforward);} - static inline bool main_saveconfig() {return run_main(guid_main_saveconfig);} -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_item.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/menu_item.cpp deleted file mode 100644 index b4e5cbf58..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_item.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "foobar2000.h" - - - -bool contextmenu_item::item_get_display_data_root(pfc::string_base & p_out,unsigned & p_displayflags,unsigned p_index,const pfc::list_base_const_t & p_data,const GUID & p_caller) -{ - bool status = false; - pfc::ptrholder_t root ( instantiate_item(p_index,p_data,p_caller) ); - if (root.is_valid()) status = root->get_display_data(p_out,p_displayflags,p_data,p_caller); - return status; -} - - -static contextmenu_item_node * g_find_node(const GUID & p_guid,contextmenu_item_node * p_parent) -{ - if (p_parent->get_guid() == p_guid) return p_parent; - else if (p_parent->get_type() == contextmenu_item_node::TYPE_POPUP) - { - t_size n, m = p_parent->get_children_count(); - for(n=0;nget_child(n)); - if (temp) return temp; - } - return 0; - } - else return 0; -} - -bool contextmenu_item::item_get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,unsigned p_index,const GUID & p_node,const pfc::list_base_const_t & p_data,const GUID & p_caller) -{ - bool status = false; - pfc::ptrholder_t root ( instantiate_item(p_index,p_data,p_caller) ); - if (root.is_valid()) - { - contextmenu_item_node * node = g_find_node(p_node,root.get_ptr()); - if (node) status = node->get_display_data(p_out,p_displayflags,p_data,p_caller); - } - return status; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_manager.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/menu_manager.cpp deleted file mode 100644 index e5cfc1608..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/menu_manager.cpp +++ /dev/null @@ -1,401 +0,0 @@ -#include "foobar2000.h" - -#ifdef WIN32 - -static void fix_ampersand(const char * src,pfc::string_base & out) -{ - out.reset(); - unsigned ptr = 0; - while(src[ptr]) - { - if (src[ptr]=='&') - { - out.add_string("&&"); - ptr++; - while(src[ptr]=='&') - { - out.add_string("&&"); - ptr++; - } - } - else out.add_byte(src[ptr++]); - } -} - -static unsigned flags_to_win32(unsigned flags) -{ - unsigned ret = 0; - if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) {/* dealt with elsewhere */} - else if (flags & contextmenu_item_node::FLAG_CHECKED) ret |= MF_CHECKED; - if (flags & contextmenu_item_node::FLAG_DISABLED) ret |= MF_DISABLED; - if (flags & contextmenu_item_node::FLAG_GRAYED) ret |= MF_GRAYED; - return ret; -} - -void contextmenu_manager::win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id)//menu item identifiers are base_id<=Nget_type()==contextmenu_item_node::TYPE_POPUP) - { - pfc::string8_fastalloc temp; - t_size child_idx,child_num = parent->get_num_children(); - for(child_idx=0;child_idxget_child(child_idx); - if (child) - { - const char * name = child->get_name(); - if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;} - contextmenu_item_node::t_type type = child->get_type(); - if (type==contextmenu_item_node::TYPE_POPUP) - { - HMENU new_menu = CreatePopupMenu(); - uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(child->get_display_flags()),(UINT_PTR)new_menu,name); - win32_build_menu(new_menu,child,base_id,max_id); - } - else if (type==contextmenu_item_node::TYPE_SEPARATOR) - { - uAppendMenu(menu,MF_SEPARATOR,0,0); - } - else if (type==contextmenu_item_node::TYPE_COMMAND) - { - int id = child->get_id(); - if (id>=0 && (max_id<0 || idget_display_flags(); - const UINT ID = base_id+id; - uAppendMenu(menu,MF_STRING | flags_to_win32(flags),ID,name); - if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) CheckMenuRadioItem(menu,ID,ID,ID,MF_BYCOMMAND); - } - } - } - } - } -} - -#endif - -bool contextmenu_manager::get_description_by_id(unsigned id,pfc::string_base & out) { - contextmenu_node * ptr = find_by_id(id); - if (ptr == NULL) return false; - return ptr->get_description(out); -} -bool contextmenu_manager::execute_by_id(unsigned id) { - contextmenu_node * ptr = find_by_id(id); - if (ptr == NULL) return false; - ptr->execute(); - return true; -} - -#ifdef WIN32 - -void contextmenu_manager::win32_run_menu_popup(HWND parent,const POINT * pt) -{ - enum {ID_CUSTOM_BASE = 1}; - - int cmd; - - { - POINT p; - if (pt) p = *pt; - else GetCursorPos(&p); - - HMENU hmenu = CreatePopupMenu(); - try { - - win32_build_menu(hmenu,ID_CUSTOM_BASE,-1); - menu_helpers::win32_auto_mnemonics(hmenu); - - cmd = TrackPopupMenu(hmenu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,p.x,p.y,0,parent,0); - } catch(...) {DestroyMenu(hmenu); throw;} - - DestroyMenu(hmenu); - } - - if (cmd>0) - { - if (cmd>=ID_CUSTOM_BASE) - { - execute_by_id(cmd - ID_CUSTOM_BASE); - } - } -} - -void contextmenu_manager::win32_run_menu_context(HWND parent,const pfc::list_base_const_t & data,const POINT * pt,unsigned flags) -{ - service_ptr_t manager; - contextmenu_manager::g_create(manager); - manager->init_context(data,flags); - manager->win32_run_menu_popup(parent,pt); -} - -void contextmenu_manager::win32_run_menu_context_playlist(HWND parent,const POINT * pt,unsigned flags) -{ - service_ptr_t manager; - contextmenu_manager::g_create(manager); - manager->init_context_playlist(flags); - manager->win32_run_menu_popup(parent,pt); -} - - -namespace { - class mnemonic_manager - { - pfc::string8_fastalloc used; - bool is_used(unsigned c) - { - char temp[8]; - temp[pfc::utf8_encode_char(uCharLower(c),temp)]=0; - return !!strstr(used,temp); - } - - static bool is_alphanumeric(char c) - { - return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'); - } - - - - - void insert(const char * src,unsigned idx,pfc::string_base & out) - { - out.reset(); - out.add_string(src,idx); - out.add_string("&"); - out.add_string(src+idx); - used.add_char(uCharLower(src[idx])); - } - public: - bool check_string(const char * src) - {//check for existing mnemonics - const char * ptr = src; - while(ptr = strchr(ptr,'&')) - { - if (ptr[1]=='&') ptr+=2; - else - { - unsigned c = 0; - if (pfc::utf8_decode_char(ptr+1,c)>0) - { - if (!is_used(c)) used.add_char(uCharLower(c)); - } - return true; - } - } - return false; - } - bool process_string(const char * src,pfc::string_base & out)//returns if changed - { - if (check_string(src)) {out=src;return false;} - unsigned idx=0; - while(src[idx]==' ') idx++; - while(src[idx]) - { - if (is_alphanumeric(src[idx]) && !is_used(src[idx])) - { - insert(src,idx,out); - return true; - } - - while(src[idx] && src[idx]!=' ' && src[idx]!='\t') idx++; - if (src[idx]=='\t') break; - while(src[idx]==' ') idx++; - } - - //no success picking first letter of one of words - idx=0; - while(src[idx]) - { - if (src[idx]=='\t') break; - if (is_alphanumeric(src[idx]) && !is_used(src[idx])) - { - insert(src,idx,out); - return true; - } - idx++; - } - - //giving up - out = src; - return false; - } - }; -} - -void menu_helpers::win32_auto_mnemonics(HMENU menu) -{ - mnemonic_manager mgr; - unsigned n, m = GetMenuItemCount(menu); - pfc::string8_fastalloc temp,temp2; - for(n=0;n & data,WPARAM wp,const GUID & caller) -{ - if (data.get_count()==0) return false; - return process_keydown_ex(TYPE_CONTEXT,data,get_key_code(wp),caller); -} - -bool keyboard_shortcut_manager::on_keydown_auto(WPARAM wp) -{ - if (on_keydown(TYPE_MAIN,wp)) return true; - if (on_keydown(TYPE_CONTEXT_PLAYLIST,wp)) return true; - if (on_keydown(TYPE_CONTEXT_NOW_PLAYING,wp)) return true; - return false; -} - -bool keyboard_shortcut_manager::on_keydown_auto_playlist(WPARAM wp) -{ - metadb_handle_list data; - static_api_ptr_t api; - api->activeplaylist_get_selected_items(data); - return on_keydown_auto_context(data,wp,contextmenu_item::caller_playlist); -} - -bool keyboard_shortcut_manager::on_keydown_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller) -{ - if (on_keydown_context(data,wp,caller)) return true; - else return on_keydown_auto(wp); -} - -static bool should_relay_key_restricted(UINT p_key) { - switch(p_key) { - case VK_LEFT: - case VK_RIGHT: - case VK_UP: - case VK_DOWN: - return false; - default: - return (p_key >= VK_F1 && p_key <= VK_F24) || IsKeyPressed(VK_CONTROL) || IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN); - } -} - -bool keyboard_shortcut_manager::on_keydown_restricted_auto(WPARAM wp) { - if (!should_relay_key_restricted(wp)) return false; - return on_keydown_auto(wp); -} -bool keyboard_shortcut_manager::on_keydown_restricted_auto_playlist(WPARAM wp) { - if (!should_relay_key_restricted(wp)) return false; - return on_keydown_auto_playlist(wp); -} -bool keyboard_shortcut_manager::on_keydown_restricted_auto_context(const pfc::list_base_const_t & data,WPARAM wp,const GUID & caller) { - if (!should_relay_key_restricted(wp)) return false; - return on_keydown_auto_context(data,wp,caller); -} - -bool keyboard_shortcut_manager_v2::pretranslate_message(const MSG * msg, HWND thisPopupWnd) { - switch(msg->message) { - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if (thisPopupWnd != NULL && FindOwningPopup(msg->hwnd) == thisPopupWnd) { - const t_uint32 modifiers = GetHotkeyModifierFlags(); - /*if (filterTypableWindowMessage(msg, modifiers))*/ { - if (process_keydown_simple(get_key_code(msg->wParam,modifiers))) return true; - } - } - return false; - default: - return false; - } -} - -bool keyboard_shortcut_manager::is_text_key(t_uint32 vkCode) { - return vkCode == VK_SPACE - || (vkCode >= '0' && vkCode < 0x40) - || (vkCode > 0x40 && vkCode < VK_LWIN) - || (vkCode >= VK_NUMPAD0 && vkCode <= VK_DIVIDE) - || (vkCode >= VK_OEM_1 && vkCode <= VK_OEM_3) - || (vkCode >= VK_OEM_4 && vkCode <= VK_OEM_8) - ; -} - -bool keyboard_shortcut_manager::is_typing_key(t_uint32 vkCode) { - return is_text_key(vkCode) - || vkCode == VK_BACK - || vkCode == VK_RETURN - || vkCode == VK_INSERT - || (vkCode > VK_SPACE && vkCode < '0'); -} - -bool keyboard_shortcut_manager::is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers) { - if (!is_typing_modifier(modifiers)) return false; - return is_typing_key(vkCode); -} - -bool keyboard_shortcut_manager::is_typing_modifier(t_uint32 flags) { - flags &= ~MOD_SHIFT; - return flags == 0 || flags == (MOD_ALT | MOD_CONTROL); -} - -bool keyboard_shortcut_manager::is_typing_message(HWND editbox, const MSG * msg) { - if (msg->hwnd != editbox) return false; - return is_typing_message(msg); -} -bool keyboard_shortcut_manager::is_typing_message(const MSG * msg) { - if (msg->message != WM_KEYDOWN && msg->message != WM_SYSKEYDOWN) return false; - return is_typing_key_combo(msg->wParam, GetHotkeyModifierFlags()); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/message_loop.h b/tools/vio2sf/src/foobar/foobar2000/SDK/message_loop.h deleted file mode 100644 index 19cacaf60..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/message_loop.h +++ /dev/null @@ -1,80 +0,0 @@ -class NOVTABLE message_filter -{ -public: - virtual bool pretranslate_message(MSG * p_msg) = 0; -}; - -class NOVTABLE idle_handler { -public: - virtual bool on_idle() = 0; -}; - -class NOVTABLE message_loop : public service_base -{ -public: - virtual void add_message_filter(message_filter * ptr) = 0; - virtual void remove_message_filter(message_filter * ptr) = 0; - - virtual void add_idle_handler(idle_handler * ptr) = 0; - virtual void remove_idle_handler(idle_handler * ptr) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(message_loop); -}; - -class NOVTABLE message_loop_v2 : public message_loop { -public: - virtual void add_message_filter_ex(message_filter * ptr, t_uint32 lowest, t_uint32 highest) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(message_loop_v2, message_loop); -}; - -class message_filter_impl_base : public message_filter { -public: - message_filter_impl_base() {static_api_ptr_t()->add_message_filter(this);} - message_filter_impl_base(t_uint32 lowest, t_uint32 highest) { - static_api_ptr_t api; - message_loop_v2::ptr apiV2; - if (api->service_query_t(apiV2)) { - apiV2->add_message_filter_ex(this, lowest, highest); - } else { - api->add_message_filter(this); - } - } - ~message_filter_impl_base() {static_api_ptr_t()->remove_message_filter(this);} - bool pretranslate_message(MSG * p_msg) {return false;} - - PFC_CLASS_NOT_COPYABLE(message_filter_impl_base,message_filter_impl_base); -}; - -class message_filter_impl_accel : public message_filter_impl_base { -protected: - bool pretranslate_message(MSG * p_msg) { - if (m_wnd != NULL) { - if (GetActiveWindow() == m_wnd) { - if (TranslateAccelerator(m_wnd,m_accel.get(),p_msg) != 0) { - return true; - } - } - } - return false; - } -public: - message_filter_impl_accel(HINSTANCE p_instance,const TCHAR * p_accel) : m_wnd(NULL) { - m_accel.load(p_instance,p_accel); - } - void set_wnd(HWND p_wnd) {m_wnd = p_wnd;} -private: - HWND m_wnd; - win32_accelerator m_accel; - - PFC_CLASS_NOT_COPYABLE(message_filter_impl_accel,message_filter_impl_accel); -}; - -class idle_handler_impl_base : public idle_handler { -public: - idle_handler_impl_base() {static_api_ptr_t()->add_idle_handler(this);} - ~idle_handler_impl_base() {static_api_ptr_t()->remove_idle_handler(this);} - bool on_idle() {return true;} - - PFC_CLASS_NOT_COPYABLE_EX(idle_handler_impl_base) -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/metadb.cpp deleted file mode 100644 index 3fc8689b2..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "foobar2000.h" - - -void metadb::handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) { - handle_create(p_out,make_playable_location(p_new_path,p_source->get_subsong_index())); -} - -void metadb::handle_create_replace_path(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) { - pfc::string8 path; - filesystem::g_get_canonical_path(p_new_path,path); - handle_create_replace_path_canonical(p_out,p_source,path); -} - -void metadb::handle_replace_path_canonical(metadb_handle_ptr & p_out,const char * p_new_path) { - metadb_handle_ptr temp; - handle_create_replace_path_canonical(temp,p_out,p_new_path); - p_out = temp; -} - - -metadb_io::t_load_info_state metadb_io::load_info(metadb_handle_ptr p_item,t_load_info_type p_type,HWND p_parent_window,bool p_show_errors) { - return load_info_multi(pfc::list_single_ref_t(p_item),p_type,p_parent_window,p_show_errors); -} - -metadb_io::t_update_info_state metadb_io::update_info(metadb_handle_ptr p_item,file_info & p_info,HWND p_parent_window,bool p_show_errors) -{ - file_info * blah = &p_info; - return update_info_multi(pfc::list_single_ref_t(p_item),pfc::list_single_ref_t(blah),p_parent_window,p_show_errors); -} - - -void metadb_io::hint_async(metadb_handle_ptr p_item,const file_info & p_info,const t_filestats & p_stats,bool p_fresh) -{ - const file_info * blargh = &p_info; - hint_multi_async(pfc::list_single_ref_t(p_item),pfc::list_single_ref_t(blargh),pfc::list_single_ref_t(p_stats),bit_array_val(p_fresh)); -} - - -bool metadb::g_get_random_handle(metadb_handle_ptr & p_out) { - if (static_api_ptr_t()->get_now_playing(p_out)) return true; - - { - static_api_ptr_t api; - - t_size playlist_count = api->get_playlist_count(); - t_size active_playlist = api->get_active_playlist(); - if (active_playlist != infinite) { - if (api->playlist_get_focus_item_handle(p_out,active_playlist)) return true; - } - - for(t_size n = 0; n < playlist_count; n++) { - if (api->playlist_get_focus_item_handle(p_out,n)) return true; - } - - if (active_playlist != infinite) { - t_size item_count = api->playlist_get_item_count(active_playlist); - if (item_count > 0) { - if (api->playlist_get_item_handle(p_out,active_playlist,0)) return true; - } - } - - for(t_size n = 0; n < playlist_count; n++) { - t_size item_count = api->playlist_get_item_count(n); - if (item_count > 0) { - if (api->playlist_get_item_handle(p_out,n,0)) return true; - } - } - } - - return false; -} - - -void metadb_io_v2::update_info_async_simple(const pfc::list_base_const_t & p_list,const pfc::list_base_const_t & p_new_info, HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) { - update_info_async(p_list,new service_impl_t(p_list,p_new_info),p_parent_window,p_op_flags,p_notify); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb.h b/tools/vio2sf/src/foobar/foobar2000/SDK/metadb.h deleted file mode 100644 index 7b1495f8a..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb.h +++ /dev/null @@ -1,312 +0,0 @@ -//! API for tag read/write operations. Legal to call from main thread only, except for hint_multi_async() / hint_async() / hint_reader().\n -//! Implemented only by core, do not reimplement.\n -//! Use static_api_ptr_t template to access metadb_io methods.\n -//! WARNING: Methods that perform file access (tag reads/writes) run a modal message loop. They SHOULD NOT be called from global callbacks and such. -class NOVTABLE metadb_io : public service_base -{ -public: - enum t_load_info_type { - load_info_default, - load_info_force, - load_info_check_if_changed - }; - - enum t_update_info_state { - update_info_success, - update_info_aborted, - update_info_errors, - }; - - enum t_load_info_state { - load_info_success, - load_info_aborted, - load_info_errors, - }; - - //! No longer use - returns false always. - __declspec(deprecated) virtual bool is_busy() = 0; - //! No longer used - returns false always. - __declspec(deprecated) virtual bool is_updating_disabled() = 0; - //! No longer used - returns false always. - __declspec(deprecated) virtual bool is_file_updating_blocked() = 0; - //! No longer used. - __declspec(deprecated) virtual void highlight_running_process() = 0; - //! Loads tags from multiple items. Use the async version in metadb_io_v2 instead if possible. - __declspec(deprecated) virtual t_load_info_state load_info_multi(metadb_handle_list_cref p_list,t_load_info_type p_type,HWND p_parent_window,bool p_show_errors) = 0; - //! Updates tags on multiple items. Use the async version in metadb_io_v2 instead if possible. - __declspec(deprecated) virtual t_update_info_state update_info_multi(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_new_info,HWND p_parent_window,bool p_show_errors) = 0; - //! Rewrites tags on multiple items. Use the async version in metadb_io_v2 instead if possible. - __declspec(deprecated) virtual t_update_info_state rewrite_info_multi(metadb_handle_list_cref p_list,HWND p_parent_window,bool p_show_errors) = 0; - //! Removes tags from multiple items. Use the async version in metadb_io_v2 instead if possible. - __declspec(deprecated) virtual t_update_info_state remove_info_multi(metadb_handle_list_cref p_list,HWND p_parent_window,bool p_show_errors) = 0; - - virtual void hint_multi(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_infos,const pfc::list_base_const_t & p_stats,const bit_array & p_fresh_mask) = 0; - - virtual void hint_multi_async(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_infos,const pfc::list_base_const_t & p_stats,const bit_array & p_fresh_mask) = 0; - - virtual void hint_reader(service_ptr_t p_reader,const char * p_path,abort_callback & p_abort) = 0; - - //! For internal use only. - virtual void path_to_handles_simple(const char * p_path, metadb_handle_list_ref p_out) = 0; - - //! Dispatches metadb_io_callback calls with specified items. To be used with metadb_display_field_provider when your component needs specified items refreshed. - virtual void dispatch_refresh(metadb_handle_list_cref p_list) = 0; - - void dispatch_refresh(metadb_handle_ptr const & handle) {dispatch_refresh(pfc::list_single_ref_t(handle));} - - void hint_async(metadb_handle_ptr p_item,const file_info & p_info,const t_filestats & p_stats,bool p_fresh); - - __declspec(deprecated) t_load_info_state load_info(metadb_handle_ptr p_item,t_load_info_type p_type,HWND p_parent_window,bool p_show_errors); - __declspec(deprecated) t_update_info_state update_info(metadb_handle_ptr p_item,file_info & p_info,HWND p_parent_window,bool p_show_errors); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io); -}; - -//! Implementing this class gives you direct control over which part of file_info gets altered during a tag update uperation. To be used with metadb_io_v2::update_info_async(). -class NOVTABLE file_info_filter : public service_base { -public: - //! Alters specified file_info entry; called as a part of tag update process. Specified file_info has been read from a file, and will be written back.\n - //! WARNING: This will be typically called from another thread than main app thread (precisely, from thread created by tag updater). You should copy all relevant data to members of your file_info_filter instance in constructor and reference only member data in apply_filter() implementation. - //! @returns True when you have altered file_info and changes need to be written back to the file; false if no changes have been made. - virtual bool apply_filter(metadb_handle_ptr p_location,t_filestats p_stats,file_info & p_info) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(file_info_filter,service_base); -}; - -//! Advanced interface for passing infos read from files to metadb backend. Use metadb_io_v2::create_hint_list() to instantiate. -class NOVTABLE metadb_hint_list : public service_base { -public: - //! Adds a hint to the list. - //! @param p_location Location of the item the hint applies to. - //! @param p_info file_info object describing the item. - //! @param p_stats Information about the file containing item the hint applies to. - //! @param p_freshflag Set to true if the info has been directly read from the file, false if it comes from another source such as a playlist file. - virtual void add_hint(metadb_handle_ptr const & p_location,const file_info & p_info,const t_filestats & p_stats,bool p_freshflag) = 0; - //! Reads info from specified info reader instance and adds hints. May throw an exception in case info read has failed. - virtual void add_hint_reader(const char * p_path,service_ptr_t const & p_reader,abort_callback & p_abort) = 0; - //! Call this when you're done working with this metadb_hint_list instance, to apply hints and dispatch callbacks. If you don't call this, all added hints will be ignored. - virtual void on_done() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(metadb_hint_list,service_base); -}; - -//! New in 0.9.3. Extends metadb_io functionality with nonblocking versions of tag read/write functions, and some other utility features. -class NOVTABLE metadb_io_v2 : public metadb_io { -public: - enum { - //! By default, when some part of requested operation could not be performed for reasons other than user abort, a popup dialog with description of the problem is spawned.\n - //! Set this flag to disable error notification. - op_flag_no_errors = 1 << 0, - //! Set this flag to make the progress dialog not steal focus on creation. - op_flag_background = 1 << 1, - //! Set this flag to delay the progress dialog becoming visible, so it does not appear at all during short operations. Also implies op_flag_background effect. - op_flag_delay_ui = 1 << 2, - }; - - //! Preloads information from the specified tracks. - //! @param p_list List of items to process. - //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. - //! @param p_notify Called when the task is completed. Status code is one of t_load_info_state values. Can be null if caller doesn't care. - virtual void load_info_async(metadb_handle_list_cref p_list,t_load_info_type p_type,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; - //! Updates tags of the specified tracks. - //! @param p_list List of items to process. - //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. - //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. - //! @param p_filter Callback handling actual file_info alterations. Typically used to replace entire meta part of file_info, or to alter something else such as ReplayGain while leaving meta intact. - virtual void update_info_async(metadb_handle_list_cref p_list,service_ptr_t p_filter,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; - //! Rewrites tags of the specified tracks; similar to update_info_async() but using last known/cached file_info values rather than values passed by caller. - //! @param p_list List of items to process. - //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. - //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. - virtual void rewrite_info_async(metadb_handle_list_cref p_list,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; - //! Strips all tags / metadata fields from the specified tracks. - //! @param p_list List of items to process. - //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. - //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. - virtual void remove_info_async(metadb_handle_list_cref p_list,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0; - - //! Creates a metadb_hint_list object. - virtual metadb_hint_list::ptr create_hint_list() = 0; - - //! Updates tags of the specified tracks. Helper; uses update_info_async internally. - //! @param p_list List of items to process. - //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. - //! @param p_notify Called when the task is completed. Status code is one of t_update_info values. Can be null if caller doesn't care. - //! @param p_new_info New infos to write to specified items. - void update_info_async_simple(metadb_handle_list_cref p_list,const pfc::list_base_const_t & p_new_info, HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify); - - FB2K_MAKE_SERVICE_INTERFACE(metadb_io_v2,metadb_io); -}; - - -//! Dynamically-registered version of metadb_io_callback. See metadb_io_callback for documentation, register instances using metadb_io_v3::register_callback(). It's recommended that you use the metadb_io_callback_dynamic_impl_base helper class to manage registration/unregistration. -class NOVTABLE metadb_io_callback_dynamic { -public: - virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0; -}; - -//! New (0.9.5) -class NOVTABLE metadb_io_v3 : public metadb_io_v2 { -public: - virtual void register_callback(metadb_io_callback_dynamic * p_callback) = 0; - virtual void unregister_callback(metadb_io_callback_dynamic * p_callback) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(metadb_io_v3,metadb_io_v2); -}; - -//! metadb_io_callback_dynamic implementation helper. -class metadb_io_callback_dynamic_impl_base : public metadb_io_callback_dynamic { -public: - void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) {} - - metadb_io_callback_dynamic_impl_base() {static_api_ptr_t()->register_callback(this);} - ~metadb_io_callback_dynamic_impl_base() {static_api_ptr_t()->unregister_callback(this);} - - PFC_CLASS_NOT_COPYABLE_EX(metadb_io_callback_dynamic_impl_base) -}; -//! Callback service receiving notifications about metadb contents changes. -class NOVTABLE metadb_io_callback : public service_base { -public: - //! Called when metadb contents change. (Or, one of display hook component requests display update). - //! @param p_items_sorted List of items that have been updated. The list is always sorted by pointer value, to allow fast bsearch to test whether specific item has changed. - //! @param p_fromhook Set to true when actual file contents haven't changed but one of metadb_display_field_provider implementations requested an update so output of metadb_handle::format_title() etc has changed. - virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io_callback); -}; - -//! Entrypoint service for metadb_handle related operations.\n -//! Implemented only by core, do not reimplement.\n -//! Use static_api_ptr_t template to access it, e.g. static_api_ptr_t()->handle_create(myhandle,mylocation); -class NOVTABLE metadb : public service_base -{ -public: - //! Locks metadb to prevent other threads from modifying it while you're working with some of its contents. Some functions (metadb_handle::get_info_locked(), metadb_handle::get_info_async_locked()) can be called only from inside metadb lock section. - virtual void database_lock()=0; - //! Unlocks metadb after database_lock(). Some functions (metadb_handle::get_info_locked(), metadb_handle::get_info_async_locked()) can be called only from inside metadb lock section. - virtual void database_unlock()=0; - - //! Returns a metadb_handle object referencing the specified location. If one doesn't exist yet a new one is created. There can be only one metadb_handle object referencing specific location. \n - //! This function should never fail unless there's something critically wrong (can't allocate memory for the new object, etc). \n - //! Speed: O(log(n)) to total number of metadb_handles present. It's recommended to pass metadb_handles around whenever possible rather than pass playable_locations then retrieve metadb_handles on demand when needed. - //! @param p_out Receives the metadb_handle pointer. - //! @param p_location Location to create a metadb_handle for. - virtual void handle_create(metadb_handle_ptr & p_out,const playable_location & p_location)=0; - - void handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path); - void handle_replace_path_canonical(metadb_handle_ptr & p_out,const char * p_new_path); - void handle_create_replace_path(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path); - - //! Helper function; attempts to retrieve a handle to any known playable location to be used for e.g. titleformatting script preview.\n - //! @returns True on success; false on failure (no known playable locations). - static bool g_get_random_handle(metadb_handle_ptr & p_out); - - enum {case_sensitive = true}; - typedef pfc::comparator_strcmp path_comparator; - - inline static int path_compare_ex(const char * p1,t_size len1,const char * p2,t_size len2) {return case_sensitive ? pfc::strcmp_ex(p1,len1,p2,len2) : stricmp_utf8_ex(p1,len1,p2,len2);} - inline static int path_compare(const char * p1,const char * p2) {return case_sensitive ? strcmp(p1,p2) : stricmp_utf8(p1,p2);} - inline static int path_compare_metadb_handle(const metadb_handle_ptr & p1,const metadb_handle_ptr & p2) {return path_compare(p1->get_path(),p2->get_path());} - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb); -}; - -//! Metadb lock sync helper. For use around metadb_handle "locked" methods. -class in_metadb_sync { -public: - in_metadb_sync() { - m_api->database_lock(); - } - ~in_metadb_sync() { - m_api->database_unlock(); - } -private: - static_api_ptr_t m_api; -}; - -//! Metadb lock sync helper. For use around metadb_handle "locked" methods. -class in_metadb_sync_fromptr { -public: - in_metadb_sync_fromptr(const service_ptr_t & p_api) : m_api(p_api) {m_api->database_lock();} - ~in_metadb_sync_fromptr() {m_api->database_unlock();} -private: - service_ptr_t m_api; -}; - -//! Metadb lock sync helper. For use around metadb_handle "locked" methods. -class in_metadb_sync_fromhandle { -public: - in_metadb_sync_fromhandle(const service_ptr_t & p_api) : m_api(p_api) {m_api->metadb_lock();} - ~in_metadb_sync_fromhandle() {m_api->metadb_unlock();} -private: - service_ptr_t m_api; -}; - -class titleformat_text_out; -class titleformat_hook_function_params; - - -/*! - Implementing this service lets you provide your own title-formatting fields that are parsed globally with each call to metadb_handle::format_title methods. \n - This should be implemented only where absolutely necessary, for safety and performance reasons. Any expensive operations inside the process_field() method may severely damage performance of affected title-formatting calls. \n - You must NEVER make any other foobar2000 API calls from inside process_field, other than possibly querying information from the passed metadb_handle pointer; you should read your own implementation-specific private data and return as soon as possible. You must not make any assumptions about calling context (threading etc). \n - It is guaranteed that process_field() is called only inside a metadb lock scope so you can safely call "locked" metadb_handle methods on the metadb_handle pointer you get. You must not lock metadb by yourself inside process_field() - while it is always called from inside a metadb lock scope, it may be called from another thread than the one maintaining the lock because of multi-CPU optimizations active. \n - If there are multiple metadb_display_field_provider services registered providing fields of the same name, which one gets called is undefined. \n - IMPORTANT: Any components implementing metadb_display_field_provider MUST call metadb_io::dispatch_refresh() with affected metadb_handles whenever info that they present changes. Otherwise, anything rendering title-formatting strings that reference your data will not update properly, resulting in unreliable/broken output, repaint glitches, etc. \n - Do not expect a process_field() call each time somebody uses title formatting, calling code might perform its own caching of strings that you return, getting new ones only after metadb_io::dispatch_refresh() with relevant items. \n - If you can't reliably notify other components about changes of content of fields that you provide (such as when your fields provide some kind of global information and not information specific to item identified by passed metadb_handle), you should not be providing those fields in first place. You must not change returned values of your fields without dispatching appropriate notifications. \n - Use static service_factory_single_t to register your metadb_display_field_provider implementations. Do not call other people's metadb_display_field_provider services directly, they're meant to be called by backend only. \n - List of fields that you provide is expected to be fixed at run-time. The backend will enumerate your fields only once and refer to them by indexes later. \n -*/ - -class NOVTABLE metadb_display_field_provider : public service_base { -public: - //! Returns number of fields provided by this metadb_display_field_provider implementation. - virtual t_uint32 get_field_count() = 0; - //! Returns name of specified field provided by this metadb_display_field_provider implementation. Names are not case sensitive. It's strongly recommended that you keep your field names plain English / ASCII only. - virtual void get_field_name(t_uint32 index, pfc::string_base & out) = 0; - //! Evaluates the specified field. - //! @param index Index of field being processed : 0 <= index < get_field_count(). - //! @param handle Handle to item being processed. You can safely call "locked" methods on this handle to retrieve track information and such. - //! @param out Interface receiving your text output. - //! @returns Return true to indicate that the field is present so if it's enclosed in square brackets, contents of those brackets should not be skipped, false otherwise. - virtual bool process_field(t_uint32 index, metadb_handle * handle, titleformat_text_out * out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_display_field_provider); -}; - - - - - -//! Helper implementation of file_info_filter_impl. -class file_info_filter_impl : public file_info_filter { -public: - file_info_filter_impl(const pfc::list_base_const_t & p_list,const pfc::list_base_const_t & p_new_info) { - pfc::dynamic_assert(p_list.get_count() == p_new_info.get_count()); - pfc::array_t order; - order.set_size(p_list.get_count()); - order_helper::g_fill(order.get_ptr(),order.get_size()); - p_list.sort_get_permutation_t(pfc::compare_t,order.get_ptr()); - m_handles.set_count(order.get_size()); - m_infos.set_size(order.get_size()); - for(t_size n = 0; n < order.get_size(); n++) { - m_handles[n] = p_list[order[n]]; - m_infos[n] = *p_new_info[order[n]]; - } - } - - bool apply_filter(metadb_handle_ptr p_location,t_filestats p_stats,file_info & p_info) { - t_size index; - if (m_handles.bsearch_t(pfc::compare_t,p_location,index)) { - p_info = m_infos[index]; - return true; - } else { - return false; - } - } -private: - metadb_handle_list m_handles; - pfc::array_t m_infos; -}; - diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle.cpp deleted file mode 100644 index 71fd8ae05..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "foobar2000.h" - - -double metadb_handle::get_length() -{ - double rv = 0; - in_metadb_sync_fromhandle l_sync(this); - const file_info * info; - if (get_info_locked(info)) - rv = info->get_length(); - return rv; -} - -t_filetimestamp metadb_handle::get_filetimestamp() -{ - return get_filestats().m_timestamp; -} - -t_filesize metadb_handle::get_filesize() -{ - return get_filestats().m_size; -} - -bool metadb_handle::format_title_legacy(titleformat_hook * p_hook,pfc::string_base & p_out,const char * p_spec,titleformat_text_filter * p_filter) -{ - service_ptr_t script; - if (static_api_ptr_t()->compile(script,p_spec)) { - return format_title(p_hook,p_out,script,p_filter); - } else { - p_out.reset(); - return false; - } -} - - - -bool metadb_handle::g_should_reload(const t_filestats & p_old_stats,const t_filestats & p_new_stats,bool p_fresh) -{ - if (p_new_stats.m_timestamp == filetimestamp_invalid) return p_fresh; - else if (p_fresh) return p_old_stats!= p_new_stats; - else return p_old_stats.m_timestamp < p_new_stats.m_timestamp; -} - -bool metadb_handle::should_reload(const t_filestats & p_new_stats, bool p_fresh) const -{ - if (!is_info_loaded_async()) return true; - else return g_should_reload(get_filestats(),p_new_stats,p_fresh); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle.h b/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle.h deleted file mode 100644 index 35d6363d9..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle.h +++ /dev/null @@ -1,207 +0,0 @@ -class titleformat_hook; -class titleformat_text_filter; - -//! A metadb_handle object represents interface to reference-counted file_info cache entry for the specified location.\n -//! To obtain a metadb_handle to specific location, use metadb::handle_create(). To obtain a list of metadb_handle objects corresponding to specific path (directory, playlist, multitrack file, etc), use relevant playlist_incoming_item_filter methods (recommended), or call playlist_loader methods directly.\n -//! A metadb_handle is also the most efficient way of passing playable object locations around because it provides fast access to both location and infos, and is reference counted so duplicating it is as fast as possible.\n -//! To retrieve a path of a file from a metadb_handle, use metadb_handle::get_path() function. Note that metadb_handle is NOT just file path, some formats support multiple subsongs per physical file, which are signaled using subsong indexes. - -class NOVTABLE metadb_handle : public service_base -{ -public: - //! Retrieves location represented by this metadb_handle object. Returned reference is valid until calling context releases metadb_handle that returned it (metadb_handle_ptr is deallocated etc). - virtual const playable_location & get_location() const = 0;//never fails, returned pointer valid till the object is released - - - //! Renders information about item referenced by this metadb_handle object. - //! @param p_hook Optional callback object overriding fields and functions; set to NULL if not used. - //! @param p_out String receiving the output on success. - //! @param p_script Titleformat script to use. Use titleformat_compiler service to create one. - //! @param p_filter Optional callback object allowing input to be filtered according to context (i.e. removal of linebreak characters present in tags when rendering playlist lines). Set to NULL when not used. - //! @returns true on success, false when dummy file_info instance was used because actual info is was not (yet) known. - virtual bool format_title(titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; - - //! Locks metadb to prevent other threads from modifying it while you're working with some of its contents. Some functions (metadb_handle::get_info_locked(), metadb_handle::get_info_async_locked()) can be called only from inside metadb lock section. - //! Same as metadb::database_lock(). - virtual void metadb_lock() = 0; - //! Unlocks metadb after metadb_lock(). Some functions (metadb_handle::get_info_locked(), metadb_handle::get_info_async_locked()) can be called only from inside metadb lock section. - //! Same as metadb::database_unlock(). - virtual void metadb_unlock() = 0; - - //! Returns last seen file stats, filestats_invalid if unknown. - virtual t_filestats get_filestats() const = 0; - - //! Queries whether cached info about item referenced by this metadb_handle object is already available.\n - //! Note that state of cached info changes only inside main thread, so you can safely assume that it doesn't change while some block of your code inside main thread is being executed. - virtual bool is_info_loaded() const = 0; - //! Queries cached info about item referenced by this metadb_handle object. Returns true on success, false when info is not yet known.\n - //! Note that state of cached info changes only inside main thread, so you can safely assume that it doesn't change while some block of your code inside main thread is being executed. - virtual bool get_info(file_info & p_info) const = 0; - //! Queries cached info about item referenced by this metadb_handle object. Returns true on success, false when info is not yet known. This is more efficient than get_info() since no data is copied.\n - //! You must lock the metadb before calling this function, and unlock it after you are done working with the returned pointer, to ensure multithread safety.\n - //! Note that state of cached info changes only inside main thread, so you can safely assume that it doesn't change while some block of your code inside main thread is being executed. - //! @param p_info On success, receives a pointer to metadb's file_info object. The pointer is for temporary use only, and becomes invalid when metadb is unlocked. - virtual bool get_info_locked(const file_info * & p_info) const = 0; - - //! Queries whether cached info about item referenced by this metadb_handle object is already available.\n - //! This is intended for use in special cases when you need to immediately retrieve info sent by metadb_io hint from another thread; state of returned data can be altered by any thread, as opposed to non-async methods. - virtual bool is_info_loaded_async() const = 0; - //! Queries cached info about item referenced by this metadb_handle object. Returns true on success, false when info is not yet known.\n - //! This is intended for use in special cases when you need to immediately retrieve info sent by metadb_io hint from another thread; state of returned data can be altered by any thread, as opposed to non-async methods. - virtual bool get_info_async(file_info & p_info) const = 0; - //! Queries cached info about item referenced by this metadb_handle object. Returns true on success, false when info is not yet known. This is more efficient than get_info() since no data is copied.\n - //! You must lock the metadb before calling this function, and unlock it after you are done working with the returned pointer, to ensure multithread safety.\n - //! This is intended for use in special cases when you need to immediately retrieve info sent by metadb_io hint from another thread; state of returned data can be altered by any thread, as opposed to non-async methods. - //! @param p_info On success, receives a pointer to metadb's file_info object. The pointer is for temporary use only, and becomes invalid when metadb is unlocked. - virtual bool get_info_async_locked(const file_info * & p_info) const = 0; - - - //! Renders information about item referenced by this metadb_handle object, using external file_info data. - virtual void format_title_from_external_info(const file_info & p_info,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; - - - //! New in 0.9.5. - virtual bool format_title_nonlocking(titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; - - //! New in 0.9.5. - virtual void format_title_from_external_info_nonlocking(const file_info & p_info,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter) = 0; - - static bool g_should_reload(const t_filestats & p_old_stats,const t_filestats & p_new_stats,bool p_fresh); - bool should_reload(const t_filestats & p_new_stats,bool p_fresh) const; - - - //! Helper provided for backwards compatibility; takes formatting script as text string and calls relevant titleformat_compiler methods; returns false when the script could not be compiled.\n - //! See format_title() for descriptions of parameters.\n - //! Bottleneck warning: you should consider using precompiled titleformat script object and calling regular format_title() instead when processing large numbers of items. - bool format_title_legacy(titleformat_hook * p_hook,pfc::string_base & out,const char * p_spec,titleformat_text_filter * p_filter); - - //! Retrieves path of item described by this metadb_handle instance. Returned string is valid until calling context releases metadb_handle that returned it (metadb_handle_ptr is deallocated etc). - inline const char * get_path() const {return get_location().get_path();} - //! Retrieves subsong index of item described by this metadb_handle instance (used for multiple playable tracks within single physical file). - inline t_uint32 get_subsong_index() const {return get_location().get_subsong_index();} - - double get_length();//helper - - t_filetimestamp get_filetimestamp(); - t_filesize get_filesize(); - - FB2K_MAKE_SERVICE_INTERFACE(metadb_handle,service_base); -}; - -typedef service_ptr_t metadb_handle_ptr; - -typedef pfc::list_base_t & metadb_handle_list_ref; -typedef pfc::list_base_const_t const & metadb_handle_list_cref; - -namespace metadb_handle_list_helper { - void sort_by_format(metadb_handle_list_ref p_list,const char * spec,titleformat_hook * p_hook); - void sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const char * spec,titleformat_hook * p_hook); - void sort_by_format(metadb_handle_list_ref p_list,const service_ptr_t & p_script,titleformat_hook * p_hook, int direction = 1); - void sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const service_ptr_t & p_script,titleformat_hook * p_hook,int p_direction = 1); - - void sort_by_relative_path(metadb_handle_list_ref p_list); - void sort_by_relative_path_get_order(metadb_handle_list_cref p_list,t_size* order); - - void remove_duplicates(pfc::list_base_t & p_list); - void sort_by_pointer_remove_duplicates(pfc::list_base_t & p_list); - void sort_by_path_quick(pfc::list_base_t & p_list); - - void sort_by_pointer(pfc::list_base_t & p_list); - t_size bsearch_by_pointer(const pfc::list_base_const_t & p_list,const metadb_handle_ptr & val); - - double calc_total_duration(const pfc::list_base_const_t & p_list); - - void sort_by_path(pfc::list_base_t & p_list); - - t_filesize calc_total_size(metadb_handle_list_cref list, bool skipUnknown = false); - t_filesize calc_total_size_ex(metadb_handle_list_cref list, bool & foundUnknown); -}; - -template class t_alloc = pfc::alloc_fast > -class metadb_handle_list_t : public service_list_t { -private: - typedef metadb_handle_list_t t_self; - typedef list_base_const_t t_interface; -public: - inline void sort_by_format(const char * spec,titleformat_hook * p_hook) { - return metadb_handle_list_helper::sort_by_format(*this, spec, p_hook); - } - inline void sort_by_format_get_order(t_size* order,const char * spec,titleformat_hook * p_hook) const { - metadb_handle_list_helper::sort_by_format_get_order(*this, order, spec, p_hook); - } - - inline void sort_by_format(const service_ptr_t & p_script,titleformat_hook * p_hook, int direction = 1) { - metadb_handle_list_helper::sort_by_format(*this, p_script, p_hook, direction); - } - inline void sort_by_format_get_order(t_size* order,const service_ptr_t & p_script,titleformat_hook * p_hook) const { - metadb_handle_list_helper::sort_by_format_get_order(*this, order, p_script, p_hook); - } - - inline void sort_by_relative_path() { - metadb_handle_list_helper::sort_by_relative_path(*this); - } - inline void sort_by_relative_path_get_order(t_size* order) const { - metadb_handle_list_helper::sort_by_relative_path_get_order(*this,order); - } - - inline void remove_duplicates() {metadb_handle_list_helper::remove_duplicates(*this);} - inline void sort_by_pointer_remove_duplicates() {metadb_handle_list_helper::sort_by_pointer_remove_duplicates(*this);} - inline void sort_by_path_quick() {metadb_handle_list_helper::sort_by_path_quick(*this);} - - inline void sort_by_pointer() {metadb_handle_list_helper::sort_by_pointer(*this);} - inline t_size bsearch_by_pointer(const metadb_handle_ptr & val) const {return metadb_handle_list_helper::bsearch_by_pointer(*this,val);} - - inline double calc_total_duration() const {return metadb_handle_list_helper::calc_total_duration(*this);} - - inline void sort_by_path() {metadb_handle_list_helper::sort_by_path(*this);} - - const t_self & operator=(const t_self & p_source) {remove_all(); add_items(p_source);return *this;} - const t_self & operator=(const t_interface & p_source) {remove_all(); add_items(p_source);return *this;} - metadb_handle_list_t(const t_self & p_source) {add_items(p_source);} - metadb_handle_list_t(const t_interface & p_source) {add_items(p_source);} - metadb_handle_list_t() {} - - t_self & operator+=(const t_interface & source) {add_items(source); return *this;} - t_self & operator+=(const metadb_handle_ptr & source) {add_item(source); return *this;} -}; - -typedef metadb_handle_list_t<> metadb_handle_list; - -namespace metadb_handle_list_helper { - void sorted_by_pointer_extract_difference(metadb_handle_list const & p_list_1,metadb_handle_list const & p_list_2,metadb_handle_list & p_list_1_specific,metadb_handle_list & p_list_2_specific); -}; - -class metadb_handle_lock -{ - metadb_handle_ptr m_ptr; -public: - inline metadb_handle_lock(const metadb_handle_ptr & param) - { - m_ptr = param; - m_ptr->metadb_lock(); - } - inline ~metadb_handle_lock() {m_ptr->metadb_unlock();} -}; - -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,const metadb_handle_ptr & p_location) { - if (p_location.is_valid()) - return p_fmt << p_location->get_location(); - else - return p_fmt << "[invalid location]"; -} - - -class string_format_title { -public: - string_format_title(metadb_handle_ptr p_item,const char * p_script) { - p_item->format_title_legacy(NULL,m_data,p_script,NULL); - } - string_format_title(metadb_handle_ptr p_item,service_ptr_t p_script) { - p_item->format_title(NULL,m_data,p_script,NULL); - } - - const char * get_ptr() const {return m_data.get_ptr();} - operator const char * () const {return m_data.get_ptr();} -private: - pfc::string8_fastalloc m_data; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle_list.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle_list.cpp deleted file mode 100644 index dbf3be6ce..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/metadb_handle_list.cpp +++ /dev/null @@ -1,386 +0,0 @@ -#include "foobar2000.h" -#include - -namespace { - - wchar_t * makeSortString(const char * in) { - wchar_t * out = new wchar_t[pfc::stringcvt::estimate_utf8_to_wide(in) + 1]; - out[0] = ' ';//StrCmpLogicalW bug workaround. - pfc::stringcvt::convert_utf8_to_wide_unchecked(out + 1, in); - return out; - } - - struct custom_sort_data { - wchar_t * text; - t_size index; - }; -} - -template -static int custom_sort_compare(const custom_sort_data & elem1, const custom_sort_data & elem2 ) { - int ret = direction * StrCmpLogicalW(elem1.text,elem2.text); - if (ret == 0) ret = pfc::sgn_t((t_ssize)elem1.index - (t_ssize)elem2.index); - return ret; -} - - -template -static int _cdecl _custom_sort_compare(const void * v1, const void * v2) { - return custom_sort_compare(*reinterpret_cast(v1),*reinterpret_cast(v2)); -} -void metadb_handle_list_helper::sort_by_format(metadb_handle_list_ref p_list,const char * spec,titleformat_hook * p_hook) -{ - service_ptr_t script; - if (static_api_ptr_t()->compile(script,spec)) - sort_by_format(p_list,script,p_hook); -} - -void metadb_handle_list_helper::sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const char * spec,titleformat_hook * p_hook) -{ - service_ptr_t script; - if (static_api_ptr_t()->compile(script,spec)) - sort_by_format_get_order(p_list,order,script,p_hook); -} - -void metadb_handle_list_helper::sort_by_format(metadb_handle_list_ref p_list,const service_ptr_t & p_script,titleformat_hook * p_hook, int direction) -{ - const t_size count = p_list.get_count(); - pfc::array_t order; order.set_size(count); - sort_by_format_get_order(p_list,order.get_ptr(),p_script,p_hook,direction); - p_list.reorder(order.get_ptr()); -} - -namespace { - - class tfhook_sort : public titleformat_hook { - public: - tfhook_sort() { - m_API->seed((unsigned)__rdtsc()); - } - bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) { - return false; - } - bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) { - if (stricmp_utf8_ex(p_name, p_name_length, "rand", ~0) == 0) { - t_size param_count = p_params->get_param_count(); - t_uint32 val; - if (param_count == 1) { - t_uint32 mod = (t_uint32)p_params->get_param_uint(0); - if (mod > 0) { - val = m_API->genrand(mod); - } else { - val = 0; - } - } else { - val = m_API->genrand(0xFFFFFFFF); - } - p_out->write_int(titleformat_inputtypes::unknown, val); - p_found_flag = true; - return true; - } else { - return false; - } - } - private: - static_api_ptr_t m_API; - }; - - class tfthread : public pfc::thread { - public: - tfthread(pfc::counter * walk, metadb_handle_list_cref items,custom_sort_data * out,titleformat_object::ptr script,titleformat_hook * hook) : m_walk(walk), m_items(items), m_out(out), m_script(script), m_hook(hook) {} - ~tfthread() {waitTillDone();} - - - - void threadProc() { - TRACK_CALL_TEXT("metadb_handle sort helper thread"); - - tfhook_sort myHook; - titleformat_hook_impl_splitter hookSplitter(&myHook, m_hook); - titleformat_hook * const hookPtr = m_hook ? pfc::safe_cast(&hookSplitter) : &myHook; - - pfc::string8_fastalloc temp; temp.prealloc(512); - const t_size total = m_items.get_size(); - for(;;) { - const t_size index = (*m_walk)++; - if (index >= total) break; - m_out[index].index = index; - m_items[index]->format_title_nonlocking(hookPtr,temp,m_script,0); - m_out[index].text = makeSortString(temp); - } - } - private: - pfc::counter * const m_walk; - metadb_handle_list_cref m_items; - custom_sort_data * const m_out; - titleformat_object::ptr const m_script; - titleformat_hook * const m_hook; - }; -} - -void metadb_handle_list_helper::sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const service_ptr_t & p_script,titleformat_hook * p_hook,int p_direction) -{ -// pfc::hires_timer timer; timer.start(); - - const t_size count = p_list.get_count(); - pfc::array_t data; data.set_size(count); - - { - in_metadb_sync sync; - pfc::counter counter(0); - pfc::array_t > threads; threads.set_size(pfc::getOptimalWorkerThreadCountEx(p_list.get_count() / 128)); - PFC_ASSERT( threads.get_size() > 0 ); - for(t_size walk = 0; walk < threads.get_size(); ++walk) { - threads[walk].new_t(&counter,p_list,data.get_ptr(),p_script,p_hook); - } - for(t_size walk = 1; walk < threads.get_size(); ++walk) threads[walk]->start(); - threads[0]->threadProc(); - for(t_size walk = 1; walk < threads.get_size(); ++walk) threads[walk]->waitTillDone(); - } -// console::formatter() << "metadb_handle sort: prepared in " << pfc::format_time_ex(timer.query(),6); - - pfc::sort_t(data, p_direction > 0 ? custom_sort_compare<1> : custom_sort_compare<-1>,count); - //qsort(data.get_ptr(),count,sizeof(custom_sort_data),p_direction > 0 ? _custom_sort_compare<1> : _custom_sort_compare<-1>); - - -// console::formatter() << "metadb_handle sort: sorted in " << pfc::format_time_ex(timer.query(),6); - - for(t_size n=0;n order; order.set_size(count); - sort_by_relative_path_get_order(p_list,order.get_ptr()); - p_list.reorder(order.get_ptr()); -} - -void metadb_handle_list_helper::sort_by_relative_path_get_order(metadb_handle_list_cref p_list,t_size* order) -{ - const t_size count = p_list.get_count(); - t_size n; - pfc::array_t data; - data.set_size(count); - static_api_ptr_t api; - - pfc::string8_fastalloc temp; - temp.prealloc(512); - for(n=0;nget_relative_path(item,temp)) temp = ""; - data[n].index = n; - data[n].text = makeSortString(temp); - //data[n].subsong = item->get_subsong_index(); - } - - pfc::sort_t(data,custom_sort_compare<1>,count); - //qsort(data.get_ptr(),count,sizeof(custom_sort_data),(int (__cdecl *)(const void *elem1, const void *elem2 ))custom_sort_compare); - - for(n=0;n0) - { - bit_array_bittable mask(count); - pfc::array_t order; order.set_size(count); - order_helper::g_fill(order); - - p_list.sort_get_permutation_t(pfc::compare_t,order.get_ptr()); - - t_size n; - bool found = false; - for(n=0;n0) - { - sort_by_pointer(p_list); - bool b_found = false; - t_size n; - for(n=0;n); - p_list.sort(); -} - -t_size metadb_handle_list_helper::bsearch_by_pointer(metadb_handle_list_cref p_list,const metadb_handle_ptr & val) -{ - t_size blah; - if (p_list.bsearch_t(pfc::compare_t,val,blah)) return blah; - else return ~0; -} - - -void metadb_handle_list_helper::sorted_by_pointer_extract_difference(metadb_handle_list const & p_list_1,metadb_handle_list const & p_list_2,metadb_handle_list & p_list_1_specific,metadb_handle_list & p_list_2_specific) -{ - t_size found_1, found_2; - const t_size count_1 = p_list_1.get_count(), count_2 = p_list_2.get_count(); - t_size ptr_1, ptr_2; - - found_1 = found_2 = 0; - ptr_1 = ptr_2 = 0; - while(ptr_1 < count_1 || ptr_2 < count_2) - { - while(ptr_1 < count_1 && (ptr_2 == count_2 || p_list_1[ptr_1] < p_list_2[ptr_2])) - { - found_1++; - t_size ptr_1_new = ptr_1 + 1; - while(ptr_1_new < count_1 && p_list_1[ptr_1_new] == p_list_1[ptr_1]) ptr_1_new++; - ptr_1 = ptr_1_new; - } - while(ptr_2 < count_2 && (ptr_1 == count_1 || p_list_2[ptr_2] < p_list_1[ptr_1])) - { - found_2++; - t_size ptr_2_new = ptr_2 + 1; - while(ptr_2_new < count_2 && p_list_2[ptr_2_new] == p_list_2[ptr_2]) ptr_2_new++; - ptr_2 = ptr_2_new; - } - while(ptr_1 < count_1 && ptr_2 < count_2 && p_list_1[ptr_1] == p_list_2[ptr_2]) {ptr_1++; ptr_2++;} - } - - - - p_list_1_specific.set_count(found_1); - p_list_2_specific.set_count(found_2); - if (found_1 > 0 || found_2 > 0) - { - found_1 = found_2 = 0; - ptr_1 = ptr_2 = 0; - - while(ptr_1 < count_1 || ptr_2 < count_2) - { - while(ptr_1 < count_1 && (ptr_2 == count_2 || p_list_1[ptr_1] < p_list_2[ptr_2])) - { - p_list_1_specific[found_1++] = p_list_1[ptr_1]; - t_size ptr_1_new = ptr_1 + 1; - while(ptr_1_new < count_1 && p_list_1[ptr_1_new] == p_list_1[ptr_1]) ptr_1_new++; - ptr_1 = ptr_1_new; - } - while(ptr_2 < count_2 && (ptr_1 == count_1 || p_list_2[ptr_2] < p_list_1[ptr_1])) - { - p_list_2_specific[found_2++] = p_list_2[ptr_2]; - t_size ptr_2_new = ptr_2 + 1; - while(ptr_2_new < count_2 && p_list_2[ptr_2_new] == p_list_2[ptr_2]) ptr_2_new++; - ptr_2 = ptr_2_new; - } - while(ptr_1 < count_1 && ptr_2 < count_2 && p_list_1[ptr_1] == p_list_2[ptr_2]) {ptr_1++; ptr_2++;} - } - - } -} - -double metadb_handle_list_helper::calc_total_duration(metadb_handle_list_cref p_list) -{ - double ret = 0; - t_size n, m = p_list.get_count(); - for(n=0;nget_length(); - if (temp > 0) ret += temp; - } - return ret; -} - -void metadb_handle_list_helper::sort_by_path(metadb_handle_list_ref p_list) -{ - sort_by_format(p_list,"%path_sort%",NULL); -} - - -t_filesize metadb_handle_list_helper::calc_total_size(metadb_handle_list_cref p_list, bool skipUnknown) { - metadb_handle_list list(p_list); - list.sort_t(metadb::path_compare_metadb_handle); - - t_filesize ret = 0; - t_size n, m = list.get_count(); - for(n=0;nget_path(),list[n]->get_path())) { - t_filesize t = list[n]->get_filesize(); - if (t == filesize_invalid) { - if (!skipUnknown) return filesize_invalid; - } else { - ret += t; - } - } - } - return ret; -} - -t_filesize metadb_handle_list_helper::calc_total_size_ex(metadb_handle_list_cref p_list, bool & foundUnknown) { - foundUnknown = false; - metadb_handle_list list(p_list); - list.sort_t(metadb::path_compare_metadb_handle); - - t_filesize ret = 0; - t_size n, m = list.get_count(); - for(n=0;nget_path(),list[n]->get_path())) { - t_filesize t = list[n]->get_filesize(); - if (t == filesize_invalid) { - foundUnknown = true; - } else { - ret += t; - } - } - } - return ret; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/modeless_dialog.h b/tools/vio2sf/src/foobar/foobar2000/SDK/modeless_dialog.h deleted file mode 100644 index cc7d10d1f..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/modeless_dialog.h +++ /dev/null @@ -1,17 +0,0 @@ -//! Service for plugging your nonmodal dialog windows into main app loop to receive IsDialogMessage()-translated messages.\n -//! Note that all methods are valid from main app thread only.\n -//! Usage: static_api_ptr_t or modeless_dialog_manager::g_add / modeless_dialog_manager::g_remove. -class NOVTABLE modeless_dialog_manager : public service_base { - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(modeless_dialog_manager); -public: - //! Adds specified window to global list of windows to receive IsDialogMessage(). - virtual void add(HWND p_wnd) = 0; - //! Removes specified window from global list of windows to receive IsDialogMessage(). - virtual void remove(HWND p_wnd) = 0; - - //! Static helper; see add(). - static void g_add(HWND p_wnd) {static_api_ptr_t()->add(p_wnd);} - //! Static helper; see remove(). - static void g_remove(HWND p_wnd) {static_api_ptr_t()->remove(p_wnd);} - -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/ole_interaction.h b/tools/vio2sf/src/foobar/foobar2000/SDK/ole_interaction.h deleted file mode 100644 index 5159194bd..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/ole_interaction.h +++ /dev/null @@ -1,149 +0,0 @@ -class NOVTABLE playlist_dataobject_desc { -public: - virtual t_size get_entry_count() const = 0; - virtual void get_entry_name(t_size which, pfc::string_base & out) const = 0; - virtual void get_entry_content(t_size which, metadb_handle_list_ref out) const = 0; - - virtual void set_entry_count(t_size count) = 0; - virtual void set_entry_name(t_size which, const char * name) = 0; - virtual void set_entry_content(t_size which, metadb_handle_list_cref content) = 0; - - void copy(playlist_dataobject_desc const & source) { - const t_size count = source.get_entry_count(); set_entry_count(count); - metadb_handle_list content; pfc::string8 name; - for(t_size walk = 0; walk < count; ++walk) { - source.get_entry_name(walk,name); source.get_entry_content(walk,content); - set_entry_name(walk,name); set_entry_content(walk,content); - } - } -protected: - ~playlist_dataobject_desc() {} -private: - const playlist_dataobject_desc & operator=(const playlist_dataobject_desc &) {return *this;} -}; - -class NOVTABLE playlist_dataobject_desc_v2 : public playlist_dataobject_desc { -public: - virtual void get_side_data(t_size which, mem_block_container & out) const = 0; - virtual void set_side_data(t_size which, const void * data, t_size size) = 0; - - void copy(playlist_dataobject_desc_v2 const & source) { - const t_size count = source.get_entry_count(); set_entry_count(count); - metadb_handle_list content; pfc::string8 name; - mem_block_container_impl_t sideData; - for(t_size walk = 0; walk < count; ++walk) { - source.get_entry_name(walk,name); source.get_entry_content(walk,content); source.get_side_data(walk, sideData); - set_entry_name(walk,name); set_entry_content(walk,content); set_side_data(walk, sideData.get_ptr(), sideData.get_size()); - } - } - - void set_from_playlist_manager(bit_array const & mask) { - static_api_ptr_t api; - const t_size pltotal = api->get_playlist_count(); - const t_size total = mask.calc_count(true,0,pltotal); - set_entry_count(total); - t_size done = 0; - pfc::string8 name; metadb_handle_list content; - abort_callback_dummy abort; - for(t_size walk = 0; walk < pltotal; ++walk) if (mask[walk]) { - pfc::dynamic_assert( done < total ); - api->playlist_get_name(walk,name); api->playlist_get_all_items(walk,content); - set_entry_name(done,name); set_entry_content(done,content); - stream_writer_buffer_simple sideData; api->playlist_get_sideinfo(walk, &sideData, abort); - set_side_data(done,sideData.m_buffer.get_ptr(), sideData.m_buffer.get_size()); - ++done; - } - pfc::dynamic_assert( done == total ); - } - - const playlist_dataobject_desc_v2 & operator=(const playlist_dataobject_desc_v2& source) {copy(source); return *this;} -protected: - ~playlist_dataobject_desc_v2() {} -}; - -class playlist_dataobject_desc_impl : public playlist_dataobject_desc_v2 { -public: - playlist_dataobject_desc_impl() {} - playlist_dataobject_desc_impl(const playlist_dataobject_desc_v2 & source) {copy(source);} - - t_size get_entry_count() const {return m_entries.get_size();} - void get_entry_name(t_size which, pfc::string_base & out) const { - if (which < m_entries.get_size()) out = m_entries[which].m_name; - else throw pfc::exception_invalid_params(); - } - void get_entry_content(t_size which, metadb_handle_list_ref out) const { - if (which < m_entries.get_size()) out = m_entries[which].m_content; - else throw pfc::exception_invalid_params(); - } - void set_entry_count(t_size count) { - m_entries.set_size(count); - } - void set_entry_name(t_size which, const char * name) { - if (which < m_entries.get_size()) m_entries[which].m_name = name; - else throw pfc::exception_invalid_params(); - } - void set_entry_content(t_size which, metadb_handle_list_cref content) { - if (which < m_entries.get_size()) m_entries[which].m_content = content; - else throw pfc::exception_invalid_params(); - } - void get_side_data(t_size which, mem_block_container & out) const { - if (which < m_entries.get_size()) out.set(m_entries[which].m_sideData); - else throw pfc::exception_invalid_params(); - } - void set_side_data(t_size which, const void * data, t_size size) { - if (which < m_entries.get_size()) m_entries[which].m_sideData.set_data_fromptr(reinterpret_cast(data), size); - else throw pfc::exception_invalid_params(); - } -private: - struct entry { metadb_handle_list m_content; pfc::string8 m_name; pfc::array_t m_sideData; }; - pfc::array_t m_entries; -}; - -//! \since 0.9.5 -//! Provides various methods for interaction between foobar2000 and OLE IDataObjects, Windows Clipboard, drag&drop and such. -//! To instantiate, use static_api_ptr_t. -class NOVTABLE ole_interaction : public service_base { - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ole_interaction) -public: - enum { - KClipboardFormatSimpleLocations, - KClipboardFormatFPL, - KClipboardFormatMultiFPL, - KClipboardFormatTotal - }; - //! Retrieves clipboard format ID for one of foobar2000's internal data formats. - //! @param which One of KClipboardFormat* constants. - virtual t_uint32 get_clipboard_format(t_uint32 which) = 0; - - //! Creates an IDataObject from a group of tracks. - virtual pfc::com_ptr_t create_dataobject(metadb_handle_list_cref source) = 0; - - //! Creates an IDataObject from one or more playlists, including playlist name info for re-creating those playlists later. - virtual pfc::com_ptr_t create_dataobject(const playlist_dataobject_desc & source) = 0; - - //! Attempts to parse an IDataObject as playlists. - virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t obj, playlist_dataobject_desc & out) = 0; - - //! For internal use only. Will succeed only if the metadb_handle list can be generated immediately, without performing potentially timeconsuming tasks such as parsing media files (for an example when the specified IDataObject contains data in one of our internal formats). - virtual HRESULT parse_dataobject_immediate(pfc::com_ptr_t obj, metadb_handle_list_ref out) = 0; - - //! Attempts to parse an IDataObject into a dropped_files_data object (list of metadb_handles if immediately available, list of file paths otherwise). - virtual HRESULT parse_dataobject(pfc::com_ptr_t obj, dropped_files_data & out) = 0; - - //! Checks whether the specified IDataObject appears to be parsable by our parse_dataobject methods. - virtual HRESULT check_dataobject(pfc::com_ptr_t obj, DWORD & dropEffect, bool & isNative) = 0; - - //! Checks whether the specified IDataObject appears to be parsable as playlists (parse_dataobject_playlists method). - virtual HRESULT check_dataobject_playlists(pfc::com_ptr_t obj) = 0; -}; - -//! \since 0.9.5.4 -class NOVTABLE ole_interaction_v2 : public ole_interaction { - FB2K_MAKE_SERVICE_INTERFACE(ole_interaction_v2, ole_interaction) -public: - //! Creates an IDataObject from one or more playlists, including playlist name info for re-creating those playlists later. - virtual pfc::com_ptr_t create_dataobject(const playlist_dataobject_desc_v2 & source) = 0; - - //! Attempts to parse an IDataObject as playlists. - virtual HRESULT parse_dataobject_playlists(pfc::com_ptr_t obj, playlist_dataobject_desc_v2 & out) = 0; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/packet_decoder.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/packet_decoder.cpp deleted file mode 100644 index abef1bc4d..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/packet_decoder.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "foobar2000.h" - -void packet_decoder::g_open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort) -{ - service_enum_t e; - service_ptr_t ptr; - while(e.next(ptr)) { - if (ptr->is_our_setup(p_owner,p_param1,p_param2,p_param2size)) { - ptr->open(p_out,p_decode,p_owner,p_param1,p_param2,p_param2size,p_abort); - return; - } - } - throw exception_io_data(); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/packet_decoder.h b/tools/vio2sf/src/foobar/foobar2000/SDK/packet_decoder.h deleted file mode 100644 index 55f6a6968..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/packet_decoder.h +++ /dev/null @@ -1,113 +0,0 @@ -//! Provides interface to decode various audio data types to PCM. Use packet_decoder_factory_t template to register. - -class NOVTABLE packet_decoder : public service_base { -protected: - //! Prototype of function that must be implemented by packet_decoder implementation but is not accessible through packet_decoder interface itself. - //! Determines whether specific packet_decoder implementation supports specified decoder setup data. - static bool g_is_our_setup(const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size) {return false;} - - //! Prototype of function that must be implemented by packet_decoder implementation but is not accessible through packet_decoder interface itself. - //! Initializes packet decoder instance with specified decoder setup data. This is called only once, before any other methods. - //! @param p_decode If set to true, decode() and reset_after_seek() calls can be expected later. If set to false, those methods will not be called on this packet_decoder instance - for an example when caller is only retrieving information about the file rather than preparing to decode it. - void open(const GUID & p_owner,bool p_decode,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort) {throw exception_io_data();} -public: - - - //! Forwards additional information about stream being decoded. \n - //! Calling: this must be called immediately after packet_decoder object is created, before any other methods are called.\n - //! Implementation: this is called after open() (which is called by implementation framework immediately after creation), and before any other methods are called. - virtual t_size set_stream_property(const GUID & p_type,t_size p_param1,const void * p_param2,t_size p_param2size) = 0; - - - //! Retrieves additional user-readable tech infos that decoder can provide. - //! @param p_info Interface receiving information about the stream being decoded. Note that it already contains partial info about the file; existing info should not be erased, decoder-provided info should be merged with it. - virtual void get_info(file_info & p_info) = 0; - - //! Returns many frames back to start decoding when seeking. - virtual unsigned get_max_frame_dependency()=0; - //! Returns much time back to start decoding when seeking (for containers where going back by specified number of frames is not trivial). - virtual double get_max_frame_dependency_time()=0; - - //! Flushes decoder after seeking. - virtual void reset_after_seek()=0; - - //! Decodes a block of audio data.\n - //! It may return empty chunk even when successful (caused by encoder+decoder delay for an example), caller must check for it and handle it appropriately. - virtual void decode(const void * p_buffer,t_size p_bytes,audio_chunk & p_chunk,abort_callback & p_abort)=0; - - //! Returns whether this packet decoder supports analyze_first_frame() function. - virtual bool analyze_first_frame_supported() = 0; - //! Optional. Some codecs need to analyze first frame of the stream to return additional info about the stream, such as encoding setup. This can be only called immediately after instantiation (and set_stream_property() if present), before any actual decoding or get_info(). Caller can determine whether this method is supported or not by calling analyze_first_frame_supported(), to avoid reading first frame when decoder won't utiilize the extra info for an example. If particular decoder can't utilize first frame info in any way (and analyze_first_frame_supported() returns false), this function should do nothing and succeed. - virtual void analyze_first_frame(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) = 0; - - //! Static helper, creates a packet_decoder instance and initializes it with specific decoder setup data. - static void g_open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort); - - static const GUID owner_MP4,owner_matroska,owner_MP3,owner_MP2,owner_MP1,owner_MP4_ALAC,owner_ADTS,owner_ADIF, owner_Ogg, owner_MP4_AMR, owner_MP4_AMR_WB; - - struct matroska_setup - { - const char * codec_id; - unsigned sample_rate,sample_rate_output; - unsigned channels; - unsigned codec_private_size; - const void * codec_private; - }; - //owner_MP4: param1 - codec ID (MP4 audio type), param2 - MP4 codec initialization data - //owner_MP3: raw MP3/MP2 file, parameters ignored - //owner_matroska: param2 = matroska_setup struct, param2size size must be equal to sizeof(matroska_setup) - - - //these are used to initialize PCM decoder - static const GUID property_samplerate,property_bitspersample,property_channels,property_byteorder,property_signed,property_channelmask; - //property_samplerate : param1 == sample rate in hz - //property_bitspersample : param1 == bits per sample - //property_channels : param1 == channel count - //property_byteorder : if (param1) little_endian; else big_endian; - //property_signed : if (param1) signed; else unsigned; - - - //property_ogg_header : p_param1 = unused, p_param2 = ogg_packet structure, retval: 0 when more headers are wanted, 1 when done parsing headers - //property_ogg_query_sample_rate : returns sample rate, no parameters - //property_ogg_packet : p_param1 = unused, p_param2 = ogg_packet strucute - static const GUID property_ogg_header, property_ogg_query_sample_rate, property_ogg_packet; - - FB2K_MAKE_SERVICE_INTERFACE(packet_decoder,service_base); -}; - -class NOVTABLE packet_decoder_streamparse : public packet_decoder -{ -public: - virtual void decode_ex(const void * p_buffer,t_size p_bytes,t_size & p_bytes_processed,audio_chunk & p_chunk,abort_callback & p_abort) = 0; - virtual void analyze_first_frame_ex(const void * p_buffer,t_size p_bytes,t_size & p_bytes_processed,abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(packet_decoder_streamparse,packet_decoder); -}; - -class NOVTABLE packet_decoder_entry : public service_base -{ -public: - virtual bool is_our_setup(const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size) = 0; - virtual void open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(packet_decoder_entry); -}; - - -template -class packet_decoder_entry_impl_t : public packet_decoder_entry -{ -public: - bool is_our_setup(const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size) { - return T::g_is_our_setup(p_owner,p_param1,p_param2,p_param2size); - } - void open(service_ptr_t & p_out,bool p_decode,const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size,abort_callback & p_abort) { - assert(is_our_setup(p_owner,p_param1,p_param2,p_param2size)); - service_ptr_t instance = new service_impl_t(); - instance->open(p_owner,p_decode,p_param1,p_param2,p_param2size,p_abort); - p_out = instance.get_ptr(); - } -}; - -template -class packet_decoder_factory_t : public service_factory_single_t > {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/play_callback.h b/tools/vio2sf/src/foobar/foobar2000/SDK/play_callback.h deleted file mode 100644 index d3d659ffe..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/play_callback.h +++ /dev/null @@ -1,149 +0,0 @@ -/*! -Class receiving notifications about playback events. Note that all methods are called only from app's main thread. -Use play_callback_manager to register your dynamically created instances. Statically registered version is available too - see play_callback_static. -*/ -class NOVTABLE play_callback { -public: - //! Playback process is being initialized. on_playback_new_track() should be called soon after this when first file is successfully opened for decoding. - virtual void FB2KAPI on_playback_starting(play_control::t_track_command p_command,bool p_paused) = 0; - //! Playback advanced to new track. - virtual void FB2KAPI on_playback_new_track(metadb_handle_ptr p_track) = 0; - //! Playback stopped. - virtual void FB2KAPI on_playback_stop(play_control::t_stop_reason p_reason) = 0; - //! User has seeked to specific time. - virtual void FB2KAPI on_playback_seek(double p_time) = 0; - //! Called on pause/unpause. - virtual void FB2KAPI on_playback_pause(bool p_state) = 0; - //! Called when currently played file gets edited. - virtual void FB2KAPI on_playback_edited(metadb_handle_ptr p_track) = 0; - //! Dynamic info (VBR bitrate etc) change. - virtual void FB2KAPI on_playback_dynamic_info(const file_info & p_info) = 0; - //! Per-track dynamic info (stream track titles etc) change. Happens less often than on_playback_dynamic_info(). - virtual void FB2KAPI on_playback_dynamic_info_track(const file_info & p_info) = 0; - //! Called every second, for time display - virtual void FB2KAPI on_playback_time(double p_time) = 0; - //! User changed volume settings. Possibly called when not playing. - //! @param p_new_val new volume level in dB; 0 for full volume. - virtual void FB2KAPI on_volume_change(float p_new_val) = 0; - - enum { - flag_on_playback_starting = 1 << 0, - flag_on_playback_new_track = 1 << 1, - flag_on_playback_stop = 1 << 2, - flag_on_playback_seek = 1 << 3, - flag_on_playback_pause = 1 << 4, - flag_on_playback_edited = 1 << 5, - flag_on_playback_dynamic_info = 1 << 6, - flag_on_playback_dynamic_info_track = 1 << 7, - flag_on_playback_time = 1 << 8, - flag_on_volume_change = 1 << 9, - - flag_on_playback_all = flag_on_playback_starting | flag_on_playback_new_track | - flag_on_playback_stop | flag_on_playback_seek | - flag_on_playback_pause | flag_on_playback_edited | - flag_on_playback_dynamic_info | flag_on_playback_dynamic_info_track | flag_on_playback_time, - }; -protected: - play_callback() {} - ~play_callback() {} -}; - -//! Standard API (always present); manages registrations of dynamic play_callbacks. -//! Usage: use static_api_ptr_t. -//! Do not reimplement. -class NOVTABLE play_callback_manager : public service_base -{ -public: - //! Registers a play_callback object. - //! @param p_callback Interface to register. - //! @param p_flags Indicates which notifications are requested. - //! @param p_forward_status_on_register Set to true to have the callback immediately receive current playback status as notifications if playback is active (eg. to receive info about playback process that started before our callback was registered). - virtual void FB2KAPI register_callback(play_callback * p_callback,unsigned p_flags,bool p_forward_status_on_register) = 0; - //! Unregisters a play_callback object. - //! @p_callback Previously registered interface to unregister. - virtual void FB2KAPI unregister_callback(play_callback * p_callback) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(play_callback_manager); -}; - -//! Implementation helper. -class play_callback_impl_base : public play_callback { -public: - play_callback_impl_base(unsigned p_flags = ~0) { - static_api_ptr_t()->register_callback(this,p_flags,false); - } - ~play_callback_impl_base() { - static_api_ptr_t()->unregister_callback(this); - } - void play_callback_reregister(unsigned flags, bool refresh = false) { - static_api_ptr_t api; - api->unregister_callback(this); - api->register_callback(this,flags,refresh); - } - void on_playback_starting(play_control::t_track_command p_command,bool p_paused) {} - void on_playback_new_track(metadb_handle_ptr p_track) {} - void on_playback_stop(play_control::t_stop_reason p_reason) {} - void on_playback_seek(double p_time) {} - void on_playback_pause(bool p_state) {} - void on_playback_edited(metadb_handle_ptr p_track) {} - void on_playback_dynamic_info(const file_info & p_info) {} - void on_playback_dynamic_info_track(const file_info & p_info) {} - void on_playback_time(double p_time) {} - void on_volume_change(float p_new_val) {} - - PFC_CLASS_NOT_COPYABLE_EX(play_callback_impl_base) -}; - -//! Static (autoregistered) version of play_callback. Use play_callback_static_factory_t to register. -class play_callback_static : public service_base, public play_callback { -public: - //! Controls which methods your callback wants called; returned value should not change in run time, you should expect it to be queried only once (on startup). See play_callback::flag_* constants. - virtual unsigned get_flags() = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(play_callback_static); -}; - -template -class play_callback_static_factory_t : public service_factory_single_t {}; - - -//! Gets notified about tracks being played. Notification occurs when at least 60s of the track has been played, or the track has reached its end after at least 1/3 of it has been played through. -//! Use playback_statistics_collector_factory_t to register. -class NOVTABLE playback_statistics_collector : public service_base { -public: - virtual void on_item_played(metadb_handle_ptr p_item) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playback_statistics_collector); -}; - -template -class playback_statistics_collector_factory_t : public service_factory_single_t {}; - - - - -//! Helper providing a simplified interface for receiving playback events, in case your code does not care about the kind of playback event that has occured; useful typically for GUI/rendering code that just refreshes some control whenever a playback state change occurs. -class playback_event_notify : private play_callback_impl_base { -public: - playback_event_notify(playback_control::t_display_level level = playback_control::display_level_all) : play_callback_impl_base(GrabCBFlags(level)) {} - - static t_uint32 GrabCBFlags(playback_control::t_display_level level) { - t_uint32 flags = flag_on_playback_starting | flag_on_playback_new_track | flag_on_playback_stop | flag_on_playback_pause | flag_on_playback_edited | flag_on_volume_change; - if (level >= playback_control::display_level_titles) flags |= flag_on_playback_dynamic_info_track; - if (level >= playback_control::display_level_all) flags |= flag_on_playback_seek | flag_on_playback_dynamic_info | flag_on_playback_time; - return flags; - } -protected: - virtual void on_playback_event() {} -private: - void on_playback_starting(play_control::t_track_command p_command,bool p_paused) {on_playback_event();} - void on_playback_new_track(metadb_handle_ptr p_track) {on_playback_event();} - void on_playback_stop(play_control::t_stop_reason p_reason) {on_playback_event();} - void on_playback_seek(double p_time) {on_playback_event();} - void on_playback_pause(bool p_state) {on_playback_event();} - void on_playback_edited(metadb_handle_ptr p_track) {on_playback_event();} - void on_playback_dynamic_info(const file_info & p_info) {on_playback_event();} - void on_playback_dynamic_info_track(const file_info & p_info) {on_playback_event();} - void on_playback_time(double p_time) {on_playback_event();} - void on_volume_change(float p_new_val) {on_playback_event();} -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playable_location.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/playable_location.cpp deleted file mode 100644 index 5ad6e0c0e..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playable_location.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "foobar2000.h" - -int playable_location::g_compare(const playable_location & p_item1,const playable_location & p_item2) { - int ret = metadb::path_compare(p_item1.get_path(),p_item2.get_path()); - if (ret != 0) return ret; - return pfc::compare_t(p_item1.get_subsong(),p_item2.get_subsong()); -} - -pfc::string_base & operator<<(pfc::string_base & p_fmt,const playable_location & p_location) -{ - p_fmt << "\"" << file_path_display(p_location.get_path()) << "\""; - t_uint32 index = p_location.get_subsong_index(); - if (index != 0) p_fmt << " / index: " << p_location.get_subsong_index(); - return p_fmt; -} - - -bool playable_location::operator==(const playable_location & p_other) const { - return metadb::path_compare(get_path(),p_other.get_path()) == 0 && get_subsong() == p_other.get_subsong(); -} -bool playable_location::operator!=(const playable_location & p_other) const { - return !(*this == p_other); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playable_location.h b/tools/vio2sf/src/foobar/foobar2000/SDK/playable_location.h deleted file mode 100644 index 0f1d1829b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playable_location.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef _FOOBAR2000_PLAYABLE_LOCATION_H_ -#define _FOOBAR2000_PLAYABLE_LOCATION_H_ - -//playable_location stores location of a playable resource, currently implemented as file path and integer for indicating multiple playable "subsongs" per file -//also see: file_info.h -//for getting more info about resource referenced by a playable_location, see metadb.h - -//char* strings are all UTF-8 - -class NOVTABLE playable_location//interface (for passing around between DLLs) -{ -public: - virtual const char * get_path() const =0; - virtual void set_path(const char*)=0; - virtual t_uint32 get_subsong() const =0; - virtual void set_subsong(t_uint32)=0; - - void copy(const playable_location & p_other) { - set_path(p_other.get_path()); - set_subsong(p_other.get_subsong()); - } - - static int g_compare(const playable_location & p_item1,const playable_location & p_item2); - - const playable_location & operator=(const playable_location & src) {copy(src);return *this;} - - bool operator==(const playable_location & p_other) const; - bool operator!=(const playable_location & p_other) const; - - inline bool is_empty() {return get_path()[0]==0 && get_subsong()==0;} - inline void reset() {set_path("");set_subsong(0);} - inline t_uint32 get_subsong_index() const {return get_subsong();} - inline void set_subsong_index(t_uint32 v) {set_subsong(v);} - - class comparator { - public: - static int compare(const playable_location & v1, const playable_location & v2) {return g_compare(v1,v2);} - }; - -protected: - playable_location() {} - ~playable_location() {} -}; - -typedef playable_location * pplayable_location; -typedef playable_location const * pcplayable_location; -typedef playable_location & rplayable_location; -typedef playable_location const & rcplayable_location; - -class playable_location_impl : public playable_location//implementation -{ -public: - const char * get_path() const {return m_path;} - void set_path(const char* p_path) {m_path=p_path;} - t_uint32 get_subsong() const {return m_subsong;} - void set_subsong(t_uint32 p_subsong) {m_subsong=p_subsong;} - - const playable_location_impl & operator=(const playable_location & src) {copy(src);return *this;} - const playable_location_impl & operator=(const playable_location_impl & src) {copy(src);return *this;} - - playable_location_impl() : m_subsong(0) {} - playable_location_impl(const char * p_path,t_uint32 p_subsong) : m_path(p_path), m_subsong(p_subsong) {} - playable_location_impl(const playable_location & src) {copy(src);} - playable_location_impl(const playable_location_impl & src) {copy(src);} - -private: - pfc::string_simple m_path; - t_uint32 m_subsong; -}; - -// usage: something( make_playable_location("file://c:\blah.ogg",0) ); -// only for use as a parameter to a function taking const playable_location & -class make_playable_location : public playable_location -{ - const char * path; - t_uint32 num; - - void set_path(const char*) {throw pfc::exception_not_implemented();} - void set_subsong(t_uint32) {throw pfc::exception_not_implemented();} - -public: - const char * get_path() const {return path;} - t_uint32 get_subsong() const {return num;} - - make_playable_location(const char * p_path,t_uint32 p_num) : path(p_path), num(p_num) {} -}; - -pfc::string_base & operator<<(pfc::string_base & p_fmt,const playable_location & p_location); - -#endif //_FOOBAR2000_PLAYABLE_LOCATION_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playback_control.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/playback_control.cpp deleted file mode 100644 index bf9c47be7..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playback_control.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "foobar2000.h" - - -double playback_control::playback_get_length() -{ - double rv = 0; - metadb_handle_ptr ptr; - if (get_now_playing(ptr)) - { - rv = ptr->get_length(); - } - return rv; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playback_control.h b/tools/vio2sf/src/foobar/foobar2000/SDK/playback_control.h deleted file mode 100644 index a756847e4..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playback_control.h +++ /dev/null @@ -1,135 +0,0 @@ -//! Provides control for various playback-related operations. -//! All methods provided by this interface work from main app thread only. Calling from another thread will do nothing or trigger an exception. If you need to trigger one of playback_control methods from another thread, see main_thread_callback. -//! Do not call playback_control methods from inside any kind of global callback (e.g. playlist callback), otherwise race conditions may occur. -//! Use static_api_ptr_t to instantiate. See static_api_ptr_t documentation for more info. -class NOVTABLE playback_control : public service_base -{ -public: - - enum t_stop_reason { - stop_reason_user = 0, - stop_reason_eof, - stop_reason_starting_another, - stop_reason_shutting_down, - }; - - - enum t_track_command { - track_command_default = 0, - track_command_play, - track_command_next, - track_command_prev, - track_command_settrack, - track_command_rand, - track_command_resume, - }; - - //! Retrieves now playing item handle. - //! @returns true on success, false on failure (not playing). - virtual bool get_now_playing(metadb_handle_ptr & p_out) = 0; - //! Starts playback. If playback is already active, existing process is stopped first. - //! @param p_command Specifies what track to start playback from. See t_track_Command enum for more info. - //! @param p_paused Specifies whether playback should be started as paused. - virtual void start(t_track_command p_command = track_command_play,bool p_paused = false) = 0; - //! Stops playback. - virtual void stop() = 0; - //! Returns whether playback is active. - virtual bool is_playing() = 0; - //! Returns whether playback is active and in paused state. - virtual bool is_paused() = 0; - //! Toggles pause state if playback is active. - //! @param p_state set to true when pausing or to false when unpausing. - virtual void pause(bool p_state) = 0; - - //! Retrieves stop-after-current-track option state. - virtual bool get_stop_after_current() = 0; - //! Alters stop-after-current-track option state. - virtual void set_stop_after_current(bool p_state) = 0; - - //! Alters playback volume level. - //! @param p_value volume in dB; 0 for full volume. - virtual void set_volume(float p_value) = 0; - //! Retrieves playback volume level. - //! @returns current playback volume level, in dB; 0 for full volume. - virtual float get_volume() = 0; - //! Alters playback volume level one step up. - virtual void volume_up() = 0; - //! Alters playback volume level one step down. - virtual void volume_down() = 0; - //! Toggles playback mute state. - virtual void volume_mute_toggle() = 0; - //! Seeks in currenly played track to specified time. - //! @param p_time target time in seconds. - virtual void playback_seek(double p_time) = 0; - //! Seeks in currently played track by specified time forward or back. - //! @param p_delta time in seconds to seek by; can be positive to seek forward or negative to seek back. - virtual void playback_seek_delta(double p_delta) = 0; - //! Returns whether currently played track is seekable. If it's not, playback_seek/playback_seek_delta calls will be ignored. - virtual bool playback_can_seek() = 0; - //! Returns current playback position within currently played track, in seconds. - virtual double playback_get_position() = 0; - - //! Type used to indicate level of dynamic playback-related info displayed. Safe to use with <> opereators, e.g. level above N always includes information rendered by level N. - enum t_display_level { - //! No playback-related info - display_level_none, - //! Static info and is_playing/is_paused stats - display_level_basic, - //! display_level_basic + dynamic track titles on e.g. live streams - display_level_titles, - //! display_level_titles + timing + VBR bitrate display etc - display_level_all, - }; - - //! Renders information about currently playing item. - //! @param p_hook Optional callback object overriding fields and functions; set to NULL if not used. - //! @param p_out String receiving the output on success. - //! @param p_script Titleformat script to use. Use titleformat_compiler service to create one. - //! @param p_filter Optional callback object allowing input to be filtered according to context (i.e. removal of linebreak characters present in tags when rendering playlist lines). Set to NULL when not used. - //! @param p_level Indicates level of dynamic playback-related info displayed. See t_display_level enum for more details. - //! @returns true on success, false when no item is currently being played. - virtual bool playback_format_title(titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,t_display_level p_level) = 0; - - - - //! Helper; renders info about any item, including currently playing item info if the item is currently played. - bool playback_format_title_ex(metadb_handle_ptr p_item,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,t_display_level p_level) { - if (p_item.is_empty()) return playback_format_title(p_hook,p_out,p_script,p_filter,p_level); - metadb_handle_ptr temp; - if (get_now_playing(temp)) { - if (temp == p_item) { - return playback_format_title(p_hook,p_out,p_script,p_filter,p_level); - } - } - p_item->format_title(p_hook,p_out,p_script,p_filter); - return true; - } - - //! Helper; retrieves length of currently playing item. - double playback_get_length(); - - //! Toggles stop-after-current state. - void toggle_stop_after_current() {set_stop_after_current(!get_stop_after_current());} - //! Toggles pause state. - void toggle_pause() {pause(!is_paused());} - - //! Starts playback if playback is inactive, otherwise toggles pause. - void play_or_pause() {if (is_playing()) toggle_pause(); else start();} - - //deprecated - inline void play_start(t_track_command p_command = track_command_play,bool p_paused = false) {start(p_command,p_paused);} - //deprecated - inline void play_stop() {stop();} - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playback_control); -}; - -class playback_control_v2 : public playback_control { -public: - virtual float get_volume_step() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(playback_control_v2,playback_control); -}; - -//for compatibility with old code -typedef playback_control play_control; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/playlist.cpp deleted file mode 100644 index fe4456bd9..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist.cpp +++ /dev/null @@ -1,861 +0,0 @@ -#include "foobar2000.h" - - -namespace { - class enum_items_callback_retrieve_item : public playlist_manager::enum_items_callback - { - metadb_handle_ptr m_item; - public: - enum_items_callback_retrieve_item() : m_item(0) {} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) - { - assert(m_item.is_empty()); - m_item = p_location; - return false; - } - inline const metadb_handle_ptr & get_item() {return m_item;} - }; - - class enum_items_callback_retrieve_selection : public playlist_manager::enum_items_callback - { - bool m_state; - public: - enum_items_callback_retrieve_selection() : m_state(false) {} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) - { - m_state = b_selected; - return false; - } - inline bool get_state() {return m_state;} - }; - - class enum_items_callback_retrieve_selection_mask : public playlist_manager::enum_items_callback - { - bit_array_var & m_out; - public: - enum_items_callback_retrieve_selection_mask(bit_array_var & p_out) : m_out(p_out) {} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) - { - m_out.set(p_index,b_selected); - return true; - } - }; - - class enum_items_callback_retrieve_all_items : public playlist_manager::enum_items_callback - { - pfc::list_base_t & m_out; - public: - enum_items_callback_retrieve_all_items(pfc::list_base_t & p_out) : m_out(p_out) {m_out.remove_all();} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) - { - m_out.add_item(p_location); - return true; - } - }; - - class enum_items_callback_retrieve_selected_items : public playlist_manager::enum_items_callback - { - pfc::list_base_t & m_out; - public: - enum_items_callback_retrieve_selected_items(pfc::list_base_t & p_out) : m_out(p_out) {m_out.remove_all();} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) - { - if (b_selected) m_out.add_item(p_location); - return true; - } - }; - - class enum_items_callback_count_selection : public playlist_manager::enum_items_callback - { - t_size m_counter,m_max; - public: - enum_items_callback_count_selection(t_size p_max) : m_max(p_max), m_counter(0) {} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) - { - if (b_selected) - { - if (++m_counter >= m_max) return false; - } - return true; - } - - inline t_size get_count() {return m_counter;} - }; - -} - -void playlist_manager::playlist_get_all_items(t_size p_playlist,pfc::list_base_t & out) -{ - playlist_get_items(p_playlist,out,bit_array_true()); -} - -void playlist_manager::playlist_get_selected_items(t_size p_playlist,pfc::list_base_t & out) -{ - playlist_enum_items(p_playlist,enum_items_callback_retrieve_selected_items(out),bit_array_true()); -} - -void playlist_manager::playlist_get_selection_mask(t_size p_playlist,bit_array_var & out) -{ - playlist_enum_items(p_playlist,enum_items_callback_retrieve_selection_mask(out),bit_array_true()); -} - -bool playlist_manager::playlist_is_item_selected(t_size p_playlist,t_size p_item) -{ - enum_items_callback_retrieve_selection callback; - playlist_enum_items(p_playlist,callback,bit_array_one(p_item)); - return callback.get_state(); -} - -metadb_handle_ptr playlist_manager::playlist_get_item_handle(t_size playlist, t_size item) { - metadb_handle_ptr temp; - if (!playlist_get_item_handle(temp, playlist, item)) throw pfc::exception_invalid_params(); - PFC_ASSERT( temp.is_valid() ); - return temp; - -} -bool playlist_manager::playlist_get_item_handle(metadb_handle_ptr & p_out,t_size p_playlist,t_size p_item) -{ - enum_items_callback_retrieve_item callback; - playlist_enum_items(p_playlist,callback,bit_array_one(p_item)); - p_out = callback.get_item(); - return p_out.is_valid(); -} - -void playlist_manager::g_make_selection_move_permutation(t_size * p_output,t_size p_count,const bit_array & p_selection,int p_delta) { - pfc::create_move_items_permutation(p_output,p_count,p_selection,p_delta); -} - -bool playlist_manager::playlist_move_selection(t_size p_playlist,int p_delta) { - if (p_delta==0) return true; - - t_size count = playlist_get_item_count(p_playlist); - - pfc::array_t order; order.set_size(count); - pfc::array_t selection; selection.set_size(count); - - playlist_get_selection_mask(p_playlist,bit_array_var_table(selection.get_ptr(),selection.get_size())); - g_make_selection_move_permutation(order.get_ptr(),count,bit_array_table(selection.get_ptr(),selection.get_size()),p_delta); - return playlist_reorder_items(p_playlist,order.get_ptr(),count); -} - -//retrieving status -t_size playlist_manager::activeplaylist_get_item_count() -{ - t_size playlist = get_active_playlist(); - if (playlist == infinite) return 0; - else return playlist_get_item_count(playlist); -} - -void playlist_manager::activeplaylist_enum_items(enum_items_callback & p_callback,const bit_array & p_mask) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_enum_items(playlist,p_callback,p_mask); -} - -t_size playlist_manager::activeplaylist_get_focus_item() -{ - t_size playlist = get_active_playlist(); - if (playlist == infinite) return infinite; - else return playlist_get_focus_item(playlist); -} - -bool playlist_manager::activeplaylist_get_name(pfc::string_base & p_out) -{ - t_size playlist = get_active_playlist(); - if (playlist == infinite) return false; - else return playlist_get_name(playlist,p_out); -} - -//modifying playlist -bool playlist_manager::activeplaylist_reorder_items(const t_size * order,t_size count) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_reorder_items(playlist,order,count); - else return false; -} - -void playlist_manager::activeplaylist_set_selection(const bit_array & affected,const bit_array & status) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_set_selection(playlist,affected,status); -} - -bool playlist_manager::activeplaylist_remove_items(const bit_array & mask) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_remove_items(playlist,mask); - else return false; -} - -bool playlist_manager::activeplaylist_replace_item(t_size p_item,const metadb_handle_ptr & p_new_item) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_replace_item(playlist,p_item,p_new_item); - else return false; -} - -void playlist_manager::activeplaylist_set_focus_item(t_size p_item) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_set_focus_item(playlist,p_item); -} - -t_size playlist_manager::activeplaylist_insert_items(t_size p_base,const pfc::list_base_const_t & data,const bit_array & p_selection) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_insert_items(playlist,p_base,data,p_selection); - else return infinite; -} - -void playlist_manager::activeplaylist_ensure_visible(t_size p_item) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_ensure_visible(playlist,p_item); -} - -bool playlist_manager::activeplaylist_rename(const char * p_name,t_size p_name_len) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_rename(playlist,p_name,p_name_len); - else return false; -} - -bool playlist_manager::activeplaylist_is_item_selected(t_size p_item) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_is_item_selected(playlist,p_item); - else return false; -} - -metadb_handle_ptr playlist_manager::activeplaylist_get_item_handle(t_size p_item) { - metadb_handle_ptr temp; - if (!activeplaylist_get_item_handle(temp, p_item)) throw pfc::exception_invalid_params(); - PFC_ASSERT( temp.is_valid() ); - return temp; -} -bool playlist_manager::activeplaylist_get_item_handle(metadb_handle_ptr & p_out,t_size p_item) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_get_item_handle(p_out,playlist,p_item); - else return false; -} - -void playlist_manager::activeplaylist_move_selection(int p_delta) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_move_selection(playlist,p_delta); -} - -void playlist_manager::activeplaylist_get_selection_mask(bit_array_var & out) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_get_selection_mask(playlist,out); -} - -void playlist_manager::activeplaylist_get_all_items(pfc::list_base_t & out) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_get_all_items(playlist,out); -} - -void playlist_manager::activeplaylist_get_selected_items(pfc::list_base_t & out) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_get_selected_items(playlist,out); -} - -bool playlist_manager::remove_playlist(t_size idx) -{ - return remove_playlists(bit_array_one(idx)); -} - -bool playlist_incoming_item_filter::process_location(const char * url,pfc::list_base_t & out,bool filter,const char * p_mask,const char * p_exclude,HWND p_parentwnd) -{ - return process_locations(pfc::list_single_ref_t(url),out,filter,p_mask,p_exclude,p_parentwnd); -} - -void playlist_manager::playlist_clear(t_size p_playlist) -{ - playlist_remove_items(p_playlist,bit_array_true()); -} - -void playlist_manager::activeplaylist_clear() -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_clear(playlist); -} - -bool playlist_manager::playlist_update_content(t_size playlist, metadb_handle_list_cref content, bool bUndoBackup) { - metadb_handle_list old; - playlist_get_all_items(playlist, old); - if (old.get_size() == 0) { - if (content.get_size() == 0) return false; - if (bUndoBackup) playlist_undo_backup(playlist); - playlist_add_items(playlist, content, bit_array_false()); - return true; - } - pfc::avltree_t itemsOld, itemsNew; - - for(t_size walk = 0; walk < old.get_size(); ++walk) itemsOld += old[walk]; - for(t_size walk = 0; walk < content.get_size(); ++walk) itemsNew += content[walk]; - bit_array_bittable removeMask(old.get_size()); - bit_array_bittable filterMask(content.get_size()); - bool gotNew = false, filterNew = false, gotRemove = false; - for(t_size walk = 0; walk < content.get_size(); ++walk) { - const bool state = !itemsOld.have_item(content[walk]); - if (state) gotNew = true; - else filterNew = true; - filterMask.set(walk, state); - } - for(t_size walk = 0; walk < old.get_size(); ++walk) { - const bool state = !itemsNew.have_item(old[walk]); - if (state) gotRemove = true; - removeMask.set(walk, state); - } - if (!gotNew && !gotRemove) return false; - if (bUndoBackup) playlist_undo_backup(playlist); - if (gotRemove) { - playlist_remove_items(playlist, removeMask); - } - if (gotNew) { - if (filterNew) { - metadb_handle_list temp(content); - temp.filter_mask(filterMask); - playlist_add_items(playlist, temp, bit_array_false()); - } else { - playlist_add_items(playlist, content, bit_array_false()); - } - } - return true; -} -bool playlist_manager::playlist_add_items(t_size playlist,const pfc::list_base_const_t & data,const bit_array & p_selection) -{ - return playlist_insert_items(playlist,infinite,data,p_selection) != infinite; -} - -bool playlist_manager::activeplaylist_add_items(const pfc::list_base_const_t & data,const bit_array & p_selection) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_add_items(playlist,data,p_selection); - else return false; -} - -bool playlist_manager::playlist_insert_items_filter(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_data,bool p_select) -{ - metadb_handle_list temp; - static_api_ptr_t api; - if (!api->filter_items(p_data,temp)) - return false; - return playlist_insert_items(p_playlist,p_base,temp,bit_array_val(p_select)) != infinite; -} - -bool playlist_manager::activeplaylist_insert_items_filter(t_size p_base,const pfc::list_base_const_t & p_data,bool p_select) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_insert_items_filter(playlist,p_base,p_data,p_select); - else return false; -} - -bool playlist_manager::playlist_insert_locations(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd) -{ - metadb_handle_list temp; - static_api_ptr_t api; - if (!api->process_locations(p_urls,temp,true,0,0,p_parentwnd)) return false; - return playlist_insert_items(p_playlist,p_base,temp,bit_array_val(p_select)) != infinite; -} - -bool playlist_manager::activeplaylist_insert_locations(t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_insert_locations(playlist,p_base,p_urls,p_select,p_parentwnd); - else return false; -} - -bool playlist_manager::playlist_add_items_filter(t_size p_playlist,const pfc::list_base_const_t & p_data,bool p_select) -{ - return playlist_insert_items_filter(p_playlist,infinite,p_data,p_select); -} - -bool playlist_manager::activeplaylist_add_items_filter(const pfc::list_base_const_t & p_data,bool p_select) -{ - return activeplaylist_insert_items_filter(infinite,p_data,p_select); -} - -bool playlist_manager::playlist_add_locations(t_size p_playlist,const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd) -{ - return playlist_insert_locations(p_playlist,infinite,p_urls,p_select,p_parentwnd); -} -bool playlist_manager::activeplaylist_add_locations(const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd) -{ - return activeplaylist_insert_locations(infinite,p_urls,p_select,p_parentwnd); -} - -void playlist_manager::reset_playing_playlist() -{ - set_playing_playlist(get_active_playlist()); -} - -void playlist_manager::playlist_clear_selection(t_size p_playlist) -{ - playlist_set_selection(p_playlist,bit_array_true(),bit_array_false()); -} - -void playlist_manager::activeplaylist_clear_selection() -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_clear_selection(playlist); -} - -void playlist_manager::activeplaylist_undo_backup() -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_undo_backup(playlist); -} - -bool playlist_manager::activeplaylist_undo_restore() -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_undo_restore(playlist); - else return false; -} - -bool playlist_manager::activeplaylist_redo_restore() -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_redo_restore(playlist); - else return false; -} - -void playlist_manager::playlist_remove_selection(t_size p_playlist,bool p_crop) -{ - bit_array_bittable table(playlist_get_item_count(p_playlist)); - playlist_get_selection_mask(p_playlist,table); - if (p_crop) playlist_remove_items(p_playlist,bit_array_not(table)); - else playlist_remove_items(p_playlist,table); -} - -void playlist_manager::activeplaylist_remove_selection(bool p_crop) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_remove_selection(playlist,p_crop); -} - -void playlist_manager::activeplaylist_item_format_title(t_size p_item,titleformat_hook * p_hook,pfc::string_base & out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,play_control::t_display_level p_playback_info_level) -{ - t_size playlist = get_active_playlist(); - if (playlist == infinite) out = "NJET"; - else playlist_item_format_title(playlist,p_item,p_hook,out,p_script,p_filter,p_playback_info_level); -} - -void playlist_manager::playlist_set_selection_single(t_size p_playlist,t_size p_item,bool p_state) -{ - playlist_set_selection(p_playlist,bit_array_one(p_item),bit_array_val(p_state)); -} - -void playlist_manager::activeplaylist_set_selection_single(t_size p_item,bool p_state) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_set_selection_single(playlist,p_item,p_state); -} - -t_size playlist_manager::playlist_get_selection_count(t_size p_playlist,t_size p_max) -{ - enum_items_callback_count_selection callback(p_max); - playlist_enum_items(p_playlist,callback,bit_array_true()); - return callback.get_count(); -} - -t_size playlist_manager::activeplaylist_get_selection_count(t_size p_max) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_get_selection_count(playlist,p_max); - else return 0; -} - -bool playlist_manager::playlist_get_focus_item_handle(metadb_handle_ptr & p_out,t_size p_playlist) -{ - t_size index = playlist_get_focus_item(p_playlist); - if (index == infinite) return false; - return playlist_get_item_handle(p_out,p_playlist,index); -} - -bool playlist_manager::activeplaylist_get_focus_item_handle(metadb_handle_ptr & p_out) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_get_focus_item_handle(p_out,playlist); - else return false; -} - -t_size playlist_manager::find_playlist(const char * p_name,t_size p_name_length) -{ - t_size n, m = get_playlist_count(); - pfc::string_formatter temp; - for(n=0;n namebuffer; - namebuffer << new_playlist_text << " (" << walk << ")"; - if (find_playlist(namebuffer,infinite) == infinite) return create_playlist(namebuffer,infinite,p_index); - } -} - -bool playlist_manager::activeplaylist_sort_by_format(const char * spec,bool p_sel_only) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) return playlist_sort_by_format(playlist,spec,p_sel_only); - else return false; -} - -bool playlist_manager::highlight_playing_item() -{ - t_size playlist,item; - if (!get_playing_item_location(&playlist,&item)) return false; - set_active_playlist(playlist); - playlist_set_focus_item(playlist,item); - playlist_set_selection(playlist,bit_array_true(),bit_array_one(item)); - playlist_ensure_visible(playlist,item); - return true; -} - -void playlist_manager::playlist_get_items(t_size p_playlist,pfc::list_base_t & out,const bit_array & p_mask) -{ - playlist_enum_items(p_playlist,enum_items_callback_retrieve_all_items(out),p_mask); -} - -void playlist_manager::activeplaylist_get_items(pfc::list_base_t & out,const bit_array & p_mask) -{ - t_size playlist = get_active_playlist(); - if (playlist != infinite) playlist_get_items(playlist,out,p_mask); -} - -void playlist_manager::active_playlist_fix() -{ - t_size playlist = get_active_playlist(); - if (playlist == infinite) - { - t_size max = get_playlist_count(); - if (max == 0) - { - create_playlist_autoname(); - } - set_active_playlist(0); - } -} - -namespace { - class enum_items_callback_remove_list : public playlist_manager::enum_items_callback - { - const metadb_handle_list & m_data; - bit_array_var & m_table; - t_size m_found; - public: - enum_items_callback_remove_list(const metadb_handle_list & p_data,bit_array_var & p_table) : m_data(p_data), m_table(p_table), m_found(0) {} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) - { - bool found = m_data.bsearch_by_pointer(p_location) != infinite; - m_table.set(p_index,found); - if (found) m_found++; - return true; - } - - inline t_size get_found() const {return m_found;} - }; -} - -void playlist_manager::remove_items_from_all_playlists(const pfc::list_base_const_t & p_data) -{ - t_size playlist_num, playlist_max = get_playlist_count(); - if (playlist_max != infinite) - { - metadb_handle_list temp; - temp.add_items(p_data); - temp.sort_by_pointer(); - for(playlist_num = 0; playlist_num < playlist_max; playlist_num++ ) - { - t_size playlist_item_count = playlist_get_item_count(playlist_num); - if (playlist_item_count == infinite) break; - bit_array_bittable table(playlist_item_count); - enum_items_callback_remove_list callback(temp,table); - playlist_enum_items(playlist_num,callback,bit_array_true()); - if (callback.get_found()>0) - playlist_remove_items(playlist_num,table); - } - } -} - -bool playlist_manager::get_all_items(pfc::list_base_t & out) -{ - t_size n, m = get_playlist_count(); - if (m == infinite) return false; - enum_items_callback_retrieve_all_items callback(out); - for(n=0;n 0) - { - if (idx >= total) idx = total-1; - set_active_playlist(idx); - } - } - return true; - } - else return false; -} - - - -bool t_playback_queue_item::operator==(const t_playback_queue_item & p_item) const -{ - return m_handle == p_item.m_handle && m_playlist == p_item.m_playlist && m_item == p_item.m_item; -} - -bool t_playback_queue_item::operator!=(const t_playback_queue_item & p_item) const -{ - return m_handle != p_item.m_handle || m_playlist != p_item.m_playlist || m_item != p_item.m_item; -} - - - -bool playlist_manager::activeplaylist_execute_default_action(t_size p_item) { - t_size idx = get_active_playlist(); - if (idx == infinite) return false; - else return playlist_execute_default_action(idx,p_item); -} - -namespace { - class completion_notify_dfd : public completion_notify { - public: - completion_notify_dfd(const pfc::list_base_const_t & p_data,service_ptr_t p_notify) : m_data(p_data), m_notify(p_notify) {} - void on_completion(unsigned p_code) { - switch(p_code) { - case metadb_io::load_info_aborted: - m_notify->on_aborted(); - break; - default: - m_notify->on_completion(m_data); - break; - } - } - private: - metadb_handle_list m_data; - service_ptr_t m_notify; - }; -}; - -void dropped_files_data_impl::to_handles_async_ex(t_uint32 p_op_flags,HWND p_parentwnd,service_ptr_t p_notify) { - if (m_is_paths) { - static_api_ptr_t()->process_locations_async( - m_paths, - p_op_flags, - NULL, - NULL, - p_parentwnd, - p_notify); - } else { - t_uint32 flags = 0; - if (p_op_flags & playlist_incoming_item_filter_v2::op_flag_background) flags |= metadb_io_v2::op_flag_background; - if (p_op_flags & playlist_incoming_item_filter_v2::op_flag_delay_ui) flags |= metadb_io_v2::op_flag_delay_ui; - static_api_ptr_t()->load_info_async(m_handles,metadb_io::load_info_default,p_parentwnd,flags,new service_impl_t(m_handles,p_notify)); - } -} -void dropped_files_data_impl::to_handles_async(bool p_filter,HWND p_parentwnd,service_ptr_t p_notify) { - to_handles_async_ex(p_filter ? 0 : playlist_incoming_item_filter_v2::op_flag_no_filter,p_parentwnd,p_notify); -} - -bool dropped_files_data_impl::to_handles(pfc::list_base_t & p_out,bool p_filter,HWND p_parentwnd) { - if (m_is_paths) { - return static_api_ptr_t()->process_locations(m_paths,p_out,p_filter,NULL,NULL,p_parentwnd); - } else { - if (static_api_ptr_t()->load_info_multi(m_handles,metadb_io::load_info_default,p_parentwnd,true) == metadb_io::load_info_aborted) return false; - p_out = m_handles; - return true; - } -} - -void playlist_manager::playlist_activate_delta(int p_delta) { - const t_size total = get_playlist_count(); - if (total > 0) { - t_size active = get_active_playlist(); - - //clip p_delta to -(total-1)...(total-1) range - if (p_delta < 0) { - p_delta = - ( (-p_delta) % (t_ssize)total ); - } else { - p_delta = p_delta % total; - } - if (p_delta != 0) { - if (active == infinite) { - //special case when no playlist is active - if (p_delta > 0) { - active = (t_size)(p_delta - 1); - } else { - active = (total + p_delta);//p_delta is negative - } - } else { - active = (t_size) (active + total + p_delta) % total; - } - set_active_playlist(active % total); - } - } -} -namespace { - class enum_items_callback_get_selected_count : public playlist_manager::enum_items_callback { - public: - enum_items_callback_get_selected_count() : m_found() {} - t_size get_count() const {return m_found;} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) { - if (b_selected) m_found++; - return true; - } - private: - t_size m_found; - }; -} -t_size playlist_manager::playlist_get_selected_count(t_size p_playlist,bit_array const & p_mask) { - enum_items_callback_get_selected_count callback; - playlist_enum_items(p_playlist,callback,p_mask); - return callback.get_count(); -} - -namespace { - class enum_items_callback_find_item : public playlist_manager::enum_items_callback { - public: - enum_items_callback_find_item(metadb_handle_ptr p_lookingFor) : m_result(infinite), m_lookingFor(p_lookingFor) {} - t_size result() const {return m_result;} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) { - if (p_location == m_lookingFor) { - m_result = p_index; - return false; - } else { - return true; - } - } - private: - metadb_handle_ptr m_lookingFor; - t_size m_result; - }; - class enum_items_callback_find_item_selected : public playlist_manager::enum_items_callback { - public: - enum_items_callback_find_item_selected(metadb_handle_ptr p_lookingFor) : m_result(infinite), m_lookingFor(p_lookingFor) {} - t_size result() const {return m_result;} - bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) { - if (b_selected && p_location == m_lookingFor) { - m_result = p_index; - return false; - } else { - return true; - } - } - private: - metadb_handle_ptr m_lookingFor; - t_size m_result; - }; -} - -bool playlist_manager::playlist_find_item(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result) { - enum_items_callback_find_item callback(p_item); - playlist_enum_items(p_playlist,callback,bit_array_true()); - t_size result = callback.result(); - if (result == infinite) return false; - p_result = result; - return true; -} -bool playlist_manager::playlist_find_item_selected(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result) { - enum_items_callback_find_item_selected callback(p_item); - playlist_enum_items(p_playlist,callback,bit_array_true()); - t_size result = callback.result(); - if (result == infinite) return false; - p_result = result; - return true; -} -t_size playlist_manager::playlist_set_focus_by_handle(t_size p_playlist,metadb_handle_ptr p_item) { - t_size index; - if (!playlist_find_item(p_playlist,p_item,index)) index = infinite; - playlist_set_focus_item(p_playlist,index); - return index; -} -bool playlist_manager::activeplaylist_find_item(metadb_handle_ptr p_item,t_size & p_result) { - t_size playlist = get_active_playlist(); - if (playlist == infinite) return false; - return playlist_find_item(playlist,p_item,p_result); -} -t_size playlist_manager::activeplaylist_set_focus_by_handle(metadb_handle_ptr p_item) { - t_size playlist = get_active_playlist(); - if (playlist == infinite) return infinite; - return playlist_set_focus_by_handle(playlist,p_item); -} - -pfc::com_ptr_t playlist_incoming_item_filter::create_dataobject_ex(metadb_handle_list_cref data) { - pfc::com_ptr_t temp; temp.attach( create_dataobject(data) ); PFC_ASSERT( temp.is_valid() ); return temp; -} - -void playlist_manager_v3::recycler_restore_by_id(t_uint32 id) { - t_size which = recycler_find_by_id(id); - if (which != ~0) recycler_restore(which); -} - -t_size playlist_manager_v3::recycler_find_by_id(t_uint32 id) { - const t_size total = recycler_get_count(); - for(t_size walk = 0; walk < total; ++walk) { - if (id == recycler_get_id(walk)) return walk; - } - return ~0; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist.h b/tools/vio2sf/src/foobar/foobar2000/SDK/playlist.h deleted file mode 100644 index 1dc9a9e4c..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist.h +++ /dev/null @@ -1,873 +0,0 @@ -//! This interface allows filtering of playlist modification operations.\n -//! Implemented by components "locking" playlists; use playlist_manager::playlist_lock_install() etc to takeover specific playlist with your instance of playlist_lock. -class NOVTABLE playlist_lock : public service_base { -public: - enum { - filter_add = 1 << 0, - filter_remove = 1 << 1, - filter_reorder = 1 << 2, - filter_replace = 1 << 3, - filter_rename = 1 << 4, - filter_remove_playlist = 1 << 5, - filter_default_action = 1 << 6, - }; - - //! Queries whether specified item insertiion operation is allowed in the locked playlist. - //! @param p_base Index from which the items are being inserted. - //! @param p_data Items being inserted. - //! @param p_selection Caller-requested selection state of items being inserted. - //! @returns True to allow the operation, false to block it. - virtual bool query_items_add(t_size p_base, const pfc::list_base_const_t & p_data,const bit_array & p_selection) = 0; - //! Queries whether specified item reorder operation is allowed in the locked playlist. - //! @param p_order Pointer to array containing permutation defining requested reorder operation. - //! @param p_count Number of items in array pointed to by p_order. This should always be equal to number of items on the locked playlist. - //! @returns True to allow the operation, false to block it. - virtual bool query_items_reorder(const t_size * p_order,t_size p_count) = 0; - //! Queries whether specified item removal operation is allowed in the locked playlist. - //! @param p_mask Specifies which items from locked playlist are being removed. - //! @param p_force If set to true, the call is made only for notification purpose and items are getting removed regardless (after e.g. they have been physically removed). - //! @returns True to allow the operation, false to block it. Note that return value is ignored if p_force is set to true. - virtual bool query_items_remove(const bit_array & p_mask,bool p_force) = 0; - //! Queries whether specified item replacement operation is allowed in the locked playlist. - //! @param p_index Index of the item being replaced. - //! @param p_old Old value of the item being replaced. - //! @param p_new New value of the item being replaced. - //! @returns True to allow the operation, false to block it. - virtual bool query_item_replace(t_size p_index,const metadb_handle_ptr & p_old,const metadb_handle_ptr & p_new)=0; - //! Queries whether renaming the locked playlist is allowed. - //! @param p_new_name Requested new name of the playlist; a UTF-8 encoded string. - //! @param p_new_name_len Length limit of the name string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. - //! @returns True to allow the operation, false to block it. - virtual bool query_playlist_rename(const char * p_new_name,t_size p_new_name_len) = 0; - //! Queries whether removal of the locked playlist is allowed. Note that the lock will be released when the playlist is removed. - //! @returns True to allow the operation, false to block it. - virtual bool query_playlist_remove() = 0; - //! Executes "default action" (doubleclick etc) for specified playlist item. When the playlist is not locked, default action starts playback of the item. - //! @returns True if custom default action was executed, false to fall-through to default one for non-locked playlists (start playback). - virtual bool execute_default_action(t_size p_item) = 0; - //! Notifies lock about changed index of the playlist, in result of user reordering playlists or removing other playlists. - virtual void on_playlist_index_change(t_size p_new_index) = 0; - //! Notifies lock about the locked playlist getting removed. - virtual void on_playlist_remove() = 0; - //! Retrieves human-readable name of playlist lock to display. - virtual void get_lock_name(pfc::string_base & p_out) = 0; - //! Requests user interface of component controlling the playlist lock to be shown. - virtual void show_ui() = 0; - //! Queries which actions the lock filters. The return value must not change while the lock is registered with playlist_manager. The return value is a combination of one or more filter_* constants. - virtual t_uint32 get_filter_mask() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(playlist_lock,service_base); -}; - -struct t_playback_queue_item { - metadb_handle_ptr m_handle; - t_size m_playlist,m_item; - - bool operator==(const t_playback_queue_item & p_item) const; - bool operator!=(const t_playback_queue_item & p_item) const; -}; - - -//! This service provides methods for all sorts of playlist interaction.\n -//! All playlist_manager methods are valid only from main app thread.\n -//! Usage: static_api_ptr_t. -class NOVTABLE playlist_manager : public service_base -{ -public: - - //! Callback interface for playlist enumeration methods. - class NOVTABLE enum_items_callback { - public: - //! @returns True to continue enumeration, false to abort. - virtual bool on_item(t_size p_index,const metadb_handle_ptr & p_location,bool b_selected) = 0;//return false to stop - }; - - //! Retrieves number of playlists. - virtual t_size get_playlist_count() = 0; - //! Retrieves index of active playlist; infinite if no playlist is active. - virtual t_size get_active_playlist() = 0; - //! Sets active playlist (infinite to set no active playlist). - virtual void set_active_playlist(t_size p_index) = 0; - //! Retrieves playlist from which items to be played are taken from. - virtual t_size get_playing_playlist() = 0; - //! Sets playlist from which items to be played are taken from. - virtual void set_playing_playlist(t_size p_index) = 0; - //! Removes playlists according to specified mask. See also: bit_array. - virtual bool remove_playlists(const bit_array & p_mask) = 0; - //! Creates a new playlist. - //! @param p_name Name of playlist to create; a UTF-8 encoded string. - //! @param p_name_length Length limit of playlist name string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. - //! @param p_index Index at which to insert new playlist; set to infinite to put it at the end of playlist list. - //! @returns Actual index of newly inserted playlist, infinite on failure (call from invalid context). - virtual t_size create_playlist(const char * p_name,t_size p_name_length,t_size p_index) = 0; - //! Reorders the playlist list according to specified permutation. - //! @returns True on success, false on failure (call from invalid context). - virtual bool reorder(const t_size * p_order,t_size p_count) = 0; - - - //! Retrieves number of items on specified playlist. - virtual t_size playlist_get_item_count(t_size p_playlist) = 0; - //! Enumerates contents of specified playlist. - virtual void playlist_enum_items(t_size p_playlist,enum_items_callback & p_callback,const bit_array & p_mask) = 0; - //! Retrieves index of focus item on specified playlist; returns infinite when no item has focus. - virtual t_size playlist_get_focus_item(t_size p_playlist) = 0; - //! Retrieves name of specified playlist. Should never fail unless the parameters are invalid. - virtual bool playlist_get_name(t_size p_playlist,pfc::string_base & p_out) = 0; - - //! Reorders items in specified playlist according to specified permutation. - virtual bool playlist_reorder_items(t_size p_playlist,const t_size * p_order,t_size p_count) = 0; - //! Selects/deselects items on specified playlist. - //! @param p_playlist Index of playlist to alter. - //! @param p_affected Mask of items to alter. - //! @param p_status Mask of selected/deselected state to apply to items specified by p_affected. - virtual void playlist_set_selection(t_size p_playlist,const bit_array & p_affected,const bit_array & p_status) = 0; - //! Removes specified items from specified playlist. Returns true on success or false on failure (playlist locked). - virtual bool playlist_remove_items(t_size p_playlist,const bit_array & mask)=0; - //! Replaces specified item on specified playlist. Returns true on success or false on failure (playlist locked). - virtual bool playlist_replace_item(t_size p_playlist,t_size p_item,const metadb_handle_ptr & p_new_item) = 0; - //! Sets index of focus item on specified playlist; use infinite to set no focus item. - virtual void playlist_set_focus_item(t_size p_playlist,t_size p_item) = 0; - //! Inserts new items into specified playlist, at specified position. - virtual t_size playlist_insert_items(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & data,const bit_array & p_selection) = 0; - //! Tells playlist renderers to make sure that specified item is visible. - virtual void playlist_ensure_visible(t_size p_playlist,t_size p_item) = 0; - //! Renames specified playlist. - //! @param p_name New name of playlist; a UTF-8 encoded string. - //! @param p_name_length Length limit of playlist name string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. - //! @returns True on success, false on failure (playlist locked). - virtual bool playlist_rename(t_size p_index,const char * p_name,t_size p_name_length) = 0; - - - //! Creates an undo restore point for specified playlist. - virtual void playlist_undo_backup(t_size p_playlist) = 0; - //! Reverts specified playlist to last undo restore point and generates a redo restore point. - //! @returns True on success, false on failure (playlist locked or no restore point available). - virtual bool playlist_undo_restore(t_size p_playlist) = 0; - //! Reverts specified playlist to next redo restore point and generates an undo restore point. - //! @returns True on success, false on failure (playlist locked or no restore point available). - virtual bool playlist_redo_restore(t_size p_playlist) = 0; - //! Returns whether an undo restore point is available for specified playlist. - virtual bool playlist_is_undo_available(t_size p_playlist) = 0; - //! Returns whether a redo restore point is available for specified playlist. - virtual bool playlist_is_redo_available(t_size p_playlist) = 0; - - //! Renders information about specified playlist item, using specified titleformatting script parameters. - //! @param p_playlist Index of playlist containing item being processed. - //! @param p_item Index of item being processed in the playlist containing it. - //! @param p_hook Titleformatting script hook to use; see titleformat_hook documentation for more info. Set to NULL when hook functionality is not needed. - //! @param p_out String object receiving results. - //! @param p_script Compiled titleformatting script to use; see titleformat_object cocumentation for more info. - //! @param p_filter Text filter to use; see titleformat_text_filter documentation for more info. Set to NULL when text filter functionality is not needed. - //! @param p_playback_info_level Level of playback related information requested. See playback_control::t_display_level documentation for more info. - virtual void playlist_item_format_title(t_size p_playlist,t_size p_item,titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,playback_control::t_display_level p_playback_info_level)=0; - - - //! Retrieves playlist position of currently playing item. - //! @param p_playlist Receives index of playlist containing currently playing item on success. - //! @param p_index Receives index of currently playing item in the playlist that contains it on success. - //! @returns True on success, false on failure (not playing or currently played item has been removed from the playlist it was on when starting). - virtual bool get_playing_item_location(t_size * p_playlist,t_size * p_index) = 0; - - //! Sorts specified playlist - entire playlist or selection only - by specified title formatting pattern, or randomizes the order. - //! @param p_playlist Index of playlist to alter. - //! @param p_pattern Title formatting pattern to sort by (an UTF-8 encoded null-termindated string). Set to NULL to randomize the order of items. - //! @param p_sel_only Set to false to sort/randomize whole playlist, or to true to sort/randomize only selection on the playlist. - //! @returns True on success, false on failure (playlist locked etc). - virtual bool playlist_sort_by_format(t_size p_playlist,const char * p_pattern,bool p_sel_only) = 0; - - //! For internal use only; p_items must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly. - virtual void on_files_deleted_sorted(const pfc::list_base_const_t & p_items) = 0; - //! For internal use only; p_from must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly. - virtual void on_files_moved_sorted(const pfc::list_base_const_t & p_from,const pfc::list_base_const_t & p_to) = 0; - - virtual bool playlist_lock_install(t_size p_playlist,const service_ptr_t & p_lock) = 0;//returns false when invalid playlist or already locked - virtual bool playlist_lock_uninstall(t_size p_playlist,const service_ptr_t & p_lock) = 0; - virtual bool playlist_lock_is_present(t_size p_playlist) = 0; - virtual bool playlist_lock_query_name(t_size p_playlist,pfc::string_base & p_out) = 0; - virtual bool playlist_lock_show_ui(t_size p_playlist) = 0; - virtual t_uint32 playlist_lock_get_filter_mask(t_size p_playlist) = 0; - - - //! Retrieves number of available playback order modes. - virtual t_size playback_order_get_count() = 0; - //! Retrieves name of specified playback order move. - //! @param p_index Index of playback order mode to query, from 0 to playback_order_get_count() return value - 1. - //! @returns Null-terminated UTF-8 encoded string containing name of the playback order mode. Returned pointer points to statically allocated string and can be safely stored without having to free it later. - virtual const char * playback_order_get_name(t_size p_index) = 0; - //! Retrieves GUID of specified playback order mode. Used for managing playback modes without relying on names. - //! @param p_index Index of playback order mode to query, from 0 to playback_order_get_count() return value - 1. - virtual GUID playback_order_get_guid(t_size p_index) = 0; - //! Retrieves index of active playback order mode. - virtual t_size playback_order_get_active() = 0; - //! Sets index of active playback order mode. - virtual void playback_order_set_active(t_size p_index) = 0; - - virtual void queue_remove_mask(bit_array const & p_mask) = 0; - virtual void queue_add_item_playlist(t_size p_playlist,t_size p_item) = 0; - virtual void queue_add_item(metadb_handle_ptr p_item) = 0; - virtual t_size queue_get_count() = 0; - virtual void queue_get_contents(pfc::list_base_t & p_out) = 0; - //! Returns index (0-based) on success, infinite on failure (item not in queue). - virtual t_size queue_find_index(t_playback_queue_item const & p_item) = 0; - - //! Registers a playlist callback; registered object receives notifications about any modifications of any of loaded playlists. - //! @param p_callback Callback interface to register. - //! @param p_flags Flags indicating which callback methods are requested. See playlist_callback::flag_* constants for more info. The main purpose of flags parameter is working set optimization by not calling methods that do nothing. - virtual void register_callback(class playlist_callback * p_callback,unsigned p_flags) = 0; - //! Registers a playlist callback; registered object receives notifications about any modifications of active playlist. - //! @param p_callback Callback interface to register. - //! @param p_flags Flags indicating which callback methods are requested. See playlist_callback_single::flag_* constants for more info. The main purpose of flags parameter is working set optimization by not calling methods that do nothing. - virtual void register_callback(class playlist_callback_single * p_callback,unsigned p_flags) = 0; - //! Unregisters a playlist callback (playlist_callback version). - virtual void unregister_callback(class playlist_callback * p_callback) = 0; - //! Unregisters a playlist callback (playlist_callback_single version). - virtual void unregister_callback(class playlist_callback_single * p_callback) = 0; - //! Modifies flags indicating which calback methods are requested (playlist_callback version). - virtual void modify_callback(class playlist_callback * p_callback,unsigned p_flags) = 0; - //! Modifies flags indicating which calback methods are requested (playlist_callback_single version). - virtual void modify_callback(class playlist_callback_single * p_callback,unsigned p_flags) = 0; - - //! Executes default doubleclick/enter action for specified item on specified playlist (starts playing the item unless overridden by a lock to do something else). - virtual bool playlist_execute_default_action(t_size p_playlist,t_size p_item) = 0; - - - //! Helper; removes all items from the playback queue. - void queue_flush() {queue_remove_mask(bit_array_true());} - //! Helper; returns whether there are items in the playback queue. - bool queue_is_active() {return queue_get_count() > 0;} - - //! Helper; highlights currently playing item; returns true on success or false on failure (not playing or currently played item has been removed from playlist since playback started). - bool highlight_playing_item(); - //! Helper; removes single playlist of specified index. - bool remove_playlist(t_size p_playlist); - //! Helper; removes single playlist of specified index, and switches to another playlist when possible. - bool remove_playlist_switch(t_size p_playlist); - - //! Helper; returns whether specified item on specified playlist is selected or not. - bool playlist_is_item_selected(t_size p_playlist,t_size p_item); - //! Helper; retrieves metadb_handle of the specified playlist item. Returns true on success, false on failure (invalid parameters). - bool playlist_get_item_handle(metadb_handle_ptr & p_out,t_size p_playlist,t_size p_item); - //! Helper; retrieves metadb_handle of the specified playlist item; throws pfc::exception_invalid_params() on failure. - metadb_handle_ptr playlist_get_item_handle(t_size playlist, t_size item); - - //! Moves selected items up/down in the playlist by specified offset. - //! @param p_playlist Index of playlist to alter. - //! @param p_delta Offset to move items by. Set it to a negative valuye to move up, or to a positive value to move down. - //! @returns True on success, false on failure (e.g. playlist locked). - bool playlist_move_selection(t_size p_playlist,int p_delta); - //! Retrieves selection map of specific playlist, using bit_array_var interface. - void playlist_get_selection_mask(t_size p_playlist,bit_array_var & out); - void playlist_get_items(t_size p_playlist,pfc::list_base_t & out,const bit_array & p_mask); - void playlist_get_all_items(t_size p_playlist,pfc::list_base_t & out); - void playlist_get_selected_items(t_size p_playlist,pfc::list_base_t & out); - - //! Clears contents of specified playlist (removes all items from it). - void playlist_clear(t_size p_playlist); - bool playlist_add_items(t_size playlist,const pfc::list_base_const_t & data,const bit_array & p_selection); - void playlist_clear_selection(t_size p_playlist); - void playlist_remove_selection(t_size p_playlist,bool p_crop = false); - - - //! Changes contents of the specified playlist to the specified items, trying to reuse existing playlist content as much as possible (preserving selection/focus/etc). Order of items in playlist not guaranteed to be the same as in the specified item list. - //! @returns true if the playlist has been altered, false if there was nothing to update. - bool playlist_update_content(t_size playlist, metadb_handle_list_cref content, bool bUndoBackup); - - //retrieving status - t_size activeplaylist_get_item_count(); - void activeplaylist_enum_items(enum_items_callback & p_callback,const bit_array & p_mask); - t_size activeplaylist_get_focus_item();//focus may be infinite if no item is focused - bool activeplaylist_get_name(pfc::string_base & p_out); - - //modifying playlist - bool activeplaylist_reorder_items(const t_size * order,t_size count); - void activeplaylist_set_selection(const bit_array & affected,const bit_array & status); - bool activeplaylist_remove_items(const bit_array & mask); - bool activeplaylist_replace_item(t_size p_item,const metadb_handle_ptr & p_new_item); - void activeplaylist_set_focus_item(t_size p_item); - t_size activeplaylist_insert_items(t_size p_base,const pfc::list_base_const_t & data,const bit_array & p_selection); - void activeplaylist_ensure_visible(t_size p_item); - bool activeplaylist_rename(const char * p_name,t_size p_name_len); - - void activeplaylist_undo_backup(); - bool activeplaylist_undo_restore(); - bool activeplaylist_redo_restore(); - - bool activeplaylist_is_item_selected(t_size p_item); - bool activeplaylist_get_item_handle(metadb_handle_ptr & item,t_size p_item); - metadb_handle_ptr activeplaylist_get_item_handle(t_size p_item); - void activeplaylist_move_selection(int p_delta); - void activeplaylist_get_selection_mask(bit_array_var & out); - void activeplaylist_get_items(pfc::list_base_t & out,const bit_array & p_mask); - void activeplaylist_get_all_items(pfc::list_base_t & out); - void activeplaylist_get_selected_items(pfc::list_base_t & out); - void activeplaylist_clear(); - - bool activeplaylist_add_items(const pfc::list_base_const_t & data,const bit_array & p_selection); - - bool playlist_insert_items_filter(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_data,bool p_select); - bool activeplaylist_insert_items_filter(t_size p_base,const pfc::list_base_const_t & p_data,bool p_select); - - //! \deprecated (since 0.9.3) Use playlist_incoming_item_filter_v2::process_locations_async whenever possible - bool playlist_insert_locations(t_size p_playlist,t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd); - //! \deprecated (since 0.9.3) Use playlist_incoming_item_filter_v2::process_locations_async whenever possible - bool activeplaylist_insert_locations(t_size p_base,const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd); - - bool playlist_add_items_filter(t_size p_playlist,const pfc::list_base_const_t & p_data,bool p_select); - bool activeplaylist_add_items_filter(const pfc::list_base_const_t & p_data,bool p_select); - - bool playlist_add_locations(t_size p_playlist,const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd); - bool activeplaylist_add_locations(const pfc::list_base_const_t & p_urls,bool p_select,HWND p_parentwnd); - - void reset_playing_playlist(); - - void activeplaylist_clear_selection(); - void activeplaylist_remove_selection(bool p_crop = false); - - void activeplaylist_item_format_title(t_size p_item,titleformat_hook * p_hook,pfc::string_base & out,const service_ptr_t & p_script,titleformat_text_filter * p_filter,play_control::t_display_level p_playback_info_level); - - void playlist_set_selection_single(t_size p_playlist,t_size p_item,bool p_state); - void activeplaylist_set_selection_single(t_size p_item,bool p_state); - - t_size playlist_get_selection_count(t_size p_playlist,t_size p_max); - t_size activeplaylist_get_selection_count(t_size p_max); - - bool playlist_get_focus_item_handle(metadb_handle_ptr & p_item,t_size p_playlist); - bool activeplaylist_get_focus_item_handle(metadb_handle_ptr & item); - - t_size find_playlist(const char * p_name,t_size p_name_length = ~0); - t_size find_or_create_playlist(const char * p_name,t_size p_name_length = ~0); - t_size find_or_create_playlist_unlocked(const char * p_name,t_size p_name_length = ~0); - - t_size create_playlist_autoname(t_size p_index = infinite); - - bool activeplaylist_sort_by_format(const char * spec,bool p_sel_only); - - t_uint32 activeplaylist_lock_get_filter_mask(); - bool activeplaylist_is_undo_available(); - bool activeplaylist_is_redo_available(); - - bool activeplaylist_execute_default_action(t_size p_item); - - void remove_items_from_all_playlists(const pfc::list_base_const_t & p_data); - - void active_playlist_fix(); - - bool get_all_items(pfc::list_base_t & out); - - void playlist_activate_delta(int p_delta); - void playlist_activate_next() {playlist_activate_delta(1);} - void playlist_activate_previous() {playlist_activate_delta(-1);} - - - t_size playlist_get_selected_count(t_size p_playlist,bit_array const & p_mask); - t_size activeplaylist_get_selected_count(bit_array const & p_mask) {return playlist_get_selected_count(get_active_playlist(),p_mask);} - - bool playlist_find_item(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist - bool playlist_find_item_selected(t_size p_playlist,metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist - t_size playlist_set_focus_by_handle(t_size p_playlist,metadb_handle_ptr p_item); - bool activeplaylist_find_item(metadb_handle_ptr p_item,t_size & p_result);//inefficient, walks entire playlist - t_size activeplaylist_set_focus_by_handle(metadb_handle_ptr p_item); - - static void g_make_selection_move_permutation(t_size * p_output,t_size p_count,const bit_array & p_selection,int p_delta); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_manager); -}; - -//! Extension of the playlist_manager service that manages playlist properties. -//! Playlist properties come in two flavors: persistent and runtime. -//! Persistent properties are blocks of binary that that will be preserved when the application is exited and restarted. -//! Runtime properties are service pointers that will be lost when the application exits. -//! \since 0.9.5 -class NOVTABLE playlist_manager_v2 : public playlist_manager { -public: - //! Write a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_stream stream that contains the data that will be associated with the property - //! \param p_abort abort_callback that will be used when reading from p_stream - virtual void playlist_set_property(t_size p_playlist,const GUID & p_property,stream_reader * p_stream,t_size p_size_hint,abort_callback & p_abort) = 0; - //! Read a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_stream stream that will receive the stored data - //! \param p_abort abort_callback that will be used when writing to p_stream - //! \return true if the property exists, false otherwise - virtual bool playlist_get_property(t_size p_playlist,const GUID & p_property,stream_writer * p_stream,abort_callback & p_abort) = 0; - //! Test existence of a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \return true if the property exists, false otherwise - virtual bool playlist_have_property(t_size p_playlist,const GUID & p_property) = 0; - //! Remove a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \return true if the property existed, false otherwise - virtual bool playlist_remove_property(t_size p_playlist,const GUID & p_property) = 0; - - //! Write a runtime playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_data service pointer that will be associated with the property - virtual void playlist_set_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t p_data) = 0; - //! Read a runtime playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_data base service pointer reference that will receive the stored servive pointer - //! \return true if the property exists, false otherwise - virtual bool playlist_get_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t & p_data) = 0; - //! Test existence of a runtime playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \return true if the property exists, false otherwise - virtual bool playlist_have_runtime_property(t_size p_playlist,const GUID & p_property) = 0; - //! Remove a runtime playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \return true if the property existed, false otherwise - virtual bool playlist_remove_runtime_property(t_size p_playlist,const GUID & p_property) = 0; - - //! Write a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_data array that contains the data that will be associated with the property - template void playlist_set_property(t_size p_playlist,const GUID & p_property,const t_array & p_data) { - pfc::static_assert(); - playlist_set_property(p_playlist,p_property,&stream_reader_memblock_ref(p_data),p_data.get_size(),abort_callback_impl()); - } - //! Read a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_data array that will receive the stored data - //! \return true if the property exists, false otherwise - template bool playlist_get_property(t_size p_playlist,const GUID & p_property,t_array & p_data) { - pfc::static_assert(); - typedef pfc::array_t t_temp; - t_temp temp; - if (!playlist_get_property(p_playlist,p_property,&stream_writer_buffer_append_ref_t(temp),abort_callback_impl())) return false; - p_data = temp; - return true; - } - //! Read a runtime playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_data specific service pointer reference that will receive the stored servive pointer - //! \return true if the property exists and can be converted to the type of p_data, false otherwise - template bool playlist_get_runtime_property(t_size p_playlist,const GUID & p_property,service_ptr_t<_t_interface> & p_data) { - service_ptr_t ptr; - if (!playlist_get_runtime_property(p_playlist,p_property,ptr)) return false; - return ptr->service_query_t(p_data); - } - - //! Write a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_value integer that will be associated with the property - template - void playlist_set_property_int(t_size p_playlist,const GUID & p_property,_t_int p_value) { - pfc::array_t temp; temp.set_size(sizeof(_t_int)); - pfc::encode_little_endian(temp.get_ptr(),p_value); - playlist_set_property(p_playlist,p_property,temp); - } - //! Read a persistent playlist property. - //! \param p_playlist Index of the playlist - //! \param p_property GUID that identifies the property - //! \param p_value integer reference that will receive the stored data - //! \return true if the property exists and if the data is compatible with p_value, false otherwise - template - bool playlist_get_property_int(t_size p_playlist,const GUID & p_property,_t_int & p_value) { - pfc::array_t temp; - if (!playlist_get_property(p_playlist,p_property,temp)) return false; - if (temp.get_size() != sizeof(_t_int)) return false; - pfc::decode_little_endian(p_value,temp.get_ptr()); - return true; - } - - FB2K_MAKE_SERVICE_INTERFACE(playlist_manager_v2,playlist_manager) -}; - -//! \since 0.9.5 -class NOVTABLE playlist_manager_v3 : public playlist_manager_v2 { - FB2K_MAKE_SERVICE_INTERFACE(playlist_manager_v3,playlist_manager_v2) -public: - virtual t_size recycler_get_count() = 0; - virtual void recycler_get_content(t_size which, metadb_handle_list_ref out) = 0; - virtual void recycler_get_name(t_size which, pfc::string_base & out) = 0; - virtual t_uint32 recycler_get_id(t_size which) = 0; - virtual void recycler_purge(const bit_array & mask) = 0; - virtual void recycler_restore(t_size which) = 0; - - void recycler_restore_by_id(t_uint32 id); - t_size recycler_find_by_id(t_uint32 id); -}; - -//! \since 0.9.5.4 -class NOVTABLE playlist_manager_v4 : public playlist_manager_v3 { - FB2K_MAKE_SERVICE_INTERFACE(playlist_manager_v4, playlist_manager_v3) -public: - virtual void playlist_get_sideinfo(t_size which, stream_writer * stream, abort_callback & abort) = 0; - virtual t_size create_playlist_ex(const char * p_name,t_size p_name_length,t_size p_index, metadb_handle_list_cref content, stream_reader * sideInfo, abort_callback & abort) = 0; -}; - -class NOVTABLE playlist_callback -{ -public: - virtual void on_items_added(t_size p_playlist,t_size p_start, const pfc::list_base_const_t & p_data,const bit_array & p_selection)=0;//inside any of these methods, you can call playlist APIs to get exact info about what happened (but only methods that read playlist state, not those that modify it) - virtual void on_items_reordered(t_size p_playlist,const t_size * p_order,t_size p_count)=0;//changes selection too; doesnt actually change set of items that are selected or item having focus, just changes their order - virtual void on_items_removing(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0;//called before actually removing them - virtual void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0; - virtual void on_items_selection_change(t_size p_playlist,const bit_array & p_affected,const bit_array & p_state) = 0; - virtual void on_item_focus_change(t_size p_playlist,t_size p_from,t_size p_to)=0;//focus may be -1 when no item has focus; reminder: focus may also change on other callbacks - - virtual void on_items_modified(t_size p_playlist,const bit_array & p_mask)=0; - virtual void on_items_modified_fromplayback(t_size p_playlist,const bit_array & p_mask,play_control::t_display_level p_level)=0; - - struct t_on_items_replaced_entry - { - t_size m_index; - metadb_handle_ptr m_old,m_new; - }; - - virtual void on_items_replaced(t_size p_playlist,const bit_array & p_mask,const pfc::list_base_const_t & p_data)=0; - - virtual void on_item_ensure_visible(t_size p_playlist,t_size p_idx)=0; - - virtual void on_playlist_activate(t_size p_old,t_size p_new) = 0; - virtual void on_playlist_created(t_size p_index,const char * p_name,t_size p_name_len) = 0; - virtual void on_playlists_reorder(const t_size * p_order,t_size p_count) = 0; - virtual void on_playlists_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) = 0; - virtual void on_playlists_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) = 0; - virtual void on_playlist_renamed(t_size p_index,const char * p_new_name,t_size p_new_name_len) = 0; - - virtual void on_default_format_changed() = 0; - virtual void on_playback_order_changed(t_size p_new_index) = 0; - virtual void on_playlist_locked(t_size p_playlist,bool p_locked) = 0; - - enum { - flag_on_items_added = 1 << 0, - flag_on_items_reordered = 1 << 1, - flag_on_items_removing = 1 << 2, - flag_on_items_removed = 1 << 3, - flag_on_items_selection_change = 1 << 4, - flag_on_item_focus_change = 1 << 5, - flag_on_items_modified = 1 << 6, - flag_on_items_modified_fromplayback = 1 << 7, - flag_on_items_replaced = 1 << 8, - flag_on_item_ensure_visible = 1 << 9, - flag_on_playlist_activate = 1 << 10, - flag_on_playlist_created = 1 << 11, - flag_on_playlists_reorder = 1 << 12, - flag_on_playlists_removing = 1 << 13, - flag_on_playlists_removed = 1 << 14, - flag_on_playlist_renamed = 1 << 15, - flag_on_default_format_changed = 1 << 16, - flag_on_playback_order_changed = 1 << 17, - flag_on_playlist_locked = 1 << 18, - - flag_all = ~0, - flag_item_ops = flag_on_items_added | flag_on_items_reordered | flag_on_items_removing | flag_on_items_removed | flag_on_items_selection_change | flag_on_item_focus_change | flag_on_items_modified | flag_on_items_modified_fromplayback | flag_on_items_replaced | flag_on_item_ensure_visible, - flag_playlist_ops = flag_on_playlist_activate | flag_on_playlist_created | flag_on_playlists_reorder | flag_on_playlists_removing | flag_on_playlists_removed | flag_on_playlist_renamed | flag_on_playlist_locked, - }; -protected: - playlist_callback() {} - ~playlist_callback() {} -}; - -class NOVTABLE playlist_callback_static : public service_base, public playlist_callback -{ -public: - virtual unsigned get_flags() = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_callback_static); -}; - -class NOVTABLE playlist_callback_single -{ -public: - virtual void on_items_added(t_size p_base, const pfc::list_base_const_t & p_data,const bit_array & p_selection)=0;//inside any of these methods, you can call playlist APIs to get exact info about what happened (but only methods that read playlist state, not those that modify it) - virtual void on_items_reordered(const t_size * p_order,t_size p_count)=0;//changes selection too; doesnt actually change set of items that are selected or item having focus, just changes their order - virtual void on_items_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0;//called before actually removing them - virtual void on_items_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count)=0; - virtual void on_items_selection_change(const bit_array & p_affected,const bit_array & p_state) = 0; - virtual void on_item_focus_change(t_size p_from,t_size p_to)=0;//focus may be -1 when no item has focus; reminder: focus may also change on other callbacks - virtual void on_items_modified(const bit_array & p_mask)=0; - virtual void on_items_modified_fromplayback(const bit_array & p_mask,play_control::t_display_level p_level)=0; - virtual void on_items_replaced(const bit_array & p_mask,const pfc::list_base_const_t & p_data)=0; - virtual void on_item_ensure_visible(t_size p_idx)=0; - - virtual void on_playlist_switch() = 0; - virtual void on_playlist_renamed(const char * p_new_name,t_size p_new_name_len) = 0; - virtual void on_playlist_locked(bool p_locked) = 0; - - virtual void on_default_format_changed() = 0; - virtual void on_playback_order_changed(t_size p_new_index) = 0; - - enum { - flag_on_items_added = 1 << 0, - flag_on_items_reordered = 1 << 1, - flag_on_items_removing = 1 << 2, - flag_on_items_removed = 1 << 3, - flag_on_items_selection_change = 1 << 4, - flag_on_item_focus_change = 1 << 5, - flag_on_items_modified = 1 << 6, - flag_on_items_modified_fromplayback = 1 << 7, - flag_on_items_replaced = 1 << 8, - flag_on_item_ensure_visible = 1 << 9, - flag_on_playlist_switch = 1 << 10, - flag_on_playlist_renamed = 1 << 11, - flag_on_playlist_locked = 1 << 12, - flag_on_default_format_changed = 1 << 13, - flag_on_playback_order_changed = 1 << 14, - flag_all = ~0, - }; -protected: - playlist_callback_single() {} - ~playlist_callback_single() {} -}; - -//! playlist_callback implementation helper - registers itself on creation / unregisters on destruction. Must not be instantiated statically! -class playlist_callback_impl_base : public playlist_callback { -public: - playlist_callback_impl_base(t_uint32 p_flags = 0) { - static_api_ptr_t()->register_callback(this,p_flags); - } - ~playlist_callback_impl_base() { - static_api_ptr_t()->unregister_callback(this); - } - void set_callback_flags(t_uint32 p_flags) { - static_api_ptr_t()->modify_callback(this,p_flags); - } - //dummy implementations - avoid possible pure virtual function calls! - void on_items_added(t_size p_playlist,t_size p_start, const pfc::list_base_const_t & p_data,const bit_array & p_selection) {} - void on_items_reordered(t_size p_playlist,const t_size * p_order,t_size p_count) {} - void on_items_removing(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count) {} - void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count) {} - void on_items_selection_change(t_size p_playlist,const bit_array & p_affected,const bit_array & p_state) {} - void on_item_focus_change(t_size p_playlist,t_size p_from,t_size p_to) {} - - void on_items_modified(t_size p_playlist,const bit_array & p_mask) {} - void on_items_modified_fromplayback(t_size p_playlist,const bit_array & p_mask,play_control::t_display_level p_level) {} - - void on_items_replaced(t_size p_playlist,const bit_array & p_mask,const pfc::list_base_const_t & p_data) {} - - void on_item_ensure_visible(t_size p_playlist,t_size p_idx) {} - - void on_playlist_activate(t_size p_old,t_size p_new) {} - void on_playlist_created(t_size p_index,const char * p_name,t_size p_name_len) {} - void on_playlists_reorder(const t_size * p_order,t_size p_count) {} - void on_playlists_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) {} - void on_playlists_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) {} - void on_playlist_renamed(t_size p_index,const char * p_new_name,t_size p_new_name_len) {} - - void on_default_format_changed() {} - void on_playback_order_changed(t_size p_new_index) {} - void on_playlist_locked(t_size p_playlist,bool p_locked) {} -}; - -//! playlist_callback_single implementation helper - registers itself on creation / unregisters on destruction. Must not be instantiated statically! -class playlist_callback_single_impl_base : public playlist_callback_single { -protected: - playlist_callback_single_impl_base(t_uint32 p_flags = 0) { - static_api_ptr_t()->register_callback(this,p_flags); - } - void set_callback_flags(t_uint32 p_flags) { - static_api_ptr_t()->modify_callback(this,p_flags); - } - ~playlist_callback_single_impl_base() { - static_api_ptr_t()->unregister_callback(this); - } - - //dummy implementations - avoid possible pure virtual function calls! - void on_items_added(t_size p_base, const pfc::list_base_const_t & p_data,const bit_array & p_selection) {} - void on_items_reordered(const t_size * p_order,t_size p_count) {} - void on_items_removing(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) {} - void on_items_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) {} - void on_items_selection_change(const bit_array & p_affected,const bit_array & p_state) {} - void on_item_focus_change(t_size p_from,t_size p_to) {} - void on_items_modified(const bit_array & p_mask) {} - void on_items_modified_fromplayback(const bit_array & p_mask,play_control::t_display_level p_level) {} - void on_items_replaced(const bit_array & p_mask,const pfc::list_base_const_t & p_data) {} - void on_item_ensure_visible(t_size p_idx) {} - - void on_playlist_switch() {} - void on_playlist_renamed(const char * p_new_name,t_size p_new_name_len) {} - void on_playlist_locked(bool p_locked) {} - - void on_default_format_changed() {} - void on_playback_order_changed(t_size p_new_index) {} - - PFC_CLASS_NOT_COPYABLE(playlist_callback_single_impl_base,playlist_callback_single_impl_base); -}; - -class playlist_callback_single_static : public service_base, public playlist_callback_single -{ -public: - virtual unsigned get_flags() = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_callback_single_static); -}; - - -//! Class used for async processing of IDataObject. Content of IDataObject can be dumped into dropped_files_data without any time-consuming operations - won't block calling app when used inside drag&drop handler - and actual time-consuming processing (listing directories and reading infos) can be done later.\n -//! \deprecated In 0.9.3 and up, instead of going thru dropped_files_data, you can use playlist_incoming_item_filter_v2::process_dropped_files_async(). -class NOVTABLE dropped_files_data { -public: - virtual void set_paths(pfc::string_list_const const & p_paths) = 0; - virtual void set_handles(const pfc::list_base_const_t & p_handles) = 0; -protected: - dropped_files_data() {} - ~dropped_files_data() {} -}; - - -class NOVTABLE playlist_incoming_item_filter : public service_base { -public: - //! Pre-sorts incoming items according to user-configured settings, removes duplicates. \n - //! @param in Items to process. - //! @param out Receives processed item list. \n - //! NOTE: because of an implementation bug in pre-0.9.5, the output list should be emptied before calling filter_items(), otherwise the results will be inconsistent/unpredictable. - //! @returns True when there's one or more item in the output list, false when the output list is empty. - virtual bool filter_items(metadb_handle_list_cref in,metadb_handle_list_ref out) = 0; - - //! Converts one or more paths to a list of metadb_handles; displays a progress dialog.\n - //! Note that this function creates modal dialog and does not return until the operation has completed. - //! @returns True on success, false on user abort. - //! \deprecated Use playlist_incoming_item_filter_v2::process_locations_async() when possible. - virtual bool process_locations(const pfc::list_base_const_t & p_urls,pfc::list_base_t & p_out,bool p_filter,const char * p_restrict_mask_override, const char * p_exclude_mask_override,HWND p_parentwnd) = 0; - - //! Converts an IDataObject to a list of metadb_handles. - //! Using this function is strongly disrecommended as it implies blocking the drag&drop source app (as well as our app).\n - //! @returns True on success, false on user abort or unknown data format. - //! \deprecated Use playlist_incoming_item_filter_v2::process_dropped_files_async() when possible. - virtual bool process_dropped_files(interface IDataObject * pDataObject,pfc::list_base_t & p_out,bool p_filter,HWND p_parentwnd) = 0; - - //! Checks whether IDataObject contains one of known data formats that can be translated to a list of metadb_handles. - virtual bool process_dropped_files_check(interface IDataObject * pDataObject) = 0; - - //! Checks whether IDataObject contains our own private data format (drag&drop within the app etc). - virtual bool process_dropped_files_check_if_native(interface IDataObject * pDataObject) = 0; - - //! Creates an IDataObject from specified metadb_handle list. The caller is responsible for releasing the returned object. It is recommended that you use create_dataobject_ex() to get an autopointer that ensures proper deletion. - virtual interface IDataObject * create_dataobject(const pfc::list_base_const_t & p_data) = 0; - - //! Checks whether IDataObject contains one of known data formats that can be translated to a list of metadb_handles.\n - //! This function also returns drop effects to use (see: IDropTarget::DragEnter(), IDropTarget::DragOver() ). In certain cases, drag effects are necessary for drag&drop to work at all (such as dragging links from IE).\n - virtual bool process_dropped_files_check_ex(interface IDataObject * pDataObject, DWORD * p_effect) = 0; - - //! Dumps IDataObject content to specified dropped_files_data object, without any time-consuming processing.\n - //! Using this function instead of process_dropped_files() and processing dropped_files_data outside drop handler allows you to avoid blocking drop source app when processing large directories etc.\n - //! Note: since 0.9.3, it is recommended to use playlist_incoming_item_filter_v2::process_dropped_files_async() instead. - //! @returns True on success, false when IDataObject does not contain any of known data formats. - virtual bool process_dropped_files_delayed(dropped_files_data & p_out,interface IDataObject * pDataObject) = 0; - - //! Helper - calls process_locations() with a single URL. See process_locations() for more info. - bool process_location(const char * url,pfc::list_base_t & out,bool filter,const char * p_mask,const char * p_exclude,HWND p_parentwnd); - //! Helper - returns a pfc::com_ptr_t<> rather than a raw pointer. - pfc::com_ptr_t create_dataobject_ex(metadb_handle_list_cref data); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_incoming_item_filter); -}; - -//! For use with playlist_incoming_item_filter_v2::process_locations_async(). -//! \since 0.9.3 -class NOVTABLE process_locations_notify : public service_base { -public: - virtual void on_completion(const pfc::list_base_const_t & p_items) = 0; - virtual void on_aborted() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(process_locations_notify,service_base); -}; - -typedef service_ptr_t process_locations_notify_ptr; - -//! \since 0.9.3 -class NOVTABLE playlist_incoming_item_filter_v2 : public playlist_incoming_item_filter { -public: - enum { - //! Set this to disable presorting (according to user settings) and duplicate removal in output list. Should be unset in most cases. - op_flag_no_filter = 1 << 0, - //! Set this flag to make the progress dialog not steal focus on creation. - op_flag_background = 1 << 1, - //! Set this flag to delay the progress dialog becoming visible, so it does not appear at all during short operations. Also implies op_flag_background effect. - op_flag_delay_ui = 1 << 2, - }; - - //! Converts one or more paths to a list of metadb_handles. The function returns immediately; specified callback object receives results when the operation has completed. - //! @param p_urls List of paths to process. - //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. - //! @param p_restrict_mask_override Override of "restrict incoming items to" setting. Pass NULL to use the value from preferences. - //! @param p_exclude_mask_override Override of "exclude file types" setting. Pass NULL to use value from preferences. - //! @param p_parentwnd Parent window for spawned progress dialogs. - //! @param p_notify Callback receiving notifications about success/abort of the operation as well as output item list. - virtual void process_locations_async(const pfc::list_base_const_t & p_urls,t_uint32 p_op_flags,const char * p_restrict_mask_override, const char * p_exclude_mask_override,HWND p_parentwnd,process_locations_notify_ptr p_notify) = 0; - - //! Converts an IDataObject to a list of metadb_handles. The function returns immediately; specified callback object receives results when the operation has completed. - //! @param p_dataobject IDataObject to process. - //! @param p_op_flags Can be null, or one or more of op_flag_* enum values combined, altering behaviors of the operation. - //! @param p_parentwnd Parent window for spawned progress dialogs. - //! @param p_notify Callback receiving notifications about success/abort of the operation as well as output item list. - virtual void process_dropped_files_async(interface IDataObject * p_dataobject,t_uint32 p_op_flags,HWND p_parentwnd,process_locations_notify_ptr p_notify) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(playlist_incoming_item_filter_v2,playlist_incoming_item_filter); -}; - -//! \since 0.9.5 -class playlist_incoming_item_filter_v3 : public playlist_incoming_item_filter_v2 { -public: - virtual bool auto_playlist_name(metadb_handle_list_cref data,pfc::string_base & out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(playlist_incoming_item_filter_v3,playlist_incoming_item_filter_v2) -}; - -//! Implementation of dropped_files_data. -class dropped_files_data_impl : public dropped_files_data { -public: - dropped_files_data_impl() : m_is_paths(false) {} - void set_paths(pfc::string_list_const const & p_paths) { - m_is_paths = true; - m_paths = p_paths; - } - void set_handles(const pfc::list_base_const_t & p_handles) { - m_is_paths = false; - m_handles = p_handles; - } - - void to_handles_async(bool p_filter,HWND p_parentwnd,service_ptr_t p_notify); - //! @param p_op_flags Can be null, or one or more of playlist_incoming_item_filter_v2::op_flag_* enum values combined, altering behaviors of the operation. - void to_handles_async_ex(t_uint32 p_op_flags,HWND p_parentwnd,service_ptr_t p_notify); - bool to_handles(pfc::list_base_t & p_out,bool p_filter,HWND p_parentwnd); -private: - pfc::string_list_impl m_paths; - metadb_handle_list m_handles; - bool m_is_paths; -}; - - -class NOVTABLE playback_queue_callback : public service_base -{ -public: - enum t_change_origin { - changed_user_added, - changed_user_removed, - changed_playback_advance, - }; - virtual void on_changed(t_change_origin p_origin) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playback_queue_callback); -}; - - -class playlist_lock_change_notify : private playlist_callback_single_impl_base { -public: - playlist_lock_change_notify() : playlist_callback_single_impl_base(flag_on_playlist_switch|flag_on_playlist_locked) {} -protected: - virtual void on_lock_state_change() {} - bool is_playlist_command_available(t_uint32 what) const { - static_api_ptr_t api; - const t_size active = api->get_active_playlist(); - if (active == ~0) return false; - return (api->playlist_lock_get_filter_mask(active) & what) == 0; - } -private: - void on_playlist_switch() {on_lock_state_change();} - void on_playlist_locked(bool p_locked) {on_lock_state_change();} -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist_loader.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/playlist_loader.cpp deleted file mode 100644 index fe5f09d61..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist_loader.cpp +++ /dev/null @@ -1,270 +0,0 @@ -#include "foobar2000.h" - -static void process_path_internal(const char * p_path,const service_ptr_t & p_reader,playlist_loader_callback_v2 & callback,playlist_loader_callback::t_entry_type type,const t_filestats & p_stats); - -namespace { - class archive_callback_impl : public archive_callback - { - public: - archive_callback_impl(playlist_loader_callback_v2 & p_callback) : m_callback(p_callback) {} - bool on_entry(archive * owner,const char * p_path,const t_filestats & p_stats,const service_ptr_t & p_reader) - { - process_path_internal(p_path,p_reader,m_callback,playlist_loader_callback::entry_directory_enumerated,p_stats); - return !m_callback.is_aborting(); - } - bool is_aborting() const {return m_callback.is_aborting();} - abort_callback_event get_abort_event() const {return m_callback.get_abort_event();} - private: - playlist_loader_callback_v2 & m_callback; - }; -} - -void playlist_loader::g_load_playlist_filehint(file::ptr fileHint,const char * p_path,playlist_loader_callback & p_callback) { - TRACK_CALL_TEXT("playlist_loader::g_load_playlist_filehint"); - pfc::string8 filepath; - - filesystem::g_get_canonical_path(p_path,filepath); - - pfc::string_extension extension(filepath); - - service_ptr_t l_file = fileHint; - - if (l_file.is_empty()) { - filesystem::ptr fs; - if (filesystem::g_get_interface(fs,filepath)) { - if (fs->supports_content_types()) { - fs->open(l_file,filepath,filesystem::open_mode_read,p_callback); - } - } - } - - { - service_enum_t e; - - if (l_file.is_valid()) { - pfc::string8 content_type; - if (l_file->get_content_type(content_type)) { - service_ptr_t l; - e.reset(); while(e.next(l)) { - if (l->is_our_content_type(content_type)) { - try { - TRACK_CODE("playlist_loader::open",l->open(filepath,l_file,p_callback)); - return; - } catch(exception_io_unsupported_format) { - l_file->reopen(p_callback); - } - } - } - } - } - - if (extension.length()>0) { - service_ptr_t l; - e.reset(); while(e.next(l)) { - if (stricmp_utf8(l->get_extension(),extension) == 0) { - if (l_file.is_empty()) filesystem::g_open_read(l_file,filepath,p_callback); - try { - TRACK_CODE("playlist_loader::open",l->open(filepath,l_file,p_callback)); - return; - } catch(exception_io_unsupported_format) { - l_file->reopen(p_callback); - } - } - } - } - } - - throw exception_io_unsupported_format(); -} -void playlist_loader::g_load_playlist(const char * p_path,playlist_loader_callback & callback) { - g_load_playlist_filehint(NULL,p_path,callback); -} - -static void index_tracks_helper(const char * p_path,const service_ptr_t & p_reader,const t_filestats & p_stats,playlist_loader_callback::t_entry_type p_type,playlist_loader_callback & p_callback,bool & p_got_input) -{ - TRACK_CALL_TEXT("index_tracks_helper"); - if (p_reader.is_empty() && filesystem::g_is_remote_safe(p_path)) - { - TRACK_CALL_TEXT("remote"); - metadb_handle_ptr handle; - p_callback.handle_create(handle,make_playable_location(p_path,0)); - p_got_input = true; - p_callback.on_entry(handle,p_type,p_stats,true); - } else { - TRACK_CALL_TEXT("hintable"); - service_ptr_t instance; - input_entry::g_open_for_info_read(instance,p_reader,p_path,p_callback); - - t_filestats stats = instance->get_file_stats(p_callback); - - t_uint32 subsong,subsong_count = instance->get_subsong_count(); - for(subsong=0;subsongget_subsong(subsong); - p_callback.handle_create(handle,make_playable_location(p_path,index)); - - p_got_input = true; - if (p_callback.want_info(handle,p_type,stats,true)) - { - file_info_impl info; - TRACK_CODE("get_info",instance->get_info(index,info,p_callback)); - p_callback.on_entry_info(handle,p_type,stats,info,true); - } - else - { - p_callback.on_entry(handle,p_type,stats,true); - } - } - } -} - - -static void track_indexer__g_get_tracks_wrap(const char * p_path,const service_ptr_t & p_reader,const t_filestats & p_stats,playlist_loader_callback::t_entry_type p_type,playlist_loader_callback & p_callback) { - bool got_input = false; - bool fail = false; - try { - index_tracks_helper(p_path,p_reader,p_stats,p_type,p_callback,got_input); - } catch(exception_aborted) { - throw; - } catch(exception_io_unsupported_format) { - fail = true; - } catch(std::exception const & e) { - fail = true; - console::formatter() << "could not enumerate tracks (" << e << ") on:\n" << file_path_display(p_path); - } - if (fail) { - if (!got_input && !p_callback.is_aborting()) { - if (p_type == playlist_loader_callback::entry_user_requested) - { - metadb_handle_ptr handle; - p_callback.handle_create(handle,make_playable_location(p_path,0)); - p_callback.on_entry(handle,p_type,p_stats,true); - } - } - } -} - - -static void process_path_internal(const char * p_path,const service_ptr_t & p_reader,playlist_loader_callback_v2 & p_callback,playlist_loader_callback::t_entry_type p_type,const t_filestats & p_stats) -{ - //p_path must be canonical - - p_callback.check(); - - p_callback.on_progress(p_path); - - - { - if (p_reader.is_empty()) { - directory_callback_impl directory_results(true); - try { - filesystem::g_list_directory(p_path,directory_results,p_callback); - for(t_size n=0;n e; - service_ptr_t f; - while(e.next(f)) { - p_callback.check(); - service_ptr_t arch; - if (f->service_query_t(arch)) { - if (p_reader.is_valid()) p_reader->reopen(p_callback); - - try { - TRACK_CODE("archive::archive_list",arch->archive_list(p_path,p_reader,archive_results,true)); - return; - } catch(exception_aborted) {throw;} - catch(...) {} - } - } - } - } - - - - { - service_ptr_t ptr; - if (link_resolver::g_find(ptr,p_path)) - { - if (p_reader.is_valid()) p_reader->reopen(p_callback); - - pfc::string8 temp; - try { - TRACK_CODE("link_resolver::resolve",ptr->resolve(p_reader,p_path,temp,p_callback)); - - track_indexer__g_get_tracks_wrap(temp,0,filestats_invalid,playlist_loader_callback::entry_from_playlist,p_callback); - return;//success - } catch(exception_aborted) {throw;} - catch(...) {} - } - } - - if (p_callback.is_path_wanted(p_path,p_type)) { - track_indexer__g_get_tracks_wrap(p_path,p_reader,p_stats,p_type,p_callback); - } -} - -void playlist_loader::g_process_path(const char * p_filename,playlist_loader_callback_v2 & callback,playlist_loader_callback::t_entry_type type) -{ - TRACK_CALL_TEXT("playlist_loader::g_process_path"); - - file_path_canonical filename(p_filename); - - process_path_internal(filename,0,callback,type,filestats_invalid); -} - -void playlist_loader::g_save_playlist(const char * p_filename,const pfc::list_base_const_t & data,abort_callback & p_abort) -{ - TRACK_CALL_TEXT("playlist_loader::g_save_playlist"); - pfc::string8 filename; - filesystem::g_get_canonical_path(p_filename,filename); - try { - service_ptr_t r; - filesystem::g_open(r,filename,filesystem::open_mode_write_new,p_abort); - - pfc::string_extension ext(filename); - - service_enum_t e; - service_ptr_t l; - if (e.first(l)) do { - if (l->can_write() && !stricmp_utf8(ext,l->get_extension())) { - try { - TRACK_CODE("playlist_loader::write",l->write(filename,r,data,p_abort)); - return; - } catch(exception_io_data) {} - } - } while(e.next(l)); - throw exception_io_data(); - } catch(...) { - try {filesystem::g_remove(filename,p_abort);} catch(...) {} - throw; - } -} - - -bool playlist_loader::g_process_path_ex(const char * filename,playlist_loader_callback_v2 & callback,playlist_loader_callback::t_entry_type type) -{ - try { - g_load_playlist(filename,callback); - return true; - } catch(exception_io_unsupported_format) {//not a playlist format - g_process_path(filename,callback,type); - return false; - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist_loader.h b/tools/vio2sf/src/foobar/foobar2000/SDK/playlist_loader.h deleted file mode 100644 index 604b343e5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/playlist_loader.h +++ /dev/null @@ -1,151 +0,0 @@ -//! Callback interface receiving item locations from playlist loader. Also inherits abort_callback methods and can be passed to functions that require an abort_callback. \n -//! See playlist_loader_callback_impl for a basic implementation of playlist_loader_callback. Typically, you call one of standard services such as playlist_incoming_item_filter instead of implementing this interface and calling playlist_loader methods directly. -class NOVTABLE playlist_loader_callback : public abort_callback { -public: - //! Enumeration type representing origin of item passed to playlist_loader_callback. - enum t_entry_type { - //! User-requested (such as directly dropped to window or picked in openfiledialog). - entry_user_requested, - //! From directory content enumeration. - entry_directory_enumerated, - //! Referenced by playlist file. - entry_from_playlist, - }; - //! Indicates specified path being processed; provided for updating GUI. Note that optimally GUI should not be updated every time this is called because that could introduce a bottleneck. - virtual void on_progress(const char * p_path) = 0; - - //! Receives an item from one of playlist_loader functions. - //! @param p_item Item location, in form of metadb_handle pointer. - //! @param p_type Origin of this item - see t_entry_type for more info. - //! @param p_stats File stats of this item; set to filestats_invalid if not available. - //! @param p_fresh Fresh flag; indicates whether stats are directly from filesystem (true) or as stored earlier in a playlist file (false). - virtual void on_entry(const metadb_handle_ptr & p_item,t_entry_type p_type,const t_filestats & p_stats,bool p_fresh) = 0; - //! Queries whether file_info for specified item is requested. In typical scenario, if want_info() returns false, on_entry() will be called with same parameters; otherwise caller will attempt to read info from the item and call on_entry_info() with same parameters and file_info read from the item. - //! @param p_item Item location, in form of metadb_handle pointer. - //! @param p_type Origin of this item - see t_entry_type for more info. - //! @param p_stats File stats of this item; set to filestats_invalid if not available. - //! @param p_fresh Fresh flag; indicates whether stats are directly from filesystem (true) or as stored earlier in a playlist file (false). - virtual bool want_info(const metadb_handle_ptr & p_item,t_entry_type p_type,const t_filestats & p_stats,bool p_fresh) = 0; - //! Receives an item from one of playlist_loader functions; including file_info data. Except for file_info to be typically used as hint for metadb backend, behavior of this method is same as on_entry(). - //! @param p_item Item location, in form of metadb_handle pointer. - //! @param p_type Origin of this item - see t_entry_type for more info. - //! @param p_stats File stats of this item; set to filestats_invalid if not available. - //! @param p_info Information about the item, read from the file directly (if p_fresh is set to true) or from e.g. playlist file (if p_fresh is set to false). - //! @param p_fresh Fresh flag; indicates whether stats are directly from filesystem (true) or as stored earlier in a playlist file (false). - virtual void on_entry_info(const metadb_handle_ptr & p_item,t_entry_type p_type,const t_filestats & p_stats,const file_info & p_info,bool p_fresh) = 0; - - //! Same as metadb::handle_create(); provided here to avoid repeated metadb instantiation bottleneck since calling code will need this function often. - virtual void handle_create(metadb_handle_ptr & p_out,const playable_location & p_location) = 0; - -protected: - playlist_loader_callback() {} - ~playlist_loader_callback() {} -}; - -class NOVTABLE playlist_loader_callback_v2 : public playlist_loader_callback { -public: - //! Returns whether further on_entry() calls for this file are wanted. Typically always returns true, can be used to optimize cases when directories are searched for files matching specific pattern only so unwanted files aren't parsed unnecessarily. - //! @param path Canonical path to the media file being processed. - virtual bool is_path_wanted(const char * path, t_entry_type type) = 0; - -protected: - playlist_loader_callback_v2() {} - ~playlist_loader_callback_v2() {} -}; - -//! Basic implementation of playlist_loader_callback. -class playlist_loader_callback_impl : public playlist_loader_callback_v2 { -public: - - playlist_loader_callback_impl(abort_callback & p_abort) : m_abort(p_abort) {} - - bool is_aborting() const {return m_abort.is_aborting();} - abort_callback_event get_abort_event() const {return m_abort.get_abort_event();} - - const metadb_handle_ptr & get_item(t_size idx) const {return m_data[idx];} - const metadb_handle_ptr & operator[](t_size idx) const {return m_data[idx];} - t_size get_count() const {return m_data.get_count();} - - const metadb_handle_list & get_data() const {return m_data;} - - void on_progress(const char * path) {} - - void on_entry(const metadb_handle_ptr & ptr,t_entry_type type,const t_filestats & p_stats,bool p_fresh) {m_data.add_item(ptr);} - bool want_info(const metadb_handle_ptr & ptr,t_entry_type type,const t_filestats & p_stats,bool p_fresh) {return false;} - void on_entry_info(const metadb_handle_ptr & ptr,t_entry_type type,const t_filestats & p_stats,const file_info & p_info,bool p_fresh) {m_data.add_item(ptr);} - - void handle_create(metadb_handle_ptr & p_out,const playable_location & p_location) {m_api->handle_create(p_out,p_location);} - - bool is_path_wanted(const char * path,t_entry_type type) {return true;} - -private: - metadb_handle_list m_data; - abort_callback & m_abort; - static_api_ptr_t m_api; -}; - -//! Service handling playlist file operations. There are multiple implementations handling different playlist formats; you can add new implementations to allow new custom playlist file formats to be read or written.\n -//! Also provides static helper functions for turning a filesystem path into a list of playable item locations. \n -//! Note that you should typically call playlist_incoming_item_filter methods instead of calling playlist_loader methods directly to get a list of playable items from a specified path; this way you get a core-implemented threading and abortable dialog displaying progress.\n -//! To register your own implementation, use playlist_loader_factory_t template.\n -//! To call existing implementations, use static helper methods of playlist_loader class. -class NOVTABLE playlist_loader : public service_base { -public: - //! Parses specified playlist file into list of playable locations. Throws exception_io or derivatives on failure, exception_aborted on abort. If specified file is not a recognized playlist file, exception_io_unsupported_format is thrown. - //! @param p_path Path of playlist file to parse. Used for relative path handling purposes (p_file parameter is used for actual file access). - //! @param p_file File interface to use for reading. Read/write pointer must be set to beginning by caller before calling. - //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. - virtual void open(const char * p_path, const service_ptr_t & p_file,playlist_loader_callback & p_callback) = 0; - //! Writes a playlist file containing specific item list to specified file. Will fail (pfc::exception_not_implemented) if specified playlist_loader is read-only (can_write() returns false). - //! @param p_path Path of playlist file to write. Used for relative path handling purposes (p_file parameter is used for actual file access). - //! @param p_file File interface to use for writing. Caller should ensure that the file is empty (0 bytes long) before calling. - //! @param p_data List of items to save to playlist file. - //! @param p_abort abort_callback object signaling user aborting the operation. Note that aborting a save playlist operation will most likely leave user with corrupted/incomplete file. - virtual void write(const char * p_path, const service_ptr_t & p_file,const pfc::list_base_const_t & p_data,abort_callback & p_abort) = 0; - //! Returns extension of file format handled by this playlist_loader implementation (a UTF-8 encoded null-terminated string). - virtual const char * get_extension() = 0; - //! Returns whether this playlist_loader implementation supports writing. If can_write() returns false, all write() calls will fail. - virtual bool can_write() = 0; - //! Returns whether specified content type is one of playlist types supported by this playlist_loader implementation or not. - //! @param p_content_type Content type to query, a UTF-8 encoded null-terminated string. - virtual bool is_our_content_type(const char* p_content_type) = 0; - //! Returns whether playlist format extension supported by this implementation should be listed on file types associations page. - virtual bool is_associatable() = 0; - - //! Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives on failure, exception_aborted on abort. If specified file is not a recognized playlist file, exception_io_unsupported_format is thrown. \n - //! Equivalent to g_load_playlist_filehint(NULL,p_path,p_callback). - //! @param p_path Filesystem path to load playlist from, a UTF-8 encoded null-terminated string. - //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. - static void g_load_playlist(const char * p_path,playlist_loader_callback & p_callback); - - //! Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives on failure, exception_aborted on abort. If specified file is not a recognized playlist file, exception_io_unsupported_format is thrown. - //! @param p_path Filesystem path to load playlist from, a UTF-8 encoded null-terminated string. - //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. - //! @param fileHint File object to read from, can be NULL if not available. - static void g_load_playlist_filehint(file::ptr fileHint,const char * p_path,playlist_loader_callback & p_callback); - - //! Saves specified list of locations into a playlist file. Throws exception_io or derivatives on failure, exception_aborted on abort. - //! @param p_path Filesystem path to save playlist to, a UTF-8 encoded null-terminated string. - //! @param p_data List of items to save to playlist file. - //! @param p_abort abort_callback object signaling user aborting the operation. Note that aborting a save playlist operation will most likely leave user with corrupted/incomplete file. - static void g_save_playlist(const char * p_path,const pfc::list_base_const_t & p_data,abort_callback & p_abort); - - //! Processes specified path to generate list of playable items. Includes recursive directory/archive enumeration. \n - //! Does not touch playlist files encountered - use g_process_path_ex() if specified path is possibly a playlist file; playlist files found inside directories or archives are ignored regardless.\n - //! Warning: caller must handle exceptions which will occur in case of I/O failure. - //! @param p_path Filesystem path to process; a UTF-8 encoded null-terminated string. - //! @param p_callback Callback object receiving enumerated playable item locations as well as signaling user aborting the operation. - //! @param p_type Origin of p_path string. Reserved for internal use in recursive calls, should be left at default value; it controls various internal behaviors. - static void g_process_path(const char * p_path,playlist_loader_callback_v2 & p_callback,playlist_loader_callback::t_entry_type p_type = playlist_loader_callback::entry_user_requested); - - //! Calls attempts to process specified path as a playlist; if that fails (i.e. not a playlist), calls g_process_path with same parameters. See g_process_path for parameter descriptions. \n - //! Warning: caller must handle exceptions which will occur in case of I/O failure or playlist parsing failure. - //! @returns True if specified path was processed as a playlist file, false otherwise (relevant in some scenarios where output is sorted after loading, playlist file contents should not be sorted). - static bool g_process_path_ex(const char * p_path,playlist_loader_callback_v2 & p_callback,playlist_loader_callback::t_entry_type p_type = playlist_loader_callback::entry_user_requested); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playlist_loader); -}; - -template -class playlist_loader_factory_t : public service_factory_single_t {}; - diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/popup_message.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/popup_message.cpp deleted file mode 100644 index 7c62cb986..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/popup_message.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "foobar2000.h" - -void popup_message::g_show_ex(const char * p_msg,unsigned p_msg_length,const char * p_title,unsigned p_title_length,t_icon p_icon) -{ - static_api_ptr_t()->show_ex(p_msg,p_msg_length,p_title,p_title_length,p_icon); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/popup_message.h b/tools/vio2sf/src/foobar/foobar2000/SDK/popup_message.h deleted file mode 100644 index f62aef6f9..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/popup_message.h +++ /dev/null @@ -1,42 +0,0 @@ - -//! This interface allows you to show generic nonmodal noninteractive dialog with a text message. This should be used instead of MessageBox where possible.\n -//! Usage: use popup_message::g_show / popup_message::g_show_ex static helpers, or static_api_ptr_t.\n -//! Note that all strings are UTF-8. - -class NOVTABLE popup_message : public service_base { -public: - enum t_icon {icon_information, icon_error, icon_query}; - //! Activates the popup dialog; returns immediately (the dialog remains visible). - //! @param p_msg Message to show (UTF-8 encoded string). - //! @param p_msg_length Length limit of message string to show, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. - //! @param p_title Title of dialog to show (UTF-8 encoded string). - //! @param p_title_length Length limit of the title string, in bytes (actual string may be shorter if null terminator is encountered before). Set this to infinite to use plain null-terminated strings. - //! @param p_icon Icon of the dialog - can be set to icon_information, icon_error or icon_query. - virtual void show_ex(const char * p_msg,unsigned p_msg_length,const char * p_title,unsigned p_title_length,t_icon p_icon = icon_information) = 0; - - //! Activates the popup dialog; returns immediately (the dialog remains visible); helper function built around show_ex(), takes null terminated strings with no length limit parameters. - //! @param p_msg Message to show (UTF-8 encoded string). - //! @param p_title Title of dialog to show (UTF-8 encoded string). - //! @param p_icon Icon of the dialog - can be set to icon_information, icon_error or icon_query. - inline void show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {show_ex(p_msg,infinite,p_title,infinite,p_icon);} - - //! Static helper function instantiating the service and activating the message dialog. See show_ex() for description of parameters. - static void g_show_ex(const char * p_msg,unsigned p_msg_length,const char * p_title,unsigned p_title_length,t_icon p_icon = icon_information); - //! Static helper function instantiating the service and activating the message dialog. See show() for description of parameters. - static inline void g_show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {g_show_ex(p_msg,infinite,p_title,infinite,p_icon);} - - static void g_complain(const char * what) { - g_show(what, "Information", icon_error); - } - - static void g_complain(const char * p_whatFailed, const std::exception & p_exception) { - g_complain(p_whatFailed,p_exception.what()); - } - static void g_complain(const char * p_whatFailed, const char * msg) { - g_complain(pfc::string_formatter() << p_whatFailed << ": " << msg); - } - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(popup_message); -}; - -#define EXCEPTION_TO_POPUP_MESSAGE(CODE,LABEL) try { CODE; } catch(std::exception const & e) {popup_message::g_complain(LABEL,e);} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/preferences_page.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/preferences_page.cpp deleted file mode 100644 index 037d6a819..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/preferences_page.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "foobar2000.h" - -void preferences_page::get_help_url_helper(pfc::string_base & out, const char * category, const GUID & id, const char * name) { - out.reset(); - out << "http://help.foobar2000.org/" << core_version_info::g_get_version_string() << "/" << category << "/" << pfc::print_guid(id) << "/" << name; -} -bool preferences_page::get_help_url(pfc::string_base & p_out) { - get_help_url_helper(p_out,"preferences",get_guid(), get_name()); - return true; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/preferences_page.h b/tools/vio2sf/src/foobar/foobar2000/SDK/preferences_page.h deleted file mode 100644 index c184c66e8..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/preferences_page.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _FOOBAR2000_SDK_PREFERENCES_PAGE_H_ -#define _FOOBAR2000_SDK_PREFERENCES_PAGE_H_ - -//! Implementing this service will generate a page in preferences dialog. Use preferences_page_factory_t template to register. -class NOVTABLE preferences_page : public service_base { -public: - //! Creates preferences page dialog window. It is safe to assume that two dialog instances will never coexist. Caller is responsible for embedding it into preferences dialog itself. - virtual HWND create(HWND p_parent) = 0; - //! Retrieves name of the prefernces page to be displayed in preferences tree (static string). - virtual const char * get_name() = 0; - //! Retrieves GUID of the page. - virtual GUID get_guid() = 0; - //! Retrieves GUID of parent page/branch of this page. See preferences_page::guid_* constants for list of standard parent GUIDs. Can also be a GUID of another page or a branch (see: preferences_branch). - virtual GUID get_parent_guid() = 0; - //! Queries whether this page supports "reset page" feature. - virtual bool reset_query() = 0; - //! Activates "reset page" feature. It is safe to assume that the preferences page dialog does not exist at the point this is called (caller destroys it before calling reset and creates it again afterwards). - virtual void reset() = 0; - //! Retrieves help URL. Without overriding it, it will redirect to foobar2000 wiki. - virtual bool get_help_url(pfc::string_base & p_out); - - static void get_help_url_helper(pfc::string_base & out, const char * category, const GUID & id, const char * name); - - static const GUID guid_root, guid_hidden, guid_tools,guid_core,guid_display,guid_playback,guid_visualisations,guid_input,guid_tag_writing,guid_media_library, guid_tagging; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(preferences_page); -}; - -class NOVTABLE preferences_page_v2 : public preferences_page { -public: - //! Allows custom sorting order of preferences pages. Return lower value for higher priority (lower resulting index in the list). When sorting priority of two items matches, alphabetic sorting is used. Return 0 to use default alphabetic sorting without overriding priority. - virtual double get_sort_priority() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(preferences_page_v2,preferences_page); -}; - -template -class preferences_page_factory_t : public service_factory_single_t {}; - -//! Creates a preferences branch - an empty page that only serves as a parent for other pages and is hidden when no child pages exist. Instead of implementing this, simply use preferences_branch_factory class to declare a preferences branch with specified parameters. -class NOVTABLE preferences_branch : public service_base { -public: - //! Retrieves name of the preferences branch. - virtual const char * get_name() = 0; - //! Retrieves GUID of the preferences branch. Use this GUID as parent GUID for pages/branches nested in this branch. - virtual GUID get_guid() = 0; - //! Retrieves GUID of parent page/branch of this branch. See preferences_page::guid_* constants for list of standard parent GUIDs. Can also be a GUID of another branch or a page. - virtual GUID get_parent_guid() = 0; - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(preferences_branch); -}; - -class preferences_branch_v2 : public preferences_branch { -public: - //! Allows custom sorting order of preferences pages. Return lower value for higher priority (lower resulting index in the list). When sorting priority of two items matches, alphabetic sorting is used. Return 0 to use default alphabetic sorting without overriding priority. - virtual double get_sort_priority() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(preferences_branch_v2,preferences_branch); -}; - -class preferences_branch_impl : public preferences_branch_v2 { -public: - preferences_branch_impl(const GUID & p_guid,const GUID & p_parent,const char * p_name,double p_sort_priority = 0) : m_guid(p_guid), m_parent(p_parent), m_name(p_name), m_sort_priority(p_sort_priority) {} - const char * get_name() {return m_name;} - GUID get_guid() {return m_guid;} - GUID get_parent_guid() {return m_parent;} - double get_sort_priority() {return m_sort_priority;} -private: - const GUID m_guid,m_parent; - const pfc::string8 m_name; - const double m_sort_priority; -}; - -typedef service_factory_single_t __preferences_branch_factory; - -//! Instantiating this class declares a preferences branch with specified parameters.\n -//! Usage: static preferences_branch_factory g_mybranch(mybranchguid,parentbranchguid,"name of my preferences branch goes here"); -class preferences_branch_factory : public __preferences_branch_factory { -public: - preferences_branch_factory(const GUID & p_guid,const GUID & p_parent,const char * p_name,double p_sort_priority = 0) : __preferences_branch_factory(p_guid,p_parent,p_name,p_sort_priority) {} -}; - -#endif //_FOOBAR2000_SDK_PREFERENCES_PAGE_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain.cpp deleted file mode 100644 index caa22e623..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "foobar2000.h" - -void t_replaygain_config::reset() -{ - m_source_mode = source_mode_none; - m_processing_mode = processing_mode_none; - m_preamp_without_rg = 0; - m_preamp_with_rg = 0; -} - -audio_sample t_replaygain_config::query_scale(const file_info & p_info) const -{ - const audio_sample peak_margin = 1.0;//used to be 0.999 but it must not trigger on lossless - - audio_sample peak = peak_margin; - audio_sample gain = 0; - - bool have_rg_gain = false, have_rg_peak = false; - - if (m_source_mode == source_mode_track || m_source_mode == source_mode_album) - { - replaygain_info info = p_info.get_replaygain(); - float gain_select = replaygain_info::gain_invalid, peak_select = replaygain_info::peak_invalid; - if (m_source_mode == source_mode_track) - { - if (info.is_track_gain_present()) {gain = info.m_track_gain; have_rg_gain = true; } - else if (info.is_album_gain_present()) {gain = info.m_album_gain; have_rg_gain = true; } - if (info.is_track_peak_present()) {peak = info.m_track_peak; have_rg_peak = true; } - else if (info.is_album_peak_present()) {peak = info.m_album_peak; have_rg_peak = true; } - } - else - { - if (info.is_album_gain_present()) {gain = info.m_album_gain; have_rg_gain = true; } - else if (info.is_track_gain_present()) {gain = info.m_track_gain; have_rg_gain = true; } - if (info.is_album_peak_present()) {peak = info.m_album_peak; have_rg_peak = true; } - else if (info.is_track_peak_present()) {peak = info.m_track_peak; have_rg_peak = true; } - } - } - - gain += have_rg_gain ? m_preamp_with_rg : m_preamp_without_rg; - - audio_sample scale = 1.0; - - if (m_processing_mode == processing_mode_gain || m_processing_mode == processing_mode_gain_and_peak) - { - scale *= audio_math::gain_to_scale(gain); - } - - if (m_processing_mode == processing_mode_peak || m_processing_mode == processing_mode_gain_and_peak) - { - if (scale * peak > peak_margin) - scale = (audio_sample)(peak_margin / peak); - } - - return scale; -} - -audio_sample t_replaygain_config::query_scale(const metadb_handle_ptr & p_object) const -{ - audio_sample rv = 1.0; - p_object->metadb_lock(); - const file_info * info; - if (p_object->get_info_async_locked(info)) - rv = query_scale(*info); - p_object->metadb_unlock(); - return rv; -} - -audio_sample replaygain_manager::core_settings_query_scale(const file_info & p_info) -{ - t_replaygain_config temp; - get_core_settings(temp); - return temp.query_scale(p_info); -} - -audio_sample replaygain_manager::core_settings_query_scale(const metadb_handle_ptr & info) -{ - t_replaygain_config temp; - get_core_settings(temp); - return temp.query_scale(info); -} - -//enum t_source_mode {source_mode_none,source_mode_track,source_mode_album}; -//enum t_processing_mode {processing_mode_none,processing_mode_gain,processing_mode_gain_and_peak,processing_mode_peak}; -namespace { -class format_dbdelta -{ -public: - format_dbdelta(double p_val); - operator const char*() const {return m_buffer;} -private: - pfc::string_fixed_t<128> m_buffer; -}; -static const char * querysign(int val) { - return val<0 ? "-" : val>0 ? "+" : "\xc2\xb1"; -} - -format_dbdelta::format_dbdelta(double p_val) { - int val = (int)(p_val * 10); - m_buffer << querysign(val) << (abs(val)/10) << "." << (abs(val)%10) << "dB"; -} -} -void t_replaygain_config::format_name(pfc::string_base & p_out) const -{ - switch(m_processing_mode) - { - case processing_mode_none: - p_out = "None."; - break; - case processing_mode_gain: - switch(m_source_mode) - { - case source_mode_none: - if (m_preamp_without_rg == 0) p_out = "None."; - else p_out = pfc::string_formatter() << "Preamp : " << format_dbdelta(m_preamp_without_rg); - break; - case source_mode_track: - { - pfc::string_formatter fmt; - fmt << "Apply track gain"; - if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; - fmt << "."; - p_out = fmt; - } - break; - case source_mode_album: - { - pfc::string_formatter fmt; - fmt << "Apply album gain"; - if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; - fmt << "."; - p_out = fmt; - } - break; - }; - break; - case processing_mode_gain_and_peak: - switch(m_source_mode) - { - case source_mode_none: - if (m_preamp_without_rg >= 0) p_out = "None."; - else p_out = pfc::string_formatter() << "Preamp : " << format_dbdelta(m_preamp_without_rg); - break; - case source_mode_track: - { - pfc::string_formatter fmt; - fmt << "Apply track gain"; - if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; - fmt << ", prevent clipping according to track peak."; - p_out = fmt; - } - break; - case source_mode_album: - { - pfc::string_formatter fmt; - fmt << "Apply album gain"; - if (m_preamp_without_rg != 0 || m_preamp_with_rg != 0) fmt << ", with preamp"; - fmt << ", prevent clipping according to album peak."; - p_out = fmt; - } - break; - }; - break; - case processing_mode_peak: - switch(m_source_mode) - { - case source_mode_none: - p_out = "None."; - break; - case source_mode_track: - p_out = "Prevent clipping according to track peak."; - break; - case source_mode_album: - p_out = "Prevent clipping according to album peak."; - break; - }; - break; - } -} - -bool t_replaygain_config::is_active() const -{ - switch(m_processing_mode) - { - case processing_mode_none: - return false; - case processing_mode_gain: - switch(m_source_mode) - { - case source_mode_none: - return m_preamp_without_rg != 0; - case source_mode_track: - return true; - case source_mode_album: - return true; - }; - return false; - case processing_mode_gain_and_peak: - switch(m_source_mode) - { - case source_mode_none: - return m_preamp_without_rg < 0; - case source_mode_track: - return true; - case source_mode_album: - return true; - }; - return false; - case processing_mode_peak: - switch(m_source_mode) - { - case source_mode_none: - return false; - case source_mode_track: - return true; - case source_mode_album: - return true; - }; - return false; - default: - return false; - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain.h b/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain.h deleted file mode 100644 index 5e4c840ce..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain.h +++ /dev/null @@ -1,56 +0,0 @@ -//! Structure storing ReplayGain configuration: album/track source data modes, gain/peak processing modes and preamp values. -struct t_replaygain_config -{ - enum /*t_source_mode*/ {source_mode_none,source_mode_track,source_mode_album}; - enum /*t_processing_mode*/ {processing_mode_none,processing_mode_gain,processing_mode_gain_and_peak,processing_mode_peak}; - typedef t_uint32 t_source_mode; typedef t_uint32 t_processing_mode; - - t_replaygain_config() {reset();} - t_replaygain_config(const t_replaygain_config & p_source) {*this = p_source;} - t_replaygain_config(t_source_mode p_source_mode,t_processing_mode p_processing_mode,float p_preamp_without_rg, float p_preamp_with_rg) - : m_source_mode(p_source_mode), m_processing_mode(p_processing_mode), m_preamp_without_rg(p_preamp_without_rg), m_preamp_with_rg(p_preamp_with_rg) {} - - - t_source_mode m_source_mode; - t_processing_mode m_processing_mode; - float m_preamp_without_rg, m_preamp_with_rg;//preamp values in dB - - void reset(); - audio_sample query_scale(const file_info & info) const; - audio_sample query_scale(const metadb_handle_ptr & info) const; - - void format_name(pfc::string_base & p_out) const; - bool is_active() const; -}; - -FB2K_STREAM_READER_OVERLOAD(t_replaygain_config) { - return stream >> value.m_source_mode >> value.m_processing_mode >> value.m_preamp_with_rg >> value.m_preamp_with_rg; -} -FB2K_STREAM_WRITER_OVERLOAD(t_replaygain_config) { - return stream << value.m_source_mode << value.m_processing_mode << value.m_preamp_with_rg << value.m_preamp_with_rg; -} - -//! Core service providing methods to retrieve/alter playback ReplayGain settings, as well as use ReplayGain configuration dialog. -class NOVTABLE replaygain_manager : public service_base { -public: - //! Retrieves playback ReplayGain settings. - virtual void get_core_settings(t_replaygain_config & p_out) = 0; - - //! Creates embedded version of ReplayGain settings dialog. Note that embedded dialog sends WM_COMMAND with id/BN_CLICKED to parent window when user makes changes to settings. - virtual HWND configure_embedded(const t_replaygain_config & p_initdata,HWND p_parent,unsigned p_id,bool p_from_modal) = 0; - //! Retrieves settings from embedded version of ReplayGain settings dialog. - virtual void configure_embedded_retrieve(HWND wnd,t_replaygain_config & p_data) = 0; - - //! Shows popup/modal version of ReplayGain settings dialog. Returns true when user changed the settings, false when user cancelled the operation. Title parameter can be null to use default one. - virtual bool configure_popup(t_replaygain_config & p_data,HWND p_parent,const char * p_title) = 0; - - //! Alters playback ReplayGain settings. - virtual void set_core_settings(const t_replaygain_config & p_config) = 0; - - //! Helper; queries scale value for specified item according to core playback settings. - audio_sample core_settings_query_scale(const file_info & p_info); - //! Helper; queries scale value for specified item according to core playback settings. - audio_sample core_settings_query_scale(const metadb_handle_ptr & info); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(replaygain_manager); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain_info.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain_info.cpp deleted file mode 100644 index e1c5640fb..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain_info.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "foobar2000.h" - -bool replaygain_info::g_format_gain(float p_value,char p_buffer[text_buffer_size]) -{ - fpu_control_roundnearest bah; - if (p_value == gain_invalid) - { - p_buffer[0] = 0; - return false; - } - else - { - pfc::float_to_string(p_buffer,text_buffer_size - 4,p_value,2,true); - strcat(p_buffer," dB"); - return true; - } -} - -bool replaygain_info::g_format_peak(float p_value,char p_buffer[text_buffer_size]) -{ - fpu_control_roundnearest bah; - if (p_value == peak_invalid) - { - p_buffer[0] = 0; - return false; - } - else - { - pfc::float_to_string(p_buffer,text_buffer_size,p_value,6,false); - return true; - } -} - -void replaygain_info::reset() -{ - m_album_gain = gain_invalid; - m_track_gain = gain_invalid; - m_album_peak = peak_invalid; - m_track_peak = peak_invalid; -} - -static const char meta_album_gain[] = "replaygain_album_gain", meta_album_peak[] = "replaygain_album_peak", meta_track_gain[] = "replaygain_track_gain", meta_track_peak[] = "replaygain_track_peak"; - -bool replaygain_info::g_is_meta_replaygain(const char * p_name,t_size p_name_len) -{ - return - stricmp_utf8_ex(p_name,p_name_len,meta_album_gain,infinite) == 0 || - stricmp_utf8_ex(p_name,p_name_len,meta_album_peak,infinite) == 0 || - stricmp_utf8_ex(p_name,p_name_len,meta_track_gain,infinite) == 0 || - stricmp_utf8_ex(p_name,p_name_len,meta_track_peak,infinite) == 0; -} - -bool replaygain_info::set_from_meta_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) -{ - fpu_control_roundnearest bah; - if (stricmp_utf8_ex(p_name,p_name_len,meta_album_gain,infinite) == 0) - { - m_album_gain = (float)pfc::string_to_float(p_value,p_value_len); - return true; - } - else if (stricmp_utf8_ex(p_name,p_name_len,meta_album_peak,infinite) == 0) - { - m_album_peak = (float)pfc::string_to_float(p_value,p_value_len); - if (m_album_peak < 0) m_album_peak = 0; - return true; - } - else if (stricmp_utf8_ex(p_name,p_name_len,meta_track_gain,infinite) == 0) - { - m_track_gain = (float)pfc::string_to_float(p_value,p_value_len); - return true; - } - else if (stricmp_utf8_ex(p_name,p_name_len,meta_track_peak,infinite) == 0) - { - m_track_peak = (float)pfc::string_to_float(p_value,p_value_len); - if (m_track_peak < 0) m_track_peak = 0; - return true; - } - else return false; -} - - -t_size replaygain_info::get_value_count() -{ - t_size ret = 0; - if (is_album_gain_present()) ret++; - if (is_album_peak_present()) ret++; - if (is_track_gain_present()) ret++; - if (is_track_peak_present()) ret++; - return ret; -} - -void replaygain_info::set_album_gain_text(const char * p_text,t_size p_text_len) -{ - fpu_control_roundnearest bah; - if (p_text != 0 && p_text_len > 0 && *p_text != 0) - m_album_gain = (float)pfc::string_to_float(p_text,p_text_len); - else - remove_album_gain(); -} - -void replaygain_info::set_track_gain_text(const char * p_text,t_size p_text_len) -{ - fpu_control_roundnearest bah; - if (p_text != 0 && p_text_len > 0 && *p_text != 0) - m_track_gain = (float)pfc::string_to_float(p_text,p_text_len); - else - remove_track_gain(); -} - -void replaygain_info::set_album_peak_text(const char * p_text,t_size p_text_len) -{ - fpu_control_roundnearest bah; - if (p_text != 0 && p_text_len > 0 && *p_text != 0) - m_album_peak = (float)pfc::string_to_float(p_text,p_text_len); - else - remove_album_peak(); -} - -void replaygain_info::set_track_peak_text(const char * p_text,t_size p_text_len) -{ - fpu_control_roundnearest bah; - if (p_text != 0 && p_text_len > 0 && *p_text != 0) - m_track_peak = (float)pfc::string_to_float(p_text,p_text_len); - else - remove_track_peak(); -} - -replaygain_info replaygain_info::g_merge(replaygain_info r1,replaygain_info r2) -{ - replaygain_info ret = r1; - if (!ret.is_album_gain_present()) ret.m_album_gain = r2.m_album_gain; - if (!ret.is_album_peak_present()) ret.m_album_peak = r2.m_album_peak; - if (!ret.is_track_gain_present()) ret.m_track_gain = r2.m_track_gain; - if (!ret.is_track_peak_present()) ret.m_track_peak = r2.m_track_peak; - return ret; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain_scanner.h b/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain_scanner.h deleted file mode 100644 index 0224d8a9f..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/replaygain_scanner.h +++ /dev/null @@ -1,37 +0,0 @@ -//! Container of ReplayGain scan results from one or more tracks. -class replaygain_result : public service_base { - FB2K_MAKE_SERVICE_INTERFACE(replaygain_result, service_base); -public: - //! Retrieves the gain value, in dB. - virtual float get_gain() = 0; - //! Retrieves the peak value, normalized to 0..1 range (audio_sample value). - virtual float get_peak() = 0; - //! Merges ReplayGain scan results from different tracks. Merge results from all tracks in an album to get album gain/peak values. \n - //! This function returns a newly created replaygain_result object. Existing replaygain_result objects remain unaltered. - virtual replaygain_result::ptr merge(replaygain_result::ptr other) = 0; -}; - -//! Instance of a ReplayGain scanner. \n -//! Use static_api_ptr_t()->instantiate() to create a replaygain_scanner object; see replaygain_scanner_entry for more info. \n -//! Typical use: call process_chunk() with each chunk read from your track, call finalize() to obtain results for this track and reset replaygain_scanner's state for scanning another track; to obtain album gain/peak values, merge results (replaygain_result::merge) from all tracks. \n -class replaygain_scanner : public service_base { - FB2K_MAKE_SERVICE_INTERFACE(replaygain_scanner, service_base); -public: - //! Processes a PCM chunk. \n - //! May throw exception_io_data if the chunk contains something that can't be processed properly. - virtual void process_chunk(const audio_chunk & chunk) = 0; - //! Finalizes the scanning process; resets scanner's internal state and returns results for the track we've just scanned. \n - //! After calling finalize(), scanner's state becomes the same as after instantiation; you can continue with processing another track without creating a new scanner object. - virtual replaygain_result::ptr finalize() = 0; -}; - - -//! Entrypoint class for instantiating replaygain_scanner objects. Use static_api_ptr_t()->instantiate() to create replaygain_scanner instances. \n -//! This service is OPTIONAL; it's available from foobar2000 0.9.5.3 up but only if the ReplayGain Scanner component is installed. \n -//! It is recommended that you use replaygain_scanner like this: try { myInstance = static_api_ptr_t()->instantiate(); } catch(exception_service_not_found) { /* too old foobar2000 version or no foo_rgscan installed - complain/fail/etc */ } -class replaygain_scanner_entry : public service_base { - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(replaygain_scanner_entry); -public: - //! Instantiates a replaygain_scanner object. - virtual replaygain_scanner::ptr instantiate() = 0; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/resampler.h b/tools/vio2sf/src/foobar/foobar2000/SDK/resampler.h deleted file mode 100644 index de4626960..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/resampler.h +++ /dev/null @@ -1,25 +0,0 @@ -class NOVTABLE resampler_entry : public dsp_entry -{ -public: - virtual bool is_conversion_supported(unsigned p_srate_from,unsigned p_srate_to) = 0; - virtual bool create_preset(dsp_preset & p_out,unsigned p_target_srate,float p_qualityscale) = 0;//p_qualityscale is 0...1 - virtual float get_priority() = 0;//value is 0...1, where high-quality (SSRC etc) has 1 - - static bool g_get_interface(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to); - static bool g_create(service_ptr_t & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale); - static bool g_create_preset(dsp_preset & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale); - - FB2K_MAKE_SERVICE_INTERFACE(resampler_entry,dsp_entry); -}; - -template -class resampler_entry_impl_t : public dsp_entry_impl_t -{ -public: - bool is_conversion_supported(unsigned p_srate_from,unsigned p_srate_to) {return T::g_is_conversion_supported(p_srate_from,p_srate_to);} - bool create_preset(dsp_preset & p_out,unsigned p_target_srate,float p_qualityscale) {return T::g_create_preset(p_out,p_target_srate,p_qualityscale);} - float get_priority() {return T::g_get_priority();} -}; - -template -class resampler_factory_t : public service_factory_single_t > {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/search_tools.h b/tools/vio2sf/src/foobar/foobar2000/SDK/search_tools.h deleted file mode 100644 index 91c4fadbf..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/search_tools.h +++ /dev/null @@ -1,68 +0,0 @@ -//! Instance of a search filter object. New in 0.9.5. \n -//! This object contains a preprocessed search query; used to perform filtering similar to Media Library Search or Album List's "filter" box. \n -//! Use search_filter_manager API to instantiate search_filter objects. -class search_filter : public service_base { -public: - //! For backwards compatibility with older (0.9.5 alpha) revisions of this API. Do not call. - virtual bool test_locked(const metadb_handle_ptr & p_item,const file_info * p_info) = 0; - - //! Use this to run this filter on a group of items. - //! @param data Items to test. - //! @param out Pointer to a buffer (size at least equal to number of items in the source list) receiving the results. - virtual void test_multi(metadb_handle_list_cref data, bool * out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(search_filter,service_base); -}; - -//! New in 0.9.5.3. You can obtain a search_filter_v2 pointer by using service_query() on a search_filter pointer, or from search_filter_manager_v2::create_ex(). -class search_filter_v2 : public search_filter { -public: - virtual bool get_sort_pattern(titleformat_object::ptr & out, int & direction) = 0; - - //! Abortable version of test_multi(). If the abort_callback object becomes signaled while the operation is being performed, contents of the output buffer are undefined and the operation will fail with exception_aborted. - virtual void test_multi_ex(metadb_handle_list_cref data, bool * out, abort_callback & abort) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(search_filter_v2, search_filter) -}; - -//! New in 0.9.5.4. You can obtain a search_filter_v2 pointer by using service_query() on a search_filter/search_filter_v2 pointer. -class search_filter_v3 : public search_filter_v2 { -public: - //! Returns whether the sort pattern returned by get_sort_pattern() was set by the user explicitly using "SORT BY" syntax or whether it was determined implicitly from some other part of the query. It's recommended to use this to determine whether to create a force-sorted autoplaylist or not. - virtual bool is_sort_explicit() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(search_filter_v3, search_filter_v2) -}; - -//! Entrypoint class to instantiate search_filter objects. New in 0.9.5. -class search_filter_manager : public service_base { -public: - //! Creates a search_filter object. Throws an exception on failure (such as an error in the query). It's recommended that you relay the exception message to the user if this function fails. - virtual search_filter::ptr create(const char * p_query) = 0; - - //! Retrieves the search expression manual string. See also: show_manual(). - virtual void get_manual(pfc::string_base & p_out) = 0; - - void show_manual() { - pfc::string8 temp; - get_manual(temp); - popup_message::g_show(temp,"Search Expression Reference"); - } - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(search_filter_manager); -}; - -//! New in 0.9.5.3. -class search_filter_manager_v2 : public search_filter_manager { -public: - enum { - KFlagAllowSort = 1 << 0, - }; - //! Creates a search_filter object. Throws an exception on failure (such as an error in the query). It's recommended that you relay the exception message to the user if this function fails. - //! @param changeNotify A completion_notify callback object that will get called each time the query's behavior changes as a result of some external event (such as system time change). The caller must refresh query results each time this callback is triggered. The status parameter of it's on_completion() parameter is unused and always set to zero. - virtual search_filter_v2::ptr create_ex(const char * query, completion_notify::ptr changeNotify, t_uint32 flags) = 0; - - //! Opens the search query syntax reference document, typically an external HTML in user's default web browser. - virtual void show_manual() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(search_filter_manager_v2, search_filter_manager); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/service.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/service.cpp deleted file mode 100644 index 996117140..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/service.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "foobar2000.h" -#include "component.h" - -foobar2000_api * g_api; - -service_class_ref service_factory_base::enum_find_class(const GUID & p_guid) -{ - PFC_ASSERT(core_api::are_services_available() && g_api); - return g_api->service_enum_find_class(p_guid); -} - -bool service_factory_base::enum_create(service_ptr_t & p_out,service_class_ref p_class,t_size p_index) -{ - PFC_ASSERT(core_api::are_services_available() && g_api); - return g_api->service_enum_create(p_out,p_class,p_index); -} - -t_size service_factory_base::enum_get_count(service_class_ref p_class) -{ - PFC_ASSERT(core_api::are_services_available() && g_api); - return g_api->service_enum_get_count(p_class); -} - -service_factory_base * service_factory_base::__internal__list = NULL; - - - - - -namespace { - class main_thread_callback_release_object : public main_thread_callback { - public: - main_thread_callback_release_object(service_ptr obj) : m_object(obj) {} - void callback_run() { - try { m_object.release(); } catch(...) {} - } - private: - service_ptr m_object; - }; -} -namespace service_impl_helper { - void release_object_delayed(service_ptr obj) { - static_api_ptr_t()->add_callback(new service_impl_t(obj)); - } -}; - - -void _standard_api_create_internal(service_ptr & out, const GUID & classID) { - service_class_ref c = service_factory_base::enum_find_class(classID); - switch(service_factory_base::enum_get_count(c)) { - case 0: - throw exception_service_not_found(); - case 1: - PFC_ASSERT_SUCCESS( service_factory_base::enum_create(out, c, 0) ); - break; - default: - throw exception_service_duplicated(); - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/service.h b/tools/vio2sf/src/foobar/foobar2000/SDK/service.h deleted file mode 100644 index a2d64651d..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/service.h +++ /dev/null @@ -1,605 +0,0 @@ -#ifndef _foobar2000_sdk_service_h_included_ -#define _foobar2000_sdk_service_h_included_ - -typedef const void* service_class_ref; - -PFC_DECLARE_EXCEPTION(exception_service_not_found,pfc::exception,"Service not found"); -PFC_DECLARE_EXCEPTION(exception_service_extension_not_found,pfc::exception,"Service extension not found"); -PFC_DECLARE_EXCEPTION(exception_service_duplicated,pfc::exception,"Service duplicated"); - -#ifdef _MSC_VER -#define FOOGUIDDECL __declspec(selectany) -#else -#define FOOGUIDDECL -#endif - - -#define DECLARE_GUID(NAME,A,S,D,F,G,H,J,K,L,Z,X) FOOGUIDDECL const GUID NAME = {A,S,D,{F,G,H,J,K,L,Z,X}}; -#define DECLARE_CLASS_GUID(NAME,A,S,D,F,G,H,J,K,L,Z,X) FOOGUIDDECL const GUID NAME::class_guid = {A,S,D,{F,G,H,J,K,L,Z,X}}; - -//! Special hack to ensure errors when someone tries to ->service_add_ref()/->service_release() on a service_ptr_t -template class service_obscure_refcounting : public T { -private: - int service_add_ref() throw(); - int service_release() throw(); -}; - -//! Converts a service interface pointer to a pointer that obscures service counter functionality. -template static inline service_obscure_refcounting* service_obscure_refcounting_cast(T * p_source) throw() {return static_cast*>(p_source);} - -//Must be templated instead of taking service_base* because of multiple inheritance issues. -template static void service_release_safe(T * p_ptr) throw() { - if (p_ptr != NULL) PFC_ASSERT_NO_EXCEPTION( p_ptr->service_release() ); -} - -//Must be templated instead of taking service_base* because of multiple inheritance issues. -template static void service_add_ref_safe(T * p_ptr) throw() { - if (p_ptr != NULL) PFC_ASSERT_NO_EXCEPTION( p_ptr->service_add_ref() ); -} - -class service_base; - -//! Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes. -template -class service_ptr_t { -private: - typedef service_ptr_t t_self; -public: - inline service_ptr_t() throw() : m_ptr(NULL) {} - inline service_ptr_t(T* p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);} - inline service_ptr_t(const t_self & p_source) throw() : m_ptr(NULL) {copy(p_source);} - - template - inline service_ptr_t(t_source * p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);} - - template - inline service_ptr_t(const service_ptr_t & p_source) throw() : m_ptr(NULL) {copy(p_source);} - - inline ~service_ptr_t() throw() {service_release_safe(m_ptr);} - - template - void copy(t_source * p_ptr) throw() { - service_add_ref_safe(p_ptr); - service_release_safe(m_ptr); - m_ptr = pfc::safe_ptr_cast(p_ptr); - - } - - template - inline void copy(const service_ptr_t & p_source) throw() {copy(p_source.get_ptr());} - - - inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;} - inline const t_self & operator=(T * p_ptr) throw() {copy(p_ptr); return *this;} - - template inline t_self & operator=(const service_ptr_t & p_source) throw() {copy(p_source); return *this;} - template inline t_self & operator=(t_source * p_ptr) throw() {copy(p_ptr); return *this;} - - inline void release() throw() { - service_release_safe(m_ptr); - m_ptr = NULL; - } - - - inline service_obscure_refcounting* operator->() const throw() {PFC_ASSERT(m_ptr != NULL);return service_obscure_refcounting_cast(m_ptr);} - - inline T* get_ptr() const throw() {return m_ptr;} - - inline bool is_valid() const throw() {return m_ptr != NULL;} - inline bool is_empty() const throw() {return m_ptr == NULL;} - - inline bool operator==(const t_self & p_item) const throw() {return m_ptr == p_item.get_ptr();} - inline bool operator!=(const t_self & p_item) const throw() {return m_ptr != p_item.get_ptr();} - inline bool operator>(const t_self & p_item) const throw() {return m_ptr > p_item.get_ptr();} - inline bool operator<(const t_self & p_item) const throw() {return m_ptr < p_item.get_ptr();} - - template - inline t_self & operator<<(service_ptr_t & p_source) throw() {attach(p_source.detach());return *this;} - template - inline t_self & operator>>(service_ptr_t & p_dest) throw() {p_dest.attach(detach());return *this;} - - - inline T* __unsafe_duplicate() const throw() {//should not be used ! temporary ! - service_add_ref_safe(m_ptr); - return m_ptr; - } - - inline T* detach() throw() { - return pfc::replace_null_t(m_ptr); - } - - template - inline void attach(t_source * p_ptr) throw() { - service_release_safe(m_ptr); - m_ptr = pfc::safe_ptr_cast(p_ptr); - } - - T & operator*() const throw() {return *m_ptr;} - - service_ptr_t & _as_base_ptr() { - PFC_ASSERT( _as_base_ptr_check() ); - return *reinterpret_cast*>(this); - } - static bool _as_base_ptr_check() { - return static_cast((T*)NULL) == reinterpret_cast((T*)NULL); - } -private: - T* m_ptr; -}; - -namespace pfc { - template - class traits_t > : public traits_default { - public: - enum { realloc_safe = true, constructor_may_fail = false}; - }; -} - - -template class t_alloc = pfc::alloc_fast> -class service_list_t : public pfc::list_t, t_alloc > -{ -}; - -//! Helper macro for use when defining a service class. Generates standard features of a service, without ability to register using service_factory / enumerate using service_enum_t. \n -//! This is used for declaring services that are meant to be instantiated by means other than service_enum_t (or non-entrypoint services), or extensions of services (including extension of entrypoint services). \n -//! Sample non-entrypoint declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, service_base); }; \n -//! Sample extension declaration: class myclass : public myotherclass {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, myotherclass); }; \n -//! This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes. -#define FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,PARENTCLASS) \ - public: \ - typedef THISCLASS t_interface; \ - typedef PARENTCLASS t_interface_parent; \ - \ - static const GUID class_guid; \ - \ - virtual bool service_query(service_ptr_t & p_out,const GUID & p_guid) { \ - if (p_guid == class_guid) {p_out = this; return true;} \ - else return PARENTCLASS::service_query(p_out,p_guid); \ - } \ - typedef service_ptr_t ptr; \ - protected: \ - THISCLASS() {} \ - ~THISCLASS() {} \ - private: \ - const THISCLASS & operator=(const THISCLASS &) {throw pfc::exception_not_implemented();} \ - THISCLASS(const THISCLASS &) {throw pfc::exception_not_implemented();} \ - private: \ - void __private__service_declaration_selftest() { \ - pfc::assert_same_type(); /*parentclass must be an interface*/ \ - __validate_service_class_helper(); /*service_base must be reachable by walking t_interface_parent*/ \ - pfc::safe_cast(this); /*this class must derive from service_base, directly or indirectly, and be implictly castable to it*/ \ - } - -//! Helper macro for use when defining an entrypoint service class. Generates standard features of a service, including ability to register using service_factory and enumerate using service_enum. \n -//! Sample declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(myclass); }; \n -//! Note that entrypoint service classes must directly derive from service_base, and not from another service class. -//! This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes. -#define FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS) \ - public: \ - typedef THISCLASS t_interface_entrypoint; \ - FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,service_base) - - -#define FB2K_DECLARE_SERVICE_BEGIN(THISCLASS,BASECLASS) \ - class NOVTABLE THISCLASS : public BASECLASS { \ - FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,BASECLASS); \ - public: - -#define FB2K_DECLARE_SERVICE_END() \ - }; - -#define FB2K_DECLARE_SERVICE_ENTRYPOINT_BEGIN(THISCLASS) \ - class NOVTABLE THISCLASS : public service_base { \ - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS) \ - public: - - -//! Base class for all service classes.\n -//! Provides interfaces for reference counter and querying for different interfaces supported by the object.\n -class NOVTABLE service_base -{ -public: - //! Decrements reference count; deletes the object if reference count reaches zero. This is normally not called directly but managed by service_ptr_t<> template. - //! @returns New reference count. For debug purposes only, in certain conditions return values may be unreliable. - virtual int service_release() throw() = 0; - //! Increments reference count. This is normally not called directly but managed by service_ptr_t<> template. - //! @returns New reference count. For debug purposes only, in certain conditions return values may be unreliable. - virtual int service_add_ref() throw() = 0; - //! Queries whether the object supports specific interface and retrieves a pointer to that interface. This is normally not called directly but managed by service_query_t<> function template. - //! Typical implementation checks the parameter against GUIDs of interfaces supported by this object, if the GUID is one of supported interfaces, p_out is set to service_base pointer that can be static_cast<>'ed to queried interface and the method returns true; otherwise the method returns false. - virtual bool service_query(service_ptr_t & p_out,const GUID & p_guid) {return false;} - - //! Queries whether the object supports specific interface and retrieves a pointer to that interface. - //! @param p_out Receives pointer to queried interface on success. - //! returns true on success, false on failure (interface not supported by the object). - template - bool service_query_t(service_ptr_t & p_out) - { - pfc::assert_same_type(); - return service_query( *reinterpret_cast*>(&p_out),T::class_guid); - } - - typedef service_base t_interface; - -protected: - service_base() {} - ~service_base() {} -private: - service_base(const service_base&) {throw pfc::exception_not_implemented();} - const service_base & operator=(const service_base&) {throw pfc::exception_not_implemented();} -}; - -typedef service_ptr_t service_ptr; - -template -static void __validate_service_class_helper() { - __validate_service_class_helper(); -} - -template<> -static void __validate_service_class_helper() {} - - -#include "service_impl.h" - -class NOVTABLE service_factory_base { -protected: - inline service_factory_base(const GUID & p_guid) : m_guid(p_guid) {PFC_ASSERT(!core_api::are_services_available());__internal__next=__internal__list;__internal__list=this;} - inline ~service_factory_base() {PFC_ASSERT(!core_api::are_services_available());} -public: - inline const GUID & get_class_guid() const {return m_guid;} - - static service_class_ref enum_find_class(const GUID & p_guid); - static bool enum_create(service_ptr_t & p_out,service_class_ref p_class,t_size p_index); - static t_size enum_get_count(service_class_ref p_class); - - inline static bool is_service_present(const GUID & g) {return enum_get_count(enum_find_class(g))>0;} - - //! Throws std::bad_alloc or another exception on failure. - virtual void instance_create(service_ptr_t & p_out) = 0; - - //! FOR INTERNAL USE ONLY - static service_factory_base *__internal__list; - //! FOR INTERNAL USE ONLY - service_factory_base * __internal__next; -private: - const GUID & m_guid; -}; - - -template -class service_factory_base_t : public service_factory_base { -public: - service_factory_base_t() : service_factory_base(B::class_guid) { - pfc::assert_same_type(); - } - -}; - - -template static void _validate_service_ptr(service_ptr_t const & ptr) { - PFC_ASSERT( ptr.is_valid() ); - service_ptr_t test; - PFC_ASSERT( ptr->service_query_t(test) ); -} - -#ifdef _DEBUG -#define FB2K_ASSERT_VALID_SERVICE_PTR(ptr) _validate_service_ptr(ptr) -#else -#define FB2K_ASSERT_VALID_SERVICE_PTR(ptr) -#endif - -template static bool service_enum_create_t(service_ptr_t & p_out,t_size p_index) { - pfc::assert_same_type(); - service_ptr_t ptr; - if (service_factory_base::enum_create(ptr,service_factory_base::enum_find_class(T::class_guid),p_index)) { - p_out = static_cast(ptr.get_ptr()); - return true; - } else { - p_out.release(); - return false; - } -} - -template static service_class_ref _service_find_class() { - pfc::assert_same_type(); - return service_factory_base::enum_find_class(T::class_guid); -} - -template -static bool _service_instantiate_helper(service_ptr_t & out, service_class_ref servClass, t_size index) { - /*if (out._as_base_ptr_check()) { - const bool state = service_factory_base::enum_create(out._as_base_ptr(), servClass, index); - if (state) { FB2K_ASSERT_VALID_SERVICE_PTR(out); } - return state; - } else */{ - service_ptr temp; - const bool state = service_factory_base::enum_create(temp, servClass, index); - if (state) { - out.attach( static_cast( temp.detach() ) ); - FB2K_ASSERT_VALID_SERVICE_PTR( out ); - } - return state; - } -} - -template class service_class_helper_t { -public: - service_class_helper_t() : m_class(service_factory_base::enum_find_class(T::class_guid)) { - pfc::assert_same_type(); - } - t_size get_count() const { - return service_factory_base::enum_get_count(m_class); - } - - bool create(service_ptr_t & p_out,t_size p_index) const { - return _service_instantiate_helper(p_out, m_class, p_index); - } - - service_ptr_t create(t_size p_index) const { - service_ptr_t temp; - if (!create(temp,p_index)) throw pfc::exception_bug_check_v2(); - return temp; - } - service_class_ref get_class() const {return m_class;} -private: - service_class_ref m_class; -}; - -void _standard_api_create_internal(service_ptr & out, const GUID & classID); - -template static void standard_api_create_t(service_ptr_t & p_out) { - if (pfc::is_same_type::value) { - _standard_api_create_internal(p_out._as_base_ptr(), T::class_guid); - FB2K_ASSERT_VALID_SERVICE_PTR(p_out); - } else { - service_ptr_t temp; - standard_api_create_t(temp); - if (!temp->service_query_t(p_out)) throw exception_service_extension_not_found(); - } -} - -template static service_ptr_t standard_api_create_t() { - service_ptr_t temp; - standard_api_create_t(temp); - return temp; -} - -template -static bool static_api_test_t() { - typedef T::t_interface_entrypoint EP; - service_class_helper_t helper; - if (helper.get_count() != 1) return false; - if (!pfc::is_same_type::value) { - service_ptr_t t; - if (!helper.create(0)->service_query_t(t)) return false; - } - return true; -} - -#define FB2K_API_AVAILABLE(API) static_api_test_t() - -//! Helper template used to easily access core services. \n -//! Usage: static_api_ptr_t api; api->dosomething(); -//! Can be used at any point of code, WITH EXCEPTION of static objects that are initialized during the DLL loading process before the service system is initialized; such as static static_api_ptr_t objects or having static_api_ptr_t instances as members of statically created objects. -//! Throws exception_service_not_found if service could not be reached (which can be ignored for core APIs that are always present unless there is some kind of bug in the code). -template -class static_api_ptr_t { -public: - static_api_ptr_t() { - standard_api_create_t(m_ptr); - } - service_obscure_refcounting* operator->() const {return service_obscure_refcounting_cast(m_ptr.get_ptr());} - t_interface* get_ptr() const {return m_ptr.get_ptr();} -private: - service_ptr_t m_ptr; -}; - -//! Helper; simulates array with instance of each available implementation of given service class. -template class service_instance_array_t { -public: - typedef service_ptr_t t_ptr; - service_instance_array_t() { - service_class_helper_t helper; - const t_size count = helper.get_count(); - m_data.set_size(count); - for(t_size n=0;n m_data; -}; - -template -class service_enum_t { -public: - service_enum_t() : m_index(0) { - pfc::assert_same_type(); - } - void reset() {m_index = 0;} - - template - bool first(service_ptr_t & p_out) { - reset(); - return next(p_out); - } - - template - bool next(service_ptr_t & p_out) { - pfc::assert_same_type(); - if (pfc::is_same_type::value) { - return __next(reinterpret_cast&>(p_out)); - } else { - service_ptr_t temp; - while(__next(temp)) { - if (temp->service_query_t(p_out)) return true; - } - return false; - } - } - -private: - bool __next(service_ptr_t & p_out) { - return m_helper.create(p_out,m_index++); - } - unsigned m_index; - service_class_helper_t m_helper; -}; - -template -class service_factory_t : public service_factory_base_t { -public: - void instance_create(service_ptr_t & p_out) { - p_out = pfc::safe_cast(pfc::safe_cast(pfc::safe_cast( new service_impl_t ))); - } -}; - -template -class service_factory_single_t : public service_factory_base_t { - service_impl_single_t g_instance; -public: - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(service_factory_single_t,g_instance) - - void instance_create(service_ptr_t & p_out) { - p_out = pfc::safe_cast(pfc::safe_cast(pfc::safe_cast(&g_instance))); - } - - inline T& get_static_instance() {return g_instance;} - inline const T& get_static_instance() const {return g_instance;} -}; - -template -class service_factory_single_ref_t : public service_factory_base_t -{ -private: - T & instance; -public: - service_factory_single_ref_t(T& param) : instance(param) {} - - void instance_create(service_ptr_t & p_out) { - p_out = pfc::safe_cast(pfc::safe_cast(pfc::safe_cast(&instance))); - } - - inline T& get_static_instance() {return instance;} -}; - - -template -class service_factory_single_transparent_t : public service_factory_base_t, public service_impl_single_t -{ -public: - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(service_factory_single_transparent_t,service_impl_single_t) - - void instance_create(service_ptr_t & p_out) { - p_out = pfc::safe_cast(pfc::safe_cast(pfc::safe_cast(this))); - } - - inline T& get_static_instance() {return *(T*)this;} -}; - - - - - - - - - - - - - - - -template -static bool service_by_guid_fallback(service_ptr_t & out, const GUID & id) { - service_enum_t e; - service_ptr_t ptr; - while(e.next(ptr)) { - if (ptr->get_guid() == id) {out = ptr; return true;} - } - return false; -} - -template -class service_by_guid_data { -public: - service_by_guid_data() : m_servClass(), m_inited() {} - - bool ready() const {return m_inited;} - - void initialize() { - if (m_inited) return; - pfc::assert_same_type< what, typename what::t_interface_entrypoint >(); - m_servClass = service_factory_base::enum_find_class(what::class_guid); - const t_size servCount = service_factory_base::enum_get_count(m_servClass); - for(t_size walk = 0; walk < servCount; ++walk) { - service_ptr_t temp; - if (_service_instantiate_helper(temp, m_servClass, walk)) { - m_order.set(temp->get_guid(), walk); - } - } - m_inited = true; - } - - bool create(service_ptr_t & out, const GUID & id) const { - PFC_ASSERT(m_inited); - t_size index; - if (!m_order.query(id,index)) return false; - return _service_instantiate_helper(out, m_servClass, index); - } - service_ptr_t create(const GUID & id) const { - service_ptr_t temp; if (!crete(temp,id)) throw exception_service_not_found(); return temp; - } - -private: - volatile bool m_inited; - pfc::map_t m_order; - service_class_ref m_servClass; -}; - -template -class _service_by_guid_data_container { -public: - static service_by_guid_data data; -}; -template service_by_guid_data _service_by_guid_data_container::data; - - -template -static void service_by_guid_init() { - service_by_guid_data & data = _service_by_guid_data_container::data; - data.initialize(); -} -template -static bool service_by_guid(service_ptr_t & out, const GUID & id) { - pfc::assert_same_type< what, typename what::t_interface_entrypoint >(); - service_by_guid_data & data = _service_by_guid_data_container::data; - if (data.ready()) { - //fall-thru - } else if (core_api::is_main_thread()) { - data.initialize(); - } else { -#ifdef _DEBUG - uDebugLog() << "Warning: service_by_guid() used in non-main thread without initialization, using fallback"; -#endif - return service_by_guid_fallback(out,id); - } - return data.create(out,id); -} -template -static service_ptr_t service_by_guid(const GUID & id) { - service_ptr_t temp; - if (!service_by_guid(temp,id)) throw exception_service_not_found(); - return temp; -} - -#define FB2K_FOR_EACH_SERVICE(type, call) {service_enum_t e; service_ptr_t ptr; while(e.next(ptr)) {ptr->call;} } - -#endif //_foobar2000_sdk_service_h_included_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/service_impl.h b/tools/vio2sf/src/foobar/foobar2000/SDK/service_impl.h deleted file mode 100644 index 1c31536bb..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/service_impl.h +++ /dev/null @@ -1,37 +0,0 @@ -//! Template implementing reference-counting features of service_base. Intended for dynamic instantiation: "new service_impl_t(param1,param2);"; should not be instantiated otherwise (no local/static/member objects) because it does a "delete this;" when reference count reaches zero.\n -//! Note that some constructor parameters such as NULL will need explicit typecasts to ensure correctly guessed types for constructor function template (null string needs to be (const char*)NULL rather than just NULL, etc). -template -class service_impl_t : public T -{ -public: - int FB2KAPI service_release() throw() { - int ret = --m_counter; - if (ret == 0) { - PFC_ASSERT_NO_EXCEPTION( delete this ); - } - return ret; - } - int FB2KAPI service_add_ref() throw() {return ++m_counter;} - - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(service_impl_t,T) -private: - pfc::refcounter m_counter; -}; - -//! Template implementing dummy version of reference-counting features of service_base. Intended for static/local/member instantiation: "static service_impl_single_t myvar(params);". Because reference counting features are disabled (dummy reference counter), code instantiating it is responsible for deleting it as well as ensuring that no references are active when the object gets deleted.\n -//! Note that some constructor parameters such as NULL will need explicit typecasts to ensure correctly guessed types for constructor function template (null string needs to be (const char*)NULL rather than just NULL, etc). -template -class service_impl_single_t : public T -{ -public: - int FB2KAPI service_release() throw() {return 1;} - int FB2KAPI service_add_ref() throw() {return 1;} - - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(service_impl_single_t,T) -}; - - -namespace service_impl_helper { - void release_object_delayed(service_ptr obj); -}; - diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/shortcut_actions.h b/tools/vio2sf/src/foobar/foobar2000/SDK/shortcut_actions.h deleted file mode 100644 index cfc068aec..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/shortcut_actions.h +++ /dev/null @@ -1 +0,0 @@ -#error DEPRECATED diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/stdafx.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/stdafx.cpp deleted file mode 100644 index ea4f0bdf1..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ -//cpp used to generate precompiled header -#include "foobar2000.h" \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor.cpp deleted file mode 100644 index 6b6361a94..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include "foobar2000.h" - -void tag_processor_trailing::write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) -{ - write(p_file,p_info,flag_id3v1,p_abort); -} - -void tag_processor_trailing::write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) -{ - write(p_file,p_info,flag_apev2,p_abort); -} - -void tag_processor_trailing::write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) -{ - write(p_file,p_info,flag_id3v1|flag_apev2,p_abort); -} - - - - -enum { - g_flag_id3v1 = 1<<0, - g_flag_id3v2 = 1<<1, - g_flag_apev2 = 1<<2 -}; - -static void tagtype_list_append(pfc::string_base & p_out,const char * p_name) -{ - if (!p_out.is_empty()) p_out += "|"; - p_out += p_name; -} - -static void g_write_tags_ex(tag_write_callback & p_callback,unsigned p_flags,const service_ptr_t & p_file,const file_info * p_info,abort_callback & p_abort) { - PFC_ASSERT( p_flags == 0 || p_info != 0 ); - - - if (p_flags & (g_flag_id3v1 | g_flag_apev2)) { - switch(p_flags & (g_flag_id3v1 | g_flag_apev2)) { - case g_flag_id3v1 | g_flag_apev2: - static_api_ptr_t()->write_apev2_id3v1(p_file,*p_info,p_abort); - break; - case g_flag_id3v1: - static_api_ptr_t()->write_id3v1(p_file,*p_info,p_abort); - break; - case g_flag_apev2: - static_api_ptr_t()->write_apev2(p_file,*p_info,p_abort); - break; - default: - throw exception_io_data(); - } - } else { - static_api_ptr_t()->remove(p_file,p_abort); - } - - if (p_flags & g_flag_id3v2) - { - static_api_ptr_t()->write_ex(p_callback,p_file,*p_info,p_abort); - } - else - { - t_uint64 dummy; - tag_processor_id3v2::g_remove_ex(p_callback,p_file,dummy,p_abort); - } -} - -static void g_write_tags(unsigned p_flags,const service_ptr_t & p_file,const file_info * p_info,abort_callback & p_abort) { - g_write_tags_ex(tag_write_callback_dummy(),p_flags,p_file,p_info,p_abort); -} - - -void tag_processor::write_multi(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2) { - unsigned flags = 0; - if (p_write_id3v1) flags |= g_flag_id3v1; - if (p_write_id3v2) flags |= g_flag_id3v2; - if (p_write_apev2) flags |= g_flag_apev2; - g_write_tags(flags,p_file,&p_info,p_abort); -} - -void tag_processor::write_multi_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2) { - unsigned flags = 0; - if (p_write_id3v1) flags |= g_flag_id3v1; - if (p_write_id3v2) flags |= g_flag_id3v2; - if (p_write_apev2) flags |= g_flag_apev2; - g_write_tags_ex(p_callback,flags,p_file,&p_info,p_abort); -} - -void tag_processor::write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { - g_write_tags(g_flag_id3v1,p_file,&p_info,p_abort); -} - -void tag_processor::write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { - g_write_tags(g_flag_apev2,p_file,&p_info,p_abort); -} - -void tag_processor::write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { - g_write_tags(g_flag_apev2|g_flag_id3v1,p_file,&p_info,p_abort); -} - -void tag_processor::write_id3v2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { - g_write_tags(g_flag_id3v2,p_file,&p_info,p_abort); -} - -void tag_processor::write_id3v2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) { - g_write_tags(g_flag_id3v2|g_flag_id3v1,p_file,&p_info,p_abort); -} - -void tag_processor::remove_trailing(const service_ptr_t & p_file,abort_callback & p_abort) { - return static_api_ptr_t()->remove(p_file,p_abort); -} - -bool tag_processor::remove_id3v2(const service_ptr_t & p_file,abort_callback & p_abort) { - t_uint64 dummy = 0; - tag_processor_id3v2::g_remove(p_file,dummy,p_abort); - return dummy > 0; -} - -void tag_processor::remove_id3v2_trailing(const service_ptr_t & p_file,abort_callback & p_abort) { - remove_id3v2(p_file,p_abort); - remove_trailing(p_file,p_abort); -} - -void tag_processor::read_trailing(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) { - static_api_ptr_t()->read(p_file,p_info,p_abort); -} - -void tag_processor::read_trailing_ex(const service_ptr_t & p_file,file_info & p_info,t_uint64 & p_tagoffset,abort_callback & p_abort) { - static_api_ptr_t()->read_ex(p_file,p_info,p_tagoffset,p_abort); -} - -void tag_processor::read_id3v2(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) { - static_api_ptr_t()->read(p_file,p_info,p_abort); -} - -void tag_processor::read_id3v2_trailing(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) -{ - file_info_impl temp_infos[2]; - bool have_id3v2 = true, have_trailing = true; - try { - read_id3v2(p_file,temp_infos[0],p_abort); - } catch(exception_io_data) { - have_id3v2 = false; - } - try { - read_trailing(p_file,temp_infos[1],p_abort); - } catch(exception_io_data) { - have_trailing = false; - } - - if (!have_id3v2 && !have_trailing) throw exception_tag_not_found(); - else { - pfc::ptr_list_t blargh; - if (have_id3v2) blargh.add_item(&temp_infos[0]); - if (have_trailing) blargh.add_item(&temp_infos[1]); - p_info.merge(blargh); - } -} - -void tag_processor::skip_id3v2(const service_ptr_t & p_file,t_uint64 & p_size_skipped,abort_callback & p_abort) { - tag_processor_id3v2::g_skip(p_file,p_size_skipped,p_abort); -} - -bool tag_processor::is_id3v1_sufficient(const file_info & p_info) -{ - return static_api_ptr_t()->is_id3v1_sufficient(p_info); -} - -void tag_processor::truncate_to_id3v1(file_info & p_info) -{ - static_api_ptr_t()->truncate_to_id3v1(p_info); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor.h b/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor.h deleted file mode 100644 index 8369d4f65..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor.h +++ /dev/null @@ -1,99 +0,0 @@ -PFC_DECLARE_EXCEPTION(exception_tag_not_found,exception_io_data,"Tag not found"); - -//! Callback interface for write-tags-to-temp-file-and-swap scheme, used for ID3v2 tag updates and such where entire file needs to be rewritten. -//! As a speed optimization, file content can be copied to a temporary file in the same directory as the file being updated, and then source file can be swapped for the newly created file with updated tags. -//! This also gives better security against data loss on crash compared to rewriting the file in place and using memory or generic temporary file APIs to store content being rewritten. -class NOVTABLE tag_write_callback { -public: - //! Called only once per operation (or not called at all when operation being performed can be done in-place). - //! Requests a temporary file to be created in the same directory - virtual bool open_temp_file(service_ptr_t & p_out,abort_callback & p_abort) = 0; -protected: - tag_write_callback() {} - ~tag_write_callback() {} -private: - tag_write_callback(const tag_write_callback &) {throw pfc::exception_not_implemented();} - const tag_write_callback & operator=(const tag_write_callback &) {throw pfc::exception_not_implemented();} -}; - -class tag_write_callback_dummy : public tag_write_callback { -public: - bool open_temp_file(service_ptr_t & p_out,abort_callback & p_abort) {return false;} -}; - -//! For internal use - call tag_processor namespace methods instead. -class NOVTABLE tag_processor_id3v2 : public service_base -{ -public: - virtual void read(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) = 0; - virtual void write(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) = 0; - virtual void write_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort) = 0; - - static bool g_get(service_ptr_t & p_out); - static void g_skip(const service_ptr_t & p_file,t_filesize & p_size_skipped,abort_callback & p_abort); - static void g_remove(const service_ptr_t & p_file,t_filesize & p_size_removed,abort_callback & p_abort); - static void g_remove_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,t_filesize & p_size_removed,abort_callback & p_abort); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(tag_processor_id3v2); -}; - -//! For internal use - call tag_processor namespace methods instead. -class NOVTABLE tag_processor_trailing : public service_base -{ -public: - enum { - flag_apev2 = 1, - flag_id3v1 = 2, - }; - - virtual void read(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort) = 0; - virtual void write(const service_ptr_t & p_file,const file_info & p_info,unsigned p_flags,abort_callback & p_abort) = 0; - virtual void remove(const service_ptr_t & p_file,abort_callback & p_abort) = 0; - virtual bool is_id3v1_sufficient(const file_info & p_info) = 0; - virtual void truncate_to_id3v1(file_info & p_info) = 0; - virtual void read_ex(const service_ptr_t & p_file,file_info & p_info,t_filesize & p_tagoffset,abort_callback & p_abort) = 0; - - void write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - void write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - void write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(tag_processor_trailing); -}; - -namespace tag_processor { - //! Strips all recognized tags from the file and writes an ID3v1 tag with specified info. - void write_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - //! Strips all recognized tags from the file and writes an APEv2 tag with specified info. - void write_apev2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - //! Strips all recognized tags from the file and writes ID3v1+APEv2 tags with specified info. - void write_apev2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - //! Strips all recognized tags from the file and writes an ID3v2 tag with specified info. - void write_id3v2(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - //! Strips all recognized tags from the file and writes ID3v1+ID3v2 tags with specified info. - void write_id3v2_id3v1(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort); - //! Strips all recognized tags from the file and writes new tags with specified info according to parameters. - void write_multi(const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2); - //! Strips all recognized tags from the file and writes new tags with specified info according to parameters. Extended to allow write-tags-to-temp-file-and-swap scheme. - void write_multi_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,const file_info & p_info,abort_callback & p_abort,bool p_write_id3v1,bool p_write_id3v2,bool p_write_apev2); - //! Removes trailing tags from the file. - void remove_trailing(const service_ptr_t & p_file,abort_callback & p_abort); - //! Removes ID3v2 tags from the file. Returns true when a tag was removed, false when the file was not altered. - bool remove_id3v2(const service_ptr_t & p_file,abort_callback & p_abort); - //! Removes ID3v2 and trailing tags from specified file (not to be confused with trailing ID3v2 which are not yet supported). - void remove_id3v2_trailing(const service_ptr_t & p_file,abort_callback & p_abort); - //! Reads trailing tags from the file. - void read_trailing(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort); - //! Reads trailing tags from the file. Extended version, returns offset at which parsed tags start. - void read_trailing_ex(const service_ptr_t & p_file,file_info & p_info,t_filesize & p_tagoffset,abort_callback & p_abort); - //! Reads ID3v2 tags from specified file. - void read_id3v2(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort); - //! Reads ID3v2 and trailing tags from specified file (not to be confused with trailing ID3v2 which are not yet supported). - void read_id3v2_trailing(const service_ptr_t & p_file,file_info & p_info,abort_callback & p_abort); - - void skip_id3v2(const service_ptr_t & p_file,t_filesize & p_size_skipped,abort_callback & p_abort); - - bool is_id3v1_sufficient(const file_info & p_info); - void truncate_to_id3v1(file_info & p_info); - -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor_id3v2.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor_id3v2.cpp deleted file mode 100644 index 26e1577a9..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/tag_processor_id3v2.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "foobar2000.h" - -bool tag_processor_id3v2::g_get(service_ptr_t & p_out) -{ - return service_enum_t().first(p_out); -} - -void tag_processor_id3v2::g_remove(const service_ptr_t & p_file,t_uint64 & p_size_removed,abort_callback & p_abort) { - g_remove_ex(tag_write_callback_dummy(),p_file,p_size_removed,p_abort); -} - -void tag_processor_id3v2::g_remove_ex(tag_write_callback & p_callback,const service_ptr_t & p_file,t_uint64 & p_size_removed,abort_callback & p_abort) -{ - p_file->ensure_seekable(); - - t_filesize len; - - len = p_file->get_size(p_abort); - - if (len == filesize_invalid) throw exception_io_no_length(); - - p_file->seek(0,p_abort); - - t_uint64 offset; - g_skip(p_file,offset,p_abort); - - if (offset>0 && offset temp; - if (p_callback.open_temp_file(temp,p_abort)) { - file::g_transfer_object(p_file,temp,len,p_abort); - } else { - if (len > 16*1024*1024) filesystem::g_open_temp(temp,p_abort); - else filesystem::g_open_tempmem(temp,p_abort); - file::g_transfer_object(p_file,temp,len,p_abort); - p_file->seek(0,p_abort); - p_file->set_eof(p_abort); - temp->seek(0,p_abort); - file::g_transfer_object(temp,p_file,len,p_abort); - } - } - p_size_removed = offset; -} - -void tag_processor_id3v2::g_skip(const service_ptr_t & p_file,t_uint64 & p_size_skipped,abort_callback & p_abort) -{ - - unsigned char tmp[10]; - - t_size io_bytes_done; - - p_file->seek ( 0, p_abort ); - - io_bytes_done = p_file->read( tmp, sizeof(tmp), p_abort); - if (io_bytes_done != sizeof(tmp)) { - p_file->seek ( 0, p_abort ); - p_size_skipped = 0; - return; - } - - if ( 0 != memcmp ( tmp, "ID3", 3) ) { - p_file->seek ( 0, p_abort ); - p_size_skipped = 0; - return; - } - - int Unsynchronisation = tmp[5] & 0x80; - int ExtHeaderPresent = tmp[5] & 0x40; - int ExperimentalFlag = tmp[5] & 0x20; - int FooterPresent = tmp[5] & 0x10; - - if ( tmp[5] & 0x0F ) { - p_file->seek ( 0, p_abort ); - p_size_skipped = 0; - return; - } - - if ( (tmp[6] | tmp[7] | tmp[8] | tmp[9]) & 0x80 ) { - p_file->seek ( 0, p_abort ); - p_size_skipped = 0; - return; - } - - t_uint32 ret; - ret = tmp[6] << 21; - ret += tmp[7] << 14; - ret += tmp[8] << 7; - ret += tmp[9] ; - ret += 10; - if ( FooterPresent ) ret += 10; - - p_file->seek ( ret, p_abort ); - - p_size_skipped = ret; - -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/threaded_process.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/threaded_process.cpp deleted file mode 100644 index 567bd304f..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/threaded_process.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "foobar2000.h" - -void threaded_process_status::set_progress(t_size p_state,t_size p_max) -{ - set_progress( progress_min + MulDiv_Size(p_state,progress_max-progress_min,p_max) ); -} - -void threaded_process_status::set_progress_secondary(t_size p_state,t_size p_max) -{ - set_progress_secondary( progress_min + MulDiv_Size(p_state,progress_max-progress_min,p_max) ); -} - -void threaded_process_status::set_progress_float(double p_state) -{ - if (p_state < 0.0) set_progress(progress_min); - else if (p_state < 1.0) set_progress( progress_min + (t_size)(p_state * (progress_max - progress_min))); - else set_progress(progress_max); -} - -void threaded_process_status::set_progress_secondary_float(double p_state) -{ - if (p_state < 0.0) set_progress_secondary(progress_min); - else if (p_state < 1.0) set_progress_secondary( progress_min + (t_size)(p_state * (progress_max - progress_min))); - else set_progress_secondary(progress_max); -} - - -bool threaded_process::g_run_modal(service_ptr_t p_callback,unsigned p_flags,HWND p_parent,const char * p_title,t_size p_title_len) -{ - return static_api_ptr_t()->run_modal(p_callback,p_flags,p_parent,p_title,p_title_len); -} - -bool threaded_process::g_run_modeless(service_ptr_t p_callback,unsigned p_flags,HWND p_parent,const char * p_title,t_size p_title_len) -{ - return static_api_ptr_t()->run_modeless(p_callback,p_flags,p_parent,p_title,p_title_len); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/threaded_process.h b/tools/vio2sf/src/foobar/foobar2000/SDK/threaded_process.h deleted file mode 100644 index 1f7dbc491..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/threaded_process.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _foobar2000_sdk_threaded_process_h_ -#define _foobar2000_sdk_threaded_process_h_ - -class NOVTABLE threaded_process_status -{ -public: - enum {progress_min = 0, progress_max = 5000}; - - virtual void set_progress(t_size p_state) = 0; - virtual void set_progress_secondary(t_size p_state) = 0; - virtual void set_item(const char * p_item,t_size p_item_len = ~0) = 0; - virtual void set_item_path(const char * p_item,t_size p_item_len = ~0) = 0; - virtual void set_title(const char * p_title,t_size p_title_len = ~0) = 0; - virtual void force_update() = 0; - virtual bool is_paused() = 0; - virtual bool process_pause() = 0;//checks if process is paused and sleeps if needed; returns false when process should be aborted, true on success - - void set_progress(t_size p_state,t_size p_max); - void set_progress_secondary(t_size p_state,t_size p_max); - void set_progress_float(double p_state); - void set_progress_secondary_float(double p_state); -protected: - threaded_process_status() {} - ~threaded_process_status() {} -}; - - -class NOVTABLE threaded_process_callback : public service_base -{ -public: - virtual void on_init(HWND p_wnd) {} - virtual void run(threaded_process_status & p_status,abort_callback & p_abort) = 0; - virtual void on_done(HWND p_wnd,bool p_was_aborted) {} - - FB2K_MAKE_SERVICE_INTERFACE(threaded_process_callback,service_base); -}; - -class NOVTABLE threaded_process : public service_base { -public: - enum { - flag_show_abort = 1, - flag_show_minimize = 1 << 1, - flag_show_progress = 1 << 2, - flag_show_progress_dual = 1 << 3,//implies flag_show_progress - flag_show_item = 1 << 4, - flag_show_pause = 1 << 5, - flag_high_priority = 1 << 6, - flag_show_delayed = 1 << 7,//modeless-only - flag_no_focus = 1 << 8,//new (0.9.3) - }; - - virtual bool run_modal(service_ptr_t p_callback,unsigned p_flags,HWND p_parent,const char * p_title,t_size p_title_len) = 0; - virtual bool run_modeless(service_ptr_t p_callback,unsigned p_flags,HWND p_parent,const char * p_title,t_size p_title_len) = 0; - - static bool g_run_modal(service_ptr_t p_callback,unsigned p_flags,HWND p_parent,const char * p_title,t_size p_title_len = infinite); - static bool g_run_modeless(service_ptr_t p_callback,unsigned p_flags,HWND p_parent,const char * p_title,t_size p_title_len = infinite); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(threaded_process); -}; - - -#endif //_foobar2000_sdk_threaded_process_h_ diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/titleformat.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/titleformat.cpp deleted file mode 100644 index 251e15a1b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/titleformat.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "foobar2000.h" - - -#define tf_profiler(x) // profiler(x) - -void titleformat_compiler::remove_color_marks(const char * src,pfc::string_base & out)//helper -{ - out.reset(); - while(*src) - { - if (*src==3) - { - src++; - while(*src && *src!=3) src++; - if (*src==3) src++; - } - else out.add_byte(*src++); - } -} - -static bool test_for_bad_char(const char * source,t_size source_char_len,const char * reserved) -{ - return pfc::strstr_ex(reserved,(t_size)(-1),source,source_char_len) != (t_size)(-1); -} - -void titleformat_compiler::remove_forbidden_chars(titleformat_text_out * p_out,const GUID & p_inputtype,const char * p_source,t_size p_source_len,const char * p_reserved_chars) -{ - if (p_reserved_chars == 0 || *p_reserved_chars == 0) - { - p_out->write(p_inputtype,p_source,p_source_len); - } - else - { - p_source_len = pfc::strlen_max(p_source,p_source_len); - t_size index = 0; - t_size good_byte_count = 0; - while(index < p_source_len) - { - t_size delta = pfc::utf8_char_len(p_source + index,p_source_len - index); - if (delta == 0) break; - if (test_for_bad_char(p_source+index,delta,p_reserved_chars)) - { - if (good_byte_count > 0) {p_out->write(p_inputtype,p_source+index-good_byte_count,good_byte_count);good_byte_count=0;} - p_out->write(p_inputtype,"_",1); - } - else - { - good_byte_count += delta; - } - index += delta; - } - if (good_byte_count > 0) {p_out->write(p_inputtype,p_source+index-good_byte_count,good_byte_count);good_byte_count=0;} - } -} - -void titleformat_compiler::remove_forbidden_chars_string_append(pfc::string_receiver & p_out,const char * p_source,t_size p_source_len,const char * p_reserved_chars) -{ - remove_forbidden_chars(&titleformat_text_out_impl_string(p_out),pfc::guid_null,p_source,p_source_len,p_reserved_chars); -} - -void titleformat_compiler::remove_forbidden_chars_string(pfc::string_base & p_out,const char * p_source,t_size p_source_len,const char * p_reserved_chars) -{ - p_out.reset(); - remove_forbidden_chars_string_append(p_out,p_source,p_source_len,p_reserved_chars); -} - -bool titleformat_hook_impl_file_info::process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) { - return m_api->process_field(*m_info,m_location,p_out,p_name,p_name_length,p_found_flag); -} -bool titleformat_hook_impl_file_info::process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) { - return m_api->process_function(*m_info,m_location,p_out,p_name,p_name_length,p_params,p_found_flag); -} - -void titleformat_object::run_hook(const playable_location & p_location,const file_info * p_source,titleformat_hook * p_hook,pfc::string_base & p_out,titleformat_text_filter * p_filter) -{ - if (p_hook) - { - run( - &titleformat_hook_impl_splitter( - p_hook, - &titleformat_hook_impl_file_info(p_location,p_source) - ), - p_out,p_filter); - } - else - { - run( - &titleformat_hook_impl_file_info(p_location,p_source), - p_out,p_filter); - } -} - -void titleformat_object::run_simple(const playable_location & p_location,const file_info * p_source,pfc::string_base & p_out) -{ - run(&titleformat_hook_impl_file_info(p_location,p_source),p_out,NULL); -} - -t_size titleformat_hook_function_params::get_param_uint(t_size index) -{ - const char * str; - t_size str_len; - get_param(index,str,str_len); - return pfc::atoui_ex(str,str_len); -} - - -void titleformat_text_out_impl_filter_chars::write(const GUID & p_inputtype,const char * p_data,t_size p_data_length) -{ - titleformat_compiler::remove_forbidden_chars(m_chain,p_inputtype,p_data,p_data_length,m_restricted_chars); -} - -bool titleformat_hook_impl_splitter::process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) -{ - p_found_flag = false; - if (m_hook1 && m_hook1->process_field(p_out,p_name,p_name_length,p_found_flag)) return true; - p_found_flag = false; - if (m_hook2 && m_hook2->process_field(p_out,p_name,p_name_length,p_found_flag)) return true; - p_found_flag = false; - return false; -} - -bool titleformat_hook_impl_splitter::process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) -{ - p_found_flag = false; - if (m_hook1 && m_hook1->process_function(p_out,p_name,p_name_length,p_params,p_found_flag)) return true; - p_found_flag = false; - if (m_hook2 && m_hook2->process_function(p_out,p_name,p_name_length,p_params,p_found_flag)) return true; - p_found_flag = false; - return false; -} - -void titleformat_text_out::write_int_padded(const GUID & p_inputtype,t_int64 val,t_int64 maxval) -{ - unsigned width = 0; - while(maxval > 0) {maxval/=10;width++;} - write(p_inputtype,pfc::format_int(val,width)); -} - -void titleformat_text_out::write_int(const GUID & p_inputtype,t_int64 val) -{ - write(p_inputtype,pfc::format_int(val)); -} -void titleformat_text_filter_impl_reserved_chars::write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) -{ - if (p_inputtype == titleformat_inputtypes::meta) titleformat_compiler::remove_forbidden_chars_string_append(p_out,p_data,p_data_length,m_reserved_chars); - else p_out.add_string(p_data,p_data_length); -} - -void titleformat_compiler::run(titleformat_hook * p_source,pfc::string_base & p_out,const char * p_spec) -{ - service_ptr_t ptr; - if (!compile(ptr,p_spec)) p_out = "[COMPILATION ERROR]"; - else ptr->run(p_source,p_out,NULL); -} - -void titleformat_compiler::compile_safe(service_ptr_t & p_out,const char * p_spec) -{ - if (!compile(p_out,p_spec)) { - if (!compile(p_out,"%filename%")) - throw pfc::exception_bug_check_v2(); - } -} - - -namespace titleformat_inputtypes { - const GUID meta = { 0xcd839c8e, 0x5c66, 0x4ae1, { 0x8d, 0xad, 0x71, 0x1f, 0x86, 0x0, 0xa, 0xe3 } }; - const GUID unknown = { 0x673aa1cd, 0xa7a8, 0x40c8, { 0xbf, 0x9b, 0x34, 0x37, 0x99, 0x29, 0x16, 0x3b } }; -}; - -void titleformat_text_filter_impl_filename_chars::write(const GUID & p_inputType,pfc::string_receiver & p_out,const char * p_data,t_size p_dataLength) { - if (p_inputType == titleformat_inputtypes::meta) { - //slightly inefficient... - p_out.add_string( pfc::io::path::replaceIllegalNameChars(pfc::string(p_data,p_dataLength)).ptr()); - } else p_out.add_string(p_data,p_dataLength); -} - -void titleformat_compiler::compile_safe_ex(titleformat_object::ptr & p_out,const char * p_spec,const char * p_fallback) { - if (!compile(p_out,p_spec)) compile_force(p_out,p_fallback); -} - - -void titleformat_text_filter_nontext_chars::write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) { - for(t_size walk = 0;;) { - t_size base = walk; - while(walk < p_data_length && !isReserved(p_data[walk]) && p_data[walk] != 0) walk++; - p_out.add_string(p_data+base,walk-base); - if (walk >= p_data_length || p_data[walk] == 0) break; - p_out.add_byte('_'); walk++; - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/titleformat.h b/tools/vio2sf/src/foobar/foobar2000/SDK/titleformat.h deleted file mode 100644 index 6ed9bce65..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/titleformat.h +++ /dev/null @@ -1,227 +0,0 @@ -namespace titleformat_inputtypes { - extern const GUID meta, unknown; -}; - -class NOVTABLE titleformat_text_out { -public: - virtual void write(const GUID & p_inputtype,const char * p_data,t_size p_data_length = infinite) = 0; - void write_int(const GUID & p_inputtype,t_int64 val); - void write_int_padded(const GUID & p_inputtype,t_int64 val,t_int64 maxval); -protected: - titleformat_text_out() {} - ~titleformat_text_out() {} -}; - - -class NOVTABLE titleformat_text_filter { -public: - virtual void write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length) = 0; -protected: - titleformat_text_filter() {} - ~titleformat_text_filter() {} -}; - -class NOVTABLE titleformat_hook_function_params -{ -public: - virtual t_size get_param_count() = 0; - virtual void get_param(t_size index,const char * & p_string,t_size & p_string_len) = 0;//warning: not a null-terminated string - - //helper - t_size get_param_uint(t_size index); -}; - -class NOVTABLE titleformat_hook -{ -public: - virtual bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) = 0; - virtual bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) = 0; -}; -//! Represents precompiled executable title-formatting script. Use titleformat_compiler to instantiate; do not reimplement. -class NOVTABLE titleformat_object : public service_base -{ -public: - virtual void run(titleformat_hook * p_source,pfc::string_base & p_out,titleformat_text_filter * p_filter)=0; - - void run_hook(const playable_location & p_location,const file_info * p_source,titleformat_hook * p_hook,pfc::string_base & p_out,titleformat_text_filter * p_filter); - void run_simple(const playable_location & p_location,const file_info * p_source,pfc::string_base & p_out); - - FB2K_MAKE_SERVICE_INTERFACE(titleformat_object,service_base); -}; - -//! Standard service for instantiating titleformat_object. Implemented by the core; do not reimplement. -//! To instantiate, use static_api_ptr_t. -class NOVTABLE titleformat_compiler : public service_base -{ -public: - //! Returns false in case of a compilation error. - virtual bool compile(titleformat_object::ptr & p_out,const char * p_spec) = 0; - //! Helper; - void run(titleformat_hook * p_source,pfc::string_base & p_out,const char * p_spec); - //! Should never fail, falls back to %filename% in case of failure. - void compile_safe(titleformat_object::ptr & p_out,const char * p_spec); - - //! Falls back to p_fallback in case of failure. - void compile_safe_ex(titleformat_object::ptr & p_out,const char * p_spec,const char * p_fallback = ""); - - //! Throws a bug check exception when script can't be compiled. For use with hardcoded scripts only. - void compile_force(titleformat_object::ptr & p_out,const char * p_spec) {if (!compile(p_out,p_spec)) throw pfc::exception_bug_check_v2();} - - - static void remove_color_marks(const char * src,pfc::string_base & out);//helper - static void remove_forbidden_chars(titleformat_text_out * p_out,const GUID & p_inputtype,const char * p_source,t_size p_source_len,const char * p_forbidden_chars); - static void remove_forbidden_chars_string_append(pfc::string_receiver & p_out,const char * p_source,t_size p_source_len,const char * p_forbidden_chars); - static void remove_forbidden_chars_string(pfc::string_base & p_out,const char * p_source,t_size p_source_len,const char * p_forbidden_chars); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(titleformat_compiler); -}; - - -class titleformat_object_wrapper { -public: - titleformat_object_wrapper(const char * p_script) { - static_api_ptr_t()->compile_force(m_script,p_script); - } - - operator const service_ptr_t &() const {return m_script;} - -private: - service_ptr_t m_script; -}; - - -//helpers - - -class titleformat_text_out_impl_filter_chars : public titleformat_text_out -{ -public: - inline titleformat_text_out_impl_filter_chars(titleformat_text_out * p_chain,const char * p_restricted_chars) - : m_chain(p_chain), m_restricted_chars(p_restricted_chars) {} - void write(const GUID & p_inputtype,const char * p_data,t_size p_data_length); -private: - titleformat_text_out * m_chain; - const char * m_restricted_chars; -}; - -class titleformat_text_out_impl_string : public titleformat_text_out { -public: - titleformat_text_out_impl_string(pfc::string_receiver & p_string) : m_string(p_string) {} - void write(const GUID & p_inputtype,const char * p_data,t_size p_data_length) {m_string.add_string(p_data,p_data_length);} -private: - pfc::string_receiver & m_string; -}; - -class titleformat_common_methods : public service_base { -public: - virtual bool process_field(const file_info & p_info,const playable_location & p_location,titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) = 0; - virtual bool process_function(const file_info & p_info,const playable_location & p_location,titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) = 0; - virtual bool remap_meta(const file_info & p_info,t_size & p_index, const char * p_name, t_size p_name_length) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(titleformat_common_methods); -}; - -class titleformat_hook_impl_file_info : public titleformat_hook -{ -public: - titleformat_hook_impl_file_info(const playable_location & p_location,const file_info * p_info) : m_location(p_location), m_info(p_info) {}//caller must ensure that referenced file_info object is alive as long as the titleformat_hook_impl_file_info instance - bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag); - bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag); -protected: - bool remap_meta(t_size & p_index, const char * p_name, t_size p_name_length) {return m_api->remap_meta(*m_info,p_index,p_name,p_name_length);} - const file_info * m_info; -private: - const playable_location & m_location; - static_api_ptr_t m_api; -}; - -class titleformat_hook_impl_splitter : public titleformat_hook { -public: - inline titleformat_hook_impl_splitter(titleformat_hook * p_hook1,titleformat_hook * p_hook2) : m_hook1(p_hook1), m_hook2(p_hook2) {} - bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag); - bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag); -private: - titleformat_hook * m_hook1, * m_hook2; -}; - -class titleformat_text_filter_impl_reserved_chars : public titleformat_text_filter { -public: - titleformat_text_filter_impl_reserved_chars(const char * p_reserved_chars) : m_reserved_chars(p_reserved_chars) {} - virtual void write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length); -private: - const char * m_reserved_chars; -}; - -class titleformat_text_filter_impl_filename_chars : public titleformat_text_filter { -public: - void write(const GUID & p_inputType,pfc::string_receiver & p_out,const char * p_data,t_size p_dataLength); -}; - -class titleformat_text_filter_nontext_chars : public titleformat_text_filter { -public: - inline static bool isReserved(char c) { return c >= 0 && c < 0x20; } - void write(const GUID & p_inputtype,pfc::string_receiver & p_out,const char * p_data,t_size p_data_length); -}; - - - - - - - -class titleformat_hook_impl_list : public titleformat_hook { -public: - titleformat_hook_impl_list(t_size p_index /* zero-based! */,t_size p_total) : m_index(p_index), m_total(p_total) {} - - bool process_field(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,bool & p_found_flag) { - if ( - stricmp_utf8_ex(p_name,p_name_length,"list_index",infinite) == 0 - ) { - p_out->write_int_padded(titleformat_inputtypes::unknown,m_index+1, m_total); - p_found_flag = true; return true; - } else if ( - stricmp_utf8_ex(p_name,p_name_length,"list_total",infinite) == 0 - ) { - p_out->write_int(titleformat_inputtypes::unknown,m_total); - p_found_flag = true; return true; - } else { - p_found_flag = false; return false; - } - } - - bool process_function(titleformat_text_out * p_out,const char * p_name,t_size p_name_length,titleformat_hook_function_params * p_params,bool & p_found_flag) {return false;} - -private: - t_size m_index, m_total; -}; - -class string_formatter_tf : public pfc::string_base { -public: - string_formatter_tf(titleformat_text_out * out, const GUID & inputType = titleformat_inputtypes::meta) : m_out(out), m_inputType(inputType) {} - - const char * get_ptr() const { - throw pfc::exception_not_implemented(); - } - void add_string(const char * p_string,t_size p_length) { - m_out->write(m_inputType,p_string,p_length); - } - void set_string(const char * p_string,t_size p_length) { - throw pfc::exception_not_implemented(); - } - void truncate(t_size len) { - throw pfc::exception_not_implemented(); - } - t_size get_length() const { - throw pfc::exception_not_implemented(); - } - char * lock_buffer(t_size p_requested_length) { - throw pfc::exception_not_implemented(); - } - void unlock_buffer() { - throw pfc::exception_not_implemented(); - } - -private: - titleformat_text_out * const m_out; - const GUID m_inputType; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/track_property.h b/tools/vio2sf/src/foobar/foobar2000/SDK/track_property.h deleted file mode 100644 index 3f8aa605d..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/track_property.h +++ /dev/null @@ -1,45 +0,0 @@ -//! Callback interface for track_property_provider::enumerate_properties(). -class NOVTABLE track_property_callback { -public: - //! Sets a property list entry to display. Called by track_property_provider::enumerate_properties() implementation. - //! @param p_group Name of group to put the entry in, case-sensitive. Note that non-standard groups are sorted alphabetically. - //! @param p_sortpriority Sort priority of the property inside its group (smaller value means earlier in the list), pass 0 if you don't care (alphabetic order by name used when more than one item has same priority). - //! @param p_name Name of the property. - //! @param p_value Value of the property. - virtual void set_property(const char * p_group,double p_sortpriority,const char * p_name,const char * p_value) = 0; -protected: - track_property_callback const & operator=(track_property_callback const &) {return *this;} - ~track_property_callback() {} -}; - -class NOVTABLE track_property_callback_v2 : public track_property_callback { -public: - virtual bool is_group_wanted(const char * p_group) = 0; -protected: - ~track_property_callback_v2() {} -}; - -//! Service for adding custom entries in "Properties" tab of the properties dialog. -class NOVTABLE track_property_provider : public service_base { -public: - //! Enumerates properties of specified track list. - //! @param p_tracks List of tracks to enumerate properties on. - //! @param p_out Callback interface receiving enumerated properties. - virtual void enumerate_properties(metadb_handle_list_cref p_tracks, track_property_callback & p_out) = 0; - //! Returns whether specified tech info filed is processed by our service and should not be displayed among unknown fields. - //! @param p_name Name of tech info field being queried. - //! @returns True if the field is among fields processed by this track_property_provider implementation and should not be displayed among unknown fields, false otherwise. - virtual bool is_our_tech_info(const char * p_name) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(track_property_provider); -}; - -class NOVTABLE track_property_provider_v2 : public track_property_provider { -public: - virtual void enumerate_properties_v2(metadb_handle_list_cref p_tracks, track_property_callback_v2 & p_out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(track_property_provider_v2,track_property_provider) -}; - -template -class track_property_provider_factory_t : public service_factory_single_t {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/ui.cpp b/tools/vio2sf/src/foobar/foobar2000/SDK/ui.cpp deleted file mode 100644 index 7417e65e5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/ui.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "foobar2000.h" - -bool ui_drop_item_callback::g_on_drop(interface IDataObject * pDataObject) -{ - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - if (ptr->on_drop(pDataObject)) return true; - } while(e.next(ptr)); - return false; -} - -bool ui_drop_item_callback::g_is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect) -{ - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - if (ptr->is_accepted_type(pDataObject,p_effect)) return true; - } while(e.next(ptr)); - return false; -} - -bool user_interface::g_find(service_ptr_t & p_out,const GUID & p_guid) -{ - service_enum_t e; - service_ptr_t ptr; - if (e.first(ptr)) do { - if (ptr->get_guid() == p_guid) - { - p_out = ptr; - return true; - } - } while(e.next(ptr)); - return false; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/ui.h b/tools/vio2sf/src/foobar/foobar2000/SDK/ui.h deleted file mode 100644 index 079a63e68..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/ui.h +++ /dev/null @@ -1,190 +0,0 @@ -#ifndef _WINDOWS -#error PORTME -#endif - -//! Entrypoint service for user interface modules. Implement when registering an UI module. Do not call existing implementations; only core enumerates / dispatches calls. To control UI behaviors from other components, use ui_control API. \n -//! Use user_interface_factory_t<> to register, e.g static user_interface_factory_t g_myclass_factory; -class NOVTABLE user_interface : public service_base { -public: - //!HookProc usage: \n - //! in your windowproc, call HookProc first, and if it returns true, return LRESULT value it passed to you - typedef BOOL (WINAPI * HookProc_t)(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,LRESULT * ret); - - //! Retrieves name (UTF-8 null-terminated string) of the UI module. - virtual const char * get_name()=0; - //! Initializes the UI module - creates the main app window, etc. Failure should be signaled by appropriate exception (std::exception or a derivative). - virtual HWND init(HookProc_t hook)=0; - //! Deinitializes the UI module - destroys the main app window, etc. - virtual void shutdown()=0; - //! Activates main app window. - virtual void activate()=0; - //! Minimizes/hides main app window. - virtual void hide()=0; - //! Returns whether main window is visible / not minimized. Used for activate/hide command. - virtual bool is_visible() = 0; - //! Retrieves GUID of your implementation, to be stored in configuration file etc. - virtual GUID get_guid() = 0; - - //! Overrides statusbar text with specified string. The parameter is a null terminated UTF-8 string. The override is valid until another override_statusbar_text() call or revert_statusbar_text() call. - virtual void override_statusbar_text(const char * p_text) = 0; - //! Disables statusbar text override. - virtual void revert_statusbar_text() = 0; - - //! Shows now-playing item somehow (e.g. system notification area popup). - virtual void show_now_playing() = 0; - - static bool g_find(service_ptr_t & p_out,const GUID & p_guid); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(user_interface); -}; - -template -class user_interface_factory : public service_factory_single_t {}; - -//! Interface class allowing you to override UI statusbar text. There may be multiple callers trying to override statusbar text; backend decides which one succeeds so you will not always get what you want. Statusbar text override is automatically cancelled when the object is released.\n -//! Use ui_control::override_status_text_create() to instantiate. -//! Implemented by core. Do not reimplement. -class NOVTABLE ui_status_text_override : public service_base -{ -public: - //! Sets statusbar text to specified UTF-8 null-terminated string. - virtual void override_text(const char * p_message) = 0; - //! Cancels statusbar text override. - virtual void revert_text() = 0; - - FB2K_MAKE_SERVICE_INTERFACE(ui_status_text_override,service_base); -}; - -//! Serivce providing various UI-related commands. Implemented by core; do not reimplement. -//! Instantiation: use static_api_ptr_t. -class NOVTABLE ui_control : public service_base { -public: - //! Returns whether primary UI is visible/unminimized. - virtual bool is_visible()=0; - //! Activates/unminimizes main UI. - virtual void activate()=0; - //! Hides/minimizese main UI. - virtual void hide()=0; - //! Retrieves main GUI icon, to use as window icon etc. Returned handle does not need to be freed. - virtual HICON get_main_icon()=0; - //! Loads main GUI icon, version with specified width/height. Returned handle needs to be freed with DestroyIcon when you are done using it. - virtual HICON load_main_icon(unsigned width,unsigned height) = 0; - - //! Activates preferences dialog and navigates to specified page. See also: preference_page API. - virtual void show_preferences(const GUID & p_page) = 0; - - //! Instantiates ui_status_text_override service, that can be used to display status messages. - //! @param p_out receives new ui_status_text_override instance. - //! @returns true on success, false on failure (out of memory / no GUI loaded / etc) - virtual bool override_status_text_create(service_ptr_t & p_out) = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_control); -}; - -//! Service called from the UI when some object is dropped into the UI. Usable for modifying drag&drop behaviors such as adding custom handlers for object types other than supported media files.\n -//! Implement where needed; use ui_drop_item_callback_factory_t<> template to register, e.g. static ui_drop_item_callback_factory_t g_myclass_factory. -class NOVTABLE ui_drop_item_callback : public service_base { -public: - //! Called when an object was dropped; returns true if the object was processed and false if not. - virtual bool on_drop(interface IDataObject * pDataObject) = 0; - //! Tests whether specified object type is supported by this ui_drop_item_callback implementation. Returns true and sets p_effect when it's supported; returns false otherwise. \n - //! See IDropTarget::DragEnter() documentation for more information about p_effect values. - virtual bool is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect)=0; - - //! Static helper, calls all existing implementations appropriately. See on_drop(). - static bool g_on_drop(interface IDataObject * pDataObject); - //! Static helper, calls all existing implementations appropriately. See is_accepted_type(). - static bool g_is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_drop_item_callback); -}; - -template -class ui_drop_item_callback_factory_t : public service_factory_single_t {}; - - -class ui_selection_callback; - -//! Write interface and reference counter for the shared selection. -//! The ui_selection_manager stores the selected items as a list. -//! The ui_selection_holder service allows components to modify this list. -//! It also serves as a reference count: the ui_selection_manager clears the stored -//! selection when no component holds a reference to a ui_selection_holder. -//! -//! When a window that uses the shared selection gets the focus, it should acquire -//! a ui_selection_holder from the ui_selection_manager. If it contains selectable items, -//! it should use the appropriate method to store its selected items as the shared selection. -//! If it just wants to preserve the selection - for example so it can display it - it should -//! merely store the acquired ui_selection_holder. -//! -//! When the window loses the focus, it should release its ui_selection_holder. -//! It should not use a set method to clear the selection -class NOVTABLE ui_selection_holder : public service_base { -public: - //! Sets selected items. - virtual void set_selection(metadb_handle_list_cref data) = 0; - //! Sets selected items to playlist selection and enables tracking. - //! When the playlist selection changes, the stored selection is automatically updated. - //! Tracking ends when a set method is called on any ui_selection_holder or when - //! the last reference to this ui_selection_holder is released. - virtual void set_playlist_selection_tracking() = 0; - //! Sets selected items to the contents of the active playlist and enables tracking. - //! When the active playlist or its contents changes, the stored selection is automatically updated. - //! Tracking ends when a set method is called on any ui_selection_holder or when - //! the last reference to this ui_selection_holder is released. - virtual void set_playlist_tracking() = 0; - - //! Sets selected items and type of selection holder. - //! @param type Specifies type of selection. Values same as contextmenu_item caller IDs. - virtual void set_selection_ex(metadb_handle_list_cref data, const GUID & type) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(ui_selection_holder,service_base); -}; - -class NOVTABLE ui_selection_manager : public service_base { -public: - //! Retrieves current selection. - virtual void get_selection(pfc::list_base_t & p_selection) = 0; - //! Registers a callback. It is recommended to use ui_selection_callback_impl_base class instead of calling this directly. - virtual void register_callback(ui_selection_callback * p_callback) = 0; - //! Unregisters a callback. It is recommended to use ui_selection_callback_impl_base class instead of calling this directly. - virtual void unregister_callback(ui_selection_callback * p_callback) = 0; - - virtual ui_selection_holder::ptr acquire() = 0; - - //! Retrieves type of the active selection holder. Values same as contextmenu_item caller IDs. - virtual GUID get_selection_type() = 0; - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_selection_manager); -}; - -class ui_selection_callback { -public: - virtual void on_selection_changed(const pfc::list_base_const_t & p_selection) = 0; -protected: - ui_selection_callback() {} - ~ui_selection_callback() {} -}; - -//! ui_selection_callback implementation helper with autoregistration - do not instantiate statically -class ui_selection_callback_impl_base : public ui_selection_callback { -protected: - ui_selection_callback_impl_base(bool activate = true) : m_active() {ui_selection_callback_activate(activate);} - ~ui_selection_callback_impl_base() {ui_selection_callback_activate(false);} - - void ui_selection_callback_activate(bool state = true) { - if (state != m_active) { - m_active = state; - static_api_ptr_t api; - if (state) api->register_callback(this); - else api->unregister_callback(this); - } - } - - //avoid pure virtual function calls in rare cases - provide a dummy implementation - void on_selection_changed(const pfc::list_base_const_t & p_selection) {} - - PFC_CLASS_NOT_COPYABLE_EX(ui_selection_callback_impl_base); -private: - bool m_active; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/unpack.h b/tools/vio2sf/src/foobar/foobar2000/SDK/unpack.h deleted file mode 100644 index 7e2be58cb..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/unpack.h +++ /dev/null @@ -1,22 +0,0 @@ -//! Service providing "unpacker" functionality - processes "packed" file (such as a zip file containing a single media file inside) to allow its contents to be accessed transparently.\n -//! To access existing unpacker implementations, use unpacker::g_open helper function.\n -//! To register your own implementation, use unpacker_factory_t template. -class NOVTABLE unpacker : public service_base { -public: - //! Attempts to open specified file for unpacking, creates interface to virtual file with uncompressed data on success. When examined file doesn't appear to be one of formats supported by this unpacker implementation, throws exception_io_data. - //! @param p_out Receives interface to virtual file with uncompressed data on success. - //! @param p_source Source file to process. - //! @param p_abort abort_callback object signaling user aborting the operation. - virtual void open(service_ptr_t & p_out,const service_ptr_t & p_source,abort_callback & p_abort) = 0; - - //! Static helper querying existing unpacker implementations until one that successfully opens specified file is found. Attempts to open specified file for unpacking, creates interface to virtual file with uncompressed data on success. When examined file doesn't appear to be one of formats supported by registered unpacker implementations, throws exception_io_data. - //! @param p_out Receives interface to virtual file with uncompressed data on success. - //! @param p_source Source file to process. - //! @param p_abort abort_callback object signaling user aborting the operation. - static void g_open(service_ptr_t & p_out,const service_ptr_t & p_source,abort_callback & p_abort); - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(unpacker); -}; - -template -class unpacker_factory_t : public service_factory_single_t {}; diff --git a/tools/vio2sf/src/foobar/foobar2000/SDK/vis.h b/tools/vio2sf/src/foobar/foobar2000/SDK/vis.h deleted file mode 100644 index 803311386..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/SDK/vis.h +++ /dev/null @@ -1,78 +0,0 @@ -//! This class provides abstraction for retrieving visualisation data. Instances of visualisation_stream being created/released serve as an indication for visualisation backend to process currently played audio data or shut down when there are no visualisation clients active.\n -//! Use visualisation_manager::create_stream to instantiate. -class NOVTABLE visualisation_stream : public service_base { -public: - //! Retrieves absolute playback time since last playback start or seek. You typically pass value retrieved by this function - optionally with offset added - to other visualisation_stream methods. - virtual bool get_absolute_time(double & p_value) = 0; - - //! Retrieves an audio chunk starting at specified offset (see get_absolute_time()), of specified length. - //! @returns False when requested timestamp is out of available range, true on success. - virtual bool get_chunk_absolute(audio_chunk & p_chunk,double p_offset,double p_requested_length) = 0; - //! Retrieves spectrum for audio data at specified offset (see get_absolute_time()), with specified FFT size. - //! @param p_chunk Receives spectrum data. audio_chunk type is used for consistency (since required functionality is identical to provided by audio_chunk), the data is *not* PCM. Returned sample count is equal to half of FFT size; channels and sample rate are as in audio stream the spectrum was generated from. - //! @param p_offset Timestamp of spectrum to retrieve. See get_absolute_time(). - //! @param p_fft_size FFT size to use for spectrum generation. Must be a power of 2. - //! @returns False when requested timestamp is out of available range, true on success. - virtual bool get_spectrum_absolute(audio_chunk & p_chunk,double p_offset,unsigned p_fft_size) = 0; - - //! Generates fake audio chunk to display when get_chunk_absolute() fails - e.g. shortly after visualisation_stream creation data for currently played audio might not be available yet. - //! Throws std::exception derivatives on failure. - virtual void make_fake_chunk_absolute(audio_chunk & p_chunk,double p_offset,double p_requested_length) = 0; - //! Generates fake spectrum to display when get_spectrum_absolute() fails - e.g. shortly after visualisation_stream creation data for currently played audio might not be available yet. - //! Throws std::exception derivatives on failure. - virtual void make_fake_spectrum_absolute(audio_chunk & p_chunk,double p_offset,unsigned p_fft_size) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(visualisation_stream,service_base); -}; - -//! New in 0.9.5. -class NOVTABLE visualisation_stream_v2 : public visualisation_stream { -public: - virtual void request_backlog(double p_time) = 0; - virtual void set_channel_mode(t_uint32 p_mode) = 0; - - enum { - channel_mode_default = 0, - channel_mode_mono, - channel_mode_frontonly, - channel_mode_backonly, - }; - - FB2K_MAKE_SERVICE_INTERFACE(visualisation_stream_v2,visualisation_stream); -}; - -//! New in 0.9.5.2. -class NOVTABLE visualisation_stream_v3 : public visualisation_stream_v2 { -public: - virtual void chunk_to_spectrum(audio_chunk const & chunk, audio_chunk & spectrum, double centerOffset) = 0; - - FB2K_MAKE_SERVICE_INTERFACE(visualisation_stream_v3,visualisation_stream_v2); -}; - -//! Entrypoint service for visualisation processing; use this to create visualisation_stream objects that can be used to retrieve properties of currently played audio. \n -//! Implemented by core; do not reimplement.\n -//! Use static_api_ptr_t to access it, e.g. static_api_ptr_t()->create_stream(mystream,0); -class NOVTABLE visualisation_manager : public service_base { -public: - //! Creates a visualisation_stream object. See visualisation_stream for more info. - //! @param p_out Receives newly created visualisation_stream instance. - //! @param p_flags Combination of one or more KStreamFlag* values. Currently only KStreamFlagNewFFT is defined. - //! It's recommended that you set p_flags to KStreamFlagNewFFT to get the new FFT behavior (better quality and result normalization), the old behavior for null flags is preserved for compatibility with old components that rely on it. - virtual void create_stream(service_ptr_t & p_out,unsigned p_flags) = 0; - - enum { - //! New FFT behavior for spectrum-generating methods, available in 0.9.5.2 and newer: output normalized to 0..1, Gauss window used instead of rectangluar (better quality / less aliasing). - //! It's recommended to always set this flag. The old behavior is preserved for backwards compatibility. - KStreamFlagNewFFT = 1 << 0, - }; - - - //! Wrapper around non-template create_stream(); retrieves one of newer visualisation_stream_* interfaces rather than base visualisation_stream interface. Throws exception_service_extension_not_found() when running too old foobar2000 version for the requested interface. - template - void create_stream(t_streamptr & out, unsigned flags) { - visualisation_stream::ptr temp; create_stream(temp, flags); - if (!temp->service_query_t(out)) throw exception_service_extension_not_found(); - } - - FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(visualisation_manager); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/foobar2000_component_client/component_client.cpp b/tools/vio2sf/src/foobar/foobar2000/foobar2000_component_client/component_client.cpp deleted file mode 100644 index 1b1c919da..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/foobar2000_component_client/component_client.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "../SDK/foobar2000.h" -#include "../SDK/component.h" - -static HINSTANCE g_hIns; - -static pfc::string_simple g_name,g_full_path; - -static bool g_services_available = false, g_initialized = false; - - - -namespace core_api -{ - - HINSTANCE get_my_instance() - { - return g_hIns; - } - - HWND get_main_window() - { - return g_api->get_main_window(); - } - pcchar get_my_file_name() - { - return g_name; - } - - pcchar get_my_full_path() - { - return g_full_path; - } - - bool are_services_available() - { - return g_services_available; - } - bool assert_main_thread() - { - return (g_services_available && g_api) ? g_api->assert_main_thread() : true; - } - - void ensure_main_thread() { - if (!assert_main_thread()) throw exception_wrong_thread(); - } - - bool is_main_thread() - { - return (g_services_available && g_api) ? g_api->is_main_thread() : true; - } - pcchar get_profile_path() - { - return (g_services_available && g_api) ? g_api->get_profile_path() : 0; - } - - bool is_shutting_down() - { - return (g_services_available && g_api) ? g_api->is_shutting_down() : g_initialized; - } - bool is_initializing() - { - return (g_services_available && g_api) ? g_api->is_initializing() : !g_initialized; - } -} - -namespace { - class foobar2000_client_impl : public foobar2000_client - { - public: - t_uint32 get_version() {return FOOBAR2000_CLIENT_VERSION;} - pservice_factory_base get_service_list() {return service_factory_base::__internal__list;} - - void get_config(stream_writer * p_stream,abort_callback & p_abort) { - cfg_var::config_write_file(p_stream,p_abort); - } - - void set_config(stream_reader * p_stream,abort_callback & p_abort) { - cfg_var::config_read_file(p_stream,p_abort); - } - - void set_library_path(const char * path,const char * name) { - g_full_path = path; - g_name = name; - } - - void services_init(bool val) { - if (val) g_initialized = true; - g_services_available = val; - } - - bool is_debug() { -#ifdef _DEBUG - return true; -#else - return false; -#endif - } - }; -} - -static foobar2000_client_impl g_client; - -extern "C" -{ - __declspec(dllexport) foobar2000_client * _cdecl foobar2000_get_interface(foobar2000_api * p_api,HINSTANCE hIns) - { - g_hIns = hIns; - g_api = p_api; - - return &g_client; - } -} - -#if 0 -BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle, IN DWORD nReason, IN LPVOID Reserved ) -{ - BOOLEAN bSuccess = TRUE; - - switch ( nReason ) { - case DLL_PROCESS_ATTACH: - - DisableThreadLibraryCalls( hDllHandle ); - - break; - - case DLL_PROCESS_DETACH: - - break; - } - return TRUE; -} -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/foobar2000_component_client/foobar2000_component_client.vcproj b/tools/vio2sf/src/foobar/foobar2000/foobar2000_component_client/foobar2000_component_client.vcproj deleted file mode 100644 index c5ccc4a16..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/foobar2000_component_client/foobar2000_component_client.vcproj +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/COM_utils.h b/tools/vio2sf/src/foobar/foobar2000/helpers/COM_utils.h deleted file mode 100644 index b0704c6b4..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/COM_utils.h +++ /dev/null @@ -1,7 +0,0 @@ -#define FB2K_COM_CATCH catch(exception_com const & e) {return e.get_code();} catch(std::bad_alloc) {return E_OUTOFMEMORY;} catch(pfc::exception_invalid_params) {return E_INVALIDARG;} catch(...) {return E_UNEXPECTED;} - -#define COM_QI_BEGIN() HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,void ** ppvObject) { if (ppvObject == NULL) return E_INVALIDARG; -#define COM_QI_ENTRY(IWhat) { if (iid == IID_##IWhat) {IWhat * temp = this; temp->AddRef(); * ppvObject = temp; return S_OK;} } -#define COM_QI_END() return E_NOINTERFACE; } - -#define COM_QI_CHAIN(Parent) { HRESULT status = Parent::QueryInterface(iid, ppvObject); if (SUCCEEDED(status)) return status; } diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/CallForwarder.h b/tools/vio2sf/src/foobar/foobar2000/helpers/CallForwarder.h deleted file mode 100644 index 53608d6c1..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/CallForwarder.h +++ /dev/null @@ -1,32 +0,0 @@ -namespace CF { - template class CallForwarder { - public: - CallForwarder(TWhat * ptr) { m_ptr.new_t(ptr); } - - void Orphan() {*m_ptr = NULL;} - bool IsValid() const { return *m_ptr != NULL; } - bool IsEmpty() const { return !IsValid(); } - - TWhat * operator->() const { - PFC_ASSERT( IsValid() ); - return *m_ptr; - } - - TWhat & operator*() const { - PFC_ASSERT( IsValid() ); - return **m_ptr; - } - - private: - pfc::rcptr_t m_ptr; - }; - - template class CallForwarderMaster : public CallForwarder { - public: - CallForwarderMaster(TWhat * ptr) : CallForwarder(ptr) {} - ~CallForwarderMaster() { Orphan(); } - - PFC_CLASS_NOT_COPYABLE(CallForwarderMaster, CallForwarderMaster); - }; - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/IDataObjectUtils.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/IDataObjectUtils.cpp deleted file mode 100644 index ed0bff6a7..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/IDataObjectUtils.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include "stdafx.h" - - -HRESULT IDataObjectUtils::DataBlockToSTGMEDIUM(const void * blockPtr, t_size blockSize, STGMEDIUM * medium, DWORD tymed, bool bHere) throw() { - try { - if (bHere) { - switch(tymed) { - case TYMED_ISTREAM: - { - if (medium->pstm == NULL) return E_INVALIDARG; - ULONG written = 0; - HRESULT state; - state = medium->pstm->Write(blockPtr, pfc::downcast_guarded(blockSize),&written); - if (FAILED(state)) return state; - if (written != blockSize) return STG_E_MEDIUMFULL; - return S_OK; - } - default: - return DV_E_TYMED; - } - } else { - if (tymed & TYMED_HGLOBAL) { - HGLOBAL hMem = HGlobalFromMemblock(blockPtr, blockSize); - if (hMem == NULL) return E_OUTOFMEMORY; - medium->tymed = TYMED_HGLOBAL; - medium->hGlobal = hMem; - medium->pUnkForRelease = NULL; - return S_OK; - } - if (tymed & TYMED_ISTREAM) { - HRESULT state; - HGLOBAL hMem = HGlobalFromMemblock(blockPtr, blockSize); - if (hMem == NULL) return E_OUTOFMEMORY; - medium->tymed = TYMED_ISTREAM; - pfc::com_ptr_t stream; - if (FAILED( state = CreateStreamOnHGlobal(hMem,TRUE,stream.receive_ptr()) ) ) { - GlobalFree(hMem); - return state; - } - { - LARGE_INTEGER wtf = {}; - if (FAILED( state = stream->Seek(wtf,STREAM_SEEK_END,NULL) ) ) { - return state; - } - } - medium->pstm = stream.get_ptr(); - medium->pUnkForRelease = stream.detach(); - return S_OK; - } - return DV_E_TYMED; - } - } catch(pfc::exception_not_implemented) { - return E_NOTIMPL; - } catch(std::bad_alloc) { - return E_OUTOFMEMORY; - } catch(...) { - return E_UNEXPECTED; - } -} - - -HGLOBAL IDataObjectUtils::HGlobalFromMemblock(const void * ptr,t_size size) { - HGLOBAL handle = GlobalAlloc(GMEM_MOVEABLE,size); - if (handle != NULL) { - void * destptr = GlobalLock(handle); - if (destptr == NULL) { - GlobalFree(handle); - handle = NULL; - } else { - memcpy(destptr,ptr,size); - GlobalUnlock(handle); - } - } - return handle; -} - -HRESULT IDataObjectUtils::ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, pfc::array_t & out) { - FORMATETC fmt = {}; - fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = index; - fmt.tymed = TYMED_HGLOBAL | TYMED_ISTREAM; - - STGMEDIUM med = {}; - HRESULT state; - if (FAILED( state = obj->GetData(&fmt,&med) ) ) return state; - ReleaseStgMediumScope relScope(&med); - return STGMEDIUMToDataBlock(med, out); -} - -HRESULT IDataObjectUtils::STGMEDIUMToDataBlock(const STGMEDIUM & med, pfc::array_t & out) { - switch(med.tymed) { - case TYMED_HGLOBAL: - { - CGlobalLockScope lock(med.hGlobal); - out.set_data_fromptr( (const t_uint8*) lock.GetPtr(), lock.GetSize() ); - } - return S_OK; - case TYMED_ISTREAM: - { - HRESULT state; - IStream * stream = med.pstm; - LARGE_INTEGER offset = {}; - STATSTG stats = {}; - if (FAILED( state = stream->Stat(&stats,STATFLAG_NONAME ) ) ) return state; - t_size toRead = pfc::downcast_guarded(stats.cbSize.QuadPart); - out.set_size(toRead); - if (FAILED( state = stream->Seek(offset,STREAM_SEEK_SET,NULL) ) ) return state; - ULONG cbRead = 0; - if (FAILED( state = stream->Read(out.get_ptr(), pfc::downcast_guarded(toRead), &cbRead) ) ) return state; - if (cbRead != toRead) return E_UNEXPECTED; - } - return S_OK; - default: - return DV_E_TYMED; - } -} - -HRESULT IDataObjectUtils::ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, pfc::array_t & out) { - return ExtractDataObjectContent(obj, format, DVASPECT_CONTENT, -1, out); -} - -HRESULT IDataObjectUtils::ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index) { - FORMATETC fmt = {}; - fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = index; - for(t_uint32 walk = 0; walk < 32; ++walk) { - const DWORD tymed = 1 << walk; - if ((ExtractDataObjectContent_SupportedTymeds & tymed) != 0) { - fmt.tymed = tymed; - HRESULT state = obj->QueryGetData(&fmt); - if (SUCCEEDED(state)) return S_OK; - if (state != DV_E_TYMED) return state; - } - } - return E_FAIL; -} - -HRESULT IDataObjectUtils::ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format) { - return ExtractDataObjectContentTest(obj,format,DVASPECT_CONTENT,-1); -} - -HRESULT IDataObjectUtils::ExtractDataObjectString(pfc::com_ptr_t obj, pfc::string_base & out) { - pfc::array_t data; - HRESULT state; - state = ExtractDataObjectContent(obj,CF_UNICODETEXT,data); - if (SUCCEEDED(state)) { - out = pfc::stringcvt::string_utf8_from_os_ex( (const wchar_t*) data.get_ptr(), data.get_size() / sizeof(wchar_t) ); - return S_OK; - } - state = ExtractDataObjectContent(obj,CF_TEXT,data); - if (SUCCEEDED(state)) { - out = pfc::stringcvt::string_utf8_from_os_ex( (const char*) data.get_ptr(), data.get_size() / sizeof(char) ); - return S_OK; - } - return E_FAIL; -} - -HRESULT IDataObjectUtils::SetDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, const void * data, t_size dataSize) { - STGMEDIUM med = {}; - FORMATETC fmt = {}; - fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = index; fmt.tymed = TYMED_HGLOBAL; - HRESULT state; - if (FAILED(state = DataBlockToSTGMEDIUM(data,dataSize,&med,TYMED_HGLOBAL,false))) return state; - return obj->SetData(&fmt,&med,TRUE); -} - -HRESULT IDataObjectUtils::SetDataObjectString(pfc::com_ptr_t obj, const char * str) { - pfc::stringcvt::string_wide_from_utf8 s(str); - return SetDataObjectContent(obj,CF_UNICODETEXT,DVASPECT_CONTENT,-1,s.get_ptr(), (s.length()+1) * sizeof(s[0])); -} - -HRESULT IDataObjectUtils::ExtractDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD & val) { - HRESULT state; - pfc::array_t buffer; - if (FAILED( state = ExtractDataObjectContent(obj, format, DVASPECT_CONTENT, -1, buffer) ) ) return state; - if (buffer.get_size() < sizeof(val)) return E_UNEXPECTED; - val = *(DWORD*) buffer.get_ptr(); - return S_OK; -} -HRESULT IDataObjectUtils::SetDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD val) { - return SetDataObjectContent(obj,format,DVASPECT_CONTENT,-1,&val,sizeof(val)); -} -HRESULT IDataObjectUtils::PasteSucceeded(pfc::com_ptr_t obj, DWORD effect) { - return SetDataObjectDWORD(obj, RegisterClipboardFormat(CFSTR_PASTESUCCEEDED), effect); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/IDataObjectUtils.h b/tools/vio2sf/src/foobar/foobar2000/helpers/IDataObjectUtils.h deleted file mode 100644 index fb69d9957..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/IDataObjectUtils.h +++ /dev/null @@ -1,183 +0,0 @@ -#include - -namespace IDataObjectUtils { - - class ReleaseStgMediumScope { - public: - ReleaseStgMediumScope(STGMEDIUM * medium) : m_medium(medium) {} - ~ReleaseStgMediumScope() {if (m_medium != NULL) ReleaseStgMedium(m_medium);} - private: - STGMEDIUM * m_medium; - - PFC_CLASS_NOT_COPYABLE_EX(ReleaseStgMediumScope) - }; - - static const DWORD DataBlockToSTGMEDIUM_SupportedTymeds = TYMED_ISTREAM | TYMED_HGLOBAL; - static const DWORD ExtractDataObjectContent_SupportedTymeds = TYMED_ISTREAM | TYMED_HGLOBAL; - - HRESULT DataBlockToSTGMEDIUM(const void * blockPtr, t_size blockSize, STGMEDIUM * medium, DWORD tymed, bool bHere) throw(); - - HGLOBAL HGlobalFromMemblock(const void * ptr,t_size size); - - HRESULT ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, pfc::array_t & out); - HRESULT ExtractDataObjectContent(pfc::com_ptr_t obj, UINT format, pfc::array_t & out); - - HRESULT ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index); - HRESULT ExtractDataObjectContentTest(pfc::com_ptr_t obj, UINT format); - - HRESULT ExtractDataObjectString(pfc::com_ptr_t obj, pfc::string_base & out); - HRESULT SetDataObjectString(pfc::com_ptr_t obj, const char * str); - - HRESULT SetDataObjectContent(pfc::com_ptr_t obj, UINT format, DWORD aspect, LONG index, const void * data, t_size dataSize); - - HRESULT STGMEDIUMToDataBlock(const STGMEDIUM & med, pfc::array_t & out); - - HRESULT ExtractDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD & val); - HRESULT SetDataObjectDWORD(pfc::com_ptr_t obj, UINT format, DWORD val); - - HRESULT PasteSucceeded(pfc::com_ptr_t obj, DWORD effect); - - class comparator_FORMATETC { - public: - static int compare(const FORMATETC & v1, const FORMATETC & v2) { - int val; - val = pfc::compare_t(v1.cfFormat,v2.cfFormat); if (val != 0) return val; - val = pfc::compare_t(v1.dwAspect,v2.dwAspect); if (val != 0) return val; - val = pfc::compare_t(v1.lindex, v2.lindex ); if (val != 0) return val; - return 0; - } - }; - - class CDataObjectBase : public IDataObject { - public: - COM_QI_BEGIN() - COM_QI_ENTRY(IUnknown) - COM_QI_ENTRY(IDataObject) - COM_QI_END() - - HRESULT STDMETHODCALLTYPE GetData(FORMATETC * formatetc, STGMEDIUM * medium) { - return GetData_internal(formatetc,medium,false); - } - - HRESULT STDMETHODCALLTYPE GetDataHere(FORMATETC * formatetc, STGMEDIUM * medium) { - return GetData_internal(formatetc,medium,true); - } - - HRESULT STDMETHODCALLTYPE QueryGetData(FORMATETC * formatetc) { - if (formatetc == NULL) return E_INVALIDARG; - - if ((DataBlockToSTGMEDIUM_SupportedTymeds & formatetc->tymed) == 0) return DV_E_TYMED; - - try { - return RenderDataTest(formatetc->cfFormat,formatetc->dwAspect,formatetc->lindex); - } FB2K_COM_CATCH; - } - - - HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(FORMATETC * in, FORMATETC * out) { - //check this again - if (in == NULL || out == NULL) - return E_INVALIDARG; - *out = *in; - return DATA_S_SAMEFORMATETC; - } - - HRESULT STDMETHODCALLTYPE EnumFormatEtc(DWORD dwDirection,IEnumFORMATETC ** ppenumFormatetc) { - if (dwDirection == DATADIR_GET) { - if (ppenumFormatetc == NULL) return E_INVALIDARG; - return CreateIEnumFORMATETC(ppenumFormatetc); - } else if (dwDirection == DATADIR_SET) { - return E_NOTIMPL; - } else { - return E_INVALIDARG; - } - } - - HRESULT STDMETHODCALLTYPE SetData(FORMATETC * pFormatetc, STGMEDIUM * pmedium, BOOL fRelease) { - try { - ReleaseStgMediumScope relScope(fRelease ? pmedium : NULL); - if (pFormatetc == NULL || pmedium == NULL) return E_INVALIDARG; - - /*TCHAR buf[256]; - if (GetClipboardFormatName(pFormatetc->cfFormat,buf,tabsize(buf)) > 0) { - buf[tabsize(buf)-1] = 0; - OutputDebugString(TEXT("SetData: ")); OutputDebugString(buf); OutputDebugString(TEXT("\n")); - } else { - OutputDebugString(TEXT("SetData: unknown clipboard format.\n")); - }*/ - - pfc::array_t temp; - HRESULT state = STGMEDIUMToDataBlock(*pmedium,temp); - if (FAILED(state)) return state; - m_entries.set(*pFormatetc,temp); - return S_OK; - } FB2K_COM_CATCH; - } - HRESULT STDMETHODCALLTYPE DAdvise(FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection) {return OLE_E_ADVISENOTSUPPORTED;} - HRESULT STDMETHODCALLTYPE DUnadvise(DWORD dwConnection) {return OLE_E_ADVISENOTSUPPORTED;} - HRESULT STDMETHODCALLTYPE EnumDAdvise(IEnumSTATDATA ** ppenumAdvise) {return OLE_E_ADVISENOTSUPPORTED;} - protected: - virtual HRESULT RenderData(UINT format,DWORD aspect,LONG dataIndex,stream_writer_formatter<> & out) const { - FORMATETC fmt = {}; - fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = dataIndex; - const pfc::array_t * entry = m_entries.query_ptr(fmt); - if (entry != NULL) { - out.write_raw(entry->get_ptr(), entry->get_size()); - return S_OK; - } - return DV_E_FORMATETC; - } - virtual HRESULT RenderDataTest(UINT format,DWORD aspect, LONG dataIndex) const { - FORMATETC fmt = {}; - fmt.cfFormat = format; fmt.dwAspect = aspect; fmt.lindex = dataIndex; - if (m_entries.have_item(fmt)) return S_OK; - return DV_E_FORMATETC; - } - typedef pfc::list_base_t TFormatList; - - static void AddFormat(TFormatList & out,UINT code) { - FORMATETC fmt = {}; - fmt.dwAspect = DVASPECT_CONTENT; - fmt.lindex = -1; - fmt.cfFormat = code; - for(t_size medWalk = 0; medWalk < 32; ++medWalk) { - const DWORD med = 1 << medWalk; - if ((DataBlockToSTGMEDIUM_SupportedTymeds & med) != 0) { - fmt.tymed = med; - out.add_item(fmt); - } - } - } - - virtual void EnumFormats(TFormatList & out) const { - pfc::avltree_t formats; - for(t_entries::const_iterator walk = m_entries.first(); walk.is_valid(); ++walk) { - formats.add_item( walk->m_key.cfFormat ); - } - for(pfc::const_iterator walk = formats.first(); walk.is_valid(); ++walk) { - AddFormat(out, *walk); - } - } - HRESULT CreateIEnumFORMATETC(IEnumFORMATETC ** outptr) const throw() { - try { - pfc::list_t out; - EnumFormats(out); - return SHCreateStdEnumFmtEtc((UINT)out.get_count(), out.get_ptr(), outptr); - } FB2K_COM_CATCH; - } - private: - HRESULT GetData_internal(FORMATETC * formatetc, STGMEDIUM * medium,bool bHere) { - if (formatetc == NULL || medium == NULL) return E_INVALIDARG; - - try { - stream_writer_formatter_simple<> out; - HRESULT hr = RenderData(formatetc->cfFormat,formatetc->dwAspect,formatetc->lindex,out); - if (FAILED(hr)) return hr; - return DataBlockToSTGMEDIUM(out.m_buffer.get_ptr(),out.m_buffer.get_size(),medium,formatetc->tymed,bHere); - } FB2K_COM_CATCH; - } - - typedef pfc::map_t, comparator_FORMATETC> t_entries; - t_entries m_entries; - }; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/StdAfx.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/StdAfx.cpp deleted file mode 100644 index 9dc5b543a..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/StdAfx.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// foobar2000_sdk_helpers.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/StdAfx.h b/tools/vio2sf/src/foobar/foobar2000/helpers/StdAfx.h deleted file mode 100644 index 50a4e7bf8..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/StdAfx.h +++ /dev/null @@ -1,22 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_) -#define AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -#include "../SDK/foobar2000.h" -#include "helpers.h" - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_) diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/ThreadUtils.h b/tools/vio2sf/src/foobar/foobar2000/helpers/ThreadUtils.h deleted file mode 100644 index 6495410a8..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/ThreadUtils.h +++ /dev/null @@ -1,135 +0,0 @@ -namespace ThreadUtils { - static void WaitAbortable(HANDLE ev, abort_callback & abort, DWORD timeout = INFINITE) { - const HANDLE handles[2] = {ev, abort.get_abort_event()}; - SetLastError(0); - const DWORD status = WaitForMultipleObjects(2, handles, FALSE, INFINITE); - switch(status) { - case WAIT_OBJECT_0: - break; - case WAIT_OBJECT_0 + 1: - throw exception_aborted(); - default: - throw exception_win32(GetLastError()); - } - } - - template - class CObjectQueue { - public: - CObjectQueue() { m_event.create(true,false); } - - template void Add(const TSource & source) { - insync(m_sync); - m_content.add_item(source); - if (m_content.get_count() == 1) m_event.set_state(true); - } - template void Get(TDestination & out, abort_callback & abort) { - WaitAbortable(m_event.get(), abort); - insync(m_sync); - pfc::const_iterator iter = m_content.first(); - pfc::dynamic_assert( iter.is_valid() ); - out = *iter; - m_content.remove(iter); - if (m_content.get_count() == 0) m_event.set_state(false); - } - - private: - win32_event m_event; - critical_section m_sync; - pfc::chain_list_v2_t m_content; - }; - - - template - class CSingleThreadWrapper : protected pfc::thread { - private: - enum status { - success, - fail, - fail_io, - fail_io_data, - fail_abort, - }; - protected: - class command { - protected: - command() : m_status(success), m_abort(), m_completionEvent() {} - virtual void executeImpl(TBase &) {} - virtual ~command() {} - public: - void execute(TBase & obj) { - try { - executeImpl(obj); - m_status = success; - } catch(exception_aborted const & e) { - m_status = fail_abort; m_statusMsg = e.what(); - } catch(exception_io_data const & e) { - m_status = fail_io_data; m_statusMsg = e.what(); - } catch(exception_io const & e) { - m_status = fail_io; m_statusMsg = e.what(); - } catch(std::exception const & e) { - m_status = fail; m_statusMsg = e.what(); - } - SetEvent(m_completionEvent); - } - void rethrow() const { - switch(m_status) { - case fail: - throw pfc::exception(m_statusMsg); - case fail_io: - throw exception_io(m_statusMsg); - case fail_io_data: - throw exception_io_data(m_statusMsg); - case fail_abort: - throw exception_aborted(); - case success: - break; - default: - throw pfc::exception_bug_check_v2(); - } - } - status m_status; - pfc::string8 m_statusMsg; - HANDLE m_completionEvent; - abort_callback * m_abort; - }; - - typedef pfc::rcptr_t command_ptr; - - CSingleThreadWrapper() { - m_completionEvent.create(true,false); - start(); - } - - ~CSingleThreadWrapper() { - m_threadAbort.abort(); - waitTillDone(); - } - - void invokeCommand(command_ptr cmd, abort_callback & abort) { - abort.check(); - m_completionEvent.set_state(false); - pfc::vartoggle_t abortToggle(cmd->m_abort, &abort); - pfc::vartoggle_t eventToggle(cmd->m_completionEvent, m_completionEvent.get() ); - m_commands.Add(cmd); - m_completionEvent.wait_for(-1); - //WaitAbortable(m_completionEvent.get(), abort); - cmd->rethrow(); - } - - private: - void threadProc() { - try { - TBase instance; - for(;;) { - command_ptr cmd; - m_commands.Get(cmd, m_threadAbort); - cmd->execute(instance); - } - } catch(...) {} - } - win32_event m_completionEvent; - CObjectQueue m_commands; - abort_callback_impl m_threadAbort; - }; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/VisUtils.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/VisUtils.cpp deleted file mode 100644 index 069244d46..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/VisUtils.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "stdafx.h" - -namespace VisUtils { - void PrepareFFTChunk(audio_chunk const & source, audio_chunk & out, double centerOffset) { - const t_size channels = source.get_channel_count(); - const t_uint32 sampleRate = source.get_sample_rate(); - pfc::dynamic_assert( sampleRate > 0 ); - out.set_channels(channels, source.get_channel_config()); - out.set_sample_rate(sampleRate); - const t_size inSize = source.get_sample_count(); - const t_size fftSize = MatchFFTSize(inSize); - out.set_sample_count(fftSize); - out.set_data_size(fftSize * channels); - if (fftSize >= inSize) { //rare case with *REALLY* small input - pfc::memcpy_t( out.get_data(), source.get_data(), inSize * channels ); - pfc::memset_null_t( out.get_data() + inSize * channels, (fftSize - inSize) * channels ); - } else { //inSize > fftSize, we're using a subset of source chunk for the job, pick a subset around centerOffset. - const double baseOffset = pfc::max_t(0, centerOffset - 0.5 * (double)fftSize / (double)sampleRate); - const t_size baseSample = pfc::min_t( (t_size) audio_math::time_to_samples(baseOffset, sampleRate), inSize - fftSize); - pfc::memcpy_t( out.get_data(), source.get_data() + baseSample * channels, fftSize * channels); - } - } - - bool IsValidFFTSize(t_size p_size) { - return p_size >= 2 && (p_size & (p_size - 1)) == 0; - } - - t_size MatchFFTSize(t_size samples) { - if (samples <= 2) return 2; - t_size mask = 1; - while(!IsValidFFTSize(samples)) { - samples &= ~mask; mask <<= 1; - } - return samples; - } -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/VisUtils.h b/tools/vio2sf/src/foobar/foobar2000/helpers/VisUtils.h deleted file mode 100644 index 973fb3fcb..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/VisUtils.h +++ /dev/null @@ -1,8 +0,0 @@ -namespace VisUtils { - //! Turns an arbitrary audio_chunk into a valid chunk to run FFT on, with proper sample count etc. - //! @param centerOffset Time offset (in seconds) inside the source chunk to center the output on, in case the FFT window is smaller than input data. - void PrepareFFTChunk(audio_chunk const & source, audio_chunk & out, double centerOffset); - - bool IsValidFFTSize(t_size size); - t_size MatchFFTSize(t_size samples); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/album_art_helpers.h b/tools/vio2sf/src/foobar/foobar2000/helpers/album_art_helpers.h deleted file mode 100644 index e1e669335..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/album_art_helpers.h +++ /dev/null @@ -1,109 +0,0 @@ -//! Helper class to load album art from a separate thread (without lagging GUI). In most scenarios you will want to use CAlbumArtLoader instead of deriving from CAlbumArtLoaderBase, unless you want to additionally process the images as they are loaded. -//! All methods meant to be called from the main thread. -//! IMPORTANT: derived classes must call Abort() in their own destructor rather than relying on CAlbumArtLoaderBase destructor, since the thread calls virtual functions! -class CAlbumArtLoaderBase : private CSimpleThread { -public: - CAlbumArtLoaderBase() : m_api(static_api_ptr_t()->instantiate()) {} - ~CAlbumArtLoaderBase() {Abort();} - - //! Requests the loader to process specific album art type. See album_art_ids namespace for defined types. - void AddType(const GUID & p_what) { - if (!HaveType(p_what)) { - Abort(); - m_requestIds.add_item(p_what); - m_api->close(); - } - } - bool HaveType(const GUID & p_what) const { - return m_requestIds.have_item(p_what); - } - - void ResetTypes() { - Abort(); - m_requestIds.remove_all(); - m_api->close(); - } - - void Abort() { - AbortThread(); - m_notify.release(); - } - - //! Completion notify code is 1 when content has changed, 0 when content is the same as before the request (like, advanced to another track with the same album art data). - void Request(const char * p_path,completion_notify_ptr p_notify = NULL) { - Abort(); - m_requestPath = p_path; - m_notify = p_notify; - StartThread(); - } - - bool IsReady() const {return !IsWorking();} - bool IsWorking() const {return IsThreadActive();} - -protected: - virtual void OnContent(const GUID & p_what,album_art_data_ptr p_data,abort_callback & p_abort) {} - virtual void OnContentReset() {} - -private: - unsigned ThreadProc(abort_callback & p_abort) { - try { - return ProcessRequest(p_abort); - } catch(exception_aborted) { - return 0; - } catch(std::exception const & e) { - console::complain("Album Art loading failure", e); - return 0; - } - } - - unsigned ProcessRequest(abort_callback & p_abort) { - if (m_api->open(m_requestPath,p_abort)) { - OnContentReset(); - for(pfc::chain_list_v2_t::const_iterator walk = m_requestIds.first(); walk.is_valid(); ++walk) { - album_art_data_ptr data; - try { - data = m_api->query(*walk,p_abort); - } catch(exception_io const & e) { - console::complain("Requested Album Art entry could not be retrieved", e); - continue; - } - pfc::dynamic_assert( data.is_valid() ); - OnContent(*walk,data,p_abort); - } - return 1; - } else { - return 0; - } - } - void ThreadDone(unsigned p_code) { - //release our notify ptr before triggering callbacks, they might fire another query from inside that - completion_notify_ptr temp; temp << m_notify; - if (temp.is_valid()) temp->on_completion(p_code); - } - - pfc::string8 m_requestPath; - pfc::chain_list_v2_t m_requestIds; - - completion_notify_ptr m_notify; - - const album_art_manager_instance_ptr m_api; - - PFC_CLASS_NOT_COPYABLE_EX(CAlbumArtLoaderBase); -}; - -class CAlbumArtLoader : public CAlbumArtLoaderBase { -public: - ~CAlbumArtLoader() {Abort();} - bool Query(const GUID & p_what, album_art_data_ptr & p_data) const { - pfc::dynamic_assert( IsReady() ); - return m_content.query(p_what,p_data); - } -protected: - void OnContentReset() { - m_content.remove_all(); - } - void OnContent(const GUID & p_what,album_art_data_ptr p_data,abort_callback & p_abort) { - m_content.set(p_what,p_data); - } - pfc::map_t m_content; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/bitreader_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/bitreader_helper.h deleted file mode 100644 index 4af87efd0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/bitreader_helper.h +++ /dev/null @@ -1,122 +0,0 @@ -namespace bitreader_helper { - - inline static size_t extract_bit(const t_uint8 * p_stream,size_t p_offset) { - return (p_stream[p_offset>>3] >> (7-(p_offset&7)))&1; - } - - static size_t extract_int(const t_uint8 * p_stream,size_t p_base,size_t p_width) { - size_t ret = 0; - size_t offset = p_base; - for(size_t bit=0;bit - t_ret read_t(t_size p_bits) { - t_ret ret = 0; - for(t_size bit=0;bit>3] >> (7-(m_bitptr&7)))&1; - m_bitptr++; - } - return ret; - } - - t_size read(t_size p_bits) {return read_t(p_bits);} - - inline t_size get_bitptr() const {return m_bitptr;} - - inline bool read_bit() { - bool state = ( (m_ptr[m_bitptr>>3] >> (7-(m_bitptr&7)))&1 ) != 0; - m_bitptr++; - return state; - } - -private: - - const t_uint8 * m_ptr; - t_size m_bitptr; -}; - -class bitreader_fromfile -{ -public: - inline bitreader_fromfile(service_ptr_t const& p_file) : m_file(p_file), m_buffer_ptr(0) {} - - t_size read(t_size p_bits,abort_callback & p_abort) { - t_size ret = 0; - for(t_size bit=0;bitread_object(&m_buffer,1,p_abort); - - ret <<= 1; - ret |= (m_buffer >> (7-m_buffer_ptr))&1; - m_buffer_ptr = (m_buffer_ptr+1) & 7; - } - return ret; - } - - void skip(t_size p_bits,abort_callback & p_abort) { - for(t_size bit=0;bitread_object(&m_buffer,1,p_abort); - m_buffer_ptr = (m_buffer_ptr+1) & 7; - } - } - - inline void byte_align() {m_buffer_ptr = 0;} - -private: - service_ptr_t m_file; - t_size m_buffer_ptr; - t_uint8 m_buffer; -}; - -class bitreader_limited -{ -public: - inline bitreader_limited(const t_uint8 * p_ptr,t_size p_base,t_size p_remaining) : m_reader(p_ptr,p_base), m_remaining(p_remaining) {} - - inline t_size get_bitptr() const {return m_reader.get_bitptr();} - - inline t_size get_remaining() const {return m_remaining;} - - inline void skip(t_size p_bits) { - if (p_bits > m_remaining) throw exception_io_data_truncation(); - m_remaining -= p_bits; - m_reader.skip(p_bits); - } - - t_size read(t_size p_bits) - { - if (p_bits > m_remaining) throw exception_io_data_truncation(); - m_remaining -= p_bits; - return m_reader.read(p_bits); - } - -private: - bitreader m_reader; - t_size m_remaining; -}; - -inline static t_size extract_bits(const t_uint8 * p_buffer,t_size p_base,t_size p_count) { - return bitreader(p_buffer,p_base).read(p_count); -} - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/cfg_guidlist.h b/tools/vio2sf/src/foobar/foobar2000/helpers/cfg_guidlist.h deleted file mode 100644 index dfdbae14e..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/cfg_guidlist.h +++ /dev/null @@ -1,29 +0,0 @@ -class cfg_guidlist : public cfg_var, public pfc::list_t -{ -public: - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) { - t_uint32 n, m = pfc::downcast_guarded(get_count()); - p_stream->write_lendian_t(m,p_abort); - for(n=0;nwrite_lendian_t(get_item(n),p_abort); - } - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - t_uint32 n,count; - p_stream->read_lendian_t(count,p_abort); - m_buffer.set_size(count); - for(n=0;nread_lendian_t(m_buffer[n],p_abort); - } catch(...) {m_buffer.set_size(0); throw;} - } - } - - void sort() {sort_t(pfc::guid_compare);} - - bool have_item_bsearch(const GUID & p_item) { - t_size dummy; - return bsearch_t(pfc::guid_compare,p_item,dummy); - } - -public: - cfg_guidlist(const GUID & p_guid) : cfg_var(p_guid) {} -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/clipboard.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/clipboard.cpp deleted file mode 100644 index 928ce1e0a..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/clipboard.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "stdafx.h" - -#ifdef UNICODE -#define CF_TCHAR CF_UNICODETEXT -#else -#define CF_TCHAR CF_TEXT -#endif - -namespace ClipboardHelper { - void SetRaw(UINT format,const void * data, t_size size) { - HANDLE buffer = GlobalAlloc(GMEM_DDESHARE,size); - if (buffer == NULL) throw std::bad_alloc(); - try { - CGlobalLockScope lock(buffer); - PFC_ASSERT(lock.GetSize() == size); - memcpy(lock.GetPtr(),data,size); - } catch(...) { - GlobalFree(buffer); throw; - } - - WIN32_OP(SetClipboardData(format,buffer) != NULL); - } - void SetString(const char * in) { - pfc::stringcvt::string_os_from_utf8 temp(in); - SetRaw(CF_TCHAR,temp.get_ptr(),(temp.length() + 1) * sizeof(TCHAR)); - } - - bool GetString(pfc::string_base & out) { - pfc::array_t temp; - if (!GetRaw(CF_TCHAR,temp)) return false; - out = pfc::stringcvt::string_utf8_from_os(reinterpret_cast(temp.get_ptr()),temp.get_size() / sizeof(TCHAR)); - return true; - } - bool IsTextAvailable() { - return IsClipboardFormatAvailable(CF_TCHAR) == TRUE; - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/clipboard.h b/tools/vio2sf/src/foobar/foobar2000/helpers/clipboard.h deleted file mode 100644 index f456ab1c9..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/clipboard.h +++ /dev/null @@ -1,40 +0,0 @@ -namespace ClipboardHelper { - - class OpenScope { - public: - OpenScope() : m_open(false) {} - ~OpenScope() {Close();} - void Open(HWND p_owner) { - Close(); - WIN32_OP(OpenClipboard(p_owner)); - m_open = true; - } - void Close() { - if (m_open) { - m_open = false; - CloseClipboard(); - } - } - private: - bool m_open; - - PFC_CLASS_NOT_COPYABLE_EX(OpenScope) - }; - - void SetRaw(UINT format,const void * buffer, t_size size); - void SetString(const char * in); - - bool GetString(pfc::string_base & out); - - template - bool GetRaw(UINT format,TArray & out) { - pfc::assert_byte_type(); - HANDLE data = GetClipboardData(format); - if (data == NULL) return false; - CGlobalLockScope lock(data); - out.set_size( lock.GetSize() ); - memcpy(out.get_ptr(), lock.GetPtr(), lock.GetSize() ); - return true; - } - bool IsTextAvailable(); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/create_directory_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/create_directory_helper.cpp deleted file mode 100644 index 14d03c1b5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/create_directory_helper.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "stdafx.h" - -namespace create_directory_helper -{ - static void create_path_internal(const char * p_path,t_size p_base,abort_callback & p_abort) { - pfc::string8_fastalloc temp; - for(t_size walk = p_base; p_path[walk]; walk++) { - if (p_path[walk] == '\\') { - temp.set_string(p_path,walk); - try {filesystem::g_create_directory(temp.get_ptr(),p_abort);} catch(exception_io_already_exists) {} - } - } - } - - static bool is_valid_netpath_char(char p_char) { - return pfc::char_is_ascii_alphanumeric(p_char) || p_char == '_' || p_char == '-'; - } - - static bool test_localpath(const char * p_path) { - if (pfc::strcmp_partial(p_path,"file://") == 0) p_path += strlen("file://"); - return pfc::char_is_ascii_alpha(p_path[0]) && - p_path[1] == ':' && - p_path[2] == '\\'; - } - static bool test_netpath(const char * p_path) { - if (pfc::strcmp_partial(p_path,"file://") == 0) p_path += strlen("file://"); - if (*p_path != '\\') return false; - p_path++; - if (*p_path != '\\') return false; - p_path++; - if (!is_valid_netpath_char(*p_path)) return false; - p_path++; - while(is_valid_netpath_char(*p_path)) p_path++; - if (*p_path != '\\') return false; - return true; - } - - void create_path(const char * p_path,abort_callback & p_abort) { - if (test_localpath(p_path)) { - t_size walk = 0; - if (pfc::strcmp_partial(p_path,"file://") == 0) walk += strlen("file://"); - create_path_internal(p_path,walk + 3,p_abort); - } else if (test_netpath(p_path)) { - t_size walk = 0; - if (pfc::strcmp_partial(p_path,"file://") == 0) walk += strlen("file://"); - while(p_path[walk] == '\\') walk++; - while(p_path[walk] != 0 && p_path[walk] != '\\') walk++; - while(p_path[walk] == '\\') walk++; - create_path_internal(p_path,walk,p_abort); - } else { - throw exception_io("Could not create directory structure; unknown path format"); - } - } - - static bool is_bad_dirchar(char c) - { - return c==' ' || c=='.'; - } - - void make_path(const char * parent,const char * filename,const char * extension,bool allow_new_dirs,pfc::string8 & out,bool really_create_dirs,abort_callback & p_abort) - { - out.reset(); - if (parent && *parent) - { - out = parent; - out.fix_dir_separator('\\'); - } - bool last_char_is_dir_sep = true; - while(*filename) - { -#ifdef WIN32 - if (allow_new_dirs && is_bad_dirchar(*filename)) - { - const char * ptr = filename+1; - while(is_bad_dirchar(*ptr)) ptr++; - if (*ptr!='\\' && *ptr!='/') out.add_string(filename,ptr-filename); - filename = ptr; - if (*filename==0) break; - } -#endif - if (pfc::is_path_bad_char(*filename)) - { - if (allow_new_dirs && (*filename=='\\' || *filename=='/')) - { - if (!last_char_is_dir_sep) - { - if (really_create_dirs) try{filesystem::g_create_directory(out,p_abort);}catch(exception_io_already_exists){} - out.add_char('\\'); - last_char_is_dir_sep = true; - } - } - else - out.add_char('_'); - } - else - { - out.add_byte(*filename); - last_char_is_dir_sep = false; - } - filename++; - } - if (out.length()>0 && out[out.length()-1]=='\\') - { - out.add_string("noname"); - } - if (extension && *extension) - { - out.add_char('.'); - out.add_string(extension); - } - } -} - -void create_directory_helper::format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,const char * spec,pfc::string8 & out) -{ - titleformat_text_filter_impl_filename_chars filter; - pfc::string8 temp; - handle->format_title_legacy(p_hook,temp,spec,&filter); - temp.replace_char('/','\\'); - temp.fix_filename_chars('_','\\'); - out = temp; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/create_directory_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/create_directory_helper.h deleted file mode 100644 index b15624196..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/create_directory_helper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _CREATE_DIRECTORY_HELPER_H_ -#define _CREATE_DIRECTORY_HELPER_H_ - -namespace create_directory_helper { - void create_path(const char * p_path,abort_callback & p_abort); - void make_path(const char * parent,const char * filename,const char * extension,bool allow_new_dirs,pfc::string8 & out,bool b_really_create_dirs,abort_callback & p_dir_create_abort); - void format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,const char * spec,pfc::string8 & out); -}; - -#endif//_CREATE_DIRECTORY_HELPER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_creator.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/cue_creator.cpp deleted file mode 100644 index 6b261ceaf..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_creator.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "stdafx.h" - - -namespace { - - class format_meta - { - public: - format_meta(const file_info & p_source,const char * p_name,bool p_allow_space = true) - { - p_source.meta_format(p_name,m_buffer); - m_buffer.replace_byte('\"','\''); - uReplaceString(m_buffer,pfc::string8(m_buffer),infinite,"\x0d\x0a",2,"\\",1,false); - if (!p_allow_space) m_buffer.replace_byte(' ','_'); - m_buffer.replace_nontext_chars(); - } - inline operator const char*() const {return m_buffer;} - private: - pfc::string8_fastalloc m_buffer; - }; -} - -static bool is_meta_same_everywhere(const cue_creator::t_entry_list & p_list,const char * p_meta) -{ - pfc::string8_fastalloc reference,temp; - - cue_creator::t_entry_list::const_iterator iter; - iter = p_list.first(); - if (!iter.is_valid()) return false; - if (!iter->m_infos.meta_format(p_meta,reference)) return false; - for(;iter.is_valid();++iter) - { - if (!iter->m_infos.meta_format(p_meta,temp)) return false; - if (strcmp(temp,reference)!=0) return false; - } - return true; -} - -static const char g_eol[] = "\r\n"; - - -namespace cue_creator -{ - void create(pfc::string_formatter & p_out,const t_entry_list & p_data) - { - if (p_data.get_count() == 0) return; - bool album_artist_global = is_meta_same_everywhere(p_data,"album artist"), - artist_global = is_meta_same_everywhere(p_data,"artist"), - album_global = is_meta_same_everywhere(p_data,"album"), - genre_global = is_meta_same_everywhere(p_data,"genre"), - date_global = is_meta_same_everywhere(p_data,"date"), - discid_global = is_meta_same_everywhere(p_data,"discid"), - comment_global = is_meta_same_everywhere(p_data,"comment"), - catalog_global = is_meta_same_everywhere(p_data,"catalog"), - songwriter_global = is_meta_same_everywhere(p_data,"songwriter"); - - if (genre_global) { - p_out << "REM GENRE " << format_meta(p_data.first()->m_infos,"genre") << g_eol; - } - if (date_global) { - p_out << "REM DATE " << format_meta(p_data.first()->m_infos,"date") << g_eol; - } - if (discid_global) { - p_out << "REM DISCID " << format_meta(p_data.first()->m_infos,"discid") << g_eol; - } - if (comment_global) { - p_out << "REM COMMENT " << format_meta(p_data.first()->m_infos,"comment") << g_eol; - } - if (catalog_global) { - p_out << "CATALOG " << format_meta(p_data.first()->m_infos,"catalog") << g_eol; - } - if (songwriter_global) { - p_out << "SONGWRITER \"" << format_meta(p_data.first()->m_infos,"songwriter") << "\"" << g_eol; - } - - if (album_artist_global) - { - p_out << "PERFORMER \"" << format_meta(p_data.first()->m_infos,"album artist") << "\"" << g_eol; - artist_global = false; - } - else if (artist_global) - { - p_out << "PERFORMER \"" << format_meta(p_data.first()->m_infos,"artist") << "\"" << g_eol; - } - if (album_global) - { - p_out << "TITLE \"" << format_meta(p_data.first()->m_infos,"album") << "\"" << g_eol; - } - - { - replaygain_info::t_text_buffer rgbuffer; - replaygain_info rg = p_data.first()->m_infos.get_replaygain(); - if (rg.format_album_gain(rgbuffer)) - p_out << "REM REPLAYGAIN_ALBUM_GAIN " << rgbuffer << g_eol; - if (rg.format_album_peak(rgbuffer)) - p_out << "REM REPLAYGAIN_ALBUM_PEAK " << rgbuffer << g_eol; - } - - pfc::string8 last_file; - - for(t_entry_list::const_iterator iter = p_data.first();iter.is_valid();++iter) - { - if (strcmp(last_file,iter->m_file) != 0) - { - p_out << "FILE \"" << iter->m_file << "\" WAVE" << g_eol; - last_file = iter->m_file; - } - - p_out << " TRACK " << pfc::format_int(iter->m_track_number,2) << " AUDIO" << g_eol; - - if (iter->m_infos.meta_find("title") != infinite) - p_out << " TITLE \"" << format_meta(iter->m_infos,"title") << "\"" << g_eol; - - if (!artist_global && iter->m_infos.meta_find("artist") != infinite) - p_out << " PERFORMER \"" << format_meta(iter->m_infos,"artist") << "\"" << g_eol; - - if (!songwriter_global && iter->m_infos.meta_find("songwriter") != infinite) { - p_out << " SONGWRITER \"" << format_meta(iter->m_infos,"songwriter") << "\"" << g_eol; - } - - if (iter->m_infos.meta_find("isrc") != infinite) { - p_out << " ISRC " << format_meta(iter->m_infos,"isrc") << g_eol; - } - - if (!date_global && iter->m_infos.meta_find("date") != infinite) { - p_out << " REM DATE " << format_meta(iter->m_infos,"date") << g_eol; - } - - - - { - replaygain_info::t_text_buffer rgbuffer; - replaygain_info rg = iter->m_infos.get_replaygain(); - if (rg.format_track_gain(rgbuffer)) - p_out << " REM REPLAYGAIN_TRACK_GAIN " << rgbuffer << g_eol; - if (rg.format_track_peak(rgbuffer)) - p_out << " REM REPLAYGAIN_TRACK_PEAK " << rgbuffer << g_eol; - } - - if (!iter->m_flags.is_empty()) { - p_out << " FLAGS " << iter->m_flags << g_eol; - } - - if (iter->m_index_list.m_positions[0] < iter->m_index_list.m_positions[1]) - { - if (iter->m_index_list.m_positions[0] < 0) - p_out << " PREGAP " << cuesheet_format_index_time(iter->m_index_list.m_positions[1] - iter->m_index_list.m_positions[0]) << g_eol; - else - p_out << " INDEX 00 " << cuesheet_format_index_time(iter->m_index_list.m_positions[0]) << g_eol; - } - - p_out << " INDEX 01 " << cuesheet_format_index_time(iter->m_index_list.m_positions[1]) << g_eol; - - for(unsigned n=2;nm_index_list.m_positions[n] > 0;n++) - { - p_out << " INDEX " << pfc::format_uint(n,2) << " " << cuesheet_format_index_time(iter->m_index_list.m_positions[n]) << g_eol; - } - - // p_out << " INDEX 01 " << cuesheet_format_index_time(iter->m_offset) << g_eol; - } - } - - - void t_entry::set_simple_index(double p_time) - { - m_index_list.reset(); - m_index_list.m_positions[0] = m_index_list.m_positions[1] = p_time; - } - -} - diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_creator.h b/tools/vio2sf/src/foobar/foobar2000/helpers/cue_creator.h deleted file mode 100644 index cb62cbbf3..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_creator.h +++ /dev/null @@ -1,17 +0,0 @@ -namespace cue_creator -{ - struct t_entry - { - file_info_impl m_infos; - pfc::string8 m_file,m_flags; - unsigned m_track_number; - - t_cuesheet_index_list m_index_list; - - void set_simple_index(double p_time); - }; - - typedef pfc::chain_list_v2_t t_entry_list; - - void create(pfc::string_formatter & p_out,const t_entry_list & p_list); -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser.cpp deleted file mode 100644 index 536e8326b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser.cpp +++ /dev/null @@ -1,764 +0,0 @@ -#include "stdafx.h" - -namespace { - PFC_DECLARE_EXCEPTION(exception_cue,pfc::exception,"Invalid cuesheet"); -} - -static bool is_numeric(char c) {return c>='0' && c<='9';} - - -static bool is_spacing(char c) -{ - return c == ' ' || c == '\t'; -} - -static bool is_linebreak(char c) -{ - return c == '\n' || c == '\r'; -} - -static void validate_file_type(const char * p_type,t_size p_type_length) { - if ( - //standard types - stricmp_utf8_ex(p_type,p_type_length,"WAVE",infinite) != 0 && - stricmp_utf8_ex(p_type,p_type_length,"MP3",infinite) != 0 && - stricmp_utf8_ex(p_type,p_type_length,"AIFF",infinite) != 0 && - //common user-entered types - stricmp_utf8_ex(p_type,p_type_length,"APE",infinite) != 0 && - stricmp_utf8_ex(p_type,p_type_length,"FLAC",infinite) != 0 && - stricmp_utf8_ex(p_type,p_type_length,"WV",infinite) != 0 && - stricmp_utf8_ex(p_type,p_type_length,"WAVPACK",infinite) != 0 - ) - throw exception_cue(pfc::string_formatter() << "expected WAVE, MP3 or AIFF, got : \"" << pfc::string8(p_type,p_type_length) << "\""); -} - -namespace { - - class NOVTABLE cue_parser_callback - { - public: - virtual void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) = 0; - virtual void on_track(unsigned p_index,const char * p_type,t_size p_type_length) = 0; - virtual void on_pregap(unsigned p_value) = 0; - virtual void on_index(unsigned p_index,unsigned p_value) = 0; - virtual void on_title(const char * p_title,t_size p_title_length) = 0; - virtual void on_performer(const char * p_performer,t_size p_performer_length) = 0; - virtual void on_songwriter(const char * p_songwriter,t_size p_songwriter_length) = 0; - virtual void on_isrc(const char * p_isrc,t_size p_isrc_length) = 0; - virtual void on_catalog(const char * p_catalog,t_size p_catalog_length) = 0; - virtual void on_comment(const char * p_comment,t_size p_comment_length) = 0; - virtual void on_flags(const char * p_flags,t_size p_flags_length) = 0; - }; - - class NOVTABLE cue_parser_callback_meta : public cue_parser_callback - { - public: - virtual void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) = 0; - virtual void on_track(unsigned p_index,const char * p_type,t_size p_type_length) = 0; - virtual void on_pregap(unsigned p_value) = 0; - virtual void on_index(unsigned p_index,unsigned p_value) = 0; - virtual void on_meta(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0; - protected: - static bool is_known_meta(const char * p_name,t_size p_length) - { - static const char * metas[] = {"genre","date","discid","comment","replaygain_track_gain","replaygain_track_peak","replaygain_album_gain","replaygain_album_peak"}; - for(t_size n=0;n value_base) on_meta(p_comment,name_length,p_comment + value_base,ptr - value_base); - } - else - { - unsigned value_base = ptr; - while(ptr < p_comment_length /*&& !is_spacing(p_comment[ptr])*/) ptr++; - if (ptr > value_base) on_meta(p_comment,name_length,p_comment + value_base,ptr - value_base); - } - } - } - } - void on_title(const char * p_title,t_size p_title_length) - { - on_meta("title",infinite,p_title,p_title_length); - } - void on_songwriter(const char * p_songwriter,t_size p_songwriter_length) { - on_meta("songwriter",infinite,p_songwriter,p_songwriter_length); - } - void on_performer(const char * p_performer,t_size p_performer_length) - { - on_meta("artist",infinite,p_performer,p_performer_length); - } - - void on_isrc(const char * p_isrc,t_size p_isrc_length) - { - on_meta("isrc",infinite,p_isrc,p_isrc_length); - } - void on_catalog(const char * p_catalog,t_size p_catalog_length) - { - on_meta("catalog",infinite,p_catalog,p_catalog_length); - } - void on_flags(const char * p_flags,t_size p_flags_length) {} - }; - - - class cue_parser_callback_retrievelist : public cue_parser_callback - { - public: - cue_parser_callback_retrievelist(cue_parser::t_cue_entry_list & p_out) : m_out(p_out), m_track(0), m_pregap(0), m_index0_set(false), m_index1_set(false) - { - } - - void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) - { - validate_file_type(p_type,p_type_length); - m_file.set_string(p_file,p_file_length); - } - - void on_track(unsigned p_index,const char * p_type,t_size p_type_length) - { - if (stricmp_utf8_ex(p_type,p_type_length,"audio",infinite)) throw exception_cue("only tracks of type AUDIO supported",0); - //if (p_index != m_track + 1) throw exception_cue("cuesheet tracks out of order"); - if (m_track != 0) finalize_track(); - if (m_file.is_empty()) throw exception_cue("declaring a track with no file set",0); - m_trackfile = m_file; - m_track = p_index; - } - - void on_pregap(unsigned p_value) {m_pregap = (double) p_value / 75.0;} - - void on_index(unsigned p_index,unsigned p_value) - { - if (p_index < t_cuesheet_index_list::count) - { - switch(p_index) - { - case 0: m_index0_set = true; break; - case 1: m_index1_set = true; break; - } - m_index_list.m_positions[p_index] = (double) p_value / 75.0; - } - } - - void on_title(const char * p_title,t_size p_title_length) {} - void on_performer(const char * p_performer,t_size p_performer_length) {} - void on_songwriter(const char * p_songwriter,t_size p_songwriter_length) {} - void on_isrc(const char * p_isrc,t_size p_isrc_length) {} - void on_catalog(const char * p_catalog,t_size p_catalog_length) {} - void on_comment(const char * p_comment,t_size p_comment_length) {} - void on_flags(const char * p_flags,t_size p_flags_length) {} - - void finalize() - { - if (m_track != 0) - { - finalize_track(); - m_track = 0; - } - } - - private: - void finalize_track() - { - if (!m_index1_set) throw exception_cue("INDEX 01 not set",0); - if (!m_index0_set) m_index_list.m_positions[0] = m_index_list.m_positions[1] - m_pregap; - if (!m_index_list.is_valid()) throw exception_cue("invalid index list"); - - cue_parser::t_cue_entry_list::iterator iter; - iter = m_out.insert_last(); - if (m_trackfile.is_empty()) throw exception_cue("track has no file assigned",0); - iter->m_file = m_trackfile; - iter->m_track_number = m_track; - iter->m_indexes = m_index_list; - - m_index_list.reset(); - m_index0_set = false; - m_index1_set = false; - m_pregap = 0; - } - - bool m_index0_set,m_index1_set; - t_cuesheet_index_list m_index_list; - double m_pregap; - unsigned m_track; - pfc::string8 m_file,m_trackfile; - cue_parser::t_cue_entry_list & m_out; - }; - - class cue_parser_callback_retrieveinfo : public cue_parser_callback_meta - { - public: - cue_parser_callback_retrieveinfo(file_info & p_out,unsigned p_wanted_track) : m_out(p_out), m_wanted_track(p_wanted_track), m_track(0), m_is_va(false), m_index0_set(false), m_index1_set(false), m_pregap(0), m_totaltracks(0) {} - - void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) {} - - void on_track(unsigned p_index,const char * p_type,t_size p_type_length) - { - if (p_index == 0) throw exception_cue("invalid TRACK index",0); - if (p_index == m_wanted_track) - { - if (stricmp_utf8_ex(p_type,p_type_length,"audio",infinite)) throw exception_cue("only tracks of type AUDIO supported",0); - } - m_track = p_index; - m_totaltracks++; - } - - void on_pregap(unsigned p_value) {if (m_track == m_wanted_track) m_pregap = (double) p_value / 75.0;} - - void on_index(unsigned p_index,unsigned p_value) - { - if (m_track == m_wanted_track && p_index < t_cuesheet_index_list::count) - { - switch(p_index) - { - case 0: m_index0_set = true; break; - case 1: m_index1_set = true; break; - } - m_indexes.m_positions[p_index] = (double) p_value / 75.0; - } - } - - - void on_meta(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) - { - t_meta_list::iterator iter; - if (m_track == 0) //globals - { - //convert global title to album - if (!stricmp_utf8_ex(p_name,p_name_length,"title",infinite)) - { - p_name = "album"; - p_name_length = 5; - } - else if (!stricmp_utf8_ex(p_name,p_name_length,"artist",infinite)) - { - m_album_artist.set_string(p_value,p_value_length); - } - - iter = m_globals.insert_last(); - } - else - { - if (!m_is_va) - { - if (!stricmp_utf8_ex(p_name,p_name_length,"artist",infinite)) - { - if (!m_album_artist.is_empty()) - { - if (stricmp_utf8_ex(p_value,p_value_length,m_album_artist,m_album_artist.length())) m_is_va = true; - } - } - } - - if (m_track == m_wanted_track) //locals - { - iter = m_locals.insert_last(); - } - } - if (iter.is_valid()) - { - iter->m_name.set_string(p_name,p_name_length); - iter->m_value.set_string(p_value,p_value_length); - } - } - - void finalize() - { - if (!m_index1_set) throw exception_cue("INDEX 01 not set",0); - if (!m_index0_set) m_indexes.m_positions[0] = m_indexes.m_positions[1] - m_pregap; - m_indexes.to_infos(m_out); - - replaygain_info rg; - rg.reset(); - t_meta_list::const_iterator iter; - - if (m_is_va) - { - //clean up VA mess - - t_meta_list::const_iterator iter_global,iter_local; - - iter_global = find_first_field(m_globals,"artist"); - iter_local = find_first_field(m_locals,"artist"); - if (iter_global.is_valid()) - { - m_out.meta_set("album artist",iter_global->m_value); - if (iter_local.is_valid()) m_out.meta_set("artist",iter_local->m_value); - else m_out.meta_set("artist",iter_global->m_value); - } - else - { - if (iter_local.is_valid()) m_out.meta_set("artist",iter_local->m_value); - } - - - wipe_field(m_globals,"artist"); - wipe_field(m_locals,"artist"); - - } - - for(iter=m_globals.first();iter.is_valid();iter++) - { - if (!rg.set_from_meta(iter->m_name,iter->m_value)) - m_out.meta_set(iter->m_name,iter->m_value); - } - for(iter=m_locals.first();iter.is_valid();iter++) - { - if (!rg.set_from_meta(iter->m_name,iter->m_value)) - m_out.meta_set(iter->m_name,iter->m_value); - } - m_out.meta_set("tracknumber",pfc::string_formatter() << m_wanted_track); - m_out.meta_set("totaltracks", pfc::string_formatter() << m_totaltracks); - m_out.set_replaygain(rg); - - } - private: - struct t_meta_entry { - pfc::string8 m_name,m_value; - }; - typedef pfc::chain_list_v2_t t_meta_list; - - static t_meta_list::const_iterator find_first_field(t_meta_list const & p_list,const char * p_field) - { - t_meta_list::const_iterator iter; - for(iter=p_list.first();iter.is_valid();++iter) - { - if (!stricmp_utf8(p_field,iter->m_name)) return iter; - } - return t_meta_list::const_iterator();//null iterator - } - - static void wipe_field(t_meta_list & p_list,const char * p_field) - { - t_meta_list::iterator iter; - for(iter=p_list.first();iter.is_valid();) - { - if (!stricmp_utf8(p_field,iter->m_name)) - { - t_meta_list::iterator temp = iter; - ++temp; - p_list.remove_single(iter); - iter = temp; - } - else - { - ++iter; - } - } - } - - t_meta_list m_globals,m_locals; - file_info & m_out; - unsigned m_wanted_track, m_track,m_totaltracks; - pfc::string8 m_album_artist; - bool m_is_va; - t_cuesheet_index_list m_indexes; - bool m_index0_set,m_index1_set; - double m_pregap; - }; - -}; - - -static void g_parse_cue_line(const char * p_line,t_size p_line_length,cue_parser_callback & p_callback) -{ - t_size ptr = 0; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; - if (!stricmp_utf8_ex(p_line,ptr,"file",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - t_size file_base,file_length, type_base,type_length; - - if (p_line[ptr] == '\"') - { - ptr++; - file_base = ptr; - while(ptr < p_line_length && p_line[ptr] != '\"') ptr++; - if (ptr == p_line_length) throw exception_cue("invalid FILE syntax",0); - file_length = ptr - file_base; - ptr++; - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - } - else - { - file_base = ptr; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; - file_length = ptr - file_base; - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - } - - type_base = ptr; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; - type_length = ptr - type_base; - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - - if (ptr != p_line_length || file_length == 0 || type_length == 0) throw exception_cue("invalid FILE syntax",0); - - p_callback.on_file(p_line + file_base, file_length, p_line + type_base, type_length); - } - else if (!stricmp_utf8_ex(p_line,ptr,"track",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - - t_size track_base = ptr, track_length; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) - { - if (!is_numeric(p_line[ptr])) throw exception_cue("invalid TRACK syntax",0); - ptr++; - } - track_length = ptr - track_base; - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - - t_size type_base = ptr, type_length; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) ptr++; - type_length = ptr - type_base; - - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr != p_line_length || type_length == 0) throw exception_cue("invalid TRACK syntax",0); - unsigned track = pfc::atoui_ex(p_line+track_base,track_length); - if (track < 1 || track > 99) throw exception_cue("invalid track number",0); - - p_callback.on_track(track,p_line + type_base, type_length); - } - else if (!stricmp_utf8_ex(p_line,ptr,"index",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - - t_size index_base,index_length, time_base,time_length; - index_base = ptr; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) - { - if (!is_numeric(p_line[ptr])) throw exception_cue("invalid INDEX syntax",0); - ptr++; - } - index_length = ptr - index_base; - - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - time_base = ptr; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) - { - if (!is_numeric(p_line[ptr]) && p_line[ptr] != ':') - throw exception_cue("invalid INDEX syntax",0); - ptr++; - } - time_length = ptr - time_base; - - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - - if (ptr != p_line_length || index_length == 0 || time_length == 0) - throw exception_cue("invalid INDEX syntax",0); - - unsigned index = pfc::atoui_ex(p_line+index_base,index_length); - if (index > 99) throw exception_cue("invalid INDEX syntax",0); - unsigned time = cuesheet_parse_index_time_ticks_e(p_line + time_base,time_length); - - p_callback.on_index(index,time); - } - else if (!stricmp_utf8_ex(p_line,ptr,"pregap",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - - t_size time_base, time_length; - time_base = ptr; - while(ptr < p_line_length && !is_spacing(p_line[ptr])) - { - if (!is_numeric(p_line[ptr]) && p_line[ptr] != ':') - throw exception_cue("invalid PREGAP syntax",0); - ptr++; - } - time_length = ptr - time_base; - - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - - if (ptr != p_line_length || time_length == 0) - throw exception_cue("invalid PREGAP syntax",0); - - unsigned time = cuesheet_parse_index_time_ticks_e(p_line + time_base,time_length); - - p_callback.on_pregap(time); - } - else if (!stricmp_utf8_ex(p_line,ptr,"title",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr == p_line_length) throw exception_cue("invalid TITLE syntax",0); - if (p_line[ptr] == '\"') - { - ptr++; - t_size base = ptr; - while(ptr < p_line_length && p_line[ptr] != '\"') ptr++; - if (ptr == p_line_length) throw exception_cue("invalid TITLE syntax",0); - t_size length = ptr-base; - ptr++; - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr != p_line_length) throw exception_cue("invalid TITLE syntax",0); - p_callback.on_title(p_line+base,length); - } - else - { - p_callback.on_title(p_line+ptr,p_line_length-ptr); - } - } - else if (!stricmp_utf8_ex(p_line,ptr,"performer",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr == p_line_length) throw exception_cue("invalid PERFORMER syntax",0); - if (p_line[ptr] == '\"') - { - ptr++; - t_size base = ptr; - while(ptr < p_line_length && p_line[ptr] != '\"') ptr++; - if (ptr == p_line_length) throw exception_cue("invalid PERFORMER syntax",0); - t_size length = ptr-base; - ptr++; - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr != p_line_length) throw exception_cue("invalid PERFORMER syntax",0); - p_callback.on_performer(p_line+base,length); - } - else - { - p_callback.on_performer(p_line+ptr,p_line_length-ptr); - } - } - else if (!stricmp_utf8_ex(p_line,ptr,"songwriter",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr == p_line_length) throw exception_cue("invalid SONGWRITER syntax",0); - if (p_line[ptr] == '\"') - { - ptr++; - t_size base = ptr; - while(ptr < p_line_length && p_line[ptr] != '\"') ptr++; - if (ptr == p_line_length) throw exception_cue("invalid SONGWRITER syntax",0); - t_size length = ptr-base; - ptr++; - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr != p_line_length) throw exception_cue("invalid SONGWRITER syntax",0); - p_callback.on_songwriter(p_line+base,length); - } - else - { - p_callback.on_songwriter(p_line+ptr,p_line_length-ptr); - } - } - else if (!stricmp_utf8_ex(p_line,ptr,"isrc",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - t_size length = p_line_length - ptr; - if (length == 0) throw exception_cue("invalid ISRC syntax",0); - p_callback.on_isrc(p_line+ptr,length); - } - else if (!stricmp_utf8_ex(p_line,ptr,"catalog",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - t_size length = p_line_length - ptr; - if (length == 0) throw exception_cue("invalid CATALOG syntax",0); - p_callback.on_catalog(p_line+ptr,length); - } - else if (!stricmp_utf8_ex(p_line,ptr,"flags",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr < p_line_length) - p_callback.on_flags(p_line + ptr, p_line_length - ptr); - } - else if (!stricmp_utf8_ex(p_line,ptr,"rem",infinite)) - { - while(ptr < p_line_length && is_spacing(p_line[ptr])) ptr++; - if (ptr < p_line_length) - p_callback.on_comment(p_line + ptr, p_line_length - ptr); - } - else if (!stricmp_utf8_ex(p_line,ptr,"postgap",infinite)) { - throw exception_cue("POSTGAP is not supported",0); - } else if (!stricmp_utf8_ex(p_line,ptr,"cdtextfile",infinite)) { - //do nothing - } - else throw exception_cue("unknown cuesheet item",0); -} - -static void g_parse_cue(const char * p_cuesheet,cue_parser_callback & p_callback) -{ - const char * parseptr = p_cuesheet; - t_size lineidx = 1; - while(*parseptr) - { - while(is_spacing(*parseptr)) *parseptr++; - if (*parseptr) - { - t_size length = 0; - while(parseptr[length] && !is_linebreak(parseptr[length])) length++; - if (length > 0) { - try { - g_parse_cue_line(parseptr,length,p_callback); - } catch(exception_cue const & e) {//rethrow with line info - throw exception_cue(pfc::string_formatter() << e.what() << " (line " << lineidx << ")"); - } - } - parseptr += length; - while(is_linebreak(*parseptr)) { - if (*parseptr == '\n') lineidx++; - parseptr++; - } - } - } -} - -void cue_parser::parse(const char *p_cuesheet,t_cue_entry_list & p_out) { - try { - cue_parser_callback_retrievelist callback(p_out); - g_parse_cue(p_cuesheet,callback); - callback.finalize(); - } catch(exception_cue const & e) { - throw exception_bad_cuesheet(pfc::string_formatter() << "Error parsing cuesheet: " << e.what()); - } -} -void cue_parser::parse_info(const char * p_cuesheet,file_info & p_info,unsigned p_index) { - try { - cue_parser_callback_retrieveinfo callback(p_info,p_index); - g_parse_cue(p_cuesheet,callback); - callback.finalize(); - } catch(exception_cue const & e) { - throw exception_bad_cuesheet(pfc::string_formatter() << "Error parsing cuesheet: " << e.what()); - } -} - -namespace { - - class cue_parser_callback_retrievecount : public cue_parser_callback - { - public: - cue_parser_callback_retrievecount() : m_count(0) {} - unsigned get_count() const {return m_count;} - void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) {} - void on_track(unsigned p_index,const char * p_type,t_size p_type_length) {m_count++;} - void on_pregap(unsigned p_value) {} - void on_index(unsigned p_index,unsigned p_value) {} - void on_title(const char * p_title,t_size p_title_length) {} - void on_performer(const char * p_performer,t_size p_performer_length) {} - void on_isrc(const char * p_isrc,t_size p_isrc_length) {} - void on_catalog(const char * p_catalog,t_size p_catalog_length) {} - void on_comment(const char * p_comment,t_size p_comment_length) {} - void on_flags(const char * p_flags,t_size p_flags_length) {} - private: - unsigned m_count; - }; - - class cue_parser_callback_retrievecreatorentries : public cue_parser_callback - { - public: - cue_parser_callback_retrievecreatorentries(cue_creator::t_entry_list & p_out) : m_out(p_out), m_track(0), m_pregap(0), m_index0_set(false), m_index1_set(false) {} - - void on_file(const char * p_file,t_size p_file_length,const char * p_type,t_size p_type_length) { - validate_file_type(p_type,p_type_length); - m_file.set_string(p_file,p_file_length); - } - - void on_track(unsigned p_index,const char * p_type,t_size p_type_length) - { - if (stricmp_utf8_ex(p_type,p_type_length,"audio",infinite)) throw exception_cue("only tracks of type AUDIO supported",0); - //if (p_index != m_track + 1) throw exception_cue("cuesheet tracks out of order",0); - if (m_track != 0) finalize_track(); - if (m_file.is_empty()) throw exception_cue("declaring a track with no file set",0); - m_trackfile = m_file; - m_track = p_index; - } - - void on_pregap(unsigned p_value) - { - m_pregap = (double) p_value / 75.0; - } - - void on_index(unsigned p_index,unsigned p_value) - { - if (p_index < t_cuesheet_index_list::count) - { - switch(p_index) - { - case 0: m_index0_set = true; break; - case 1: m_index1_set = true; break; - } - m_indexes.m_positions[p_index] = (double) p_value / 75.0; - } - } - void on_title(const char * p_title,t_size p_title_length) {} - void on_performer(const char * p_performer,t_size p_performer_length) {} - void on_songwriter(const char * p_performer,t_size p_performer_length) {} - void on_isrc(const char * p_isrc,t_size p_isrc_length) {} - void on_catalog(const char * p_catalog,t_size p_catalog_length) {} - void on_comment(const char * p_comment,t_size p_comment_length) {} - void finalize() - { - if (m_track != 0) - { - finalize_track(); - m_track = 0; - } - } - void on_flags(const char * p_flags,t_size p_flags_length) { - m_flags.set_string(p_flags,p_flags_length); - } - private: - void finalize_track() - { - if (m_track < 1 || m_track > 99) throw exception_cue("track number out of range",0); - if (!m_index1_set) throw exception_cue("INDEX 01 not set",0); - if (!m_index0_set) m_indexes.m_positions[0] = m_indexes.m_positions[1] - m_pregap; - if (!m_indexes.is_valid()) throw exception_cue("invalid index list"); - - cue_creator::t_entry_list::iterator iter; - iter = m_out.insert_last(); - iter->m_track_number = m_track; - iter->m_file = m_trackfile; - iter->m_index_list = m_indexes; - iter->m_flags = m_flags; - m_pregap = 0; - m_indexes.reset(); - m_index0_set = m_index1_set = false; - m_flags.reset(); - } - - bool m_index0_set,m_index1_set; - double m_pregap; - unsigned m_track; - cue_creator::t_entry_list & m_out; - pfc::string8 m_file,m_trackfile,m_flags; - t_cuesheet_index_list m_indexes; - }; -} - -void cue_parser::parse_full(const char * p_cuesheet,cue_creator::t_entry_list & p_out) { - try { - { - cue_parser_callback_retrievecreatorentries callback(p_out); - g_parse_cue(p_cuesheet,callback); - callback.finalize(); - } - - { - cue_creator::t_entry_list::iterator iter; - for(iter=p_out.first();iter.is_valid();++iter) - { - cue_parser_callback_retrieveinfo callback(iter->m_infos,iter->m_track_number); - g_parse_cue(p_cuesheet,callback); - callback.finalize(); - } - } - } catch(exception_cue const & e) { - throw exception_bad_cuesheet(pfc::string_formatter() << "Error parsing cuesheet: " << e.what()); - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser.h b/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser.h deleted file mode 100644 index 92f546bbf..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser.h +++ /dev/null @@ -1,445 +0,0 @@ -//HINT: for info on how to generate an embedded cuesheet enabled input, see the end of this header. - -//to be moved somewhere else later -namespace file_info_record_helper { - - class __file_info_record__info__enumerator { - public: - __file_info_record__info__enumerator(file_info & p_out) : m_out(p_out) {} - void operator() (const char * p_name,const char * p_value) {m_out.__info_add_unsafe(p_name,p_value);} - private: - file_info & m_out; - }; - - class __file_info_record__meta__enumerator { - public: - __file_info_record__meta__enumerator(file_info & p_out) : m_out(p_out) {} - template void operator() (const char * p_name,const t_value & p_value) { - t_size index = infinite; - for(typename t_value::const_iterator iter = p_value.first(); iter.is_valid(); ++iter) { - if (index == infinite) index = m_out.__meta_add_unsafe(p_name,*iter); - else m_out.meta_add_value(index,*iter); - } - } - private: - file_info & m_out; - }; - - class file_info_record { - public: - typedef pfc::chain_list_v2_t t_meta_value; - typedef pfc::map_t t_meta_map; - typedef pfc::map_t t_info_map; - - file_info_record() : m_replaygain(replaygain_info_invalid), m_length(0) {} - - replaygain_info get_replaygain() const {return m_replaygain;} - void set_replaygain(const replaygain_info & p_replaygain) {m_replaygain = p_replaygain;} - double get_length() const {return m_length;} - void set_length(double p_length) {m_length = p_length;} - - void reset() { - m_meta.remove_all(); m_info.remove_all(); - m_length = 0; - m_replaygain = replaygain_info_invalid; - } - - void from_info_overwrite_info(const file_info & p_info) { - for(t_size infowalk = 0, infocount = p_info.info_get_count(); infowalk < infocount; ++infowalk) { - m_info.set(p_info.info_enum_name(infowalk),p_info.info_enum_value(infowalk)); - } - } - void from_info_overwrite_meta(const file_info & p_info) { - for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) { - const t_size valuecount = p_info.meta_enum_value_count(metawalk); - if (valuecount > 0) { - t_meta_value & entry = m_meta.find_or_add(p_info.meta_enum_name(metawalk)); - entry.remove_all(); - for(t_size valuewalk = 0; valuewalk < valuecount; ++valuewalk) { - entry.add_item(p_info.meta_enum_value(metawalk,valuewalk)); - } - } - } - } - - void from_info_overwrite_rg(const file_info & p_info) { - m_replaygain = replaygain_info::g_merge(m_replaygain,p_info.get_replaygain()); - } - - template - void overwrite_meta(const t_source & p_meta) { - m_meta.overwrite(p_meta); - } - template - void overwrite_info(const t_source & p_info) { - m_info.overwrite(p_info); - } - - void merge_overwrite(const file_info & p_info) { - from_info_overwrite_info(p_info); - from_info_overwrite_meta(p_info); - from_info_overwrite_rg(p_info); - } - - void transfer_meta_entry(const char * p_name,const file_info & p_info,t_size p_index) { - const t_size count = p_info.meta_enum_value_count(p_index); - if (count == 0) { - m_meta.remove(p_name); - } else { - t_meta_value & val = m_meta.find_or_add(p_name); - val.remove_all(); - for(t_size walk = 0; walk < count; ++walk) { - val.add_item(p_info.meta_enum_value(p_index,walk)); - } - } - } - - void meta_set(const char * p_name,const char * p_value) { - m_meta.find_or_add(p_name).set_single(p_value); - } - - const t_meta_value * meta_query_ptr(const char * p_name) const { - return m_meta.query_ptr(p_name); - } - - - void from_info_set_meta(const file_info & p_info) { - m_meta.remove_all(); - from_info_overwrite_meta(p_info); - } - - void from_info(const file_info & p_info) { - reset(); - m_length = p_info.get_length(); - m_replaygain = p_info.get_replaygain(); - from_info_overwrite_meta(p_info); - from_info_overwrite_info(p_info); - } - void to_info(file_info & p_info) const { - p_info.reset(); - p_info.set_length(m_length); - p_info.set_replaygain(m_replaygain); - m_info.enumerate(__file_info_record__info__enumerator(p_info)); - m_meta.enumerate(__file_info_record__meta__enumerator(p_info)); - } - - template void enumerate_meta(t_callback & p_callback) const {m_meta.enumerate(p_callback);} - template void enumerate_meta(t_callback & p_callback) {m_meta.enumerate(p_callback);} - - //private: - t_meta_map m_meta; - t_info_map m_info; - replaygain_info m_replaygain; - double m_length; - }; - -}//namespace file_info_record_helper - - -namespace cue_parser -{ - struct cue_entry { - pfc::string8 m_file; - unsigned m_track_number; - t_cuesheet_index_list m_indexes; - }; - - typedef pfc::chain_list_v2_t t_cue_entry_list; - - - PFC_DECLARE_EXCEPTION(exception_bad_cuesheet,exception_io_data,"Invalid cuesheet"); - - //! Throws exception_bad_cuesheet on failure. - void parse(const char *p_cuesheet,t_cue_entry_list & p_out); - //! Throws exception_bad_cuesheet on failure. - void parse_info(const char *p_cuesheet,file_info & p_info,unsigned p_index); - //! Throws exception_bad_cuesheet on failure. - void parse_full(const char * p_cuesheet,cue_creator::t_entry_list & p_out); - - - - struct track_record { - file_info_record_helper::file_info_record m_info; - pfc::string8 m_file,m_flags; - t_cuesheet_index_list m_index_list; - }; - - typedef pfc::map_t track_record_list; - - class embeddedcue_metadata_manager { - public: - void get_tag(file_info & p_info) const; - void set_tag(file_info const & p_info); - - void get_track_info(unsigned p_track,file_info & p_info) const; - void set_track_info(unsigned p_track,file_info const & p_info); - void query_track_offsets(unsigned p_track,double & p_begin,double & p_length) const; - bool have_cuesheet() const; - unsigned remap_trackno(unsigned p_index) const; - t_size get_cue_track_count() const; - private: - track_record_list m_content; - }; - - - - - - - class _decoder_wrapper { - public: - virtual bool run(audio_chunk & p_chunk,abort_callback & p_abort) = 0; - virtual void seek(double p_seconds,abort_callback & p_abort) = 0; - virtual bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) = 0; - virtual bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) = 0; - virtual void on_idle(abort_callback & p_abort) = 0; - virtual bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) = 0; - virtual void set_logger(event_logger::ptr ptr) = 0; - virtual ~_decoder_wrapper() {} - }; - - template - class _decoder_wrapper_simple : public _decoder_wrapper { - public: - void initialize(service_ptr_t p_filehint,const char * p_path,unsigned p_flags,abort_callback & p_abort) { - m_input.open(p_filehint,p_path,input_open_decode,p_abort); - m_input.decode_initialize(p_flags,p_abort); - } - bool run(audio_chunk & p_chunk,abort_callback & p_abort) {return m_input.decode_run(p_chunk,p_abort);} - void seek(double p_seconds,abort_callback & p_abort) {m_input.decode_seek(p_seconds,p_abort);} - bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {return m_input.decode_get_dynamic_info(p_out,p_timestamp_delta);} - bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {return m_input.decode_get_dynamic_info_track(p_out,p_timestamp_delta);} - void on_idle(abort_callback & p_abort) {m_input.decode_on_idle(p_abort);} - bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) {return m_input.decode_run_raw(p_chunk, p_raw, p_abort);} - void set_logger(event_logger::ptr ptr) {m_input.set_logger(ptr);} - private: - t_input m_input; - }; - - class _decoder_wrapper_cue : public _decoder_wrapper { - public: - void open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,double p_start,double p_length) { - m_input.open(p_filehint,p_location,p_flags,p_abort,p_start,p_length); - } - bool run(audio_chunk & p_chunk,abort_callback & p_abort) {return m_input.run(p_chunk,p_abort);} - void seek(double p_seconds,abort_callback & p_abort) {m_input.seek(p_seconds,p_abort);} - bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {return m_input.get_dynamic_info(p_out,p_timestamp_delta);} - bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {return m_input.get_dynamic_info_track(p_out,p_timestamp_delta);} - void on_idle(abort_callback & p_abort) {m_input.on_idle(p_abort);} - bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) {return m_input.run_raw(p_chunk, p_raw, p_abort);} - void set_logger(event_logger::ptr ptr) {m_input.set_logger(ptr);} - private: - input_helper_cue m_input; - }; - - template - class input_wrapper_cue_t { - public: - input_wrapper_cue_t() {} - ~input_wrapper_cue_t() {} - - void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) { - m_path = p_path; - - m_file = p_filehint; - input_open_file_helper(m_file,p_path,p_reason,p_abort); - - { - file_info_impl info; - t_base instance; - instance.open(m_file,p_path,p_reason,p_abort); - instance.get_info(info,p_abort); - m_meta.set_tag(info); - } - } - - t_uint32 get_subsong_count() { - return m_meta.have_cuesheet() ? m_meta.get_cue_track_count() : 1; - } - - t_uint32 get_subsong(t_uint32 p_index) { - return m_meta.have_cuesheet() ? m_meta.remap_trackno(p_index) : 0; - } - - void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { - if (p_subsong == 0) { - m_meta.get_tag(p_info); - } else { - m_meta.get_track_info(p_subsong,p_info); - } - } - - t_filestats get_file_stats(abort_callback & p_abort) {return m_file->get_stats(p_abort);} - - void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) { - m_decoder.release(); - if (p_subsong == 0) { - pfc::rcptr_t<_decoder_wrapper_simple > temp; - temp.new_t(); - m_file->reopen(p_abort); - temp->initialize(m_file,m_path,p_flags,p_abort); - m_decoder = temp; - } else { - double start,length; - m_meta.query_track_offsets(p_subsong,start,length); - - pfc::rcptr_t<_decoder_wrapper_cue> temp; - temp.new_t(); - m_file->reopen(p_abort); - temp->open(m_file,make_playable_location(m_path,0),p_flags & ~input_flag_no_seeking,p_abort,start,length); - m_decoder = temp; - } - if (m_logger.is_valid()) m_decoder->set_logger(m_logger); - } - - bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { - return m_decoder->run(p_chunk,p_abort); - } - - void decode_seek(double p_seconds,abort_callback & p_abort) { - m_decoder->seek(p_seconds,p_abort); - } - - bool decode_can_seek() {return true;} - - bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { - return m_decoder->run_raw(p_chunk, p_raw, p_abort); - } - void set_logger(event_logger::ptr ptr) { - m_logger = ptr; - if (m_decoder.is_valid()) m_decoder->set_logger(ptr); - } - - bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) { - return m_decoder->get_dynamic_info(p_out,p_timestamp_delta); - } - - bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) { - return m_decoder->get_dynamic_info_track(p_out,p_timestamp_delta); - } - - void decode_on_idle(abort_callback & p_abort) { - m_decoder->on_idle(p_abort); - } - - void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) { - pfc::dynamic_assert(m_decoder.is_empty()); - if (p_subsong == 0) { - m_meta.set_tag(p_info); - } else { - m_meta.set_track_info(p_subsong,p_info); - } - } - - void retag_commit(abort_callback & p_abort) { - pfc::dynamic_assert(m_decoder.is_empty()); - - file_info_impl info; - m_meta.get_tag(info); - - { - t_base instance; - m_file->reopen(p_abort); - instance.open(m_file,m_path,input_open_info_write,p_abort); - instance.retag(pfc::safe_cast(info),p_abort); - info.reset(); - instance.get_info(info,p_abort); - m_meta.set_tag(info); - } - } - - inline static bool g_is_our_content_type(const char * p_content_type) {return t_base::g_is_our_content_type(p_content_type);} - inline static bool g_is_our_path(const char * p_path,const char * p_extension) {return t_base::g_is_our_path(p_path,p_extension);} - - private: - pfc::rcptr_t<_decoder_wrapper> m_decoder; - - file_info_impl m_info; - pfc::string8 m_path; - service_ptr_t m_file; - - embeddedcue_metadata_manager m_meta; - event_logger::ptr m_logger; - }; - - template - class chapterizer_impl_t : public chapterizer - { - public: - bool is_our_file(const char * p_path,abort_callback & p_abort) - { - return I::g_is_our_path(p_path,pfc::string_extension(p_path)); - } - - void set_chapters(const char * p_path,chapter_list const & p_list,abort_callback & p_abort) { - - - input_wrapper_cue_t instance; - instance.open(0,p_path,input_open_info_write,p_abort); - - //stamp the cuesheet first - { - file_info_impl info; - instance.get_info(0,info,p_abort); - - pfc::string_formatter cuesheet; - - { - cue_creator::t_entry_list entries; - t_size n, m = p_list.get_chapter_count(); - - double offset_acc = 0; - for(n=0;nm_infos = p_list.get_info(n); - entry->m_file = "CDImage.wav"; - entry->m_track_number = (unsigned)(n+1); - entry->m_index_list.from_infos(entry->m_infos,offset_acc); - offset_acc += entry->m_infos.get_length(); - } - cue_creator::create(cuesheet,entries); - } - - info.meta_set("cuesheet",cuesheet); - - instance.retag_set_info(0,info,p_abort); - } - //stamp per-chapter infos - for(t_size walk = 0, total = p_list.get_chapter_count(); walk < total; ++walk) { - instance.retag_set_info(walk + 1, p_list.get_info(walk),p_abort); - } - - instance.retag_commit(p_abort); - } - - void get_chapters(const char * p_path,chapter_list & p_list,abort_callback & p_abort) { - - input_wrapper_cue_t instance; - - - instance.open(0,p_path,input_open_info_read,p_abort); - - const t_uint32 total = instance.get_subsong_count(); - - p_list.set_chapter_count(total); - for(t_uint32 walk = 0; walk < total; ++walk) { - file_info_impl info; - instance.get_info(instance.get_subsong(walk),info,p_abort); - p_list.set_info(walk,info); - } - } - }; - -}; - -//! Wrapper template for generating embedded cuesheet enabled inputs. -//! t_input_impl is a singletrack input implementation (see input_singletrack_impl for method declarations). -//! To declare an embedded cuesheet enabled input, change your input declaration from input_singletrack_factory_t to input_cuesheet_factory_t. -template -class input_cuesheet_factory_t { -public: - input_factory_ex_t,0,input_decoder_v2> m_input_factory; - service_factory_single_t > m_chapterizer_factory; -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser_embedding.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser_embedding.cpp deleted file mode 100644 index 41719f2e3..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/cue_parser_embedding.cpp +++ /dev/null @@ -1,358 +0,0 @@ -#include "stdafx.h" - -using namespace cue_parser; -using namespace file_info_record_helper; -static void build_cue_meta_name(const char * p_name,unsigned p_tracknumber,pfc::string_base & p_out) { - p_out.reset(); - p_out << "cue_track" << pfc::format_uint(p_tracknumber % 100,2) << "_" << p_name; -} - -static bool is_reserved_meta_entry(const char * p_name) { - return file_info::field_name_comparator::compare(p_name,"cuesheet") == 0; -} - -static bool is_global_meta_entry(const char * p_name) { - static const char header[] = "cue_track"; - return pfc::stricmp_ascii_ex(p_name,strlen(header),header,infinite) != 0; -} -static bool is_allowed_field(const char * p_name) { - return !is_reserved_meta_entry(p_name) && is_global_meta_entry(p_name); -} -namespace { - class __get_tag_cue_track_list_builder { - public: - __get_tag_cue_track_list_builder(cue_creator::t_entry_list & p_entries) : m_entries(p_entries) {} - void operator() (unsigned p_trackno,const track_record & p_record) { - if (p_trackno > 0) { - cue_creator::t_entry_list::iterator iter = m_entries.insert_last(); - iter->m_file = p_record.m_file; - iter->m_flags = p_record.m_flags; - iter->m_index_list = p_record.m_index_list; - iter->m_track_number = p_trackno; - p_record.m_info.to_info(iter->m_infos); - } - } - private: - cue_creator::t_entry_list & m_entries; - }; - - typedef pfc::avltree_t field_name_list; - - class __get_tag__enum_fields_enumerator { - public: - __get_tag__enum_fields_enumerator(field_name_list & p_out) : m_out(p_out) {} - void operator() (unsigned p_trackno,const track_record & p_record) { - if (p_trackno > 0) p_record.m_info.enumerate_meta(*this); - } - template void operator() (const char * p_name,const t_value & p_value) { - m_out.add(p_name); - } - private: - field_name_list & m_out; - }; - - - class __get_tag__is_field_global_check { - private: - typedef file_info_record::t_meta_value t_value; - public: - __get_tag__is_field_global_check(const char * p_field) : m_field(p_field), m_value(NULL), m_state(true) {} - - void operator() (unsigned p_trackno,const track_record & p_record) { - if (p_trackno > 0 && m_state) { - const t_value * val = p_record.m_info.meta_query_ptr(m_field); - if (val == NULL) {m_state = false; return;} - if (m_value == NULL) { - m_value = val; - } else { - if (pfc::comparator_list::compare(*m_value,*val) != 0) { - m_state = false; return; - } - } - } - } - void finalize(file_info_record::t_meta_map & p_globals) { - if (m_state && m_value != NULL) { - p_globals.set(m_field,*m_value); - } - } - private: - const char * const m_field; - const t_value * m_value; - bool m_state; - }; - - class __get_tag__filter_globals { - public: - __get_tag__filter_globals(track_record_list const & p_tracks,file_info_record::t_meta_map & p_globals) : m_tracks(p_tracks), m_globals(p_globals) {} - - void operator() (const char * p_field) { - if (is_allowed_field(p_field)) { - __get_tag__is_field_global_check wrapper(p_field); - m_tracks.enumerate(wrapper); - wrapper.finalize(m_globals); - } - } - private: - const track_record_list & m_tracks; - file_info_record::t_meta_map & m_globals; - }; - - class __get_tag__local_field_filter { - public: - __get_tag__local_field_filter(const file_info_record::t_meta_map & p_globals,file_info_record::t_meta_map & p_output) : m_globals(p_globals), m_output(p_output), m_currenttrack(0) {} - void operator() (unsigned p_trackno,const track_record & p_track) { - if (p_trackno > 0) { - m_currenttrack = p_trackno; - p_track.m_info.enumerate_meta(*this); - } - } - void operator() (const char * p_name,const file_info_record::t_meta_value & p_value) { - PFC_ASSERT(m_currenttrack > 0); - if (!m_globals.have_item(p_name)) { - build_cue_meta_name(p_name,m_currenttrack,m_buffer); - m_output.set(m_buffer,p_value); - } - } - private: - unsigned m_currenttrack; - pfc::string8_fastalloc m_buffer; - const file_info_record::t_meta_map & m_globals; - file_info_record::t_meta_map & m_output; - }; -}; - -static void strip_redundant_track_meta(unsigned p_tracknumber,const file_info & p_cueinfo,file_info_record::t_meta_map & p_meta,const char * p_metaname) { - t_size metaindex = p_cueinfo.meta_find(p_metaname); - if (metaindex == infinite) return; - pfc::string_formatter namelocal; - build_cue_meta_name(p_metaname,p_tracknumber,namelocal); - { - const file_info_record::t_meta_value * val = p_meta.query_ptr(namelocal); - if (val == NULL) return; - file_info_record::t_meta_value::const_iterator iter = val->first(); - for(t_size valwalk = 0, valcount = p_cueinfo.meta_enum_value_count(metaindex); valwalk < valcount; ++valwalk) { - if (iter.is_empty()) return; - if (strcmp(*iter,p_cueinfo.meta_enum_value(metaindex,valwalk)) != 0) return; - ++iter; - } - if (!iter.is_empty()) return; - } - //success - p_meta.remove(namelocal); -} - -void embeddedcue_metadata_manager::get_tag(file_info & p_info) const { - if (!have_cuesheet()) { - m_content.query_ptr((unsigned)0)->m_info.to_info(p_info); - p_info.meta_remove_field("cuesheet"); - } else { - cue_creator::t_entry_list entries; - m_content.enumerate(__get_tag_cue_track_list_builder(entries)); - pfc::string_formatter cuesheet; - cue_creator::create(cuesheet,entries); - entries.remove_all(); - //parse it back to see what info got stored in the cuesheet and what needs to be stored outside cuesheet in the tags - cue_parser::parse_full(cuesheet,entries); - file_info_record output; - - - - - { - file_info_record::t_meta_map globals; - //1. find global infos and forward them - { - field_name_list fields; - m_content.enumerate(__get_tag__enum_fields_enumerator(fields)); - fields.enumerate(__get_tag__filter_globals(m_content,globals)); - } - - output.overwrite_meta(globals); - - //2. find local infos - m_content.enumerate(__get_tag__local_field_filter(globals,output.m_meta)); - } - - - //strip redundant titles and tracknumbers that the cuesheet already contains - for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ++iter) { - strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"tracknumber"); - strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"title"); - } - - - //add tech infos etc - - { - const track_record * rec = m_content.query_ptr((unsigned)0); - if (rec != NULL) { - output.set_length(rec->m_info.get_length()); - output.set_replaygain(rec->m_info.get_replaygain()); - output.overwrite_info(rec->m_info.m_info); - } - } - output.meta_set("cuesheet",cuesheet); - output.to_info(p_info); - } -} - -static bool resolve_cue_meta_name(const char * p_name,pfc::string_base & p_outname,unsigned & p_tracknumber) { - //"cue_trackNN_fieldname" - static const char header[] = "cue_track"; - if (pfc::stricmp_ascii_ex(p_name,strlen(header),header,infinite) != 0) return false; - p_name += strlen(header); - if (!pfc::char_is_numeric(p_name[0]) || !pfc::char_is_numeric(p_name[1]) || p_name[2] != '_') return false; - unsigned tracknumber = pfc::atoui_ex(p_name,2); - if (tracknumber == 0) return false; - p_name += 3; - p_tracknumber = tracknumber; - p_outname = p_name; - return true; -} - - -namespace { - class __set_tag_global_field_relay { - public: - __set_tag_global_field_relay(const file_info & p_info,t_size p_index) : m_info(p_info), m_index(p_index) {} - void operator() (unsigned p_trackno,track_record & p_record) { - if (p_trackno > 0) { - p_record.m_info.transfer_meta_entry(m_info.meta_enum_name(m_index),m_info,m_index); - } - } - private: - const file_info & m_info; - const t_size m_index; - }; -} - -void embeddedcue_metadata_manager::set_tag(file_info const & p_info) { - m_content.remove_all(); - - { - track_record & track0 = m_content.find_or_add((unsigned)0); - track0.m_info.from_info(p_info); - track0.m_info.m_info.set("cue_embedded","no"); - } - - - - const char * cuesheet = p_info.meta_get("cuesheet",0); - if (cuesheet == NULL) { - return; - } - - //processing order - //1. cuesheet content - //2. overwrite with global metadata from the tag - //2. overwrite with local metadata from the tag - - { - cue_creator::t_entry_list entries; - try { - cue_parser::parse_full(cuesheet,entries); - } catch(exception_io_data const & e) { - console::print(e.what()); - return; - } - - for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ) { - cue_creator::t_entry_list::const_iterator next = iter; - ++next; - track_record & entry = m_content.find_or_add(iter->m_track_number); - entry.m_file = iter->m_file; - entry.m_flags = iter->m_flags; - entry.m_index_list = iter->m_index_list; - entry.m_info.from_info(iter->m_infos); - entry.m_info.from_info_overwrite_info(p_info); - entry.m_info.m_info.set("cue_embedded","yes"); - double begin = entry.m_index_list.start(), end = next.is_valid() ? next->m_index_list.start() : p_info.get_length(); - if (end <= begin) throw exception_io_data(); - entry.m_info.set_length(end - begin); - iter = next; - } - } - - for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) { - const char * name = p_info.meta_enum_name(metawalk); - const t_size valuecount = p_info.meta_enum_value_count(metawalk); - if (valuecount > 0 && !is_reserved_meta_entry(name) && is_global_meta_entry(name)) { - __set_tag_global_field_relay relay(p_info,metawalk); - m_content.enumerate(relay); - } - } - - { - pfc::string8_fastalloc namebuffer; - for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk) { - const char * name = p_info.meta_enum_name(metawalk); - const t_size valuecount = p_info.meta_enum_value_count(metawalk); - unsigned trackno; - if (valuecount > 0 && !is_reserved_meta_entry(name) && resolve_cue_meta_name(name,namebuffer,trackno)) { - track_record * rec = m_content.query_ptr(trackno); - if (rec != NULL) { - rec->m_info.transfer_meta_entry(namebuffer,p_info,metawalk); - } - } - } - } -} - -void embeddedcue_metadata_manager::get_track_info(unsigned p_track,file_info & p_info) const { - const track_record * rec = m_content.query_ptr(p_track); - if (rec == NULL) throw exception_io_data(); - rec->m_info.to_info(p_info); -} - -void embeddedcue_metadata_manager::set_track_info(unsigned p_track,file_info const & p_info) { - track_record * rec = m_content.query_ptr(p_track); - if (rec == NULL) throw exception_io_data(); - rec->m_info.from_info_set_meta(p_info); - rec->m_info.set_replaygain(p_info.get_replaygain()); -} - -void embeddedcue_metadata_manager::query_track_offsets(unsigned p_track,double & p_begin,double & p_length) const { - const track_record * rec = m_content.query_ptr(p_track); - if (rec == NULL) throw exception_io_data(); - p_begin = rec->m_index_list.start(); - p_length = rec->m_info.get_length(); -} - -bool embeddedcue_metadata_manager::have_cuesheet() const { - return m_content.get_count() > 1; -} - -namespace { - class __remap_trackno_enumerator { - public: - __remap_trackno_enumerator(unsigned p_index) : m_countdown(p_index), m_result(0) {} - template void operator() (unsigned p_trackno,const t_blah&) { - if (p_trackno > 0 && m_result == 0) { - if (m_countdown == 0) { - m_result = p_trackno; - } else { - --m_countdown; - } - } - } - unsigned result() const {return m_result;} - private: - unsigned m_countdown; - unsigned m_result; - }; -}; - -unsigned embeddedcue_metadata_manager::remap_trackno(unsigned p_index) const { - if (have_cuesheet()) { - __remap_trackno_enumerator wrapper(p_index); - m_content.enumerate(wrapper); - return wrapper.result(); - } else { - return 0; - } -} - -t_size embeddedcue_metadata_manager::get_cue_track_count() const { - return m_content.get_count() - 1; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/cuesheet_index_list.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/cuesheet_index_list.cpp deleted file mode 100644 index 5f9700876..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/cuesheet_index_list.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "stdafx.h" - -static bool is_numeric(char c) {return c>='0' && c<='9';} - - -bool t_cuesheet_index_list::is_valid() const { - if (m_positions[1] < m_positions[0]) return false; - for(t_size n = 2; n < count && m_positions[n] > 0; n++) { - if (m_positions[n] < m_positions[n-1]) return false; - } - return true; -} - -void t_cuesheet_index_list::to_infos(file_info & p_out) const -{ - double base = m_positions[1]; - - if (base > 0) { - p_out.info_set("referenced_offset",cuesheet_format_index_time(base)); - } - - if (m_positions[0] < base) - p_out.info_set("pregap",cuesheet_format_index_time(base - m_positions[0])); - else - p_out.info_remove("pregap"); - - p_out.info_remove("index 00"); - p_out.info_remove("index 01"); - - for(unsigned n=2;n 0) - p_out.info_set(namebuffer,cuesheet_format_index_time(position)); - else - p_out.info_remove(namebuffer); - } -} - -static bool parse_value(const char * p_name,double & p_out) -{ - if (p_name == NULL) return false; - try { - p_out = cuesheet_parse_index_time_e(p_name,strlen(p_name)); - } catch(std::exception const &) {return false;} - return true; -} - -bool t_cuesheet_index_list::from_infos(file_info const & p_in,double p_base) -{ - double pregap; - bool found = false; - if (!parse_value(p_in.info_get("pregap"),pregap)) pregap = 0; - else found = true; - m_positions[0] = p_base - pregap; - m_positions[1] = p_base; - for(unsigned n=2;n= 2) throw std::exception("invalid INDEX time syntax",0); - splitmarks[splitptr++] = ptr; - } - else if (!is_numeric(p_string[ptr])) throw std::exception("invalid INDEX time syntax",0); - } - - t_size minutes_base = 0, minutes_length = 0, seconds_base = 0, seconds_length = 0, frames_base = 0, frames_length = 0; - - switch(splitptr) - { - case 0: - frames_base = 0; - frames_length = p_length; - break; - case 1: - seconds_base = 0; - seconds_length = splitmarks[0]; - frames_base = splitmarks[0] + 1; - frames_length = p_length - frames_base; - break; - case 2: - minutes_base = 0; - minutes_length = splitmarks[0]; - seconds_base = splitmarks[0] + 1; - seconds_length = splitmarks[1] - seconds_base; - frames_base = splitmarks[1] + 1; - frames_length = p_length - frames_base; - break; - } - - unsigned ret = 0; - - if (frames_length > 0) ret += pfc::atoui_ex(p_string + frames_base,frames_length); - if (seconds_length > 0) ret += 75 * pfc::atoui_ex(p_string + seconds_base,seconds_length); - if (minutes_length > 0) ret += 60 * 75 * pfc::atoui_ex(p_string + minutes_base,minutes_length); - - return ret; -} - - -bool t_cuesheet_index_list::is_empty() const { - for(unsigned n=0;nptMaxTrackSize.x = r.right - r.left; - info->ptMaxTrackSize.y = r.bottom - r.top; - } - if (min_x && min_y) - { - r.left = 0; r.right = min_x; - r.top = 0; r.bottom = min_y; - MapDialogRect(hWnd,&r); - AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle); - info->ptMinTrackSize.x = r.right - r.left; - info->ptMinTrackSize.y = r.bottom - r.top; - } - } - lResult = 0; - return TRUE; - case WM_INITDIALOG: - set_parent(hWnd); - { - t_size n; - for(n=0;n rects; - RECT orig_client; - HWND parent; - HWND sizegrip; - unsigned min_x,min_y,max_x,max_y; - -public: - struct param { - unsigned short id; - unsigned short flags; - }; -private: - pfc::array_t m_table; - - void set_parent(HWND wnd); - void reset(); - void on_wm_size(); -public: - inline void set_min_size(unsigned x,unsigned y) {min_x = x; min_y = y;} - inline void set_max_size(unsigned x,unsigned y) {max_x = x; max_y = y;} - void add_sizegrip(); - - enum { - X_MOVE = 1, X_SIZE = 2, Y_MOVE = 4, Y_SIZE = 8, - XY_MOVE = X_MOVE|Y_MOVE, XY_SIZE = X_SIZE|Y_SIZE, - X_MOVE_Y_SIZE = X_MOVE|Y_SIZE, X_SIZE_Y_MOVE = X_SIZE|Y_MOVE, - }; - //the old way - bool process_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); - - //ATL-compatible - BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult); - - dialog_resize_helper(const param * src,unsigned count,unsigned p_min_x,unsigned p_min_y,unsigned p_max_x,unsigned p_max_y); - - ~dialog_resize_helper(); - - PFC_CLASS_NOT_COPYABLE_EX(dialog_resize_helper); -}; - -#endif diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/dropdown_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/dropdown_helper.cpp deleted file mode 100644 index f75427e90..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/dropdown_helper.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "stdafx.h" -#include "dropdown_helper.h" - - -void cfg_dropdown_history::build_list(pfc::ptr_list_t & out) -{ - const char * src = data; - while(*src) - { - int ptr = 0; - while(src[ptr] && src[ptr]!=separator) ptr++; - if (ptr>0) - { - out.add_item(pfc::strdup_n(src,ptr)); - src += ptr; - } - while(*src==separator) src++; - } -} - -void cfg_dropdown_history::parse_list(const pfc::ptr_list_t & src) -{ - t_size n; - pfc::string8_fastalloc temp; - for(n=0;n & list) -{ - t_size n, m = list.get_count(); - uSendMessage(wnd,CB_RESETCONTENT,0,0); - for(n=0;n list; - build_list(list); - g_setup_dropdown_fromlist(wnd,list); - list.free_all(); -} - -void cfg_dropdown_history::add_item(const char * item) -{ - if (!item || !*item) return; - pfc::string8 meh; - if (strchr(item,separator)) - { - uReplaceChar(meh,item,-1,separator,'|',false); - item = meh; - } - pfc::ptr_list_t list; - build_list(list); - unsigned n; - bool found = false; - for(n=0;n max) list.delete_by_idx(list.get_count()-1); - list.insert_item(_strdup(item),0); - } - parse_list(list); - list.free_all(); -} - -bool cfg_dropdown_history::is_empty() -{ - const char * src = data; - while(*src) - { - if (*src!=separator) return false; - src++; - } - return true; -} - -void cfg_dropdown_history::on_context(HWND wnd,LPARAM coords) { - try { - int coords_x = (short)LOWORD(coords), coords_y = (short)HIWORD(coords); - if (coords_x == -1 && coords_y == -1) - { - RECT asdf; - GetWindowRect(wnd,&asdf); - coords_x = (asdf.left + asdf.right) / 2; - coords_y = (asdf.top + asdf.bottom) / 2; - } - enum {ID_ERASE_ALL = 1, ID_ERASE_ONE }; - HMENU menu = CreatePopupMenu(); - uAppendMenu(menu,MF_STRING,ID_ERASE_ALL,"Wipe history"); - { - pfc::string8 tempvalue; - uGetWindowText(wnd,tempvalue); - if (!tempvalue.is_empty()) - uAppendMenu(menu,MF_STRING,ID_ERASE_ONE,"Remove this history item"); - } - int cmd = TrackPopupMenu(menu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,coords_x,coords_y,0,wnd,0); - DestroyMenu(menu); - switch(cmd) - { - case ID_ERASE_ALL: - { - data = ""; - pfc::string8 value;//preserve old value while wiping dropdown list - uGetWindowText(wnd,value); - uSendMessage(wnd,CB_RESETCONTENT,0,0); - uSetWindowText(wnd,value); - } - break; - case ID_ERASE_ONE: - { - pfc::string8 value; - uGetWindowText(wnd,value); - - pfc::ptr_list_t list; - t_size n,m; - bool found; - build_list(list); - m = list.get_count(); - found = false; - for(n=0;n & out); - void parse_list(const pfc::ptr_list_t & src); -public: - cfg_dropdown_history(const GUID & p_guid,unsigned p_max = 10,const char * init_vals = "") : data(p_guid,init_vals) {max = p_max;} - void setup_dropdown(HWND wnd); - void setup_dropdown(HWND wnd,UINT id) {setup_dropdown(GetDlgItem(wnd,id));} - void add_item(const char * item); - bool is_empty(); - void on_context(HWND wnd,LPARAM coords); -}; - -// ATL-compatible message map entry macro for installing dropdown list context menus. -#define DROPDOWN_HISTORY_HANDLER(ctrlID,var) \ - if(uMsg == WM_CONTEXTMENU) { \ - const HWND source = (HWND) wParam; \ - if (source != NULL && source == GetDlgItem(ctrlID)) { \ - var.on_context(source,lParam); \ - lResult = 0; \ - return TRUE; \ - } \ - } - -#endif //_DROPDOWN_HELPER_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/dynamic_bitrate_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/dynamic_bitrate_helper.cpp deleted file mode 100644 index 2be9380be..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/dynamic_bitrate_helper.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "stdafx.h" - -static unsigned g_query_settings() -{ - t_int32 temp; - try { - config_object::g_get_data_int32(standard_config_objects::int32_dynamic_bitrate_display_rate,temp); - } catch(std::exception const &) {return 9;} - if (temp < 0) return 0; - return (unsigned) temp; -} - -dynamic_bitrate_helper::dynamic_bitrate_helper() -{ - reset(); -} - -void dynamic_bitrate_helper::init() -{ - if (!m_inited) - { - m_inited = true; - unsigned temp = g_query_settings(); - if (temp > 0) {m_enabled = true; m_update_interval = 1.0 / (double) temp; } - else {m_enabled = false; m_update_interval = 0; } - m_last_duration = 0; - m_update_bits = 0; - m_update_time = 0; - - } -} - -void dynamic_bitrate_helper::on_frame(double p_duration,t_size p_bits) -{ - init(); - m_last_duration = p_duration; - m_update_time += p_duration; - m_update_bits += p_bits; -} - -bool dynamic_bitrate_helper::on_update(file_info & p_out, double & p_timestamp_delta) -{ - init(); - - bool ret = false; - if (m_enabled) - { - if (m_update_time > m_update_interval) - { - int val = (int) ( ((double)m_update_bits / m_update_time + 500.0) / 1000.0 ); - if (val != p_out.info_get_bitrate_vbr()) - { - p_timestamp_delta = - (m_update_time - m_last_duration); //relative to last frame beginning; - p_out.info_set_bitrate_vbr(val); - ret = true; - } - m_update_bits = 0; - m_update_time = 0; - } - } - else - { - m_update_bits = 0; - m_update_time = 0; - } - - return ret; - -} - -void dynamic_bitrate_helper::reset() -{ - m_inited = false; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/dynamic_bitrate_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/dynamic_bitrate_helper.h deleted file mode 100644 index 6480c679e..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/dynamic_bitrate_helper.h +++ /dev/null @@ -1,15 +0,0 @@ -class dynamic_bitrate_helper -{ -public: - dynamic_bitrate_helper(); - void on_frame(double p_duration,t_size p_bits); - bool on_update(file_info & p_out, double & p_timestamp_delta); - void reset(); -private: - void init(); - double m_last_duration; - t_size m_update_bits; - double m_update_time; - double m_update_interval; - bool m_inited, m_enabled; -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_cached.h b/tools/vio2sf/src/foobar/foobar2000/helpers/file_cached.h deleted file mode 100644 index b31be524b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_cached.h +++ /dev/null @@ -1,116 +0,0 @@ -class file_cached : public file { -public: - static void g_create(service_ptr_t & p_out,service_ptr_t p_base,abort_callback & p_abort, t_size blockSize) { - service_ptr_t temp = new service_impl_t(blockSize); - temp->initialize(p_base,p_abort); - p_out = temp.get_ptr(); - } -protected: - file_cached(t_size blocksize) { - m_buffer.set_size(blocksize); - } - void initialize(service_ptr_t p_base,abort_callback & p_abort) { - m_base = p_base; - m_position = 0; - m_can_seek = m_base->can_seek(); - if (m_can_seek) { - m_position_base = m_base->get_position(p_abort); - } else { - m_position_base = 0; - } - - m_size = m_base->get_size(p_abort); - - flush_buffer(); - } -public: - - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - t_uint8 * outptr = (t_uint8*)p_buffer; - t_size done = 0; - while(done < p_bytes && m_position < m_size) { - p_abort.check(); - - if (m_position >= m_buffer_position && m_position < m_buffer_position + m_buffer_status) { - t_size delta = pfc::min_t((t_size)(m_buffer_position + m_buffer_status - m_position),p_bytes - done); - t_size bufptr = (t_size)(m_position - m_buffer_position); - memcpy(outptr+done,m_buffer.get_ptr()+bufptr,delta); - done += delta; - m_position += delta; - if (m_buffer_status != m_buffer.get_size() && done < p_bytes) break;//EOF before m_size is hit - } else { - m_buffer_position = m_position - m_position % m_buffer.get_size(); - adjust_position(m_buffer_position,p_abort); - - m_buffer_status = m_base->read(m_buffer.get_ptr(),m_buffer.get_size(),p_abort); - m_position_base += m_buffer_status; - - if (m_buffer_status <= (t_size)(m_position - m_buffer_position)) break; - } - } - - return done; - } - - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check(); - adjust_position(m_position,p_abort); - m_base->write(p_buffer,p_bytes,p_abort); - m_position_base = m_position = m_position + p_bytes; - if (m_size < m_position) m_size = m_position; - flush_buffer(); - } - - t_filesize get_size(abort_callback & p_abort) { - p_abort.check(); - return m_size; - } - t_filesize get_position(abort_callback & p_abort) { - p_abort.check(); - return m_position; - } - void set_eof(abort_callback & p_abort) { - p_abort.check(); - adjust_position(m_position,p_abort); - m_base->set_eof(p_abort); - flush_buffer(); - } - void seek(t_filesize p_position,abort_callback & p_abort) { - p_abort.check(); - if (!m_can_seek) throw exception_io_object_not_seekable(); - if (p_position > m_size) throw exception_io_seek_out_of_range(); - m_position = p_position; - } - void reopen(abort_callback & p_abort) {seek(0,p_abort);} - bool can_seek() {return m_can_seek;} - bool get_content_type(pfc::string_base & out) {return m_base->get_content_type(out);} - void on_idle(abort_callback & p_abort) {p_abort.check();m_base->on_idle(p_abort);} - t_filetimestamp get_timestamp(abort_callback & p_abort) {p_abort.check(); return m_base->get_timestamp(p_abort);} - bool is_remote() {return m_base->is_remote();} - void resize(t_filesize p_size,abort_callback & p_abort) { - flush_buffer(); - m_base->resize(p_size,p_abort); - m_size = p_size; - if (m_position > m_size) m_position = m_size; - if (m_position_base > m_size) m_position_base = m_size; - } -private: - void adjust_position(t_filesize p_target,abort_callback & p_abort) { - if (p_target != m_position_base) { - m_base->seek(p_target,p_abort); - m_position_base = p_target; - } - } - - void flush_buffer() { - m_buffer_status = 0; - m_buffer_position = 0; - } - - service_ptr_t m_base; - t_filesize m_position,m_position_base,m_size; - bool m_can_seek; - t_filesize m_buffer_position; - t_size m_buffer_status; - pfc::array_t m_buffer; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_const_impl.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_const_impl.cpp deleted file mode 100644 index 1851fac3b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_const_impl.cpp +++ /dev/null @@ -1,269 +0,0 @@ -#include "stdafx.h" - -// presorted - do not change without a proper strcmp resort -static const char * const standard_fieldnames[] = { - "ALBUM","ALBUM ARTIST","ARTIST","Album","Album Artist","Artist","COMMENT","Comment","DATE","DISCNUMBER","Date", - "Discnumber","GENRE","Genre","TITLE","TOTALTRACKS","TRACKNUMBER","Title","TotalTracks","Totaltracks","TrackNumber", - "Tracknumber","album","album artist","artist","comment","date","discnumber","genre","title","totaltracks","tracknumber", -}; - -// presorted - do not change without a proper strcmp resort -static const char * const standard_infonames[] = { - "bitrate","bitspersample","channels","codec","codec_profile","encoding","samplerate","tagtype","tool", -}; - -static const char * optimize_fieldname(const char * p_string) { - t_size index; - if (!pfc::binarySearch::run(standard_fieldnames,0,tabsize(standard_fieldnames),p_string,index)) return NULL; - return standard_fieldnames[index]; -} - -static const char * optimize_infoname(const char * p_string) { - t_size index; - if (!pfc::binarySearch::run(standard_infonames,0,tabsize(standard_infonames),p_string,index)) return NULL; - return standard_infonames[index]; -} - -/* -order of things - - meta entries - meta value map - info entries - string buffer - -*/ - -inline static char* stringbuffer_append(char * & buffer,const char * value) -{ - char * ret = buffer; - while(*value) *(buffer++) = *(value++); - *(buffer++) = 0; - return ret; -} - -#ifdef __file_info_const_impl_have_hintmap__ - -namespace { - class sort_callback_hintmap_impl : public pfc::sort_callback - { - public: - sort_callback_hintmap_impl(const file_info_const_impl::meta_entry * p_meta,file_info_const_impl::t_index * p_hintmap) - : m_meta(p_meta), m_hintmap(p_hintmap) - { - } - - int compare(t_size p_index1, t_size p_index2) const - { -// profiler(sort_callback_hintmap_impl_compare); - return pfc::stricmp_ascii(m_meta[m_hintmap[p_index1]].m_name,m_meta[m_hintmap[p_index2]].m_name); - } - - void swap(t_size p_index1, t_size p_index2) - { - pfc::swap_t(m_hintmap[p_index1],m_hintmap[p_index2]); - } - private: - const file_info_const_impl::meta_entry * m_meta; - file_info_const_impl::t_index * m_hintmap; - }; - - class bsearch_callback_hintmap_impl// : public pfc::bsearch_callback - { - public: - bsearch_callback_hintmap_impl( - const file_info_const_impl::meta_entry * p_meta, - const file_info_const_impl::t_index * p_hintmap, - const char * p_name, - t_size p_name_length) - : m_meta(p_meta), m_hintmap(p_hintmap), m_name(p_name), m_name_length(p_name_length) - { - } - - inline int test(t_size p_index) const - { - return pfc::stricmp_ascii_ex(m_meta[m_hintmap[p_index]].m_name,infinite,m_name,m_name_length); - } - - private: - const file_info_const_impl::meta_entry * m_meta; - const file_info_const_impl::t_index * m_hintmap; - const char * m_name; - t_size m_name_length; - }; -} - -#endif//__file_info_const_impl_have_hintmap__ - -void file_info_const_impl::copy(const file_info & p_source) -{ -// profiler(file_info_const_impl__copy); - t_size meta_size = 0; - t_size info_size = 0; - t_size valuemap_size = 0; - t_size stringbuffer_size = 0; -#ifdef __file_info_const_impl_have_hintmap__ - t_size hintmap_size = 0; -#endif - - { -// profiler(file_info_const_impl__copy__pass1); - t_size index; - m_meta_count = pfc::downcast_guarded(p_source.meta_get_count()); - meta_size = m_meta_count * sizeof(meta_entry); -#ifdef __file_info_const_impl_have_hintmap__ - hintmap_size = (m_meta_count > hintmap_cutoff) ? m_meta_count * sizeof(t_index) : 0; -#endif//__file_info_const_impl_have_hintmap__ - for(index = 0; index < m_meta_count; index++ ) - { - { - const char * name = p_source.meta_enum_name(index); - if (optimize_fieldname(name) == 0) - stringbuffer_size += strlen(name) + 1; - } - - t_size val; const t_size val_max = p_source.meta_enum_value_count(index); - - if (val_max == 1) - { - stringbuffer_size += strlen(p_source.meta_enum_value(index,0)) + 1; - } - else - { - valuemap_size += val_max * sizeof(char*); - - for(val = 0; val < val_max; val++ ) - { - stringbuffer_size += strlen(p_source.meta_enum_value(index,val)) + 1; - } - } - } - - m_info_count = pfc::downcast_guarded(p_source.info_get_count()); - info_size = m_info_count * sizeof(info_entry); - for(index = 0; index < m_info_count; index++ ) - { - const char * name = p_source.info_enum_name(index); - if (optimize_infoname(name) == NULL) stringbuffer_size += strlen(name) + 1; - stringbuffer_size += strlen(p_source.info_enum_value(index)) + 1; - } - } - - - { -// profiler(file_info_const_impl__copy__alloc); - m_buffer.set_size( -#ifdef __file_info_const_impl_have_hintmap__ - hintmap_size + -#endif - meta_size + info_size + valuemap_size + stringbuffer_size); - } - - char * walk = m_buffer.get_ptr(); - -#ifdef __file_info_const_impl_have_hintmap__ - t_index* hintmap = (hintmap_size > 0) ? (t_index*) walk : NULL; - walk += hintmap_size; -#endif - meta_entry * meta = (meta_entry*) walk; - walk += meta_size; - char ** valuemap = (char**) walk; - walk += valuemap_size; - info_entry * info = (info_entry*) walk; - walk += info_size; - char * stringbuffer = walk; - - m_meta = meta; - m_info = info; -#ifdef __file_info_const_impl_have_hintmap__ - m_hintmap = hintmap; -#endif - - { -// profiler(file_info_const_impl__copy__pass2); - t_size index; - for( index = 0; index < m_meta_count; index ++ ) - { - t_size val; const t_size val_max = p_source.meta_enum_value_count(index); - - { - const char * name = p_source.meta_enum_name(index); - const char * name_opt = optimize_fieldname(name); - if (name_opt == NULL) - meta[index].m_name = stringbuffer_append(stringbuffer, name ); - else - meta[index].m_name = name_opt; - } - - meta[index].m_valuecount = val_max; - - if (val_max == 1) - { - meta[index].m_valuemap = reinterpret_cast(stringbuffer_append(stringbuffer, p_source.meta_enum_value(index,0) )); - } - else - { - meta[index].m_valuemap = valuemap; - for( val = 0; val < val_max ; val ++ ) - *(valuemap ++ ) = stringbuffer_append(stringbuffer, p_source.meta_enum_value(index,val) ); - } - } - - for( index = 0; index < m_info_count; index ++ ) - { - const char * name = p_source.info_enum_name(index); - const char * name_opt = optimize_infoname(name); - if (name_opt == NULL) - info[index].m_name = stringbuffer_append(stringbuffer, name ); - else - info[index].m_name = name_opt; - info[index].m_value = stringbuffer_append(stringbuffer, p_source.info_enum_value(index) ); - } - } - - m_length = p_source.get_length(); - m_replaygain = p_source.get_replaygain(); -#ifdef __file_info_const_impl_have_hintmap__ - if (hintmap != NULL) { -// profiler(file_info_const_impl__copy__hintmap); - for(t_size n=0;n(entry.m_valuemap); - else - return entry.m_valuemap[p_value_number]; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_const_impl.h b/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_const_impl.h deleted file mode 100644 index 05cd5e595..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_const_impl.h +++ /dev/null @@ -1,78 +0,0 @@ -#define __file_info_const_impl_have_hintmap__ - -//! Special implementation of file_info that implements only const and copy methods. The difference between this and regular file_info_impl is amount of resources used and speed of the copy operation. -class file_info_const_impl : public file_info -{ -public: - file_info_const_impl(const file_info & p_source) {copy(p_source);} - file_info_const_impl(const file_info_const_impl & p_source) {copy(p_source);} - file_info_const_impl() {m_meta_count = m_info_count = 0; m_length = 0; m_replaygain.reset();} - - double get_length() const {return m_length;} - - t_size meta_get_count() const {return m_meta_count;} - const char* meta_enum_name(t_size p_index) const {return m_meta[p_index].m_name;} - t_size meta_enum_value_count(t_size p_index) const; - const char* meta_enum_value(t_size p_index,t_size p_value_number) const; - t_size meta_find_ex(const char * p_name,t_size p_name_length) const; - - t_size info_get_count() const {return m_info_count;} - const char* info_enum_name(t_size p_index) const {return m_info[p_index].m_name;} - const char* info_enum_value(t_size p_index) const {return m_info[p_index].m_value;} - - - const file_info_const_impl & operator=(const file_info & p_source) {copy(p_source); return *this;} - const file_info_const_impl & operator=(const file_info_const_impl & p_source) {copy(p_source); return *this;} - void copy(const file_info & p_source); - void reset(); - - replaygain_info get_replaygain() const {return m_replaygain;} - -private: - void set_length(double p_length) {throw pfc::exception_bug_check_v2();} - - t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {throw pfc::exception_bug_check_v2();} - void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) {throw pfc::exception_bug_check_v2();} - void meta_remove_mask(const bit_array & p_mask) {throw pfc::exception_bug_check_v2();} - void meta_reorder(const t_size * p_order) {throw pfc::exception_bug_check_v2();} - void meta_remove_values(t_size p_index,const bit_array & p_mask) {throw pfc::exception_bug_check_v2();} - void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) {throw pfc::exception_bug_check_v2();} - - t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {throw pfc::exception_bug_check_v2();} - void info_remove_mask(const bit_array & p_mask) {throw pfc::exception_bug_check_v2();} - - void set_replaygain(const replaygain_info & p_info) {throw pfc::exception_bug_check_v2();} - - t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {throw pfc::exception_bug_check_v2();} - t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {throw pfc::exception_bug_check_v2();} -public: - struct meta_entry { - const char * m_name; - t_size m_valuecount; - const char * const * m_valuemap; - }; - - struct info_entry { - const char * m_name; - const char * m_value; - }; - -#ifdef __file_info_const_impl_have_hintmap__ - typedef t_uint32 t_index; - enum {hintmap_cutoff = 20}; -#endif//__file_info_const_impl_have_hintmap__ -private: - pfc::array_t m_buffer; - t_index m_meta_count; - t_index m_info_count; - - const meta_entry * m_meta; - const info_entry * m_info; - -#ifdef __file_info_const_impl_have_hintmap__ - const t_index * m_hintmap; -#endif - - double m_length; - replaygain_info m_replaygain; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_update_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_update_helper.cpp deleted file mode 100644 index 618797247..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_update_helper.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "stdafx.h" - -file_info_update_helper::file_info_update_helper(metadb_handle_ptr p_item) -{ - const t_size count = 1; - m_data.add_item(p_item); - - m_infos.set_size(count); - m_mask.set_size(count); - for(t_size n=0;n & p_data) -{ - const t_size count = p_data.get_count(); - m_data.add_items(p_data); - - m_infos.set_size(count); - m_mask.set_size(count); - for(t_size n=0;n api; - if (api->load_info_multi(m_data,metadb_io::load_info_default,p_parent,p_show_errors) != metadb_io::load_info_success) return false; - t_size n; const t_size m = m_data.get_count(); - t_size loaded_count = 0; - for(n=0;nget_info(m_infos[n]); - if (val) loaded_count++; - m_mask[n] = val; - } - return loaded_count == m; -} - -file_info_update_helper::t_write_result file_info_update_helper::write_infos(HWND p_parent,bool p_show_errors) -{ - t_size n, outptr = 0; const t_size count = m_data.get_count(); - pfc::array_t items_to_update; - pfc::array_t infos_to_write; - items_to_update.set_size(count); - infos_to_write.set_size(count); - - for(n=0;n api; - switch(api->update_info_multi( - pfc::list_const_array_t&>(items_to_update,outptr), - pfc::list_const_array_t&>(infos_to_write,outptr), - p_parent, - true - )) - { - case metadb_io::update_info_success: - return write_ok; - case metadb_io::update_info_aborted: - return write_aborted; - default: - case metadb_io::update_info_errors: - return write_error; - } - } -} - -t_size file_info_update_helper::get_item_count() const -{ - return m_data.get_count(); -} - -bool file_info_update_helper::is_item_valid(t_size p_index) const -{ - return m_mask[p_index]; -} - -file_info & file_info_update_helper::get_item(t_size p_index) -{ - return m_infos[p_index]; -} - -metadb_handle_ptr file_info_update_helper::get_item_handle(t_size p_index) const -{ - return m_data[p_index]; -} - -void file_info_update_helper::invalidate_item(t_size p_index) -{ - m_mask[p_index] = false; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_update_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_update_helper.h deleted file mode 100644 index 831446481..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_info_update_helper.h +++ /dev/null @@ -1,29 +0,0 @@ -//! Deprecated - relies on old blocking metadb_io methods - use metadb_io_v2::update_info_async w/ file_info_filter whenever possible. -class __declspec(deprecated("Use metadb_io_v2::update_info_async instead whenever possible.")) file_info_update_helper { -public: - file_info_update_helper(const pfc::list_base_const_t & p_data); - file_info_update_helper(metadb_handle_ptr p_item); - - bool read_infos(HWND p_parent,bool p_show_errors); - - enum t_write_result - { - write_ok, - write_aborted, - write_error - }; - t_write_result write_infos(HWND p_parent,bool p_show_errors); - - t_size get_item_count() const; - bool is_item_valid(t_size p_index) const;//returns false where info reading failed - - file_info & get_item(t_size p_index); - metadb_handle_ptr get_item_handle(t_size p_index) const; - - void invalidate_item(t_size p_index); - -private: - metadb_handle_list m_data; - pfc::array_t m_infos; - pfc::array_t m_mask; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_list_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/file_list_helper.cpp deleted file mode 100644 index 4053e73a0..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_list_helper.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "stdafx.h" - -static void file_list_remove_duplicates(pfc::ptr_list_t & out) -{ - t_size n, m = out.get_count(); - out.sort_t(metadb::path_compare); - bit_array_bittable mask(m); - t_size duplicates = 0; - for(n=1;n0) { - out.free_mask(mask); - } -} - - -namespace file_list_helper -{ - t_size file_list_from_metadb_handle_list::g_get_count(metadb_handle_list_cref data, t_size max) { - pfc::avltree_t content; - const t_size inCount = data.get_size(); - for(t_size walk = 0; walk < inCount && content.get_count() < max; ++walk) { - content += data[walk]->get_path(); - } - return content.get_count(); - } - void file_list_from_metadb_handle_list::__add(const char * p_what) { - char * temp = _strdup(p_what); - if (temp == NULL) throw std::bad_alloc(); - try {m_data.add_item(temp); } catch(...) {free(temp); throw;} - } - - void file_list_from_metadb_handle_list::init_from_list(const list_base_const_t & p_list) - { - m_data.free_all(); - - t_size n, m = p_list.get_count(); - for(n=0;nget_path() ); - } - file_list_remove_duplicates(m_data); - } - - void file_list_from_metadb_handle_list::init_from_list_display(const list_base_const_t & p_list) - { - m_data.free_all(); - - pfc::string8_fastalloc temp; - - t_size n, m = p_list.get_count(); - for(n=0;nget_path(),temp); - __add(temp); - } - file_list_remove_duplicates(m_data); - - - } - - t_size file_list_from_metadb_handle_list::get_count() const {return m_data.get_count();} - void file_list_from_metadb_handle_list::get_item_ex(const char * & p_out,t_size n) const {p_out = m_data.get_item(n);} - - file_list_from_metadb_handle_list::~file_list_from_metadb_handle_list() - { - m_data.free_all(); - } - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_list_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/file_list_helper.h deleted file mode 100644 index 3cf03831c..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_list_helper.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _foobar2000_helpers_file_list_helper_ -#define _foobar2000_helpers_file_list_helper_ - - -namespace file_list_helper -{ - //list guaranteed to be sorted by metadb::path_compare - class file_list_from_metadb_handle_list : public pfc::list_base_const_t { - public: - - static t_size g_get_count(const list_base_const_t & p_list, t_size max = ~0); - - void init_from_list(const list_base_const_t & p_list); - void init_from_list_display(const list_base_const_t & p_list); - - t_size get_count() const; - void get_item_ex(const char * & p_out,t_size n) const; - - ~file_list_from_metadb_handle_list(); - - private: - void __add(const char * p_what); - pfc::ptr_list_t m_data; - }; - - -}; - - -#endif //_foobar2000_helpers_file_list_helper_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_move_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/file_move_helper.cpp deleted file mode 100644 index b54c99e76..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_move_helper.cpp +++ /dev/null @@ -1,278 +0,0 @@ -#include "stdafx.h" - -static bool grab_items_by_path(pfc::list_base_t & p_out,const char * p_path,abort_callback & p_abort) -{ - try { - pfc::string8 path; - filesystem::g_get_canonical_path(p_path,path); - p_out.remove_all(); - service_ptr_t reader; - input_entry::g_open_for_info_read(reader,0,path,p_abort); - - static_api_ptr_t l_metadb; - - const t_uint32 count = reader->get_subsong_count(); - for(t_uint32 n=0;nhandle_create(ptr,make_playable_location(path,reader->get_subsong(n))); - p_out.add_item(ptr); - } - - return p_out.get_count() > 0; - } catch(std::exception const &) {return false;} -} - -file_move_helper::file_move_helper() {} -file_move_helper::~file_move_helper() {} -file_move_helper::file_move_helper(const file_move_helper & p_src) {*this = p_src;} - -bool file_move_helper::take_snapshot(const char * p_path,abort_callback & p_abort) -{ - in_metadb_sync blah; - - m_source_handles.remove_all(); - m_data.set_size(0); - if (!grab_items_by_path(m_source_handles,p_path,p_abort)) return false; - t_size n, m = m_source_handles.get_count(); - m_data.set_size(m); - for(n=0;nget_location(); - m_data[n].m_have_info = m_source_handles[n]->get_info(m_data[n].m_info); - m_data[n].m_stats = m_source_handles[n]->get_filestats(); - - } - return true; -} - -bool file_move_helper::on_moved(const char * p_path,abort_callback & p_abort) -{ - bool ret; - file_move_callback_manager cb; - ret = on_moved(p_path,p_abort,cb); - cb.run_callback(); - return ret; -} - -bool file_move_helper::on_copied(const char * p_path,abort_callback & p_abort) -{ - bool ret; - file_move_callback_manager cb; - ret = on_copied(p_path,p_abort,cb); - cb.run_callback(); - return ret; -} - -bool file_move_helper::on_moved(const char * p_path,abort_callback & p_abort,file_move_callback_manager & p_cb) -{ - file_path_canonical path(p_path); - if (m_data.get_size() == 0) return false; - if (!metadb::path_compare(path,get_source_path())) return true; - - metadb_handle_list items; - make_new_item_list(items,path,p_cb); - - - /*if (p_update_db)*/ - p_cb.on_library_add_items(items); - p_cb.on_library_remove_items(m_source_handles); - - p_cb.on_moved(pfc::list_single_ref_t(get_source_path()),pfc::list_single_ref_t(path)); - - return true; -} - -bool file_move_helper::on_copied(const char * p_path,abort_callback & p_abort,file_move_callback_manager & p_cb) -{ - file_path_canonical path(p_path); - if (m_data.get_size() == 0) return false; - if (!metadb::path_compare(path,get_source_path())) return true; - metadb_handle_list items; - make_new_item_list(items,path,p_cb); - /*if (p_update_db)*/ p_cb.on_library_add_items(items); - p_cb.on_copied(pfc::list_single_ref_t(get_source_path()),pfc::list_single_ref_t(path)); - return true; -} - -bool file_move_helper::g_on_deleted(const pfc::list_base_const_t & p_files) -{ - file_operation_callback::g_on_files_deleted(p_files); - return true; -} - -void file_move_helper::make_new_item_list(pfc::list_base_t & p_out,const char * p_new_path,file_move_callback_manager & p_cb) -{ - pfc::string8 new_path; - filesystem::g_get_canonical_path(p_new_path,new_path); - - t_size n; const t_size m = m_data.get_size(); - static_api_ptr_t api; - pfc::array_t hint_handles; - pfc::array_t hint_infos; - pfc::array_t hint_stats; - hint_handles.set_size(m); hint_infos.set_size(m); hint_stats.set_size(m); - t_size hintptr = 0; - for(n=0;nhandle_create(temp,make_playable_location(new_path,m_data[n].m_location.get_subsong())); - if (m_data[n].m_have_info) - { - hint_handles[hintptr] = temp; - hint_infos[hintptr] = &m_data[n].m_info; - hint_stats[hintptr] = m_data[n].m_stats; - - hintptr++; - } - p_out.add_item(temp); - } - - if (hintptr > 0) - { - p_cb.on_hint( - pfc::list_const_array_t &>(hint_handles,hintptr), - pfc::list_const_array_t &>(hint_infos,hintptr), - pfc::list_const_array_t &>(hint_stats,hintptr) - ); -/* - static_api_ptr_t()->hint_multi( - list_const_array_t &>(hint_handles,hintptr), - list_const_array_t &>(hint_infos,hintptr), - list_const_array_t &>(hint_stats,hintptr), - bit_array_false());*/ - } - -} - -const char * file_move_helper::get_source_path() const -{ - return m_data.get_size() > 0 ? m_data[0].m_location.get_path() : 0; -} - -t_size file_move_helper::g_filter_dead_files_sorted_make_mask(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead,bit_array_var & p_mask) -{ - t_size n, m = p_data.get_count(); - t_size found = 0; - for(n=0;nget_path(),dummy); - if (dead) found++; - p_mask.set(n,dead); - } - return found; -} - -t_size file_move_helper::g_filter_dead_files_sorted(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead) -{ - bit_array_bittable mask(p_data.get_count()); - t_size found = g_filter_dead_files_sorted_make_mask(p_data,p_dead,mask); - if (found > 0) p_data.remove_mask(mask); - return found; -} - -t_size file_move_helper::g_filter_dead_files(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead) -{ - pfc::ptr_list_t temp; - temp.add_items(p_dead); - temp.sort_t(metadb::path_compare); - return g_filter_dead_files_sorted(p_data,temp); -} - - -void file_move_callback_manager::on_library_add_items(const pfc::list_base_const_t & p_data) -{ - m_added.add_items(p_data); -} - -void file_move_callback_manager::on_library_remove_items(const pfc::list_base_const_t & p_data) -{ - m_removed.add_items(p_data); -} - -void file_move_callback_manager::on_moved(const pfc::string_list_const & p_from,const pfc::string_list_const & p_to) -{ - assert(p_from.get_count() == p_to.get_count()); - m_move_from += p_from; - m_move_to += p_to; -} - -void file_move_callback_manager::on_copied(const pfc::string_list_const & p_from,const pfc::string_list_const & p_to) -{ - assert(p_from.get_count() == p_to.get_count()); - m_copy_from += p_from; - m_copy_to += p_to; -} - -void file_move_callback_manager::on_hint(const pfc::list_base_const_t & p_list,const pfc::list_base_const_t & p_infos,const pfc::list_base_const_t & p_stats) -{ - m_hint_handles.add_items(p_list); - m_hint_stats.add_items(p_stats); - - { - t_size old_count = m_hint_infos.get_count(), delta = p_infos.get_count(); - m_hint_infos.set_count(old_count + delta); - for(t_size n=0;n m_hint_infos; - list_t m_hint_stats;*/ - -} - - -void file_move_callback_manager::run_callback() -{ - if (m_hint_handles.get_count() > 0) - { - static_api_ptr_t()->hint_multi( - m_hint_handles, - pfc::ptr_list_const_array_t &>(m_hint_infos,m_hint_infos.get_count()), - m_hint_stats, - bit_array_false()); - - m_hint_infos.remove_all(); - m_hint_stats.remove_all(); - - //trick to make sure values don't get wiped - //m_hint_handles.remove_all(); - - } - - assert(m_copy_from.get_count() == m_copy_to.get_count()); - assert(m_move_from.get_count() == m_move_to.get_count()); - - static_api_ptr_t api_library_manager; - - if (m_added.get_count() > 0) - { - api_library_manager->add_items(m_added); - m_added.remove_all(); - } - - if (m_removed.get_count()) - { - api_library_manager->remove_items(m_removed); - m_removed.remove_all(); - } - - if (m_copy_from.get_count() > 0) - { - file_operation_callback::g_on_files_copied(m_copy_from,m_copy_to); - m_copy_from.remove_all(); - m_copy_to.remove_all(); - } - - if (m_move_from.get_count() > 0) - { - file_operation_callback::g_on_files_moved(m_move_from,m_move_to); - m_move_from.remove_all(); - m_move_to.remove_all(); - } - - //trick to make sure values don't get wiped - m_hint_handles.remove_all(); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_move_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/file_move_helper.h deleted file mode 100644 index d2e9622e7..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_move_helper.h +++ /dev/null @@ -1,60 +0,0 @@ -class file_move_callback_manager -{ -public: - void on_library_add_items(const pfc::list_base_const_t & p_data); - void on_library_remove_items(const pfc::list_base_const_t & p_data); - - void on_moved(const pfc::string_list_const & p_from,const pfc::string_list_const & p_to); - void on_copied(const pfc::string_list_const & p_from,const pfc::string_list_const & p_to); - - void on_hint(const pfc::list_base_const_t & p_list,const pfc::list_base_const_t & p_infos,const pfc::list_base_const_t & p_stats); - - void run_callback(); -private: - metadb_handle_list m_removed; - metadb_handle_list m_added; - - pfc::string_list_impl m_copy_from,m_copy_to; - pfc::string_list_impl m_move_from,m_move_to; - - metadb_handle_list m_hint_handles; - pfc::list_t m_hint_infos; - pfc::list_t m_hint_stats; -}; - -class file_move_helper -{ -public: - file_move_helper(); - ~file_move_helper(); - file_move_helper(const file_move_helper & p_src); - bool take_snapshot(const char * p_path,abort_callback & p_abort); - bool on_moved(const char * p_path,abort_callback & p_abort); - bool on_copied(const char * p_path,abort_callback & p_abort); - bool on_moved(const char * p_path,abort_callback & p_abort,file_move_callback_manager & p_cb); - bool on_copied(const char * p_path,abort_callback & p_abort,file_move_callback_manager & p_cb); - - static bool g_on_deleted(const pfc::list_base_const_t & p_files); - - static t_size g_filter_dead_files_sorted_make_mask(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead,bit_array_var & p_mask); - static t_size g_filter_dead_files_sorted(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead); - static t_size g_filter_dead_files(pfc::list_base_t & p_data,const pfc::list_base_const_t & p_dead); - -private: - - struct t_entry - { - playable_location_impl m_location; - file_info_impl m_info; - t_filestats m_stats; - bool m_have_info; - }; - - metadb_handle_list m_source_handles; - - pfc::array_t m_data; - - const char * get_source_path() const; - - void make_new_item_list(pfc::list_base_t & p_out,const char * p_path,file_move_callback_manager & p_cb); -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_win32_wrapper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/file_win32_wrapper.h deleted file mode 100644 index 5d111889c..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_win32_wrapper.h +++ /dev/null @@ -1,183 +0,0 @@ -namespace file_win32_helpers { - static t_filesize get_size(HANDLE p_handle) { - union { - t_uint64 val64; - t_uint32 val32[2]; - } u; - - u.val64 = 0; - SetLastError(NO_ERROR); - u.val32[0] = GetFileSize(p_handle,reinterpret_cast(&u.val32[1])); - if (GetLastError()!=NO_ERROR) exception_io_from_win32(GetLastError()); - return u.val64; - } - static void seek(HANDLE p_handle,t_sfilesize p_position,file::t_seek_mode p_mode) { - union { - t_int64 temp64; - struct { - DWORD temp_lo; - LONG temp_hi; - }; - }; - - temp64 = p_position; - SetLastError(ERROR_SUCCESS); - temp_lo = SetFilePointer(p_handle,temp_lo,&temp_hi,(DWORD)p_mode); - if (GetLastError() != ERROR_SUCCESS) exception_io_from_win32(GetLastError()); - } -} - -template -class file_win32_wrapper_t : public file { -public: - file_win32_wrapper_t(HANDLE p_handle) : m_handle(p_handle), m_position(0) - { - } - - static service_ptr_t g_CreateFile(const char * p_path,DWORD p_access,DWORD p_sharemode,LPSECURITY_ATTRIBUTES p_security_attributes,DWORD p_createmode,DWORD p_flags,HANDLE p_template) { - SetLastError(NO_ERROR); - HANDLE handle = uCreateFile(p_path,p_access,p_sharemode,p_security_attributes,p_createmode,p_flags,p_template); - if (handle == INVALID_HANDLE_VALUE) exception_io_from_win32(GetLastError()); - try { - return g_create_from_handle(handle); - } catch(...) {CloseHandle(handle); throw;} - } - - static service_ptr_t g_create_from_handle(HANDLE p_handle) { - return new service_impl_t >(p_handle); - } - - - void reopen(abort_callback & p_abort) {seek(0,p_abort);} - - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - if (!p_writeable) throw exception_io_denied(); - - pfc::static_assert_t< (sizeof(t_size) >= sizeof(DWORD)) >(); - - t_size bytes_written_total = 0; - - if (sizeof(t_size) == sizeof(DWORD)) { - p_abort.check_e(); - DWORD bytes_written = 0; - SetLastError(ERROR_SUCCESS); - if (!WriteFile(m_handle,p_buffer,(DWORD)p_bytes,&bytes_written,0)) exception_io_from_win32(GetLastError()); - if (bytes_written != p_bytes) throw exception_io("Write failure"); - bytes_written_total = bytes_written; - m_position += bytes_written; - } else { - while(bytes_written_total < p_bytes) { - p_abort.check_e(); - DWORD bytes_written = 0; - DWORD delta = (DWORD) pfc::min_t(p_bytes - bytes_written_total, 0x80000000); - SetLastError(ERROR_SUCCESS); - if (!WriteFile(m_handle,(const t_uint8*)p_buffer + bytes_written_total,delta,&bytes_written,0)) exception_io_from_win32(GetLastError()); - if (bytes_written != delta) throw exception_io("Write failure"); - bytes_written_total += bytes_written; - m_position += bytes_written; - } - } - } - - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - pfc::static_assert_t< (sizeof(t_size) >= sizeof(DWORD)) >(); - - t_size bytes_read_total = 0; - if (sizeof(t_size) == sizeof(DWORD)) { - p_abort.check_e(); - DWORD bytes_read = 0; - SetLastError(ERROR_SUCCESS); - if (!ReadFile(m_handle,p_buffer,pfc::downcast_guarded(p_bytes),&bytes_read,0)) exception_io_from_win32(GetLastError()); - bytes_read_total = bytes_read; - m_position += bytes_read; - } else { - while(bytes_read_total < p_bytes) { - p_abort.check_e(); - DWORD bytes_read = 0; - DWORD delta = (DWORD) pfc::min_t(p_bytes - bytes_read_total, 0x80000000); - SetLastError(ERROR_SUCCESS); - if (!ReadFile(m_handle,(t_uint8*)p_buffer + bytes_read_total,delta,&bytes_read,0)) exception_io_from_win32(GetLastError()); - bytes_read_total += bytes_read; - m_position += bytes_read; - if (bytes_read != delta) break; - } - } - return bytes_read_total; - } - - - t_filesize get_size(abort_callback & p_abort) { - p_abort.check_e(); - return file_win32_helpers::get_size(m_handle); - } - - t_filesize get_position(abort_callback & p_abort) { - p_abort.check_e(); - return m_position; - } - - void resize(t_filesize p_size,abort_callback & p_abort) { - if (!p_writeable) throw exception_io_denied(); - p_abort.check_e(); - if (m_position != p_size) { - file_win32_helpers::seek(m_handle,p_size,file::seek_from_beginning); - } - SetLastError(ERROR_SUCCESS); - if (!SetEndOfFile(m_handle)) { - DWORD code = GetLastError(); - if (m_position != p_size) try {file_win32_helpers::seek(m_handle,m_position,file::seek_from_beginning);} catch(...) {} - exception_io_from_win32(code); - } - if (m_position > p_size) m_position = p_size; - if (m_position != p_size) file_win32_helpers::seek(m_handle,m_position,file::seek_from_beginning); - } - -#if 0 - void set_eof(abort_callback & p_abort) { - if (!p_writeable) throw exception_io_denied(); - p_abort.check_e(); - - SetLastError(ERROR_SUCCESS); - if (!SetEndOfFile(m_handle)) exception_io_from_win32(GetLastError()); - } -#endif - - void seek(t_filesize p_position,abort_callback & p_abort) { - if (!p_seekable) throw exception_io_object_not_seekable(); - p_abort.check_e(); - if (p_position > file_win32_helpers::get_size(m_handle)) throw exception_io_seek_out_of_range(); - file_win32_helpers::seek(m_handle,p_position,file::seek_from_beginning); - m_position = p_position; - //return seek_ex((t_sfilesize)p_position,file::seek_from_beginning,p_abort); - } -#if 0 - void seek_ex(t_sfilesize p_position,file::t_seek_mode p_mode,abort_callback & p_abort) { - if (!p_seekable) throw exception_io_object_not_seekable(); - p_abort.check_e(); - - file_win32_helpers::seek(m_handle,p_position,p_mode); - - m_position = (t_filesize) temp64; - } -#endif - - bool can_seek() {return p_seekable;} - bool get_content_type(pfc::string_base & out) {return false;} - bool is_in_memory() {return false;} - void on_idle(abort_callback & p_abort) {p_abort.check_e();} - - t_filetimestamp get_timestamp(abort_callback & p_abort) { - p_abort.check_e(); - FlushFileBuffers(m_handle); - SetLastError(ERROR_SUCCESS); - t_filetimestamp temp; - if (!GetFileTime(m_handle,0,0,(FILETIME*)&temp)) exception_io_from_win32(GetLastError()); - return temp; - } - - bool is_remote() {return false;} - ~file_win32_wrapper_t() {CloseHandle(m_handle);} -private: - HANDLE m_handle; - t_filesize m_position; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_wrapper_simple.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/file_wrapper_simple.cpp deleted file mode 100644 index 79b61b197..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_wrapper_simple.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "stdafx.h" - -t_size file_wrapper_simple::read(void * p_buffer,t_size p_bytes) { - if (m_has_failed) return 0; - try { - return m_file->read(p_buffer,p_bytes,m_abort); - } catch(std::exception const &) { - m_has_failed = true; - return 0; - } -} - -t_size file_wrapper_simple::write(const void * p_buffer,t_size p_bytes) { - if (m_has_failed) return 0; - try { - m_file->write(p_buffer,p_bytes,m_abort); - return p_bytes; - } catch(std::exception const &) { - m_has_failed = true; - return 0; - } -} - -bool file_wrapper_simple::seek(t_filesize p_offset) { - if (m_has_failed) return false; - try { - m_file->seek(p_offset,m_abort); - return true; - } catch(std::exception const &) { - m_has_failed = true; - return false; - } -} - -t_filesize file_wrapper_simple::get_position() { - if (m_has_failed) return filesize_invalid; - try { - return m_file->get_position(m_abort); - } catch(std::exception const &) { - m_has_failed = true; - return filesize_invalid; - } -} - -bool file_wrapper_simple::truncate() { - if (m_has_failed) return false; - try { - m_file->set_eof(m_abort); - return true; - } catch(std::exception) { - m_has_failed = true; - return true; - } -} - - -t_filesize file_wrapper_simple::get_size() { - if (m_has_failed) return filesize_invalid; - try { - return m_file->get_size(m_abort); - } catch(std::exception const &) { - m_has_failed = true; - return filesize_invalid; - } -} - -bool file_wrapper_simple::can_seek() { - if (m_has_failed) return false; - try { - return m_file->can_seek(); - } catch(std::exception const &) { - m_has_failed = true; - return false; - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/file_wrapper_simple.h b/tools/vio2sf/src/foobar/foobar2000/helpers/file_wrapper_simple.h deleted file mode 100644 index 6819d0ddf..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/file_wrapper_simple.h +++ /dev/null @@ -1,21 +0,0 @@ -class file_wrapper_simple -{ -public: - explicit file_wrapper_simple(const service_ptr_t & p_file,abort_callback & p_abort) : m_file(p_file), m_abort(p_abort), m_has_failed(false) {} - - inline bool has_failed() const {return m_has_failed;} - inline void reset_status() {m_has_failed = false;} - - - t_size read(void * p_buffer,t_size p_bytes); - t_size write(const void * p_buffer,t_size p_bytes); - bool seek(t_filesize p_offset); - t_filesize get_position(); - t_filesize get_size(); - bool can_seek(); - bool truncate(); -private: - service_ptr_t m_file; - abort_callback & m_abort; - bool m_has_failed; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/filetimetools.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/filetimetools.cpp deleted file mode 100644 index a52da25c7..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/filetimetools.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "stdafx.h" - - -#ifndef _WIN32 -#error PORTME -#endif - -static bool is_spacing(char c) {return c == ' ' || c==10 || c==13 || c == '\t';} - -static bool is_spacing(const char * str, t_size len) { - for(t_size walk = 0; walk < len; ++walk) if (!is_spacing(str[walk])) return false; - return true; -} - -typedef exception_io_data exception_time_error; - -static unsigned ParseDateElem(const char * ptr, t_size len) { - unsigned ret = 0; - for(t_size walk = 0; walk < len; ++walk) { - const char c = ptr[walk]; - if (c < '0' || c > '9') throw exception_time_error(); - ret = ret * 10 + (unsigned)(c - '0'); - } - return ret; -} - -t_filetimestamp foobar2000_io::filetimestamp_from_string(const char * date) { - // Accepted format - // YYYY-MM-DD HH:MM:SS - try { - t_size remaining = strlen(date); - SYSTEMTIME st = {}; - st.wDay = 1; st.wMonth = 1; - for(;;) { -#define ADVANCE(n) { PFC_ASSERT( remaining >= n); date += n; remaining -= n; } -#define ADVANCE_TEST(n) { if (remaining < n) throw exception_time_error(); } -#define PARSE(var, digits) { ADVANCE_TEST(digits); var = (WORD) ParseDateElem(date, digits); ADVANCE(digits) ; } -#define TEST_END( durationIncrement ) -#define SKIP(c) { ADVANCE_TEST(1); if (date[0] != c) throw exception_time_error(); ADVANCE(1); } -#define SKIP_SPACING() {while(remaining > 0 && is_spacing(*date)) ADVANCE(1);} - SKIP_SPACING(); - PARSE( st.wYear, 4 ); if (st.wYear < 1601) throw exception_time_error(); - TEST_END(wYear); SKIP('-'); - PARSE( st.wMonth, 2 ); if (st.wMonth < 1 || st.wMonth > 12) throw exception_time_error(); - TEST_END(wMonth); SKIP('-'); - PARSE( st.wDay, 2); if (st.wDay < 1 || st.wDay > 31) throw exception_time_error(); - TEST_END(wDay); SKIP(' '); - PARSE( st.wHour, 2); if (st.wHour >= 24) throw exception_time_error(); - TEST_END(wHour); SKIP(':'); - PARSE( st.wMinute, 2); if (st.wMinute >= 60) throw exception_time_error(); - TEST_END(wMinute); SKIP(':'); - PARSE( st.wSecond, 2); if (st.wSecond >= 60) throw exception_time_error(); - SKIP_SPACING(); - TEST_END( wSecond ); -#undef ADVANCE -#undef ADVANCE_TEST -#undef PARSE -#undef TEST_END -#undef SKIP -#undef SKIP_SPACING - if (remaining > 0) throw exception_time_error(); - break; - } - t_filetimestamp base, out; - if (!SystemTimeToFileTime(&st, (FILETIME*) &base)) throw exception_time_error(); - if (!LocalFileTimeToFileTime((const FILETIME*)&base, (FILETIME*)&out)) throw exception_time_error(); - return out; - } catch(exception_time_error) { - return filetimestamp_invalid; - } -} - - - -format_filetimestamp::format_filetimestamp(t_filetimestamp p_timestamp) { - SYSTEMTIME st; FILETIME ft; - if (FileTimeToLocalFileTime((FILETIME*)&p_timestamp,&ft)) { - if (FileTimeToSystemTime(&ft,&st)) { - m_buffer - << pfc::format_uint(st.wYear,4) << "-" << pfc::format_uint(st.wMonth,2) << "-" << pfc::format_uint(st.wDay,2) << " " - << pfc::format_uint(st.wHour,2) << ":" << pfc::format_uint(st.wMinute,2) << ":" << pfc::format_uint(st.wSecond,2); - } else m_buffer << ""; - } else m_buffer << ""; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/filetimetools.h b/tools/vio2sf/src/foobar/foobar2000/helpers/filetimetools.h deleted file mode 100644 index b376be137..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/filetimetools.h +++ /dev/null @@ -1,14 +0,0 @@ -namespace foobar2000_io { - t_filetimestamp filetimestamp_from_string(const char * date); - - //! Warning: this formats according to system timezone settings, created strings should be used for display only, never for storage. - class format_filetimestamp { - public: - format_filetimestamp(t_filetimestamp p_timestamp); - operator const char*() const {return m_buffer;} - const char * get_ptr() const {return m_buffer;} - private: - pfc::string_fixed_t<32> m_buffer; - }; - -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/foobar2000_sdk_helpers.vcproj b/tools/vio2sf/src/foobar/foobar2000/helpers/foobar2000_sdk_helpers.vcproj deleted file mode 100644 index b68498d52..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/foobar2000_sdk_helpers.vcproj +++ /dev/null @@ -1,909 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/helpers.h b/tools/vio2sf/src/foobar/foobar2000/helpers/helpers.h deleted file mode 100644 index f1232b9cf..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/helpers.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _FOOBAR2000_SDK_HELPERS_H_ -#define _FOOBAR2000_SDK_HELPERS_H_ - -#include "file_info_update_helper.h" -#include "input_helpers.h" -#include "create_directory_helper.h" -#include "dialog_resize_helper.h" -#include "dropdown_helper.h" -#include "window_placement_helper.h" -#include "win32_dialog.h" -#include "wildcard.h" -#include "cuesheet_index_list.h" -#include "cue_creator.h" -#include "cue_parser.h" -#include "text_file_loader.h" -#include "file_list_helper.h" -#include "preload_info_helper.h" -#include "listview_helper.h" -#include "stream_buffer_helper.h" -#include "file_info_const_impl.h" -#include "file_wrapper_simple.h" -#include "dynamic_bitrate_helper.h" -#include "cfg_guidlist.h" -#include "file_win32_wrapper.h" -#include "file_move_helper.h" -#include "file_cached.h" -#include "seekabilizer.h" -#include "string_filter.h" -#include "bitreader_helper.h" -#include "mp3_utils.h" -#include "win32_misc.h" -#include "COM_utils.h" -#include "metadb_io_hintlist.h" -#include "meta_table_builder.h" -#include "icon_remapping_wildcard.h" -#include "album_art_helpers.h" -#include "clipboard.h" -#include "IDataObjectUtils.h" -#include "CallForwarder.h" -#include "playlist_position_reference_tracker.h" -#include "ThreadUtils.h" -#include "VisUtils.h" -#include "filetimetools.h" - -#endif //_FOOBAR2000_SDK_HELPERS_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/icon_remapping_wildcard.h b/tools/vio2sf/src/foobar/foobar2000/helpers/icon_remapping_wildcard.h deleted file mode 100644 index c6bb98129..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/icon_remapping_wildcard.h +++ /dev/null @@ -1,13 +0,0 @@ -class icon_remapping_wildcard_impl : public icon_remapping { -public: - icon_remapping_wildcard_impl(const char * p_pattern,const char * p_iconname) : m_pattern(p_pattern), m_iconname(p_iconname) {} - bool query(const char * p_extension,pfc::string_base & p_iconname) { - if (wildcard_helper::test(p_extension,m_pattern,true)) { - p_iconname = m_iconname; return true; - } else { - return false; - } - } -private: - pfc::string8 m_pattern,m_iconname; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/input_helpers.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/input_helpers.cpp deleted file mode 100644 index f36873054..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/input_helpers.cpp +++ /dev/null @@ -1,405 +0,0 @@ -#include "stdafx.h" - -void input_helper::open(service_ptr_t p_filehint,metadb_handle_ptr p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints) -{ - open(p_filehint,p_location->get_location(),p_flags,p_abort,p_from_redirect,p_skip_hints); -} - -static void process_fullbuffer(service_ptr_t & p_file,const char * p_path,t_filesize p_fullbuffer,abort_callback & p_abort) { - if (p_fullbuffer > 0) { - if (p_file.is_empty()) { - service_ptr_t fs; - if (filesystem::g_get_interface(fs,p_path)) { - fs->open(p_file,p_path,filesystem::open_mode_read,p_abort); - } - } - - if (p_file.is_valid()) { - t_filesize size = p_file->get_size(p_abort); - if (size != filesize_invalid && size <= p_fullbuffer) { - service_ptr_t l_file_buffered; - if (reader_membuffer_mirror::g_create(l_file_buffered,p_file,p_abort)) { - p_file = l_file_buffered; - } - } - } - } -} - -bool input_helper::need_file_reopen(const char * newPath) const { - return m_input.is_empty() || metadb::path_compare(m_path, newPath) != 0; -} - -bool input_helper::open_path(file::ptr p_filehint,const char * path,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints) { - p_abort.check(); - - if (!need_file_reopen(path)) return false; - m_input.release(); - - service_ptr_t l_file = p_filehint; - process_fullbuffer(l_file,path,m_fullbuffer,p_abort); - - TRACK_CODE("input_entry::g_open_for_decoding", - input_entry::g_open_for_decoding(m_input,l_file,path,p_abort,p_from_redirect) - ); - - - if (!p_skip_hints) { - try { - static_api_ptr_t()->hint_reader(m_input.get_ptr(),path,p_abort); - } catch(exception_io_data) { - //Don't fail to decode when this barfs, might be barfing when reading info from another subsong than the one we're trying to decode etc. - m_input.release(); - if (l_file.is_valid()) l_file->reopen(p_abort); - TRACK_CODE("input_entry::g_open_for_decoding", - input_entry::g_open_for_decoding(m_input,l_file,path,p_abort,p_from_redirect) - ); - } - } - - m_path = path; - return true; -} - -void input_helper::open_decoding(t_uint32 subsong, t_uint32 flags, abort_callback & p_abort) { - TRACK_CODE("input_decoder::initialize",m_input->initialize(subsong,flags,p_abort)); -} - -void input_helper::open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints) { - open_path(p_filehint, p_location.get_path(), p_abort, p_from_redirect, p_skip_hints); - - open_decoding(p_location.get_subsong(), p_flags, p_abort); -} - - -void input_helper::close() { - m_input.release(); -} - -bool input_helper::is_open() { - return m_input.is_valid(); -} - -void input_helper::set_logger(event_logger::ptr ptr) { - if (m_input.is_empty()) throw pfc::exception_bug_check_v2(); - input_decoder_v2::ptr v2; - if (m_input->service_query_t(v2)) v2->set_logger(ptr); -} - -bool input_helper::run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { - if (m_input.is_empty()) throw pfc::exception_bug_check_v2(); - input_decoder_v2::ptr v2; - if (!m_input->service_query_t(v2)) throw pfc::exception_not_implemented(); - return v2->run_raw(p_chunk, p_raw, p_abort); -} - -bool input_helper::run(audio_chunk & p_chunk,abort_callback & p_abort) -{ - if (m_input.is_valid()) { - TRACK_CODE("input_decoder::run",return m_input->run(p_chunk,p_abort)); - } else { - throw pfc::exception_bug_check_v2(); - } -} - -void input_helper::seek(double seconds,abort_callback & p_abort) -{ - if (m_input.is_valid()) { - TRACK_CODE("input_decoder::seek",m_input->seek(seconds,p_abort)); - } else { - throw pfc::exception_bug_check_v2(); - } -} - -bool input_helper::can_seek() { - if (m_input.is_valid()) { - return m_input->can_seek(); - } else { - throw pfc::exception_bug_check_v2(); - } -} - -void input_helper::set_full_buffer(t_filesize val) { - m_fullbuffer = val; -} -void input_helper::on_idle(abort_callback & p_abort) { - if (m_input.is_valid()) { - TRACK_CODE("input_decoder::on_idle",m_input->on_idle(p_abort)); - } -} - -bool input_helper::get_dynamic_info(file_info & p_out,double & p_timestamp_delta) { - if (m_input.is_valid()) { - TRACK_CODE("input_decoder::get_dynamic_info",return m_input->get_dynamic_info(p_out,p_timestamp_delta)); - } else { - throw pfc::exception_bug_check_v2(); - } -} - -bool input_helper::get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta) { - if (m_input.is_valid()) { - TRACK_CODE("input_decoder::get_dynamic_info_track",return m_input->get_dynamic_info_track(p_out,p_timestamp_delta)); - } else { - throw pfc::exception_bug_check_v2(); - } -} - -void input_helper::get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) { - if (m_input.is_valid()) { - TRACK_CODE("input_decoder::get_info",m_input->get_info(p_subsong,p_info,p_abort)); - } else { - throw pfc::exception_bug_check_v2(); - } -} - -const char * input_helper::get_path() const { - return m_path; -} - - -input_helper::input_helper() : m_fullbuffer(0) -{ -} - - -void input_helper::g_get_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect) { - service_ptr_t instance; - input_entry::g_open_for_info_read(instance,0,p_location.get_path(),p_abort,p_from_redirect); - instance->get_info(p_location.get_subsong_index(),p_info,p_abort); -} - -void input_helper::g_set_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect) { - service_ptr_t instance; - input_entry::g_open_for_info_write(instance,0,p_location.get_path(),p_abort,p_from_redirect); - instance->set_info(p_location.get_subsong_index(),p_info,p_abort); - instance->commit(p_abort); -} - - -bool dead_item_filter::run(const pfc::list_base_const_t & p_list,bit_array_var & p_mask) { - file_list_helper::file_list_from_metadb_handle_list path_list; - path_list.init_from_list(p_list); - metadb_handle_list valid_handles; - static_api_ptr_t l_metadb; - for(t_size pathidx=0;pathidxhandle_create(temp,make_playable_location(path,0)); - valid_handles.add_item(temp); - } else { - try { - service_ptr_t reader; - - input_entry::g_open_for_info_read(reader,0,path,*this); - t_uint32 count = reader->get_subsong_count(); - for(t_uint32 n=0;nget_subsong(n); - l_metadb->handle_create(ptr,make_playable_location(path,index)); - valid_handles.add_item(ptr); - } - } catch(...) {} - } - } - - if (is_aborting()) return false; - - valid_handles.sort_by_pointer(); - for(t_size listidx=0;listidx & p_list,bit_array_var & p_mask,abort_callback & p_abort) -{ - dead_item_filter_impl_simple filter(p_abort); - return filter.run(p_list,p_mask); -} - -void input_info_read_helper::open(const char * p_path,abort_callback & p_abort) { - if (m_input.is_empty() || metadb::path_compare(m_path,p_path) != 0) - { - TRACK_CODE("input_entry::g_open_for_info_read",input_entry::g_open_for_info_read(m_input,0,p_path,p_abort)); - - m_path = p_path; - } -} - -void input_info_read_helper::get_info(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,abort_callback & p_abort) { - open(p_location.get_path(),p_abort); - - TRACK_CODE("input_info_reader::get_file_stats",p_stats = m_input->get_file_stats(p_abort)); - - TRACK_CODE("input_info_reader::get_info",m_input->get_info(p_location.get_subsong_index(),p_info,p_abort)); -} - -void input_info_read_helper::get_info_check(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,bool & p_reloaded,abort_callback & p_abort) { - open(p_location.get_path(),p_abort); - t_filestats newstats; - TRACK_CODE("input_info_reader::get_file_stats",newstats = m_input->get_file_stats(p_abort)); - if (metadb_handle::g_should_reload(p_stats,newstats,true)) { - p_stats = newstats; - TRACK_CODE("input_info_reader::get_info",m_input->get_info(p_location.get_subsong_index(),p_info,p_abort)); - p_reloaded = true; - } else { - p_reloaded = false; - } -} - - - - - - -void input_helper_cue::open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,double p_start,double p_length) { - p_abort.check(); - - m_start = p_start; - m_position = 0; - m_dynamic_info_trigger = false; - m_dynamic_info_track_trigger = false; - - m_input.open(p_filehint,p_location,p_flags,p_abort,true,true); - - if (!m_input.can_seek()) throw exception_io_object_not_seekable(); - - if (m_start > 0) { - m_input.seek(m_start,p_abort); - } - - if (p_length > 0) { - m_length = p_length; - } else { - file_info_impl temp; - m_input.get_info(0,temp,p_abort); - double ref_length = temp.get_length(); - if (ref_length <= 0) throw exception_io_data(); - m_length = ref_length - m_start + p_length /* negative or zero */; - if (m_length <= 0) throw exception_io_data(); - } -} - -void input_helper_cue::close() {m_input.close();} -bool input_helper_cue::is_open() {return m_input.is_open();} - -bool input_helper_cue::_m_input_run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort) { - if (p_raw == NULL) { - return m_input.run(p_chunk, p_abort); - } else { - return m_input.run_raw(p_chunk, *p_raw, p_abort); - } -} -bool input_helper_cue::_run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort) { - p_abort.check(); - - if (m_length > 0) { - if (m_position >= m_length) return false; - - if (!_m_input_run(p_chunk, p_raw, p_abort)) return false; - - m_dynamic_info_trigger = true; - m_dynamic_info_track_trigger = true; - - t_uint64 max = (t_uint64) audio_math::time_to_samples(m_length - m_position, p_chunk.get_sample_rate()); - if (max == 0) - {//handle rounding accidents, this normally shouldn't trigger - m_position = m_length; - return false; - } - - t_size samples = p_chunk.get_sample_count(); - if ((t_uint64)samples > max) - { - p_chunk.set_sample_count((unsigned)max); - if (p_raw != NULL) { - const t_size rawSize = p_raw->get_size(); - PFC_ASSERT( rawSize % samples == 0 ); - p_raw->set_size( (t_size) ( (t_uint64) rawSize * max / samples ) ); - } - m_position = m_length; - } - else - { - m_position += p_chunk.get_duration(); - } - return true; - } - else - { - if (!_m_input_run(p_chunk, p_raw, p_abort)) return false; - m_position += p_chunk.get_duration(); - return true; - } -} -bool input_helper_cue::run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) { - return _run(p_chunk, &p_raw, p_abort); -} - -bool input_helper_cue::run(audio_chunk & p_chunk,abort_callback & p_abort) { - return _run(p_chunk, NULL, p_abort); -} - -void input_helper_cue::seek(double p_seconds,abort_callback & p_abort) -{ - m_dynamic_info_trigger = false; - m_dynamic_info_track_trigger = false; - if (m_length <= 0 || p_seconds < m_length) { - m_input.seek(p_seconds + m_start,p_abort); - m_position = p_seconds; - } else { - m_position = m_length; - } -} - -bool input_helper_cue::can_seek() {return true;} -void input_helper_cue::set_full_buffer(t_filesize val) {m_input.set_full_buffer(val);} - -void input_helper_cue::on_idle(abort_callback & p_abort) {m_input.on_idle(p_abort);} - -bool input_helper_cue::get_dynamic_info(file_info & p_out,double & p_timestamp_delta) { - if (m_dynamic_info_trigger) { - m_dynamic_info_trigger = false; - return m_input.get_dynamic_info(p_out,p_timestamp_delta); - } else { - return false; - } -} - -bool input_helper_cue::get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta) { - if (m_dynamic_info_track_trigger) { - m_dynamic_info_track_trigger = false; - return m_input.get_dynamic_info_track(p_out,p_timestamp_delta); - } else { - return false; - } -} - -const char * input_helper_cue::get_path() const {return m_input.get_path();} - -void input_helper_cue::get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) {m_input.get_info(p_subsong,p_info,p_abort);} - - diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/input_helpers.h b/tools/vio2sf/src/foobar/foobar2000/helpers/input_helpers.h deleted file mode 100644 index 5c2486c0b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/input_helpers.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef _INPUT_HELPERS_H_ -#define _INPUT_HELPERS_H_ - -class input_helper { -public: - input_helper(); - void open(service_ptr_t p_filehint,metadb_handle_ptr p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect = false,bool p_skip_hints = false); - void open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect = false,bool p_skip_hints = false); - - //! Multilevel open helpers. - //! @returns Diagnostic/helper value: true if the decoder had to be re-opened entirely, false if the instance was reused. - bool open_path(file::ptr p_filehint,const char * path,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints); - //! Multilevel open helpers. - void open_decoding(t_uint32 subsong, t_uint32 flags, abort_callback & p_abort); - - bool need_file_reopen(const char * newPath) const; - - void close(); - bool is_open(); - bool run(audio_chunk & p_chunk,abort_callback & p_abort); - bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort); - void seek(double seconds,abort_callback & p_abort); - bool can_seek(); - void set_full_buffer(t_filesize val); - void on_idle(abort_callback & p_abort); - bool get_dynamic_info(file_info & p_out,double & p_timestamp_delta); - bool get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta); - void set_logger(event_logger::ptr ptr); - - //! Retrieves path of currently open file. - const char * get_path() const; - - //! Retrieves info about specific subsong of currently open file. - void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort); - - static void g_get_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect = false); - static void g_set_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect = false); - - - static bool g_mark_dead(const pfc::list_base_const_t & p_list,bit_array_var & p_mask,abort_callback & p_abort); - -private: - service_ptr_t m_input; - pfc::string8 m_path; - t_filesize m_fullbuffer; -}; - -class NOVTABLE dead_item_filter : public abort_callback { -public: - virtual void on_progress(t_size p_position,t_size p_total) = 0; - - bool run(const pfc::list_base_const_t & p_list,bit_array_var & p_mask); -}; - -class input_info_read_helper { -public: - input_info_read_helper() {} - void get_info(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,abort_callback & p_abort); - void get_info_check(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,bool & p_reloaded,abort_callback & p_abort); -private: - void open(const char * p_path,abort_callback & p_abort); - - pfc::string8 m_path; - service_ptr_t m_input; -}; - - - -class input_helper_cue { -public: - void open(service_ptr_t p_filehint,const playable_location & p_location,unsigned p_flags,abort_callback & p_abort,double p_start,double p_length); - - void close(); - bool is_open(); - bool run(audio_chunk & p_chunk,abort_callback & p_abort); - bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort); - void seek(double seconds,abort_callback & p_abort); - bool can_seek(); - void set_full_buffer(t_filesize val); - void on_idle(abort_callback & p_abort); - bool get_dynamic_info(file_info & p_out,double & p_timestamp_delta); - bool get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta); - void set_logger(event_logger::ptr ptr) {m_input.set_logger(ptr);} - - const char * get_path() const; - - void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort); - -private: - bool _run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort); - bool _m_input_run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort); - input_helper m_input; - double m_start,m_length,m_position; - bool m_dynamic_info_trigger,m_dynamic_info_track_trigger; -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/listview_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/listview_helper.cpp deleted file mode 100644 index c18e51ac7..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/listview_helper.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include "stdafx.h" - - - -namespace listview_helper { - - unsigned insert_item(HWND p_listview,unsigned p_index,const char * p_name,LPARAM p_param) - { - if (p_index == infinite) p_index = ListView_GetItemCount(p_listview); - LVITEM item = {}; - - pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); - - item.mask = LVIF_TEXT | LVIF_PARAM; - item.iItem = p_index; - item.lParam = p_param; - item.pszText = const_cast(os_string_temp.get_ptr()); - - LRESULT ret = uSendMessage(p_listview,LVM_INSERTITEM,0,(LPARAM)&item); - if (ret < 0) return infinite; - else return (unsigned) ret; - } - - - - unsigned insert_column(HWND p_listview,unsigned p_index,const char * p_name,unsigned p_width_dlu) - { - pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); - - RECT rect = {0,0,p_width_dlu,0}; - MapDialogRect(GetParent(p_listview),&rect); - - LVCOLUMN data = {}; - data.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT; - data.fmt = LVCFMT_LEFT; - data.cx = rect.right; - data.pszText = const_cast(os_string_temp.get_ptr()); - - LRESULT ret = uSendMessage(p_listview,LVM_INSERTCOLUMN,p_index,(LPARAM)&data); - if (ret < 0) return infinite; - else return (unsigned) ret; - } - - void get_item_text(HWND p_listview,unsigned p_index,unsigned p_column,pfc::string_base & p_out) { - enum {buffer_length = 4096}; - TCHAR buffer[buffer_length]; - ListView_GetItemText(p_listview,p_index,p_column,buffer,buffer_length); - p_out = pfc::stringcvt::string_utf8_from_os(buffer,buffer_length); - } - - bool set_item_text(HWND p_listview,unsigned p_index,unsigned p_column,const char * p_name) - { - LVITEM item = {}; - - pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); - - item.mask = LVIF_TEXT; - item.iItem = p_index; - item.iSubItem = p_column; - item.pszText = const_cast(os_string_temp.get_ptr()); - return uSendMessage(p_listview,LVM_SETITEM,0,(LPARAM)&item) ? true : false; - } - - bool is_item_selected(HWND p_listview,unsigned p_index) - { - LVITEM item = {}; - item.mask = LVIF_STATE; - item.iItem = p_index; - item.stateMask = LVIS_SELECTED; - if (!uSendMessage(p_listview,LVM_GETITEM,0,(LPARAM)&item)) return false; - return (item.state & LVIS_SELECTED) ? true : false; - } - - void set_item_selection(HWND p_listview,unsigned p_index,bool p_state) - { - PFC_ASSERT( ::IsWindow(p_listview) ); - LVITEM item = {}; - item.stateMask = LVIS_SELECTED; - item.state = p_state ? LVIS_SELECTED : 0; - WIN32_OP_D( SendMessage(p_listview,LVM_SETITEMSTATE,(WPARAM)p_index,(LPARAM)&item) ); - } - - bool select_single_item(HWND p_listview,unsigned p_index) - { - LRESULT temp = SendMessage(p_listview,LVM_GETITEMCOUNT,0,0); - if (temp < 0) return false; - ListView_SetSelectionMark(p_listview,p_index); - unsigned n; const unsigned m = pfc::downcast_guarded(temp); - for(n=0;n= 0) { - RECT rect; - WIN32_OP_D( ListView_GetItemRect(p_list,firstsel,&rect,LVIR_BOUNDS) ); - p_point.x = (rect.left + rect.right) / 2; - p_point.y = (rect.top + rect.bottom) / 2; - WIN32_OP_D( ClientToScreen(p_list,&p_point) ); - } else { - RECT rect; - WIN32_OP_D(GetClientRect(p_list,&rect)); - p_point.x = (rect.left + rect.right) / 2; - p_point.y = (rect.top + rect.bottom) / 2; - WIN32_OP_D(ClientToScreen(p_list,&p_point)); - } - p_selection = firstsel; - } else { - POINT pt = {(short)LOWORD(p_coords),(short)HIWORD(p_coords)}; - p_point = pt; - POINT client = pt; - WIN32_OP_D( ScreenToClient(p_list,&client) ); - LVHITTESTINFO info = {}; - info.pt = client; - p_selection = ListView_HitTest(p_list,&info); - } -} - -#if 0 -static bool ProbeColumn(HWND view, int index) { - LVCOLUMN col = {LVCF_ORDER}; - return !! ListView_GetColumn(view, index, &col); -} -int ListView_GetColumnCount(HWND listView) { - if (!ProbeColumn(listView, 0)) return 0; - int hi = 1; - for(;;) { - if (!ProbeColumn(listView, hi)) break; - hi <<= 1; - if (hi <= 0) { - PFC_ASSERT(!"Shouldn't get here!"); - return -1; - } - } - int lo = hi >> 1; - //lo is the highest known valid column, hi is the lowest known invalid, let's bsearch thru - while(lo + 1 < hi) { - PFC_ASSERT( lo < hi ); - const int mid = lo + (hi - lo) / 2; - PFC_ASSERT( lo < mid && mid < hi ); - if (ProbeColumn(listView, mid)) { - lo = mid; - } else { - hi = mid; - } - } - return hi; -} -#else -int ListView_GetColumnCount(HWND listView) { - HWND header = ListView_GetHeader(listView); - PFC_ASSERT(header != NULL); - return Header_GetItemCount(header); -} -#endif diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/listview_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/listview_helper.h deleted file mode 100644 index 9f5831afd..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/listview_helper.h +++ /dev/null @@ -1,40 +0,0 @@ -namespace listview_helper -{ - unsigned insert_item(HWND p_listview,unsigned p_index,const char * p_name,LPARAM p_param);//returns index of new item on success, infinite on failure - - unsigned insert_column(HWND p_listview,unsigned p_index,const char * p_name,unsigned p_width_dlu);//returns index of new item on success, infinite on failure - - bool set_item_text(HWND p_listview,unsigned p_index,unsigned p_column,const char * p_name); - - bool is_item_selected(HWND p_listview,unsigned p_index); - - void set_item_selection(HWND p_listview,unsigned p_index,bool p_state); - - bool select_single_item(HWND p_listview,unsigned p_index); - - bool ensure_visible(HWND p_listview,unsigned p_index); - - void get_item_text(HWND p_listview,unsigned p_index,unsigned p_column,pfc::string_base & p_out); - -}; - -static int ListView_GetFirstSelection(HWND p_listview) { - return ListView_GetNextItem(p_listview,-1,LVNI_SELECTED); -} - -static int ListView_GetSingleSelection(HWND p_listview) { - if (ListView_GetSelectedCount(p_listview) != 1) return -1; - return ListView_GetFirstSelection(p_listview); -} - -static int ListView_GetFocusItem(HWND p_listview) { - return ListView_GetNextItem(p_listview,-1,LVNI_FOCUSED); -} - -static bool ListView_IsItemSelected(HWND p_listview,int p_index) { - return ListView_GetItemState(p_listview,p_index,LVIS_SELECTED) != 0; -} - -void ListView_GetContextMenuPoint(HWND p_list,LPARAM p_coords,POINT & p_point,int & p_selection); - -int ListView_GetColumnCount(HWND listView); diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/meta_table_builder.h b/tools/vio2sf/src/foobar/foobar2000/helpers/meta_table_builder.h deleted file mode 100644 index 45f4594cb..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/meta_table_builder.h +++ /dev/null @@ -1,74 +0,0 @@ -class __meta_table_enum_wrapper { -public: - __meta_table_enum_wrapper(file_info & p_info) : m_info(p_info) {} - template - void operator() (const char * p_name,const t_values & p_values) { - t_size index = infinite; - for(t_values::const_iterator iter = p_values.first(); iter.is_valid(); ++iter) { - if (index == infinite) index = m_info.__meta_add_unsafe(p_name,*iter); - else m_info.meta_add_value(index,*iter); - } - } -private: - file_info & m_info; -}; - -//! Purpose: building a file_info metadata table from loose input without search-for-existing-entry bottleneck -class meta_table_builder { -public: - typedef pfc::chain_list_v2_t t_entry; - typedef pfc::map_t t_content; - - t_content & content() {return m_data;} - t_content const & content() const {return m_data;} - - void add(const char * p_name,const char * p_value,t_size p_value_len = infinite) { - if (file_info::g_is_valid_field_name(p_name)) { - __add(p_name).insert_last()->set_string(p_value,p_value_len); - } - } - - void remove(const char * p_name) { - m_data.remove(p_name); - } - void set(const char * p_name,const char * p_value,t_size p_value_len = infinite) { - if (file_info::g_is_valid_field_name(p_name)) { - t_entry & entry = __add(p_name); - entry.remove_all(); - entry.insert_last()->set_string(p_value,p_value_len); - } - } - t_entry & add(const char * p_name) { - if (!file_info::g_is_valid_field_name(p_name)) throw pfc::exception_bug_check_v2();//we return a reference, nothing smarter to do - return __add(p_name); - } - void finalize(file_info & p_info) const { - p_info.meta_remove_all(); - m_data.enumerate(__meta_table_enum_wrapper(p_info)); - } - - void from_info(const file_info & p_info) { - m_data.remove_all(); - from_info_overwrite(p_info); - } - void from_info_overwrite(const file_info & p_info) { - for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk ) { - const t_size valuecount = p_info.meta_enum_value_count(metawalk); - if (valuecount > 0) { - t_entry & entry = add(p_info.meta_enum_name(metawalk)); - entry.remove_all(); - for(t_size valuewalk = 0; valuewalk < valuecount; ++valuewalk) { - entry.insert_last(p_info.meta_enum_value(metawalk,valuewalk)); - } - } - } - } - void reset() {m_data.remove_all();} -private: - - t_entry & __add(const char * p_name) { - return m_data.find_or_add(p_name); - } - - t_content m_data; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/metadb_io_hintlist.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/metadb_io_hintlist.cpp deleted file mode 100644 index 4849f1134..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/metadb_io_hintlist.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "stdafx.h" - -void metadb_io_hintlist::run() { - if (m_entries.get_count() > 0) { - static_api_ptr_t()->hint_multi_async( - metadb_io_hintlist_wrapper_part1(m_entries), - metadb_io_hintlist_wrapper_part2(m_entries), - metadb_io_hintlist_wrapper_part3(m_entries), - metadb_io_hintlist_wrapper_part4(m_entries) - ); - } - m_entries.remove_all(); -} - -void metadb_io_hintlist::add(metadb_handle_ptr const & p_handle,const file_info & p_info,t_filestats const & p_stats,bool p_fresh) { - t_entry entry; - entry.m_handle = p_handle; - entry.m_info.new_t(p_info); - entry.m_stats = p_stats; - entry.m_fresh = p_fresh; - m_entries.add_item(entry); -} - -void metadb_io_hintlist::hint_reader(service_ptr_t p_reader, const char * p_path,abort_callback & p_abort) { - static_api_ptr_t api; - const t_uint32 subsongcount = p_reader->get_subsong_count(); - t_filestats stats = p_reader->get_file_stats(p_abort); - for(t_uint32 subsong = 0; subsong < subsongcount; subsong++) { - t_uint32 subsong_id = p_reader->get_subsong(subsong); - metadb_handle_ptr handle; - api->handle_create(handle,make_playable_location(p_path,subsong_id)); - if (handle->should_reload(stats,true)) { - file_info_impl temp; - p_reader->get_info(subsong_id,temp,p_abort); - - add(handle,temp,stats,true); - } - } -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/metadb_io_hintlist.h b/tools/vio2sf/src/foobar/foobar2000/helpers/metadb_io_hintlist.h deleted file mode 100644 index 054964955..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/metadb_io_hintlist.h +++ /dev/null @@ -1,50 +0,0 @@ - -class metadb_io_hintlist { -public: - void hint_reader(service_ptr_t p_reader, const char * p_path,abort_callback & p_abort); - void add(metadb_handle_ptr const & p_handle,const file_info & p_info,t_filestats const & p_stats,bool p_fresh); - void run(); - t_size get_pending_count() const {return m_entries.get_count();} -private: - struct t_entry { - metadb_handle_ptr m_handle; - pfc::rcptr_t m_info; - t_filestats m_stats; - bool m_fresh; - }; - class metadb_io_hintlist_wrapper_part1 : public pfc::list_base_const_t { - public: - metadb_io_hintlist_wrapper_part1(const pfc::list_base_const_t & p_list) : m_list(p_list) {} - t_size get_count() const {return m_list.get_count();} - void get_item_ex(metadb_handle_ptr & p_out, t_size n) const {p_out = m_list[n].m_handle;} - - private: - const pfc::list_base_const_t & m_list; - }; - class metadb_io_hintlist_wrapper_part2 : public pfc::list_base_const_t { - public: - metadb_io_hintlist_wrapper_part2(const pfc::list_base_const_t & p_list) : m_list(p_list) {} - t_size get_count() const {return m_list.get_count();} - void get_item_ex(const file_info* & p_out, t_size n) const {p_out = &*m_list[n].m_info;} - private: - const pfc::list_base_const_t & m_list; - }; - class metadb_io_hintlist_wrapper_part3 : public pfc::list_base_const_t { - public: - metadb_io_hintlist_wrapper_part3(const pfc::list_base_const_t & p_list) : m_list(p_list) {} - t_size get_count() const {return m_list.get_count();} - void get_item_ex(t_filestats & p_out, t_size n) const {p_out = m_list[n].m_stats;} - private: - const pfc::list_base_const_t & m_list; - }; - class metadb_io_hintlist_wrapper_part4 : public bit_array { - public: - metadb_io_hintlist_wrapper_part4(const pfc::list_base_const_t & p_list) : m_list(p_list) {} - bool get(t_size n) const {return m_list[n].m_fresh;} - private: - const pfc::list_base_const_t & m_list; - }; - - pfc::list_t m_entries; -}; - diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/mp3_utils.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/mp3_utils.cpp deleted file mode 100644 index a3ace28e3..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/mp3_utils.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include "stdafx.h" - -using namespace bitreader_helper; - -static unsigned extract_header_bits(const t_uint8 p_header[4],unsigned p_base,unsigned p_bits) -{ - assert(p_base+p_bits<=32); - return extract_bits(p_header,p_base,p_bits); -} - -namespace { - - class header_parser - { - public: - header_parser(const t_uint8 p_header[4]) : m_bitptr(0) - { - memcpy(m_header,p_header,4); - } - unsigned read(unsigned p_bits) - { - unsigned ret = extract_header_bits(m_header,m_bitptr,p_bits); - m_bitptr += p_bits; - return ret; - } - private: - t_uint8 m_header[4]; - unsigned m_bitptr; - }; -} - -typedef t_uint16 uint16; - -static const uint16 bitrate_table_l1v1[16] = { 0, 32, 64, 96,128,160,192,224,256,288,320,352,384,416,448, 0}; -static const uint16 bitrate_table_l2v1[16] = { 0, 32, 48, 56, 64, 80, 96,112,128,160,192,224,256,320,384, 0}; -static const uint16 bitrate_table_l3v1[16] = { 0, 32, 40, 48, 56, 64, 80, 96,112,128,160,192,224,256,320, 0}; -static const uint16 bitrate_table_l1v2[16] = { 0, 32, 48, 56, 64, 80, 96,112,128,144,160,176,192,224,256, 0}; -static const uint16 bitrate_table_l23v2[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160, 0}; -static const uint16 sample_rate_table[] = {11025,12000,8000}; - -unsigned mp3_utils::QueryMPEGFrameSize(const t_uint8 p_header[4]) -{ - TMPEGFrameInfo info; - if (!ParseMPEGFrameHeader(info,p_header)) return 0; - return info.m_bytes; -} - -bool mp3_utils::ParseMPEGFrameHeader(TMPEGFrameInfo & p_info,const t_uint8 p_header[4]) -{ - enum {MPEG_LAYER_1 = 3, MPEG_LAYER_2 = 2, MPEG_LAYER_3 = 1}; - enum {_MPEG_1 = 3, _MPEG_2 = 2, _MPEG_25 = 0}; - - header_parser parser(p_header); - if (parser.read(11) != 0x7FF) return false; - unsigned mpeg_version = parser.read(2); - unsigned layer = parser.read(2); - unsigned protection = parser.read(1); - unsigned bitrate_index = parser.read(4); - unsigned sample_rate_index = parser.read(2); - if (sample_rate_index == 11) return false;//reserved - unsigned paddingbit = parser.read(1); - int paddingdelta = 0; - parser.read(1);//private - unsigned channel_mode = parser.read(2); - parser.read(2);//channel_mode_extension - parser.read(1);//copyright - parser.read(1);//original - parser.read(2);//emphasis - - unsigned bitrate = 0,sample_rate = 0; - - switch(layer) - { - default: - return false; - case MPEG_LAYER_3: - paddingdelta = paddingbit ? 1 : 0; - - p_info.m_layer = 3; - switch(mpeg_version) - { - case _MPEG_1: - p_info.m_duration = 1152; - bitrate = bitrate_table_l3v1[bitrate_index]; - break; - case _MPEG_2: - case _MPEG_25: - p_info.m_duration = 576; - bitrate = bitrate_table_l23v2[bitrate_index]; - break; - default: - return false; - } - - break; - case MPEG_LAYER_2: - paddingdelta = paddingbit ? 1 : 0; - p_info.m_duration = 1152; - p_info.m_layer = 2; - switch(mpeg_version) - { - case _MPEG_1: - bitrate = bitrate_table_l2v1[bitrate_index]; - break; - case _MPEG_2: - case _MPEG_25: - bitrate = bitrate_table_l23v2[bitrate_index]; - break; - default: - return false; - } - break; - case MPEG_LAYER_1: - paddingdelta = paddingbit ? 4 : 0; - p_info.m_duration = 384; - p_info.m_layer = 1; - switch(mpeg_version) - { - case _MPEG_1: - bitrate = bitrate_table_l1v1[bitrate_index]; - break; - case _MPEG_2: - case _MPEG_25: - bitrate = bitrate_table_l1v2[bitrate_index]; - break; - default: - return false; - } - break; - } - if (bitrate == 0) return false; - - sample_rate = sample_rate_table[sample_rate_index]; - if (sample_rate == 0) return false; - switch(mpeg_version) - { - case _MPEG_1: - sample_rate *= 4; - p_info.m_mpegversion = MPEG_1; - break; - case _MPEG_2: - sample_rate *= 2; - p_info.m_mpegversion = MPEG_2; - break; - case _MPEG_25: - p_info.m_mpegversion = MPEG_25; - break; - } - - switch(channel_mode) - { - case 0: - case 1: - case 2: - p_info.m_channels = 2; - break; - case 3: - p_info.m_channels = 1; - break; - } - - p_info.m_channel_mode = channel_mode; - - p_info.m_sample_rate = sample_rate; - - - p_info.m_bytes = ( bitrate /*kbps*/ * (1000/8) /* kbps-to-bytes*/ * p_info.m_duration /*samples-per-frame*/ ) / sample_rate + paddingdelta; - - if (p_info.m_layer == 1) p_info.m_bytes &= ~3; - - p_info.m_crc = protection == 0; - - return true; -} - -unsigned mp3header::get_samples_per_frame() -{ - mp3_utils::TMPEGFrameInfo fr; - if (!decode(fr)) return 0; - return fr.m_duration; -} - -bool mp3_utils::IsSameStream(TMPEGFrameInfo const & p_frame1,TMPEGFrameInfo const & p_frame2) { - return - p_frame1.m_channel_mode == p_frame2.m_channel_mode && - p_frame1.m_sample_rate == p_frame2.m_sample_rate && - p_frame1.m_layer == p_frame2.m_layer && - p_frame1.m_mpegversion == p_frame2.m_mpegversion; -} - - - -bool mp3_utils::ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { - if (frameSize < info.m_bytes) return false; //FAIL, incomplete data - if (!info.m_crc) return true; //nothing to check, frame appears valid - return ExtractFrameCRC(frameData, frameSize, info) == CalculateFrameCRC(frameData, frameSize, info); -} - -static t_uint32 CRC_update(unsigned value, t_uint32 crc) -{ - enum { CRC16_POLYNOMIAL = 0x8005 }; - unsigned i; - value <<= 8; - for (i = 0; i < 8; i++) { - value <<= 1; - crc <<= 1; - if (((crc ^ value) & 0x10000)) crc ^= CRC16_POLYNOMIAL; - } - return crc; -} - - -void mp3_utils::RecalculateFrameCRC(t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { - PFC_ASSERT( frameSize >= info.m_bytes && info.m_crc ); - - const t_uint16 crc = ExtractFrameCRC(frameData, frameSize, info); - frameData[4] = (t_uint8)(crc >> 8); - frameData[5] = (t_uint8)(crc & 0xFF); -} - -static t_uint16 grabFrameCRC(const t_uint8 * frameData, t_size sideInfoLen) { - t_uint32 crc = 0xffff; - crc = CRC_update(frameData[2], crc); - crc = CRC_update(frameData[3], crc); - for (t_size i = 6; i < sideInfoLen; i++) { - crc = CRC_update(frameData[i], crc); - } - - return (t_uint32) (crc & 0xFFFF); -} - -t_uint16 mp3_utils::ExtractFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { - PFC_ASSERT( frameSize >= info.m_bytes && info.m_crc ); - - return ((t_uint16)frameData[4] << 8) | (t_uint16)frameData[5]; - -} -t_uint16 mp3_utils::CalculateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & info) { - PFC_ASSERT( frameSize >= info.m_bytes && info.m_crc ); - - t_size sideInfoLen = 0; - if (info.m_mpegversion == MPEG_1) - sideInfoLen = (info.m_channels == 1) ? 4 + 17 : 4 + 32; - else - sideInfoLen = (info.m_channels == 1) ? 4 + 9 : 4 + 17; - - //CRC - sideInfoLen += 2; - - PFC_ASSERT( sideInfoLen <= frameSize ); - - return grabFrameCRC(frameData, sideInfoLen); -} - - -bool mp3_utils::ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize) { - if (frameSize < 4) return false; //FAIL, not a valid frame - TMPEGFrameInfo info; - if (!ParseMPEGFrameHeader(info, frameData)) return false; //FAIL, not a valid frame - return ValidateFrameCRC(frameData, frameSize, info); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/mp3_utils.h b/tools/vio2sf/src/foobar/foobar2000/helpers/mp3_utils.h deleted file mode 100644 index 0d058f29d..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/mp3_utils.h +++ /dev/null @@ -1,68 +0,0 @@ -namespace mp3_utils -{ - - enum { - MPG_MD_STEREO=0, - MPG_MD_JOINT_STEREO=1, - MPG_MD_DUAL_CHANNEL=2, - MPG_MD_MONO=3, - }; - - typedef t_uint8 byte; - - enum {MPEG_1, MPEG_2, MPEG_25}; - - struct TMPEGFrameInfo - { - unsigned m_bytes; - unsigned m_sample_rate; - unsigned m_layer; - unsigned m_mpegversion; - unsigned m_channels; - unsigned m_duration; - unsigned m_channel_mode; - bool m_crc; - }; - - - bool ParseMPEGFrameHeader(TMPEGFrameInfo & p_info,const t_uint8 p_header[4]); - bool ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize); - bool ValidateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); - - //! Assumes valid frame with CRC (frameInfo.m_crc set, frameInfo.m_bytes <= frameSize). - t_uint16 ExtractFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); - //! Assumes valid frame with CRC (frameInfo.m_crc set, frameInfo.m_bytes <= frameSize). - t_uint16 CalculateFrameCRC(const t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); - //! Assumes valid frame with CRC (frameInfo.m_crc set, frameInfo.m_bytes <= frameSize). - void RecalculateFrameCRC(t_uint8 * frameData, t_size frameSize, TMPEGFrameInfo const & frameInfo); - - unsigned QueryMPEGFrameSize(const t_uint8 p_header[4]); - bool IsSameStream(TMPEGFrameInfo const & p_frame1,TMPEGFrameInfo const & p_frame2); -}; - -class mp3header -{ - t_uint8 bytes[4]; -public: - - inline void copy(const mp3header & src) {memcpy(bytes,src.bytes,4);} - inline void copy_raw(const void * src) {memcpy(bytes,src,4);} - - inline mp3header(const mp3header & src) {copy(src);} - inline mp3header() {} - - inline const mp3header & operator=(const mp3header & src) {copy(src); return *this;} - - inline void get_bytes(void * out) {memcpy(out,bytes,4);} - inline unsigned get_frame_size() const {return mp3_utils::QueryMPEGFrameSize(bytes);} - inline bool decode(mp3_utils::TMPEGFrameInfo & p_out) {return mp3_utils::ParseMPEGFrameHeader(p_out,bytes);} - - unsigned get_samples_per_frame(); -}; - -static inline mp3header mp3header_from_buffer(const void * p_buffer) -{ - mp3header temp; - temp.copy_raw(p_buffer); - return temp; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/playlist_position_reference_tracker.h b/tools/vio2sf/src/foobar/foobar2000/helpers/playlist_position_reference_tracker.h deleted file mode 100644 index 4108b071a..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/playlist_position_reference_tracker.h +++ /dev/null @@ -1,73 +0,0 @@ -class playlist_position_reference_tracker : public playlist_callback_impl_base { -public: - //! @param p_trackitem Specifies whether we want to track some specific item rather than just an offset in a playlist. When set to true, item index becomes invalidated when the item we're tracking is removed. - playlist_position_reference_tracker(bool p_trackitem = true) : playlist_callback_impl_base(~0), m_trackitem(p_trackitem), m_playlist(infinite), m_item(infinite) {} - - void on_items_added(t_size p_playlist,t_size p_start, const pfc::list_base_const_t & p_data,const bit_array & p_selection) { - if (p_playlist == m_playlist && m_item != infinite && p_start <= m_item) { - m_item += p_data.get_count(); - } - } - void on_items_reordered(t_size p_playlist,const t_size * p_order,t_size p_count) { - if (p_playlist == m_playlist) { - if (m_item < p_count) { - m_item = order_helper::g_find_reverse(p_order,m_item); - } else { - m_item = infinite; - } - } - } - - void on_items_removed(t_size p_playlist,const bit_array & p_mask,t_size p_old_count,t_size p_new_count) { - if (p_playlist == m_playlist) { - if (m_item < p_old_count) { - const t_size item_before = m_item; - for(t_size walk = p_mask.find_first(true,0,p_old_count); walk < p_old_count; walk = p_mask.find_next(true,walk,p_old_count)) { - if (walk < item_before) { - m_item--; - } else if (walk == item_before) { - if (m_trackitem) m_item = infinite; - break; - } else { - break; - } - } - if (m_item >= p_new_count) m_item = infinite; - } else { - m_item = infinite; - } - } - } - - //todo? could be useful in some cases - void on_items_replaced(t_size p_playlist,const bit_array & p_mask,const pfc::list_base_const_t & p_data) {} - - void on_playlist_created(t_size p_index,const char * p_name,t_size p_name_len) { - if (m_playlist != infinite && p_index <= m_playlist) m_playlist++; - } - void on_playlists_reorder(const t_size * p_order,t_size p_count) { - if (m_playlist < p_count) m_playlist = order_helper::g_find_reverse(p_order,m_playlist); - else m_playlist = infinite; - } - void on_playlists_removed(const bit_array & p_mask,t_size p_old_count,t_size p_new_count) { - if (m_playlist < p_old_count) { - const t_size playlist_before = m_playlist; - for(t_size walk = p_mask.find_first(true,0,p_old_count); walk < p_old_count; walk = p_mask.find_next(true,walk,p_old_count)) { - if (walk < playlist_before) { - m_playlist--; - } else if (walk == playlist_before) { - m_playlist = infinite; - break; - } else { - break; - } - } - } else { - m_playlist = infinite; - } - } - - t_size m_playlist, m_item; -private: - const bool m_trackitem; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/preload_info_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/preload_info_helper.cpp deleted file mode 100644 index 1d352605a..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/preload_info_helper.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "stdafx.h" - -bool preload_info_helper::preload_info(metadb_handle_ptr p_item,HWND p_parent_window,bool p_showerror) { - if (p_item->is_info_loaded()) return true; - return static_api_ptr_t()->load_info(p_item,metadb_io::load_info_default,p_parent_window,p_showerror) == metadb_io::load_info_success; -} - -bool preload_info_helper::are_all_loaded(const pfc::list_base_const_t & p_items) -{ - t_size n, m = p_items.get_count(); - for(n=0;nis_info_loaded()) return false; - } - return true; -} - -bool preload_info_helper::preload_info_multi(const pfc::list_base_const_t & p_items,HWND p_parent_window,bool p_showerror) -{ - if (are_all_loaded(p_items)) return true; - return static_api_ptr_t()->load_info_multi(p_items,metadb_io::load_info_default,p_parent_window,p_showerror) == metadb_io::load_info_success; -} - -bool preload_info_helper::preload_info_multi_modalcheck(const pfc::list_base_const_t & p_items,HWND p_parent_window,bool p_showerror) -{ - if (are_all_loaded(p_items)) return true; - if (!modal_dialog_scope::can_create()) return false; - return static_api_ptr_t()->load_info_multi(p_items,metadb_io::load_info_default,p_parent_window,p_showerror) == metadb_io::load_info_success; -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/preload_info_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/preload_info_helper.h deleted file mode 100644 index 5f3451f36..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/preload_info_helper.h +++ /dev/null @@ -1,6 +0,0 @@ -namespace preload_info_helper { - bool __declspec(deprecated("Use metadb_io_v2 methods instead.")) preload_info(metadb_handle_ptr p_item,HWND p_parent_window,bool p_showerror); - bool __declspec(deprecated("Use metadb_io_v2 methods instead.")) preload_info_multi(const pfc::list_base_const_t & p_items,HWND p_parent_window,bool p_showerror); - bool __declspec(deprecated("Use metadb_io_v2 methods instead.")) preload_info_multi_modalcheck(const pfc::list_base_const_t & p_items,HWND p_parent_window,bool p_showerror); - bool are_all_loaded(const pfc::list_base_const_t & p_items); -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/seekabilizer.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/seekabilizer.cpp deleted file mode 100644 index 5173d39ec..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/seekabilizer.cpp +++ /dev/null @@ -1,218 +0,0 @@ -#include "stdafx.h" - -enum {backread_on_seek = 1024}; - -void seekabilizer_backbuffer::initialize(t_size p_size) -{ - m_depth = m_cursor = 0; - - m_buffer.set_size(p_size); -} - -void seekabilizer_backbuffer::write(const void * p_buffer,t_size p_bytes) -{ - if (p_bytes >= m_buffer.get_size()) - { - memcpy(m_buffer.get_ptr(),(const t_uint8*)p_buffer + p_bytes - m_buffer.get_size(),m_buffer.get_size()); - m_cursor = 0; - m_depth = m_buffer.get_size(); - } - else - { - const t_uint8* sourceptr = (const t_uint8*) p_buffer; - t_size remaining = p_bytes; - while(remaining > 0) - { - t_size delta = m_buffer.get_size() - m_cursor; - if (delta > remaining) delta = remaining; - - memcpy(m_buffer.get_ptr() + m_cursor,sourceptr,delta); - - sourceptr += delta; - remaining -= delta; - m_cursor = (m_cursor + delta) % m_buffer.get_size(); - - m_depth = pfc::min_t(m_buffer.get_size(),m_depth + delta); - - } - } -} - -void seekabilizer_backbuffer::read(t_size p_backlogdepth,void * p_buffer,t_size p_bytes) const -{ - assert(p_backlogdepth <= m_depth); - assert(p_backlogdepth >= p_bytes); - - - t_uint8* targetptr = (t_uint8*) p_buffer; - t_size remaining = p_bytes; - t_size cursor = (m_cursor + m_buffer.get_size() - p_backlogdepth) % m_buffer.get_size(); - - while(remaining > 0) - { - t_size delta = m_buffer.get_size() - cursor; - if (delta > remaining) delta = remaining; - - memcpy(targetptr,m_buffer.get_ptr() + cursor,delta); - - targetptr += delta; - remaining -= delta; - cursor = (cursor + delta) % m_buffer.get_size(); - } -} - -t_size seekabilizer_backbuffer::get_depth() const -{ - return m_depth; -} - -t_size seekabilizer_backbuffer::get_max_depth() const -{ - return m_buffer.get_size(); -} - -void seekabilizer_backbuffer::reset() -{ - m_depth = m_cursor = 0; -} - - -void seekabilizer::initialize(service_ptr_t p_base,t_size p_buffer_size,abort_callback & p_abort) { - m_buffer.initialize(p_buffer_size); - m_file = p_base; - m_position = m_position_base = 0; - m_size = m_file->get_size(p_abort); -} - -void seekabilizer::g_seekabilize(service_ptr_t & p_reader,t_size p_buffer_size,abort_callback & p_abort) { - if (p_reader.is_valid() && p_reader->is_remote() && p_buffer_size > 0) { - service_ptr_t instance = new service_impl_t(); - instance->initialize(p_reader,p_buffer_size,p_abort); - p_reader = instance.get_ptr(); - } -} - -t_size seekabilizer::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check_e(); - - if (m_position > m_position_base + pfc::max_t(m_buffer.get_max_depth(),backread_on_seek) && m_file->can_seek()) { - t_filesize target = m_position; - if (target < backread_on_seek) target = 0; - else target -= backread_on_seek; - m_file->seek(target,p_abort); - m_position_base = target; - } - - //seek ahead - while(m_position > m_position_base) { - enum {tempsize = 1024}; - t_uint8 temp[tempsize]; - t_size delta = (t_size) pfc::min_t(tempsize,m_position - m_position_base); - t_size bytes_read = 0; - bytes_read = m_file->read(temp,delta,p_abort); - m_buffer.write(temp,bytes_read); - m_position_base += bytes_read; - - if (bytes_read < delta) { - return 0; - } - } - - t_size done = 0; - t_uint8 * targetptr = (t_uint8*) p_buffer; - - //try to read backbuffer - if (m_position < m_position_base) { - if (m_position_base - m_position > (t_filesize)m_buffer.get_depth()) throw exception_io_seek_out_of_range(); - t_size backread_depth = (t_size) (m_position_base - m_position); - t_size delta = pfc::min_t(backread_depth,p_bytes-done); - m_buffer.read(backread_depth,targetptr,delta); - done += delta; - m_position += delta; - } - - //regular read - if (done < p_bytes) - { - t_size bytes_read; - bytes_read = m_file->read(targetptr+done,p_bytes-done,p_abort); - - m_buffer.write(targetptr+done,bytes_read); - - done += bytes_read; - m_position += bytes_read; - m_position_base += bytes_read; - } - - return done; -} - -t_filesize seekabilizer::get_size(abort_callback & p_abort) { - p_abort.check_e(); - return m_size; -} - -t_filesize seekabilizer::get_position(abort_callback & p_abort) { - p_abort.check_e(); - return m_position; -} - -void seekabilizer::seek(t_filesize p_position,abort_callback & p_abort) { - assert(m_position_base >= m_buffer.get_depth()); - p_abort.check_e(); - - if (m_size != filesize_invalid && p_position > m_size) throw exception_io_seek_out_of_range(); - - t_filesize lowest = m_position_base - m_buffer.get_depth(); - - if (p_position < lowest) { - if (m_file->can_seek()) { - m_buffer.reset(); - t_filesize target = p_position; - t_size delta = m_buffer.get_max_depth(); - if (delta > backread_on_seek) delta = backread_on_seek; - if (target > delta) target -= delta; - else target = 0; - m_file->seek(target,p_abort); - m_position_base = target; - } - else { - m_buffer.reset(); - m_file->reopen(p_abort); - m_position_base = 0; - } - } - - m_position = p_position; -} - -bool seekabilizer::can_seek() -{ - return true; -} - -bool seekabilizer::get_content_type(pfc::string_base & p_out) {return m_file->get_content_type(p_out);} - -bool seekabilizer::is_in_memory() {return false;} - -void seekabilizer::on_idle(abort_callback & p_abort) {return m_file->on_idle(p_abort);} - -t_filetimestamp seekabilizer::get_timestamp(abort_callback & p_abort) { - p_abort.check_e(); - return m_file->get_timestamp(p_abort); -} - -void seekabilizer::reopen(abort_callback & p_abort) { - if (m_position_base - m_buffer.get_depth() == 0) { - seek(0,p_abort); - } else { - m_position = m_position_base = 0; - m_buffer.reset(); - m_file->reopen(p_abort); - } -} - -bool seekabilizer::is_remote() -{ - return m_file->is_remote(); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/seekabilizer.h b/tools/vio2sf/src/foobar/foobar2000/helpers/seekabilizer.h deleted file mode 100644 index 454546b14..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/seekabilizer.h +++ /dev/null @@ -1,36 +0,0 @@ -class seekabilizer_backbuffer -{ -public: - void initialize(t_size p_size); - void write(const void * p_buffer,t_size p_bytes); - void read(t_size p_backlogdepth,void * p_buffer,t_size p_bytes) const; - t_size get_depth() const; - void reset(); - t_size get_max_depth() const; -private: - pfc::array_t m_buffer; - t_size m_depth,m_cursor; -}; - -class seekabilizer : public file_readonly { -public: - void initialize(service_ptr_t p_base,t_size p_buffer_size,abort_callback & p_abort); - - static void g_seekabilize(service_ptr_t & p_reader,t_size p_buffer_size,abort_callback & p_abort); - - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort); - t_filesize get_size(abort_callback & p_abort); - t_filesize get_position(abort_callback & p_abort); - void seek(t_filesize p_position,abort_callback & p_abort); - bool can_seek(); - bool get_content_type(pfc::string_base & p_out); - bool is_in_memory(); - void on_idle(abort_callback & p_abort); - t_filetimestamp get_timestamp(abort_callback & p_abort); - void reopen(abort_callback & p_abort); - bool is_remote(); -private: - service_ptr_t m_file; - seekabilizer_backbuffer m_buffer; - t_filesize m_size,m_position,m_position_base; -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/stream_buffer_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/stream_buffer_helper.cpp deleted file mode 100644 index 6e6c099a2..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/stream_buffer_helper.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "stdafx.h" - -stream_reader_buffered::stream_reader_buffered(stream_reader * p_base,t_size p_buffer) : m_base(p_base) -{ - m_buffer.set_size(p_buffer); - m_buffer_ptr = 0; - m_buffer_max = 0; -} - -t_size stream_reader_buffered::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check_e(); - char * output = (char*) p_buffer; - t_size output_ptr = 0; - - while(output_ptr < p_bytes) { - { - t_size delta = pfc::min_t(p_bytes - output_ptr, m_buffer_max - m_buffer_ptr); - if (delta > 0) - { - memcpy(output + output_ptr, m_buffer.get_ptr() + m_buffer_ptr, delta); - output_ptr += delta; - m_buffer_ptr += delta; - } - } - - if (m_buffer_ptr == m_buffer_max) - { - t_size bytes_read; - bytes_read = m_base->read(m_buffer.get_ptr(), m_buffer.get_size(), p_abort); - m_buffer_ptr = 0; - m_buffer_max = bytes_read; - - if (m_buffer_max == 0) break; - } - } - - return output_ptr; -} - -stream_writer_buffered::stream_writer_buffered(stream_writer * p_base,t_size p_buffer) - : m_base(p_base) -{ - m_buffer.set_size(p_buffer); - m_buffer_ptr = 0; -} - -void stream_writer_buffered::write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) { - p_abort.check_e(); - const char * source = (const char*)p_buffer; - t_size source_remaining = p_bytes; - const t_size buffer_size = m_buffer.get_size(); - if (source_remaining >= buffer_size) - { - flush(p_abort); - m_base->write_object(source,source_remaining,p_abort); - return; - } - - if (m_buffer_ptr + source_remaining >= buffer_size) - { - t_size delta = buffer_size - m_buffer_ptr; - memcpy(m_buffer.get_ptr() + m_buffer_ptr, source,delta); - source += delta; - source_remaining -= delta; - m_buffer_ptr += delta; - flush(p_abort); - } - - memcpy(m_buffer.get_ptr() + m_buffer_ptr, source,source_remaining); - m_buffer_ptr += source_remaining; -} - - -void stream_writer_buffered::flush(abort_callback & p_abort) { - if (m_buffer_ptr > 0) { - m_base->write_object(m_buffer.get_ptr(),m_buffer_ptr,p_abort); - m_buffer_ptr = 0; - } -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/stream_buffer_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/stream_buffer_helper.h deleted file mode 100644 index b58c382c4..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/stream_buffer_helper.h +++ /dev/null @@ -1,26 +0,0 @@ -class stream_reader_buffered : public stream_reader -{ -public: - stream_reader_buffered(stream_reader * p_base,t_size p_buffer); - t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort); -private: - stream_reader * m_base; - pfc::array_t m_buffer; - t_size m_buffer_ptr, m_buffer_max; -}; - -class stream_writer_buffered : public stream_writer -{ -public: - stream_writer_buffered(stream_writer * p_base,t_size p_buffer); - - void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort); - - void flush(abort_callback & p_abort); - -private: - stream_writer * m_base; - pfc::array_t m_buffer; - t_size m_buffer_ptr; -}; - diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/string_filter.h b/tools/vio2sf/src/foobar/foobar2000/helpers/string_filter.h deleted file mode 100644 index 6507407de..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/string_filter.h +++ /dev/null @@ -1,24 +0,0 @@ -class string_filter_noncasesensitive { -public: - string_filter_noncasesensitive(const char * p_string,t_size p_string_len = infinite) { - uStringLower(m_pattern,p_string,p_string_len); - } - - bool test(const char * p_string,t_size p_string_len = infinite) const { - ::uStringLower(m_lowercasebuffer,p_string,p_string_len); - t_size walk = 0; - while(m_pattern[walk] != 0) { - while(m_pattern[walk] == ' ') walk++; - t_size delta = 0; - while(m_pattern[walk+delta] != 0 && m_pattern[walk+delta] != ' ') delta++; - if (delta > 0) { - if (pfc::string_find_first_ex(m_lowercasebuffer,infinite,m_pattern+walk,delta) == infinite) return false; - } - walk += delta; - } - return true; - } -private: - mutable pfc::string8_fastalloc m_lowercasebuffer; - pfc::string8 m_pattern; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/text_file_loader.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/text_file_loader.cpp deleted file mode 100644 index ec63ff403..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/text_file_loader.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "StdAfx.h" - -static const unsigned char utf8_header[3] = {0xEF,0xBB,0xBF}; - -namespace text_file_loader -{ - void write(const service_ptr_t & p_file,abort_callback & p_abort,const char * p_string,bool is_utf8) - { - p_file->seek(0,p_abort); - p_file->set_eof(p_abort); - if (is_utf8) - { - p_file->write_object(utf8_header,sizeof(utf8_header),p_abort); - p_file->write_object(p_string,strlen(p_string),p_abort); - } - else - { - pfc::stringcvt::string_ansi_from_utf8 bah(p_string); - p_file->write_object(bah,bah.length(),p_abort); - } - } - - void read(const service_ptr_t & p_file,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8) { - p_out.reset(); - if (p_file->can_seek()) - { - p_file->seek(0,p_abort); - } - - pfc::array_t mem; - t_filesize size64; - size64 = p_file->get_size(p_abort); - if (size64 == filesize_invalid)//typically HTTP - { - pfc::string8 ansitemp; - is_utf8 = false; - enum {delta = 1024*64, max = 1024*512}; - char temp[3]; - t_size done; - done = p_file->read(temp,3,p_abort); - if (done != 3) - { - if (done > 0) p_out = pfc::stringcvt::string_utf8_from_ansi(temp,done); - return; - } - if (!memcmp(utf8_header,temp,3)) is_utf8 = true; - else ansitemp.add_string(temp,3); - - mem.set_size(delta); - - for(;;) - { - done = p_file->read(mem.get_ptr(),delta,p_abort); - if (done > 0) - { - if (is_utf8) p_out.add_string(mem.get_ptr(),done); - else ansitemp.add_string(mem.get_ptr(),done); - } - if (done < delta) break; - } - - if (!is_utf8) - { - p_out = pfc::stringcvt::string_utf8_from_ansi(ansitemp); - } - - return; - } - else - { - if (size64>1024*1024*128) throw exception_io_data();//hard limit - t_size size = pfc::downcast_guarded(size64); - mem.set_size(size+1); - char * asdf = mem.get_ptr(); - p_file->read_object(asdf,size,p_abort); - asdf[size]=0; - if (size>3 && !memcmp(utf8_header,asdf,3)) {is_utf8 = true; p_out.add_string(asdf+3); } - else { - is_utf8 = false; - p_out = pfc::stringcvt::string_utf8_from_ansi(asdf); - } - return; - } - } - - void write(const char * p_path,abort_callback & p_abort,const char * p_string,bool is_utf8) - { - service_ptr_t f; - filesystem::g_open_write_new(f,p_path,p_abort); - write(f,p_abort,p_string,is_utf8); - } - - void read(const char * p_path,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8) - { - service_ptr_t f; - filesystem::g_open_read(f,p_path,p_abort); - read(f,p_abort,p_out,is_utf8); - } - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/text_file_loader.h b/tools/vio2sf/src/foobar/foobar2000/helpers/text_file_loader.h deleted file mode 100644 index fd4b83622..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/text_file_loader.h +++ /dev/null @@ -1,9 +0,0 @@ -namespace text_file_loader -{ - void write(const service_ptr_t & p_file,abort_callback & p_abort,const char * p_string,bool is_utf8); - void read(const service_ptr_t & p_file,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8); - - void write(const char * p_path,abort_callback & p_abort,const char * p_string,bool is_utf8); - void read(const char * p_path,abort_callback & p_abort,pfc::string_base & p_out,bool & is_utf8); - -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/wildcard.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/wildcard.cpp deleted file mode 100644 index de15870eb..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/wildcard.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "stdafx.h" - -static bool test_recur(const char * fn,const char * rm,bool b_sep) -{ - for(;;) - { - if ((b_sep && *rm==';') || *rm==0) return *fn==0; - else if (*rm=='*') - { - rm++; - do - { - if (test_recur(fn,rm,b_sep)) return true; - } while(pfc::utf8_advance(fn)); - return false; - } - else if (*fn==0) return false; - else if (*rm!='?' && uCharLower(pfc::utf8_get_char(fn))!=uCharLower(pfc::utf8_get_char(rm))) return false; - - fn = pfc::utf8_char_next(fn); rm = pfc::utf8_char_next(rm); - } -} - -bool wildcard_helper::test_path(const char * path,const char * pattern,bool b_sep) {return test(path + pfc::scan_filename(path),pattern,b_sep);} - -bool wildcard_helper::test(const char * fn,const char * pattern,bool b_sep) -{ - if (!b_sep) return test_recur(fn,pattern,false); - const char * rm=pattern; - while(*rm) - { - if (test_recur(fn,rm,true)) return true; - while(*rm && *rm!=';') rm++; - if (*rm==';') - { - while(*rm==';') rm++; - while(*rm==' ') rm++; - } - }; - - return false; -} - -bool wildcard_helper::has_wildcards(const char * str) {return strchr(str,'*') || strchr(str,'?');} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/wildcard.h b/tools/vio2sf/src/foobar/foobar2000/helpers/wildcard.h deleted file mode 100644 index c38aed9f7..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/wildcard.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __FOOBAR2000_HELPER_WILDCARD_H__ -#define __FOOBAR2000_HELPER_WILDCARD_H__ - -namespace wildcard_helper -{ - bool test_path(const char * path,const char * pattern,bool b_separate_by_semicolon = false);//will extract filename from path first - bool test(const char * str,const char * pattern,bool b_separate_by_semicolon = false);//tests if str matches pattern - bool has_wildcards(const char * str); -}; - - - -#endif //__FOOBAR2000_HELPER_WILDCARD_H__ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_dialog.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/win32_dialog.cpp deleted file mode 100644 index 1c38be59a..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_dialog.cpp +++ /dev/null @@ -1,288 +0,0 @@ -#include "stdafx.h" - - -namespace dialog_helper { - - - INT_PTR CALLBACK dialog::DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) - { - dialog * p_this; - BOOL rv; - if (msg==WM_INITDIALOG) - { - p_this = reinterpret_cast(lp); - p_this->wnd = wnd; - SetWindowLongPtr(wnd,DWLP_USER,lp); - - if (p_this->m_is_modal) p_this->m_modal_scope.initialize(wnd); - } - else p_this = reinterpret_cast(GetWindowLongPtr(wnd,DWLP_USER)); - - rv = p_this ? p_this->on_message(msg,wp,lp) : FALSE; - - if (msg==WM_DESTROY && p_this) - { - SetWindowLongPtr(wnd,DWLP_USER,0); -// p_this->wnd = 0; - } - - return rv; - } - - - int dialog::run_modal(unsigned id,HWND parent) - { - assert(wnd == 0); - if (wnd != 0) return -1; - m_is_modal = true; - return uDialogBox(id,parent,DlgProc,reinterpret_cast(this)); - } - HWND dialog::run_modeless(unsigned id,HWND parent) - { - assert(wnd == 0); - if (wnd != 0) return 0; - m_is_modal = false; - return uCreateDialog(id,parent,DlgProc,reinterpret_cast(this)); - } - - void dialog::end_dialog(int code) - { - assert(m_is_modal); - if (m_is_modal) uEndDialog(wnd,code); - } - - - - - - - - - - - int dialog_modal::run(unsigned p_id,HWND p_parent,HINSTANCE p_instance) - { - int status; - - // note: uDialogBox() has its own modal scope, we don't want that to trigger - // if this is ever changed, move deinit to WM_DESTROY handler in DlgProc - - status = (int)DialogBoxParam(p_instance,MAKEINTRESOURCE(p_id),p_parent,DlgProc,reinterpret_cast(this)); - - m_modal_scope.deinitialize(); - - return status; - } - - void dialog_modal::end_dialog(int p_code) - { - EndDialog(m_wnd,p_code); - } - - - INT_PTR CALLBACK dialog_modal::DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) - { - dialog_modal * _this; - if (msg==WM_INITDIALOG) - { - _this = reinterpret_cast(lp); - _this->m_wnd = wnd; - SetWindowLongPtr(wnd,DWLP_USER,lp); - - _this->m_modal_scope.initialize(wnd); - } - else _this = reinterpret_cast(GetWindowLongPtr(wnd,DWLP_USER)); - - assert(_this == 0 || _this->m_wnd == wnd); - - return _this ? _this->on_message(msg,wp,lp) : FALSE; - } - - - bool dialog_modeless::create(unsigned p_id,HWND p_parent,HINSTANCE p_instance) { - assert(!m_is_in_create); - if (m_is_in_create) return false; - pfc::vartoggle_t scope(m_is_in_create,true); - if (CreateDialogParam(p_instance,MAKEINTRESOURCE(p_id),p_parent,DlgProc,reinterpret_cast(this)) == 0) return false; - return m_wnd != 0; - } - - dialog_modeless::~dialog_modeless() { - assert(!m_is_in_create); - switch(m_destructor_status) - { - case destructor_none: - m_destructor_status = destructor_normal; - if (m_wnd != 0) - { - DestroyWindow(m_wnd); - m_wnd = 0; - } - break; - case destructor_fromwindow: - if (m_wnd != 0) SetWindowLongPtr(m_wnd,DWLP_USER,0); - break; - default: - //should never trigger - pfc::crash(); - break; - } - } - - void dialog_modeless::on_window_destruction() - { - if (m_is_in_create) - { - m_wnd = 0; - } - else - switch(m_destructor_status) - { - case destructor_none: - m_destructor_status = destructor_fromwindow; - delete this; - break; - case destructor_fromwindow: - pfc::crash(); - break; - default: - break; - } - } - - BOOL dialog_modeless::on_message_wrap(UINT msg,WPARAM wp,LPARAM lp) - { - if (m_destructor_status == destructor_none) - return on_message(msg,wp,lp); - else - return FALSE; - } - - INT_PTR CALLBACK dialog_modeless::DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) - { - dialog_modeless * thisptr; - BOOL rv; - if (msg == WM_INITDIALOG) - { - thisptr = reinterpret_cast(lp); - thisptr->m_wnd = wnd; - SetWindowLongPtr(wnd,DWLP_USER,lp); - modeless_dialog_manager::g_add(wnd); - } - else thisptr = reinterpret_cast(GetWindowLongPtr(wnd,DWLP_USER)); - - rv = thisptr ? thisptr->on_message_wrap(msg,wp,lp) : FALSE; - - if (msg == WM_DESTROY) - modeless_dialog_manager::g_remove(wnd); - - if (msg == WM_DESTROY && thisptr != 0) - thisptr->on_window_destruction(); - - return rv; - } - - - - - - - - - - - - - - - - - dialog_modeless_v2::dialog_modeless_v2(unsigned p_id,HWND p_parent,HINSTANCE p_instance,bool p_stealfocus) : m_wnd(0), m_status(status_construction), m_stealfocus(p_stealfocus) - { - WIN32_OP( CreateDialogParam(p_instance,MAKEINTRESOURCE(p_id),p_parent,DlgProc,reinterpret_cast(this)) != NULL ); - m_status = status_lifetime; - } - - dialog_modeless_v2::~dialog_modeless_v2() - { - bool is_window_being_destroyed = (m_status == status_destruction_requested); - m_status = status_destruction; - - if (m_wnd != 0) - { - if (is_window_being_destroyed) - detach_window(); - else - DestroyWindow(m_wnd); - } - } - - INT_PTR CALLBACK dialog_modeless_v2::DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) - { - dialog_modeless_v2 * thisptr; - BOOL rv = FALSE; - if (msg == WM_INITDIALOG) - { - thisptr = reinterpret_cast(lp); - assert(thisptr->m_status == status_construction); - thisptr->m_wnd = wnd; - SetWindowLongPtr(wnd,DWLP_USER,lp); - if (GetWindowLong(wnd,GWL_STYLE) & WS_POPUP) { - modeless_dialog_manager::g_add(wnd); - } - } - else thisptr = reinterpret_cast(GetWindowLongPtr(wnd,DWLP_USER)); - - if (thisptr != NULL) rv = thisptr->on_message_internal(msg,wp,lp); - - if (msg == WM_DESTROY) - { - modeless_dialog_manager::g_remove(wnd); - } - - return rv; - } - - - void dialog_modeless_v2::detach_window() - { - if (m_wnd != 0) - { - SetWindowLongPtr(m_wnd,DWLP_USER,0); - m_wnd = 0; - } - } - - - BOOL dialog_modeless_v2::on_message_internal(UINT msg,WPARAM wp,LPARAM lp) - { - if (m_status == status_lifetime || m_status == status_destruction_requested) - { - if (msg == WM_DESTROY) - { - assert(m_status == status_lifetime); - m_status = status_destruction_requested; - delete this; - return TRUE; - } - else - return on_message(msg,wp,lp); - } - else if (m_status == status_construction) - { - if (msg == WM_INITDIALOG) return m_stealfocus ? TRUE : FALSE; - else return FALSE; - } - else return FALSE; - } -} - -HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,LPARAM param) -{ - return CreateDialogParam(core_api::get_my_instance(),MAKEINTRESOURCE(id),parent,proc,param); -} - -int uDialogBox(UINT id,HWND parent,DLGPROC proc,LPARAM param) -{ - return (int)DialogBoxParam(core_api::get_my_instance(),MAKEINTRESOURCE(id),parent,proc,param); -} diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_dialog.h b/tools/vio2sf/src/foobar/foobar2000/helpers/win32_dialog.h deleted file mode 100644 index 6c409c1e5..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_dialog.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _FOOBAR2000_HELPERS_WIN32_DIALOG_H_ -#define _FOOBAR2000_HELPERS_WIN32_DIALOG_H_ - -//DEPRECATED dialog helpers - kept only for compatibility with old code - do not use in new code, use WTL instead. - -namespace dialog_helper -{ - - class dialog - { - protected: - - dialog() : wnd(0), m_is_modal(false) {} - ~dialog() { } - - virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0; - - void end_dialog(int code); - - public: - inline HWND get_wnd() {return wnd;} - - __declspec(deprecated) int run_modal(unsigned id,HWND parent); - - __declspec(deprecated) HWND run_modeless(unsigned id,HWND parent); - private: - HWND wnd; - static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); - - bool m_is_modal; - - modal_dialog_scope m_modal_scope; - }; - - //! This class is meant to be instantiated on-stack, as a local variable. Using new/delete operators instead or even making this a member of another object works, but does not make much sense because of the way this works (single run() call). - class dialog_modal - { - public: - __declspec(deprecated) int run(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance()); - protected: - virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0; - - inline dialog_modal() : m_wnd(0) {} - void end_dialog(int p_code); - inline HWND get_wnd() const {return m_wnd;} - private: - static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); - - HWND m_wnd; - modal_dialog_scope m_modal_scope; - }; - - //! This class is meant to be used with new/delete operators only. Destroying the window - outside create() / WM_INITDIALOG - will result in object calling delete this. If object is deleted directly using delete operator, WM_DESTROY handler may not be called so it should not be used (use destructor of derived class instead). - //! Classes derived from dialog_modeless must not be instantiated in any other way than operator new(). - /*! Typical usage : \n - class mydialog : public dialog_helper::dialog_modeless {...}; - (...) - bool createmydialog() - { - mydialog * instance = new mydialog; - if (instance == 0) return flase; - if (!instance->create(...)) {delete instance; return false;} - return true; - } - - */ - class dialog_modeless - { - public: - //! Creates the dialog window. This will call on_message with WM_INITDIALOG. To abort creation, you can call DestroyWindow() on our window; it will not delete the object but make create() return false instead. You should not delete the object from inside WM_INITDIALOG handler or anything else possibly called from create(). - //! @returns true on success, false on failure. - __declspec(deprecated) bool create(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance()); - protected: - //! Standard windows message handler (DialogProc-style). Use get_wnd() to retrieve our dialog window handle. - virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp)=0; - - inline dialog_modeless() : m_wnd(0), m_destructor_status(destructor_none), m_is_in_create(false) {} - inline HWND get_wnd() const {return m_wnd;} - virtual ~dialog_modeless(); - private: - static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); - void on_window_destruction(); - - BOOL on_message_wrap(UINT msg,WPARAM wp,LPARAM lp); - - HWND m_wnd; - enum {destructor_none,destructor_normal,destructor_fromwindow} m_destructor_status; - bool m_is_in_create; - }; - - - class dialog_modeless_v2 - { - protected: - __declspec(deprecated) explicit dialog_modeless_v2(unsigned p_id,HWND p_parent,HINSTANCE p_instance = core_api::get_my_instance(),bool p_stealfocus = true); - virtual ~dialog_modeless_v2(); - HWND get_wnd() const {return m_wnd;} - virtual BOOL on_message(UINT msg,WPARAM wp,LPARAM lp) {return FALSE;} - - static dialog_modeless_v2 * __unsafe__instance_from_window(HWND p_wnd) {return reinterpret_cast(GetWindowLongPtr(p_wnd,DWLP_USER));} - private: - static INT_PTR CALLBACK DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); - void detach_window(); - BOOL on_message_internal(UINT msg,WPARAM wp,LPARAM lp); - enum {status_construction, status_lifetime, status_destruction_requested, status_destruction} m_status; - HWND m_wnd; - const bool m_stealfocus; - - const dialog_modeless_v2 & operator=(const dialog_modeless_v2 &); - dialog_modeless_v2(const dialog_modeless_v2 &); - }; - -}; - -//! Wrapper (provided mainly for old code), simplifies parameters compared to standard CreateDialog() by using core_api::get_my_instance(). -HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0); -//! Wrapper (provided mainly for old code), simplifies parameters compared to standard DialogBox() by using core_api::get_my_instance(). -int uDialogBox(UINT id,HWND parent,DLGPROC proc,LPARAM param = 0); - - -#endif diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_misc.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/win32_misc.cpp deleted file mode 100644 index 76d71b53d..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_misc.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "stdafx.h" - -void registerclass_scope_delayed::toggle_on(UINT p_style,WNDPROC p_wndproc,int p_clsextra,int p_wndextra,HICON p_icon,HCURSOR p_cursor,HBRUSH p_background,const TCHAR * p_class_name,const TCHAR * p_menu_name) { - toggle_off(); - WNDCLASS wc = {}; - wc.style = p_style; - wc.lpfnWndProc = p_wndproc; - wc.cbClsExtra = p_clsextra; - wc.cbWndExtra = p_wndextra; - wc.hInstance = core_api::get_my_instance(); - wc.hIcon = p_icon; - wc.hCursor = p_cursor; - wc.hbrBackground = p_background; - wc.lpszMenuName = p_menu_name; - wc.lpszClassName = p_class_name; - WIN32_OP( (m_class = RegisterClass(&wc)) != 0); -} - -void registerclass_scope_delayed::toggle_off() { - if (m_class != 0) { - UnregisterClass((LPCTSTR)m_class,core_api::get_my_instance()); - m_class = 0; - } -} - - -unsigned QueryScreenDPI() { - HDC dc = GetDC(0); - unsigned ret = GetDeviceCaps(dc,LOGPIXELSY); - ReleaseDC(0,dc); - return ret; -} - - -SIZE QueryScreenDPIEx() { - HDC dc = GetDC(0); - SIZE ret = { GetDeviceCaps(dc,LOGPIXELSY), GetDeviceCaps(dc,LOGPIXELSY) }; - ReleaseDC(0,dc); - return ret; -} - - -bool IsMenuNonEmpty(HMENU menu) { - unsigned n,m=GetMenuItemCount(menu); - for(n=0;n msgFormatted; msgFormatted.set_size(pfc::strlen_t(_Message) + 64); - wsprintfW(msgFormatted.get_ptr(), L"%s (code: %u)", _Message, code); - if (IsDebuggerPresent()) { - OutputDebugString(TEXT("WIN32_OP_D() failure:\n")); - OutputDebugString(msgFormatted.get_ptr()); - OutputDebugString(TEXT("\n")); - pfc::crash(); - } - _wassert(msgFormatted.get_ptr(),_File,_Line); -} -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_misc.h b/tools/vio2sf/src/foobar/foobar2000/helpers/win32_misc.h deleted file mode 100644 index 3862ed637..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/win32_misc.h +++ /dev/null @@ -1,399 +0,0 @@ -void WIN32_OP_FAIL(); -#ifdef _DEBUG -void WIN32_OP_D_FAIL(const wchar_t * _Message, const wchar_t *_File, unsigned _Line); -#endif - -//Throws an exception when (OP) evaluates to false/zero. -#define WIN32_OP(OP) \ - { \ - SetLastError(NO_ERROR); \ - if (!(OP)) WIN32_OP_FAIL(); \ - } - -//WIN32_OP_D() acts like an assert specialized for win32 operations in debug build, ignores the return value / error codes in release build. -//Use WIN32_OP_D() instead of WIN32_OP() on operations that are extremely unlikely to fail, so failure condition checks are performed in the debug build only, to avoid bloating release code with pointless error checks. -#ifdef _DEBUG -#define WIN32_OP_D(OP) \ - { \ - SetLastError(NO_ERROR); \ - if (!(OP)) WIN32_OP_D_FAIL(PFC_WIDESTRING(#OP), PFC_WIDESTRING(__FILE__), __LINE__); \ - } - -#else -#define WIN32_OP_D(OP) (void)( (OP), 0); -#endif - - -class registerclass_scope_delayed { -public: - registerclass_scope_delayed() : m_class(0) {} - - bool is_registered() const {return m_class != 0;} - void toggle_on(UINT p_style,WNDPROC p_wndproc,int p_clsextra,int p_wndextra,HICON p_icon,HCURSOR p_cursor,HBRUSH p_background,const TCHAR * p_classname,const TCHAR * p_menuname); - void toggle_off(); - ATOM get_class() const {return m_class;} - - ~registerclass_scope_delayed() {toggle_off();} -private: - registerclass_scope_delayed(const registerclass_scope_delayed &) {throw pfc::exception_not_implemented();} - const registerclass_scope_delayed & operator=(const registerclass_scope_delayed &) {throw pfc::exception_not_implemented();} - - ATOM m_class; -}; - - - -template -class syncd_storage { -private: - typedef syncd_storage t_self; -public: - syncd_storage() {} - template - syncd_storage(const t_source & p_source) : m_object(p_source) {} - template - void set(t_source const & p_in) { - insync(m_sync); - m_object = p_in; - } - template - void get(t_destination & p_out) const { - insync(m_sync); - p_out = m_object; - } - t_object get() const { - insync(m_sync); - return m_object; - } - template - const t_self & operator=(t_source const & p_source) {set(p_source); return *this;} -private: - mutable critical_section m_sync; - t_object m_object; -}; - -template -class syncd_storage_flagged { -private: - typedef syncd_storage_flagged t_self; -public: - syncd_storage_flagged() : m_changed_flag(false) {} - template - syncd_storage_flagged(const t_source & p_source) : m_changed_flag(false), m_object(p_source) {} - void set_changed(bool p_flag = true) { - insync(m_sync); - m_changed_flag = p_flag; - } - template - void set(t_source const & p_in) { - insync(m_sync); - m_object = p_in; - m_changed_flag = true; - } - bool has_changed() const { - insync(m_sync); - return m_changed_flag; - } - t_object peek() const {insync(m_sync); return m_object;} - template - bool get_if_changed(t_destination & p_out) { - insync(m_sync); - if (m_changed_flag) { - p_out = m_object; - m_changed_flag = false; - return true; - } else { - return false; - } - } - t_object get() { - insync(m_sync); - m_changed_flag = false; - return m_object; - } - template - void get(t_destination & p_out) { - insync(m_sync); - p_out = m_object; - m_changed_flag = false; - } - template - const t_self & operator=(t_source const & p_source) {set(p_source); return *this;} -private: - bool m_changed_flag; - mutable critical_section m_sync; - t_object m_object; -}; - -typedef CGlobalLockScope CGlobalLock;//for compatibility, implementation moved elsewhere - -static bool SetClipboardDataBlock(UINT p_format,const void * p_block,t_size p_block_size) { - bool success = false; - if (OpenClipboard(NULL)) { - EmptyClipboard(); - HANDLE handle = GlobalAlloc(GMEM_MOVEABLE,p_block_size); - if (handle == NULL) { - CloseClipboard(); - throw std::bad_alloc(); - } - {CGlobalLock lock(handle);memcpy(lock.GetPtr(),p_block,p_block_size);} - if (SetClipboardData(p_format,handle) == NULL) { - GlobalFree(handle);//todo? - } else { - success = true; - } - CloseClipboard(); - } - return success; -} - -template -static bool SetClipboardDataBlock(UINT p_format,const t_array & p_array) { - pfc::static_assert(); - return SetClipboardDataBlock(p_format,p_array.get_ptr(),p_array.get_size()); -} - -template -static bool GetClipboardDataBlock(UINT p_format,t_array & p_array) { - pfc::static_assert(); - if (OpenClipboard(NULL)) { - HANDLE handle = GetClipboardData(p_format); - if (handle == NULL) { - CloseClipboard(); - return false; - } - { - CGlobalLock lock(handle); - const t_size size = lock.GetSize(); - try { - p_array.set_size(size); - } catch(...) { - CloseClipboard(); - throw; - } - memcpy(p_array.get_ptr(),lock.GetPtr(),size); - } - CloseClipboard(); - return true; - } else { - return false; - } -} - - -class OleInitializeScope { -public: - OleInitializeScope() { - if (FAILED(OleInitialize(NULL))) throw pfc::exception("OleInitialize() failure"); - } - ~OleInitializeScope() { - OleUninitialize(); - } - -private: - PFC_CLASS_NOT_COPYABLE(OleInitializeScope,OleInitializeScope); -}; - -class CoInitializeScope { -public: - CoInitializeScope() { - if (FAILED(CoInitialize(NULL))) throw pfc::exception("CoInitialize() failed"); - } - ~CoInitializeScope() { - CoUninitialize(); - } - PFC_CLASS_NOT_COPYABLE_EX(CoInitializeScope) -}; - - -unsigned QueryScreenDPI(); - -SIZE QueryScreenDPIEx(); - -static WORD GetOSVersion() { - const DWORD ver = GetVersion(); - return (WORD)HIBYTE(LOWORD(ver)) | ((WORD)LOBYTE(LOWORD(ver)) << 8); -} - -#if _WIN32_WINNT >= 0x501 -#define WS_EX_COMPOSITED_Safe() WS_EX_COMPOSITED -#else -static DWORD WS_EX_COMPOSITED_Safe() { - return (GetOSVersion() < 0x501) ? 0 : 0x02000000L; -} -#endif - - -static t_size GetOptimalWorkerThreadCount() throw() { - DWORD_PTR mask,system; - t_size ret = 0; - GetProcessAffinityMask(GetCurrentProcess(),&mask,&system); - for(t_size n=0;n(this),0,NULL) ) != NULL); - m_thread = thread; - } - bool IsThreadActive() const { - return m_thread != INVALID_HANDLE_VALUE; - } - void WaitTillThreadDone() { - CloseThread(); - } -protected: - virtual void ThreadProc() {} -private: - void CloseThread() { - if (IsThreadActive()) { - WaitForSingleObject(m_thread,INFINITE); - CloseHandle(m_thread); m_thread = INVALID_HANDLE_VALUE; - } - } - - static DWORD CALLBACK g_entry(void* p_instance) { - return reinterpret_cast(p_instance)->entry(); - } - unsigned entry() { - try { - ThreadProc(); - } catch(...) {} - return 0; - } - HANDLE m_thread; - - PFC_CLASS_NOT_COPYABLE_EX(CVerySimpleThread) -}; - -//! IMPORTANT: all classes derived from CSimpleThread must call AbortThread()/WaitTillThreadDone() in their destructors, to avoid object destruction during a virtual function call! -class CSimpleThread : private completion_notify_receiver { -public: - CSimpleThread() : m_thread(INVALID_HANDLE_VALUE) {} - ~CSimpleThread() {AbortThread();} - void StartThread() { - AbortThread(); - m_abort.reset(); - m_ownNotify = create_task(0); - HANDLE thread; - WIN32_OP( (thread = CreateThread(NULL,0,g_entry,reinterpret_cast(this),0,NULL) ) != NULL); - m_thread = thread; - } - void AbortThread() { - m_abort.abort(); - CloseThread(); - } - bool IsThreadActive() const { - return m_thread != INVALID_HANDLE_VALUE; - } - void WaitTillThreadDone() { - CloseThread(); - } -protected: - virtual unsigned ThreadProc(abort_callback & p_abort) {return 0;} - //! Called when the thread has completed normally, with p_code equal to ThreadProc retval. Not called when AbortThread() or WaitTillThreadDone() was used to abort the thread / wait for the thread to finish. - virtual void ThreadDone(unsigned p_code) {}; -private: - void CloseThread() { - if (IsThreadActive()) { - WaitForSingleObject(m_thread,INFINITE); - CloseHandle(m_thread); m_thread = INVALID_HANDLE_VALUE; - } - orphan_all_tasks(); - } - - void on_task_completion(unsigned p_id,unsigned p_status) { - if (IsThreadActive()) { - CloseThread(); - ThreadDone(p_status); - } - } - static DWORD CALLBACK g_entry(void* p_instance) { - return reinterpret_cast(p_instance)->entry(); - } - unsigned entry() { - unsigned code = ~0; - try { - code = ThreadProc(m_abort); - } catch(...) {} - if (!m_abort.is_aborting()) m_ownNotify->on_completion_async(code); - return code; - } - abort_callback_impl m_abort; - HANDLE m_thread; - completion_notify_ptr m_ownNotify; - - PFC_CLASS_NOT_COPYABLE_EX(CSimpleThread); -}; - - - -class EnableWindowScope { -public: - EnableWindowScope(HWND p_window,BOOL p_state) throw() : m_window(p_window) { - m_oldState = IsWindowEnabled(m_window); - EnableWindow(m_window,p_state); - } - ~EnableWindowScope() throw() { - EnableWindow(m_window,m_oldState); - } - -private: - BOOL m_oldState; - HWND m_window; -}; - -bool IsMenuNonEmpty(HMENU menu); - -class SetTextColorScope { -public: - SetTextColorScope(HDC dc, COLORREF col) throw() : m_dc(dc) { - m_oldCol = SetTextColor(dc,col); - } - ~SetTextColorScope() throw() { - SetTextColor(m_dc,m_oldCol); - } - PFC_CLASS_NOT_COPYABLE_EX(SetTextColorScope) -private: - HDC m_dc; - COLORREF m_oldCol; -}; - -class CloseHandleScope { -public: - CloseHandleScope(HANDLE handle) throw() : m_handle(handle) {} - ~CloseHandleScope() throw() {CloseHandle(m_handle);} - HANDLE Detach() throw() {return pfc::replace_t(m_handle,INVALID_HANDLE_VALUE);} - HANDLE Get() const throw() {return m_handle;} - void Close() throw() {CloseHandle(Detach());} - PFC_CLASS_NOT_COPYABLE_EX(CloseHandleScope) -private: - HANDLE m_handle; -}; - -class CModelessDialogEntry { -public: - inline CModelessDialogEntry() : m_wnd() {} - inline CModelessDialogEntry(HWND p_wnd) : m_wnd() {Set(p_wnd);} - inline ~CModelessDialogEntry() {Set(NULL);} - - void Set(HWND p_new) { - static_api_ptr_t api; - if (m_wnd) api->remove(m_wnd); - m_wnd = p_new; - if (m_wnd) api->add(m_wnd); - } -private: - PFC_CLASS_NOT_COPYABLE_EX(CModelessDialogEntry); - HWND m_wnd; -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/window_placement_helper.cpp b/tools/vio2sf/src/foobar/foobar2000/helpers/window_placement_helper.cpp deleted file mode 100644 index 93856a576..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/window_placement_helper.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include "stdafx.h" - -static bool g_is_enabled() -{ - return standard_config_objects::query_remember_window_positions(); -} - -static BOOL CALLBACK __MonitorEnumProc( - HMONITOR hMonitor, // handle to display monitor - HDC hdcMonitor, // handle to monitor DC - LPRECT lprcMonitor, // monitor intersection rectangle - LPARAM dwData // data - ) { - RECT * clip = (RECT*)dwData; - RECT newclip; - if (UnionRect(&newclip,clip,lprcMonitor)) { - *clip = newclip; - } - return TRUE; -} - -static bool test_rect(const RECT * rc) { - RECT clip = {}; - if (EnumDisplayMonitors(NULL,NULL,__MonitorEnumProc,(LPARAM)&clip)) { - const LONG sanitycheck = 4; - const LONG cwidth = clip.right - clip.left; - const LONG cheight = clip.bottom - clip.top; - - const LONG width = rc->right - rc->left; - const LONG height = rc->bottom - rc->top; - - if (width > cwidth * sanitycheck || height > cheight * sanitycheck) return false; - } - - return MonitorFromRect(rc,MONITOR_DEFAULTTONULL) != NULL; -} - - -bool cfg_window_placement::read_from_window(HWND window) -{ - WINDOWPLACEMENT wp = {}; - if (g_is_enabled()) { - wp.length = sizeof(wp); - if (!GetWindowPlacement(window,&wp)) - memset(&wp,0,sizeof(wp)); - /*else - { - if (!IsWindowVisible(window)) wp.showCmd = SW_HIDE; - }*/ - } - m_data = wp; - return m_data.length == sizeof(m_data); -} - -void cfg_window_placement::on_window_creation_silent(HWND window) { - PFC_ASSERT(!m_windows.have_item(window)); - m_windows.add_item(window); -} -bool cfg_window_placement::on_window_creation(HWND window) -{ - bool ret = false; - PFC_ASSERT(!m_windows.have_item(window)); - m_windows.add_item(window); - - if (g_is_enabled()) - { - if (m_data.length==sizeof(m_data) && test_rect(&m_data.rcNormalPosition)) - { - if (SetWindowPlacement(window,&m_data)) - { - ret = true; - } - } - } - - return ret; -} - - -void cfg_window_placement::on_window_destruction(HWND window) -{ - if (m_windows.have_item(window)) - { - read_from_window(window); - m_windows.remove_item(window); - } -} - -void cfg_window_placement::get_data_raw(stream_writer * p_stream,abort_callback & p_abort) { - if (g_is_enabled()) { - { - t_size n, m = m_windows.get_count(); - for(n=0;nwrite_object(&m_data,sizeof(m_data),p_abort); - } - } -} - -void cfg_window_placement::set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - if (p_sizehint == 0) return; - WINDOWPLACEMENT temp; - try { - p_stream->read_object(&temp,sizeof(temp),p_abort); - } catch(exception_io_data) {return;} - if (temp.length == sizeof(temp)) m_data = temp; -} - - -cfg_window_placement::cfg_window_placement(const GUID & p_guid) : cfg_var(p_guid) -{ - memset(&m_data,0,sizeof(m_data)); -} - - -cfg_window_size::cfg_window_size(const GUID & p_guid) : cfg_var(p_guid), m_width(infinite32), m_height(infinite32) {} - -static BOOL SetWindowSize(HWND p_wnd,unsigned p_x,unsigned p_y) -{ - if (p_x != infinite32 && p_y != infinite32) - return SetWindowPos(p_wnd,0,0,0,p_x,p_y,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); - else - return FALSE; -} - -bool cfg_window_size::on_window_creation(HWND p_wnd) -{ - bool ret = false; - PFC_ASSERT(!m_windows.have_item(p_wnd)); - m_windows.add_item(p_wnd); - - if (g_is_enabled()) - { - if (SetWindowSize(p_wnd,m_width,m_height)) ret = true; - } - - return ret; -} - -void cfg_window_size::on_window_destruction(HWND p_wnd) -{ - if (m_windows.have_item(p_wnd)) - { - read_from_window(p_wnd); - m_windows.remove_item(p_wnd); - } -} - -bool cfg_window_size::read_from_window(HWND p_wnd) -{ - if (g_is_enabled()) - { - RECT r; - if (GetWindowRect(p_wnd,&r)) - { - m_width = r.right - r.left; - m_height = r.bottom - r.top; - return true; - } - else - { - m_width = m_height = infinite32; - return false; - } - } - else - { - m_width = m_height = infinite32; - return false; - } -} - -void cfg_window_size::get_data_raw(stream_writer * p_stream,abort_callback & p_abort) { - if (g_is_enabled()) { - { - t_size n, m = m_windows.get_count(); - for(n=0;nwrite_lendian_t(m_width,p_abort); - p_stream->write_lendian_t(m_height,p_abort); - } - } -} - -void cfg_window_size::set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) { - if (p_sizehint == 0) return; - t_uint32 width,height; - try { - p_stream->read_lendian_t(width,p_abort); - p_stream->read_lendian_t(height,p_abort); - } catch(exception_io_data) {return;} - - m_width = width; m_height = height; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/helpers/window_placement_helper.h b/tools/vio2sf/src/foobar/foobar2000/helpers/window_placement_helper.h deleted file mode 100644 index 24cfe20dd..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/helpers/window_placement_helper.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _WINDOW_PLACEMENT_HELPER_H_ -#define _WINDOW_PLACEMENT_HELPER_H_ - -class cfg_window_placement : public cfg_var -{ -public: - bool on_window_creation(HWND window);//returns true if window position has been changed, false if not - void on_window_creation_silent(HWND window); - void on_window_destruction(HWND window); - bool read_from_window(HWND window); - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort); - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort); - cfg_window_placement(const GUID & p_guid); -private: - pfc::list_hybrid_t m_windows; - WINDOWPLACEMENT m_data; -}; - -class cfg_window_size : public cfg_var -{ -public: - bool on_window_creation(HWND window);//returns true if window position has been changed, false if not - void on_window_destruction(HWND window); - bool read_from_window(HWND window); - void get_data_raw(stream_writer * p_stream,abort_callback & p_abort); - void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort); - cfg_window_size(const GUID & p_guid); -private: - pfc::list_hybrid_t m_windows; - t_uint32 m_width,m_height; -}; - - -#endif //_WINDOW_PLACEMENT_HELPER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/shared/audio_math.h b/tools/vio2sf/src/foobar/foobar2000/shared/audio_math.h deleted file mode 100644 index f58c171de..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/shared/audio_math.h +++ /dev/null @@ -1,78 +0,0 @@ -#include - -#ifdef _M_X64 -#include -#include -#endif - - -#define audio_sample_size 32 - -#if audio_sample_size == 32 -typedef float audio_sample; -#define audio_sample_asm dword -#elif audio_sample_size == 64 -typedef double audio_sample; -#define audio_sample_asm qword -#else -#error wrong audio_sample_size -#endif - -#define audio_sample_bytes (audio_sample_size/8) - -namespace audio_math -{ - //! p_source/p_output can point to same buffer - void SHARED_EXPORT scale(const audio_sample * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale); - void SHARED_EXPORT convert_to_int16(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale); - void SHARED_EXPORT convert_to_int32(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale); - audio_sample SHARED_EXPORT convert_to_int16_calculate_peak(const audio_sample * p_source,t_size p_count,t_int16 * p_output,audio_sample p_scale); - void SHARED_EXPORT convert_from_int16(const t_int16 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale); - void SHARED_EXPORT convert_from_int32(const t_int32 * p_source,t_size p_count,audio_sample * p_output,audio_sample p_scale); - audio_sample SHARED_EXPORT convert_to_int32_calculate_peak(const audio_sample * p_source,t_size p_count,t_int32 * p_output,audio_sample p_scale); - audio_sample SHARED_EXPORT calculate_peak(const audio_sample * p_source,t_size p_count); - void SHARED_EXPORT remove_denormals(audio_sample * p_buffer,t_size p_count); - void SHARED_EXPORT add_offset(audio_sample * p_buffer,audio_sample p_delta,t_size p_count); - - - inline t_uint64 time_to_samples(double p_time,t_uint32 p_sample_rate) { - return (t_uint64)floor((double)p_sample_rate * p_time + 0.5); - } - - inline double samples_to_time(t_uint64 p_samples,t_uint32 p_sample_rate) { - PFC_ASSERT(p_sample_rate > 0); - return (double) p_samples / (double) p_sample_rate; - } - - -#ifdef _M_IX86 - inline static t_int64 rint64(audio_sample val) { - t_int64 rv; - _asm { - fld val; - fistp rv; - } - return rv; - } - inline static t_int32 rint32(audio_sample val) { - t_int32 rv; - _asm { - fld val; - fistp rv; - } - return rv; - } -#elif defined(_M_X64) - inline static t_int64 rint64(audio_sample val) {return (t_int64)floor(val+0.5);} - static inline t_int32 rint32(float p_val) { - return (t_int32)_mm_cvtss_si32(_mm_load_ss(&p_val)); - } -#else - inline static t_int64 rint64(audio_sample val) {return (t_int64)floor(val+0.5);} - inline static t_int32 rint32(audio_sample val) {return (t_int32)floor(val+0.5);} -#endif - - - inline audio_sample gain_to_scale(double p_gain) {return (audio_sample) pow(10.0,p_gain / 20.0);} - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/foobar2000/shared/filedialogs.h b/tools/vio2sf/src/foobar/foobar2000/shared/filedialogs.h deleted file mode 100644 index 8d2169a17..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/shared/filedialogs.h +++ /dev/null @@ -1,7 +0,0 @@ -class uGetOpenFileNameMultiResult_impl : public uGetOpenFileNameMultiResult { - pfc::list_t m_data; -public: - void AddItem(pfc::stringp param) {m_data.add_item(param);} - t_size get_count() const {return m_data.get_count();} - void get_item_ex(const char * & out,t_size n) const {out = m_data[n].ptr();} -}; diff --git a/tools/vio2sf/src/foobar/foobar2000/shared/shared.h b/tools/vio2sf/src/foobar/foobar2000/shared/shared.h deleted file mode 100644 index b32ca1ffe..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/shared/shared.h +++ /dev/null @@ -1,788 +0,0 @@ -#ifndef _SHARED_DLL__SHARED_H_ -#define _SHARED_DLL__SHARED_H_ - -#include "../../pfc/pfc.h" - -#ifndef WIN32 -#error N/A -#endif - -#ifndef STRICT -#define STRICT -#endif - -#include -#include -#include - -#ifndef NOTHROW -#ifdef _MSC_VER -#define NOTHROW __declspec(nothrow) -#else -#define NOTHROW -#endif -#endif - -#define SHARED_API /*NOTHROW*/ __stdcall - -#ifndef SHARED_EXPORTS -#define SHARED_EXPORT __declspec(dllimport) SHARED_API -#else -#define SHARED_EXPORT __declspec(dllexport) SHARED_API -#endif - -extern "C" { - -//SHARED_EXPORT BOOL IsUnicode(); -#ifdef UNICODE -#define IsUnicode() 1 -#else -#define IsUnicode() 0 -#endif - -LRESULT SHARED_EXPORT uSendMessageText(HWND wnd,UINT msg,WPARAM wp,const char * text); -LRESULT SHARED_EXPORT uSendDlgItemMessageText(HWND wnd,UINT id,UINT msg,WPARAM wp,const char * text); -BOOL SHARED_EXPORT uGetWindowText(HWND wnd,pfc::string_base & out); -BOOL SHARED_EXPORT uSetWindowText(HWND wnd,const char * p_text); -BOOL SHARED_EXPORT uSetWindowTextEx(HWND wnd,const char * p_text,unsigned p_text_length); -BOOL SHARED_EXPORT uGetDlgItemText(HWND wnd,UINT id,pfc::string_base & out); -BOOL SHARED_EXPORT uSetDlgItemText(HWND wnd,UINT id,const char * p_text); -BOOL SHARED_EXPORT uSetDlgItemTextEx(HWND wnd,UINT id,const char * p_text,unsigned p_text_length); -BOOL SHARED_EXPORT uBrowseForFolder(HWND parent,const char * title,pfc::string_base & out); -BOOL SHARED_EXPORT uBrowseForFolderWithFile(HWND parent,const char * title,pfc::string_base & out,const char * p_file_to_find); -int SHARED_EXPORT uMessageBox(HWND wnd,const char * text,const char * caption,UINT type); -void SHARED_EXPORT uOutputDebugString(const char * msg); -BOOL SHARED_EXPORT uAppendMenu(HMENU menu,UINT flags,UINT_PTR id,const char * content); -BOOL SHARED_EXPORT uInsertMenu(HMENU menu,UINT position,UINT flags,UINT_PTR id,const char * content); -int SHARED_EXPORT uStringCompare(const char * elem1, const char * elem2); -int SHARED_EXPORT uCharCompare(t_uint32 p_char1,t_uint32 p_char2); -int SHARED_EXPORT uStringCompare_ConvertNumbers(const char * elem1,const char * elem2); -HINSTANCE SHARED_EXPORT uLoadLibrary(const char * name); -HANDLE SHARED_EXPORT uCreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes,BOOL bManualReset,BOOL bInitialState, const char * lpName); -DWORD SHARED_EXPORT uGetModuleFileName(HMODULE hMod,pfc::string_base & out); -BOOL SHARED_EXPORT uSetClipboardString(const char * ptr); -BOOL SHARED_EXPORT uGetClipboardString(pfc::string_base & out); -BOOL SHARED_EXPORT uSetClipboardRawData(UINT format,const void * ptr,t_size size);//does not empty the clipboard -BOOL SHARED_EXPORT uGetClassName(HWND wnd,pfc::string_base & out); -t_size SHARED_EXPORT uCharLength(const char * src); -BOOL SHARED_EXPORT uDragQueryFile(HDROP hDrop,UINT idx,pfc::string_base & out); -UINT SHARED_EXPORT uDragQueryFileCount(HDROP hDrop); -BOOL SHARED_EXPORT uGetTextExtentPoint32(HDC dc,const char * text,UINT cb,LPSIZE size);//note, cb is number of bytes, not actual unicode characters in the string (read: plain strlen() will do) -BOOL SHARED_EXPORT uExtTextOut(HDC dc,int x,int y,UINT flags,const RECT * rect,const char * text,UINT cb,const int * lpdx); -BOOL SHARED_EXPORT uTextOutColors(HDC dc,const char * src,UINT len,int x,int y,const RECT * clip,BOOL is_selected,DWORD default_color); -BOOL SHARED_EXPORT uTextOutColorsTabbed(HDC dc,const char * src,UINT src_len,const RECT * item,int border,const RECT * clip,BOOL selected,DWORD default_color,BOOL use_columns); -UINT SHARED_EXPORT uGetTextHeight(HDC dc); -UINT SHARED_EXPORT uGetFontHeight(HFONT font); -BOOL SHARED_EXPORT uChooseColor(DWORD * p_color,HWND parent,DWORD * p_custom_colors); -HCURSOR SHARED_EXPORT uLoadCursor(HINSTANCE hIns,const char * name); -HICON SHARED_EXPORT uLoadIcon(HINSTANCE hIns,const char * name); -HMENU SHARED_EXPORT uLoadMenu(HINSTANCE hIns,const char * name); -BOOL SHARED_EXPORT uGetEnvironmentVariable(const char * name,pfc::string_base & out); -HMODULE SHARED_EXPORT uGetModuleHandle(const char * name); -UINT SHARED_EXPORT uRegisterWindowMessage(const char * name); -BOOL SHARED_EXPORT uMoveFile(const char * src,const char * dst); -BOOL SHARED_EXPORT uDeleteFile(const char * fn); -DWORD SHARED_EXPORT uGetFileAttributes(const char * fn); -BOOL SHARED_EXPORT uFileExists(const char * fn); -BOOL SHARED_EXPORT uRemoveDirectory(const char * fn); -HANDLE SHARED_EXPORT uCreateFile(const char * p_path,DWORD p_access,DWORD p_sharemode,LPSECURITY_ATTRIBUTES p_security_attributes,DWORD p_createmode,DWORD p_flags,HANDLE p_template); -HANDLE SHARED_EXPORT uCreateFileMapping(HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,const char * lpName); -BOOL SHARED_EXPORT uCreateDirectory(const char * fn,LPSECURITY_ATTRIBUTES blah); -HANDLE SHARED_EXPORT uCreateMutex(LPSECURITY_ATTRIBUTES blah,BOOL bInitialOwner,const char * name); -BOOL SHARED_EXPORT uGetLongPathName(const char * name,pfc::string_base & out);//may just fail to work on old windows versions, present on win98/win2k+ -BOOL SHARED_EXPORT uGetFullPathName(const char * name,pfc::string_base & out); -BOOL SHARED_EXPORT uSearchPath(const char * path, const char * filename, const char * extension, pfc::string_base & p_out); -BOOL SHARED_EXPORT uFixPathCaps(const char * path,pfc::string_base & p_out); -void SHARED_EXPORT uGetCommandLine(pfc::string_base & out); -BOOL SHARED_EXPORT uGetTempPath(pfc::string_base & out); -BOOL SHARED_EXPORT uGetTempFileName(const char * path_name,const char * prefix,UINT unique,pfc::string_base & out); -BOOL SHARED_EXPORT uGetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::string_base & p_filename,BOOL b_save); -//note: uGetOpenFileName extension mask uses | as separator, not null -HANDLE SHARED_EXPORT uLoadImage(HINSTANCE hIns,const char * name,UINT type,int x,int y,UINT flags); -UINT SHARED_EXPORT uRegisterClipboardFormat(const char * name); -BOOL SHARED_EXPORT uGetClipboardFormatName(UINT format,pfc::string_base & out); -BOOL SHARED_EXPORT uFormatSystemErrorMessage(pfc::string_base & p_out,DWORD p_code); - -HANDLE SHARED_EXPORT uSortStringCreate(const char * src); -int SHARED_EXPORT uSortStringCompare(HANDLE string1,HANDLE string2); -int SHARED_EXPORT uSortStringCompareEx(HANDLE string1,HANDLE string2,DWORD flags);//flags - see win32 CompareString -int SHARED_EXPORT uSortPathCompare(HANDLE string1,HANDLE string2); -void SHARED_EXPORT uSortStringFree(HANDLE string); - - -int SHARED_EXPORT uCompareString(DWORD flags,const char * str1,unsigned len1,const char * str2,unsigned len2); - -class NOVTABLE uGetOpenFileNameMultiResult : public pfc::list_base_const_t -{ -public: - inline t_size GetCount() {return get_count();} - inline const char * GetFileName(t_size index) {return get_item(index);} - virtual ~uGetOpenFileNameMultiResult() {} -}; - -typedef uGetOpenFileNameMultiResult * puGetOpenFileNameMultiResult; - -puGetOpenFileNameMultiResult SHARED_EXPORT uGetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory); - -class NOVTABLE uFindFile -{ -protected: - uFindFile() {} -public: - virtual BOOL FindNext()=0; - virtual const char * GetFileName()=0; - virtual t_uint64 GetFileSize()=0; - virtual DWORD GetAttributes()=0; - virtual FILETIME GetCreationTime()=0; - virtual FILETIME GetLastAccessTime()=0; - virtual FILETIME GetLastWriteTime()=0; - virtual ~uFindFile() {}; - inline bool IsDirectory() {return (GetAttributes() & FILE_ATTRIBUTE_DIRECTORY) ? true : false;} -}; - -typedef uFindFile * puFindFile; - -puFindFile SHARED_EXPORT uFindFirstFile(const char * path); - -HINSTANCE SHARED_EXPORT uShellExecute(HWND wnd,const char * oper,const char * file,const char * params,const char * dir,int cmd); -HWND SHARED_EXPORT uCreateStatusWindow(LONG style,const char * text,HWND parent,UINT id); - -BOOL SHARED_EXPORT uShellNotifyIcon(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip); -BOOL SHARED_EXPORT uShellNotifyIconEx(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip,const char * balloon_title,const char * balloon_msg); - -HWND SHARED_EXPORT uCreateWindowEx(DWORD dwExStyle,const char * lpClassName,const char * lpWindowName,DWORD dwStyle,int x,int y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam); - -BOOL SHARED_EXPORT uGetSystemDirectory(pfc::string_base & out); -BOOL SHARED_EXPORT uGetWindowsDirectory(pfc::string_base & out); -BOOL SHARED_EXPORT uSetCurrentDirectory(const char * path); -BOOL SHARED_EXPORT uGetCurrentDirectory(pfc::string_base & out); -BOOL SHARED_EXPORT uExpandEnvironmentStrings(const char * src,pfc::string_base & out); -BOOL SHARED_EXPORT uGetUserName(pfc::string_base & out); -BOOL SHARED_EXPORT uGetShortPathName(const char * src,pfc::string_base & out); - -HSZ SHARED_EXPORT uDdeCreateStringHandle(DWORD ins,const char * src); -BOOL SHARED_EXPORT uDdeQueryString(DWORD ins,HSZ hsz,pfc::string_base & out); -UINT SHARED_EXPORT uDdeInitialize(LPDWORD pidInst,PFNCALLBACK pfnCallback,DWORD afCmd,DWORD ulRes); -BOOL SHARED_EXPORT uDdeAccessData_Text(HDDEDATA data,pfc::string_base & out); - -HIMAGELIST SHARED_EXPORT uImageList_LoadImage(HINSTANCE hi, const char * lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags); - -#define uDdeFreeStringHandle DdeFreeStringHandle -#define uDdeCmpStringHandles DdeCmpStringHandles -#define uDdeKeepStringHandle DdeKeepStringHandle -#define uDdeUninitialize DdeUninitialize -#define uDdeNameService DdeNameService -#define uDdeFreeDataHandle DdeFreeDataHandle - - -typedef TVINSERTSTRUCTA uTVINSERTSTRUCT; - -HTREEITEM SHARED_EXPORT uTreeView_InsertItem(HWND wnd,const uTVINSERTSTRUCT * param); -LPARAM SHARED_EXPORT uTreeView_GetUserData(HWND wnd,HTREEITEM item); -bool SHARED_EXPORT uTreeView_GetText(HWND wnd,HTREEITEM item,pfc::string_base & out); - -#define uSetWindowsHookEx SetWindowsHookEx -#define uUnhookWindowsHookEx UnhookWindowsHookEx -#define uCallNextHookEx CallNextHookEx - - -/* usage: - - const char * src = "something"; - - void * temp = malloc(uOSStringEstimateSize(src)); - uOSStringConvert(src,temp); - //now temp contains OS-friendly (TCHAR) version of src -*/ - -typedef TCITEMA uTCITEM; -int SHARED_EXPORT uTabCtrl_InsertItem(HWND wnd,t_size idx,const uTCITEM * item); -int SHARED_EXPORT uTabCtrl_SetItem(HWND wnd,t_size idx,const uTCITEM * item); - -int SHARED_EXPORT uGetKeyNameText(LONG lparam,pfc::string_base & out); - -void SHARED_EXPORT uFixAmpersandChars(const char * src,pfc::string_base & out);//for systray -void SHARED_EXPORT uFixAmpersandChars_v2(const char * src,pfc::string_base & out);//for other controls - -//deprecated -t_size SHARED_EXPORT uPrintCrashInfo(LPEXCEPTION_POINTERS param,const char * extrainfo,char * out); -enum {uPrintCrashInfo_max_length = 1024}; - -void SHARED_EXPORT uPrintCrashInfo_Init(const char * name);//called only by exe on startup -void SHARED_EXPORT uPrintCrashInfo_AddInfo(const char * p_info);//called only by exe on startup -void SHARED_EXPORT uPrintCrashInfo_SetDumpPath(const char * name);//called only by exe on startup - - -void SHARED_EXPORT uDumpCrashInfo(LPEXCEPTION_POINTERS param); - -BOOL SHARED_EXPORT uListBox_GetText(HWND listbox,UINT index,pfc::string_base & out); - -void SHARED_EXPORT uPrintfV(pfc::string_base & out,const char * fmt,va_list arglist); -static inline void uPrintf(pfc::string_base & out,const char * fmt,...) {va_list list;va_start(list,fmt);uPrintfV(out,fmt,list);va_end(list);} - - -class NOVTABLE uResource -{ -public: - virtual const void * GetPointer() = 0; - virtual unsigned GetSize() = 0; - virtual ~uResource() {} -}; - -typedef uResource* puResource; - -puResource SHARED_EXPORT uLoadResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); -puResource SHARED_EXPORT LoadResourceEx(HMODULE hMod,const TCHAR * name,const TCHAR * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); -HRSRC SHARED_EXPORT uFindResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); - -BOOL SHARED_EXPORT uLoadString(HINSTANCE ins,UINT id,pfc::string_base & out); - -UINT SHARED_EXPORT uCharLower(UINT c); -UINT SHARED_EXPORT uCharUpper(UINT c); - -BOOL SHARED_EXPORT uGetMenuString(HMENU menu,UINT id,pfc::string_base & out,UINT flag); -BOOL SHARED_EXPORT uModifyMenu(HMENU menu,UINT id,UINT flags,UINT newitem,const char * data); -UINT SHARED_EXPORT uGetMenuItemType(HMENU menu,UINT position); - - -}//extern "C" - -inline char * uCharNext(char * src) {return src+uCharLength(src);} -inline const char * uCharNext(const char * src) {return src+uCharLength(src);} - - -class string_utf8_from_window -{ -public: - string_utf8_from_window(HWND wnd) - { - uGetWindowText(wnd,m_data); - } - string_utf8_from_window(HWND wnd,UINT id) - { - uGetDlgItemText(wnd,id,m_data); - } - inline operator const char * () const {return m_data.get_ptr();} - inline t_size length() const {return m_data.length();} - inline bool is_empty() const {return length() == 0;} - inline const char * get_ptr() const {return m_data.get_ptr();} -private: - pfc::string8 m_data; -}; - -static pfc::string uGetWindowText(HWND wnd) { - pfc::string8 temp; - if (!uGetWindowText(wnd,temp)) return ""; - return temp.toString(); -} -static pfc::string uGetDlgItemText(HWND wnd,UINT id) { - pfc::string8 temp; - if (!uGetDlgItemText(wnd,id,temp)) return ""; - return temp.toString(); -} - -#define uMAKEINTRESOURCE(x) ((const char*)LOWORD(x)) - -#ifdef _DEBUG -class critical_section { -private: - CRITICAL_SECTION sec; - int count; -public: - int enter() {EnterCriticalSection(&sec);return ++count;} - int leave() {int rv = --count;LeaveCriticalSection(&sec);return rv;} - int get_lock_count() {return count;} - int get_lock_count_check() {enter();return leave();} - inline void assert_locked() {assert(get_lock_count_check()>0);} - inline void assert_not_locked() {assert(get_lock_count_check()==0);} - critical_section() {InitializeCriticalSection(&sec);count=0;} - ~critical_section() {DeleteCriticalSection(&sec);} -private: - critical_section(const critical_section&) {throw pfc::exception_not_implemented();} - const critical_section & operator=(const critical_section &) {throw pfc::exception_not_implemented();} -}; -#else -class critical_section { -private: - CRITICAL_SECTION sec; -public: - void enter() throw() {EnterCriticalSection(&sec);} - void leave() throw() {LeaveCriticalSection(&sec);} - critical_section() {InitializeCriticalSection(&sec);} - ~critical_section() {DeleteCriticalSection(&sec);} -private: - critical_section(const critical_section&) {throw pfc::exception_not_implemented();} - const critical_section & operator=(const critical_section &) {throw pfc::exception_not_implemented();} -}; -#endif -class c_insync -{ -private: - critical_section & m_section; -public: - c_insync(critical_section * p_section) throw() : m_section(*p_section) {m_section.enter();} - c_insync(critical_section & p_section) throw() : m_section(p_section) {m_section.enter();} - ~c_insync() throw() {m_section.leave();} -}; - -#define insync(X) c_insync blah____sync(X) - - -class critical_section2 //smarter version, has try_enter() -{ -private: - HANDLE hMutex; - int count; -public: - int enter() {return enter_timeout(INFINITE);} - int leave() {int rv = --count;ReleaseMutex(hMutex);return rv;} - int get_lock_count() {return count;} - int get_lock_count_check() - { - int val = try_enter(); - if (val>0) val = leave(); - return val; - } - int enter_timeout(DWORD t) {return WaitForSingleObject(hMutex,t)==WAIT_OBJECT_0 ? ++count : 0;} - int try_enter() {return enter_timeout(0);} - int check_count() {enter();return leave();} - critical_section2() - { - hMutex = uCreateMutex(0,0,0); - count=0; - } - ~critical_section2() {CloseHandle(hMutex);} - - inline void assert_locked() {assert(get_lock_count_check()>0);} - inline void assert_not_locked() {assert(get_lock_count_check()==0);} - -}; - -class c_insync2 -{ -private: - critical_section2 * ptr; -public: - c_insync2(critical_section2 * p) {ptr=p;ptr->enter();} - c_insync2(critical_section2 & p) {ptr=&p;ptr->enter();} - ~c_insync2() {ptr->leave();} -}; - -#define insync2(X) c_insync2 blah____sync2(X) - - -//other - -#define uIsDialogMessage IsDialogMessage -#define uGetMessage GetMessage -#define uPeekMessage PeekMessage -#define uDispatchMessage DispatchMessage - -#define uCallWindowProc CallWindowProc -#define uDefWindowProc DefWindowProc -#define uGetWindowLong GetWindowLong -#define uSetWindowLong SetWindowLong - -#define uEndDialog EndDialog -#define uDestroyWindow DestroyWindow -#define uGetDlgItem GetDlgItem -#define uEnableWindow EnableWindow -#define uGetDlgItemInt GetDlgItemInt -#define uSetDlgItemInt SetDlgItemInt - -#define _uHookWindowProc(WND,PROC) ((WNDPROC)SetWindowLongPtr(WND,GWLP_WNDPROC,(LONG_PTR)(PROC))) -static WNDPROC uHookWindowProc(HWND p_wnd,WNDPROC p_proc) {return _uHookWindowProc(p_wnd,p_proc);} - -#define uSendMessage SendMessage -#define uSendDlgItemMessage SendDlgItemMessage -#define uSendMessageTimeout SendMessageTimeout -#define uSendNotifyMessage SendNotifyMessage -#define uSendMessageCallback SendMessageCallback -#define uPostMessage PostMessage -#define uPostThreadMessage PostThreadMessage - - -class uStringPrintf -{ -public: - inline explicit uStringPrintf(const char * fmt,...) - { - va_list list; - va_start(list,fmt); - uPrintfV(m_data,fmt,list); - va_end(list); - } - inline operator const char * () const {return m_data.get_ptr();} - inline t_size length() const {return m_data.length();} - inline bool is_empty() const {return length() == 0;} - inline const char * get_ptr() const {return m_data.get_ptr();} - const char * toString() const {return get_ptr();} -private: - pfc::string8_fastalloc m_data; -}; -#pragma deprecated(uStringPrintf, uPrintf, uPrintfV) - -inline LRESULT uButton_SetCheck(HWND wnd,UINT id,bool state) {return uSendDlgItemMessage(wnd,id,BM_SETCHECK,state ? BST_CHECKED : BST_UNCHECKED,0); } -inline bool uButton_GetCheck(HWND wnd,UINT id) {return uSendDlgItemMessage(wnd,id,BM_GETCHECK,0,0) == BST_CHECKED;} - -class uCallStackTracker -{ - t_size param; -public: - explicit SHARED_EXPORT uCallStackTracker(const char * name); - SHARED_EXPORT ~uCallStackTracker(); -}; - -extern "C" -{ - LPCSTR SHARED_EXPORT uGetCallStackPath(); -} - -namespace pfc { - class formatBugCheck : public string_formatter { - public: - formatBugCheck(const char * msg) { - *this << msg; - const char * path = uGetCallStackPath(); - if (*path) { - *this << " (at: " << path << ")"; - } - } - }; - class exception_bug_check_v2 : public exception_bug_check { - public: - exception_bug_check_v2(const char * msg = exception_bug_check::g_what()) : exception_bug_check(formatBugCheck(msg)) { - PFC_ASSERT(!"exception_bug_check_v2 triggered"); - } - }; -} - -#if 1 -#define TRACK_CALL(X) uCallStackTracker TRACKER__##X(#X) -#define TRACK_CALL_TEXT(X) uCallStackTracker TRACKER__BLAH(X) -#define TRACK_CODE(description,code) {uCallStackTracker __call_tracker(description); code;} -#else -#define TRACK_CALL(X) -#define TRACK_CALL_TEXT(X) -#define TRACK_CODE(description,code) {code;} -#endif - -extern "C" { -int SHARED_EXPORT stricmp_utf8(const char * p1,const char * p2) throw(); -int SHARED_EXPORT stricmp_utf8_ex(const char * p1,t_size len1,const char * p2,t_size len2) throw(); -int SHARED_EXPORT stricmp_utf8_stringtoblock(const char * p1,const char * p2,t_size p2_bytes) throw(); -int SHARED_EXPORT stricmp_utf8_partial(const char * p1,const char * p2,t_size num = ~0) throw(); -int SHARED_EXPORT stricmp_utf8_max(const char * p1,const char * p2,t_size p1_bytes) throw(); -t_size SHARED_EXPORT uReplaceStringAdd(pfc::string_base & out,const char * src,t_size src_len,const char * s1,t_size len1,const char * s2,t_size len2,bool casesens); -t_size SHARED_EXPORT uReplaceCharAdd(pfc::string_base & out,const char * src,t_size src_len,unsigned c1,unsigned c2,bool casesens); -//all lengths in uReplaceString functions are optional, set to -1 if parameters is a simple null-terminated string -void SHARED_EXPORT uAddStringLower(pfc::string_base & out,const char * src,t_size len = ~0); -void SHARED_EXPORT uAddStringUpper(pfc::string_base & out,const char * src,t_size len = ~0); -} - -class comparator_stricmp_utf8 { -public: - static int compare(const char * p_string1,const char * p_string2) throw() {return stricmp_utf8(p_string1,p_string2);} -}; - -inline void uStringLower(pfc::string_base & out,const char * src,t_size len = ~0) {out.reset();uAddStringLower(out,src,len);} -inline void uStringUpper(pfc::string_base & out,const char * src,t_size len = ~0) {out.reset();uAddStringUpper(out,src,len);} - -inline t_size uReplaceString(pfc::string_base & out,const char * src,t_size src_len,const char * s1,t_size len1,const char * s2,t_size len2,bool casesens) -{ - out.reset(); - return uReplaceStringAdd(out,src,src_len,s1,len1,s2,len2,casesens); -} - -inline t_size uReplaceChar(pfc::string_base & out,const char * src,t_size src_len,unsigned c1,unsigned c2,bool casesens) -{ - out.reset(); - return uReplaceCharAdd(out,src,src_len,c1,c2,casesens); -} - -class string_lower -{ -public: - explicit string_lower(const char * ptr,t_size p_count = ~0) {uAddStringLower(m_data,ptr,p_count);} - inline operator const char * () const {return m_data.get_ptr();} - inline t_size length() const {return m_data.length();} - inline bool is_empty() const {return length() == 0;} - inline const char * get_ptr() const {return m_data.get_ptr();} -private: - pfc::string8 m_data; -}; - -class string_upper -{ -public: - explicit string_upper(const char * ptr,t_size p_count = ~0) {uAddStringUpper(m_data,ptr,p_count);} - inline operator const char * () const {return m_data.get_ptr();} - inline t_size length() const {return m_data.length();} - inline bool is_empty() const {return length() == 0;} - inline const char * get_ptr() const {return m_data.get_ptr();} -private: - pfc::string8 m_data; -}; - - -inline BOOL uGetLongPathNameEx(const char * name,pfc::string_base & out) -{ - if (uGetLongPathName(name,out)) return TRUE; - return uGetFullPathName(name,out); -} - -struct t_font_description -{ - enum - { - m_facename_length = LF_FACESIZE*2, - m_height_dpi = 480, - }; - - t_uint32 m_height; - t_uint32 m_weight; - t_uint8 m_italic; - t_uint8 m_charset; - char m_facename[m_facename_length]; - - HFONT SHARED_EXPORT create() const; - bool SHARED_EXPORT popup_dialog(HWND p_parent); - void SHARED_EXPORT from_font(HFONT p_font); - static t_font_description SHARED_EXPORT g_from_font(HFONT p_font); - - template void to_stream(t_stream p_stream,t_abort & p_abort) const; - template void from_stream(t_stream p_stream,t_abort & p_abort); -}; - -template void t_font_description::to_stream(t_stream p_stream,t_abort & p_abort) const { - p_stream->write_lendian_t(m_height,p_abort); - p_stream->write_lendian_t(m_weight,p_abort); - p_stream->write_lendian_t(m_italic,p_abort); - p_stream->write_lendian_t(m_charset,p_abort); - p_stream->write_string(m_facename,tabsize(m_facename),p_abort); -} - -template void t_font_description::from_stream(t_stream p_stream,t_abort & p_abort) { - p_stream->read_lendian_t(m_height,p_abort); - p_stream->read_lendian_t(m_weight,p_abort); - p_stream->read_lendian_t(m_italic,p_abort); - p_stream->read_lendian_t(m_charset,p_abort); - pfc::string8 temp; - p_stream->read_string(temp,p_abort); - strncpy_s(m_facename,temp,tabsize(m_facename)); -} - - -struct t_modal_dialog_entry -{ - HWND m_wnd_to_poke; - bool m_in_use; -}; - -extern "C" { - void SHARED_EXPORT ModalDialog_Switch(t_modal_dialog_entry & p_entry); - void SHARED_EXPORT ModalDialog_PokeExisting(); - bool SHARED_EXPORT ModalDialog_CanCreateNew(); - - HWND SHARED_EXPORT FindOwningPopup(HWND p_wnd); - void SHARED_EXPORT PokeWindow(HWND p_wnd); -}; - -//! The purpose of modal_dialog_scope is to help to avoid the modal dialog recursion problem. Current toplevel modal dialog handle is stored globally, so when creation of a new modal dialog is blocked, it can be activated to indicate the reason for the task being blocked. -class modal_dialog_scope { -public: - //! This constructor initializes the modal dialog scope with specified dialog handle. - inline modal_dialog_scope(HWND p_wnd) throw() : m_initialized(false) {initialize(p_wnd);} - //! This constructor leaves the scope uninitialized (you can call initialize() later with your window handle). - inline modal_dialog_scope() throw() : m_initialized(false) {} - inline ~modal_dialog_scope() throw() {deinitialize();} - - //! Returns whether creation of a new modal dialog is allowed (false when there's another one active).\n - //! NOTE: when calling context is already inside a modal dialog that you own, you should not be checking this before creating a new modal dialog. - inline static bool can_create() throw(){return ModalDialog_CanCreateNew();} - //! Activates the top-level modal dialog existing, if one exists. - inline static void poke_existing() throw() {ModalDialog_PokeExisting();} - - //! Initializes the scope with specified window handle. - void initialize(HWND p_wnd) throw() - { - if (!m_initialized) - { - m_initialized = true; - m_entry.m_in_use = true; - m_entry.m_wnd_to_poke = p_wnd; - ModalDialog_Switch(m_entry); - } - } - - void deinitialize() throw() - { - if (m_initialized) - { - ModalDialog_Switch(m_entry); - m_initialized = false; - } - } - - - -private: - modal_dialog_scope(const modal_dialog_scope & p_scope) {assert(0);} - const modal_dialog_scope & operator=(const modal_dialog_scope &) {assert(0); return *this;} - - t_modal_dialog_entry m_entry; - - bool m_initialized; -}; - -class format_win32_error { -public: - format_win32_error(DWORD p_code) { - if (p_code == 0) m_buffer = "Undefined error"; - else if (!uFormatSystemErrorMessage(m_buffer,p_code)) m_buffer << "Unknown error code (" << (unsigned)p_code << ")"; - } - - const char * get_ptr() const {return m_buffer.get_ptr();} - operator const char*() const {return m_buffer.get_ptr();} -private: - pfc::string8 m_buffer; -}; - -struct exception_win32 : public std::exception { - exception_win32(DWORD p_code) : std::exception(format_win32_error(p_code)), m_code(p_code) {} - DWORD get_code() const {return m_code;} -private: - DWORD m_code; -}; - -class uDebugLog : public pfc::string_formatter { -public: - ~uDebugLog() {*this << "\n"; uOutputDebugString(get_ptr());} -}; - -static void uAddWindowStyle(HWND p_wnd,LONG p_style) { - SetWindowLong(p_wnd,GWL_STYLE, GetWindowLong(p_wnd,GWL_STYLE) | p_style); -} - -static void uRemoveWindowStyle(HWND p_wnd,LONG p_style) { - SetWindowLong(p_wnd,GWL_STYLE, GetWindowLong(p_wnd,GWL_STYLE) & ~p_style); -} - -static void uAddWindowExStyle(HWND p_wnd,LONG p_style) { - SetWindowLong(p_wnd,GWL_EXSTYLE, GetWindowLong(p_wnd,GWL_EXSTYLE) | p_style); -} - -static void uRemoveWindowExStyle(HWND p_wnd,LONG p_style) { - SetWindowLong(p_wnd,GWL_EXSTYLE, GetWindowLong(p_wnd,GWL_EXSTYLE) & ~p_style); -} - -static unsigned MapDialogWidth(HWND p_dialog,unsigned p_value) { - RECT temp; - temp.left = 0; temp.right = p_value; temp.top = temp.bottom = 0; - if (!MapDialogRect(p_dialog,&temp)) return 0; - return temp.right; -} - -static bool IsKeyPressed(unsigned vk) { - return (GetKeyState(vk) & 0x8000) ? true : false; -} - -//! Returns current modifier keys pressed, using win32 MOD_* flags. -static unsigned GetHotkeyModifierFlags() { - unsigned ret = 0; - if (IsKeyPressed(VK_CONTROL)) ret |= MOD_CONTROL; - if (IsKeyPressed(VK_SHIFT)) ret |= MOD_SHIFT; - if (IsKeyPressed(VK_MENU)) ret |= MOD_ALT; - if (IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN)) ret |= MOD_WIN; - return ret; -} - -class CClipboardOpenScope { -public: - CClipboardOpenScope() : m_open(false) {} - ~CClipboardOpenScope() {Close();} - bool Open(HWND p_owner) { - Close(); - if (OpenClipboard(p_owner)) { - m_open = true; - return true; - } else { - return false; - } - } - void Close() { - if (m_open) { - m_open = false; - CloseClipboard(); - } - } -private: - bool m_open; - - PFC_CLASS_NOT_COPYABLE_EX(CClipboardOpenScope) -}; - -class CGlobalLockScope { -public: - CGlobalLockScope(HGLOBAL p_handle) : m_handle(p_handle), m_ptr(GlobalLock(p_handle)) { - if (m_ptr == NULL) throw std::bad_alloc(); - } - ~CGlobalLockScope() { - if (m_ptr != NULL) GlobalUnlock(m_handle); - } - void * GetPtr() const {return m_ptr;} - t_size GetSize() const {return GlobalSize(m_handle);} -private: - void * m_ptr; - HGLOBAL m_handle; - - PFC_CLASS_NOT_COPYABLE_EX(CGlobalLockScope) -}; - -template class CGlobalLockScopeT { -public: - CGlobalLockScopeT(HGLOBAL handle) : m_scope(handle) {} - TItem * GetPtr() const {return reinterpret_cast(m_scope.GetPtr());} - t_size GetSize() const { - const t_size val = m_scope.GetSize(); - PFC_ASSERT( val % sizeof(TItem) == 0 ); - return val / sizeof(TItem); - } -private: - CGlobalLockScope m_scope; -}; - - -static bool IsPointInsideControl(const POINT& pt, HWND wnd) { - HWND walk = WindowFromPoint(pt); - for(;;) { - if (walk == NULL) return false; - if (walk == wnd) return true; - if (GetWindowLong(walk,GWL_STYLE) & WS_POPUP) return false; - walk = GetParent(walk); - } -} - -static bool IsWindowChildOf(HWND child, HWND parent) { - HWND walk = child; - while(walk != parent && walk != NULL && (GetWindowLong(walk,GWL_STYLE) & WS_CHILD) != 0) { - walk = GetParent(walk); - } - return walk == parent; -} - - -#include "audio_math.h" -#include "win32_misc.h" - -template -class CoTaskMemObject { -public: - CoTaskMemObject() : m_ptr() {} - - ~CoTaskMemObject() {CoTaskMemFree(m_ptr);} - - TPtr m_ptr; - PFC_CLASS_NOT_COPYABLE(CoTaskMemObject, CoTaskMemObject ); -}; -#endif //_SHARED_DLL__SHARED_H_ diff --git a/tools/vio2sf/src/foobar/foobar2000/shared/shared.lib b/tools/vio2sf/src/foobar/foobar2000/shared/shared.lib deleted file mode 100644 index da00a2638..000000000 Binary files a/tools/vio2sf/src/foobar/foobar2000/shared/shared.lib and /dev/null differ diff --git a/tools/vio2sf/src/foobar/foobar2000/shared/win32_misc.h b/tools/vio2sf/src/foobar/foobar2000/shared/win32_misc.h deleted file mode 100644 index 2d59d708b..000000000 --- a/tools/vio2sf/src/foobar/foobar2000/shared/win32_misc.h +++ /dev/null @@ -1,252 +0,0 @@ -class win32_menu { -public: - win32_menu(HMENU p_initval) : m_menu(p_initval) {} - win32_menu() : m_menu(NULL) {} - ~win32_menu() {release();} - void release() { - if (m_menu != NULL) { - DestroyMenu(m_menu); - m_menu = NULL; - } - } - void set(HMENU p_menu) {release(); m_menu = p_menu;} - void create_popup() { - release(); - SetLastError(NO_ERROR); - m_menu = CreatePopupMenu(); - if (m_menu == NULL) throw exception_win32(GetLastError()); - } - HMENU get() const {return m_menu;} - HMENU detach() {return pfc::replace_t(m_menu,(HMENU)NULL);} - - bool is_valid() const {return m_menu != NULL;} -private: - win32_menu(const win32_menu &) {throw pfc::exception_not_implemented();} - const win32_menu & operator=(const win32_menu &) {throw pfc::exception_not_implemented();} - - HMENU m_menu; -}; - -class win32_font { -public: - win32_font(HFONT p_initval) : m_font(p_initval) {} - win32_font() : m_font(NULL) {} - ~win32_font() {release();} - - void release() { - HFONT temp = detach(); - if (temp != NULL) DeleteObject(temp); - } - - void set(HFONT p_font) {release(); m_font = p_font;} - HFONT get() const {return m_font;} - HFONT detach() {return pfc::replace_t(m_font,(HFONT)NULL);} - - void create(const t_font_description & p_desc) { - SetLastError(NO_ERROR); - HFONT temp = p_desc.create(); - if (temp == NULL) throw exception_win32(GetLastError()); - set(temp); - } - - bool is_valid() const {return m_font != NULL;} - -private: - win32_font(const win32_font&) {throw pfc::exception_not_implemented();} - const win32_font & operator=(const win32_font &) {throw pfc::exception_not_implemented();} - - HFONT m_font; -}; - -class win32_event { -public: - win32_event() : m_handle(NULL) {} - ~win32_event() {release();} - - void create(bool p_manualreset,bool p_initialstate) { - release(); - SetLastError(NO_ERROR); - m_handle = CreateEvent(NULL,p_manualreset ? TRUE : FALSE, p_initialstate ? TRUE : FALSE,NULL); - if (m_handle == NULL) throw exception_win32(GetLastError()); - } - - void set(HANDLE p_handle) {release(); m_handle = p_handle;} - HANDLE get() const {return m_handle;} - HANDLE detach() {return pfc::replace_t(m_handle,(HANDLE)NULL);} - bool is_valid() const {return m_handle != NULL;} - - void release() { - HANDLE temp = detach(); - if (temp != NULL) CloseHandle(temp); - } - - - //! Returns true when signaled, false on timeout - bool wait_for(double p_timeout_seconds) {return g_wait_for(get(),p_timeout_seconds);} - - static DWORD g_calculate_wait_time(double p_seconds) { - DWORD time = 0; - if (p_seconds> 0) { - time = audio_math::rint32((audio_sample)(p_seconds * 1000.0)); - if (time == 0) time = 1; - } else if (p_seconds < 0) { - time = INFINITE; - } - return time; - } - - //! Returns true when signaled, false on timeout - static bool g_wait_for(HANDLE p_event,double p_timeout_seconds) { - SetLastError(NO_ERROR); - DWORD status = WaitForSingleObject(p_event,g_calculate_wait_time(p_timeout_seconds)); - switch(status) { - case WAIT_FAILED: - throw exception_win32(GetLastError()); - default: - throw pfc::exception_bug_check(); - case WAIT_OBJECT_0: - return true; - case WAIT_TIMEOUT: - return false; - } - } - - void set_state(bool p_state) { - PFC_ASSERT(m_handle != NULL); - if (p_state) SetEvent(m_handle); - else ResetEvent(m_handle); - } - -private: - win32_event(const win32_event&) {throw pfc::exception_not_implemented();} - const win32_event & operator=(const win32_event &) {throw pfc::exception_not_implemented();} - - HANDLE m_handle; -}; - -static void uSleepSeconds(double p_time,bool p_alertable) { - SleepEx(win32_event::g_calculate_wait_time(p_time),p_alertable ? TRUE : FALSE); -} - - - - -class win32_icon { -public: - win32_icon(HICON p_initval) : m_icon(p_initval) {} - win32_icon() : m_icon(NULL) {} - ~win32_icon() {release();} - - void release() { - HICON temp = detach(); - if (temp != NULL) DestroyIcon(temp); - } - - void set(HICON p_icon) {release(); m_icon = p_icon;} - HICON get() const {return m_icon;} - HICON detach() {return pfc::replace_t(m_icon,(HICON)NULL);} - - bool is_valid() const {return m_icon != NULL;} - -private: - win32_icon(const win32_icon&) {throw pfc::exception_not_implemented();} - const win32_icon & operator=(const win32_icon &) {throw pfc::exception_not_implemented();} - - HICON m_icon; -}; - -class win32_accelerator { -public: - win32_accelerator() : m_accel(NULL) {} - ~win32_accelerator() {release();} - HACCEL get() const {return m_accel;} - - void load(HINSTANCE p_inst,const TCHAR * p_id) { - release(); - SetLastError(NO_ERROR); - m_accel = LoadAccelerators(p_inst,p_id); - if (m_accel == NULL) { - throw exception_win32(GetLastError()); - } - } - - void release() { - if (m_accel != NULL) { - DestroyAcceleratorTable(m_accel); - m_accel = NULL; - } - } -private: - HACCEL m_accel; - PFC_CLASS_NOT_COPYABLE(win32_accelerator,win32_accelerator); -}; - - -class SelectObjectScope { -public: - SelectObjectScope(HDC p_dc,HGDIOBJ p_obj) throw() : m_dc(p_dc), m_obj(SelectObject(p_dc,p_obj)) {} - ~SelectObjectScope() throw() {SelectObject(m_dc,m_obj);} -private: - PFC_CLASS_NOT_COPYABLE_EX(SelectObjectScope) - HDC m_dc; - HGDIOBJ m_obj; -}; - -class OffsetWindowOrgScope { -public: - OffsetWindowOrgScope(HDC dc, const POINT & pt) throw() : m_dc(dc), m_pt(pt) { - OffsetWindowOrgEx(m_dc, m_pt.x, m_pt.y, NULL); - } - ~OffsetWindowOrgScope() throw() { - OffsetWindowOrgEx(m_dc, -m_pt.x, -m_pt.y, NULL); - } - -private: - const HDC m_dc; - const POINT m_pt; -}; -class DCStateScope { -public: - DCStateScope(HDC p_dc) throw() : m_dc(p_dc) { - m_state = SaveDC(m_dc); - } - ~DCStateScope() throw() { - RestoreDC(m_dc,m_state); - } -private: - const HDC m_dc; - int m_state; -}; - - -class exception_com : public std::exception { -public: - exception_com(HRESULT p_code) : std::exception(format_win32_error(p_code)), m_code(p_code) {} - HRESULT get_code() const {return m_code;} -private: - HRESULT m_code; -}; - -// Same format as _WIN32_WINNT macro. -static WORD GetWindowsVersionCode() throw() { - const DWORD ver = GetVersion(); - return (WORD)HIBYTE(LOWORD(ver)) | ((WORD)LOBYTE(LOWORD(ver)) << 8); -} - -//! Simple implementation of a COM reference counter. The initial reference count is zero, so it can be used with pfc::com_ptr_t<> with plain operator=/constructor rather than attach(). -template class ImplementCOMRefCounter : public TBase { -public: - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(ImplementCOMRefCounter,TBase) - ULONG STDMETHODCALLTYPE AddRef() { - return ++m_refcounter; - } - ULONG STDMETHODCALLTYPE Release() { - long val = --m_refcounter; - if (val == 0) delete this; - return val; - } -protected: - virtual ~ImplementCOMRefCounter() {} -private: - pfc::refcounter m_refcounter; -}; diff --git a/tools/vio2sf/src/foobar/pfc/alloc.h b/tools/vio2sf/src/foobar/pfc/alloc.h deleted file mode 100644 index b40aa092c..000000000 --- a/tools/vio2sf/src/foobar/pfc/alloc.h +++ /dev/null @@ -1,422 +0,0 @@ -namespace pfc { - - static void * raw_malloc(t_size p_size) { - return p_size > 0 ? new_ptr_check_t(malloc(p_size)) : NULL; - } - - static void raw_free(void * p_block) throw() {free(p_block);} - - static void* raw_realloc(void * p_ptr,t_size p_size) { - if (p_size == 0) {raw_free(p_ptr); return NULL;} - else if (p_ptr == NULL) return raw_malloc(p_size); - else return pfc::new_ptr_check_t(::realloc(p_ptr,p_size)); - } - - static bool raw_realloc_inplace(void * p_block,t_size p_size) throw() { - if (p_block == NULL) return p_size == 0; -#ifdef _MSC_VER - if (p_size == 0) return false; - return _expand(p_block,p_size) != NULL; -#else - return false; -#endif - } - - template - t_size calc_array_width(t_size p_width) { - return pfc::mul_safe_t(p_width,sizeof(T)); - } - - template - T * __raw_malloc_t(t_size p_size) { - return reinterpret_cast(raw_malloc(calc_array_width(p_size))); - } - - template - void __raw_free_t(T * p_block) throw() { - raw_free(reinterpret_cast(p_block)); - } - - template - T * __raw_realloc_t(T * p_block,t_size p_size) { - return reinterpret_cast(raw_realloc(p_block,calc_array_width(p_size))); - } - - template - bool __raw_realloc_inplace_t(T * p_block,t_size p_size) { - return raw_realloc_inplace(p_block,calc_array_width(p_size)); - } - - - template - inline t_int safe_shift_left_t(t_int p_val,t_size p_shift = 1) { - t_int newval = p_val << p_shift; - if (newval >> p_shift != p_val) throw t_exception(); - return newval; - } - - template class alloc_dummy { - private: typedef alloc_dummy t_self; - public: - alloc_dummy() {} - void set_size(t_size p_size) {throw pfc::exception_not_implemented();} - t_size get_size() const {throw pfc::exception_not_implemented();} - const t_item & operator[](t_size p_index) const {throw pfc::exception_not_implemented();} - t_item & operator[](t_size p_index) {throw pfc::exception_not_implemented();} - - bool is_ptr_owned(const void * p_item) const {return false;} - - //set to true when we prioritize speed over memory usage - enum { alloc_prioritizes_speed = false }; - - //not mandatory - const t_item * get_ptr() const {throw pfc::exception_not_implemented();} - t_item * get_ptr() {throw pfc::exception_not_implemented();} - void prealloc(t_size) {throw pfc::exception_not_implemented();} - void force_reset() {throw pfc::exception_not_implemented();} - private: - const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();} - alloc_dummy(const t_self&) {throw pfc::exception_not_implemented();} - }; - - template - bool is_pointer_in_range(const t_item * p_buffer,t_size p_buffer_size,const void * p_pointer) { - return p_pointer >= reinterpret_cast(p_buffer) && p_pointer < reinterpret_cast(p_buffer + p_buffer_size); - } - - - //! Simple inefficient fully portable allocator. - template class alloc_simple { - private: typedef alloc_simple t_self; - public: - alloc_simple() : m_data(NULL), m_size(0) {} - void set_size(t_size p_size) { - if (p_size != m_size) { - t_item * l_data = NULL; - if (p_size > 0) l_data = new t_item[p_size]; - try { - pfc::memcpy_t(l_data,m_data,pfc::min_t(m_size,p_size)); - } catch(...) { - delete[] l_data; - throw; - } - delete[] m_data; - m_data = l_data; - m_size = p_size; - } - } - t_size get_size() const {return m_size;} - const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_data[p_index];} - t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_data[p_index];} - bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(get_ptr(),get_size(),p_item);} - - enum { alloc_prioritizes_speed = false }; - - t_item * get_ptr() {return m_data;} - const t_item * get_ptr() const {return m_data;} - - void prealloc(t_size) {} - void force_reset() {set_size(0);} - - ~alloc_simple() {delete[] m_data;} - private: - const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();} - alloc_simple(const t_self&) {throw pfc::exception_not_implemented();} - - t_item * m_data; - t_size m_size; - }; - - template class __array_fast_helper_t { - private: - typedef __array_fast_helper_t t_self; - public: - __array_fast_helper_t() : m_buffer(NULL), m_size_total(0), m_size(0) {} - - - void set_size(t_size p_size,t_size p_size_total) { - PFC_ASSERT(p_size <= p_size_total); - PFC_ASSERT(m_size <= m_size_total); - if (p_size_total > m_size_total) { - resize_storage(p_size_total); - resize_content(p_size); - } else { - resize_content(p_size); - resize_storage(p_size_total); - } - } - - - - t_size get_size() const {return m_size;} - t_size get_size_total() const {return m_size_total;} - const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];} - t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < m_size); return m_buffer[p_index];} - ~__array_fast_helper_t() { - set_size(0,0); - } - t_item * get_ptr() {return m_buffer;} - const t_item * get_ptr() const {return m_buffer;} - bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(m_buffer,m_size_total,p_item);} - private: - const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();} - __array_fast_helper_t(const t_self &) {throw pfc::exception_not_implemented();} - - - void resize_content(t_size p_size) { - if (traits_t::needs_constructor || traits_t::needs_destructor) { - if (p_size > m_size) {//expand - do { - __unsafe__in_place_constructor_t(m_buffer[m_size]); - m_size++; - } while(m_size < p_size); - } else if (p_size < m_size) { - __unsafe__in_place_destructor_array_t(m_buffer + p_size, m_size - p_size); - m_size = p_size; - } - } else { - m_size = p_size; - } - } - - void resize_storage(t_size p_size) { - PFC_ASSERT( m_size <= m_size_total ); - PFC_ASSERT( m_size <= p_size ); - if (m_size_total != p_size) { - if (pfc::traits_t::realloc_safe) { - m_buffer = pfc::__raw_realloc_t(m_buffer,p_size); - m_size_total = p_size; - } else if (__raw_realloc_inplace_t(m_buffer,p_size)) { - //success - m_size_total = p_size; - } else { - t_item * newbuffer = pfc::__raw_malloc_t(p_size); - try { - pfc::__unsafe__in_place_constructor_array_copy_t(newbuffer,m_size,m_buffer); - } catch(...) { - pfc::__raw_free_t(newbuffer); - throw; - } - pfc::__unsafe__in_place_destructor_array_t(m_buffer,m_size); - pfc::__raw_free_t(m_buffer); - m_buffer = newbuffer; - m_size_total = p_size; - } - } - } - - t_item * m_buffer; - t_size m_size,m_size_total; - }; - - template class alloc_standard { - private: typedef alloc_standard t_self; - public: - alloc_standard() {} - void set_size(t_size p_size) {m_content.set_size(p_size,p_size);} - - t_size get_size() const {return m_content.get_size();} - - const t_item & operator[](t_size p_index) const {return m_content[p_index];} - t_item & operator[](t_size p_index) {return m_content[p_index];} - - const t_item * get_ptr() const {return m_content.get_ptr();} - t_item * get_ptr() {return m_content.get_ptr();} - - bool is_ptr_owned(const void * p_item) const {return m_content.is_ptr_owned(p_item);} - void prealloc(t_size p_size) {} - void force_reset() {set_size(0);} - - enum { alloc_prioritizes_speed = false }; - private: - alloc_standard(const t_self &) {throw pfc::exception_not_implemented();} - const t_self & operator=(const t_self&) {throw pfc::exception_not_implemented();} - - __array_fast_helper_t m_content; - }; - - template class alloc_fast { - private: typedef alloc_fast t_self; - public: - alloc_fast() {} - - void set_size(t_size p_size) { - t_size size_base = m_data.get_size_total(); - if (size_base == 0) size_base = 1; - while(size_base < p_size) { - size_base = safe_shift_left_t(size_base,1); - } - while(size_base >> 2 > p_size) { - size_base >>= 1; - } - m_data.set_size(p_size,size_base); - } - - t_size get_size() const {return m_data.get_size();} - const t_item & operator[](t_size p_index) const {return m_data[p_index];} - t_item & operator[](t_size p_index) {return m_data[p_index];} - - const t_item * get_ptr() const {return m_data.get_ptr();} - t_item * get_ptr() {return m_data.get_ptr();} - bool is_ptr_owned(const void * p_item) const {return m_data.is_ptr_owned(p_item);} - void prealloc(t_size) {} - void force_reset() {m_data.set_size(0,0);} - - enum { alloc_prioritizes_speed = true }; - private: - alloc_fast(const t_self &) {throw pfc::exception_not_implemented();} - const t_self & operator=(const t_self&) {throw pfc::exception_not_implemented();} - __array_fast_helper_t m_data; - }; - - template class alloc_fast_aggressive { - private: typedef alloc_fast_aggressive t_self; - public: - alloc_fast_aggressive() {} - - void set_size(t_size p_size) { - t_size size_base = m_data.get_size_total(); - if (size_base == 0) size_base = 1; - while(size_base < p_size) { - size_base = safe_shift_left_t(size_base,1); - } - m_data.set_size(p_size,size_base); - } - - void prealloc(t_size p_size) { - if (p_size > 0) { - t_size size_base = m_data.get_size_total(); - if (size_base == 0) size_base = 1; - while(size_base < p_size) { - size_base = safe_shift_left_t(size_base,1); - } - m_data.set_size(m_data.get_size(),size_base); - } - } - - t_size get_size() const {return m_data.get_size();} - const t_item & operator[](t_size p_index) const {;return m_data[p_index];} - t_item & operator[](t_size p_index) {return m_data[p_index];} - - const t_item * get_ptr() const {return m_data.get_ptr();} - t_item * get_ptr() {return m_data.get_ptr();} - bool is_ptr_owned(const void * p_item) const {return m_data.is_ptr_owned(p_item);} - void force_reset() {m_data.set_size(0,0);} - - enum { alloc_prioritizes_speed = true }; - private: - alloc_fast_aggressive(const t_self &) {throw pfc::exception_not_implemented();} - const t_self & operator=(const t_self&) {throw pfc::exception_not_implemented();} - __array_fast_helper_t m_data; - }; - - template class alloc_fixed { - public: - template class alloc { - private: typedef alloc t_self; - public: - alloc() : m_size(0) {} - - void set_size(t_size p_size) { - static_assert(); - - if (p_size > p_width) throw pfc::exception_overflow(); - else if (p_size > m_size) { - __unsafe__in_place_constructor_array_t(get_ptr()+m_size,p_size-m_size); - m_size = p_size; - } else if (p_size < m_size) { - __unsafe__in_place_destructor_array_t(get_ptr()+p_size,m_size-p_size); - m_size = p_size; - } - } - - ~alloc() { - if (pfc::traits_t::needs_destructor) set_size(0); - } - - t_size get_size() const {return m_size;} - - t_item * get_ptr() {return reinterpret_cast(&m_array);} - const t_item * get_ptr() const {return reinterpret_cast(&m_array);} - - const t_item & operator[](t_size n) const {return get_ptr()[n];} - t_item & operator[](t_size n) {return get_ptr()[n];} - bool is_ptr_owned(const void * p_item) const {return is_pointer_in_range(get_ptr(),p_width,p_item);} - void prealloc(t_size) {} - void force_reset() {set_size(0);} - - enum { alloc_prioritizes_speed = false }; - private: - alloc(const t_self&) {throw pfc::exception_not_implemented();} - const t_self& operator=(const t_self&) {throw pfc::exception_not_implemented();} - - t_uint8 m_array[sizeof(t_item[p_width])]; - t_size m_size; - }; - }; - - template class t_alloc = alloc_standard > class alloc_hybrid { - public: - template class alloc { - private: typedef alloc t_self; - public: - alloc() {} - - void set_size(t_size p_size) { - if (p_size > p_width) { - m_fixed.set_size(p_width); - m_variable.set_size(p_size - p_width); - } else { - m_fixed.set_size(p_size); - m_variable.set_size(0); - } - } - - t_item & operator[](t_size p_index) { - PFC_ASSERT(p_index < get_size()); - if (p_index < p_width) return m_fixed[p_index]; - else return m_variable[p_index - p_width]; - } - - const t_item & operator[](t_size p_index) const { - PFC_ASSERT(p_index < get_size()); - if (p_index < p_width) return m_fixed[p_index]; - else return m_variable[p_index - p_width]; - } - - t_size get_size() const {return m_fixed.get_size() + m_variable.get_size();} - bool is_ptr_owned(const void * p_item) const {return m_fixed.is_ptr_owned(p_item) || m_variable.is_ptr_owned(p_item);} - void prealloc(t_size p_size) { - if (p_size > p_width) m_variable.prealloc(p_size - p_width); - } - void force_reset() { - m_fixed.force_reset(); m_variable.force_reset(); - } - enum { alloc_prioritizes_speed = t_alloc::alloc_prioritizes_speed }; - private: - alloc(const t_self&) {throw pfc::exception_not_implemented();} - const t_self& operator=(const t_self&) {throw pfc::exception_not_implemented();} - - typename alloc_fixed::template alloc m_fixed; - t_alloc m_variable; - }; - }; - - template class traits_t > : public traits_default_movable {}; - template class traits_t<__array_fast_helper_t > : public traits_default_movable {}; - template class traits_t > : public pfc::traits_t<__array_fast_helper_t > {}; - template class traits_t > : public pfc::traits_t<__array_fast_helper_t > {}; - template class traits_t > : public pfc::traits_t<__array_fast_helper_t > {}; - -#if 0//not working (compiler bug?) - template class traits_t::template alloc > : public pfc::traits_t { - public: - enum { - needs_constructor = true, - }; - }; - - template class t_alloc,typename t_item> - class traits_t::template alloc > : public traits_combined::template alloc > {}; -#endif -}; diff --git a/tools/vio2sf/src/foobar/pfc/array.h b/tools/vio2sf/src/foobar/pfc/array.h deleted file mode 100644 index c643cb652..000000000 --- a/tools/vio2sf/src/foobar/pfc/array.h +++ /dev/null @@ -1,239 +0,0 @@ -#ifndef _PFC_ARRAY_H_ -#define _PFC_ARRAY_H_ - -namespace pfc { - - template class t_alloc = alloc_standard> class array_t; - - - //! Special simplififed version of array class that avoids stepping on landmines with classes without public copy operators/constructors. - template - class array_staticsize_t { - public: typedef _t_item t_item; - private: typedef array_staticsize_t t_self; - public: - array_staticsize_t() : m_size(0), m_array(NULL) {} - array_staticsize_t(t_size p_size) : m_array(new t_item[p_size]), m_size(p_size) {} - ~array_staticsize_t() {__release();} - - //! Copy constructor nonfunctional when data type is not copyable. - array_staticsize_t(const t_self & p_source) : m_size(0), m_array(NULL) { - *this = p_source; - } - - //! Copy operator nonfunctional when data type is not copyable. - const t_self & operator=(const t_self & p_source) { - __release(); - - //m_array = pfc::malloc_copy_t(p_source.get_size(),p_source.get_ptr()); - const t_size newsize = p_source.get_size(); - m_array = new t_item[newsize]; - m_size = newsize; - for(t_size n = 0; n < newsize; n++) m_array[n] = p_source[n]; - return *this; - } - - void set_size_discard(t_size p_size) { - __release(); - if (p_size > 0) { - m_array = new t_item[p_size]; - m_size = p_size; - } - } - - t_size get_size() const {return m_size;} - const t_item * get_ptr() const {return m_array;} - t_item * get_ptr() {return m_array;} - - const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < get_size());return m_array[p_index];} - t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < get_size());return m_array[p_index];} - - template bool is_owned(const t_source & p_item) {return pfc::is_pointer_in_range(get_ptr(),get_size(),&p_item);} - private: - void __release() { - m_size = 0; - delete[] pfc::replace_null_t(m_array); - } - t_item * m_array; - t_size m_size; - }; - - template - inline void copy_array_t(t_to & p_to,const t_from & p_from) { - const t_size size = array_size_t(p_from); - if (p_to.has_owned_items(p_from)) {//avoid landmines with actual array data overlapping, or p_from being same as p_to - array_staticsize_t temp; - temp.set_size_discard(size); - pfc::copy_array_loop_t(temp,p_from,size); - p_to.set_size(size); - pfc::copy_array_loop_t(p_to,temp,size); - } else { - p_to.set_size(size); - pfc::copy_array_loop_t(p_to,p_from,size); - } - } - - template - inline void fill_array_t(t_array & p_array,const t_value & p_value) { - const t_size size = array_size_t(p_array); - for(t_size n=0;n class t_alloc> class array_t { - public: typedef _t_item t_item; - private: typedef array_t t_self; - public: - array_t() {} - array_t(const t_self & p_source) {copy_array_t(*this,p_source);} - template array_t(const t_source & p_source) {copy_array_t(*this,p_source);} - const t_self & operator=(const t_self & p_source) {copy_array_t(*this,p_source); return *this;} - template const t_self & operator=(const t_source & p_source) {copy_array_t(*this,p_source); return *this;} - - void set_size(t_size p_size) {m_alloc.set_size(p_size);} - void set_count(t_size p_count) {m_alloc.set_size(p_count);} - t_size get_size() const {return m_alloc.get_size();} - t_size get_count() const {return m_alloc.get_size();} - void force_reset() {m_alloc.force_reset();} - - const t_item & operator[](t_size p_index) const {PFC_ASSERT(p_index < get_size());return m_alloc[p_index];} - t_item & operator[](t_size p_index) {PFC_ASSERT(p_index < get_size());return m_alloc[p_index];} - - //! Warning: buffer pointer must not point to buffer allocated by this array (fixme). - template - void set_data_fromptr(const t_source * p_buffer,t_size p_count) { - - set_size(p_count); - pfc::copy_array_loop_t(*this,p_buffer,p_count); - } - - template - void append(const t_array & p_source) { - if (has_owned_items(p_source)) append(array_t(p_source)); - else { - const t_size source_size = array_size_t(p_source); - const t_size base = get_size(); - increase_size(source_size); - for(t_size n=0;n - void insert_multi(const t_insert & value, t_size base, t_size count) { - const t_size oldSize = get_size(); - if (base > oldSize) base = oldSize; - increase_size(count); - pfc::memmove_t(get_ptr() + base + count, get_ptr() + base, oldSize - base); - pfc::fill_ptr_t(get_ptr() + base, count, value); - } - template void append_multi(const t_append & value, t_size count) {insert_multi(value,~0,count);} - - //! Warning: buffer pointer must not point to buffer allocated by this array (fixme). - template - void append_fromptr(const t_append * p_buffer,t_size p_count) { - PFC_ASSERT( !is_owned(&p_buffer[0]) ); - t_size base = get_size(); - increase_size(p_count); - for(t_size n=0;n - void append_single(const t_append & p_item) { - if (is_owned(p_item)) append_single(t_append(p_item)); - else { - const t_size base = get_size(); - increase_size(1); - m_alloc[base] = p_item; - } - } - - template - void fill(const t_filler & p_filler) { - const t_size max = get_size(); - for(t_size n=0;n get_size()) set_size(p_size); - } - - //not supported by some allocs - const t_item * get_ptr() const {return m_alloc.get_ptr();} - t_item * get_ptr() {return m_alloc.get_ptr();} - - void prealloc(t_size p_size) {m_alloc.prealloc(p_size);} - - template - bool has_owned_items(const t_array & p_source) { - if (array_size_t(p_source) == 0) return false; - - //how the hell would we properly check if any of source items is owned by us, in case source array implements some weird mixing of references of items from different sources? - //the most obvious way means evil bottleneck here (whether it matters or not from caller's point of view which does something O(n) already is another question) - //at least this will work fine with all standard classes which don't crossreference anyhow and always use own storage - //perhaps we'll traitify this someday later - return is_owned(p_source[0]); - } - - template - bool is_owned(const t_source & p_item) { - return m_alloc.is_ptr_owned(&p_item); - } - - template - void set_single(const t_item & p_item) { - set_size(1); - (*this)[0] = p_item; - } - - template - void enumerate(t_callback & p_callback) const { - for(t_size n = 0; n < get_size(); n++ ) { - p_callback((*this)[n]); - } - } - - private: - t_alloc m_alloc; - }; - - template class t_alloc = alloc_standard > - class array_hybrid_t : public array_t::template alloc > - {}; - - - template class traits_t > : public traits_default_movable {}; - template class t_alloc> class traits_t > : public pfc::traits_t > {}; - - - template - class comparator_array { - public: - template - static int compare(const t_array1 & p_array1, const t_array2 & p_array2) { - t_size walk = 0; - for(;;) { - if (walk >= p_array1.get_size() && walk >= p_array2.get_size()) return 0; - else if (walk >= p_array1.get_size()) return -1; - else if (walk >= p_array2.get_size()) return 1; - else { - int state = t_comparator::compare(p_array1[walk],p_array2[walk]); - if (state != 0) return state; - } - ++walk; - } - } - }; -} - - -#endif //_PFC_ARRAY_H_ diff --git a/tools/vio2sf/src/foobar/pfc/avltree.h b/tools/vio2sf/src/foobar/pfc/avltree.h deleted file mode 100644 index c1575c318..000000000 --- a/tools/vio2sf/src/foobar/pfc/avltree.h +++ /dev/null @@ -1,537 +0,0 @@ -namespace pfc { - - template - class _avltree_node : public _list_node { - public: - typedef _list_node t_node; - typedef _avltree_node t_self; - template _avltree_node(t_param const& param) : t_node(param), m_left(), m_right(), m_depth() {} - - typedef refcounted_object_ptr_t t_ptr; - typedef t_self* t_rawptr; - - t_ptr m_left, m_right; - t_rawptr m_parent; - - t_size m_depth; - - void link_left(t_self* ptr) throw() { - m_left = ptr; - if (ptr != NULL) ptr->m_parent = this; - } - void link_right(t_self* ptr) throw() { - m_right = ptr; - if (ptr != NULL) ptr->m_parent = this; - } - - void link_child(bool which,t_self* ptr) throw() { - (which ? m_right : m_left) = ptr; - if (ptr != NULL) ptr->m_parent = this; - } - - void unlink() throw() { - m_left.release(); m_right.release(); m_parent = NULL; m_depth = 0; - } - - inline void add_ref() throw() {this->refcount_add_ref();} - inline void release() throw() {this->refcount_release();} - - inline t_rawptr child(bool which) const throw() {return which ? &*m_right : &*m_left;} - inline bool which_child(const t_self* ptr) const throw() {return ptr == &*m_right;} - - - - t_rawptr step(bool direction) throw() { - t_self* walk = this; - for(;;) { - t_self* t = walk->child(direction); - if (t != NULL) return t->peakchild(!direction); - for(;;) { - t = walk->m_parent; - if (t == NULL) return NULL; - if (t->which_child(walk) != direction) return t; - walk = t; - } - } - } - t_rawptr peakchild(bool direction) throw() { - t_self* walk = this; - for(;;) { - t_rawptr next = walk->child(direction); - if (next == NULL) return walk; - walk = next; - } - } - t_node * prev() throw() {return step(false);} - t_node * next() throw() {return step(true);} - private: - ~_avltree_node() throw() {} - }; - - - template - class avltree_t { - public: - typedef avltree_t t_self; - typedef pfc::const_iterator const_iterator; - typedef pfc::iterator iterator; - typedef t_storage t_item; - private: - typedef _avltree_node t_node; -#if 1//MSVC8 bug fix - typedef refcounted_object_ptr_t t_nodeptr; - typedef t_node * t_noderawptr; -#else - typedef typename t_node::t_ptr t_nodeptr; - typedef typename t_node::t_rawptr t_noderawptr; -#endif - - - template - inline static int compare(const t_item1 & p_item1, const t_item2 & p_item2) { - return t_comparator::compare(p_item1,p_item2); - } - - t_nodeptr m_root; - - static t_size calc_depth(const t_nodeptr & ptr) - { - return ptr.is_valid() ? 1+ptr->m_depth : 0; - } - - static void recalc_depth(t_nodeptr const& ptr) { - ptr->m_depth = pfc::max_t(calc_depth(ptr->m_left), calc_depth(ptr->m_right)); - } - - static void assert_children(t_nodeptr ptr) { - PFC_ASSERT(ptr->m_depth == pfc::max_t(calc_depth(ptr->m_left),calc_depth(ptr->m_right)) ); - } - - static t_ssize test_depth(t_nodeptr const& ptr) - { - if (ptr==0) return 0; - else return calc_depth(ptr->m_right) - calc_depth(ptr->m_left); - } - - static t_nodeptr extract_left_leaf(t_nodeptr & p_base) { - if (p_base->m_left != NULL) { - t_nodeptr ret = extract_left_leaf(p_base->m_left); - recalc_depth(p_base); - g_rebalance(p_base); - return ret; - } else { - t_nodeptr node = p_base; - p_base = node->m_right; - if (p_base.is_valid()) p_base->m_parent = node->m_parent; - node->m_right.release(); - node->m_depth = 0; - node->m_parent = NULL; - return node; - } - } - - static t_nodeptr extract_right_leaf(t_nodeptr & p_base) { - if (p_base->m_right != NULL) { - t_nodeptr ret = extract_right_leaf(p_base->m_right); - recalc_depth(p_base); - g_rebalance(p_base); - return ret; - } else { - t_nodeptr node = p_base; - p_base = node->m_left; - if (p_base.is_valid()) p_base->m_parent = node->m_parent; - node->m_left.release(); - node->m_depth = 0; - node->m_parent = NULL; - return node; - } - } - - static void remove_internal(t_nodeptr & p_node) { - t_nodeptr oldval = p_node; - if (p_node->m_left.is_empty()) { - p_node = p_node->m_right; - if (p_node.is_valid()) p_node->m_parent = oldval->m_parent; - } else if (p_node->m_right.is_empty()) { - p_node = p_node->m_left; - if (p_node.is_valid()) p_node->m_parent = oldval->m_parent; - } else { - t_nodeptr swap = extract_left_leaf(p_node->m_right); - - swap->link_left(&*oldval->m_left); - swap->link_right(&*oldval->m_right); - swap->m_parent = oldval->m_parent; - recalc_depth(swap); - p_node = swap; - } - oldval->unlink(); - } - - template - static void __enum_items_recur(t_nodewalk * p_node,t_callback & p_callback) { - if (p_node != NULL) { - __enum_items_recur(&*p_node->m_left,p_callback); - p_callback (p_node->m_content); - __enum_items_recur(&*p_node->m_right,p_callback); - } - } - template - static t_node * g_find_or_add_node(t_nodeptr & p_base,t_node * parent,t_search const & p_search,bool & p_new) - { - if (p_base.is_empty()) { - p_base = new t_node(p_search); - p_base->m_parent = parent; - p_new = true; - return p_base.get_ptr(); - } - - PFC_ASSERT( p_base->m_parent == parent ); - - int result = compare(p_base->m_content,p_search); - if (result > 0) { - t_node * ret = g_find_or_add_node(p_base->m_left,&*p_base,p_search,p_new); - if (p_new) { - recalc_depth(p_base); - g_rebalance(p_base); - } - return ret; - } else if (result < 0) { - t_node * ret = g_find_or_add_node(p_base->m_right,&*p_base,p_search,p_new); - if (p_new) { - recalc_depth(p_base); - g_rebalance(p_base); - } - return ret; - } else { - p_new = false; - return p_base.get_ptr(); - } - } - - - - template - static t_storage * g_find_or_add(t_nodeptr & p_base,t_node * parent,t_search const & p_search,bool & p_new) { - return &g_find_or_add_node(p_base,parent,p_search,p_new)->m_content; - } - - - static void g_rotate_right(t_nodeptr & p_node) { - t_nodeptr oldroot = p_node; - t_nodeptr newroot = oldroot->m_right; - oldroot->link_child(true, &*newroot->m_left); - newroot->m_left = oldroot; - newroot->m_parent = oldroot->m_parent; - oldroot->m_parent = &*newroot; - recalc_depth(oldroot); - recalc_depth(newroot); - p_node = newroot; - } - - static void g_rotate_left(t_nodeptr & p_node) { - t_nodeptr oldroot = p_node; - t_nodeptr newroot = oldroot->m_left; - oldroot->link_child(false, &*newroot->m_right); - newroot->m_right = oldroot; - newroot->m_parent = oldroot->m_parent; - oldroot->m_parent = &*newroot; - recalc_depth(oldroot); - recalc_depth(newroot); - p_node = newroot; - } - - static void g_rebalance(t_nodeptr & p_node) { - t_ssize balance = test_depth(p_node); - if (balance > 1) { - //right becomes root - if (test_depth(p_node->m_right) < 0) { - g_rotate_left(p_node->m_right); - } - g_rotate_right(p_node); - } else if (balance < -1) { - //left becomes root - if (test_depth(p_node->m_left) > 0) { - g_rotate_right(p_node->m_left); - } - g_rotate_left(p_node); - } - selftest(p_node); - } - - template - static bool g_remove(t_nodeptr & p_node,t_search const & p_search) { - if (p_node.is_empty()) return false; - - int result = compare(p_node->m_content,p_search); - if (result == 0) { - remove_internal(p_node); - if (p_node != NULL) { - recalc_depth(p_node); - g_rebalance(p_node); - } - return true; - } else { - if (g_remove(result > 0 ? p_node->m_left : p_node->m_right,p_search)) { - recalc_depth(p_node); - g_rebalance(p_node); - return true; - } else { - return false; - } - } - } - - static void selftest(t_nodeptr const& p_node) { - #if 0 //def _DEBUG//SLOW! - if (p_node != NULL) { - selftest(p_node->m_left); - selftest(p_node->m_right); - assert_children(p_node); - t_ssize delta = test_depth(p_node); - PFC_ASSERT(delta >= -1 && delta <= 1); - - if (p_node->m_left.is_valid()) { - PFC_ASSERT( p_node.get_ptr() == p_node->m_left->m_parent ); - } - if (p_node->m_right.is_valid()) { - PFC_ASSERT( p_node.get_ptr() == p_node->m_right->m_parent ); - } - - if (p_node->m_parent != NULL) { - PFC_ASSERT(p_node == p_node->m_parent->m_left || p_node == p_node->m_parent->m_right); - } - } - #endif - } - - - static t_size calc_count(const t_node * p_node) throw() { - if (p_node != NULL) { - return 1 + calc_count(&*p_node->m_left) + calc_count(&*p_node->m_right); - } else { - return 0; - } - } - - template - t_storage * __find_item_ptr(t_param const & p_item) const { - t_node* ptr = &*m_root; - while(ptr != NULL) { - int result = compare(ptr->m_content,p_item); - if (result > 0) ptr=&*ptr->m_left; - else if (result < 0) ptr=&*ptr->m_right; - else return &ptr->m_content; - } - return NULL; - } - - template t_storage * __find_nearest(const t_search & p_search) const { - t_node * ptr = &*m_root; - t_storage * found = NULL; - while(ptr != NULL) { - int result = compare(ptr->m_content,p_search); - if (above) result = -result; - if (inclusive && result == 0) { - //direct hit - found = &ptr->m_content; - break; - } else if (result < 0) { - //match - found = &ptr->m_content; - ptr = ptr->child(!above); - } else { - //mismatch - ptr = ptr->child(above); - } - } - return found; - } - public: - avltree_t() : m_root(NULL) {} - ~avltree_t() {reset();} - const t_self & operator=(const t_self & p_other) {__copy(p_other);return *this;} - avltree_t(const t_self & p_other) : m_root(NULL) {try{__copy(p_other);} catch(...) {remove_all(); throw;}} - - template const t_self & operator=(const t_other & p_other) {copy_list_enumerated(*this,p_other);return *this;} - template avltree_t(const t_other & p_other) : m_root(NULL) {try{copy_list_enumerated(*this,p_other);}catch(...){remove_all(); throw;}} - - - template const t_storage * find_nearest_item(const t_search & p_search) const { - return __find_nearest(p_search); - } - - template t_storage * find_nearest_item(const t_search & p_search) { - return __find_nearest(p_search); - } - - template - t_storage & add_item(t_param const & p_item) { - bool dummy; - return add_item_ex(p_item,dummy); - } - - template - t_self & operator+=(const t_param & p_item) {add_item(p_item);return *this;} - - template - t_self & operator-=(const t_param & p_item) {remove_item(p_item);return *this;} - - //! Returns true when the list has been altered, false when the item was already present before. - template - bool add_item_check(t_param const & item) { - bool isNew = false; - g_find_or_add(m_root,NULL,item,isNew); - selftest(m_root); - return isNew; - } - template - t_storage & add_item_ex(t_param const & p_item,bool & p_isnew) { - t_storage * ret = g_find_or_add(m_root,NULL,p_item,p_isnew); - selftest(m_root); - return *ret; - } - - template - void set_item(const t_param & p_item) { - bool isnew; - t_storage & found = add_item_ex(p_item,isnew); - if (isnew) found = p_item; - } - - template - const t_storage * find_item_ptr(t_param const & p_item) const { - return __find_item_ptr(p_item); - } - - //! WARNING: caller must not alter the item in a way that changes the sort order. - template - t_storage * find_item_ptr(t_param const & p_item) { - return __find_item_ptr(p_item); - } - - template - bool contains(const t_param & p_item) const { - return find_item_ptr(p_item) != NULL; - } - - //! Same as contains(). - template - bool have_item(const t_param & p_item) const {return contains(p_item);} - - void remove_all() throw() { - _unlink_recur(m_root); - m_root.release(); - } - - bool remove(const_iterator const& iter) { - PFC_ASSERT(iter.is_valid()); - return remove_item(*iter);//OPTIMIZEME - //should never return false unless there's a bug in calling code - } - - template - bool remove_item(t_param const & p_item) { - bool ret = g_remove(m_root,p_item); - selftest(m_root); - return ret; - } - - t_size get_count() const throw() { - return calc_count(&*m_root); - } - - template - void enumerate(t_callback & p_callback) const { - __enum_items_recur(&*m_root,p_callback); - } - - //! Allows callback to modify the tree content. - //! WARNING: items must not be altered in a way that changes their sort order. - template - void _enumerate_var(t_callback & p_callback) { __enum_items_recur(&*m_root,p_callback); } - - template iterator insert(const t_param & p_item) { - bool isNew; - t_node * ret = g_find_or_add_node(m_root,NULL,p_item,isNew); - selftest(m_root); - return ret; - } - - //deprecated backwards compatibility method wrappers - template t_storage & add(const t_param & p_item) {return add_item(p_item);} - template t_storage & add_ex(const t_param & p_item,bool & p_isnew) {return add_item_ex(p_item,p_isnew);} - template const t_storage * find_ptr(t_param const & p_item) const {return find_item_ptr(p_item);} - template t_storage * find_ptr(t_param const & p_item) {return find_item_ptr(p_item);} - template bool exists(t_param const & p_item) const {return have_item(p_item);} - void reset() {remove_all();} - - - - - const_iterator first() const throw() {return _firstlast(false);} - const_iterator last() const throw() {return _firstlast(true);} - //Unsafe! Caller must not modify items in a way that changes sort order! - iterator _first_var() { return _firstlast(false); } - //Unsafe! Caller must not modify items in a way that changes sort order! - iterator _last_var() { return _firstlast(true); } - - template bool get_first(t_param & p_item) const throw() { - const_iterator iter = first(); - if (!iter.is_valid()) return false; - p_item = *iter; - return true; - } - template bool get_last(t_param & p_item) const throw() { - const_iterator iter = last(); - if (!iter.is_valid()) return false; - p_item = *iter; - return true; - } - - static bool equals(const t_self & v1, const t_self & v2) { - return listEquals(v1,v2); - } - bool operator==(const t_self & other) const {return equals(*this,other);} - bool operator!=(const t_self & other) const {return !equals(*this,other);} - - private: - static void _unlink_recur(t_nodeptr & node) { - if (node.is_valid()) { - _unlink_recur(node->m_left); - _unlink_recur(node->m_right); - node->unlink(); - } - } - t_node* _firstlast(bool which) const throw() { - if (m_root.is_empty()) return NULL; - for(t_node * walk = &*m_root; ; ) { - t_node * next = walk->child(which); - if (next == NULL) return walk; - PFC_ASSERT( next->m_parent == walk ); - walk = next; - } - } - static t_nodeptr __copy_recur(t_node * p_source,t_node * parent) { - if (p_source == NULL) { - return NULL; - } else { - t_nodeptr newnode = new t_node(p_source->m_content); - newnode->m_depth = p_source->m_depth; - newnode->m_left = __copy_recur(&*p_source->m_left,&*newnode); - newnode->m_right = __copy_recur(&*p_source->m_right,&*newnode); - newnode->m_parent = parent; - return newnode; - } - } - - void __copy(const t_self & p_other) { - reset(); - m_root = __copy_recur(&*p_other.m_root,NULL); - selftest(m_root); - } - }; - - - template - class traits_t > : public traits_default_movable {}; -} diff --git a/tools/vio2sf/src/foobar/pfc/binary_search.h b/tools/vio2sf/src/foobar/pfc/binary_search.h deleted file mode 100644 index 5b15889fe..000000000 --- a/tools/vio2sf/src/foobar/pfc/binary_search.h +++ /dev/null @@ -1,81 +0,0 @@ -namespace pfc { - class comparator_default; - - template - class binarySearch { - public: - - template - static bool run(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result) { - t_size max = p_base + p_count; - t_size min = p_base; - while(min> 1); - int state = t_comparator::compare(p_param,p_container[ptr]); - if (state > 0) min = ptr + 1; - else if (state < 0) max = ptr; - else { - p_result = ptr; - return true; - } - } - p_result = min; - return false; - } - - - template - static bool runGroupBegin(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result) { - t_size max = p_base + p_count; - t_size min = p_base; - bool found = false; - while(min> 1); - int state = t_comparator::compare(p_param,p_container[ptr]); - if (state > 0) min = ptr + 1; - else if (state < 0) max = ptr; - else { - found = true; max = ptr; - } - } - p_result = min; - return found; - } - - template - static bool runGroupEnd(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result) { - t_size max = p_base + p_count; - t_size min = p_base; - bool found = false; - while(min> 1); - int state = t_comparator::compare(p_param,p_container[ptr]); - if (state > 0) min = ptr + 1; - else if (state < 0) max = ptr; - else { - found = true; min = ptr + 1; - } - } - p_result = min; - return found; - } - - template - static bool runGroup(const t_container & p_container,t_size p_base,t_size p_count,const t_param & p_param,t_size & p_result,t_size & p_resultCount) { - if (!runGroupBegin(p_container,p_base,p_count,p_param,p_result)) { - p_resultCount = 0; - return false; - } - t_size groupEnd; - if (!runGroupEnd(p_container,p_result,p_count - p_result,p_param,groupEnd)) { - //should not happen.. - PFC_ASSERT(0); - p_resultCount = 0; - return false; - } - PFC_ASSERT(groupEnd > p_result); - p_resultCount = groupEnd - p_result; - return true; - } - }; -}; diff --git a/tools/vio2sf/src/foobar/pfc/bit_array.h b/tools/vio2sf/src/foobar/pfc/bit_array.h deleted file mode 100644 index 3e84216ad..000000000 --- a/tools/vio2sf/src/foobar/pfc/bit_array.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _PFC_BIT_ARRAY_H_ -#define _PFC_BIT_ARRAY_H_ - -class NOVTABLE bit_array { -public: - virtual bool get(t_size n) const = 0; - virtual t_size find(bool val,t_size start,t_ssize count) const//can be overridden for improved speed; returns first occurance of val between start and start+count (excluding start+count), or start+count if not found; count may be negative if we're searching back - { - t_ssize d, todo, ptr = start; - if (count==0) return start; - else if (count<0) {d = -1; todo = -count;} - else {d = 1; todo = count;} - while(todo>0 && get(ptr)!=val) {ptr+=d;todo--;} - return ptr; - } - inline bool operator[](t_size n) const {return get(n);} - - t_size calc_count(bool val,t_size start,t_size count,t_size count_max = ~0) const//counts number of vals for start<=n -class bit_array_table_t : public bit_array -{ - const T * data; - t_size count; - bool after; -public: - inline bit_array_table_t(const T * p_data,t_size p_count,bool p_after = false) - : data(p_data), count(p_count), after(p_after) - { - } - - bool get(t_size n) const - { - if (n -class bit_array_var_table_t : public bit_array_var -{ - T * data; - t_size count; - bool after; -public: - inline bit_array_var_table_t(T * p_data,t_size p_count,bool p_after = false) - : data(p_data), count(p_count), after(p_after) - { - } - - bool get(t_size n) const { - if (n bit_array_table; -typedef bit_array_var_table_t bit_array_var_table; - -class bit_array_range : public bit_array -{ - t_size begin,end; - bool state; -public: - bit_array_range(t_size first,t_size count,bool p_state = true) : begin(first), end(first+count), state(p_state) {} - - bool get(t_size n) const - { - bool rv = n>=begin && n0) - return (val>=start && valstart+count) ? val : start+count; - } - else - { - if (start == val) return count>0 ? start+1 : start-1; - else return start; - } - } -}; - -class bit_array_bittable : public bit_array_var -{ - pfc::array_t m_data; - t_size m_count; -public: - //helpers - template - inline static bool g_get(const t_array & p_array,t_size idx) - { - return !! (p_array[idx>>3] & (1<<(idx&7))); - } - - template - inline static void g_set(t_array & p_array,t_size idx,bool val) - { - unsigned char & dst = p_array[idx>>3]; - unsigned char mask = 1<<(idx&7); - dst = val ? dst|mask : dst&~mask; - } - - inline static t_size g_estimate_size(t_size p_count) {return (p_count+7)>>3;} - - void resize(t_size p_count) - { - t_size old_bytes = g_estimate_size(m_count); - m_count = p_count; - t_size bytes = g_estimate_size(m_count); - m_data.set_size(bytes); - if (bytes > old_bytes) pfc::memset_null_t(m_data.get_ptr()+old_bytes,bytes-old_bytes); - } - - bit_array_bittable(t_size p_count) : m_count(0) {resize(p_count);} - - void set(t_size n,bool val) - { - if (n - class bsearch_callback_impl_simple_t : public bsearch_callback { - public: - int test(t_size p_index) const { - return m_compare(m_container[p_index],m_param); - } - bsearch_callback_impl_simple_t(const t_container & p_container,t_compare p_compare,const t_param & p_param) - : m_container(p_container), m_compare(p_compare), m_param(p_param) - { - } - private: - const t_container & m_container; - t_compare m_compare; - const t_param & m_param; - }; - - template - class bsearch_callback_impl_permutation_t : public bsearch_callback { - public: - int test(t_size p_index) const { - return m_compare(m_container[m_permutation[p_index]],m_param); - } - bsearch_callback_impl_permutation_t(const t_container & p_container,t_compare p_compare,const t_param & p_param,const t_permutation & p_permutation) - : m_container(p_container), m_compare(p_compare), m_param(p_param), m_permutation(p_permutation) - { - } - private: - const t_container & m_container; - t_compare m_compare; - const t_param & m_param; - const t_permutation & m_permutation; - }; - - - template - bool bsearch_t(t_size p_count,const t_container & p_container,t_compare p_compare,const t_param & p_param,t_size & p_index) { - return bsearch( - p_count, - bsearch_callback_impl_simple_t(p_container,p_compare,p_param), - p_index); - } - - template - bool bsearch_permutation_t(t_size p_count,const t_container & p_container,t_compare p_compare,const t_param & p_param,const t_permutation & p_permutation,t_size & p_index) { - t_size index; - if (bsearch( - p_count, - bsearch_callback_impl_permutation_t(p_container,p_compare,p_param,p_permutation), - index)) - { - p_index = p_permutation[index]; - return true; - } else { - return false; - } - } - - template - bool bsearch_range_t(const t_size p_count,const t_container & p_container,t_compare p_compare,const t_param & p_param,t_size & p_range_base,t_size & p_range_count) - { - t_size probe; - if (!bsearch( - p_count, - bsearch_callback_impl_simple_t(p_container,p_compare,p_param), - probe)) return false; - - t_size base = probe, count = 1; - while(base > 0 && p_compare(p_container[base-1],p_param) == 0) {base--; count++;} - while(base + count < p_count && p_compare(p_container[base+count],p_param) == 0) {count++;} - p_range_base = base; - p_range_count = count; - return true; - } - -} diff --git a/tools/vio2sf/src/foobar/pfc/bsearch_inline.h b/tools/vio2sf/src/foobar/pfc/bsearch_inline.h deleted file mode 100644 index 272a275a6..000000000 --- a/tools/vio2sf/src/foobar/pfc/bsearch_inline.h +++ /dev/null @@ -1,48 +0,0 @@ -namespace pfc { - - //deprecated - -template -inline bool bsearch_inline_t(t_size p_count, const t_callback & p_callback,t_size & p_result) -{ - t_size max = p_count; - t_size min = 0; - t_size ptr; - while(min> 1); - int result = p_callback.test(ptr); - if (result<0) min = ptr + 1; - else if (result>0) max = ptr; - else - { - p_result = ptr; - return true; - } - } - p_result = min; - return false; -} - -template -inline bool bsearch_simple_inline_t(const t_buffer & p_buffer,t_size p_count,t_value const & p_value,t_size & p_result) -{ - t_size max = p_count; - t_size min = 0; - t_size ptr; - while(min> 1); - if (p_value > p_buffer[ptr]) min = ptr + 1; - else if (p_value < p_buffer[ptr]) max = ptr; - else - { - p_result = ptr; - return true; - } - } - p_result = min; - return false; -} - -} diff --git a/tools/vio2sf/src/foobar/pfc/byte_order_helper.h b/tools/vio2sf/src/foobar/pfc/byte_order_helper.h deleted file mode 100644 index 778d44316..000000000 --- a/tools/vio2sf/src/foobar/pfc/byte_order_helper.h +++ /dev/null @@ -1,232 +0,0 @@ -#ifndef _PFC_BYTE_ORDER_HELPER_ -#define _PFC_BYTE_ORDER_HELPER_ - -namespace pfc { - void byteswap_raw(void * p_buffer,t_size p_bytes); - - template T byteswap_t(T p_source); - - template<> inline char byteswap_t(char p_source) {return p_source;} - template<> inline unsigned char byteswap_t(unsigned char p_source) {return p_source;} - -#ifdef _MSC_VER//does this even help with performance/size? - template<> inline wchar_t byteswap_t(wchar_t p_source) {return _byteswap_ushort(p_source);} - - template<> inline short byteswap_t(short p_source) {return _byteswap_ushort(p_source);} - template<> inline unsigned short byteswap_t(unsigned short p_source) {return _byteswap_ushort(p_source);} - - template<> inline int byteswap_t(int p_source) {return _byteswap_ulong(p_source);} - template<> inline unsigned int byteswap_t(unsigned int p_source) {return _byteswap_ulong(p_source);} - - template<> inline long byteswap_t(long p_source) {return _byteswap_ulong(p_source);} - template<> inline unsigned long byteswap_t(unsigned long p_source) {return _byteswap_ulong(p_source);} - - template<> inline long long byteswap_t(long long p_source) {return _byteswap_uint64(p_source);} - template<> inline unsigned long long byteswap_t(unsigned long long p_source) {return _byteswap_uint64(p_source);} -#else - template<> inline t_uint16 byteswap_t(t_uint16 p_source) {return ((p_source & 0xFF00) >> 8) | ((p_source & 0x00FF) << 8);} - template<> inline t_int16 byteswap_t(t_int16 p_source) {return byteswap_t(p_source);} - - template<> inline t_uint32 byteswap_t(t_uint32 p_source) {return ((p_source & 0xFF000000) >> 24) | ((p_source & 0x00FF0000) >> 8) | ((p_source & 0x0000FF00) << 8) | ((p_source & 0x000000FF) << 24);} - template<> inline t_int32 byteswap_t(t_int32 p_source) {return byteswap_t(p_source);} - - template<> inline t_uint64 byteswap_t(t_uint64 p_source) { - //optimizeme - byteswap_raw(&p_source,sizeof(p_source)); - return p_source; - } - template<> inline t_int64 byteswap_t(t_int64 p_source) {return byteswap_t(p_source);} - - template<> inline wchar_t byteswap_t(wchar_t p_source) { - return byteswap_t::t_unsigned>(p_source); - } -#endif - - template<> inline float byteswap_t(float p_source) { - float ret; - *(t_uint32*) &ret = byteswap_t(*(const t_uint32*)&p_source ); - return ret; - } - - template<> inline double byteswap_t(double p_source) { - double ret; - *(t_uint64*) &ret = byteswap_t(*(const t_uint64*)&p_source ); - return ret; - } - - //blargh at GUID byteswap issue - template<> inline GUID byteswap_t(GUID p_guid) { - GUID ret; - ret.Data1 = pfc::byteswap_t(p_guid.Data1); - ret.Data2 = pfc::byteswap_t(p_guid.Data2); - ret.Data3 = pfc::byteswap_t(p_guid.Data3); - ret.Data4[0] = p_guid.Data4[0]; - ret.Data4[1] = p_guid.Data4[1]; - ret.Data4[2] = p_guid.Data4[2]; - ret.Data4[3] = p_guid.Data4[3]; - ret.Data4[4] = p_guid.Data4[4]; - ret.Data4[5] = p_guid.Data4[5]; - ret.Data4[6] = p_guid.Data4[6]; - ret.Data4[7] = p_guid.Data4[7]; - return ret; - } - - - -}; - -#ifdef _MSC_VER - -#if defined(_M_IX86) || defined(_M_X64) -#define PFC_BYTE_ORDER_IS_BIG_ENDIAN 0 -#endif - -#else//_MSC_VER - -#include -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define PFC_BYTE_ORDER_IS_BIG_ENDIAN 0 -#else -#define PFC_BYTE_ORDER_IS_BIG_ENDIAN 1 -#endif - -#endif//_MSC_VER - -#ifdef PFC_BYTE_ORDER_IS_BIG_ENDIAN -#define PFC_BYTE_ORDER_IS_LITTLE_ENDIAN (!(PFC_BYTE_ORDER_IS_BIG_ENDIAN)) -#else -#error please update byte order #defines -#endif - - -namespace pfc { - enum { - byte_order_is_big_endian = PFC_BYTE_ORDER_IS_BIG_ENDIAN, - byte_order_is_little_endian = PFC_BYTE_ORDER_IS_LITTLE_ENDIAN, - }; - - template T byteswap_if_be_t(T p_param) {return byte_order_is_big_endian ? byteswap_t(p_param) : p_param;} - template T byteswap_if_le_t(T p_param) {return byte_order_is_little_endian ? byteswap_t(p_param) : p_param;} -} - -namespace byte_order { - -#if PFC_BYTE_ORDER_IS_BIG_ENDIAN//big endian - template inline void order_native_to_le_t(T& param) {param = pfc::byteswap_t(param);} - template inline void order_native_to_be_t(T& param) {} - template inline void order_le_to_native_t(T& param) {param = pfc::byteswap_t(param);} - template inline void order_be_to_native_t(T& param) {} -#else//little endian - template inline void order_native_to_le_t(T& param) {} - template inline void order_native_to_be_t(T& param) {param = pfc::byteswap_t(param);} - template inline void order_le_to_native_t(T& param) {} - template inline void order_be_to_native_t(T& param) {param = pfc::byteswap_t(param);} -#endif -}; - - - -namespace pfc { - template - class __EncodeIntHelper { - public: - inline static void Run(TInt p_value,t_uint8 * p_out) { - *p_out = (t_uint8)(p_value); - __EncodeIntHelper::Run(p_value >> 8,p_out + (IsBigEndian ? -1 : 1)); - } - }; - - template - class __EncodeIntHelper { - public: - inline static void Run(TInt p_value,t_uint8* p_out) { - *p_out = (t_uint8)(p_value); - } - }; - template - class __EncodeIntHelper { - public: - inline static void Run(TInt,t_uint8*) {} - }; - - template - inline void encode_little_endian(t_uint8 * p_buffer,TInt p_value) { - __EncodeIntHelper::Run(p_value,p_buffer); - } - template - inline void encode_big_endian(t_uint8 * p_buffer,TInt p_value) { - __EncodeIntHelper::Run(p_value,p_buffer + (sizeof(TInt) - 1)); - } - - - template - class __DecodeIntHelper { - public: - inline static TInt Run(const t_uint8 * p_in) { - return (__DecodeIntHelper::Run(p_in + (IsBigEndian ? -1 : 1)) << 8) + *p_in; - } - }; - - template - class __DecodeIntHelper { - public: - inline static TInt Run(const t_uint8* p_in) {return *p_in;} - }; - - template - class __DecodeIntHelper { - public: - inline static TInt Run(const t_uint8*) {return 0;} - }; - - template - inline void decode_little_endian(TInt & p_out,const t_uint8 * p_buffer) { - p_out = __DecodeIntHelper::Run(p_buffer); - } - - template - inline void decode_big_endian(TInt & p_out,const t_uint8 * p_buffer) { - p_out = __DecodeIntHelper::Run(p_buffer + (sizeof(TInt) - 1)); - } - - template - inline TInt decode_little_endian(const t_uint8 * p_buffer) { - TInt temp; - decode_little_endian(temp,p_buffer); - return temp; - } - - template - inline TInt decode_big_endian(const t_uint8 * p_buffer) { - TInt temp; - decode_big_endian(temp,p_buffer); - return temp; - } - - template - inline void decode_endian(TInt & p_out,const t_uint8 * p_buffer) { - if (IsBigEndian) decode_big_endian(p_out,p_buffer); - else decode_little_endian(p_out,p_buffer); - } - template - inline void encode_endian(t_uint8 * p_buffer,TInt p_in) { - if (IsBigEndian) encode_big_endian(p_in,p_value); - else encode_little_endian(p_in,p_value); - } - - - - template - inline static void reverse_bytes(t_uint8 * p_buffer) { - pfc::swap_t(p_buffer[0],p_buffer[width-1]); - reverse_bytes(p_buffer+1); - } - - template<> inline static void reverse_bytes<1>(t_uint8 * p_buffer) { } - template<> inline static void reverse_bytes<0>(t_uint8 * p_buffer) { } - -} - - - -#endif diff --git a/tools/vio2sf/src/foobar/pfc/chain_list_v2.h b/tools/vio2sf/src/foobar/pfc/chain_list_v2.h deleted file mode 100644 index a6d6b64f7..000000000 --- a/tools/vio2sf/src/foobar/pfc/chain_list_v2.h +++ /dev/null @@ -1,264 +0,0 @@ -namespace pfc { - - template - class __chain_list_elem : public _list_node { - public: - typedef _list_node t_node; - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(__chain_list_elem,t_node, {m_prev = m_next = NULL;}); - - typedef __chain_list_elem t_self; - - t_self * m_prev, * m_next; - - t_node * prev() throw() {return m_prev;} - t_node * next() throw() {return m_next;} - - //helper wrappers - void add_ref() throw() {this->refcount_add_ref();} - void release() throw() {this->refcount_release();} - //workaround for cross-list-relinking case - never actually deletes p_elem - void __release_temporary() throw() {this->_refcount_release_temporary();} - }; - - //! Differences between chain_list_v2_t<> and old chain_list_t<>: \n - //! Iterators pointing to removed items as well as to items belonging to no longer existing list objects remain valid but they're no longer walkable - as if the referenced item was the only item in the list. The old class invalidated iterators on deletion instead. - template - class chain_list_v2_t { - public: - typedef _t_item t_item; - typedef chain_list_v2_t t_self; - typedef ::pfc::iterator iterator; - typedef ::pfc::const_iterator const_iterator; - typedef __chain_list_elem t_elem; - - chain_list_v2_t() : m_first(), m_last(), m_count() {} - chain_list_v2_t(const t_self & p_source) : m_first(), m_last(), m_count() { - try { - *this = p_source; - } catch(...) { - remove_all(); - throw; - } - } - const t_self & operator=(const t_self & p_other) { - remove_all(); - for(t_elem * walk = p_other.m_first; walk != NULL; walk = walk->m_next) { - add_item(walk->m_content); - } - return *this; - } - - t_size get_count() const {return m_count;} - - iterator first() {return iterator(m_first);} - iterator last() {return iterator(m_last);} - const_iterator first() const {return const_iterator(m_first);} - const_iterator last() const {return const_iterator(m_last);} - - void remove_single(const_iterator const & p_iter) { - PFC_ASSERT(p_iter.is_valid()); - __unlink(_elem(p_iter)); - } - - void remove(const_iterator const & p_iter) { - PFC_ASSERT(p_iter.is_valid()); - __unlink(_elem(p_iter)); - } - - void remove_all() throw() { - while(m_first != NULL) __unlink(m_first); - PFC_ASSERT(m_count == 0); - } - void remove_range(const_iterator const & p_from,const_iterator const & p_to) { - for(t_elem * walk = _elem(p_from);;) { - if (walk == NULL) {PFC_ASSERT(!"Should not get here"); break;}//should not happen unless there is a bug in calling code - t_elem * next = walk->m_next; - __unlink(walk); - if (walk == _elem(p_to)) break; - walk = next; - } - } - - template void enumerate(t_callback & p_callback) const {__enumerate_chain(m_first,p_callback);} - template void enumerate(t_callback & p_callback) {__enumerate_chain(m_first,p_callback);} - - template bool remove_item(const t_source & p_item) { - t_elem * elem; - if (__find(elem,p_item)) { - __unlink(elem); - return true; - } else { - return false; - } - } - - ~chain_list_v2_t() {remove_all();} - - template - inline void add_item(const t_source & p_source) { - __link_last(new t_elem(p_source)); - } - template - inline t_self & operator+=(const t_source & p_source) { - add_item(p_source); return *this; - } - iterator insert_last() {return __link_last(new t_elem);} - iterator insert_first() {return __link_first(new t_elem);} - iterator insert_after(const_iterator const & p_iter) {return __link_next(_elem(p_iter),new t_elem);} - iterator insert_before(const_iterator const & p_iter) {return __link_prev(_elem(p_iter),new t_elem);} - template iterator insert_last(const t_source & p_source) {return __link_last(new t_elem(p_source));} - template iterator insert_first(const t_source & p_source) {return __link_first(new t_elem(p_source));} - template iterator insert_after(const_iterator const & p_iter,const t_source & p_source) {return __link_next(_elem(p_iter),new t_elem(p_source));} - template iterator insert_before(const_iterator const & p_iter,const t_source & p_source) {return __link_prev(_elem(p_iter),new t_elem(p_source));} - - template const_iterator find_item(const t_source & p_item) const { - t_elem * elem; - if (!__find(elem,p_item)) return const_iterator(); - return const_iterator(elem); - } - - template iterator find_item(const t_source & p_item) { - t_elem * elem; - if (!__find(elem,p_item)) return iterator(); - return iterator(elem); - } - - template bool have_item(const t_source & p_item) const { - t_elem * dummy; - return __find(dummy,p_item); - } - template void set_single(const t_source & p_item) { - remove_all(); add_item(p_item); - } - - //! Slow! - const_iterator by_index(t_size p_index) const {return __by_index(p_index);} - //! Slow! - iterator by_index(t_size p_index) {return __by_index(p_index);} - - t_self & operator<<(t_self & p_other) { - while(p_other.m_first != NULL) { - __link_last( p_other.__unlink_temporary(p_other.m_first) ); - } - return *this; - } - t_self & operator>>(t_self & p_other) { - while(m_last != NULL) { - p_other.__link_first(__unlink_temporary(m_last)); - } - return p_other; - } - //! Links an object that has been unlinked from another list. Unsafe. - void _link_last(const_iterator const& iter) { - PFC_ASSERT(iter.is_valid()); - PFC_ASSERT( _elem(iter)->m_prev == NULL && _elem(iter)->m_next == NULL ); - __link_last(_elem(iter)); - } - //! Links an object that has been unlinked from another list. Unsafe. - void _link_first(const_iterator const& iter) { - PFC_ASSERT(iter.is_valid()); - PFC_ASSERT( _elem(iter)->m_prev == NULL && _elem(iter)->m_next == NULL ); - __link_first(_elem(iter)); - } - private: - static t_elem * _elem(const_iterator const & iter) { - return static_cast(iter._node()); - } - t_elem * __by_index(t_size p_index) const { - t_elem * walk = m_first; - while(p_index > 0 && walk != NULL) { - p_index--; - walk = walk->m_next; - } - return walk; - } - template - static void __enumerate_chain(t_elemwalk * p_elem,t_callback & p_callback) { - t_elemwalk * walk = p_elem; - while(walk != NULL) { - p_callback(walk->m_content); - walk = walk->m_next; - } - } - - template bool __find(t_elem * & p_elem,const t_source & p_item) const { - for(t_elem * walk = m_first; walk != NULL; walk = walk->m_next) { - if (walk->m_content == p_item) { - p_elem = walk; return true; - } - } - return false; - } - - void __unlink_helper(t_elem * p_elem) throw() { - (p_elem->m_prev == NULL ? m_first : p_elem->m_prev->m_next) = p_elem->m_next; - (p_elem->m_next == NULL ? m_last : p_elem->m_next->m_prev) = p_elem->m_prev; - p_elem->m_next = p_elem->m_prev = NULL; - } - - //workaround for cross-list-relinking case - never actually deletes p_elem - t_elem * __unlink_temporary(t_elem * p_elem) throw() { - __unlink_helper(p_elem); - --m_count; p_elem->__release_temporary(); - return p_elem; - } - - t_elem * __unlink(t_elem * p_elem) throw() { - __unlink_helper(p_elem); - --m_count; p_elem->release(); - return p_elem; - } - void __on_link(t_elem * p_elem) throw() { - p_elem->add_ref(); ++m_count; - } - t_elem * __link_first(t_elem * p_elem) throw() { - __on_link(p_elem); - p_elem->m_next = m_first; - p_elem->m_prev = NULL; - (m_first == NULL ? m_last : m_first->m_prev) = p_elem; - m_first = p_elem; - return p_elem; - } - t_elem * __link_last(t_elem * p_elem) throw() { - __on_link(p_elem); - p_elem->m_prev = m_last; - p_elem->m_next = NULL; - (m_last == NULL ? m_first : m_last->m_next) = p_elem; - m_last = p_elem; - return p_elem; - } - t_elem * __link_next(t_elem * p_prev,t_elem * p_elem) throw() { - __on_link(p_elem); - p_elem->m_prev = p_prev; - p_elem->m_next = p_prev->m_next; - (p_prev->m_next != NULL ? p_prev->m_next->m_prev : m_last) = p_elem; - p_prev->m_next = p_elem; - return p_elem; - } - t_elem * __link_prev(t_elem * p_next,t_elem * p_elem) throw() { - __on_link(p_elem); - p_elem->m_next = p_next; - p_elem->m_prev = p_next->m_prev; - (p_next->m_prev != NULL ? p_next->m_prev->m_next : m_first) = p_elem; - p_next->m_prev = p_elem; - return p_elem; - } - t_elem * m_first, * m_last; - t_size m_count; - }; - - - template class traits_t > : public traits_default_movable {}; - - class __chain_list_iterator_traits : public traits_default_movable { - public: - enum { - constructor_may_fail = false - }; - }; - - template class traits_t > : public traits_t > > {}; - - template class traits_t > : public traits_t > {}; - -}//namespace pfc diff --git a/tools/vio2sf/src/foobar/pfc/com_ptr_t.h b/tools/vio2sf/src/foobar/pfc/com_ptr_t.h deleted file mode 100644 index 2a309513e..000000000 --- a/tools/vio2sf/src/foobar/pfc/com_ptr_t.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifdef _WIN32 -namespace pfc { - - static void _COM_AddRef(IUnknown * ptr) { - if (ptr != NULL) ptr->AddRef(); - } - static void _COM_Release(IUnknown * ptr) { - if (ptr != NULL) ptr->Release(); - } - - template - class com_ptr_t { - public: - typedef com_ptr_t t_self; - - inline com_ptr_t() throw() : m_ptr() {} - template inline com_ptr_t(source * p_ptr) throw() : m_ptr(p_ptr) {_COM_AddRef(m_ptr);;} - inline com_ptr_t(const t_self & p_source) throw() : m_ptr(p_source.m_ptr) {_COM_AddRef(m_ptr);} - template inline com_ptr_t(const com_ptr_t & p_source) throw() : m_ptr(p_source.get_ptr()) {_COM_AddRef(m_ptr);} - - inline ~com_ptr_t() throw() {_COM_Release(m_ptr);} - - inline void copy(T * p_ptr) throw() { - _COM_Release(m_ptr); - m_ptr = p_ptr; - _COM_AddRef(m_ptr); - } - - template inline void copy(const com_ptr_t & p_source) throw() {copy(p_source.get_ptr());} - - inline void attach(T * p_ptr) throw() { - _COM_Release(m_ptr); - m_ptr = p_ptr; - } - - inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;} - inline const t_self & operator=(T* p_source) throw() {copy(p_source); return *this;} - template inline const t_self & operator=(const com_ptr_t & p_source) throw() {copy(p_source); return *this;} - template inline const t_self & operator=(source * p_ptr) throw() {copy(p_ptr); return *this;} - - inline void release() throw() { - _COM_Release(m_ptr); - m_ptr = NULL; - } - - - inline T* operator->() const throw() {assert(m_ptr);return m_ptr;} - - inline T* get_ptr() const throw() {return m_ptr;} - - inline T* duplicate_ptr() const throw() //should not be used ! temporary ! - { - _COM_AddRef(m_ptr); - return m_ptr; - } - - inline T* detach() throw() { - return replace_null_t(m_ptr); - } - - inline bool is_valid() const throw() {return m_ptr != 0;} - inline bool is_empty() const throw() {return m_ptr == 0;} - - inline bool operator==(const com_ptr_t & p_item) const throw() {return m_ptr == p_item.m_ptr;} - inline bool operator!=(const com_ptr_t & p_item) const throw() {return m_ptr != p_item.m_ptr;} - inline bool operator>(const com_ptr_t & p_item) const throw() {return m_ptr > p_item.m_ptr;} - inline bool operator<(const com_ptr_t & p_item) const throw() {return m_ptr < p_item.m_ptr;} - - inline static void g_swap(com_ptr_t & item1, com_ptr_t & item2) throw() { - pfc::swap_t(item1.m_ptr,item2.m_ptr); - } - - inline T** receive_ptr() throw() {release();return &m_ptr;} - - inline t_self & operator<<(t_self & p_source) throw() {attach(p_source.detach());return *this;} - inline t_self & operator>>(t_self & p_dest) throw() {p_dest.attach(detach());return *this;} - private: - T* m_ptr; - }; - -} -#endif diff --git a/tools/vio2sf/src/foobar/pfc/guid.cpp b/tools/vio2sf/src/foobar/pfc/guid.cpp deleted file mode 100644 index ed0fc0208..000000000 --- a/tools/vio2sf/src/foobar/pfc/guid.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "pfc.h" - -namespace pfc { -/* -6B29FC40-CA47-1067-B31D-00DD010662DA -. -typedef struct _GUID { // size is 16 - DWORD Data1; - WORD Data2; - WORD Data3; - BYTE Data4[8]; -} GUID; - -// {B296CF59-4D51-466f-8E0B-E57D3F91D908} -static const GUID <> = -{ 0xb296cf59, 0x4d51, 0x466f, { 0x8e, 0xb, 0xe5, 0x7d, 0x3f, 0x91, 0xd9, 0x8 } }; - -*/ - -unsigned GUID_from_text::read_hex(char c) -{ - if (c>='0' && c<='9') return (unsigned)c - '0'; - else if (c>='a' && c<='f') return 0xa + (unsigned)c - 'a'; - else if (c>='A' && c<='F') return 0xa + (unsigned)c - 'A'; - else return 0; -} - -unsigned GUID_from_text::read_byte(const char * ptr) -{ - return (read_hex(ptr[0])<<4) | read_hex(ptr[1]); -} -unsigned GUID_from_text::read_word(const char * ptr) -{ - return (read_byte(ptr)<<8) | read_byte(ptr+2); -} - -unsigned GUID_from_text::read_dword(const char * ptr) -{ - return (read_word(ptr)<<16) | read_word(ptr+4); -} - -void GUID_from_text::read_bytes(BYTE * out,unsigned num,const char * ptr) -{ - for(;num;num--) - { - *out = read_byte(ptr); - out++;ptr+=2; - } -} - - -GUID_from_text::GUID_from_text(const char * text) -{ - if (*text=='{') text++; - const char * max; - - { - const char * t = strchr(text,'}'); - if (t) max = t; - else max = text + strlen(text); - } - - (GUID)*this = pfc::guid_null; - - - do { - if (text+8>max) break; - Data1 = read_dword(text); - text += 8; - while(*text=='-') text++; - if (text+4>max) break; - Data2 = read_word(text); - text += 4; - while(*text=='-') text++; - if (text+4>max) break; - Data3 = read_word(text); - text += 4; - while(*text=='-') text++; - if (text+4>max) break; - read_bytes(Data4,2,text); - text += 4; - while(*text=='-') text++; - if (text+12>max) break; - read_bytes(Data4+2,6,text); - } while(false); -} - - -static inline char print_hex_digit(unsigned val) -{ - static const char table[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - assert((val & ~0xF) == 0); - return table[val]; -} - -static void print_hex(unsigned val,char * &out,unsigned bytes) -{ - unsigned n; - for(n=0;n> ((bytes - 1 - n) << 3)) & 0xFF); - *(out++) = print_hex_digit( c >> 4 ); - *(out++) = print_hex_digit( c & 0xF ); - } - *out = 0; -} - - -print_guid::print_guid(const GUID & p_guid) -{ - char * out = m_data; - print_hex(p_guid.Data1,out,4); - *(out++) = '-'; - print_hex(p_guid.Data2,out,2); - *(out++) = '-'; - print_hex(p_guid.Data3,out,2); - *(out++) = '-'; - print_hex(p_guid.Data4[0],out,1); - print_hex(p_guid.Data4[1],out,1); - *(out++) = '-'; - print_hex(p_guid.Data4[2],out,1); - print_hex(p_guid.Data4[3],out,1); - print_hex(p_guid.Data4[4],out,1); - print_hex(p_guid.Data4[5],out,1); - print_hex(p_guid.Data4[6],out,1); - print_hex(p_guid.Data4[7],out,1); - *out = 0; -} - - -void print_hex_raw(const void * buffer,unsigned bytes,char * p_out) -{ - char * out = p_out; - const unsigned char * in = (const unsigned char *) buffer; - unsigned n; - for(n=0;n inline int compare_t(const GUID & p_item1,const GUID & p_item2) {return guid_compare(p_item1,p_item2);} - - extern const GUID guid_null; - - void print_hex_raw(const void * buffer,unsigned bytes,char * p_out); - - static GUID makeGUID(t_uint32 Data1, t_uint16 Data2, t_uint16 Data3, t_uint8 Data4_1, t_uint8 Data4_2, t_uint8 Data4_3, t_uint8 Data4_4, t_uint8 Data4_5, t_uint8 Data4_6, t_uint8 Data4_7, t_uint8 Data4_8) { - GUID guid = { Data1, Data2, Data3, {Data4_1, Data4_2, Data4_3, Data4_4, Data4_5, Data4_6, Data4_7, Data4_8 } }; - return guid; - } - static GUID xorGUID(const GUID & v1, const GUID & v2) { - GUID temp; memxor(&temp, &v1, &v1, sizeof(GUID)); return temp; - } -} - - -#endif diff --git a/tools/vio2sf/src/foobar/pfc/instance_tracker.h b/tools/vio2sf/src/foobar/pfc/instance_tracker.h deleted file mode 100644 index fb3bb3b99..000000000 --- a/tools/vio2sf/src/foobar/pfc/instance_tracker.h +++ /dev/null @@ -1,49 +0,0 @@ -namespace pfc { - template - class instance_tracker_server_t { - public: - void add(t_object * p_object) { - m_list.add_item(p_object); - } - void remove(t_object * p_object) { - m_list.remove_item(p_object); - } - - t_size get_count() const {return m_list.get_count();} - t_object * get_item(t_size p_index) {return m_list[p_index];} - t_object * operator[](t_size p_index) {return m_list[p_index];} - - private: - ptr_list_hybrid_t m_list; - }; - - - template & p_server> - class instance_tracker_client_t { - public: - instance_tracker_client_t(t_object* p_ptr) : m_ptr(NULL), m_added(false) {initialize(p_ptr);} - instance_tracker_client_t() : m_ptr(NULL), m_added(false) {} - - void initialize(t_object * p_ptr) { - uninitialize(); - p_server.add(p_ptr); - m_ptr = p_ptr; - m_added = true; - } - - void uninitialize() { - if (m_added) { - p_server.remove(m_ptr); - m_ptr = NULL; - m_added = false; - } - } - - ~instance_tracker_client_t() { - uninitialize(); - } - private: - bool m_added; - t_object * m_ptr; - }; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/int_types.h b/tools/vio2sf/src/foobar/pfc/int_types.h deleted file mode 100644 index 4d2c4af71..000000000 --- a/tools/vio2sf/src/foobar/pfc/int_types.h +++ /dev/null @@ -1,120 +0,0 @@ -#if !defined(_MSC_VER) && !defined(_EVC_VER) -#include -typedef int64_t t_int64; -typedef uint64_t t_uint64; -typedef int32_t t_int32; -typedef uint32_t t_uint32; -typedef int16_t t_int16; -typedef uint16_t t_uint16; -typedef int8_t t_int8; -typedef uint8_t t_uint8; -#else -typedef __int64 t_int64; -typedef unsigned __int64 t_uint64; -typedef __int32 t_int32; -typedef unsigned __int32 t_uint32; -typedef __int16 t_int16; -typedef unsigned __int16 t_uint16; -typedef __int8 t_int8; -typedef unsigned __int8 t_uint8; -#endif - -typedef int t_int; -typedef unsigned int t_uint; - -typedef float t_float32; -typedef double t_float64; - - - -#if defined(_WIN32) && !defined(_WIN64) -#define __PFC_WP64 __w64 -#else -#define __PFC_WP64 -#endif - - -namespace pfc { - template - class sized_int_t; - - template<> class sized_int_t<1> { - public: - typedef t_uint8 t_unsigned; - typedef t_int8 t_signed; - }; - - template<> class sized_int_t<2> { - public: - typedef t_uint16 t_unsigned; - typedef t_int16 t_signed; - }; - - template<> class sized_int_t<4> { - public: - typedef t_uint32 t_unsigned; - typedef t_int32 t_signed; - }; - - template<> class sized_int_t<8> { - public: - typedef t_uint64 t_unsigned; - typedef t_int64 t_signed; - }; -} - - -typedef pfc::sized_int_t::t_unsigned __PFC_WP64 t_size; -typedef pfc::sized_int_t::t_signed __PFC_WP64 t_ssize; - - -#define infinite (~0) - -const t_uint16 infinite16 = (t_uint16)(~0); -const t_uint32 infinite32 = (t_uint32)(~0); -const t_uint64 infinite64 = (t_uint64)(~0); -const t_size infinite_size = (t_size)(~0); - - -#if defined(_WIN32) && !defined(_WIN64) -inline t_size MulDiv_Size(t_size x,t_size y,t_size z) {return (t_size) ( ((t_uint64)x * (t_uint64)y) / (t_uint64)z );} -#elif defined(_WIN64) -inline t_size MulDiv_Size(t_size x,t_size y,t_size z) {return (x*y)/z;} -#else -#error portme -#endif - - -namespace pfc { - template class int_specs_t; - - template - class int_specs_signed_t { - public: - inline static T get_min() {return ((T)1<<(sizeof(T)*8-1));} - inline static T get_max() {return ~((T)1<<(sizeof(T)*8-1));} - enum {is_signed = true}; - }; - - template - class int_specs_unsigned_t { - public: - inline static T get_min() {return (T)0;} - inline static T get_max() {return (T)~0;} - enum {is_signed = false}; - }; - - template<> class int_specs_t : public int_specs_signed_t {}; - template<> class int_specs_t : public int_specs_unsigned_t {}; - template<> class int_specs_t : public int_specs_signed_t {}; - template<> class int_specs_t : public int_specs_unsigned_t {}; - template<> class int_specs_t : public int_specs_signed_t {}; - template<> class int_specs_t : public int_specs_unsigned_t {}; - template<> class int_specs_t : public int_specs_signed_t {}; - template<> class int_specs_t : public int_specs_unsigned_t {}; - template<> class int_specs_t : public int_specs_signed_t {}; - template<> class int_specs_t : public int_specs_unsigned_t {}; - - template<> class int_specs_t : public int_specs_unsigned_t {}; - -}; diff --git a/tools/vio2sf/src/foobar/pfc/iterators.h b/tools/vio2sf/src/foobar/pfc/iterators.h deleted file mode 100644 index 5455990cc..000000000 --- a/tools/vio2sf/src/foobar/pfc/iterators.h +++ /dev/null @@ -1,113 +0,0 @@ -namespace pfc { - //! Base class for list nodes. Implemented by list implementers. - template class _list_node : public refcounted_object_root { - public: - typedef _list_node t_self; - - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(_list_node,m_content) - - t_item m_content; - - virtual t_self * prev() throw() {return NULL;} - virtual t_self * next() throw() {return NULL;} - - t_self * walk(bool forward) throw() {return forward ? next() : prev();} - }; - - template class const_iterator { - public: - typedef _list_node t_node; - typedef refcounted_object_ptr_t t_nodeptr; - typedef const_iterator t_self; - - bool is_empty() const throw() {return m_content.is_empty();} - bool is_valid() const throw() {return m_content.is_valid();} - void invalidate() throw() {m_content = NULL;} - - void walk(bool forward) throw() {m_content = m_content->walk(forward);} - void prev() throw() {m_content = m_content->prev();} - void next() throw() {m_content = m_content->next();} - - //! For internal use / list implementations only! Do not call! - t_node* _node() const throw() {return m_content.get_ptr();} - - const_iterator() {} - const_iterator(t_node* source) : m_content(source) {} - const_iterator(t_nodeptr const & source) : m_content(source) {} - - const t_item& operator*() const throw() {return m_content->m_content;} - const t_item* operator->() const throw() {return &m_content->m_content;} - - const t_self & operator++() throw() {this->next(); return *this;} - const t_self & operator--() throw() {this->prev(); return *this;} - t_self operator++(int) throw() {t_self old = *this; this->next(); return old;} - t_self operator--(int) throw() {t_self old = *this; this->prev(); return old;} - - bool operator==(const t_self & other) const throw() {return this->m_content == other.m_content;} - bool operator!=(const t_self & other) const throw() {return this->m_content != other.m_content;} - bool operator> (const t_self & other) const throw() {return this->m_content > other.m_content;} - bool operator< (const t_self & other) const throw() {return this->m_content < other.m_content;} - bool operator>=(const t_self & other) const throw() {return this->m_content >= other.m_content;} - bool operator<=(const t_self & other) const throw() {return this->m_content <= other.m_content;} - protected: - t_nodeptr m_content; - }; - template class iterator : public const_iterator { - public: - typedef const_iterator t_selfConst; - typedef iterator t_self; - typedef _list_node t_node; - typedef refcounted_object_ptr_t t_nodeptr; - - iterator() {} - iterator(t_node* source) : t_selfConst(source) {} - iterator(t_nodeptr const & source) : t_selfConst(source) {} - - t_item& operator*() const throw() {return this->m_content->m_content;} - t_item* operator->() const throw() {return &this->m_content->m_content;} - - const t_self & operator++() throw() {this->next(); return *this;} - const t_self & operator--() throw() {this->prev(); return *this;} - t_self operator++(int) throw() {t_self old = *this; this->next(); return old;} - t_self operator--(int) throw() {t_self old = *this; this->prev(); return old;} - - bool operator==(const t_self & other) const throw() {return this->m_content == other.m_content;} - bool operator!=(const t_self & other) const throw() {return this->m_content != other.m_content;} - bool operator> (const t_self & other) const throw() {return this->m_content > other.m_content;} - bool operator< (const t_self & other) const throw() {return this->m_content < other.m_content;} - bool operator>=(const t_self & other) const throw() {return this->m_content >= other.m_content;} - bool operator<=(const t_self & other) const throw() {return this->m_content <= other.m_content;} - }; - - template - class comparator_list { - public: - template - static int compare(const t_list1 & p_list1, const t_list2 p_list2) { - typename t_list1::const_iterator iter1 = p_list1.first(); - typename t_list2::const_iterator iter2 = p_list2.first(); - for(;;) { - if (iter1.is_empty() && iter2.is_empty()) return 0; - else if (iter1.is_empty()) return -1; - else if (iter2.is_empty()) return 1; - else { - int state = t_comparator::compare(*iter1,*iter2); - if (state != 0) return state; - } - ++iter1; ++iter2; - } - } - }; - - template - static bool listEquals(const t_list1 & p_list1, const t_list2 & p_list2) { - typename t_list1::const_iterator iter1 = p_list1.first(); - typename t_list2::const_iterator iter2 = p_list2.first(); - for(;;) { - if (iter1.is_empty() && iter2.is_empty()) return true; - else if (iter1.is_empty() || iter2.is_empty()) return false; - else if (*iter1 != *iter2) return false; - ++iter1; ++iter2; - } - } -} diff --git a/tools/vio2sf/src/foobar/pfc/license.txt b/tools/vio2sf/src/foobar/pfc/license.txt deleted file mode 100644 index 55dc500fb..000000000 --- a/tools/vio2sf/src/foobar/pfc/license.txt +++ /dev/null @@ -1,10 +0,0 @@ -Copyright (c) 2001-2008, Peter Pawlowski -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/vio2sf/src/foobar/pfc/list.h b/tools/vio2sf/src/foobar/pfc/list.h deleted file mode 100644 index 7b243b875..000000000 --- a/tools/vio2sf/src/foobar/pfc/list.h +++ /dev/null @@ -1,591 +0,0 @@ -#ifndef _PFC_LIST_H_ -#define _PFC_LIST_H_ - -namespace pfc { - -template -class NOVTABLE list_base_const_t { -private: typedef list_base_const_t t_self; -public: - typedef T t_item; - virtual t_size get_count() const = 0; - virtual void get_item_ex(T& p_out, t_size n) const = 0; - - inline t_size get_size() const {return get_count();} - - inline T get_item(t_size n) const {T temp; get_item_ex(temp,n); return temp;} - inline T operator[](t_size n) const {T temp; get_item_ex(temp,n); return temp;} - - template - t_size find_duplicates_sorted_t(t_compare p_compare,bit_array_var & p_out) const - { - return pfc::find_duplicates_sorted_t const &,t_compare>(*this,get_count(),p_compare,p_out); - } - - template - t_size find_duplicates_sorted_permutation_t(t_compare p_compare,t_permutation const & p_permutation,bit_array_var & p_out) - { - return pfc::find_duplicates_sorted_permutation_t const &,t_compare,t_permutation>(*this,get_count(),p_compare,p_permutation,p_out); - } - - template - t_size find_item(const t_search & p_item) const//returns index of first occurance, infinite if not found - { - t_size n,max = get_count(); - for(n=0;n - inline bool have_item(const t_search & p_item) const {return find_item(p_item)!=~0;} - - - template - bool bsearch_t(t_compare p_compare,t_param const & p_param,t_size &p_index) const { - return pfc::bsearch_t(get_count(),*this,p_compare,p_param,p_index); - } - - template - bool bsearch_permutation_t(t_compare p_compare,t_param const & p_param,const t_permutation & p_permutation,t_size & p_index) const { - return pfc::bsearch_permutation_t(get_count(),*this,p_compare,p_param,p_permutation,p_index); - } - - template - void sort_get_permutation_t(t_compare p_compare,t_permutation const & p_permutation) const { - pfc::sort_get_permutation_t,t_compare,t_permutation>(*this,p_compare,get_count(),p_permutation); - } - - template - void sort_stable_get_permutation_t(t_compare p_compare,t_permutation const & p_permutation) const { - pfc::sort_stable_get_permutation_t,t_compare,t_permutation>(*this,p_compare,get_count(),p_permutation); - } - - template - void enumerate(t_callback & p_callback) const { - for(t_size n = 0, m = get_count(); n < m; ++n ) { - p_callback( (*this)[n] ); - } - } - - static bool g_equals(const t_self & item1, const t_self & item2) { - const t_size count = item1.get_count(); - if (count != item2.get_count()) return false; - for(t_size walk = 0; walk < count; ++walk) if (item1[walk] != item2[walk]) return false; - return true; - } - bool operator==(const t_self & item2) const {return g_equals(*this,item2);} - bool operator!=(const t_self & item2) const {return !g_equals(*this,item2);} - -protected: - list_base_const_t() {} - ~list_base_const_t() {} -private: - const t_self & operator=(const t_self &) {throw pfc::exception_not_implemented();} -}; - - -template -class list_single_ref_t : public list_base_const_t -{ -public: - list_single_ref_t(const T & p_item,t_size p_count = 1) : m_item(p_item), m_count(p_count) {} - t_size get_count() const {return m_count;} - void get_item_ex(T& p_out,t_size n) const {PFC_ASSERT(n -class list_partial_ref_t : public list_base_const_t -{ -public: - list_partial_ref_t(const list_base_const_t & p_list,t_size p_base,t_size p_count) - : m_list(p_list), m_base(p_base), m_count(p_count) - { - PFC_ASSERT(m_base + m_count <= m_list.get_count()); - } - -private: - const list_base_const_t & m_list; - t_size m_base,m_count; - - t_size get_count() const {return m_count;} - void get_item_ex(T & p_out,t_size n) const {m_list.get_item_ex(p_out,n+m_base);} -}; - -template -class list_const_array_t : public list_base_const_t -{ -public: - inline list_const_array_t(A p_data,t_size p_count) : m_data(p_data), m_count(p_count) {} - t_size get_count() const {return m_count;} - void get_item_ex(T & p_out,t_size n) const {p_out = m_data[n];} -private: - A m_data; - t_size m_count; -}; - -template -class list_const_cast_t : public list_base_const_t -{ -public: - list_const_cast_t(const list_base_const_t & p_from) : m_from(p_from) {} - t_size get_count() const {return m_from.get_count();} - void get_item_ex(to & p_out,t_size n) const - { - from temp; - m_from.get_item_ex(temp,n); - p_out = temp; - } -private: - const list_base_const_t & m_from; -}; - -template -class ptr_list_const_array_t : public list_base_const_t -{ -public: - inline ptr_list_const_array_t(A p_data,t_size p_count) : m_data(p_data), m_count(p_count) {} - t_size get_count() const {return m_count;} - void get_item_ex(T* & p_out,t_size n) const {p_out = &m_data[n];} -private: - A m_data; - t_size m_count; -}; -template -class list_const_ptr_t : public list_base_const_t -{ -public: - inline list_const_ptr_t(const T * p_data,t_size p_count) : m_data(p_data), m_count(p_count) {} - t_size get_count() const {return m_count;} - void get_item_ex(T & p_out,t_size n) const {p_out = m_data[n];} -private: - const T * m_data; - t_size m_count; -}; - -template -class NOVTABLE list_base_t : public list_base_const_t { -private: - typedef list_base_t t_self; - typedef const list_base_const_t t_self_const; -public: - class NOVTABLE sort_callback - { - public: - virtual int compare(const T& p_item1,const T& p_item2) = 0; - }; - - virtual void filter_mask(const bit_array & mask) = 0; - virtual t_size insert_items(const list_base_const_t & items,t_size base) = 0; - virtual void reorder_partial(t_size p_base,const t_size * p_data,t_size p_count) = 0; - virtual void sort(sort_callback & p_callback) = 0; - virtual void sort_stable(sort_callback & p_callback) = 0; - virtual void replace_item(t_size p_index,const T& p_item) = 0; - virtual void swap_item_with(t_size p_index,T & p_item) = 0; - virtual void swap_items(t_size p_index1,t_size p_index2) = 0; - - inline void reorder(const t_size * p_data) {reorder_partial(0,p_data,this->get_count());} - - inline t_size insert_item(const T & item,t_size base) {return insert_items(list_single_ref_t(item),base);} - t_size insert_items_repeat(const T & item,t_size num,t_size base) {return insert_items(list_single_ref_t(item,num),base);} - inline t_size add_items_repeat(T item,t_size num) {return insert_items_repeat(item,num,this->get_count());} - t_size insert_items_fromptr(const T* source,t_size num,t_size base) {return insert_items(list_const_ptr_t(source,num),base);} - inline t_size add_items_fromptr(const T* source,t_size num) {return insert_items_fromptr(source,num,this->get_count());} - - inline t_size add_items(const list_base_const_t & items) {return insert_items(items,this->get_count());} - inline t_size add_item(const T& item) {return insert_item(item,this->get_count());} - - inline void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));} - inline void remove_all() {filter_mask(bit_array_false());} - inline void truncate(t_size val) {if (val < this->get_count()) remove_mask(bit_array_range(val,this->get_count()-val,true));} - - inline T replace_item_ex(t_size p_index,const T & p_item) {T ret = p_item;swap_item_with(p_index,ret);return ret;} - - inline T operator[](t_size n) const {return this->get_item(n);} - - template - class sort_callback_impl_t : public sort_callback - { - public: - sort_callback_impl_t(t_compare p_compare) : m_compare(p_compare) {} - int compare(const T& p_item1,const T& p_item2) {return m_compare(p_item1,p_item2);} - private: - t_compare m_compare; - }; - - class sort_callback_auto : public sort_callback - { - public: - int compare(const T& p_item1,const T& p_item2) {return pfc::compare_t(p_item1,p_item2);} - }; - - void sort() {sort(sort_callback_auto());} - template void sort_t(t_compare p_compare) {sort(sort_callback_impl_t(p_compare));} - template void sort_stable_t(t_compare p_compare) {sort_stable(sort_callback_impl_t(p_compare));} - - template void sort_remove_duplicates_t(t_compare p_compare) - { - sort_t(p_compare); - bit_array_bittable array(this->get_count()); - if (this->template find_duplicates_sorted_t(p_compare,array) > 0) - remove_mask(array); - } - - template void sort_stable_remove_duplicates_t(t_compare p_compare) - { - sort_stable_t(p_compare); - bit_array_bittable array(this->get_count()); - if (this->template find_duplicates_sorted_t(p_compare,array) > 0) - remove_mask(array); - } - - - template void remove_duplicates_t(t_compare p_compare) - { - order_helper order(this->get_count()); - sort_get_permutation_t(p_compare,order); - bit_array_bittable array(this->get_count()); - if (this->template find_duplicates_sorted_permutation_t(p_compare,order,array) > 0) - remove_mask(array); - } - - template - void for_each(t_func p_func) { - t_size n,max=this->get_count(); - for(n=0;nget_item(n)); - } - - template - void for_each(t_func p_func,const bit_array & p_mask) { - t_size n,max=this->get_count(); - for(n=p_mask.find(true,0,max);nget_item(n)); - } - } - - template - void remove_mask_ex(const bit_array & p_mask,t_releasefunc p_func) { - this->template for_each(p_func,p_mask); - remove_mask(p_mask); - } - - template - void remove_all_ex(t_releasefunc p_func) { - this->template for_each(p_func); - remove_all(); - } - - const t_self & operator=(const t_self & p_source) {remove_all(); add_items(p_source);return *this;} - const t_self & operator=(t_self_const & source) {remove_all(); add_items(source); return *this;} - const t_self & operator+=(t_self_const & p_source) {add_items(p_source); return *this;} - -protected: - list_base_t() {} - ~list_base_t() {} -}; - - -template -class list_impl_t : public list_base_t -{ -public: - list_impl_t() {} - list_impl_t(const list_impl_t & p_source) { *this = p_source; } - - void prealloc(t_size count) {m_buffer.prealloc(count);} - - void set_count(t_size p_count) {m_buffer.set_size(p_count);} - void set_size(t_size p_count) {m_buffer.set_size(p_count);} - - t_size insert_item(const T& item,t_size idx) - { - t_size max = m_buffer.get_size(); - if (idx > max) idx = max; - max++; - m_buffer.set_size(max); - t_size n; - for(n=max-1;n>idx;n--) - m_buffer[n]=m_buffer[n-1]; - m_buffer[idx]=item; - return idx; - } - - T remove_by_idx(t_size idx) - { - T ret = m_buffer[idx]; - t_size n; - t_size max = m_buffer.get_size(); - for(n=idx+1;n=0); - PFC_ASSERT(n=0); - PFC_ASSERT(n= 0); - PFC_ASSERT(n < get_count() ); - return m_buffer[n]; - }; - - inline t_size get_count() const {return m_buffer.get_size();} - inline t_size get_size() const {return get_count();} - - inline const T & operator[](t_size n) const - { - PFC_ASSERT(n>=0); - PFC_ASSERT(n & source,t_size base) - { - t_size count = get_count(); - if (base>count) base = count; - t_size num = source.get_count(); - m_buffer.set_size(count+num); - if (count > base) - { - t_size n; - for(n=count-1;(int)n>=(int)base;n--) - { - pfc::swap_t(m_buffer[n+num],m_buffer[n]); - } - } - - { - t_size n; - for(n=0;n & out,const bit_array & mask) - { - t_size n,count = get_count(); - for_each_bit_array(n,mask,true,0,count) - out.add_item(m_buffer[n]); - } - - void filter_mask(const bit_array & mask) - { - t_size n,count = get_count(), total = 0; - - n = total = mask.find(false,0,count); - - if (n=0); - PFC_ASSERT(idx wrapper(m_buffer); - pfc::sort(wrapper,get_count()); - } - - template - void sort_t(t_compare p_compare) - { - pfc::sort_callback_impl_simple_wrap_t wrapper(m_buffer,p_compare); - pfc::sort(wrapper,get_count()); - } - - template - void sort_stable_t(t_compare p_compare) - { - pfc::sort_callback_impl_simple_wrap_t wrapper(m_buffer,p_compare); - pfc::sort_stable(wrapper,get_count()); - } - inline void reorder_partial(t_size p_base,const t_size * p_order,t_size p_count) - { - PFC_ASSERT(p_base+p_count<=get_count()); - pfc::reorder_partial_t(m_buffer,p_base,p_order,p_count); - } - - template - t_size find_duplicates_sorted_t(t_compare p_compare,bit_array_var & p_out) const - { - return pfc::find_duplicates_sorted_t const &,t_compare>(*this,get_count(),p_compare,p_out); - } - - template - t_size find_duplicates_sorted_permutation_t(t_compare p_compare,t_permutation p_permutation,bit_array_var & p_out) - { - return pfc::find_duplicates_sorted_permutation_t const &,t_compare,t_permutation>(*this,get_count(),p_compare,p_permutation,p_out); - } - - -private: - class sort_callback_wrapper - { - public: - explicit inline sort_callback_wrapper(sort_callback & p_callback) : m_callback(p_callback) {} - inline int operator()(const T& item1,const T& item2) const {return m_callback.compare(item1,item2);} - private: - sort_callback & m_callback; - }; -public: - void sort(sort_callback & p_callback) - { - sort_t(sort_callback_wrapper(p_callback)); - } - - void sort_stable(sort_callback & p_callback) - { - sort_stable_t(sort_callback_wrapper(p_callback)); - } - - void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));} - - void remove_mask(const bool * mask) {remove_mask(bit_array_table(mask,get_count()));} - void filter_mask(const bool * mask) {filter_mask(bit_array_table(mask,get_count()));} - - t_size add_item(const T& item) - { - t_size idx = get_count(); - insert_item(item,idx); - return idx; - } - - void remove_all() {remove_mask(bit_array_true());} - - void remove_item(const T& item) - { - t_size n,max = get_count(); - bit_array_bittable mask(max); - for(n=0;n & p_item1,list_impl_t & p_item2) - { - pfc::swap_t(p_item1.m_buffer,p_item2.m_buffer); - } - - template - t_size find_item(const t_search & p_item) const//returns index of first occurance, infinite if not found - { - t_size n,max = get_count(); - for(n=0;n - inline bool have_item(const t_search & p_item) const {return this->template find_item(p_item)!=~0;} - -protected: - t_storage m_buffer; -}; - -template class t_alloc = pfc::alloc_fast > -class list_t : public list_impl_t > { }; - -template class t_alloc = pfc::alloc_fast > -class list_hybrid_t : public list_impl_t > {}; - -template -class ptr_list_const_cast_t : public list_base_const_t -{ -public: - inline ptr_list_const_cast_t(const list_base_const_t & p_param) : m_param(p_param) {} - t_size get_count() const {return m_param.get_count();} - void get_item_ex(const T * & p_out,t_size n) const {T* temp; m_param.get_item_ex(temp,n); p_out = temp;} -private: - const list_base_const_t & m_param; - -}; - - -template -class list_const_permutation_t : public list_base_const_t -{ -public: - inline list_const_permutation_t(const list_base_const_t & p_list,P p_permutation) : m_list(p_list), m_permutation(p_permutation) {} - t_size get_count() const {return m_list.get_count();} - void get_item_ex(T & p_out,t_size n) const {m_list.get_item_ex(p_out,m_permutation[n]);} -private: - P m_permutation; - const list_base_const_t & m_list; -}; - - -template -class list_permutation_t : public list_base_const_t -{ -public: - t_size get_count() const {return m_count;} - void get_item_ex(T & p_out,t_size n) const {m_base.get_item_ex(p_out,m_order[n]);} - list_permutation_t(const list_base_const_t & p_base,const t_size * p_order,t_size p_count) - : m_base(p_base), m_order(p_order), m_count(p_count) - { - PFC_ASSERT(m_base.get_count() >= m_count); - } -private: - const list_base_const_t & m_base; - const t_size * m_order; - t_size m_count; -}; - -} -#endif //_PFC_LIST_H_ diff --git a/tools/vio2sf/src/foobar/pfc/map.h b/tools/vio2sf/src/foobar/pfc/map.h deleted file mode 100644 index 95d7cc718..000000000 --- a/tools/vio2sf/src/foobar/pfc/map.h +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef _MAP_T_H_INCLUDED_ -#define _MAP_T_H_INCLUDED_ - -namespace pfc { - PFC_DECLARE_EXCEPTION(exception_map_entry_not_found,exception,"Map entry not found"); - - template class __map_overwrite_wrapper { - public: - __map_overwrite_wrapper(t_destination & p_destination) : m_destination(p_destination) {} - template void operator() (const t_key & p_key,const t_value & p_value) {m_destination.set(p_key,p_value);} - private: - t_destination & m_destination; - }; - - template - class map_t { - private: - typedef map_t t_self; - public: - typedef t_storage_key t_key; typedef t_storage_value t_value; - template - void set(const _t_key & p_key, const _t_value & p_value) { - bool isnew; - t_storage & storage = m_data.add_ex(t_search_set<_t_key,_t_value>(p_key,p_value), isnew); - if (!isnew) storage.m_value = p_value; - } - - template - t_storage_value & find_or_add(_t_key const & p_key) { - return m_data.add(t_search_query<_t_key>(p_key)).m_value; - } - - template - t_storage_value & find_or_add_ex(_t_key const & p_key,bool & p_isnew) { - return m_data.add_ex(t_search_query<_t_key>(p_key),p_isnew).m_value; - } - - template - bool have_item(const _t_key & p_key) const { - return m_data.have_item(t_search_query<_t_key>(p_key)); - } - - template - bool query(const _t_key & p_key,_t_value & p_value) const { - const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); - if (storage == NULL) return false; - p_value = storage->m_value; - return true; - } - - template - const t_storage_value & operator[] (const _t_key & p_key) const { - const t_storage_value * ptr = query_ptr(p_key); - if (ptr == NULL) throw exception_map_entry_not_found(); - return *ptr; - } - - template - t_storage_value & operator[] (const _t_key & p_key) { - return find_or_add(p_key); - } - - template - const t_storage_value * query_ptr(const _t_key & p_key) const { - const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); - if (storage == NULL) return NULL; - return &storage->m_value; - } - - template - t_storage_value * query_ptr(const _t_key & p_key) { - t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key)); - if (storage == NULL) return NULL; - return &storage->m_value; - } - - template - const t_storage_value * query_nearest_ptr(_t_key & p_key) const { - const t_storage * storage = m_data.find_nearest_item(t_search_query<_t_key>(p_key)); - if (storage == NULL) return NULL; - p_key = storage->m_key; - return &storage->m_value; - } - - template - t_storage_value * query_nearest_ptr(_t_key & p_key) { - t_storage * storage = m_data.find_nearest_item(t_search_query<_t_key>(p_key)); - if (storage == NULL) return NULL; - p_key = storage->m_key; - return &storage->m_value; - } - - template - bool query_nearest(_t_key & p_key,_t_value & p_value) const { - const t_storage * storage = m_data.find_nearest_item(t_search_query<_t_key>(p_key)); - if (storage == NULL) return false; - p_key = storage->m_key; - p_value = storage->m_value; - return true; - } - - - template - bool remove(const _t_key & p_key) { - return m_data.remove_item(t_search_query<_t_key>(p_key)); - } - - template - void enumerate(t_callback & p_callback) const { - m_data.enumerate(enumeration_wrapper(p_callback)); - } - - template - void enumerate(t_callback & p_callback) { - m_data._enumerate_var(enumeration_wrapper_var(p_callback)); - } - - - t_size get_count() const throw() {return m_data.get_count();} - - void remove_all() throw() {m_data.remove_all();} - - template - void overwrite(const t_source & p_source) { - __map_overwrite_wrapper wrapper(*this); - p_source.enumerate(wrapper); - } - - //backwards compatibility method wrappers - template bool exists(const _t_key & p_key) const {return have_item(p_key);} - - - template bool get_first(_t_key & p_out) const { - return m_data.get_first(t_retrieve_key<_t_key>(p_out)); - } - - template bool get_last(_t_key & p_out) const { - return m_data.get_last(t_retrieve_key<_t_key>(p_out)); - } - - private: - template - struct t_retrieve_key { - typedef t_retrieve_key<_t_key> t_self; - t_retrieve_key(_t_key & p_key) : m_key(p_key) {} - template const t_self & operator=(const t_what & p_what) {m_key = p_what.m_key; return *this;} - _t_key & m_key; - }; - template - struct t_search_query { - t_search_query(const _t_key & p_key) : m_key(p_key) {} - _t_key const & m_key; - }; - template - struct t_search_set { - t_search_set(const _t_key & p_key, const _t_value & p_value) : m_key(p_key), m_value(p_value) {} - - _t_key const & m_key; - _t_value const & m_value; - }; - - struct t_storage { - const t_storage_key m_key; - t_storage_value m_value; - - template - t_storage(t_search_query<_t_key> const & p_source) : m_key(p_source.m_key), m_value() {} - - template - t_storage(t_search_set<_t_key,_t_value> const & p_source) : m_key(p_source.m_key), m_value(p_source.m_value) {} - - static bool equals(const t_storage & v1, const t_storage & v2) {return v1.m_key == v2.m_key && v1.m_value == v2.m_value;} - bool operator==(const t_storage & other) const {return equals(*this,other);} - bool operator!=(const t_storage & other) const {return !equals(*this,other);} - }; - - class comparator_wrapper { - public: - template - inline static int compare(const t1 & p_item1,const t2 & p_item2) { - return t_comparator::compare(p_item1.m_key,p_item2.m_key); - } - }; - - template - class enumeration_wrapper { - public: - enumeration_wrapper(t_callback & p_callback) : m_callback(p_callback) {} - void operator()(const t_storage & p_item) {m_callback(p_item.m_key,p_item.m_value);} - private: - t_callback & m_callback; - }; - - template - class enumeration_wrapper_var { - public: - enumeration_wrapper_var(t_callback & p_callback) : m_callback(p_callback) {} - void operator()(t_storage & p_item) {m_callback(safe_cast(p_item.m_key),p_item.m_value);} - private: - t_callback & m_callback; - }; - - typedef avltree_t t_content; - - t_content m_data; - public: - typedef traits_t traits; - typedef typename t_content::const_iterator const_iterator; - typedef typename t_content::iterator iterator; - - iterator first() throw() {return m_data._first_var();} - iterator last() throw() {return m_data._last_var();} - const_iterator first() const throw() {return m_data.first();} - const_iterator last() const throw() {return m_data.last();} - - static bool equals(const t_self & v1, const t_self & v2) { - return t_content::equals(v1.m_data,v2.m_data); - } - bool operator==(const t_self & other) const {return equals(*this,other);} - bool operator!=(const t_self & other) const {return !equals(*this,other);} - - bool remove(iterator const& iter) { - PFC_ASSERT(iter.is_valid()); - return m_data.remove(iter); - //should never return false unless there's a bug in calling code - } - bool remove(const_iterator const& iter) { - PFC_ASSERT(iter.is_valid()); - return m_data.remove(iter); - //should never return false unless there's a bug in calling code - } - }; -} - -#endif //_MAP_T_H_INCLUDED_ diff --git a/tools/vio2sf/src/foobar/pfc/mem_block_mgr.h b/tools/vio2sf/src/foobar/pfc/mem_block_mgr.h deleted file mode 100644 index daaead013..000000000 --- a/tools/vio2sf/src/foobar/pfc/mem_block_mgr.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _MEM_BLOCK_MGR_H_ -#define _MEM_BLOCK_MGR_H_ - -#error DEPRECATED - - -template -class mem_block_manager -{ - struct entry - { - mem_block_t block; - bool used; - }; - ptr_list_t list; -public: - T * copy(const T* ptr,int size) - { - int n; - int found_size = -1,found_index = -1; - for(n=0;nused) - { - int block_size = list[n]->block.get_size(); - if (found_size<0) - { - found_index=n; found_size = block_size; - } - else if (found_sizefound_size) - { - found_index=n; found_size = block_size; - } - } - else if (found_size>size) - { - if (block_size>=size && block_size=0) - { - list[found_index]->used = true; - return list[found_index]->block.copy(ptr,size); - } - entry * new_entry = new entry; - new_entry->used = true; - list.add_item(new_entry); - return new_entry->block.copy(ptr,size); - } - - void mark_as_free() - { - int n; - for(n=0;nused = false; - } - } - - ~mem_block_manager() {list.delete_all();} -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/order_helper.h b/tools/vio2sf/src/foobar/pfc/order_helper.h deleted file mode 100644 index 111ffcf9e..000000000 --- a/tools/vio2sf/src/foobar/pfc/order_helper.h +++ /dev/null @@ -1,83 +0,0 @@ -namespace pfc { - PFC_DECLARE_EXCEPTION( exception_invalid_permutation, exception_invalid_params, "Invalid permutation" ); - t_size permutation_find_reverse(t_size const * order, t_size count, t_size value); - - //! For critical sanity checks. Speed: O(n), allocates memory. - bool permutation_is_valid(t_size const * order, t_size count); - //! For critical sanity checks. Speed: O(n), allocates memory. - void permutation_validate(t_size const * order, t_size count); - - //! Creates a permutation that moves selected items in a list box by the specified delta-offset. - void create_move_items_permutation(t_size * p_output,t_size p_count,const class ::bit_array & p_selection,int p_delta); -} - -class order_helper -{ - pfc::array_t m_data; -public: - order_helper(t_size p_size) { - m_data.set_size(p_size); - for(t_size n=0;n - static void g_fill(t_int * p_order,const t_size p_count) { - t_size n; for(n=0;n - static void g_fill(t_array & p_array) { - t_size n; const t_size max = pfc::array_size_t(p_array); - for(n=0;n - static bool guess_reorder_pattern(pfc::array_t & out, const t_list & from, const t_list & to) { - typedef typename t_list::t_item t_item; - const t_size count = from.get_size(); - if (count != to.get_size()) return false; - out.set_size(count); - for(t_size walk = 0; walk < count; ++walk) out[walk] = walk; - //required output: to[n] = from[out[n]]; - typedef pfc::chain_list_v2_t t_queue; - pfc::map_t content; - for(t_size walk = 0; walk < count; ++walk) { - content.find_or_add(from[walk]).add_item(walk); - } - for(t_size walk = 0; walk < count; ++walk) { - t_queue * q = content.query_ptr(to[walk]); - if (q == NULL) return false; - if (q->get_count() == 0) return false; - out[walk] = *q->first(); - q->remove(q->first()); - } - return true; - } -} diff --git a/tools/vio2sf/src/foobar/pfc/other.cpp b/tools/vio2sf/src/foobar/pfc/other.cpp deleted file mode 100644 index 4db4b5901..000000000 --- a/tools/vio2sf/src/foobar/pfc/other.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include "pfc.h" - -#include - -namespace pfc { - bool permutation_is_valid(t_size const * order, t_size count) { - bit_array_bittable found(count); - for(t_size walk = 0; walk < count; ++walk) { - if (order[walk] >= count) return false; - if (found[walk]) return false; - found.set(walk,true); - } - return true; - } - void permutation_validate(t_size const * order, t_size count) { - if (!permutation_is_valid(order,count)) throw exception_invalid_permutation(); - } - - t_size permutation_find_reverse(t_size const * order, t_size count, t_size value) { - if (value >= count) return ~0; - for(t_size walk = 0; walk < count; ++walk) { - if (order[walk] == value) return walk; - } - return ~0; - } - - void create_move_items_permutation(t_size * p_output,t_size p_count,const bit_array & p_selection,int p_delta) { - t_size * const order = p_output; - const t_size count = p_count; - - pfc::array_t selection; selection.set_size(p_count); - - for(t_size walk = 0; walk < count; ++walk) { - order[walk] = walk; - selection[walk] = p_selection[walk]; - } - - if (p_delta<0) - { - for(;p_delta<0;p_delta++) - { - t_size idx; - for(idx=1;idx0;p_delta--) - { - t_size idx; - for(idx=count-2;(int)idx>=0;idx--) - { - if (selection[idx] && !selection[idx+1]) - { - pfc::swap_t(order[idx],order[idx+1]); - pfc::swap_t(selection[idx],selection[idx+1]); - } - } - } - } - } -} - -void order_helper::g_swap(t_size * data,t_size ptr1,t_size ptr2) -{ - t_size temp = data[ptr1]; - data[ptr1] = data[ptr2]; - data[ptr2] = temp; -} - - -t_size order_helper::g_find_reverse(const t_size * order,t_size val) -{ - t_size prev = val, next = order[val]; - while(next != val) - { - prev = next; - next = order[next]; - } - return prev; -} - - -void order_helper::g_reverse(t_size * order,t_size base,t_size count) -{ - t_size max = count>>1; - t_size n; - t_size base2 = base+count-1; - for(n=0;n>1;n++) swap_t(ptr[n],ptr[p_bytes-n-1]); -} - -#if defined(_DEBUG) && defined(_WIN32) -void pfc::myassert(const wchar_t * _Message, const wchar_t *_File, unsigned _Line) { - if (IsDebuggerPresent()) pfc::crash(); - _wassert(_Message,_File,_Line); -} -#endif - - -t_uint64 pfc::pow_int(t_uint64 base, t_uint64 exp) { - t_uint64 mul = base; - t_uint64 val = 1; - t_uint64 mask = 1; - while(exp != 0) { - if (exp & mask) { - val *= mul; - exp ^= mask; - } - mul = mul * mul; - mask <<= 1; - } - return val; -} diff --git a/tools/vio2sf/src/foobar/pfc/other.h b/tools/vio2sf/src/foobar/pfc/other.h deleted file mode 100644 index ace7e266a..000000000 --- a/tools/vio2sf/src/foobar/pfc/other.h +++ /dev/null @@ -1,207 +0,0 @@ -#ifndef _PFC_OTHER_H_ -#define _PFC_OTHER_H_ - -namespace pfc { - template - class vartoggle_t { - T oldval; T & var; - public: - vartoggle_t(T & p_var,const T & val) : var(p_var) { - oldval = var; - var = val; - } - ~vartoggle_t() {var = oldval;} - }; - - typedef vartoggle_t booltoggle; -}; - -#ifdef _MSC_VER - -class fpu_control -{ - unsigned old_val; - unsigned mask; -public: - inline fpu_control(unsigned p_mask,unsigned p_val) - { - mask = p_mask; - _controlfp_s(&old_val,p_val,mask); - } - inline ~fpu_control() - { - unsigned dummy; - _controlfp_s(&dummy,old_val,mask); - } -}; - -class fpu_control_roundnearest : private fpu_control -{ -public: - fpu_control_roundnearest() : fpu_control(_MCW_RC,_RC_NEAR) {} -}; - -class fpu_control_flushdenormal : private fpu_control -{ -public: - fpu_control_flushdenormal() : fpu_control(_MCW_DN,_DN_FLUSH) {} -}; - -class fpu_control_default : private fpu_control -{ -public: - fpu_control_default() : fpu_control(_MCW_DN|_MCW_RC,_DN_FLUSH|_RC_NEAR) {} -}; - -#ifdef _M_IX86 -class sse_control { -public: - sse_control(unsigned p_mask,unsigned p_val) : m_mask(p_mask) { - __control87_2(p_val,p_mask,NULL,&m_oldval); - } - ~sse_control() { - __control87_2(m_oldval,m_mask,NULL,&m_oldval); - } -private: - unsigned m_mask,m_oldval; -}; -class sse_control_flushdenormal : private sse_control { -public: - sse_control_flushdenormal() : sse_control(_MCW_DN,_DN_FLUSH) {} -}; -#endif - -#endif - -namespace pfc { - - class releaser_delete { - public: - template static void release(T* p_ptr) {delete p_ptr;} - }; - class releaser_delete_array { - public: - template static void release(T* p_ptr) {delete[] p_ptr;} - }; - class releaser_free { - public: - static void release(void * p_ptr) {free(p_ptr);} - }; - - //! Assumes t_freefunc to never throw exceptions. - template - class ptrholder_t { - private: - typedef ptrholder_t t_self; - public: - inline ptrholder_t(T* p_ptr) : m_ptr(p_ptr) {} - inline ptrholder_t() : m_ptr(NULL) {} - inline ~ptrholder_t() {t_releaser::release(m_ptr);} - inline bool is_valid() const {return m_ptr != NULL;} - inline bool is_empty() const {return m_ptr == NULL;} - inline T* operator->() const {return m_ptr;} - inline T* get_ptr() const {return m_ptr;} - inline void release() {t_releaser::release(replace_null_t(m_ptr));;} - inline void attach(T * p_ptr) {release(); m_ptr = p_ptr;} - inline const t_self & operator=(T * p_ptr) {set(p_ptr);return *this;} - inline T* detach() {return pfc::replace_null_t(m_ptr);} - inline T& operator*() const {return *m_ptr;} - - inline t_self & operator<<(t_self & p_source) {attach(p_source.detach());return *this;} - inline t_self & operator>>(t_self & p_dest) {p_dest.attach(detach());return *this;} - - //deprecated - inline void set(T * p_ptr) {attach(p_ptr);} - private: - ptrholder_t(const t_self &) {throw pfc::exception_not_implemented();} - const t_self & operator=(const t_self & ) {throw pfc::exception_not_implemented();} - - T* m_ptr; - }; - - //avoid "void&" breakage - template - class ptrholder_t { - private: - typedef void T; - typedef ptrholder_t t_self; - public: - inline ptrholder_t(T* p_ptr) : m_ptr(p_ptr) {} - inline ptrholder_t() : m_ptr(NULL) {} - inline ~ptrholder_t() {t_releaser::release(m_ptr);} - inline bool is_valid() const {return m_ptr != NULL;} - inline bool is_empty() const {return m_ptr == NULL;} - inline T* operator->() const {return m_ptr;} - inline T* get_ptr() const {return m_ptr;} - inline void release() {t_releaser::release(replace_null_t(m_ptr));;} - inline void attach(T * p_ptr) {release(); m_ptr = p_ptr;} - inline const t_self & operator=(T * p_ptr) {set(p_ptr);return *this;} - inline T* detach() {return pfc::replace_null_t(m_ptr);} - - inline t_self & operator<<(t_self & p_source) {attach(p_source.detach());return *this;} - inline t_self & operator>>(t_self & p_dest) {p_dest.attach(detach());return *this;} - - //deprecated - inline void set(T * p_ptr) {attach(p_ptr);} - private: - ptrholder_t(const t_self &) {throw pfc::exception_not_implemented();} - const t_self & operator=(const t_self & ) {throw pfc::exception_not_implemented();} - - T* m_ptr; - }; - - void crash(); - - template - class int_container_helper { - public: - int_container_helper() : m_val(p_initval) {} - t_type m_val; - }; - - - - //warning: not multi-thread-safe - template - class instanceTracker : public t_base { - private: - typedef instanceTracker t_self; - public: - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(instanceTracker,t_base,{g_list += this;}); - - instanceTracker(const t_self & p_other) : t_base( (const t_base &)p_other) {g_list += this;} - ~instanceTracker() {g_list -= this;} - - typedef pfc::avltree_t t_list; - static const t_list & instanceList() {return g_list;} - template static void forEach(t_callback & p_callback) {instanceList().enumerate(p_callback);} - private: - static t_list g_list; - }; - - template - typename instanceTracker::t_list instanceTracker::g_list; - - - //warning: not multi-thread-safe - template - class instanceTrackerV2 { - private: - typedef instanceTrackerV2 t_self; - public: - instanceTrackerV2(const t_self & p_other) {g_list += static_cast(this);} - instanceTrackerV2() {g_list += static_cast(this);} - ~instanceTrackerV2() {g_list -= static_cast(this);} - - typedef pfc::avltree_t t_instanceList; - static const t_instanceList & instanceList() {return g_list;} - template static void forEach(t_callback & p_callback) {instanceList().enumerate(p_callback);} - private: - static t_instanceList g_list; - }; - - template - typename instanceTrackerV2::t_instanceList instanceTrackerV2::g_list; -} - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/pathUtils.cpp b/tools/vio2sf/src/foobar/pfc/pathUtils.cpp deleted file mode 100644 index fdd723340..000000000 --- a/tools/vio2sf/src/foobar/pfc/pathUtils.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include "pfc.h" - -namespace pfc { namespace io { namespace path { - -static const string g_pathSeparators ("\\/|"); - -string getFileName(string path) { - t_size split = path.lastIndexOfAnyChar(g_pathSeparators); - if (split == ~0) return path; - else return path.subString(split+1); -} -string getFileNameWithoutExtension(string path) { - string fn = getFileName(path); - t_size split = path.lastIndexOf('.'); - if (split == ~0) return fn; - else return fn.subString(0,split); -} -string getFileExtension(string path) { - string fn = getFileName(path); - t_size split = fn.lastIndexOf('.'); - if (split == ~0) return ""; - else return fn.subString(split); -} -string getDirectory(string filePath) {return getParent(filePath);} - -string getParent(string filePath) { - t_size split = filePath.lastIndexOfAnyChar(g_pathSeparators); - if (split == ~0) return ""; -#ifdef _WINDOWS - if (split > 0 && getIllegalNameChars().contains(filePath[split-1])) { - if (split + 1 < filePath.length()) return filePath.subString(0,split+1); - else return ""; - } -#endif - return filePath.subString(0,split); -} -string combine(string basePath,string fileName) { - if (basePath.length() > 0) { - if (!isSeparator(basePath.lastChar())) { - basePath += getDefaultSeparator(); - } - return basePath + fileName; - } else { - //todo? - return fileName; - } -} - -bool isSeparator(char c) { - return g_pathSeparators.indexOf(c) != ~0; -} -string getSeparators() { - return g_pathSeparators; -} - -static string replaceIllegalChar(char c) { - switch(c) { - case '*': - return "x"; - case '\"': - return "\'\'"; - default: - return "_"; - } -} -string replaceIllegalPathChars(string fn) { - string illegal = getIllegalNameChars(); - string separators = getSeparators(); - string_formatter output; - for(t_size walk = 0; walk < fn.length(); ++walk) { - const char c = fn[walk]; - if (separators.contains(c)) { - output.add_byte(getDefaultSeparator()); - } else if (string::isNonTextChar(c) || illegal.contains(c)) { - string replacement = replaceIllegalChar(c); - if (replacement.containsAnyChar(illegal)) /*per-OS weirdness security*/ replacement = "_"; - output << replacement.ptr(); - } else { - output.add_byte(c); - } - } - return output.toString(); -} - -string replaceIllegalNameChars(string fn) { - const string illegal = getIllegalNameChars(); - string_formatter output; - for(t_size walk = 0; walk < fn.length(); ++walk) { - const char c = fn[walk]; - if (string::isNonTextChar(c) || illegal.contains(c)) { - string replacement = replaceIllegalChar(c); - if (replacement.containsAnyChar(illegal)) /*per-OS weirdness security*/ replacement = "_"; - output << replacement.ptr(); - } else { - output.add_byte(c); - } - } - return output.toString(); -} - -bool isInsideDirectory(pfc::string directory, pfc::string inside) { - //not very efficient - string walk = inside; - for(;;) { - walk = getParent(walk); - if (walk == "") return false; - if (equals(directory,walk)) return true; - } -} -bool isDirectoryRoot(string path) { - return getParent(path).isEmpty(); -} -//OS-dependant part starts here - - -char getDefaultSeparator() { -#ifdef _WINDOWS - return '\\'; -#else -#error PORTME -#endif -} - -static const string g_illegalNameChars(g_pathSeparators + -#ifdef _WINDOWS - ":<>*?\"" -#else -#error PORTME -#endif - ); - -string getIllegalNameChars() { - return g_illegalNameChars; -} - -static bool isIllegalTrailingChar(char c) { - return c == ' ' || c == '.'; -} - -string validateFileName(string name) { - while(name.endsWith('?')) name = name.subString(0, name.length() - 1); -#ifdef _WINDOWS - name = replaceIllegalNameChars(name); - if (name.length() > 0) { - t_size end = name.length(); - while(end > 0) { - if (!isIllegalTrailingChar(name[end-1])) break; - --end; - } - t_size begin = 0; - while(begin < end) { - if (!isIllegalTrailingChar(name[begin])) break; - ++begin; - } - if (end < name.length() || begin > 0) name = name.subString(begin,end - begin); - } - if (name.isEmpty()) name = "_"; - return name; -#else - return replaceIllegalNameChars(name); -#endif -} - -}}} diff --git a/tools/vio2sf/src/foobar/pfc/pathUtils.h b/tools/vio2sf/src/foobar/pfc/pathUtils.h deleted file mode 100644 index 34354a6ce..000000000 --- a/tools/vio2sf/src/foobar/pfc/pathUtils.h +++ /dev/null @@ -1,29 +0,0 @@ -namespace pfc { - namespace io { - namespace path { - string getFileName(string path); - string getFileNameWithoutExtension(string path); - string getFileExtension(string path); - string getParent(string filePath); - string getDirectory(string filePath);//same as getParent() - string combine(string basePath,string fileName); - char getDefaultSeparator(); - string getSeparators(); - bool isSeparator(char c); - string getIllegalNameChars(); - string replaceIllegalNameChars(string fn); - string replaceIllegalPathChars(string fn); - bool isInsideDirectory(pfc::string directory, pfc::string inside); - bool isDirectoryRoot(string path); - string validateFileName(string name);//removes various illegal things from the name, exact effect depends on the OS, includes removal of the invalid characters - - template bool equals(const t1 & v1, const t2 & v2) {return comparator::compare(v1,v2) == 0;} - -#ifdef _WINDOWS - typedef string::comparatorCaseInsensitive comparator; -#else -#error PORTME -#endif - } - } -} diff --git a/tools/vio2sf/src/foobar/pfc/pfc.h b/tools/vio2sf/src/foobar/pfc/pfc.h deleted file mode 100644 index edb538eb0..000000000 --- a/tools/vio2sf/src/foobar/pfc/pfc.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef ___PFC_H___ -#define ___PFC_H___ - -#if !defined(_WINDOWS) && (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined(_WIN32_WCE)) -#define _WINDOWS -#endif - - -#define PFC_DLL_EXPORT - -#ifdef _WINDOWS - -#ifndef STRICT -#define STRICT -#endif - -#ifndef _SYS_GUID_OPERATOR_EQ_ -#define _NO_SYS_GUID_OPERATOR_EQ_ //fix retarded warning with operator== on GUID returning int -#endif - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x500 -#endif - -#include - -#ifndef _SYS_GUID_OPERATOR_EQ_ -__inline bool __InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2) -{ - return ( - ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] && - ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] && - ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] && - ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]); -} - -inline bool operator==(REFGUID guidOne, REFGUID guidOther) {return __InlineIsEqualGUID(guidOne,guidOther);} -inline bool operator!=(REFGUID guidOne, REFGUID guidOther) {return !__InlineIsEqualGUID(guidOne,guidOther);} -#endif - -#include - -#elif defined(__GNUC__) && (defined __unix__ || defined __POSIX__) -#include -#include -typedef struct { - uint32_t Data1; - uint16_t Data2; - uint16_t Data3; - uint8_t Data4[ 8 ]; - } GUID; //same as win32 GUID - -inline bool operator==(const GUID & p_item1,const GUID & p_item2) { - return memcmp(&p_item1,&p_item2,sizeof(GUID)) == 0; -} - -inline bool operator!=(const GUID & p_item1,const GUID & p_item2) { - return memcmp(&p_item1,&p_item2,sizeof(GUID)) != 0; -} - -#else - -#error Only win32 or unix target supported. - -#endif - - - -#define PFC_MEMORY_SPACE_LIMIT ((t_uint64)1<<(sizeof(void*)*8-1)) - -#define PFC_ALLOCA_LIMIT (4096) - -#define INDEX_INVALID ((unsigned)(-1)) - - -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#define _PFC_WIDESTRING(_String) L ## _String -#define PFC_WIDESTRING(_String) _PFC_WIDESTRING(_String) - -#ifndef _DEBUG -#define PFC_ASSERT(_Expression) ((void)0) -#define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0) -#define PFC_ASSERT_NO_EXCEPTION(_Expression) { _Expression; } -#else - -#ifdef _WIN32 -namespace pfc { void myassert(const wchar_t * _Message, const wchar_t *_File, unsigned _Line); } -#define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert(PFC_WIDESTRING(#_Expression), PFC_WIDESTRING(__FILE__), __LINE__), 0) ) -#define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT(_Expression) -#else -#define PFC_ASSERT(_Expression) assert(_Expression) -#define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0) //FIXME -#endif - -#define PFC_ASSERT_NO_EXCEPTION(_Expression) { try { _Expression; } catch(...) { PFC_ASSERT(!"Should not get here - unexpected exception"); } } -#endif - -#ifdef _MSC_VER - -#ifdef _DEBUG -#define NOVTABLE -#else -#define NOVTABLE _declspec(novtable) -#endif - -#ifdef _DEBUG -#define ASSUME(X) PFC_ASSERT(X) -#else -#define ASSUME(X) __assume(X) -#endif - -#define PFC_DEPRECATE(X) __declspec(deprecated(X)) -#else - -#define NOVTABLE -#define ASSUME(X) assert(X) -#define PFC_DEPRECATE(X) - -#endif - -#include "int_types.h" -#include "traits.h" -#include "bit_array.h" -#include "primitives.h" -#include "alloc.h" -#include "array.h" -#include "bit_array_impl.h" -#include "binary_search.h" -#include "bsearch_inline.h" -#include "bsearch.h" -#include "sort.h" -#include "order_helper.h" -#include "list.h" -#include "ptr_list.h" -#include "string.h" -#include "string_list.h" -#include "ref_counter.h" -#include "iterators.h" -#include "avltree.h" -#include "map.h" -#include "profiler.h" -#include "guid.h" -#include "byte_order_helper.h" -#include "other.h" -#include "chain_list_v2.h" -#include "rcptr.h" -#include "com_ptr_t.h" -#include "string_conv.h" -#include "stringNew.h" -#include "pathUtils.h" -#include "instance_tracker.h" -#include "threads.h" - -#endif //___PFC_H___ diff --git a/tools/vio2sf/src/foobar/pfc/pfc.vcproj b/tools/vio2sf/src/foobar/pfc/pfc.vcproj deleted file mode 100644 index 4dc422bfa..000000000 --- a/tools/vio2sf/src/foobar/pfc/pfc.vcproj +++ /dev/null @@ -1,802 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/src/foobar/pfc/primitives.h b/tools/vio2sf/src/foobar/pfc/primitives.h deleted file mode 100644 index eb1cff41a..000000000 --- a/tools/vio2sf/src/foobar/pfc/primitives.h +++ /dev/null @@ -1,783 +0,0 @@ -#define tabsize(x) ((size_t)(sizeof(x)/sizeof(*x))) -#define PFC_TABSIZE(x) ((size_t)(sizeof(x)/sizeof(*x))) - -#define TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(THISCLASS,MEMBER,INITIALIZER) \ - THISCLASS() : MEMBER() INITIALIZER \ - template THISCLASS(const t_param1 & p_param1) : MEMBER(p_param1) INITIALIZER \ - template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2) : MEMBER(p_param1,p_param2) INITIALIZER \ - template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3) : MEMBER(p_param1,p_param2,p_param3) INITIALIZER \ - template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4) : MEMBER(p_param1,p_param2,p_param3,p_param4) INITIALIZER \ - template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4,const t_param5 & p_param5) : MEMBER(p_param1,p_param2,p_param3,p_param4,p_param5) INITIALIZER \ - template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4,const t_param5 & p_param5,const t_param6 & p_param6) : MEMBER(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6) INITIALIZER \ - template THISCLASS(const t_param1 & p_param1,const t_param2 & p_param2,const t_param3 & p_param3,const t_param4 & p_param4,const t_param5 & p_param5,const t_param6 & p_param6,const t_param7 & p_param7) : MEMBER(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6,p_param7) INITIALIZER - -#define TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(THISCLASS,MEMBER) TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(THISCLASS,MEMBER,{}) - - -#ifdef _MSC_VER - -//Bah. I noticed the fact that std::exception carrying a custom message is MS-specific *after* making exception classes a part of ABI. To be nuked next time fb2k component backwards compatibility is axed. - -#define PFC_DECLARE_EXCEPTION(NAME,BASECLASS,DEFAULTMSG) \ -class NAME : public BASECLASS { \ -public: \ - static const char * g_what() {return DEFAULTMSG;} \ - NAME() : BASECLASS(DEFAULTMSG,0) {} \ - NAME(const char * p_msg) : BASECLASS(p_msg) {} \ - NAME(const char * p_msg,int) : BASECLASS(p_msg,0) {} \ - NAME(const NAME & p_source) : BASECLASS(p_source) {} \ -}; - -namespace pfc { - template inline void throw_exception_with_message(const char * p_message) { - throw t_exception(p_message); - } -} - -#else - -#define PFC_DECLARE_EXCEPTION(NAME,BASECLASS,DEFAULTMSG) \ -class NAME : public BASECLASS { \ -public: \ - static const char * g_what() {return DEFAULTMSG;} \ - const char* what() const throw() {return DEFAULTMSG;} \ -}; - -namespace pfc { - template class __exception_with_message_t : public t_base { - private: typedef __exception_with_message_t t_self; - public: - __exception_with_message_t(const char * p_message) : m_message(NULL) { - set_message(p_message); - } - __exception_with_message_t() : m_message(NULL) {} - __exception_with_message_t(const t_self & p_source) : m_message(NULL) {set_message(p_source.m_message);} - - const char* what() const throw() {return m_message != NULL ? m_message : "unnamed exception";} - - const t_self & operator=(const t_self & p_source) {set_message(p_source.m_message);} - - ~__exception_with_message_t() throw() {cleanup();} - - private: - void set_message(const char * p_message) throw() { - cleanup(); - if (p_message != NULL) m_message = strdup(p_message); - } - void cleanup() throw() { - if (m_message != NULL) {free(m_message); m_message = NULL;} - } - char * m_message; - }; - template void throw_exception_with_message(const char * p_message) { - throw __exception_with_message_t(p_message); - } -} -#endif - -namespace pfc { - - template class assert_same_type; - template class assert_same_type {}; - - template - class is_same_type { public: enum {value = false}; }; - - template - class is_same_type { public: enum {value = true}; }; - - template class static_assert; - template<> class static_assert {}; - - template class static_assert_t; - template<> class static_assert_t {}; - -#define PFC_STATIC_ASSERT(X) { pfc::static_assert<(X)>(); } - - template - void assert_raw_type() {static_assert< !traits_t::needs_constructor && !traits_t::needs_destructor >();} - - template class assert_byte_type; - template<> class assert_byte_type {}; - template<> class assert_byte_type {}; - - - template void __unsafe__memcpy_t(t_type * p_dst,const t_type * p_src,t_size p_count) { - ::memcpy(reinterpret_cast(p_dst), reinterpret_cast(p_src), p_count * sizeof(t_type)); - } - - template void __unsafe__in_place_destructor_t(t_type & p_item) throw() { - if (traits_t::needs_destructor) try{ p_item.~t_type(); } catch(...) {} - } - - template void __unsafe__in_place_constructor_t(t_type & p_item) { - if (traits_t::needs_constructor) { - t_type * ret = new(&p_item) t_type; - PFC_ASSERT(ret == &p_item); - } - } - - template void __unsafe__in_place_destructor_array_t(t_type * p_items, t_size p_count) throw() { - if (traits_t::needs_destructor) { - t_type * walk = p_items; - for(t_size n=p_count;n;--n) __unsafe__in_place_destructor_t(*(walk++)); - } - } - - template t_type * __unsafe__in_place_constructor_array_t(t_type * p_items,t_size p_count) { - if (traits_t::needs_constructor) { - t_size walkptr = 0; - try { - for(walkptr=0;walkptr t_type * __unsafe__in_place_resize_array_t(t_type * p_items,t_size p_from,t_size p_to) { - if (p_from < p_to) __unsafe__in_place_constructor_array_t(p_items + p_from, p_to - p_from); - else if (p_from > p_to) __unsafe__in_place_destructor_array_t(p_items + p_to, p_from - p_to); - return p_items; - } - - template void __unsafe__in_place_constructor_copy_t(t_type & p_item,const t_copy & p_copyfrom) { - if (traits_t::needs_constructor) { - t_type * ret = new(&p_item) t_type(p_copyfrom); - PFC_ASSERT(ret == &p_item); - } else { - p_item = p_copyfrom; - } - } - - template t_type * __unsafe__in_place_constructor_array_copy_t(t_type * p_items,t_size p_count, const t_copy * p_copyfrom) { - t_size walkptr = 0; - try { - for(walkptr=0;walkptr t_type * __unsafe__in_place_constructor_array_copy_partial_t(t_type * p_items,t_size p_count, const t_copy * p_copyfrom,t_size p_copyfrom_count) { - if (p_copyfrom_count > p_count) p_copyfrom_count = p_count; - __unsafe__in_place_constructor_array_copy_t(p_items,p_copyfrom_count,p_copyfrom); - try { - __unsafe__in_place_constructor_array_t(p_items + p_copyfrom_count,p_count - p_copyfrom_count); - } catch(...) { - __unsafe__in_place_destructor_array_t(p_items,p_copyfrom_count); - throw; - } - return p_items; - } - - template inline t_ret safe_cast(t_ret val) {return val;} - - template - t_ret * safe_ptr_cast(t_param * p_param) { - if (pfc::is_same_type::value) return p_param; - else { - if (p_param == NULL) return NULL; - else return p_param; - } - } - - typedef std::exception exception; - - PFC_DECLARE_EXCEPTION(exception_overflow,exception,"Overflow"); - PFC_DECLARE_EXCEPTION(exception_bug_check,exception,"Bug check"); - PFC_DECLARE_EXCEPTION(exception_invalid_params,exception_bug_check,"Invalid parameters"); - PFC_DECLARE_EXCEPTION(exception_unexpected_recursion,exception_bug_check,"Unexpected recursion"); - PFC_DECLARE_EXCEPTION(exception_not_implemented,exception_bug_check,"Feature not implemented"); - PFC_DECLARE_EXCEPTION(exception_dynamic_assert,exception_bug_check,"dynamic_assert failure"); - - template - t_ret downcast_guarded(const t_param & p_param) { - t_ret temp = (t_ret) p_param; - if ((t_param) temp != p_param) throw exception_overflow(); - return temp; - } - - template - t_ret downcast_guarded_ex(const t_param & p_param) { - t_ret temp = (t_ret) p_param; - if ((t_param) temp != p_param) throw t_exception(); - return temp; - } - - template - void accumulate_guarded(t_acc & p_acc, const t_add & p_add) { - t_acc delta = downcast_guarded(p_add); - delta += p_acc; - if (delta < p_acc) throw exception_overflow(); - p_acc = delta; - } - - //deprecated - inline void bug_check_assert(bool p_condition, const char * p_msg) { - if (!p_condition) { - PFC_ASSERT(0); - throw_exception_with_message(p_msg); - } - } - //deprecated - inline void bug_check_assert(bool p_condition) { - if (!p_condition) { - PFC_ASSERT(0); - throw exception_bug_check(); - } - } - - inline void dynamic_assert(bool p_condition, const char * p_msg) { - if (!p_condition) { - PFC_ASSERT(0); - throw_exception_with_message(p_msg); - } - } - inline void dynamic_assert(bool p_condition) { - if (!p_condition) { - PFC_ASSERT(0); - throw exception_dynamic_assert(); - } - } - - template - inline void swap_multi_t(T * p_buffer1,T * p_buffer2,t_size p_size) { - T * walk1 = p_buffer1, * walk2 = p_buffer2; - for(t_size n=p_size;n;--n) { - T temp (* walk1); - *walk1 = *walk2; - *walk2 = temp; - walk1++; walk2++; - } - } - - template - inline void swap_multi_t(T * p_buffer1,T * p_buffer2) { - T * walk1 = p_buffer1, * walk2 = p_buffer2; - for(t_size n=p_size;n;--n) { - T temp (* walk1); - *walk1 = *walk2; - *walk2 = temp; - walk1++; walk2++; - } - } - - - template - inline void __unsafe__swap_raw_t(void * p_object1, void * p_object2) { - if (p_size % sizeof(t_size) == 0) { - swap_multi_t(reinterpret_cast(p_object1),reinterpret_cast(p_object2)); - } else { - swap_multi_t(reinterpret_cast(p_object1),reinterpret_cast(p_object2)); - } - } - - template - inline void swap_t(T & p_item1, T & p_item2) { - if (traits_t::realloc_safe) { - __unsafe__swap_raw_t( reinterpret_cast( &p_item1 ), reinterpret_cast( &p_item2 ) ); - } else { - T temp(p_item2); - p_item2 = p_item1; - p_item1 = temp; - } - } - - template - t_size array_size_t(const t_array & p_array) {return p_array.get_size();} - - template - t_size array_size_t(const t_item (&p_array)[p_width]) {return p_width;} - - - template - inline void fill_t(t_array & p_buffer,const t_size p_count, const t_filler & p_filler) { - for(t_size n=0;n - inline void fill_ptr_t(t_array * p_buffer,const t_size p_count, const t_filler & p_filler) { - for(t_size n=0;n - inline int compare_t(const t_item1 & p_item1, const t_item2 & p_item2) { - if (p_item1 < p_item2) return -1; - else if (p_item1 > p_item2) return 1; - else return 0; - } - - //! For use with avltree/map etc. - class comparator_default { - public: - template - inline static int compare(const t_item1 & p_item1,const t_item2 & p_item2) {return pfc::compare_t(p_item1,p_item2);} - }; - - template class comparator_pointer { public: - template static int compare(const t_item1 & p_item1,const t_item2 & p_item2) {return t_comparator::compare(*p_item1,*p_item2);} - }; - - template class comparator_dual { public: - template static int compare(const t_item1 & p_item1,const t_item2 & p_item2) { - int state = t_primary::compare(p_item1,p_item2); - if (state != 0) return state; - return t_secondary::compare(p_item1,p_item2); - } - }; - - class comparator_memcmp { - public: - template - inline static int compare(const t_item1 & p_item1,const t_item2 & p_item2) { - static_assert(); - return memcmp(&p_item1,&p_item2,sizeof(t_item1)); - } - }; - - template - t_size subtract_sorted_lists_calculate_count(const t_source1 & p_source1, const t_source2 & p_source2) { - t_size walk1 = 0, walk2 = 0, walk_out = 0; - const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); - for(;;) { - int state; - if (walk1 < max1 && walk2 < max2) { - state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); - } else if (walk1 < max1) { - state = -1; - } else if (walk2 < max2) { - state = 1; - } else { - break; - } - if (state < 0) walk_out++; - if (state <= 0) walk1++; - if (state >= 0) walk2++; - } - return walk_out; - } - - //! Subtracts p_source2 contents from p_source1 and stores result in p_destination. Both source lists must be sorted. - //! Note: duplicates will be carried over (and ignored for p_source2). - template - void subtract_sorted_lists(t_destination & p_destination,const t_source1 & p_source1, const t_source2 & p_source2) { - p_destination.set_size(subtract_sorted_lists_calculate_count(p_source1,p_source2)); - t_size walk1 = 0, walk2 = 0, walk_out = 0; - const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); - for(;;) { - int state; - if (walk1 < max1 && walk2 < max2) { - state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); - } else if (walk1 < max1) { - state = -1; - } else if (walk2 < max2) { - state = 1; - } else { - break; - } - - - if (state < 0) p_destination[walk_out++] = p_source1[walk1]; - if (state <= 0) walk1++; - if (state >= 0) walk2++; - } - } - - template - t_size merge_sorted_lists_calculate_count(const t_source1 & p_source1, const t_source2 & p_source2) { - t_size walk1 = 0, walk2 = 0, walk_out = 0; - const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); - for(;;) { - int state; - if (walk1 < max1 && walk2 < max2) { - state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); - } else if (walk1 < max1) { - state = -1; - } else if (walk2 < max2) { - state = 1; - } else { - break; - } - if (state <= 0) walk1++; - if (state >= 0) walk2++; - walk_out++; - } - return walk_out; - } - - //! Merges p_source1 and p_source2, storing content in p_destination. Both source lists must be sorted. - //! Note: duplicates will be carried over. - template - void merge_sorted_lists(t_destination & p_destination,const t_source1 & p_source1, const t_source2 & p_source2) { - p_destination.set_size(merge_sorted_lists_calculate_count(p_source1,p_source2)); - t_size walk1 = 0, walk2 = 0, walk_out = 0; - const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size(); - for(;;) { - int state; - if (walk1 < max1 && walk2 < max2) { - state = pfc::compare_t(p_source1[walk1],p_source2[walk2]); - } else if (walk1 < max1) { - state = -1; - } else if (walk2 < max2) { - state = 1; - } else { - break; - } - if (state < 0) { - p_destination[walk_out] = p_source1[walk1++]; - } else if (state > 0) { - p_destination[walk_out] = p_source2[walk2++]; - } else { - p_destination[walk_out] = p_source1[walk1]; - walk1++; walk2++; - } - walk_out++; - } - } - - - - template - inline t_size append_t(t_array & p_array,const T & p_item) - { - t_size old_count = p_array.get_size(); - p_array.set_size(old_count + 1); - p_array[old_count] = p_item; - return old_count; - } - - template - inline t_size append_swap_t(t_array & p_array,T & p_item) - { - t_size old_count = p_array.get_size(); - p_array.set_size(old_count + 1); - swap_t(p_array[old_count],p_item); - return old_count; - } - - template - inline t_size insert_t(t_array & p_array,const T & p_item,t_size p_index) - { - t_size old_count = p_array.get_size(); - if (p_index > old_count) p_index = old_count; - p_array.set_size(old_count + 1); - for(t_size n=old_count;n>p_index;n--) - p_array[n] = p_array[n-1]; - p_array[p_index] = p_item; - return p_index; - } - template - inline t_size insert_default_t(t_array & p_array,t_size p_index) - { - t_size old_count = p_array.get_size(); - if (p_index > old_count) p_index = old_count; - p_array.set_size(old_count + 1); - for(t_size n=old_count;n>p_index;n--) - p_array[n] = p_array[n-1]; - /*p_array[p_index] = p_item;*/ - return p_index; - } - - template - inline t_size insert_swap_t(t_array & p_array,T & p_item,t_size p_index) - { - t_size old_count = p_array.get_size(); - if (p_index > old_count) p_index = old_count; - p_array.set_size(old_count + 1); - for(t_size n=old_count;n>p_index;n--) - swap_t(p_array[n],p_array[n-1]); - swap_t(p_array[p_index],p_item); - return p_index; - } - - - template - inline T max_t(const T & item1, const T & item2) {return item1 > item2 ? item1 : item2;}; - - template - inline T min_t(const T & item1, const T & item2) {return item1 < item2 ? item1 : item2;}; - - template - inline T abs_t(T item) {return item<0 ? -item : item;} - - template - inline T sqr_t(T item) {return item * item;} - - template - inline T clip_t(const T & p_item, const T & p_min, const T & p_max) { - if (p_item < p_min) return p_min; - else if (p_item <= p_max) return p_item; - else return p_max; - } - - - - - - template - inline void delete_t(T* ptr) {delete ptr;} - - template - inline void delete_array_t(T* ptr) {delete[] ptr;} - - template - inline T* clone_t(T* ptr) {return new T(*ptr);} - - - template - inline t_int mul_safe_t(t_int p_val1,t_int p_val2) { - if (p_val1 == 0 || p_val2 == 0) return 0; - t_int temp = (t_int) (p_val1 * p_val2); - if (temp / p_val1 != p_val2) throw t_exception(); - return temp; - } - template - t_int multiply_guarded(t_int v1, t_int v2) { - return mul_safe_t(v1, v2); - } - - template - void memcpy_t(t_dst* p_dst,const t_src* p_src,t_size p_count) { - for(t_size n=0;n - void copy_array_loop_t(t_dst & p_dst,const t_src & p_src,t_size p_count) { - for(t_size n=0;n - void memcpy_backwards_t(t_dst * p_dst,const t_src * p_src,t_size p_count) { - p_dst += p_count; p_src += p_count; - for(t_size n=0;n - void memset_t(T * p_buffer,const t_val & p_val,t_size p_count) { - for(t_size n=0;n - void memset_t(T &p_buffer,const t_val & p_val) { - const t_size width = pfc::array_size_t(p_buffer); - for(t_size n=0;n - void memset_null_t(T * p_buffer,t_size p_count) { - for(t_size n=0;n - void memset_null_t(T &p_buffer) { - const t_size width = pfc::array_size_t(p_buffer); - for(t_size n=0;n - void memmove_t(T* p_dst,const T* p_src,t_size p_count) { - if (p_dst == p_src) {/*do nothing*/} - else if (p_dst > p_src && p_dst < p_src + p_count) memcpy_backwards_t(p_dst,p_src,p_count); - else memcpy_t(p_dst,p_src,p_count); - } - - template void memxor_t(TVal * out, const TVal * s1, const TVal * s2, t_size count) { - for(t_size walk = 0; walk < count; ++walk) out[walk] = s1[walk] ^ s2[walk]; - } - static void memxor(void * target, const void * source1, const void * source2, t_size size) { - memxor_t( reinterpret_cast(target), reinterpret_cast(source1), reinterpret_cast(source2), size); - } - - template - T* new_ptr_check_t(T* p_ptr) { - if (p_ptr == NULL) throw std::bad_alloc(); - return p_ptr; - } - - template - int sgn_t(const T & p_val) { - if (p_val < 0) return -1; - else if (p_val > 0) return 1; - else return 0; - } - - template const T* empty_string_t(); - - template<> inline const char * empty_string_t() {return "";} - template<> inline const wchar_t * empty_string_t() {return L"";} - - - template - t_type replace_t(t_type & p_var,const t_newval & p_newval) { - t_type oldval = p_var; - p_var = p_newval; - return oldval; - } - template - t_type replace_null_t(t_type & p_var) { - t_type ret = p_var; - p_var = NULL; - return ret; - } - - template - inline bool is_ptr_aligned_t(const void * p_ptr) { - static_assert< (p_size_pow2 & (p_size_pow2 - 1)) == 0 >(); - return ( ((t_size)p_ptr) & (p_size_pow2-1) ) == 0; - } - - - template - void array_rangecheck_t(const t_array & p_array,t_size p_index) { - if (p_index >= pfc::array_size_t(p_array)) throw pfc::exception_overflow(); - } - - template - void array_rangecheck_t(const t_array & p_array,t_size p_from,t_size p_to) { - if (p_from > p_to) throw pfc::exception_overflow(); - array_rangecheck_t(p_array,p_from); array_rangecheck_t(p_array,p_to); - } - - inline t_int32 rint32(double p_val) {return (t_int32) floor(p_val + 0.5);} - inline t_int64 rint64(double p_val) {return (t_int64) floor(p_val + 0.5);} - - - - - template - inline t_size remove_mask_t(t_array & p_array,const bit_array & p_mask)//returns amount of items left - { - t_size n,count = p_array.get_size(), total = 0; - - n = total = p_mask.find(true,0,count); - - if (n - t_size find_duplicates_sorted_t(t_array p_array,t_size p_count,t_compare p_compare,bit_array_var & p_out) { - t_size ret = 0; - t_size n; - if (p_count > 0) - { - p_out.set(0,false); - for(n=1;n - t_size find_duplicates_sorted_permutation_t(t_array p_array,t_size p_count,t_compare p_compare,t_permutation const & p_permutation,bit_array_var & p_out) { - t_size ret = 0; - t_size n; - if (p_count > 0) { - p_out.set(p_permutation[0],false); - for(n=1;n - t_size strlen_t(const t_char * p_string,t_size p_length = infinite) { - for(t_size walk = 0;;walk++) { - if (walk >= p_length || p_string[walk] == 0) return walk; - } - } - - - template - class __list_to_array_enumerator { - public: - __list_to_array_enumerator(t_array & p_array) : m_array(p_array), m_walk(0) {} - template - void operator() (const t_item & p_item) { - PFC_ASSERT(m_walk < m_array.get_size()); - m_array[m_walk++] = p_item; - } - void finalize() { - PFC_ASSERT(m_walk == m_array.get_size()); - } - private: - t_size m_walk; - t_array & m_array; - }; - - template - void list_to_array(t_array & p_array,const t_list & p_list) { - p_array.set_size(p_list.get_count()); - __list_to_array_enumerator enumerator(p_array); - p_list.enumerate(enumerator); - enumerator.finalize(); - } - - template - class enumerator_add_item { - public: - enumerator_add_item(t_receiver & p_receiver) : m_receiver(p_receiver) {} - template void operator() (const t_item & p_item) {m_receiver.add_item(p_item);} - private: - t_receiver & m_receiver; - }; - - template - void overwrite_list_enumerated(t_receiver & p_receiver,const t_giver & p_giver) { - enumerator_add_item wrapper(p_receiver); - p_giver.enumerate(wrapper); - } - - template - void copy_list_enumerated(t_receiver & p_receiver,const t_giver & p_giver) { - p_receiver.remove_all(); - overwrite_list_enumerated(p_receiver,p_giver); - } - - inline bool lxor(bool p_val1,bool p_val2) { - return p_val1 == !p_val2; - } - - template - inline void min_acc(t_val & p_acc,const t_val & p_val) { - if (p_val < p_acc) p_acc = p_val; - } - - template - inline void max_acc(t_val & p_acc,const t_val & p_val) { - if (p_val > p_acc) p_acc = p_val; - } - - t_uint64 pow_int(t_uint64 base, t_uint64 exp); -}; - - -#define PFC_CLASS_NOT_COPYABLE(THISCLASSNAME,THISTYPE) \ - private: \ - THISCLASSNAME(const THISTYPE&) {throw pfc::exception_bug_check();} \ - const THISTYPE & operator=(const THISTYPE &) {throw pfc::exception_bug_check();} - -#define PFC_CLASS_NOT_COPYABLE_EX(THISTYPE) PFC_CLASS_NOT_COPYABLE(THISTYPE,THISTYPE) \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/printf.cpp b/tools/vio2sf/src/foobar/pfc/printf.cpp deleted file mode 100644 index cdfa6a5cf..000000000 --- a/tools/vio2sf/src/foobar/pfc/printf.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "pfc.h" - -//implementations of deprecated string_printf methods, with a pragma to disable warnings when they reference other deprecated methods. - -#pragma warning(disable:4996) - -namespace pfc { - -void string_printf::run(const char * fmt,va_list list) {g_run(*this,fmt,list);} - -string_printf_va::string_printf_va(const char * fmt,va_list list) {string_printf::g_run(*this,fmt,list);} - -void string_printf::g_run(string_base & out,const char * fmt,va_list list) -{ - out.reset(); - while(*fmt) - { - if (*fmt=='%') - { - fmt++; - if (*fmt=='%') - { - out.add_char('%'); - fmt++; - } - else - { - bool force_sign = false; - if (*fmt=='+') - { - force_sign = true; - fmt++; - } - char padchar = (*fmt == '0') ? '0' : ' '; - t_size pad = 0; - while(*fmt>='0' && *fmt<='9') - { - pad = pad * 10 + (*fmt - '0'); - fmt++; - } - - if (*fmt=='s' || *fmt=='S') - { - const char * ptr = va_arg(list,const char*); - t_size len = strlen(ptr); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(ptr); - fmt++; - - } - else if (*fmt=='i' || *fmt=='I' || *fmt=='d' || *fmt=='D') - { - char temp[8*sizeof(int)]; - int val = va_arg(list,int); - if (force_sign && val>0) out.add_char('+'); - _itoa_s(val,temp,10); - t_size len = strlen(temp); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(temp); - fmt++; - } - else if (*fmt=='u' || *fmt=='U') - { - char temp[8*sizeof(int)]; - int val = va_arg(list,int); - if (force_sign && val>0) out.add_char('+'); - _ultoa_s(val,temp,10); - t_size len = strlen(temp); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(temp); - fmt++; - } - else if (*fmt=='x' || *fmt=='X') - { - char temp[8*sizeof(int)]; - int val = va_arg(list,int); - if (force_sign && val>0) out.add_char('+'); - _ultoa_s(val,temp,16); - if (*fmt=='X') - { - char * t = temp; - while(*t) - { - if (*t>='a' && *t<='z') - *t += 'A' - 'a'; - t++; - } - } - t_size len = strlen(temp); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(temp); - fmt++; - } - else if (*fmt=='c' || *fmt=='C') - { - out.add_char(va_arg(list,char)); - fmt++; - } - } - } - else - { - out.add_char(*(fmt++)); - } - } -} - -string_printf::string_printf(const char * fmt,...) -{ - va_list list; - va_start(list,fmt); - run(fmt,list); - va_end(list); -} - - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/profiler.cpp b/tools/vio2sf/src/foobar/pfc/profiler.cpp deleted file mode 100644 index 3ec7ae578..000000000 --- a/tools/vio2sf/src/foobar/pfc/profiler.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "pfc.h" - -#ifdef _WINDOWS -namespace pfc { - -profiler_static::profiler_static(const char * p_name) -{ - name = p_name; - total_time = 0; - num_called = 0; -} - -profiler_static::~profiler_static() -{ - try { - pfc::string_fixed_t<511> message; - message << "profiler: " << pfc::format_pad_left >(48,' ',name) << " - " << - pfc::format_pad_right >(16,' ',pfc::format_uint(total_time) ) << " cycles"; - - if (num_called > 0) { - message << " (executed " << num_called << " times, " << (total_time / num_called) << " average)"; - } - message << "\n"; - OutputDebugStringA(message); - } catch(...) { - //should never happen - OutputDebugString(_T("unexpected profiler failure\n")); - } -} - -} -#else -//PORTME -#endif diff --git a/tools/vio2sf/src/foobar/pfc/profiler.h b/tools/vio2sf/src/foobar/pfc/profiler.h deleted file mode 100644 index 11715d3a5..000000000 --- a/tools/vio2sf/src/foobar/pfc/profiler.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef _PFC_PROFILER_H_ -#define _PFC_PROFILER_H_ - -#ifdef _WINDOWS - -#include -namespace pfc { -class profiler_static { -public: - profiler_static(const char * p_name); - ~profiler_static(); - void add_time(t_int64 delta) {total_time+=delta;num_called++;} -private: - const char * name; - t_uint64 total_time,num_called; -}; - -class profiler_local { -public: - profiler_local(profiler_static * p_owner) { - owner = p_owner; - start = __rdtsc(); - } - ~profiler_local() { - t_int64 end = __rdtsc(); - owner->add_time(end-start); - } -private: - t_int64 start; - profiler_static * owner; -}; - -#define profiler(name) \ - static pfc::profiler_static profiler_static_##name(#name); \ - pfc::profiler_local profiler_local_##name(&profiler_static_##name); - - -class hires_timer { -public: - void start() { - m_start = g_query(); - } - double query() const { - return _query( g_query() ); - } - double query_reset() { - t_uint64 current = g_query(); - double ret = _query(current); - m_start = current; - return ret; - } -private: - double _query(t_uint64 p_val) const { - return (double)( p_val - m_start ) / (double) g_query_freq(); - } - static t_uint64 g_query() { - LARGE_INTEGER val; - if (!QueryPerformanceCounter(&val)) throw pfc::exception_not_implemented(); - return val.QuadPart; - } - static t_uint64 g_query_freq() { - LARGE_INTEGER val; - if (!QueryPerformanceFrequency(&val)) throw pfc::exception_not_implemented(); - return val.QuadPart; - } - t_uint64 m_start; -}; - -class lores_timer { -public: - void start() { - _start(GetTickCount()); - } - - double query() const { - return _query(GetTickCount()); - } - double query_reset() { - t_uint32 time = GetTickCount(); - double ret = _query(time); - _start(time); - return ret; - } -private: - void _start(t_uint32 p_time) {m_last_seen = m_start = p_time;} - double _query(t_uint32 p_time) const { - t_uint64 time = p_time; - if (time < (m_last_seen & 0xFFFFFFFF)) time += 0x100000000; - m_last_seen = (m_last_seen & 0xFFFFFFFF00000000) + time; - return (double)(m_last_seen - m_start) / 1000.0; - } - t_uint64 m_start; - mutable t_uint64 m_last_seen; -}; -} -#else -//PORTME -#endif - -#endif diff --git a/tools/vio2sf/src/foobar/pfc/ptr_list.h b/tools/vio2sf/src/foobar/pfc/ptr_list.h deleted file mode 100644 index 8762799cd..000000000 --- a/tools/vio2sf/src/foobar/pfc/ptr_list.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __PFC_PTR_LIST_H_ -#define __PFC_PTR_LIST_H_ - -namespace pfc { - - template > - class ptr_list_t : public B - { - public: - ptr_list_t() {} - ptr_list_t(const ptr_list_t & p_source) {*this = p_source;} - - void free_by_idx(t_size n) {free_mask(bit_array_one(n));} - void free_all() {this->remove_all_ex(free);} - void free_mask(const bit_array & p_mask) {this->remove_mask_ex(p_mask,free);} - - void delete_item(T* ptr) {delete_by_idx(find_item(ptr));} - - void delete_by_idx(t_size p_index) { - delete_mask(bit_array_one(p_index)); - } - - void delete_all() { - this->remove_all_ex(pfc::delete_t); - } - - void delete_mask(const bit_array & p_mask) { - this->remove_mask_ex(p_mask,pfc::delete_t); - } - - T * operator[](t_size n) const {return this->get_item(n);} - }; - - template - class ptr_list_hybrid_t : public ptr_list_t > { - public: - ptr_list_hybrid_t() {} - ptr_list_hybrid_t(const ptr_list_hybrid_t & p_source) {*this = p_source;} - }; - - typedef ptr_list_t ptr_list; -} - - -#endif //__PFC_PTR_LIST_H_ diff --git a/tools/vio2sf/src/foobar/pfc/rcptr.h b/tools/vio2sf/src/foobar/pfc/rcptr.h deleted file mode 100644 index 5a55cb02b..000000000 --- a/tools/vio2sf/src/foobar/pfc/rcptr.h +++ /dev/null @@ -1,250 +0,0 @@ -namespace pfc { - - class rc_container_base { - public: - long add_ref() throw() { - return ++m_counter; - } - long release() throw() { - long ret = --m_counter; - if (ret == 0) PFC_ASSERT_NO_EXCEPTION( delete this ); - return ret; - } - protected: - virtual ~rc_container_base() {} - private: - refcounter m_counter; - }; - - template - class rc_container_t : public rc_container_base { - public: - TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(rc_container_t,m_object) - - t_object m_object; - }; - - template - class rcptr_t { - private: - typedef rcptr_t t_self; - typedef rc_container_base t_container; - typedef rc_container_t t_container_impl; - public: - rcptr_t() throw() {__init();} - rcptr_t(const t_self & p_source) throw() {__init(p_source);} - t_self const & operator=(const t_self & p_source) throw() {__copy(p_source); return *this;} - - template - rcptr_t(const rcptr_t & p_source) throw() {__init(p_source);} - template - const t_self & operator=(const rcptr_t & p_source) throw() {__copy(p_source); return *this;} - -/* template - operator rcptr_t() const throw() { - rcptr_t temp; - if (is_valid()) temp.__set_from_cast(this->m_container,this->m_ptr); - return temp; - }*/ - - - template - bool operator==(const rcptr_t & p_other) const throw() { - return m_container == p_other.__container(); - } - - template - bool operator!=(const rcptr_t & p_other) const throw() { - return m_container != p_other.__container(); - } - - void __set_from_cast(t_container * p_container,t_object * p_ptr) throw() { - //addref first because in rare cases this is the same pointer as the one we currently own - if (p_container != NULL) p_container->add_ref(); - release(); - m_container = p_container; - m_ptr = p_ptr; - } - - bool is_valid() const throw() {return m_container != NULL;} - bool is_empty() const throw() {return m_container == NULL;} - - - ~rcptr_t() throw() {release();} - - void release() throw() { - t_container * temp = m_container; - m_ptr = NULL; - m_container = NULL; - if (temp != NULL) temp->release(); - } - - - template - rcptr_t static_cast_t() const throw() { - rcptr_t temp; - if (is_valid()) temp.__set_from_cast(this->m_container,static_cast(this->m_ptr)); - return temp; - } - - void new_t() { - on_new(new t_container_impl()); - } - - template - void new_t(t_param1 const & p_param1) { - on_new(new t_container_impl(p_param1)); - } - - template - void new_t(t_param1 const & p_param1, t_param2 const & p_param2) { - on_new(new t_container_impl(p_param1,p_param2)); - } - - template - void new_t(t_param1 const & p_param1, t_param2 const & p_param2,t_param3 const & p_param3) { - on_new(new t_container_impl(p_param1,p_param2,p_param3)); - } - - template - void new_t(t_param1 const & p_param1, t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4) { - on_new(new t_container_impl(p_param1,p_param2,p_param3,p_param4)); - } - - template - void new_t(t_param1 const & p_param1, t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4,t_param5 const & p_param5) { - on_new(new t_container_impl(p_param1,p_param2,p_param3,p_param4,p_param5)); - } - - template - void new_t(t_param1 const & p_param1, t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4,t_param5 const & p_param5,t_param6 const & p_param6) { - on_new(new t_container_impl(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6)); - } - - static t_self g_new_t() { - t_self temp; - temp.new_t(); - return temp; - } - - template - static t_self g_new_t(t_param1 const & p_param1) { - t_self temp; - temp.new_t(p_param1); - return temp; - } - - template - static t_self g_new_t(t_param1 const & p_param1,t_param2 const & p_param2) { - t_self temp; - temp.new_t(p_param1,p_param2); - return temp; - } - - template - static t_self g_new_t(t_param1 const & p_param1,t_param2 const & p_param2,t_param3 const & p_param3) { - t_self temp; - temp.new_t(p_param1,p_param2,p_param3); - return temp; - } - - template - static t_self g_new_t(t_param1 const & p_param1,t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4) { - t_self temp; - temp.new_t(p_param1,p_param2,p_param3,p_param4); - return temp; - } - - template - static t_self g_new_t(t_param1 const & p_param1,t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4,t_param5 const & p_param5) { - t_self temp; - temp.new_t(p_param1,p_param2,p_param3,p_param4,p_param5); - return temp; - } - - t_object & operator*() const throw() {return *this->m_ptr;} - - t_object * operator->() const throw() {return this->m_ptr;} - - - t_container * __container() const throw() {return m_container;} - private: - void __init() throw() {m_container = NULL; m_ptr = NULL;} - - template - void __init(const rcptr_t & p_source) throw() { - m_container = p_source.__container(); - m_ptr = &*p_source; - if (m_container != NULL) m_container->add_ref(); - } - template - void __copy(const rcptr_t & p_source) throw() { - __set_from_cast(p_source.__container(),&*p_source); - } - void on_new(t_container_impl * p_container) throw() { - this->release(); - p_container->add_ref(); - this->m_ptr = &p_container->m_object; - this->m_container = p_container; - } - - t_container * m_container; - t_object * m_ptr; - }; - - template - rcptr_t rcnew_t() { - rcptr_t temp; - temp.new_t(); - return temp; - } - - template - rcptr_t rcnew_t(t_param1 const & p_param1) { - rcptr_t temp; - temp.new_t(p_param1); - return temp; - } - - template - rcptr_t rcnew_t(t_param1 const & p_param1,t_param2 const & p_param2) { - rcptr_t temp; - temp.new_t(p_param1,p_param2); - return temp; - } - - template - rcptr_t rcnew_t(t_param1 const & p_param1,t_param2 const & p_param2,t_param3 const & p_param3) { - rcptr_t temp; - temp.new_t(p_param1,p_param2,p_param3); - return temp; - } - - template - rcptr_t rcnew_t(t_param1 const & p_param1,t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4) { - rcptr_t temp; - temp.new_t(p_param1,p_param2,p_param3,p_param4); - return temp; - } - - template - rcptr_t rcnew_t(t_param1 const & p_param1,t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4,t_param5 const & p_param5) { - rcptr_t temp; - temp.new_t(p_param1,p_param2,p_param3,p_param4,p_param5); - return temp; - } - - template - rcptr_t rcnew_t(t_param1 const & p_param1,t_param2 const & p_param2,t_param3 const & p_param3,t_param4 const & p_param4,t_param5 const & p_param5,t_param6 const & p_param6) { - rcptr_t temp; - temp.new_t(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6); - return temp; - } - - class traits_rcptr : public traits_default { - public: - enum { realloc_safe = true, constructor_may_fail = false }; - }; - - template class traits_t > : public traits_rcptr {}; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/ref_counter.h b/tools/vio2sf/src/foobar/pfc/ref_counter.h deleted file mode 100644 index 539e4bc3a..000000000 --- a/tools/vio2sf/src/foobar/pfc/ref_counter.h +++ /dev/null @@ -1,122 +0,0 @@ -namespace pfc { - class counter { - public: - counter(long p_val = 0) : m_val(p_val) {} -#ifdef _WINDOWS - long operator++() throw() {return InterlockedIncrement(&m_val);} - long operator--() throw() {return InterlockedDecrement(&m_val);} - long operator++(int) throw() {return InterlockedIncrement(&m_val)-1;} - long operator--(int) throw() {return InterlockedDecrement(&m_val)+1;} -#else - long operator++() {return ++m_val;} - long operator--() {return --m_val;} - long operator++(int) {return m_val++;} - long operator--(int) {return m_val--;} -#pragma message("PORTME") -#endif - operator long() const throw() {return m_val;} - typedef long t_val; - private: - volatile long m_val; - }; - - typedef counter refcounter; - - class NOVTABLE refcounted_object_root - { - public: - void refcount_add_ref() throw() {++m_counter;} - void refcount_release() throw() {if (--m_counter == 0) delete this;} - void _refcount_release_temporary() throw() {--m_counter;}//for internal use only! - protected: - refcounted_object_root() {} - virtual ~refcounted_object_root() {} - private: - refcounter m_counter; - }; - - template - class refcounted_object_ptr_t { - private: - typedef refcounted_object_ptr_t t_self; - public: - inline refcounted_object_ptr_t() throw() : m_ptr(NULL) {} - inline refcounted_object_ptr_t(T* p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);} - inline refcounted_object_ptr_t(const t_self & p_source) throw() : m_ptr(NULL) {copy(p_source);} - - template - inline refcounted_object_ptr_t(t_source * p_ptr) throw() : m_ptr(NULL) {copy(p_ptr);} - - template - inline refcounted_object_ptr_t(const refcounted_object_ptr_t & p_source) throw() : m_ptr(NULL) {copy(p_source);} - - inline ~refcounted_object_ptr_t() throw() {if (m_ptr != NULL) m_ptr->refcount_release();} - - template - inline void copy(t_source * p_ptr) throw() { - T* torel = pfc::replace_t(m_ptr,pfc::safe_ptr_cast(p_ptr)); - if (m_ptr != NULL) m_ptr->refcount_add_ref(); - if (torel != NULL) torel->refcount_release(); - - } - - template - inline void copy(const refcounted_object_ptr_t & p_source) throw() {copy(p_source.get_ptr());} - - - inline const t_self & operator=(const t_self & p_source) throw() {copy(p_source); return *this;} - inline const t_self & operator=(T * p_ptr) throw() {copy(p_ptr); return *this;} - - template inline t_self & operator=(const refcounted_object_ptr_t & p_source) throw() {copy(p_source); return *this;} - template inline t_self & operator=(t_source * p_ptr) throw() {copy(p_ptr); return *this;} - - inline void release() throw() { - T * temp = pfc::replace_t(m_ptr,(T*)NULL); - if (temp != NULL) temp->refcount_release(); - } - - - inline T& operator*() const throw() {return *m_ptr;} - - inline T* operator->() const throw() {PFC_ASSERT(m_ptr != NULL);return m_ptr;} - - inline T* get_ptr() const throw() {return m_ptr;} - - inline bool is_valid() const throw() {return m_ptr != NULL;} - inline bool is_empty() const throw() {return m_ptr == NULL;} - - inline bool operator==(const t_self & p_item) const throw() {return m_ptr == p_item.get_ptr();} - inline bool operator!=(const t_self & p_item) const throw() {return m_ptr != p_item.get_ptr();} - inline bool operator>(const t_self & p_item) const throw() {return m_ptr > p_item.get_ptr();} - inline bool operator<(const t_self & p_item) const throw() {return m_ptr < p_item.get_ptr();} - - - inline T* __unsafe_duplicate() const throw()//should not be used ! temporary ! - { - if (m_ptr) m_ptr->refcount_add_ref(); - return m_ptr; - } - - inline T* detach() throw() {//should not be used ! temporary ! - T* ret = m_ptr; - m_ptr = 0; - return ret; - } - - inline void attach(T * p_ptr) throw() {//should not be used ! temporary ! - release(); - m_ptr = p_ptr; - } - inline t_self & operator<<(t_self & p_source) throw() {attach(p_source.detach());return *this;} - inline t_self & operator>>(t_self & p_dest) throw() {p_dest.attach(detach());return *this;} - private: - T* m_ptr; - }; - - template - class traits_t > : public traits_default { - public: - enum { realloc_safe = true, constructor_may_fail = false}; - }; - -}; \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/selftest.cpp b/tools/vio2sf/src/foobar/pfc/selftest.cpp deleted file mode 100644 index ed2271c37..000000000 --- a/tools/vio2sf/src/foobar/pfc/selftest.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "pfc.h" - -static void selftest() //never called, testing done at compile time -{ - pfc::static_assert_t(); - pfc::static_assert_t(); - pfc::static_assert_t(); - pfc::static_assert_t(); - - pfc::static_assert_t(); - pfc::static_assert_t(); - pfc::static_assert_t(); - pfc::static_assert_t(); - - pfc::static_assert_t(); - pfc::static_assert_t(); - - pfc::static_assert_t(); - pfc::static_assert_t(); - - pfc::static_assert_t(); - - pfc::static_assert_t(); - - /*typedef pfc::avltree_t t_asdf; - t_asdf asdf; asdf.add_item(1); - t_asdf::iterator iter = asdf._first_var(); - t_asdf::const_iterator iter2 = asdf._first_var();*/ -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/sort.cpp b/tools/vio2sf/src/foobar/pfc/sort.cpp deleted file mode 100644 index 2849992b6..000000000 --- a/tools/vio2sf/src/foobar/pfc/sort.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "pfc.h" - -#if defined(_M_IX86) || defined(_M_IX64) -#include -#define PFC_HAVE_RDTSC -#endif - -namespace pfc { - -void swap_void(void * item1,void * item2,t_size width) -{ - unsigned char * ptr1 = (unsigned char*)item1, * ptr2 = (unsigned char*)item2; - t_size n; - unsigned char temp; - for(n=0;n done; - done.set_size(done_size); - pfc::memset_t(done,(unsigned char)0); - t_size n; - for(n=0;nn); - assert(n done; - done.set_size(done_size); - pfc::memset_t(done,(unsigned char)0); - t_size n; - for(n=0;nn); - assert(n 0) pfc::swap_t(p_elem1,p_elem2); -} - - -#ifdef PFC_HAVE_RDTSC -static inline t_uint64 uniqueVal() {return __rdtsc();} -#else -static counter::t_val uniqueVal() { - static counter c; return ++c; -} -#endif - -static t_size myrand(t_size count) { - static_assert(); - - t_uint64 val; - val = (t_uint64) rand() | (t_uint64)( (t_uint32)rand() << 16 ); - - val ^= uniqueVal(); - - return (t_size)(val % count); -} - -inline static t_size __pivot_helper(pfc::sort_callback & p_callback,t_size const p_base,t_size const p_count) { - PFC_ASSERT(p_count > 2); - - //t_size val1 = p_base, val2 = p_base + (p_count / 2), val3 = p_base + (p_count - 1); - - t_size val1 = myrand(p_count), val2 = myrand(p_count-1), val3 = myrand(p_count-2); - if (val2 >= val1) val2++; - if (val3 >= val1) val3++; - if (val3 >= val2) val3++; - - val1 += p_base; val2 += p_base; val3 += p_base; - - __sort_2elem_helper(p_callback,val1,val2); - __sort_2elem_helper(p_callback,val1,val3); - __sort_2elem_helper(p_callback,val2,val3); - - return val2; -} - -static void newsort(pfc::sort_callback & p_callback,t_size const p_base,t_size const p_count) { - if (p_count <= 4) { - squaresort(p_callback,p_base,p_count); - return; - } - - t_size pivot = __pivot_helper(p_callback,p_base,p_count); - - { - const t_size target = p_base + p_count - 1; - if (pivot != target) { - p_callback.swap(pivot,target); pivot = target; - } - } - - - t_size partition = p_base; - { - bool asdf = false; - for(t_size walk = p_base; walk < pivot; ++walk) { - const int comp = p_callback.compare(walk,pivot); - bool trigger = false; - if (comp == 0) { - trigger = asdf; - asdf = !asdf; - } else if (comp < 0) { - trigger = true; - } - if (trigger) { - if (partition != walk) p_callback.swap(partition,walk); - partition++; - } - } - } - if (pivot != partition) { - p_callback.swap(pivot,partition); pivot = partition; - } - - newsort(p_callback,p_base,pivot-p_base); - newsort(p_callback,pivot+1,p_count-(pivot+1-p_base)); -} - -void sort(pfc::sort_callback & p_callback,t_size p_num) { - srand((unsigned int)(uniqueVal() ^ p_num)); - newsort(p_callback,0,p_num); -} - - -void sort_void(void * base,t_size num,t_size width,int (*comp)(const void *, const void *) ) -{ - sort_void_ex(base,num,width,comp,swap_void); -} - - - - -sort_callback_stabilizer::sort_callback_stabilizer(sort_callback & p_chain,t_size p_count) -: m_chain(p_chain) -{ - m_order.set_size(p_count); - t_size n; - for(n=0;n - class reorder_callback_impl_t : public reorder_callback - { - public: - reorder_callback_impl_t(t_container & p_data) : m_data(p_data) {} - void swap(t_size p_index1,t_size p_index2) - { - pfc::swap_t(m_data[p_index1],m_data[p_index2]); - } - private: - t_container & m_data; - }; - - class reorder_callback_impl_delta : public reorder_callback - { - public: - reorder_callback_impl_delta(reorder_callback & p_data,t_size p_delta) : m_data(p_data), m_delta(p_delta) {} - void swap(t_size p_index1,t_size p_index2) - { - m_data.swap(p_index1+m_delta,p_index2+m_delta); - } - private: - reorder_callback & m_data; - t_size m_delta; - }; - - template - void reorder_t(t_container & p_data,const t_size * p_order,t_size p_count) - { - reorder(reorder_callback_impl_t(p_data),p_order,p_count); - } - - template - void reorder_partial_t(t_container & p_data,t_size p_base,const t_size * p_order,t_size p_count) - { - reorder(reorder_callback_impl_delta(reorder_callback_impl_t(p_data),p_base),p_order,p_count); - } - - template - class reorder_callback_impl_ptr_t : public reorder_callback - { - public: - reorder_callback_impl_ptr_t(T * p_data) : m_data(p_data) {} - void swap(t_size p_index1,t_size p_index2) - { - pfc::swap_t(m_data[p_index1],m_data[p_index2]); - } - private: - T* m_data; - }; - - - template - void reorder_ptr_t(T* p_data,const t_size * p_order,t_size p_count) - { - reorder(reorder_callback_impl_ptr_t(p_data),p_order,p_count); - } - - - - class NOVTABLE sort_callback - { - public: - virtual int compare(t_size p_index1, t_size p_index2) const = 0; - virtual void swap(t_size p_index1, t_size p_index2) = 0; - void swap_check(t_size p_index1, t_size p_index2) {if (compare(p_index1,p_index2) > 0) swap(p_index1,p_index2);} - }; - - class sort_callback_stabilizer : public sort_callback - { - public: - sort_callback_stabilizer(sort_callback & p_chain,t_size p_count); - virtual int compare(t_size p_index1, t_size p_index2) const; - virtual void swap(t_size p_index1, t_size p_index2); - private: - sort_callback & m_chain; - array_t m_order; - }; - - void sort(sort_callback & p_callback,t_size p_count); - void sort_stable(sort_callback & p_callback,t_size p_count); - - void sort_void_ex(void *base,t_size num,t_size width, int (*comp)(const void *, const void *),void (*swap)(void *, void *, t_size) ); - void sort_void(void * base,t_size num,t_size width,int (*comp)(const void *, const void *) ); - - template - class sort_callback_impl_simple_wrap_t : public sort_callback - { - public: - sort_callback_impl_simple_wrap_t(t_container & p_data, t_compare p_compare) : m_data(p_data), m_compare(p_compare) {} - int compare(t_size p_index1, t_size p_index2) const - { - return m_compare(m_data[p_index1],m_data[p_index2]); - } - - void swap(t_size p_index1, t_size p_index2) - { - swap_t(m_data[p_index1],m_data[p_index2]); - } - private: - t_container & m_data; - t_compare m_compare; - }; - - template - class sort_callback_impl_auto_wrap_t : public sort_callback - { - public: - sort_callback_impl_auto_wrap_t(t_container & p_data) : m_data(p_data) {} - int compare(t_size p_index1, t_size p_index2) const - { - return compare_t(m_data[p_index1],m_data[p_index2]); - } - - void swap(t_size p_index1, t_size p_index2) - { - swap_t(m_data[p_index1],m_data[p_index2]); - } - private: - t_container & m_data; - }; - - template - class sort_callback_impl_permutation_wrap_t : public sort_callback - { - public: - sort_callback_impl_permutation_wrap_t(const t_container & p_data, t_compare p_compare,t_permutation const & p_permutation) : m_data(p_data), m_compare(p_compare), m_permutation(p_permutation) {} - int compare(t_size p_index1, t_size p_index2) const - { - return m_compare(m_data[m_permutation[p_index1]],m_data[m_permutation[p_index2]]); - } - - void swap(t_size p_index1, t_size p_index2) - { - swap_t(m_permutation[p_index1],m_permutation[p_index2]); - } - private: - const t_container & m_data; - t_compare m_compare; - t_permutation const & m_permutation; - }; - - template - static void sort_t(t_container & p_data,t_compare p_compare,t_size p_count) - { - sort(sort_callback_impl_simple_wrap_t(p_data,p_compare),p_count); - } - - template - static void sort_stable_t(t_container & p_data,t_compare p_compare,t_size p_count) - { - sort_stable(sort_callback_impl_simple_wrap_t(p_data,p_compare),p_count); - } - - template - static void sort_get_permutation_t(const t_container & p_data,t_compare p_compare,t_size p_count,t_permutation const & p_permutation) - { - sort(sort_callback_impl_permutation_wrap_t(p_data,p_compare,p_permutation),p_count); - } - - template - static void sort_stable_get_permutation_t(const t_container & p_data,t_compare p_compare,t_size p_count,t_permutation const & p_permutation) - { - sort_stable(sort_callback_impl_permutation_wrap_t(p_data,p_compare,p_permutation),p_count); - } - -} diff --git a/tools/vio2sf/src/foobar/pfc/stdafx.cpp b/tools/vio2sf/src/foobar/pfc/stdafx.cpp deleted file mode 100644 index 72044fc8b..000000000 --- a/tools/vio2sf/src/foobar/pfc/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ -//cpp used to generate precompiled header -#include "pfc.h" \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/string.cpp b/tools/vio2sf/src/foobar/pfc/string.cpp deleted file mode 100644 index 14c086a59..000000000 --- a/tools/vio2sf/src/foobar/pfc/string.cpp +++ /dev/null @@ -1,850 +0,0 @@ -#include "pfc.h" - -namespace pfc { - -void string_receiver::add_char(t_uint32 p_char) -{ - char temp[8]; - t_size len = utf8_encode_char(p_char,temp); - if (len>0) add_string(temp,len); -} - -void string_base::skip_trailing_char(unsigned skip) -{ - const char * str = get_ptr(); - t_size ptr,trunc; - bool need_trunc = false; - for(ptr=0;str[ptr];) - { - unsigned c; - t_size delta = utf8_decode_char(str+ptr,c); - if (delta==0) break; - if (c==skip) - { - need_trunc = true; - trunc = ptr; - } - else - { - need_trunc = false; - } - ptr += delta; - } - if (need_trunc) truncate(trunc); -} - -format_time::format_time(t_uint64 p_seconds) { - t_uint64 length = p_seconds; - unsigned weeks,days,hours,minutes,seconds; - - weeks = (unsigned)( ( length / (60*60*24*7) ) ); - days = (unsigned)( ( length / (60*60*24) ) % 7 ); - hours = (unsigned) ( ( length / (60 * 60) ) % 24); - minutes = (unsigned) ( ( length / (60 ) ) % 60 ); - seconds = (unsigned) ( ( length ) % 60 ); - - if (weeks) { - m_buffer << weeks << "wk "; - } - if (days || weeks) { - m_buffer << days << "d "; - } - if (hours || days || weeks) { - m_buffer << hours << ":" << format_uint(minutes,2) << ":" << format_uint(seconds,2); - } else { - m_buffer << minutes << ":" << format_uint(seconds,2); - } -} - -bool is_path_separator(unsigned c) -{ - return c=='\\' || c=='/' || c=='|' || c==':'; -} - -bool is_path_bad_char(unsigned c) -{ -#ifdef _WINDOWS - return c=='\\' || c=='/' || c=='|' || c==':' || c=='*' || c=='?' || c=='\"' || c=='>' || c=='<'; -#else -#error portme -#endif -} - - - -char * strdup_n(const char * src,t_size len) -{ - len = strlen_max(src,len); - char * ret = (char*)malloc(len+1); - if (ret) - { - memcpy(ret,src,len); - ret[len]=0; - } - return ret; -} - -string_filename::string_filename(const char * fn) -{ - fn += pfc::scan_filename(fn); - const char * ptr=fn,*dot=0; - while(*ptr && *ptr!='?') - { - if (*ptr=='.') dot=ptr; - ptr++; - } - - if (dot && dot>fn) set_string(fn,dot-fn); - else set_string(fn); -} - -string_filename_ext::string_filename_ext(const char * fn) -{ - fn += pfc::scan_filename(fn); - const char * ptr = fn; - while(*ptr && *ptr!='?') ptr++; - set_string(fn,ptr-fn); -} - -string_extension::string_extension(const char * src) -{ - buffer[0]=0; - const char * start = src + pfc::scan_filename(src); - const char * end = start + strlen(start); - const char * ptr = end-1; - while(ptr>start && *ptr!='.') - { - if (*ptr=='?') end=ptr; - ptr--; - } - - if (ptr>=start && *ptr=='.') - { - ptr++; - t_size len = end-ptr; - if (len temp; - t_size outptr; - - if (out_max == 0) return; - out_max--;//for null terminator - - outptr = 0; - - if (outptr == out_max) {out[outptr]=0;return;} - - if (val<0) {out[outptr++] = '-'; val = -val;} - else if (b_sign) {out[outptr++] = '+';} - - if (outptr == out_max) {out[outptr]=0;return;} - - - { - double powval = pow((double)10.0,(double)precision); - temp << (t_int64)floor(val * powval + 0.5); - //_i64toa(blargh,temp,10); - } - - const t_size temp_len = temp.length(); - if (temp_len <= precision) - { - out[outptr++] = '0'; - if (outptr == out_max) {out[outptr]=0;return;} - out[outptr++] = '.'; - if (outptr == out_max) {out[outptr]=0;return;} - t_size d; - for(d=precision-temp_len;d;d--) - { - out[outptr++] = '0'; - if (outptr == out_max) {out[outptr]=0;return;} - } - for(d=0;d='0' && *src<='9') - { - int d = *src - '0'; - val = val * 10 + d; - if (got_dot) div--; - src++; - } - else if (*src=='.' || *src==',') - { - if (got_dot) break; - got_dot = true; - src++; - } - else if (*src=='E' || *src=='e') - { - src++; - div += atoi(src); - break; - } - else break; - } - if (neg) val = -val; - return (double) val * pow(10.0,(double)div); -} - -double string_to_float(const char * src,t_size max) { - //old function wants an oldstyle nullterminated string, and i don't currently care enough to rewrite it as it works appropriately otherwise - char blargh[128]; - if (max > 127) max = 127; - t_size walk; - for(walk = 0; walk < max && src[walk]; walk++) blargh[walk] = src[walk]; - blargh[walk] = 0; - return pfc_string_to_float_internal(blargh); -} - - - -void string_base::convert_to_lower_ascii(const char * src,char replace) -{ - reset(); - PFC_ASSERT(replace>0); - while(*src) - { - unsigned c; - t_size delta = utf8_decode_char(src,c); - if (delta==0) {c = replace; delta = 1;} - else if (c>=0x80) c = replace; - add_byte((char)c); - src += delta; - } -} - -void convert_to_lower_ascii(const char * src,t_size max,char * out,char replace) -{ - t_size ptr = 0; - PFC_ASSERT(replace>0); - while(ptr=0x80) c = replace; - *(out++) = (char)c; - ptr += delta; - } - *out = 0; -} - -t_size strstr_ex(const char * p_string,t_size p_string_len,const char * p_substring,t_size p_substring_len) throw() -{ - p_string_len = strlen_max(p_string,p_string_len); - p_substring_len = strlen_max(p_substring,p_substring_len); - t_size index = 0; - while(index + p_substring_len <= p_string_len) - { - if (memcmp(p_string+index,p_substring,p_substring_len) == 0) return index; - t_size delta = utf8_char_len(p_string+index,p_string_len - index); - if (delta == 0) break; - index += delta; - } - return ~0; -} - -unsigned atoui_ex(const char * p_string,t_size p_string_len) -{ - unsigned ret = 0; t_size ptr = 0; - while(ptr= '0' && c <= '9' ) ) break; - ret = ret * 10 + (unsigned)( c - '0' ); - ptr++; - } - return ret; -} - -int strcmp_ex(const char* p1,t_size n1,const char* p2,t_size n2) -{ - t_size idx = 0; - n1 = strlen_max(p1,n1); n2 = strlen_max(p2,n2); - for(;;) - { - if (idx == n1 && idx == n2) return 0; - else if (idx == n1) return -1;//end of param1 - else if (idx == n2) return 1;//end of param2 - - char c1 = p1[idx], c2 = p2[idx]; - if (c1c2) return 1; - - idx++; - } -} - -t_uint64 atoui64_ex(const char * src,t_size len) { - len = strlen_max(src,len); - t_uint64 ret = 0, mul = 1; - t_size ptr = len; - t_size start = 0; -// start += skip_spacing(src+start,len-start); - - while(ptr>start) - { - char c = src[--ptr]; - if (c>='0' && c<='9') - { - ret += (c-'0') * mul; - mul *= 10; - } - else - { - ret = 0; - mul = 1; - } - } - return ret; -} - - -t_int64 atoi64_ex(const char * src,t_size len) -{ - len = strlen_max(src,len); - t_int64 ret = 0, mul = 1; - t_size ptr = len; - t_size start = 0; - bool neg = false; -// start += skip_spacing(src+start,len-start); - if (start < len && src[start] == '-') {neg = true; start++;} -// start += skip_spacing(src+start,len-start); - - while(ptr>start) - { - char c = src[--ptr]; - if (c>='0' && c<='9') - { - ret += (c-'0') * mul; - mul *= 10; - } - else - { - ret = 0; - mul = 1; - } - } - return neg ? -ret : ret; -} - -int stricmp_ascii_ex(const char * const s1,t_size const len1,const char * const s2,t_size const len2) throw() { - t_size walk1 = 0, walk2 = 0; - for(;;) { - char c1 = (walk1 < len1) ? s1[walk1] : 0; - char c2 = (walk2 < len2) ? s2[walk2] : 0; - c1 = ascii_tolower(c1); c2 = ascii_tolower(c2); - if (c1c2) return 1; - else if (c1 == 0) return 0; - walk1++; - walk2++; - } - -} -int stricmp_ascii(const char * s1,const char * s2) throw() { - for(;;) { - char c1 = ascii_tolower(*s1), c2 = ascii_tolower(*s2); - if (c1c2) return 1; - else if (c1 == 0) return 0; - s1++; - s2++; - } -} - -format_float::format_float(double p_val,unsigned p_width,unsigned p_prec) -{ - char temp[64]; - float_to_string(temp,64,p_val,p_prec,false); - temp[63] = 0; - t_size len = strlen(temp); - if (len < p_width) - m_buffer.add_chars(' ',p_width-len); - m_buffer += temp; -} - -static char format_hex_char(unsigned p_val) -{ - PFC_ASSERT(p_val < 16); - return (p_val < 10) ? p_val + '0' : p_val - 10 + 'A'; -} - -format_hex::format_hex(t_uint64 p_val,unsigned p_width) -{ - if (p_width > 16) p_width = 16; - else if (p_width == 0) p_width = 1; - char temp[16]; - unsigned n; - for(n=0;n<16;n++) - { - temp[15-n] = format_hex_char((unsigned)(p_val & 0xF)); - p_val >>= 4; - } - - for(n=0;n<16 && temp[n] == '0';n++) {} - - if (n > 16 - p_width) n = 16 - p_width; - - char * out = m_buffer; - for(;n<16;n++) - *(out++) = temp[n]; - *out = 0; -} - -static char format_hex_char_lowercase(unsigned p_val) -{ - PFC_ASSERT(p_val < 16); - return (p_val < 10) ? p_val + '0' : p_val - 10 + 'a'; -} - -format_hex_lowercase::format_hex_lowercase(t_uint64 p_val,unsigned p_width) -{ - if (p_width > 16) p_width = 16; - else if (p_width == 0) p_width = 1; - char temp[16]; - unsigned n; - for(n=0;n<16;n++) - { - temp[15-n] = format_hex_char_lowercase((unsigned)(p_val & 0xF)); - p_val >>= 4; - } - - for(n=0;n<16 && temp[n] == '0';n++) {} - - if (n > 16 - p_width) n = 16 - p_width; - - char * out = m_buffer; - for(;n<16;n++) - *(out++) = temp[n]; - *out = 0; -} - -format_uint::format_uint(t_uint64 val,unsigned p_width,unsigned p_base) -{ - - enum {max_width = tabsize(m_buffer) - 1}; - - if (p_width > max_width) p_width = max_width; - else if (p_width == 0) p_width = 1; - - char temp[max_width]; - - unsigned n; - for(n=0;n max_width - p_width) n = max_width - p_width; - - char * out = m_buffer; - - for(;n max_width) p_width = max_width; - else if (p_width == 0) p_width = 1; - - if (neg && p_width > 1) p_width --; - - char temp[max_width]; - - unsigned n; - for(n=0;n max_width - p_width) n = max_width - p_width; - - char * out = m_buffer; - - if (neg) *(out++) = '-'; - - for(;n 0 && p_spacing != 0) m_formatter << p_spacing; - m_formatter << format_hex_lowercase(buffer[n],2); - } -} - -format_hexdump::format_hexdump(const void * p_buffer,t_size p_bytes,const char * p_spacing) -{ - t_size n; - const t_uint8 * buffer = (const t_uint8*)p_buffer; - for(n=0;n 0 && p_spacing != 0) m_formatter << p_spacing; - m_formatter << format_hex(buffer[n],2); - } -} - - - -string_replace_extension::string_replace_extension(const char * p_path,const char * p_ext) -{ - m_data = p_path; - t_size dot = m_data.find_last('.'); - if (dot < m_data.scan_filename()) - {//argh - m_data += "."; - m_data += p_ext; - } - else - { - m_data.truncate(dot+1); - m_data += p_ext; - } -} - -string_directory::string_directory(const char * p_path) -{ - t_size ptr = scan_filename(p_path); - if (ptr > 0) m_data.set_string(p_path,ptr-1); -} - -t_size scan_filename(const char * ptr) -{ - t_size n; - t_size _used = strlen(ptr); - for(n=_used-1;n!=~0;n--) - { - if (is_path_separator(ptr[n])) return n+1; - } - return 0; -} - - - -t_size string_find_first(const char * p_string,char p_tofind,t_size p_start) { - return string_find_first_ex(p_string,infinite,&p_tofind,1,p_start); -} -t_size string_find_last(const char * p_string,char p_tofind,t_size p_start) { - return string_find_last_ex(p_string,infinite,&p_tofind,1,p_start); -} -t_size string_find_first(const char * p_string,const char * p_tofind,t_size p_start) { - return string_find_first_ex(p_string,infinite,p_tofind,infinite,p_start); -} -t_size string_find_last(const char * p_string,const char * p_tofind,t_size p_start) { - return string_find_last_ex(p_string,infinite,p_tofind,infinite,p_start); -} - -t_size string_find_first_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start) { - return string_find_first_ex(p_string,p_string_length,&p_tofind,1,p_start); -} -t_size string_find_last_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start) { - return string_find_last_ex(p_string,p_string_length,&p_tofind,1,p_start); -} -t_size string_find_first_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start) { - p_string_length = strlen_max(p_string,p_string_length); p_tofind_length = strlen_max(p_tofind,p_tofind_length); - if (p_string_length >= p_tofind_length) { - t_size max = p_string_length - p_tofind_length; - for(t_size walk = p_start; walk <= max; walk++) { - if (_strcmp_partial_ex(p_string+walk,p_string_length-walk,p_tofind,p_tofind_length) == 0) return walk; - } - } - return infinite; -} -t_size string_find_last_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start) { - p_string_length = strlen_max(p_string,p_string_length); p_tofind_length = strlen_max(p_tofind,p_tofind_length); - if (p_string_length >= p_tofind_length) { - t_size max = min_t(p_string_length - p_tofind_length,p_start); - for(t_size walk = max; walk != (t_size)(-1); walk--) { - if (_strcmp_partial_ex(p_string+walk,p_string_length-walk,p_tofind,p_tofind_length) == 0) return walk; - } - } - return infinite; -} - - -bool string_is_numeric(const char * p_string,t_size p_length) throw() { - bool retval = false; - for(t_size walk = 0; walk < p_length && p_string[walk] != 0; walk++) { - if (!char_is_numeric(p_string[walk])) {retval = false; break;} - retval = true; - } - return retval; -} - - -void string_base::fix_dir_separator(char p_char) { - t_size length = get_length(); - if (length == 0 || get_ptr()[length-1] != p_char) add_byte(p_char); -} - -bool is_multiline(const char * p_string,t_size p_len) { - for(t_size n = 0; n < p_len && p_string[n]; n++) { - switch(p_string[n]) { - case '\r': - case '\n': - return true; - } - } - return false; -} - -static t_uint64 pow10_helper(unsigned p_extra) { - t_uint64 ret = 1; - for(unsigned n = 0; n < p_extra; n++ ) ret *= 10; - return ret; -} - -format_time_ex::format_time_ex(double p_seconds,unsigned p_extra) { - t_uint64 pow10 = pow10_helper(p_extra); - t_uint64 ticks = pfc::rint64(pow10 * p_seconds); - - m_buffer << pfc::format_time(ticks / pow10); - if (p_extra>0) { - m_buffer << "." << pfc::format_uint(ticks % pow10, p_extra); - } -} - -t_uint32 charLower(t_uint32 param) -{ - if (param<128) - { - if (param>='A' && param<='Z') param += 'a' - 'A'; - return param; - } -#ifdef WIN32 - else if (param<0x10000) - { - unsigned ret; -#ifdef UNICODE - ret = (unsigned)CharLowerW((WCHAR*)param); -#else -#error Nein! Verboten! -#endif - return ret; - } - else return param; -#else - else - { - setlocale(LC_CTYPE,""); - return towlower(param); - } -#endif -} - -t_uint32 charUpper(t_uint32 param) -{ - if (param<128) - { - if (param>='a' && param<='z') param += 'A' - 'a'; - return param; - } -#ifdef WIN32 - else if (param<0x10000) - { - unsigned ret; -#ifdef UNICODE - ret = (unsigned)CharUpperW((WCHAR*)param); -#else -#error Nein! Verboten! -#endif - return ret; - } - else return param; -#else - else - { - setlocale(LC_CTYPE,""); - return towupper(param); - } -#endif -} - -void stringToUpperAppend(string_base & out, const char * src, t_size len) { - while(len && *src) { - unsigned c; t_size d; - d = utf8_decode_char(src,c,len); - if (d==0 || d>len) break; - out.add_char(charUpper(c)); - src+=d; - len-=d; - } -} -void stringToLowerAppend(string_base & out, const char * src, t_size len) { - while(len && *src) { - unsigned c; t_size d; - d = utf8_decode_char(src,c,len); - if (d==0 || d>len) break; - out.add_char(charLower(c)); - src+=d; - len-=d; - } -} - -int stringCompareCaseInsensitive(const char * s1, const char * s2) { - for(;;) { - unsigned c1, c2; t_size d1, d2; - d1 = utf8_decode_char(s1,c1); - d2 = utf8_decode_char(s2,c2); - if (d1 == 0 && d2 == 0) return 0; - else if (d1 == 0) return -1; - else if (d2 == 0) return 1; - else { - c1 = charLower(c1); c2 = charLower(c2); - if (c1 < c2) return -1; - else if (c1 > c2) return 1; - } - s1 += d1; s2 += d2; - } -} - -format_file_size_short::format_file_size_short(t_uint64 size) { - t_uint64 scale = 1; - const char * unit = "B"; - const char * const unitTable[] = {"B","KB","MB","GB","TB"}; - for(t_size walk = 1; walk < tabsize(unitTable); ++walk) { - t_uint64 next = scale * 1024; - if (size < next) break; - scale = next; unit = unitTable[walk]; - } - *this << ( size / scale ); - - if (scale > 1 && length() < 3) { - t_size digits = 3 - length(); - const t_uint64 mask = pow_int(10,digits); - t_uint64 remaining = ( (size * mask / scale) % mask ); - while(digits > 0 && (remaining % 10) == 0) { - remaining /= 10; --digits; - } - if (digits > 0) { - *this << "." << format_uint(remaining, (t_uint32)digits); - } - } - *this << unit; - m_scale = scale; -} - -bool string_base::truncate_eol(t_size start) -{ - const char * ptr = get_ptr() + start; - for(t_size n=start;*ptr;n++) - { - if (*ptr==10 || *ptr==13) - { - truncate(n); - return true; - } - ptr++; - } - return false; -} - -bool string_base::fix_eol(const char * append,t_size start) -{ - const bool rv = truncate_eol(start); - if (rv) add_string(append); - return rv; -} - -bool string_base::limit_length(t_size length_in_chars,const char * append) -{ - bool rv = false; - const char * base = get_ptr(), * ptr = base; - while(length_in_chars && utf8_advance(ptr)) length_in_chars--; - if (length_in_chars==0) - { - truncate(ptr-base); - add_string(append); - rv = true; - } - return rv; -} - -} //namespace pfc diff --git a/tools/vio2sf/src/foobar/pfc/string.h b/tools/vio2sf/src/foobar/pfc/string.h deleted file mode 100644 index f7ae3cc4a..000000000 --- a/tools/vio2sf/src/foobar/pfc/string.h +++ /dev/null @@ -1,854 +0,0 @@ -#ifndef _PFC_STRING_H_ -#define _PFC_STRING_H_ - -namespace pfc { - - class NOVTABLE string_receiver { - public: - virtual void add_string(const char * p_string,t_size p_string_size = infinite) = 0; - - void add_char(t_uint32 c);//adds unicode char to the string - void add_byte(char c) {add_string(&c,1);} - void add_chars(t_uint32 p_char,t_size p_count) {for(;p_count;p_count--) add_char(p_char);} - protected: - string_receiver() {} - ~string_receiver() {} - }; - - t_size scan_filename(const char * ptr); - - bool is_path_separator(unsigned c); - bool is_path_bad_char(unsigned c); - bool is_valid_utf8(const char * param,t_size max = infinite); - bool is_lower_ascii(const char * param); - bool is_multiline(const char * p_string,t_size p_len = infinite); - bool has_path_bad_chars(const char * param); - void recover_invalid_utf8(const char * src,char * out,unsigned replace);//out must be enough to hold strlen(char) + 1, or appropiately bigger if replace needs multiple chars - void convert_to_lower_ascii(const char * src,t_size max,char * out,char replace = '?');//out should be at least strlen(src)+1 long - - inline char ascii_tolower(char c) {if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; return c;} - inline char ascii_toupper(char c) {if (c >= 'a' && c <= 'z') c += 'A' - 'a'; return c;} - - t_size string_find_first(const char * p_string,char p_tofind,t_size p_start = 0); //returns infinite if not found - t_size string_find_last(const char * p_string,char p_tofind,t_size p_start = ~0); //returns infinite if not found - t_size string_find_first(const char * p_string,const char * p_tofind,t_size p_start = 0); //returns infinite if not found - t_size string_find_last(const char * p_string,const char * p_tofind,t_size p_start = ~0); //returns infinite if not found - - t_size string_find_first_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = 0); //returns infinite if not found - t_size string_find_last_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = ~0); //returns infinite if not found - t_size string_find_first_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start = 0); //returns infinite if not found - t_size string_find_last_ex(const char * p_string,t_size p_string_length,const char * p_tofind,t_size p_tofind_length,t_size p_start = ~0); //returns infinite if not found - - - template - t_size strlen_max_t(const t_char * ptr,t_size max) { - if (ptr == NULL) return 0; - t_size n = 0; - while(n= '0' && p_char <= '9';} - inline bool char_is_ascii_alpha_upper(char p_char) throw() {return p_char >= 'A' && p_char <= 'Z';} - inline bool char_is_ascii_alpha_lower(char p_char) throw() {return p_char >= 'a' && p_char <= 'z';} - inline bool char_is_ascii_alpha(char p_char) throw() {return char_is_ascii_alpha_lower(p_char) || char_is_ascii_alpha_upper(p_char);} - inline bool char_is_ascii_alphanumeric(char p_char) throw() {return char_is_ascii_alpha(p_char) || char_is_numeric(p_char);} - - unsigned atoui_ex(const char * ptr,t_size max); - t_int64 atoi64_ex(const char * ptr,t_size max); - t_uint64 atoui64_ex(const char * ptr,t_size max); - - t_size strlen_utf8(const char * s,t_size num = ~0) throw();//returns number of characters in utf8 string; num - no. of bytes (optional) - t_size utf8_char_len(const char * s,t_size max = ~0) throw();//returns size of utf8 character pointed by s, in bytes, 0 on error - t_size utf8_char_len_from_header(char c) throw(); - t_size utf8_chars_to_bytes(const char * string,t_size count) throw(); - - t_size strcpy_utf8_truncate(const char * src,char * out,t_size maxbytes); - - t_size utf8_decode_char(const char * src,unsigned & out,t_size src_bytes) throw();//returns length in bytes - t_size utf8_decode_char(const char * src,unsigned & out) throw();//returns length in bytes - - t_size utf8_encode_char(unsigned c,char * out) throw();//returns used length in bytes, max 6 - t_size utf16_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length = ~0) throw(); - t_size utf16_encode_char(unsigned c,wchar_t * out) throw(); - - - t_size strstr_ex(const char * p_string,t_size p_string_len,const char * p_substring,t_size p_substring_len) throw(); - - - t_size skip_utf8_chars(const char * ptr,t_size count) throw(); - char * strdup_n(const char * src,t_size len); - int stricmp_ascii(const char * s1,const char * s2) throw(); - int stricmp_ascii_ex(const char * s1,t_size len1,const char * s2,t_size len2) throw(); - - int strcmp_ex(const char* p1,t_size n1,const char* p2,t_size n2) throw(); - - unsigned utf8_get_char(const char * src); - - inline bool utf8_advance(const char * & var) throw() { - t_size delta = utf8_char_len(var); - var += delta; - return delta>0; - } - - inline bool utf8_advance(char * & var) throw() { - t_size delta = utf8_char_len(var); - var += delta; - return delta>0; - } - - inline const char * utf8_char_next(const char * src) throw() {return src + utf8_char_len(src);} - inline char * utf8_char_next(char * src) throw() {return src + utf8_char_len(src);} - - class NOVTABLE string_base : public pfc::string_receiver { - public: - virtual const char * get_ptr() const = 0; - virtual void add_string(const char * p_string,t_size p_length = ~0) = 0;//same as string_receiver method - virtual void set_string(const char * p_string,t_size p_length = ~0) {reset();add_string(p_string,p_length);} - virtual void truncate(t_size len)=0; - virtual t_size get_length() const {return strlen(get_ptr());} - virtual char * lock_buffer(t_size p_requested_length) = 0; - virtual void unlock_buffer() = 0; - - inline const char * toString() const {return get_ptr();} - - //! For compatibility with old conventions. - inline t_size length() const {return get_length();} - - inline void reset() {truncate(0);} - - inline bool is_empty() const {return *get_ptr()==0;} - - void skip_trailing_char(unsigned c = ' '); - - bool is_valid_utf8() const {return pfc::is_valid_utf8(get_ptr());} - - void convert_to_lower_ascii(const char * src,char replace = '?'); - - inline const string_base & operator= (const char * src) {set_string(src);return *this;} - inline const string_base & operator+= (const char * src) {add_string(src);return *this;} - inline const string_base & operator= (const string_base & src) {set_string(src);return *this;} - inline const string_base & operator+= (const string_base & src) {add_string(src);return *this;} - - bool operator==(const string_base & p_other) const {return strcmp(*this,p_other) == 0;} - bool operator!=(const string_base & p_other) const {return strcmp(*this,p_other) != 0;} - bool operator>(const string_base & p_other) const {return strcmp(*this,p_other) > 0;} - bool operator<(const string_base & p_other) const {return strcmp(*this,p_other) < 0;} - bool operator>=(const string_base & p_other) const {return strcmp(*this,p_other) >= 0;} - bool operator<=(const string_base & p_other) const {return strcmp(*this,p_other) <= 0;} - - inline operator const char * () const {return get_ptr();} - - t_size scan_filename() const {return pfc::scan_filename(get_ptr());} - - t_size find_first(char p_char,t_size p_start = 0) const {return pfc::string_find_first(get_ptr(),p_char,p_start);} - t_size find_last(char p_char,t_size p_start = ~0) const {return pfc::string_find_last(get_ptr(),p_char,p_start);} - t_size find_first(const char * p_string,t_size p_start = 0) const {return pfc::string_find_first(get_ptr(),p_string,p_start);} - t_size find_last(const char * p_string,t_size p_start = ~0) const {return pfc::string_find_last(get_ptr(),p_string,p_start);} - - void fix_dir_separator(char p_char); - - bool truncate_eol(t_size start = 0); - bool fix_eol(const char * append = " (...)",t_size start = 0); - bool limit_length(t_size length_in_chars,const char * append = " (...)"); - - protected: - string_base() {} - ~string_base() {} - }; - - template - class string_fixed_t : public pfc::string_base { - public: - inline string_fixed_t() {init();} - inline string_fixed_t(const string_fixed_t & p_source) {init(); *this = p_source;} - inline string_fixed_t(const char * p_source) {init(); set_string(p_source);} - - inline const string_fixed_t & operator=(const string_fixed_t & p_source) {set_string(p_source);return *this;} - inline const string_fixed_t & operator=(const char * p_source) {set_string(p_source);return *this;} - - char * lock_buffer(t_size p_requested_length) { - if (p_requested_length >= max_length) return NULL; - memset(m_data,0,sizeof(m_data)); - return m_data; - } - void unlock_buffer() { - m_length = strlen(m_data); - } - - inline operator const char * () const {return m_data;} - - const char * get_ptr() const {return m_data;} - - void add_string(const char * ptr,t_size len) { - len = strlen_max(ptr,len); - if (m_length + len < m_length || m_length + len > max_length) throw pfc::exception_overflow(); - for(t_size n=0;n max_length) len = max_length; - if (m_length > len) { - m_length = len; - m_data[len] = 0; - } - } - t_size get_length() const {return m_length;} - private: - inline void init() { - pfc::static_assert<(max_length>1)>(); - m_length = 0; m_data[0] = 0; - } - t_size m_length; - char m_data[max_length+1]; - }; - - template class t_alloc> - class string8_t : public pfc::string_base { - private: - typedef string8_t t_self; - protected: - pfc::array_t m_data; - t_size used; - - inline void makespace(t_size s) { - if (t_alloc::alloc_prioritizes_speed) { - m_data.set_size(s); - } else { - const t_size old_size = m_data.get_size(); - if (old_size < s) - m_data.set_size(s + 16); - else if (old_size > s + 32) - m_data.set_size(s); - } - } - - inline const char * _get_ptr() const throw() {return used > 0 ? m_data.get_ptr() : "";} - - public: - inline const t_self & operator= (const char * src) {set_string(src);return *this;} - inline const t_self & operator+= (const char * src) {add_string(src);return *this;} - inline const t_self & operator= (const string_base & src) {set_string(src);return *this;} - inline const t_self & operator+= (const string_base & src) {add_string(src);return *this;} - inline const t_self & operator= (const t_self & src) {set_string(src);return *this;} - inline const t_self & operator+= (const t_self & src) {add_string(src);return *this;} - - inline operator const char * () const throw() {return _get_ptr();} - - string8_t() : used(0) {} - string8_t(const char * p_string) : used(0) {set_string(p_string);} - string8_t(const char * p_string,t_size p_length) : used(0) {set_string(p_string,p_length);} - string8_t(const t_self & p_string) : used(0) {set_string(p_string);} - string8_t(const string_base & p_string) : used(0) {set_string(p_string);} - - void prealloc(t_size p_size) {m_data.prealloc(p_size+1);} - - const char * get_ptr() const throw() {return _get_ptr();} - - void add_string(const char * p_string,t_size p_length = ~0); - void set_string(const char * p_string,t_size p_length = ~0); - - void truncate(t_size len) - { - if (used>len) {used=len;m_data[len]=0;makespace(used+1);} - } - - t_size get_length() const throw() {return used;} - - - void set_char(unsigned offset,char c); - - t_size replace_nontext_chars(char p_replace = '_'); - t_size replace_char(unsigned c1,unsigned c2,t_size start = 0); - t_size replace_byte(char c1,char c2,t_size start = 0); - void fix_filename_chars(char def = '_',char leave=0);//replace "bad" characters, leave parameter can be used to keep eg. path separators - void remove_chars(t_size first,t_size count); //slow - void insert_chars(t_size first,const char * src, t_size count);//slow - void insert_chars(t_size first,const char * src); - - //for string_buffer class - char * lock_buffer(t_size n) - { - if (n + 1 == 0) throw exception_overflow(); - makespace(n+1); - pfc::memset_t(m_data,(char)0); - return m_data.get_ptr();; - } - - void unlock_buffer() { - if (m_data.get_size() > 0) { - used=strlen(m_data.get_ptr()); - makespace(used+1); - } - } - - void force_reset() {used=0;m_data.force_reset();} - - inline static void g_swap(t_self & p_item1,t_self & p_item2) { - pfc::swap_t(p_item1.m_data,p_item2.m_data); - pfc::swap_t(p_item1.used,p_item2.used); - } - }; - - typedef string8_t string8; - typedef string8_t string8_fast; - typedef string8_t string8_fast_aggressive; - //for backwards compatibility - typedef string8_t string8_fastalloc; - - - template class t_alloc> class traits_t > : public pfc::combine_traits > > { - public: - enum { - needs_constructor = true, - }; - }; -} - - - -#include "string8_impl.h" - -#define PFC_DEPRECATE_PRINTF PFC_DEPRECATE("Use string8/string_fixed_t with operator<< overloads instead.") - -namespace pfc { - - class string_buffer { - private: - string_base & m_owner; - char * m_buffer; - public: - explicit string_buffer(string_base & p_string,t_size p_requeted_length) : m_owner(p_string) {m_buffer = m_owner.lock_buffer(p_requeted_length);} - ~string_buffer() {m_owner.unlock_buffer();} - operator char* () {return m_buffer;} - }; - - class PFC_DEPRECATE_PRINTF string_printf : public string8_fastalloc { - public: - static void g_run(string_base & out,const char * fmt,va_list list); - void run(const char * fmt,va_list list); - - explicit string_printf(const char * fmt,...); - }; - - class PFC_DEPRECATE_PRINTF string_printf_va : public string8_fastalloc { - public: - string_printf_va(const char * fmt,va_list list); - }; - - class format_time { - public: - format_time(t_uint64 p_seconds); - const char * get_ptr() const {return m_buffer;} - operator const char * () const {return m_buffer;} - protected: - string_fixed_t<127> m_buffer; - }; - - - class format_time_ex { - public: - format_time_ex(double p_seconds,unsigned p_extra = 3); - const char * get_ptr() const {return m_buffer;} - operator const char * () const {return m_buffer;} - private: - string_fixed_t<127> m_buffer; - }; - - - - - class string_filename : public string8 { - public: - explicit string_filename(const char * fn); - }; - - class string_filename_ext : public string8 { - public: - explicit string_filename_ext(const char * fn); - }; - - class string_extension - { - char buffer[32]; - public: - inline const char * get_ptr() const {return buffer;} - inline t_size length() const {return strlen(buffer);} - inline operator const char * () const {return buffer;} - inline const char * toString() const {return buffer;} - explicit string_extension(const char * src); - }; - - - class string_replace_extension - { - public: - string_replace_extension(const char * p_path,const char * p_ext); - inline operator const char*() const {return m_data;} - private: - string8 m_data; - }; - - class string_directory - { - public: - string_directory(const char * p_path); - inline operator const char*() const {return m_data;} - private: - string8 m_data; - }; - - void float_to_string(char * out,t_size out_max,double val,unsigned precision,bool force_sign = false);//doesnt add E+X etc, has internal range limits, useful for storing float numbers as strings without having to bother with international coma/dot settings BS - double string_to_float(const char * src,t_size len = infinite); - - template<> - inline void swap_t(string8 & p_item1,string8 & p_item2) - { - string8::g_swap(p_item1,p_item2); - } - - class format_float - { - public: - format_float(double p_val,unsigned p_width = 0,unsigned p_prec = 7); - format_float(const format_float & p_source) {*this = p_source;} - - inline const char * get_ptr() const {return m_buffer.get_ptr();} - inline const char * toString() const {return m_buffer.get_ptr();} - inline operator const char*() const {return m_buffer.get_ptr();} - private: - string8 m_buffer; - }; - - class format_int - { - public: - format_int(t_int64 p_val,unsigned p_width = 0,unsigned p_base = 10); - format_int(const format_int & p_source) {*this = p_source;} - inline const char * get_ptr() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - private: - char m_buffer[64]; - }; - - - class format_uint { - public: - format_uint(t_uint64 p_val,unsigned p_width = 0,unsigned p_base = 10); - format_uint(const format_uint & p_source) {*this = p_source;} - inline const char * get_ptr() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - private: - char m_buffer[64]; - }; - - class format_hex - { - public: - format_hex(t_uint64 p_val,unsigned p_width = 0); - format_hex(const format_hex & p_source) {*this = p_source;} - inline const char * get_ptr() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - private: - char m_buffer[17]; - }; - - class format_hex_lowercase - { - public: - format_hex_lowercase(t_uint64 p_val,unsigned p_width = 0); - format_hex_lowercase(const format_hex_lowercase & p_source) {*this = p_source;} - inline const char * get_ptr() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - private: - char m_buffer[17]; - }; - - - typedef string8_fastalloc string_formatter; - - class format_hexdump_ex { - public: - template format_hexdump_ex(const TWord * buffer, t_size bufLen, const char * spacing = " ") { - for(t_size n = 0; n < bufLen; n++) { - if (n > 0 && spacing != NULL) m_formatter << spacing; - m_formatter << format_hex(buffer[n],sizeof(TWord) * 2); - } - } - inline const char * get_ptr() const {return m_formatter;} - inline operator const char * () const {return m_formatter;} - inline const char * toString() const {return m_formatter;} - private: - string_formatter m_formatter; - }; - - class format_hexdump - { - public: - format_hexdump(const void * p_buffer,t_size p_bytes,const char * p_spacing = " "); - - inline const char * get_ptr() const {return m_formatter;} - inline operator const char * () const {return m_formatter;} - inline const char * toString() const {return m_formatter;} - private: - string_formatter m_formatter; - }; - - class format_hexdump_lowercase - { - public: - format_hexdump_lowercase(const void * p_buffer,t_size p_bytes,const char * p_spacing = " "); - - inline const char * get_ptr() const {return m_formatter;} - inline operator const char * () const {return m_formatter;} - inline const char * toString() const {return m_formatter;} - - private: - string_formatter m_formatter; - }; - - class format_fixedpoint - { - public: - format_fixedpoint(t_int64 p_val,unsigned p_point); - inline const char * get_ptr() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - private: - string_formatter m_buffer; - }; - - class format_char { - public: - format_char(char p_char) {m_buffer[0] = p_char; m_buffer[1] = 0;} - inline const char * get_ptr() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - private: - char m_buffer[2]; - }; - - template - class format_pad_left { - public: - format_pad_left(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = infinite) { - t_size source_len = 0, source_walk = 0; - - while(source_walk < p_string_length && source_len < p_chars) { - unsigned dummy; - t_size delta = pfc::utf8_decode_char(p_string + source_walk, dummy, p_string_length - source_walk); - if (delta == 0) break; - source_len++; - source_walk += delta; - } - - m_buffer.add_string(p_string,source_walk); - m_buffer.add_chars(p_padding,p_chars - source_len); - } - inline const char * get_ptr() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - private: - t_stringbuffer m_buffer; - }; - - template - class format_pad_right { - public: - format_pad_right(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = infinite) { - t_size source_len = 0, source_walk = 0; - - while(source_walk < p_string_length && source_len < p_chars) { - unsigned dummy; - t_size delta = pfc::utf8_decode_char(p_string + source_walk, dummy, p_string_length - source_walk); - if (delta == 0) break; - source_len++; - source_walk += delta; - } - - m_buffer.add_chars(p_padding,p_chars - source_len); - m_buffer.add_string(p_string,source_walk); - } - inline const char * get_ptr() const {return m_buffer;} - inline operator const char*() const {return m_buffer;} - inline const char * toString() const {return m_buffer;} - private: - t_stringbuffer m_buffer; - }; - - class format_array : public string_formatter { - public: - template format_array(t_source const & source, const char * separator = ", ") { - const t_size count = array_size_t(source); - if (count > 0) { - *this << source[0]; - for(t_size walk = 1; walk < count; ++walk) *this << separator << source[walk]; - } - } - }; - - - class format_file_size_short : public string_formatter { - public: - format_file_size_short(t_uint64 size); - t_uint64 get_used_scale() const {return m_scale;} - private: - t_uint64 m_scale; - }; - -} - -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,const char * p_source) {p_fmt.add_string(p_source); return p_fmt;} -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_int32 p_val) {return p_fmt << pfc::format_int(p_val);} -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_uint32 p_val) {return p_fmt << pfc::format_uint(p_val);} -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_int64 p_val) {return p_fmt << pfc::format_int(p_val);} -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,t_uint64 p_val) {return p_fmt << pfc::format_uint(p_val);} -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,double p_val) {return p_fmt << pfc::format_float(p_val);} - -inline pfc::string_base & operator<<(pfc::string_base & p_fmt,std::exception const & p_exception) {return p_fmt << p_exception.what();} - - - - - - -namespace pfc { - template - class string_simple_t { - private: - typedef string_simple_t t_self; - public: - t_size length(t_size p_limit = infinite) const {return pfc::strlen_t(get_ptr(),p_limit);} - bool is_empty() const {return length(1) == 0;} - void set_string(const t_char * p_source,t_size p_length = infinite) { - t_size length = pfc::strlen_t(p_source,p_length); - m_buffer.set_size(length + 1); - pfc::memcpy_t(m_buffer.get_ptr(),p_source,length); - m_buffer[length] = 0; - } - string_simple_t() {} - string_simple_t(const t_char * p_source,t_size p_length = infinite) {set_string(p_source,p_length);} - const t_self & operator=(const t_char * p_source) {set_string(p_source);return *this;} - operator const t_char* () const {return get_ptr();} - const t_char * get_ptr() const {return m_buffer.get_size() > 0 ? m_buffer.get_ptr() : pfc::empty_string_t();} - private: - pfc::array_t m_buffer; - }; - - typedef string_simple_t string_simple; - - template class traits_t > : public traits_t > {}; -} - - -namespace pfc { - class comparator_strcmp { - public: - inline static int compare(const char * p_item1,const char * p_item2) {return strcmp(p_item1,p_item2);} - inline static int compare(const wchar_t * item1, const wchar_t * item2) {return wcscmp(item1, item2);} - }; - - class comparator_stricmp_ascii { - public: - inline static int compare(const char * p_item1,const char * p_item2) {return pfc::stricmp_ascii(p_item1,p_item2);} - }; - - - - - template - void splitStringEx(t_output & p_output, const t_splitCheck & p_check, const char * p_string, t_size p_stringLen = infinite) { - t_size walk = 0, splitBase = 0; - const t_size max = strlen_max(p_string,p_stringLen); - for(;walk < max;) { - t_size delta = p_check(p_string + walk,p_stringLen - walk); - if (delta > 0) { - if (walk > splitBase) p_output(p_string + splitBase, walk - splitBase); - splitBase = walk + delta; - } else { - delta = utf8_char_len(p_string + walk, p_stringLen - walk); - if (delta == 0) break; - } - walk += delta; - } - if (walk > splitBase) p_output(p_string + splitBase, walk - splitBase); - } - - class __splitStringSimple_calculateSubstringCount { - public: - __splitStringSimple_calculateSubstringCount() : m_count() {} - void operator() (const char *, t_size) {++m_count;} - t_size get() const {return m_count;} - private: - t_size m_count; - }; - class __splitStringSimple_check { - public: - __splitStringSimple_check(const char * p_chars) { - m_chars.set_size(strlen_utf8(p_chars)); - for(t_size walk = 0, ptr = 0; walk < m_chars.get_size(); ++walk) { - ptr += utf8_decode_char(p_chars + ptr,m_chars[walk]); - } - } - t_size operator()(const char * p_string, t_size p_stringLen) const { - t_uint32 c; - t_size delta = utf8_decode_char(p_string, c, p_stringLen); - if (delta > 0) { - for(t_size walk = 0; walk < m_chars.get_size(); ++walk) { - if (m_chars[walk] == c) return delta; - } - } - return 0; - } - private: - array_t m_chars; - }; - template - class __splitStringSimple_arrayWrapper { - public: - __splitStringSimple_arrayWrapper(t_array & p_array) : m_walk(), m_array(p_array) {} - void operator()(const char * p_string, t_size p_stringLen) { - m_array[m_walk++].set_string(p_string,p_stringLen); - } - private: - t_size m_walk; - t_array & m_array; - }; - template - class __splitStringSimple_listWrapper { - public: - __splitStringSimple_listWrapper(t_list & p_list) : m_list(p_list) {} - void operator()(const char * p_string, t_size p_stringLen) { - m_temp.set_string(p_string,p_stringLen); - m_list.add_item(m_temp); - } - private: - string8_fastalloc m_temp; - t_list & m_list; - }; - - template - void splitStringSimple_toArray(t_array & p_output, const char * p_splitChars, const char * p_string, t_size p_stringLen = infinite) { - __splitStringSimple_check check(p_splitChars); - - { - __splitStringSimple_calculateSubstringCount wrapper; - splitStringEx(wrapper,check,p_string,p_stringLen); - p_output.set_size(wrapper.get()); - } - - { - __splitStringSimple_arrayWrapper wrapper(p_output); - splitStringEx(wrapper,check,p_string,p_stringLen); - } - } - template - void splitStringSimple_toList(t_list & p_output, const char * p_splitChars, const char * p_string, t_size p_stringLen = infinite) { - __splitStringSimple_check check(p_splitChars); - - __splitStringSimple_listWrapper wrapper(p_output); - splitStringEx(wrapper,check,p_string,p_stringLen); - } - - template void splitStringByLines(t_out & out, const char * str) { - for(;;) { - const char * next = strchr(str, '\n'); - if (next == NULL) { - out.insert_last()->set_string(str); break; - } - const char * walk = next; - while(walk > str && walk[-1] == '\r') --walk; - out.insert_last()->set_string(str, walk - str); - str = next + 1; - } - } - - void stringToUpperAppend(string_base & p_out, const char * p_source, t_size p_sourceLen); - void stringToLowerAppend(string_base & p_out, const char * p_source, t_size p_sourceLen); - int stringCompareCaseInsensitive(const char * s1, const char * s2); - t_uint32 charLower(t_uint32 param); - t_uint32 charUpper(t_uint32 param); - - template inline const char * stringToPtr(T const& val) {return val.get_ptr();} - inline const char * stringToPtr(const char* val) {return val;} - - - - class string_base_ref : public string_base { - public: - string_base_ref(const char * ptr) : m_ptr(ptr), m_len(strlen(ptr)) {} - const char * get_ptr() const {return m_ptr;} - t_size get_length() const {return m_len;} - private: - void add_string(const char * p_string,t_size p_length = ~0) {throw pfc::exception_not_implemented();} - void set_string(const char * p_string,t_size p_length = ~0) {throw pfc::exception_not_implemented();} - void truncate(t_size len) {throw pfc::exception_not_implemented();} - char * lock_buffer(t_size p_requested_length) {throw pfc::exception_not_implemented();} - void unlock_buffer() {throw pfc::exception_not_implemented();} - private: - const char * const m_ptr; - t_size const m_len; - }; - - //! Writes a string to a fixed-size buffer. Truncates the string if necessary. Always writes a null terminator. - template - void stringToBuffer(TChar (&buffer)[len], const TSource & source) { - pfc::static_assert<(len>0)>(); - t_size walk; - for(walk = 0; walk < len - 1 && source[walk] != 0; ++walk) { - buffer[walk] = source[walk]; - } - buffer[walk] = 0; - } - - //! Same as stringToBuffer() but throws exception_overflow() if the string could not be fully written, including null terminator. - template - void stringToBufferGuarded(TChar (&buffer)[len], const TSource & source) { - t_size walk; - for(walk = 0; source[walk] != 0; ++walk) { - if (walk >= len) throw exception_overflow(); - buffer[walk] = source[walk]; - } - if (walk >= len) throw exception_overflow(); - buffer[walk] = 0; - } - - - template int _strcmp_partial_ex(const t_char * p_string,t_size p_string_length,const t_char * p_substring,t_size p_substring_length) throw() { - for(t_size walk=0;walk=p_string_length ? 0 : p_string[walk]); - t_char substringchar = p_substring[walk]; - int result = compare_t(stringchar,substringchar); - if (result != 0) return result; - } - return 0; - } - - template int strcmp_partial_ex_t(const t_char * p_string,t_size p_string_length,const t_char * p_substring,t_size p_substring_length) throw() { - p_string_length = strlen_max_t(p_string,p_string_length); p_substring_length = strlen_max_t(p_substring,p_substring_length); - return _strcmp_partial_ex(p_string,p_string_length,p_substring,p_substring_length); - } - - template - int strcmp_partial_t(const t_char * p_string,const t_char * p_substring) throw() {return strcmp_partial_ex_t(p_string,infinite,p_substring,infinite);} - - static int strcmp_partial_ex(const char * str, t_size strLen, const char * substr, t_size substrLen) throw() {return strcmp_partial_ex(str, strLen, substr, substrLen); } - static int strcmp_partial(const char * str, const char * substr) throw() {return strcmp_partial_t(str, substr); } - -} - -#endif //_PFC_STRING_H_ diff --git a/tools/vio2sf/src/foobar/pfc/string8_impl.h b/tools/vio2sf/src/foobar/pfc/string8_impl.h deleted file mode 100644 index 968798637..000000000 --- a/tools/vio2sf/src/foobar/pfc/string8_impl.h +++ /dev/null @@ -1,123 +0,0 @@ -namespace pfc { - -template class t_alloc> -void string8_t::add_string(const char * ptr,t_size len) -{ - if (m_data.is_owned(ptr)) { - add_string(string8(ptr,len)); - } else { - len = strlen_max(ptr,len); - makespace(used+len+1); - pfc::memcpy_t(m_data.get_ptr() + used,ptr,len); - used+=len; - m_data[used]=0; - } -} - -template class t_alloc> -void string8_t::set_string(const char * ptr,t_size len) { - if (m_data.is_owned(ptr)) { - set_string(string8(ptr,len)); - } else { - len = strlen_max(ptr,len); - makespace(len+1); - pfc::memcpy_t(m_data.get_ptr(),ptr,len); - used=len; - m_data[used]=0; - } -} - -template class t_alloc> -void string8_t::set_char(unsigned offset,char c) -{ - if (!c) truncate(offset); - else if (offset class t_alloc> -void string8_t::fix_filename_chars(char def,char leave)//replace "bad" characters, leave parameter can be used to keep eg. path separators -{ - t_size n; - for(n=0;n class t_alloc> -void string8_t::remove_chars(t_size first,t_size count) -{ - if (first>used) first = used; - if (first+count>used) count = used-first; - if (count>0) - { - t_size n; - for(n=first+count;n<=used;n++) - m_data[n-count]=m_data[n]; - used -= count; - makespace(used+1); - } -} - -template class t_alloc> -void string8_t::insert_chars(t_size first,const char * src, t_size count) -{ - if (first > used) first = used; - - makespace(used+count+1); - t_size n; - for(n=used;(int)n>=(int)first;n--) - m_data[n+count] = m_data[n]; - for(n=0;n class t_alloc> -void string8_t::insert_chars(t_size first,const char * src) {insert_chars(first,src,strlen(src));} - - -template class t_alloc> -t_size string8_t::replace_nontext_chars(char p_replace) -{ - t_size ret = 0; - for(t_size n=0;n class t_alloc> -t_size string8_t::replace_byte(char c1,char c2,t_size start) -{ - PFC_ASSERT(c1 != 0); PFC_ASSERT(c2 != 0); - t_size n, ret = 0; - for(n=start;n class t_alloc> -t_size string8_t::replace_char(unsigned c1,unsigned c2,t_size start) -{ - if (c1 < 128 && c2 < 128) return replace_byte((char)c1,(char)c2,start); - - string8 temp(get_ptr()+start); - truncate(start); - const char * ptr = temp; - t_size rv = 0; - while(*ptr) - { - unsigned test; - t_size delta = utf8_decode_char(ptr,test); - if (delta==0 || test==0) break; - if (test == c1) {test = c2;rv++;} - add_char(test); - ptr += delta; - } - return rv; -} - -} diff --git a/tools/vio2sf/src/foobar/pfc/stringNew.cpp b/tools/vio2sf/src/foobar/pfc/stringNew.cpp deleted file mode 100644 index f6652ee5f..000000000 --- a/tools/vio2sf/src/foobar/pfc/stringNew.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "pfc.h" - -namespace pfc { - -t_size string::indexOf(char c,t_size base) const { - return pfc::string_find_first(ptr(),c,base); -} -t_size string::lastIndexOf(char c,t_size base) const { - return pfc::string_find_last(ptr(),c,base); -} -t_size string::indexOf(stringp s,t_size base) const { - return pfc::string_find_first(ptr(),s.ptr(),base); -} -t_size string::lastIndexOf(stringp s,t_size base) const { - return pfc::string_find_last(ptr(),s.ptr(),base); -} -t_size string::indexOfAnyChar(stringp _s,t_size base) const { - string s ( _s ); - const t_size len = length(); - const char* content = ptr(); - for(t_size walk = 0; walk < len; ++walk) { - if (s.contains(content[walk])) return walk; - } - return ~0; -} -t_size string::lastIndexOfAnyChar(stringp _s,t_size base) const { - string s ( _s ); - const char* content = ptr(); - for(t_size _walk = length(); _walk > 0; --_walk) { - const t_size walk = _walk-1; - if (s.contains(content[walk])) return walk; - } - return ~0; -} -bool string::startsWith(char c) const { - return (*this)[0] == c; -} -bool string::startsWith(string s) const { - const char * walk = ptr(); - const char * subWalk = s.ptr(); - for(;;) { - if (*subWalk == 0) return true; - if (*walk != *subWalk) return false; - walk++; subWalk++; - } -} -bool string::endsWith(char c) const { - const t_size len = length(); - if (len == 0) return false; - return ptr()[len-1] == c; -} -bool string::endsWith(string s) const { - const t_size len = length(), subLen = s.length(); - if (subLen > len) return false; - return subString(len - subLen) == s; -} - -char string::firstChar() const { - return (*this)[0]; -} -char string::lastChar() const { - const t_size len = length(); - return len > 0 ? (*this)[len-1] : (char)0; -} - -string string::replace(stringp strOld, stringp strNew) const { - t_size walk = 0; - string ret; - for(;;) { - t_size next = indexOf(strOld, walk); - if (next == ~0) { - ret += subString(walk); break; - } - ret += subString(walk,next-walk) + strNew; - walk = next + strOld.length(); - } - return ret; -} -bool string::contains(char c) const {return indexOf(c) != ~0;} -bool string::contains(stringp s) const {return indexOf(s) != ~0;} -bool string::containsAnyChar(stringp s) const {return indexOfAnyChar(s) != ~0;} -} diff --git a/tools/vio2sf/src/foobar/pfc/stringNew.h b/tools/vio2sf/src/foobar/pfc/stringNew.h deleted file mode 100644 index 218f59910..000000000 --- a/tools/vio2sf/src/foobar/pfc/stringNew.h +++ /dev/null @@ -1,220 +0,0 @@ -namespace pfc { - //helper, const methods only - class __stringEmpty : public string_base { - public: - const char * get_ptr() const {return "";} - void add_string(const char * p_string,t_size p_length = ~0) {throw exception_not_implemented();} - void set_string(const char * p_string,t_size p_length = ~0) {throw exception_not_implemented();} - void truncate(t_size len) {throw exception_not_implemented();} - t_size get_length() const {return 0;} - char * lock_buffer(t_size p_requested_length) {throw exception_not_implemented();} - void unlock_buffer() {throw exception_not_implemented();} - }; - - class stringp; - - //! New EXPERIMENTAL string class, allowing efficient copies and returning from functions. \n - //! Does not implement the string_base interface so you still need string8 in many cases. \n - //! Safe to pass between DLLs, but since a reference is used, objects possibly created by other DLLs must be released before owning DLLs are unloaded. - class string { - public: - typedef rcptr_t t_data; - typedef rcptr_t t_dataImpl; - - string() : m_content(rcnew_t<__stringEmpty>()) {} - string(const char * p_source) : m_content(rcnew_t(p_source)) {} - string(const char * p_source, t_size p_sourceLen) : m_content(rcnew_t(p_source,p_sourceLen)) {} - string(t_data const & p_source) : m_content(p_source) {} - template string(const TSource & p_source); - - string const & toString() const {return *this;} - - //warning, not length-checked anymore! - static string g_concatenateRaw(const char * item1, t_size len1, const char * item2, t_size len2) { - t_dataImpl impl; impl.new_t(); - char * buffer = impl->lock_buffer(len1+len2); - memcpy_t(buffer,item1,len1); - memcpy_t(buffer+len1,item2,len2); - impl->unlock_buffer(); - return string(t_data(impl)); - } - - string operator+(const string& p_item2) const { - return g_concatenateRaw(ptr(),length(),p_item2.ptr(),p_item2.length()); - } - string operator+(const char * p_item2) const { - return g_concatenateRaw(ptr(),length(),p_item2,strlen(p_item2)); - } - - template string operator+(const TSource & p_item2) const; - - template - const string & operator+=(const TSource & p_item) { - *this = *this + p_item; - return *this; - } - - string subString(t_size base) const { - if (base > length()) throw exception_overflow(); - return string(ptr() + base); - } - string subString(t_size base, t_size count) const { - return string(ptr() + base,count); - } - - string toLower() const { - pfc::string8_fastalloc temp; temp.prealloc(128); - stringToLowerAppend(temp,ptr(),~0); - return string(temp.get_ptr()); - } - string toUpper() const { - pfc::string8_fastalloc temp; temp.prealloc(128); - stringToUpperAppend(temp,ptr(),~0); - return string(temp.get_ptr()); - } - - string clone() const {return string(ptr());} - - //! @returns ~0 if not found. - t_size indexOf(char c,t_size base = 0) const; - //! @returns ~0 if not found. - t_size lastIndexOf(char c,t_size base = ~0) const; - //! @returns ~0 if not found. - t_size indexOf(stringp s,t_size base = 0) const; - //! @returns ~0 if not found. - t_size lastIndexOf(stringp s,t_size base = ~0) const; - //! @returns ~0 if not found. - t_size indexOfAnyChar(stringp s,t_size base = 0) const; - //! @returns ~0 if not found. - t_size lastIndexOfAnyChar(stringp s,t_size base = ~0) const; - - bool contains(char c) const; - bool contains(stringp s) const; - - bool containsAnyChar(stringp s) const; - - bool startsWith(char c) const; - bool startsWith(string s) const; - bool endsWith(char c) const; - bool endsWith(string s) const; - - char firstChar() const; - char lastChar() const; - - string replace(stringp strOld, stringp strNew) const; - - static int g_compare(const string & p_item1, const string & p_item2) {return strcmp(p_item1.ptr(),p_item2.ptr());} - bool operator==(const string& p_other) const {return g_compare(*this,p_other) == 0;} - bool operator!=(const string& p_other) const {return g_compare(*this,p_other) != 0;} - bool operator<(const string& p_other) const {return g_compare(*this,p_other) < 0;} - bool operator>(const string& p_other) const {return g_compare(*this,p_other) > 0;} - bool operator<=(const string& p_other) const {return g_compare(*this,p_other) <= 0;} - bool operator>=(const string& p_other) const {return g_compare(*this,p_other) >= 0;} - - const char * ptr() const {return m_content->get_ptr();} - const char * get_ptr() const {return m_content->get_ptr();} - t_size length() const {return m_content->get_length();} - t_size get_length() const {return m_content->get_length();} - - void set_string(const char * ptr, t_size len = ~0) { - *this = string(ptr, len); - } - - static bool isNonTextChar(char c) {return c >= 0 && c < 32;} - - char operator[](t_size p_index) const { - PFC_ASSERT(p_index < length()); - return ptr()[p_index]; - } - bool isEmpty() const {return length() == 0;} - - class comparatorCaseSensitive { - public: - template - static int compare(T1 const& v1, T2 const& v2) { - return strcmp(stringToPtr(v1),stringToPtr(v2)); - } - static int compare_ex(const char * v1, t_size l1, const char * v2, t_size l2) { - return strcmp_ex(v1, l1, v2, l2); - } - - }; - class comparatorCaseInsensitive { - public: - template - static int compare(T1 const& v1, T2 const& v2) { - return stringCompareCaseInsensitive(stringToPtr(v1),stringToPtr(v2)); - } - }; - class comparatorCaseInsensitiveASCII { - public: - template - static int compare(T1 const& v1, T2 const& v2) { - return stricmp_ascii(stringToPtr(v1),stringToPtr(v2)); - } - - static int compare_ex(const char * v1, t_size l1, const char * v2, t_size l2) { - return stricmp_ascii_ex(v1, l1, v2, l2); - } - }; - - static bool g_equals(const string & p_item1, const string & p_item2) {return p_item1 == p_item2;} - static bool g_equalsCaseInsensitive(const string & p_item1, const string & p_item2) {return comparatorCaseInsensitive::compare(p_item1,p_item2) == 0;} - - t_data _content() const {return m_content;} - private: - t_data m_content; - }; - - template inline string toString(T const& val) {return val.toString();} - template<> inline string toString(t_int64 const& val) {return format_int(val).get_ptr();} - template<> inline string toString(t_int32 const& val) {return format_int(val).get_ptr();} - template<> inline string toString(t_int16 const& val) {return format_int(val).get_ptr();} - template<> inline string toString(t_uint64 const& val) {return format_uint(val).get_ptr();} - template<> inline string toString(t_uint32 const& val) {return format_uint(val).get_ptr();} - template<> inline string toString(t_uint16 const& val) {return format_uint(val).get_ptr();} - template<> inline string toString(float const& val) {return format_float(val).get_ptr();} - template<> inline string toString(double const& val) {return format_float(val).get_ptr();} - template<> inline string toString(char const& val) {return string(&val,1);} - inline const char * toString(std::exception const& val) {return val.what();} - - template string::string(const TSource & p_source) { - *this = pfc::toString(p_source); - } - template string string::operator+(const TSource & p_item2) const { - return *this + pfc::toString(p_item2); - } - - //! "String parameter" helper class, to use in function parameters, allowing functions to take any type of string as a parameter (const char*, string_base, string). - class stringp { - public: - stringp(const char * ptr) : m_ptr(ptr) {} - stringp(pfc::string const &s) : m_ptr(s.ptr()), m_s(s._content()) {} - stringp(pfc::string_base const &s) : m_ptr(s.get_ptr()) {} - template stringp(const TWhat& in) : m_ptr(in.toString()) {} - - operator const char*() const {return m_ptr;} - const char * ptr() const {return m_ptr;} - const char * get_ptr() const {return m_ptr;} - pfc::string str() const {return m_s.is_valid() ? pfc::string(m_s) : pfc::string(m_ptr);} - operator pfc::string() const {return str();} - pfc::string toString() const {return str();} - t_size length() const {return m_s.is_valid() ? m_s->length() : strlen(m_ptr);} - private: - const char * const m_ptr; - pfc::string::t_data m_s; - }; - - template - string stringCombineList(const TList & list, stringp separator) { - typename TList::const_iterator iter = list.first(); - string acc; - if (iter.is_valid()) { - acc = *iter; - for(++iter; iter.is_valid(); ++iter) { - acc = acc + separator + *iter; - } - } - return acc; - } -} diff --git a/tools/vio2sf/src/foobar/pfc/string_conv.cpp b/tools/vio2sf/src/foobar/pfc/string_conv.cpp deleted file mode 100644 index 77b2deed5..000000000 --- a/tools/vio2sf/src/foobar/pfc/string_conv.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include "pfc.h" - - -#ifdef _WINDOWS - -namespace { - template - class string_writer_t { - public: - string_writer_t(t_char * p_buffer,t_size p_size) : m_buffer(p_buffer), m_size(p_size), m_writeptr(0) {} - - void write(t_char p_char) { - if (isChecked) { - if (m_writeptr < m_size) { - m_buffer[m_writeptr++] = p_char; - } - } else { - m_buffer[m_writeptr++] = p_char; - } - } - void write_multi(const t_char * p_buffer,t_size p_count) { - if (isChecked) { - const t_size delta = pfc::min_t(p_count,m_size-m_writeptr); - for(t_size n=0;n(m_writeptr,m_size-1); - m_buffer[terminator] = 0; - return terminator; - } else { - m_buffer[m_writeptr] = 0; - return m_writeptr; - } - } - bool is_overrun() const { - return m_writeptr >= m_size; - } - private: - t_char * m_buffer; - t_size m_size; - t_size m_writeptr; - }; - - - -}; - -namespace pfc { - namespace stringcvt { - - - t_size convert_utf8_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_in,t_size p_in_size) { - const t_size insize = p_in_size; - t_size inptr = 0; - string_writer_t writer(p_out,p_out_size); - - while(inptr < insize && !writer.is_overrun()) { - unsigned newchar = 0; - t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr); - if (delta == 0 || newchar == 0) break; - PFC_ASSERT(inptr + delta <= insize); - inptr += delta; - writer.write_as_wide(newchar); - } - - return writer.finalize(); - } - - t_size convert_utf8_to_wide_unchecked(wchar_t * p_out,const char * p_in) { - t_size inptr = 0; - string_writer_t writer(p_out,~0); - - while(!writer.is_overrun()) { - unsigned newchar = 0; - t_size delta = utf8_decode_char(p_in + inptr,newchar); - if (delta == 0 || newchar == 0) break; - inptr += delta; - writer.write_as_wide(newchar); - } - - return writer.finalize(); - } - - t_size convert_wide_to_utf8(char * p_out,t_size p_out_size,const wchar_t * p_in,t_size p_in_size) { - const t_size insize = p_in_size; - t_size inptr = 0; - string_writer_t writer(p_out,p_out_size); - - while(inptr < insize && !writer.is_overrun()) { - unsigned newchar = 0; - t_size delta = utf16_decode_char(p_in + inptr,&newchar,insize - inptr); - if (delta == 0 || newchar == 0) break; - PFC_ASSERT(inptr + delta <= insize); - inptr += delta; - writer.write_as_utf8(newchar); - } - - return writer.finalize(); - } - - t_size estimate_utf8_to_wide(const char * p_in) { - t_size inptr = 0; - t_size retval = 1;//1 for null terminator - for(;;) { - unsigned newchar = 0; - t_size delta = utf8_decode_char(p_in + inptr,newchar); - if (delta == 0 || newchar == 0) break; - inptr += delta; - - { - wchar_t temp[2]; - retval += utf16_encode_char(newchar,temp); - } - } - return retval; - } - - t_size estimate_utf8_to_wide(const char * p_in,t_size p_in_size) { - const t_size insize = p_in_size; - t_size inptr = 0; - t_size retval = 1;//1 for null terminator - while(inptr < insize) { - unsigned newchar = 0; - t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr); - if (delta == 0 || newchar == 0) break; - PFC_ASSERT(inptr + delta <= insize); - inptr += delta; - - { - wchar_t temp[2]; - retval += utf16_encode_char(newchar,temp); - } - } - return retval; - } - - t_size estimate_wide_to_utf8(const wchar_t * p_in,t_size p_in_size) { - const t_size insize = p_in_size; - t_size inptr = 0; - t_size retval = 1;//1 for null terminator - while(inptr < insize) { - unsigned newchar = 0; - t_size delta = utf16_decode_char(p_in + inptr,&newchar,insize - inptr); - if (delta == 0 || newchar == 0) break; - PFC_ASSERT(inptr + delta <= insize); - inptr += delta; - - { - char temp[6]; - delta = utf8_encode_char(newchar,temp); - if (delta == 0) break; - retval += delta; - } - } - return retval; - } - - - t_size convert_codepage_to_wide(unsigned p_codepage,wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size) { - if (p_out_size == 0) return 0; - memset(p_out,0,p_out_size * sizeof(*p_out)); - MultiByteToWideChar(p_codepage,0,p_source,p_source_size,p_out,p_out_size); - p_out[p_out_size-1] = 0; - return wcslen(p_out); - } - - t_size convert_wide_to_codepage(unsigned p_codepage,char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size) { - if (p_out_size == 0) return 0; - memset(p_out,0,p_out_size * sizeof(*p_out)); - WideCharToMultiByte(p_codepage,0,p_source,p_source_size,p_out,p_out_size,0,FALSE); - p_out[p_out_size-1] = 0; - return strlen(p_out); - } - - t_size estimate_codepage_to_wide(unsigned p_codepage,const char * p_source,t_size p_source_size) { - return MultiByteToWideChar(p_codepage,0,p_source,strlen_max(p_source,p_source_size),0,0) + 1; - } - t_size estimate_wide_to_codepage(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size) { - return WideCharToMultiByte(p_codepage,0,p_source,wcslen_max(p_source,p_source_size),0,0,0,FALSE) + 1; - } - } - -} - -#endif //_WINDOWS - diff --git a/tools/vio2sf/src/foobar/pfc/string_conv.h b/tools/vio2sf/src/foobar/pfc/string_conv.h deleted file mode 100644 index 21a31e173..000000000 --- a/tools/vio2sf/src/foobar/pfc/string_conv.h +++ /dev/null @@ -1,410 +0,0 @@ -namespace pfc { - - namespace stringcvt { - -#ifdef _WINDOWS - enum { - codepage_system = CP_ACP, - codepage_ascii = 20127, - codepage_iso_8859_1 = 28591, - }; - - //! Converts UTF-8 characters to wide character. - //! @param p_out Output buffer, receives converted string, with null terminator. - //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. - //! @param p_source String to convert. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters written, not counting null terminator. - t_size convert_utf8_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size); - - - //! Estimates buffer size required to convert specified UTF-8 string to widechar. - //! @param p_source String to be converted. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters to allocate, including space for null terminator. - t_size estimate_utf8_to_wide(const char * p_source,t_size p_source_size); - - t_size estimate_utf8_to_wide(const char * p_source); - - //! Converts wide character string to UTF-8. - //! @param p_out Output buffer, receives converted string, with null terminator. - //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. - //! @param p_source String to convert. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters written, not counting null terminator. - t_size convert_wide_to_utf8(char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size); - - //! Estimates buffer size required to convert specified wide character string to UTF-8. - //! @param p_source String to be converted. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters to allocate, including space for null terminator. - t_size estimate_wide_to_utf8(const wchar_t * p_source,t_size p_source_size); - - - - //! Converts string from specified codepage to wide character. - //! @param p_out Output buffer, receives converted string, with null terminator. - //! @param p_codepage Codepage ID of source string. - //! @param p_source String to convert. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. - //! @returns Number of characters written, not counting null terminator. - t_size convert_codepage_to_wide(unsigned p_codepage,wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size); - - //! Estimates buffer size required to convert specified string from specified codepage to wide character. - //! @param p_codepage Codepage ID of source string. - //! @param p_source String to be converted. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters to allocate, including space for null terminator. - t_size estimate_codepage_to_wide(unsigned p_codepage,const char * p_source,t_size p_source_size); - - //! Converts string from wide character to specified codepage. - //! @param p_codepage Codepage ID of source string. - //! @param p_out Output buffer, receives converted string, with null terminator. - //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. - //! @param p_source String to convert. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters written, not counting null terminator. - t_size convert_wide_to_codepage(unsigned p_codepage,char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size); - - //! Estimates buffer size required to convert specified wide character string to specified codepage. - //! @param p_codepage Codepage ID of source string. - //! @param p_source String to be converted. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters to allocate, including space for null terminator. - t_size estimate_wide_to_codepage(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size); - - - //! Converts string from system codepage to wide character. - //! @param p_out Output buffer, receives converted string, with null terminator. - //! @param p_source String to convert. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. - //! @returns Number of characters written, not counting null terminator. - inline t_size convert_ansi_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size) { - return convert_codepage_to_wide(codepage_system,p_out,p_out_size,p_source,p_source_size); - } - - //! Estimates buffer size required to convert specified system codepage string to wide character. - //! @param p_source String to be converted. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters to allocate, including space for null terminator. - inline t_size estimate_ansi_to_wide(const char * p_source,t_size p_source_size) { - return estimate_codepage_to_wide(codepage_system,p_source,p_source_size); - } - - //! Converts string from wide character to system codepage. - //! @param p_out Output buffer, receives converted string, with null terminator. - //! @param p_out_size Size of output buffer, in characters. If converted string is too long, it will be truncated. Null terminator is always written, unless p_out_size is zero. - //! @param p_source String to convert. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters written, not counting null terminator. - inline t_size convert_wide_to_ansi(char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size) { - return convert_wide_to_codepage(codepage_system,p_out,p_out_size,p_source,p_source_size); - } - - //! Estimates buffer size required to convert specified wide character string to system codepage. - //! @param p_source String to be converted. - //! @param p_source_size Number of characters to read from p_source. If reading stops if null terminator is encountered earlier. - //! @returns Number of characters to allocate, including space for null terminator. - inline t_size estimate_wide_to_ansi(const wchar_t * p_source,t_size p_source_size) { - return estimate_wide_to_codepage(codepage_system,p_source,p_source_size); - } - - - //! estimate_utf8_to_wide_quick() functions use simple math to determine buffer size required for the conversion. The result is not accurate length of output string - it's just a safe estimate of required buffer size, possibly bigger than what's really needed. \n - //! These functions are meant for scenarios when speed is more important than memory usage. - inline t_size estimate_utf8_to_wide_quick(t_size sourceLen) { - return sourceLen + 1; - } - inline t_size estimate_utf8_to_wide_quick(const char * source) { - return estimate_utf8_to_wide_quick(strlen(source)); - } - inline t_size estimate_utf8_to_wide_quick(const char * source, t_size sourceLen) { - return estimate_utf8_to_wide_quick(strlen_max(source, sourceLen)); - } - t_size convert_utf8_to_wide_unchecked(wchar_t * p_out,const char * p_source); - - template const t_char * null_string_t(); - template<> inline const char * null_string_t() {return "";} - template<> inline const wchar_t * null_string_t() {return L"";} - - template t_size strlen_t(const t_char * p_string,t_size p_string_size = ~0) { - for(t_size n=0;n bool string_is_empty_t(const t_char * p_string,t_size p_string_size = ~0) { - if (p_string_size == 0) return true; - return p_string[0] == 0; - } - - template class t_alloc = pfc::alloc_standard> class char_buffer_t { - public: - char_buffer_t() {} - char_buffer_t(const char_buffer_t & p_source) : m_buffer(p_source.m_buffer) {} - void set_size(t_size p_count) {m_buffer.set_size(p_count);} - t_char * get_ptr_var() {return m_buffer.get_ptr();} - const t_char * get_ptr() const { - return m_buffer.get_size() > 0 ? m_buffer.get_ptr() : null_string_t(); - } - private: - pfc::array_t m_buffer; - }; - - template class t_alloc = pfc::alloc_standard> - class string_utf8_from_wide_t { - public: - string_utf8_from_wide_t() {} - string_utf8_from_wide_t(const wchar_t * p_source,t_size p_source_size = ~0) {convert(p_source,p_source_size);} - - void convert(const wchar_t * p_source,t_size p_source_size = ~0) { - t_size size = estimate_wide_to_utf8(p_source,p_source_size); - m_buffer.set_size(size); - convert_wide_to_utf8( m_buffer.get_ptr_var(),size,p_source,p_source_size); - } - - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - const char * toString() const {return get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - private: - char_buffer_t m_buffer; - }; - typedef string_utf8_from_wide_t<> string_utf8_from_wide; - - template class t_alloc = pfc::alloc_standard> - class string_wide_from_utf8_t { - public: - string_wide_from_utf8_t() {} - string_wide_from_utf8_t(const char* p_source) {convert(p_source);} - string_wide_from_utf8_t(const char* p_source,t_size p_source_size) {convert(p_source,p_source_size);} - - void convert(const char* p_source,t_size p_source_size) { - const t_size size = estimate_size(p_source, p_source_size); - m_buffer.set_size(size); - convert_utf8_to_wide( m_buffer.get_ptr_var(),size,p_source,p_source_size ); - } - void convert(const char * p_source) { - m_buffer.set_size( estimate_size(p_source) ); - convert_utf8_to_wide_unchecked(m_buffer.get_ptr_var(), p_source); - } - - operator const wchar_t * () const {return get_ptr();} - const wchar_t * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - enum { alloc_prioritizes_speed = t_alloc::alloc_prioritizes_speed }; - private: - - inline t_size estimate_size(const char * source, t_size sourceLen) { - return alloc_prioritizes_speed ? estimate_utf8_to_wide_quick(source, sourceLen) : estimate_utf8_to_wide(source,sourceLen); - } - inline t_size estimate_size(const char * source) { - return alloc_prioritizes_speed ? estimate_utf8_to_wide_quick(source) : estimate_utf8_to_wide(source,~0); - } - char_buffer_t m_buffer; - }; - typedef string_wide_from_utf8_t<> string_wide_from_utf8; - typedef string_wide_from_utf8_t string_wide_from_utf8_fast; - - template class t_alloc = pfc::alloc_standard> - class string_wide_from_codepage_t { - public: - string_wide_from_codepage_t() {} - string_wide_from_codepage_t(const string_wide_from_codepage_t & p_source) : m_buffer(p_source.m_buffer) {} - string_wide_from_codepage_t(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);} - - void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) { - t_size size = estimate_codepage_to_wide(p_codepage,p_source,p_source_size); - m_buffer.set_size(size); - convert_codepage_to_wide(p_codepage, m_buffer.get_ptr_var(),size,p_source,p_source_size); - } - - operator const wchar_t * () const {return get_ptr();} - const wchar_t * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - private: - char_buffer_t m_buffer; - }; - typedef string_wide_from_codepage_t<> string_wide_from_codepage; - - - template class t_alloc = pfc::alloc_standard> - class string_codepage_from_wide_t { - public: - string_codepage_from_wide_t() {} - string_codepage_from_wide_t(const string_codepage_from_wide_t & p_source) : m_buffer(p_source.m_buffer) {} - string_codepage_from_wide_t(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);} - - void convert(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size = ~0) { - t_size size = estimate_wide_to_codepage(p_codepage,p_source,p_source_size); - m_buffer.set_size(size); - convert_wide_to_codepage(p_codepage, m_buffer.get_ptr_var(),size,p_source,p_source_size); - } - - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - private: - char_buffer_t m_buffer; - }; - typedef string_codepage_from_wide_t<> string_codepage_from_wide; - - class string_codepage_from_utf8 { - public: - string_codepage_from_utf8() {} - string_codepage_from_utf8(const string_codepage_from_utf8 & p_source) : m_buffer(p_source.m_buffer) {} - string_codepage_from_utf8(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);} - - void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) { - string_wide_from_utf8 temp; - temp.convert(p_source,p_source_size); - t_size size = estimate_wide_to_codepage(p_codepage,temp,~0); - m_buffer.set_size(size); - convert_wide_to_codepage(p_codepage,m_buffer.get_ptr_var(),size,temp,~0); - } - - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - private: - char_buffer_t m_buffer; - }; - - class string_utf8_from_codepage { - public: - string_utf8_from_codepage() {} - string_utf8_from_codepage(const string_utf8_from_codepage & p_source) : m_buffer(p_source.m_buffer) {} - string_utf8_from_codepage(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);} - - void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) { - string_wide_from_codepage temp; - temp.convert(p_codepage,p_source,p_source_size); - t_size size = estimate_wide_to_utf8(temp,~0); - m_buffer.set_size(size); - convert_wide_to_utf8( m_buffer.get_ptr_var(),size,temp,~0); - } - - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - private: - char_buffer_t m_buffer; - }; - - - class string_utf8_from_ansi { - public: - string_utf8_from_ansi() {} - string_utf8_from_ansi(const string_utf8_from_ansi & p_source) : m_buffer(p_source.m_buffer) {} - string_utf8_from_ansi(const char * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {} - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - const char * toString() const {return get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - void convert(const char * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);} - - private: - string_utf8_from_codepage m_buffer; - }; - - class string_ansi_from_utf8 { - public: - string_ansi_from_utf8() {} - string_ansi_from_utf8(const string_ansi_from_utf8 & p_source) : m_buffer(p_source.m_buffer) {} - string_ansi_from_utf8(const char * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {} - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - void convert(const char * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);} - - private: - string_codepage_from_utf8 m_buffer; - }; - - class string_wide_from_ansi { - public: - string_wide_from_ansi() {} - string_wide_from_ansi(const string_wide_from_ansi & p_source) : m_buffer(p_source.m_buffer) {} - string_wide_from_ansi(const char * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {} - operator const wchar_t * () const {return get_ptr();} - const wchar_t * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - void convert(const char * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);} - - private: - string_wide_from_codepage m_buffer; - }; - - class string_ansi_from_wide { - public: - string_ansi_from_wide() {} - string_ansi_from_wide(const string_ansi_from_wide & p_source) : m_buffer(p_source.m_buffer) {} - string_ansi_from_wide(const wchar_t * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {} - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return string_is_empty_t(get_ptr());} - t_size length() const {return strlen_t(get_ptr());} - - void convert(const wchar_t * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);} - - private: - string_codepage_from_wide m_buffer; - }; - -#ifdef UNICODE - typedef string_wide_from_utf8 string_os_from_utf8; - typedef string_utf8_from_wide string_utf8_from_os; - typedef string_wide_from_utf8_fast string_os_from_utf8_fast; -#else - typedef string_ansi_from_utf8 string_os_from_utf8; - typedef string_utf8_from_ansi string_utf8_from_os; - typedef string_ansi_from_utf8 string_os_from_utf8_fast; -#endif - - class string_utf8_from_os_ex { - public: - template string_utf8_from_os_ex(const t_source * source, t_size sourceLen = ~0) { - convert(source,sourceLen); - } - - void convert(const char * source, t_size sourceLen = ~0) { - m_buffer = string_utf8_from_ansi(source,sourceLen); - } - void convert(const wchar_t * source, t_size sourceLen = ~0) { - m_buffer = string_utf8_from_wide(source,sourceLen); - } - - operator const char * () const {return get_ptr();} - const char * get_ptr() const {return m_buffer.get_ptr();} - bool is_empty() const {return m_buffer.is_empty();} - t_size length() const {return m_buffer.length();} - const char * toString() const {return get_ptr();} - private: - string8 m_buffer; - }; - } - -#else -//PORTME -#endif -}; diff --git a/tools/vio2sf/src/foobar/pfc/string_list.h b/tools/vio2sf/src/foobar/pfc/string_list.h deleted file mode 100644 index bf07cdd96..000000000 --- a/tools/vio2sf/src/foobar/pfc/string_list.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _PFC_STRING_LIST_H_ -#define _PFC_STRING_LIST_H_ - -namespace pfc { - - typedef list_base_const_t string_list_const; - - class string_list_impl : public string_list_const - { - public: - t_size get_count() const {return m_data.get_size();} - void get_item_ex(const char* & p_out, t_size n) const {p_out = m_data[n];} - - inline const char * operator[] (t_size n) const {return m_data[n];} - - void add_item(const char * p_string) { - t_size idx = m_data.get_size(); - m_data.set_size(idx + 1); - m_data[idx] = p_string; - } - - void add_items(const string_list_const & p_source) {_append(p_source);} - - void remove_all() - { - m_data.set_size(0); - } - - //unnecessary since pfc::array_t is in use for implementation - //~string_list_impl() {remove_all();} - - inline string_list_impl() {} - inline string_list_impl(const string_list_impl & p_source) {_copy(p_source);} - inline string_list_impl(const string_list_const & p_source) {_copy(p_source);} - inline const string_list_impl & operator=(const string_list_impl & p_source) {_copy(p_source);return *this;} - inline const string_list_impl & operator=(const string_list_const & p_source) {_copy(p_source);return *this;} - inline const string_list_impl & operator+=(const string_list_impl & p_source) {_append(p_source);return *this;} - inline const string_list_impl & operator+=(const string_list_const & p_source) {_append(p_source);return *this;} - - private: - - void _append(const string_list_const & p_source) { - const t_size toadd = p_source.get_count(), base = m_data.get_size(); - m_data.set_size(base+toadd); - for(t_size n=0;n m_data; - }; -} - -#endif //_PFC_STRING_LIST_H_ diff --git a/tools/vio2sf/src/foobar/pfc/threads.cpp b/tools/vio2sf/src/foobar/pfc/threads.cpp deleted file mode 100644 index 71f7f27e1..000000000 --- a/tools/vio2sf/src/foobar/pfc/threads.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "pfc.h" - -namespace pfc { - t_size getOptimalWorkerThreadCount() { -#ifdef _WINDOWS - DWORD_PTR mask,system; - t_size ret = 0; - GetProcessAffinityMask(GetCurrentProcess(),&mask,&system); - for(t_size n=0;n(this),overridePriority ? CREATE_SUSPENDED : 0,NULL); - if (thread == NULL) throw exception_creation(); - if (overridePriority) { - SetThreadPriority(thread, priority); - ResumeThread(thread); - } - m_thread = thread; - } - bool isActive() const { - return m_thread != INVALID_HANDLE_VALUE; - } - void waitTillDone() { - close(); - } - protected: - virtual void threadProc() {PFC_ASSERT(!"Stub thread entry - should not get here");} - private: - void close() { - if (isActive()) { - WaitForSingleObject(m_thread,INFINITE); - CloseHandle(m_thread); m_thread = INVALID_HANDLE_VALUE; - } - } - - static DWORD CALLBACK g_entry(void* p_instance) { - return reinterpret_cast(p_instance)->entry(); - } - unsigned entry() { - try { - threadProc(); - } catch(...) {} - return 0; - } - HANDLE m_thread; - - PFC_CLASS_NOT_COPYABLE_EX(thread) - }; -#else -#error PORTME -#endif -} diff --git a/tools/vio2sf/src/foobar/pfc/traits.h b/tools/vio2sf/src/foobar/pfc/traits.h deleted file mode 100644 index 0110eb514..000000000 --- a/tools/vio2sf/src/foobar/pfc/traits.h +++ /dev/null @@ -1,81 +0,0 @@ -namespace pfc { - - class traits_default { - public: - enum { - realloc_safe = false, - needs_destructor = true, - needs_constructor = true, - constructor_may_fail = true - }; - }; - - class traits_default_movable { - public: - enum { - realloc_safe = true, - needs_destructor = true, - needs_constructor = true, - constructor_may_fail = true - }; - }; - - class traits_rawobject : public traits_default { - public: - enum { - realloc_safe = true, - needs_destructor = false, - needs_constructor = false, - constructor_may_fail = false - }; - }; - - class traits_vtable { - public: - enum { - realloc_safe = true, - needs_destructor = true, - needs_constructor = true, - constructor_may_fail = false - }; - }; - - template class traits_t : public traits_default {}; - - template - class combine_traits { - public: - enum { - realloc_safe = (traits1::realloc_safe && traits2::realloc_safe), - needs_destructor = (traits1::needs_destructor || traits2::needs_destructor), - needs_constructor = (traits1::needs_constructor || traits2::needs_constructor), - constructor_may_fail = (traits1::constructor_may_fail || traits2::constructor_may_fail), - }; - }; - - template - class traits_combined : public combine_traits,pfc::traits_t > {}; - - template class traits_t : public traits_rawobject {}; - - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - - template<> class traits_t : public traits_rawobject {}; - template<> class traits_t : public traits_rawobject {}; - - template<> class traits_t : public traits_rawobject {}; - - template - class traits_t : public traits_t {}; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/pfc/utf8.cpp b/tools/vio2sf/src/foobar/pfc/utf8.cpp deleted file mode 100644 index 81b37d21b..000000000 --- a/tools/vio2sf/src/foobar/pfc/utf8.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include "pfc.h" - -namespace pfc { -//utf8 stuff - -static const t_uint8 mask_tab[6]={0x80,0xE0,0xF0,0xF8,0xFC,0xFE}; - -static const t_uint8 val_tab[6]={0,0xC0,0xE0,0xF0,0xF8,0xFC}; - -t_size utf8_char_len_from_header(char p_c) throw() -{ - t_uint8 c = (t_uint8)p_c; - - t_size cnt = 0; - for(;;) - { - if ((p_c & mask_tab[cnt])==val_tab[cnt]) break; - if (++cnt>=6) return 0; - } - - return cnt + 1; - -} -t_size utf8_decode_char(const char *p_utf8,unsigned & wide) throw() { - const t_uint8 * utf8 = (const t_uint8*)p_utf8; - const t_size max = 6; - - if (utf8[0]<0x80) { - wide = utf8[0]; - return utf8[0]>0 ? 1 : 0; - } - wide = 0; - - unsigned res=0; - unsigned n; - unsigned cnt=0; - for(;;) - { - if ((*utf8&mask_tab[cnt])==val_tab[cnt]) break; - if (++cnt>=max) return 0; - } - cnt++; - - if (cnt==2 && !(*utf8&0x1E)) return 0; - - if (cnt==1) - res=*utf8; - else - res=(0xFF>>(cnt+1))&*utf8; - - for (n=1;n> (7 - cnt))) - return 0; - - res=(res<<6)|(utf8[n]&0x3F); - } - - wide = res; - - return cnt; -} - -t_size utf8_decode_char(const char *p_utf8,unsigned & wide,t_size max) throw() -{ - const t_uint8 * utf8 = (const t_uint8*)p_utf8; - - if (max==0) { - wide = 0; - return 0; - } - - if (utf8[0]<0x80) { - wide = utf8[0]; - return utf8[0]>0 ? 1 : 0; - } - if (max>6) max = 6; - wide = 0; - - unsigned res=0; - unsigned n; - unsigned cnt=0; - for(;;) - { - if ((*utf8&mask_tab[cnt])==val_tab[cnt]) break; - if (++cnt>=max) return 0; - } - cnt++; - - if (cnt==2 && !(*utf8&0x1E)) return 0; - - if (cnt==1) - res=*utf8; - else - res=(0xFF>>(cnt+1))&*utf8; - - for (n=1;n> (7 - cnt))) - return 0; - - res=(res<<6)|(utf8[n]&0x3F); - } - - wide = res; - - return cnt; -} - - -t_size utf8_encode_char(unsigned wide,char * target) throw() -{ - t_size count; - - if (wide < 0x80) - count = 1; - else if (wide < 0x800) - count = 2; - else if (wide < 0x10000) - count = 3; - else if (wide < 0x200000) - count = 4; - else if (wide < 0x4000000) - count = 5; - else if (wide <= 0x7FFFFFFF) - count = 6; - else - return 0; - //if (count>max) return 0; - - if (target == 0) - return count; - - switch (count) - { - case 6: - target[5] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x4000000; - case 5: - target[4] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x200000; - case 4: - target[3] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x10000; - case 3: - target[2] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x800; - case 2: - target[1] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0xC0; - case 1: - target[0] = wide; - } - - return count; -} - -t_size utf16_encode_char(unsigned cur_wchar,wchar_t * out) throw() -{ - if (cur_wchar < 0x10000) { - *out = (wchar_t) cur_wchar; return 1; - } else if (cur_wchar < (1 << 20)) { - unsigned c = cur_wchar - 0x10000; - //MSDN: - //The first (high) surrogate is a 16-bit code value in the range U+D800 to U+DBFF. The second (low) surrogate is a 16-bit code value in the range U+DC00 to U+DFFF. Using surrogates, Unicode can support over one million characters. For more details about surrogates, refer to The Unicode Standard, version 2.0. - out[0] = (wchar_t)(0xD800 | (0x3FF & (c>>10)) ); - out[1] = (wchar_t)(0xDC00 | (0x3FF & c) ) ; - return 2; - } else { - *out = '?'; return 1; - } -} - -t_size utf16_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length) throw() { - if (p_source_length == 0) return 0; - else if (p_source_length == 1) { - *p_out = p_source[0]; - return 1; - } else { - t_size retval = 0; - unsigned decoded = p_source[0]; - if (decoded != 0) - { - retval = 1; - if ((decoded & 0xFC00) == 0xD800) - { - unsigned low = p_source[1]; - if ((low & 0xFC00) == 0xDC00) - { - decoded = 0x10000 + ( ((decoded & 0x3FF) << 10) | (low & 0x3FF) ); - retval = 2; - } - } - } - *p_out = decoded; - return retval; - } -} - - -unsigned utf8_get_char(const char * src) -{ - unsigned rv = 0; - utf8_decode_char(src,rv); - return rv; -} - - -t_size utf8_char_len(const char * s,t_size max) throw() -{ - unsigned dummy; - return utf8_decode_char(s,dummy,max); -} - -t_size skip_utf8_chars(const char * ptr,t_size count) throw() -{ - t_size num = 0; - for(;count && ptr[num];count--) - { - t_size d = utf8_char_len(ptr+num); - if (d<=0) break; - num+=d; - } - return num; -} - -bool is_valid_utf8(const char * param,t_size max) { - t_size walk = 0; - while(walk < max && param[walk] != 0) { - t_size d; - unsigned dummy; - d = utf8_decode_char(param + walk,dummy,max - walk); - if (d==0) return false; - walk += d; - if (walk > max) { - PFC_ASSERT(0);//should not be triggerable - return false; - } - } - return true; -} - -bool is_lower_ascii(const char * param) -{ - while(*param) - { - if (*param<0) return false; - param++; - } - return true; -} - -static bool check_end_of_string(const char * ptr) -{ - __try { - return !*ptr; - } - __except(1) {return true;} -} - -unsigned strcpy_utf8_truncate(const char * src,char * out,unsigned maxbytes) -{ - unsigned rv = 0 , ptr = 0; - if (maxbytes>0) - { - maxbytes--;//for null - while(!check_end_of_string(src) && maxbytes>0) - { - __try { - t_size delta = utf8_char_len(src); - if (delta>maxbytes || delta==0) break; - do - { - out[ptr++] = *(src++); - } while(--delta); - } __except(1) { break; } - rv = ptr; - } - out[rv]=0; - } - return rv; -} - -t_size strlen_utf8(const char * p,t_size num) throw() -{ - unsigned w; - t_size d; - t_size ret = 0; - for(;num;) - { - d = utf8_decode_char(p,w); - if (w==0 || d<=0) break; - ret++; - p+=d; - num-=d; - } - return ret; -} - -t_size utf8_chars_to_bytes(const char * string,t_size count) throw() -{ - t_size bytes = 0; - while(count) - { - unsigned dummy; - t_size delta = utf8_decode_char(string+bytes,dummy); - if (delta==0) break; - bytes += delta; - count--; - } - return bytes; -} - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/sdk-license.txt b/tools/vio2sf/src/foobar/sdk-license.txt deleted file mode 100644 index 350911121..000000000 --- a/tools/vio2sf/src/foobar/sdk-license.txt +++ /dev/null @@ -1,14 +0,0 @@ -foobar2000 0.9.5 SDK -Copyright (c) 2001-2008, Peter Pawlowski -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation or other materials provided with the distribution. - -Usage restrictions: -It is illegal to use this SDK as a part of foobar2000 components that operate outside of legally documented programming interfaces (APIs), such as using window procedure hooks to modify user interface behaviors. We believe components doing so to be harmful to our userbase by introducing compatibility issues and dependencies on undocumented behaviors of our code that may change at any time without any notice or an update to the SDK which would reflect the change. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/sdk-readme.css b/tools/vio2sf/src/foobar/sdk-readme.css deleted file mode 100644 index 74c0c9bc6..000000000 --- a/tools/vio2sf/src/foobar/sdk-readme.css +++ /dev/null @@ -1 +0,0 @@ -a.interwiki{background:transparent url(/wiki/lib/images/interwiki.png) 0px 1px no-repeat;padding-left:16px;}a.iw_wp{background-image:url(/wiki/lib/images/interwiki/wp.gif)}a.iw_wpde{background-image:url(/wiki/lib/images/interwiki/wpde.gif)}a.iw_wpmeta{background-image:url(/wiki/lib/images/interwiki/wpmeta.gif)}a.iw_doku{background-image:url(/wiki/lib/images/interwiki/doku.gif)}a.iw_sb{background-image:url(/wiki/lib/images/interwiki/sb.gif)}a.iw_amazon{background-image:url(/wiki/lib/images/interwiki/amazon.gif)}a.iw_amazon_de{background-image:url(/wiki/lib/images/interwiki/amazon.de.gif)}a.iw_amazon_uk{background-image:url(/wiki/lib/images/interwiki/amazon.uk.gif)}a.iw_phpfn{background-image:url(/wiki/lib/images/interwiki/phpfn.gif)}a.iw_dokubug{background-image:url(/wiki/lib/images/interwiki/dokubug.gif)}a.iw_coral{background-image:url(/wiki/lib/images/interwiki/coral.gif)}a.iw_google{background-image:url(/wiki/lib/images/interwiki/google.gif)}a.iw_meatball{background-image:url(/wiki/lib/images/interwiki/meatball.gif)}a.iw_wiki{background-image:url(/wiki/lib/images/interwiki/wiki.gif)}a.mediafile{background:transparent url(/wiki/lib/images/fileicons/file.png) 0px 1px no-repeat;padding-left:18px;padding-bottom:1px;}a.mf_jpg{background-image:url(/wiki/lib/images/fileicons/jpg.png)}a.mf_jpeg{background-image:url(/wiki/lib/images/fileicons/jpeg.png)}a.mf_gif{background-image:url(/wiki/lib/images/fileicons/gif.png)}a.mf_png{background-image:url(/wiki/lib/images/fileicons/png.png)}a.mf_tgz{background-image:url(/wiki/lib/images/fileicons/tgz.png)}a.mf_tar{background-image:url(/wiki/lib/images/fileicons/tar.png)}a.mf_gz{background-image:url(/wiki/lib/images/fileicons/gz.png)}a.mf_zip{background-image:url(/wiki/lib/images/fileicons/zip.png)}a.mf_rar{background-image:url(/wiki/lib/images/fileicons/rar.png)}a.mf_pdf{background-image:url(/wiki/lib/images/fileicons/pdf.png)}a.mf_ps{background-image:url(/wiki/lib/images/fileicons/ps.png)}a.mf_doc{background-image:url(/wiki/lib/images/fileicons/doc.png)}a.mf_xls{background-image:url(/wiki/lib/images/fileicons/xls.png)}a.mf_ppt{background-image:url(/wiki/lib/images/fileicons/ppt.png)}a.mf_rtf{background-image:url(/wiki/lib/images/fileicons/rtf.png)}a.mf_swf{background-image:url(/wiki/lib/images/fileicons/swf.png)}a.mf_rpm{background-image:url(/wiki/lib/images/fileicons/rpm.png)}a.mf_deb{background-image:url(/wiki/lib/images/fileicons/deb.png)}a.mf_sxw{background-image:url(/wiki/lib/images/fileicons/sxw.png)}a.mf_sxc{background-image:url(/wiki/lib/images/fileicons/sxc.png)}a.mf_sxi{background-image:url(/wiki/lib/images/fileicons/sxi.png)}a.mf_sxd{background-image:url(/wiki/lib/images/fileicons/sxd.png)}a.mf_odc{background-image:url(/wiki/lib/images/fileicons/odc.png)}a.mf_odf{background-image:url(/wiki/lib/images/fileicons/odf.png)}a.mf_odg{background-image:url(/wiki/lib/images/fileicons/odg.png)}a.mf_odi{background-image:url(/wiki/lib/images/fileicons/odi.png)}a.mf_odp{background-image:url(/wiki/lib/images/fileicons/odp.png)}a.mf_ods{background-image:url(/wiki/lib/images/fileicons/ods.png)}a.mf_odt{background-image:url(/wiki/lib/images/fileicons/odt.png)}div.clearer{clear:both;line-height:0px;height:0;overflow:hidden;}div.no{display:inline;margin:0;padding:0;}.hidden{display:none;}div.error{background:#fcc url(/wiki/lib/styles/../images/error.png) 0.5em 0px no-repeat;color:#000;border-bottom:1px solid #faa;font-size:90%;margin:0;padding-left:3em;overflow:hidden;}div.info{background:#ccf url(/wiki/lib/styles/../images/info.png) 0.5em 0px no-repeat;color:#000;border-bottom:1px solid #aaf;font-size:90%;margin:0;padding-left:3em;overflow:hidden;}div.success{background:#cfc url(/wiki/lib/styles/../images/success.png) 0.5em 0px no-repeat;color:#000;border-bottom:1px solid #afa;font-size:90%;margin:0;padding-left:3em;overflow:hidden;}div.notify{background:#ffc url(/wiki/lib/styles/../images/notify.png) 0.5em 0px no-repeat;color:#000;border-bottom:1px solid #ffa;font-size:90%;margin:0;padding-left:3em;overflow:hidden;}.medialeft{float:left;}.mediaright{float:right;}.mediacenter{display:block;margin-left:auto;margin-right:auto;}.leftalign{text-align:left;}.centeralign{text-align:center;}.rightalign{text-align:right;}em.u{font-style:normal;text-decoration:underline;}em em.u{font-style:italic;}.code .br0{color:#6c6;}.code .co1{color:#808080;font-style:italic;}.code .co2{color:#808080;font-style:italic;}.code .co3{color:#808080;}.code .coMULTI{color:#808080;font-style:italic;}.code .es0{color:#009;font-weight:bold;}.code .kw1{color:#b1b100;}.code .kw2{color:#000;font-weight:bold;}.code .kw3{color:#006;}.code .kw4{color:#933;}.code .kw5{color:#00f;}.code .me1{color:#060;}.code .me2{color:#060;}.code .nu0{color:#c6c;}.code .re0{color:#00f;}.code .re1{color:#00f;}.code .re2{color:#00f;}.code .re3{color:#f33;font-weight:bold;}.code .re4{color:#099;}.code .st0{color:#f00;}.code .sy0{color:#6c6;}#acl__manager label{text-align:left;font-weight:normal;display:inline;}#acl__manager table{margin-left:10%;width:80%;}#config__manager div.success,#config__manager div.error,#config__manager div.info{background-position:0.5em;padding:0.5em;text-align:center;}#config__manager fieldset{margin:1em;width:auto;margin-bottom:2em;background-color:#dee7ec;color:#000;padding:0 1em;}#config__manager legend{font-size:1.25em;}#config__manager form{}#config__manager table{margin:1em 0;width:100%;}#config__manager fieldset td{text-align:left;}#config__manager fieldset td.value{width:30em;}#config__manager td input.edit{width:30em;}#config__manager td select.edit{}#config__manager td textarea.edit{width:27.5em;height:4em;}#config__manager tr .input,#config__manager tr input,#config__manager tr textarea,#config__manager tr select{background-color:#fff;color:#000;}#config__manager tr.default .input,#config__manager tr.default input,#config__manager tr.default textarea,#config__manager tr.default select,#config__manager .selectiondefault{background-color:#cdf;color:#000;}#config__manager tr.protected .input,#config__manager tr.protected input,#config__manager tr.protected textarea,#config__manager tr.protected select,#config__manager tr.protected .selection{background-color:#fcc!important;color:#000 !important;}#config__manager td.error{background-color:red;color:#000;}#config__manager .selection{width:14.8em;float:left;margin:0 0.3em 2px 0;}#config__manager .selection label{float:right;width:14em;font-size:90%;}* html #config__manager .selection label{padding-top:2px;}#config__manager .selection input.checkbox{padding-left:0.7em;}#config__manager .other{clear:both;padding-top:0.5em;}#config__manager .other label{padding-left:2px;font-size:90%;}#plugin__manager{}#plugin__manager h2{margin-left:0;}#plugin__manager form{display:block;margin:0;padding:0;}#plugin__manager legend{display:none;}#plugin__manager fieldset{width:auto;}#plugin__manager .button{margin:0;}#plugin__manager p,#plugin__manager label{text-align:left;}#plugin__manager .hidden{display:none;}#plugin__manager .new{background:#dee7ec;}#plugin__manager input[disabled]{color:#ccc;border-color:#ccc;}#plugin__manager .pm_menu,#plugin__manager .pm_info{margin-left:0;text-align:left;}#plugin__manager .pm_menu{float:left;width:48%;}#plugin__manager .pm_info{float:right;width:50%;}#plugin__manager .common{}#plugin__manager .common form{}#plugin__manager .common fieldset{margin:0;padding:0 0 1.0em 0;text-align:left;border:none;}#plugin__manager .common label{padding:0 0 0.5em 0;}#plugin__manager .common input{}#plugin__manager .common input.edit{width:24em;margin:0.5em;}#plugin__manager .common .button{}#plugin__manager form.plugins{}#plugin__manager .plugins fieldset{color:#000;background:#fff;text-align:right;border-top:none;border-right:none;border-left:none;}#plugin__manager .plugins fieldset.protected{background:#fdd;color:#000;}#plugin__manager .plugins fieldset.disabled{background:#e0e0e0;color:#a8a8a8;}#plugin__manager .plugins .legend{color:#000;background:inherit;display:block;margin:0;padding:0;font-size:1em;line-height:1.4em;font-weight:normal;text-align:left;float:left;padding:0;clear:none;}#plugin__manager .plugins .button{font-size:95%;}#plugin__manager .plugins fieldset.buttons{border:none;}#plugin__manager .plugins fieldset.buttons .button{float:left;}#plugin__manager .pm_info h3{margin-left:0;}#plugin__manager .pm_info dl{margin:1em 0;padding:0;}#plugin__manager .pm_info dt{width:6em;float:left;clear:left;margin:0;padding:0;}#plugin__manager .pm_info dd{margin:0 0 0 7em;padding:0;background:none;}#plugin__manager .plugins .enable{float:left;width:auto;margin-right:0.5em;}#user__manager tr.disabled{color:#6f6f6f;background:#e4e4e4;}#user__manager tr.user_info{vertical-align:top;}#user__manager div.edit_user{width:46%;float:left;}#user__manager table{margin-bottom:1em;}#user__manager input.button[disabled]{color:#ccc!important;border-color:#ccc!important;}div.dokuwiki .header{padding:3px 0 0 2px;}div.dokuwiki .pagename{float:left;font-size:200%;font-weight:bolder;color:#dee7ec;text-align:left;vertical-align:middle;}div.dokuwiki .pagename a{color:#436976 !important;text-decoration:none !important;}div.dokuwiki .logo{float:right;font-size:220%;font-weight:bolder;text-align:right;vertical-align:middle;}div.dokuwiki .logo a{color:#dee7ec !important;text-decoration:none !important;font-variant:small-caps;letter-spacing:2pt;}div.dokuwiki .bar{border-top:1px solid #8cacbb;border-bottom:1px solid #8cacbb;background:#dee7ec;padding:0.1em 0.15em;clear:both;}div.dokuwiki .bar-left{float:left;}div.dokuwiki .bar-right{float:right;text-align:right;}div.dokuwiki #bar__bottom{margin-bottom:3px;}div.dokuwiki div.meta{clear:both;margin-top:1em;color:#638c9c;font-size:70%;}div.dokuwiki div.meta div.user{float:left;}div.dokuwiki div.meta div.doc{text-align:right;}*{padding:0;margin:0;}body{font:80% "Lucida Grande",Verdana,Lucida,Helvetica,Arial,sans-serif;background-color:#fff;color:#000;}div.dokuwiki div.page{margin:4px 2em 0 1em;text-align:justify;}div.dokuwiki table{font-size:100%;}div.dokuwiki tr,div.dokuwiki td,div.dokuwiki th{}div.dokuwiki img{border:0;}div.dokuwiki p,div.dokuwiki blockquote,div.dokuwiki table,div.dokuwiki pre{margin:0 0 1.0em 0;}div.dokuwiki hr{border:0px;border-top:1px solid #8cacbb;text-align:center;height:0px;}div.dokuwiki div.nothing{text-align:center;margin:2em;}div.dokuwiki form{border:none;display:inline;}div.dokuwiki label.block{display:block;text-align:right;font-weight:bold;}div.dokuwiki label.simple{display:block;text-align:left;font-weight:normal;}div.dokuwiki label.block input.edit{width:50%;}div.dokuwiki fieldset{width:300px;text-align:center;border:1px solid #8cacbb;padding:0.5em;margin:auto;}div.dokuwiki textarea.edit{font-family:monospace;font-size:14px;color:#000;background-color:#fff;border:1px solid #8cacbb;padding:0.3em 0 0 0.3em;width:100%;}html>body div.dokuwiki textarea.edit{background:#fff url(/wiki/lib/tpl/default/images/inputshadow.png) repeat-x top;}div.dokuwiki input.edit,div.dokuwiki select.edit{font-size:100%;border:1px solid #8cacbb;color:#000;background-color:#fff;vertical-align:middle;margin:1px;padding:0.20em 0.3em;display:inline;}html>body div.dokuwiki input.edit,html>body div.dokuwiki select.edit{background:#fff url(/wiki/lib/tpl/default/images/inputshadow.png) repeat-x top;}div.dokuwiki select.edit{padding:0.1em 0;}div.dokuwiki input.missing{font-size:100%;border:1px solid #8cacbb;color:#000;background-color:#fcc;vertical-align:middle;margin:1px;padding:0.20em 0.3em;display:inline;}div.dokuwiki textarea.edit[disabled],div.dokuwiki textarea.edit[readonly],div.dokuwiki input.edit[disabled],div.dokuwiki input.edit[readonly],div.dokuwiki select.edit[disabled]{background-color:#f5f5f5!important;color:#666!important;}div.dokuwiki div.toolbar,div.dokuwiki div#wiki__editbar{margin:2px 0;text-align:left;}div.dokuwiki div#size__ctl{float:right;width:60px;height:2.7em;}div.dokuwiki #size__ctl img{cursor:pointer;}div.dokuwiki div#wiki__editbar div.editButtons{float:left;padding:0 1.0em 0.7em 0;}div.dokuwiki div#wiki__editbar div.summary{float:left;}div.dokuwiki .nowrap{white-space:nowrap;}div.dokuwiki div#draft__status{float:right;color:#638c9c;}div.dokuwiki input.button,div.dokuwiki button.button{border:1px solid #8cacbb;color:#000;background-color:#fff;vertical-align:middle;text-decoration:none;font-size:100%;cursor:pointer;margin:1px;padding:0.125em 0.4em;}html>body div.dokuwiki input.button,html>body div.dokuwiki button.button{background:#fff url(/wiki/lib/tpl/default/images/buttonshadow.png) repeat-x bottom;}* html div.dokuwiki input.button,* html div.dokuwiki button.button{height:1.8em;}div.dokuwiki div.secedit input.button{border:1px solid #8cacbb;color:#000;background-color:#fff;vertical-align:middle;text-decoration:none;margin:0;padding:0;font-size:10px;cursor:pointer;float:right;display:inline;}div.dokuwiki div.pagenav{margin:1em 0 0 0;}div.dokuwiki div.pagenav-prev{text-align:right;float:left;width:49%}div.dokuwiki div.pagenav-next{text-align:left;float:right;width:49%}div.dokuwiki a:link,div.dokuwiki a:visited{color:#436976;text-decoration:none;}div.dokuwiki a:hover,div.dokuwiki a:active{color:#000;text-decoration:underline;}div.dokuwiki h1 a,div.dokuwiki h2 a,div.dokuwiki h3 a,div.dokuwiki h4 a,div.dokuwiki h5 a,div.dokuwiki a.nolink{color:#000 !important;text-decoration:none !important;}div.dokuwiki a.urlextern{background:transparent url(/wiki/lib/tpl/default/images/link_icon.gif) 0px 1px no-repeat;padding:1px 0px 1px 16px;}div.dokuwiki a.windows{background:transparent url(/wiki/lib/tpl/default/images/windows.gif) 0px 1px no-repeat;padding:1px 0px 1px 16px;}div.dokuwiki a.interwiki{}div.dokuwiki a.media{}div.dokuwiki a.urlextern:link,div.dokuwiki a.windows:link,div.dokuwiki a.interwiki:link{color:#436976;}div.dokuwiki a.urlextern:visited,div.dokuwiki a.windows:visited,div.dokuwiki a.interwiki:visited{color:purple;}div.dokuwiki a.urlextern:hover,div.dokuwiki a.urlextern:active,div.dokuwiki a.windows:hover,div.dokuwiki a.windows:active,div.dokuwiki a.interwiki:hover,div.dokuwiki a.interwiki:active{color:#000;}div.dokuwiki a.mail{background:transparent url(/wiki/lib/tpl/default/images/mail_icon.gif) 0px 1px no-repeat;padding:1px 0px 1px 16px;}div.dokuwiki a.wikilink1{color:#090 !important;}div.dokuwiki a.wikilink2{color:#f30 !important;text-decoration:none !important;border-bottom:dashed 1px #f30 !important;}div.dokuwiki div.preview{background-color:#f5f5f5;margin:0 0 0 2em;padding:4px;border:1px dashed #000;}div.dokuwiki div.breadcrumbs{background-color:#f5f5f5;color:#666;font-size:80%;padding:0 0 0 4px;}div.dokuwiki span.user{color:#ccc;font-size:90%;}div.dokuwiki li.minor{color:#666;font-style:italic;}div.dokuwiki img.media{margin:3px;}div.dokuwiki img.medialeft{border:0;float:left;margin:0 1.5em 0 0;}div.dokuwiki img.mediaright{border:0;float:right;margin:0 0 0 1.5em;}div.dokuwiki img.mediacenter{border:0;display:block;margin:0 auto;}div.dokuwiki img.middle{vertical-align:middle;}div.dokuwiki acronym{cursor:help;border-bottom:1px dotted #000;}div.dokuwiki h1,div.dokuwiki h2,div.dokuwiki h3,div.dokuwiki h4,div.dokuwiki h5{color:#000;background-color:inherit;font-size:100%;font-weight:normal;margin:0 0 1em 0;padding:0.5em 0 0 0;border-bottom:1px solid #8cacbb;clear:left;}div.dokuwiki h1{font-size:160%;margin-left:0px;font-weight:bold;}div.dokuwiki h2{font-size:150%;margin-left:20px;}div.dokuwiki h3{font-size:140%;margin-left:40px;border-bottom:none;font-weight:bold;}div.dokuwiki h4{font-size:120%;margin-left:60px;border-bottom:none;font-weight:bold;}div.dokuwiki h5{font-size:100%;margin-left:80px;border-bottom:none;font-weight:bold;}div.dokuwiki div.level1{margin-left:3px;}div.dokuwiki div.level2{margin-left:23px;}div.dokuwiki div.level3{margin-left:43px;}div.dokuwiki div.level4{margin-left:63px;}div.dokuwiki div.level5{margin-left:83px;}div.dokuwiki ul{line-height:1.5em;list-style-type:square;list-style-image:none;margin:0 0 0.5em 1.5em;color:#638c9c;}div.dokuwiki ol{line-height:1.5em;list-style-image:none;margin:0 0 0.5em 1.5em;color:#638c9c;font-weight:bold;}div.dokuwiki .li{color:#000;font-weight:normal;}div.dokuwiki ol{list-style-type:decimal}div.dokuwiki ol ol{list-style-type:upper-roman}div.dokuwiki ol ol ol{list-style-type:lower-alpha}div.dokuwiki ol ol ol ol{list-style-type:lower-greek}div.dokuwiki li.open{list-style-image:url(/wiki/lib/tpl/default/images/open.gif);}div.dokuwiki li.closed{list-style-image:url(/wiki/lib/tpl/default/images/closed.gif);}div.dokuwiki blockquote{border-left:2px solid #8cacbb;padding-left:3px;}div.dokuwiki pre{font-size:120%;padding:0.5em;border:1px dashed #8cacbb;color:#000;overflow:auto;}div.dokuwiki pre.pre{background-color:#f7f9fa;}div.dokuwiki pre.code{background-color:#f7f9fa;}div.dokuwiki code{font-size:120%;}div.dokuwiki pre.file{background-color:#dee7ec;}div.dokuwiki table.inline{background-color:#fff;border-spacing:0px;border-collapse:collapse;}div.dokuwiki table.inline th{padding:3px;border:1px solid #8cacbb;background-color:#dee7ec;}div.dokuwiki table.inline td{padding:3px;border:1px solid #8cacbb;}div.dokuwiki div.toc{margin:1.2em 0 0 2em;float:right;width:200px;font-size:80%;clear:both;}div.dokuwiki div.tocheader{border:1px solid #8cacbb;background-color:#dee7ec;text-align:left;font-weight:bold;padding:3px;margin-bottom:2px;}div.dokuwiki span.toc_open,div.dokuwiki span.toc_close{border:0.4em solid #dee7ec;float:right;display:block;margin:0.4em 3px 0 0;}div.dokuwiki span.toc_open span,div.dokuwiki span.toc_close span{display:none;}div.dokuwiki span.toc_open{margin-top:0.4em;border-top:0.4em solid #000;}div.dokuwiki span.toc_close{margin-top:0;border-bottom:0.4em solid #000;}div.dokuwiki #toc__inside{border:1px solid #8cacbb;background-color:#fff;text-align:left;padding:0.5em 0 0.7em 0;}div.dokuwiki ul.toc{list-style-type:none;list-style-image:none;line-height:1.2em;padding-left:1em;margin:0;}div.dokuwiki ul.toc li{background:transparent url(/wiki/lib/tpl/default/images/tocdot2.gif) 0 0.6em no-repeat;padding-left:0.4em;}div.dokuwiki ul.toc li.clear{background-image:none;padding-left:0.4em;}div.dokuwiki a.toc:link,div.dokuwiki a.toc:visited{color:#436976;}div.dokuwiki a.toc:hover,div.dokuwiki a.toc:active{color:#000;}div.dokuwiki table.diff{background-color:#fff;width:100%;}div.dokuwiki td.diff-blockheader{font-weight:bold;}div.dokuwiki table.diff th{border-bottom:1px solid #8cacbb;font-size:120%;width:50%;font-weight:normal;text-align:left;}div.dokuwiki table.diff td{font-family:monospace;font-size:100%;}div.dokuwiki td.diff-addedline{background-color:#dfd;}div.dokuwiki td.diff-deletedline{background-color:#ffb;}div.dokuwiki td.diff-context{background-color:#f5f5f5;}div.dokuwiki table.diff td.diff-addedline strong,div.dokuwiki table.diff td.diff-deletedline strong{color:red;}div.dokuwiki div.footnotes{clear:both;border-top:1px solid #8cacbb;padding-left:1em;margin-top:1em;}div.dokuwiki div.fn{font-size:90%;}div.dokuwiki a.fn_top{vertical-align:super;font-size:80%;}div.dokuwiki a.fn_bot{vertical-align:super;font-size:80%;font-weight:bold;}div.insitu-footnote{font-size:80%;line-height:1.2em;border:1px solid #8cacbb;background-color:#f7f9fa;text-align:left;padding:4px;max-width:40%;}* html .insitu-footnote pre.code,* html .insitu-footnote pre.file{padding-bottom:18px;}div.dokuwiki .search_result{margin-bottom:6px;padding:0 10px 0 30px;}div.dokuwiki .search_snippet{color:#ccc;font-size:12px;margin-left:20px;}div.dokuwiki .search_sep{color:#000;}div.dokuwiki .search_hit{color:#000;background-color:#ff9;}div.dokuwiki strong.search_hit{font-weight:normal;}div.dokuwiki div.search_quickresult{margin:0 0 15px 30px;padding:0 10px 10px 0;border-bottom:1px dashed #8cacbb;}div.dokuwiki div.search_quickresult h3{margin:0 0 1.0em 0;font-size:1em;font-weight:bold;}div.dokuwiki ul.search_quickhits{margin:0 0 0.5em 1.0em;}div.dokuwiki ul.search_quickhits li{margin:0 1.0em 0 1.0em;float:left;width:30%;}div.footerinc{text-align:center;}.footerinc a img{opacity:0.5;border:0;}.footerinc a:hover img{opacity:1;}div.dokuwiki div.ajax_qsearch{position:absolute;right:237px;;width:200px;opacity:0.9;display:none;font-size:80%;line-height:1.2em;border:1px solid #8cacbb;background-color:#f7f9fa;text-align:left;padding:4px;}button.toolbutton{background-color:#fff;padding:0px;margin:0 1px 0 0;border:1px solid #8cacbb;cursor:pointer;}html>body button.toolbutton{background:#fff url(/wiki/lib/tpl/default/images/buttonshadow.png) repeat-x bottom;}div.picker{width:250px;border:1px solid #8cacbb;background-color:#dee7ec;}button.pickerbutton{padding:0px;margin:0 1px 1px 0;border:0;background-color:transparent;font-size:80%;cursor:pointer;}div.dokuwiki a.spell_error{color:#f00;text-decoration:underline;}div.dokuwiki div#spell__suggest{background-color:#fff;padding:2px;border:1px solid #000;font-size:80%;display:none;}div.dokuwiki div#spell__result{border:1px solid #8cacbb;color:#000;font-size:14px;padding:3px;background-color:#f7f9fa;display:none;}div.dokuwiki span.spell_noerr{color:#093;}div.dokuwiki span.spell_wait{color:#06c;}div.dokuwiki div.img_big{float:left;margin-right:0.5em;}div.dokuwiki dl.img_tags dt{font-weight:bold;background-color:#dee7ec;}div.dokuwiki dl.img_tags dd{background-color:#f5f5f5;}div.dokuwiki div.imagemeta{color:#666;font-size:70%;line-height:95%;}div.dokuwiki div.imagemeta img.thumb{float:left;margin-right:0.1em;}#media__manager{height:100%;overflow:hidden;}#media__left{width:30%;border-right:solid 1px #8cacbb;height:100%;overflow:auto;position:absolute;left:0;}#media__right{width:69.7%;height:100%;overflow:auto;position:absolute;right:0;}#media__manager h1{margin:0;padding:0;margin-bottom:0.5em;}#media__tree img{float:left;padding:0.5em 0.3em 0 0;}#media__tree ul{list-style-type:none;list-style-image:none;}#media__tree li{clear:left;list-style-type:none;list-style-image:none;}* html #media__tree li{border:1px solid #fff;}#media__opts{padding-left:1em;margin-bottom:0.5em;}#media__opts input{float:left;position:absolute;}* html #media__opts input{position:static;}#media__opts label{display:block;float:left;margin-left:30px;}* html #media__opts label{margin-left:10px;}#media__opts br{clear:left;}#media__content img.load{margin:1em auto;}#media__content #scroll__here{border:1px dashed #8cacbb;}#media__content .odd{background-color:#f7f9fa;padding:0.4em;}#media__content .even{padding:0.4em;}#media__content a.mediafile{margin-right:1.5em;font-weight:bold;}#media__content div.detail{padding:0.3em 0 0.3em 2em;}#media__content div.detail div.thumb{float:left;width:130px;text-align:center;margin-right:0.4em;}#media__content img.btn{vertical-align:text-bottom;}#media__content div.example{color:#666;margin-left:1em;}#media__content div.upload{font-size:90%;padding:0 0.5em 0.5em 0.5em;}#media__content form.upload{display:block;border-bottom:solid 1px #8cacbb;padding:0 0.5em 1em 0.5em;}#media__content form.upload fieldset{padding:0;margin:0;border:none;width:auto;}#media__content form.upload p{clear:left;text-align:left;padding:0.25em 0;margin:0;line-height:1.0em;}#media__content form.upload label{float:left;width:30%;}#media__content form.upload label.check{float:none;width:auto;}#media__content form.upload input.check{margin-left:30%;}#media__content form.meta{display:block;padding:0 0 1em 0;}#media__content form.meta label{display:block;width:25%;float:left;font-weight:bold;margin-left:1em;clear:left;}#media__content form.meta .edit{font:100% "Lucida Grande",Verdana,Lucida,Helvetica,Arial,sans-serif;float:left;width:70%;padding-right:0;padding-left:0.2em;margin:2px;}#media__content form.meta textarea.edit{height:8em;}#media__content form.meta div.metafield{clear:left;}#media__content form.meta div.buttons{clear:left;margin-left:20%;padding-left:1em;} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar/sdk-readme.html b/tools/vio2sf/src/foobar/sdk-readme.html deleted file mode 100644 index e7dec6cbc..000000000 --- a/tools/vio2sf/src/foobar/sdk-readme.html +++ /dev/null @@ -1,372 +0,0 @@ - - - foobar2000 0.9.5 SDK readme - - - - - -
- - - - -

foobar2000 0.9.5 SDK readme

-
- -
- -

Compatibility

-
- -

- Components built with this SDK are compatible with foobar2000 0.9.5. They are not compatible with any earlier versions (will fail to load), and not guaranteed to be compatible with any future versions, though upcoming 0.9.X releases will aim to maintain compatibility as far as possible without crippling newly added functionality. -

- -
- -

New features provided by incremental updates

-
- -

-Some of non-critical functionality provided through this SDK (flagged as such) was introduced in one of incremental 0.9.5.X updates and will not function when used with foobar2000 versions older than specified in the description of specific API. For an example: -

-
try {
-  //Attempting to use an API that was introduced in 0.9.5.1:
-  static_api_ptr_t<app_close_blocking_task_manager>()->register_task(mytask);
-} catch(exception_service_not_found) {
-  //User's foobar2000 is older than 0.9.5.1.
-  //Possible responses: ignore and disable affected functionality, complain to user about outdated install, etc.
-}
-
- -

Basic usage

-
- -

- Each component must link against: -

-
    -
  • foobar2000_SDK project (contains declarations of services and various service-specific helper code)
    -
  • -
  • foobar2000_component_client project (contains DLL entrypoint)
    -
  • -
  • shared.dll (various helper code, mainly win32 function wrappers taking UTF-8 strings)
    -
  • -
  • PFC (non-OS-specific helper class library)
    -
  • -
- -

-Optionally, components can use helper libraries with various non-critical code that is commonly reused across various foobar2000 components: -

-
    -
  • foobar2000_SDK_helpers - a library of various helper code commonly used by foobar2000 components.
    -
  • -
  • foobar2000_ATL_helpers - another library of various helper code commonly used by foobar2000 components; requires WTL. Note that it depends on foobar2000_SDK and foobar2000_SDK_helpers projects.
    -
  • -
- -

- Foobar2000_SDK, foobar2000_component_client and PFC are included in sourcecode form; you can link against them by adding them to your workspace and using dependencies. To link against shared.dll, you must add 窶徭hared.lib窶 to linker input manually. -

- -

-Component code should include the following header files: -

-
    -
  • foobar2000.h from SDK - do not include other headers from the SDK directory directly, they're meant to be referenced by foobar2000.h only; it also includes PFC headers and shared.dll helper declaration headers.
    -
  • -
  • Optionally: helpers.h from helpers directory (foobar2000_SDK_helpers project) - a library of various helper code commonly used by foobar2000 components.
    -
  • -
  • Optionally: ATLHelpers.h from ATLHelpers directory (foobar2000_ATL_helpers project) - another library of various helper code commonly used by foobar2000 components; requires WTL. Note that ATLHelpers.h already includes SDK/foobar2000.h and helpers/helpers.h so you can replace your other include lines with a reference to ATLHelpers.h.
    -
  • -
- -
- -

Structure of a component

-
- -

- A component is a DLL that implements one or more entrypoint services and interacts with services provided by other components. -

- -
- -

Services

-
- -

- A service type is an interface class, deriving directly or indirectly from service_base class. A service type class must not have any data members; it can only provide virtual methods (to be overridden by service implementation), helper non-virtual methods built around virtual methods, static helper methods, and constants / enums. Each service interface class must have a static class_guid member, used for identification when enumerating services or querying for supported functionality. A service type declaration should declare a class with public virtual/helper/static methods, and use FB2K_MAKE_SERVICE_INTERFACE() / FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT() macro to implement standard service behaviors for the class; additionally, class_guid needs to be defined outside class declaration (e.g. const GUID someclass::class_guid = {….}; ). Note that most of components will not declare their own service types, they will only implement existing ones declared in the SDK. -

- -

-A service implementation is a class derived from relevant service type class, implementing virtual methods declared by service type class. Note that service implementation class does not implement virtual methods declared by service_base; those are implemented by service type declaration framework (service_query) or by instantiation framework (service_add_ref / service_release). Service implementation classes are instantiated using service_factory templates in case of entrypoint services (see below), or using service_impl_t template and operator new: 窶myserviceptr = new service_impl_t<myservice_impl>(params);窶. -

- -

-Each service object provides reference counter features and (service_add_ref() and service_release() methods) as well as a method to query for extended functionality (service_query() method). Those methods are implemented by service framework and should be never overridden by service implementations. These methods should also never be called directly - reference counter methods are managed by relevant autopointer templates, service_query_t function template should be used instead of calling service_query directly, to ensure type safety and correct type conversions. -

- -
- -

Entrypoint services

-
- -

- An entrypoint service type is a special case of a service type that can be registered using service_factory templates, and then accessed from any point of service system (excluding DLL startup/shutdown code, such as code inside static object constructors/destructors). An entrypoint service type class must directly derive from service_base. -

- -

-Registered entrypoint services can be accessed using: -

-
    -
  • For services types with variable number of implementations registered: service_enum_t<T> template, service_class_helper_t<T> template, etc, e.g.
    service_enum_t<someclass> e; service_ptr_t<someclass> ptr; while(e.next(ptr)) ptr->dosomething();
    -
  • -
  • For services types with single always-present implementation registered - such as core services like playlist_manager - using static_api_ptr_t<T> template, e.g.:
    static_api_ptr_t<someclass> api; api->dosomething(); api->dosomethingelse();
    -
  • -
  • Using per-service-type defined static helper functions, e.g. someclass::g_dosomething() - those use relevant service enumeration methods internally.
    -
  • -
- -

- An entrypoint service type must use FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT() macro to implement standard entrypoint service behaviors, as opposed to all other service types that use FB2K_MAKE_SERVICE_INTERFACE() macro instead. -

- -

-You can register your own entrypoint service implementations using either service_factory_t or service_factory_single_t template - the difference between the two is that the former instantiates the class on demand, while the latter keeps a single static instance and returns references to it when requested; the latter is faster but usable only for things that have no per-instance member data to maintain. Each service_factory_t / service_factory_single_t instance should be a static variable, such as: 窶static service_factory_t<myclass> g_myclass_factory;窶. -

- -

-Certain service types require custom service_factory helper templates to be used instead of standard service_factory_t / service_factory_single_t templates; see documentation of specific service type for exact info about registering. -

- -

-A typical entrypoint service implementation looks like this: -

-
class myservice_impl : public myservice {
-public:
-	void dosomething() {....};
-	void dosomethingelse(int meh) {...};
-};
-static service_factory_single_t<myservice_impl> g_myservice_impl_factory;
-
- -

Service extensions

-
- -

- Additional methods can be added to any service type, by declaring a new service type class deriving from service type class you want to extend. For example: -

-
class myservice : public service_base { public: virtual void dosomething() = 0; FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(myservice); };
-class myservice_v2 : public myservice { public: virtual void dosomethingelse() = 0; FB2K_MAKE_SERVICE_INTERFACE(myservice_v2, myservice); };
-

- In such scenario, to query whether a myservice instance is a myservice_v2 and to retrieve myservice_v2 pointer, use service_query functionality: -

-
service_ptr_t<myservice> ptr;
-(...)
-service_ptr_t<myservice_v2> ptr_ex;
-if (ptr->service_query_t(ptr_ex)) { /* ptr_ex is a valid pointer to myservice_v2 interface of our myservice instance */ (...) }
-else {/* this myservice implementation does not implement myservice_v2 */ (...) }
-
- -

Autopointer template use

-
- -

- When performing most kinds of service operations, service_ptr_t<T> template should be used rather than working with service pointers directly; it automatically manages reference counter calls, ensuring that the service object is deleted when it is no longer referenced. Additionally, static_api_ptr_t<T> can be used to automatically acquire/release a pointer to single-implementation entrypoint service, such as one of standard APIs like playlist_manager. -

- -
- -

Exception use

-
- -

- Most of API functions use C++ exceptions to signal failure conditions. All used exception classes must derive from std::exception (which pfc::exception is typedef'd to); this design allows various instances of code to use single catch() line to get human-readable description of the problem to display. -

- -

-Additionally, special subclasses of exceptions are defined for use in specific conditions, such as exception_io for I/O failures. As a result, you must provide an exception handler whenever you invoke any kind of I/O code that may fail, unless in specific case calling context already handles exceptions (e.g. input implementation code - any exceptions should be forwarded to calling context, since exceptions are a part of input API). -

- -

-Implementations of global callback services such as playlist_callback, playback_callback or library_callback must not throw unhandled exceptions; behaviors in case they do are undefined (app termination is to be expected). -

- -
- -

Storing configuration

-
- -

- In order to create your entries in the configuration file, you must instantiate some objects that derive from cfg_var class. Those can be either predefined classes (cfg_int, cfg_string, etc) or your own classes implementing relevant methods. -

- -

-Each cfg_var instance has a GUID assigned, to identify its configuration file entry. The GUID is passed to its constructor (which implementations must take care of, typically by providing a constructor that takes a GUID and forwards it to cfg_var constructor). -

- -

-Note that cfg_var objects can only be instantiated statically (either directly as static objects, or as members of other static objects). Additionally, you can create configuration data objects that can be accessed by other components, by implementing config_object service. Some standard configuration variables can be also accessed using config_object interface. -

- -
- -

Use of global callback services

-
- -

- Multiple service classes presented by the SDK allow your component to receive notifications about various events: -

-
    -
  • file_operation_callback - tracking file move/copy/delete operations.
    -
  • -
  • library_callback - tracking Media Library content changes.
    -
  • -
  • metadb_io_callback - tracking tag read / write operations altering cached/displayed media information.
    -
  • -
  • play_callback - tracking playback related events.
    -
  • -
  • playback_statistics_collector - collecting information about played tracks.
    -
  • -
  • playlist_callback, playlist_callback_single - tracking playlist changes (the latter tracks only active playlist changes).
    -
  • -
  • playback_queue_callback - tracking playback queue changes.
    -
  • -
  • titleformat_config_callback - tracking changes of title formatting configuration.
    -
  • -
  • ui_drop_item_callback - filtering items dropped into the UI.
    -
  • -
- -

-All of global callbacks operate only within main app thread, allowing easy cooperation with windows GUI - for an example, you perform playlist view window repainting directly from your playlist_callback implementation. -

- -

-There are restrictions on things that are legal to call from within global callbacks. For an example, you can't modify playlist from inside a playlist callback, because there are other registered callbacks tracking playlist changes that haven't been notified about the change being currently processed yet. -

- -

-IMPORTANT: You must not enter modal message loops from inside global callbacks, as those allow any unrelated code (queued messages, user input, etc.) to be executed, without being aware that a global callback is being processed. Certain global API methods such as metadb_io::load_info_multi or threaded_process::run_modal enter modal loops when called. In other words, calling tag read/write operations from within one of global callbacks is illegal and will lead to issues. Use main_thread_callback service to avoid this problem and delay execution of problematic code. -

- -
- -

Service class design guidelines (advanced)

-
- -

- This chapter describes things you should keep on your mind when designing your own service type classes. Since 99% of components will only implement existing service types rather than adding their own cross-DLL-communication protocols, you can probably skip reading this chapter. -

- -
- -

Cross-DLL safety

-
- -

- It is important that all function parameters used by virtual methods of services are cross-DLL safe (do not depend on compiler-specific or runtime-specific behaviors, so no unexpected behaviors occur when calling code is built with different compiler/runtime than callee). To achieve this, any classes passed around must be either simple objects with no structure that could possibly vary with different compilers/runtimes (i.e. make sure that any memory blocks are freed on the side that allocated them); easiest way to achieve this is to reduce all complex data objects or classes passed around to interfaces with virtual methods, with implementation details hidden from callee. For an example, use pfc::string_base& as parameter to a function that is meant to return variable-length strings. -

- -
- -

Entrypoint service efficiency

-
- -

- When designing an entrypoint service interface meant to have multiple different implementations, you should consider making it possible for all its implementations to use service_factory_single_t (i.e. no per-instance member data); by e.g. moving functionality that needs multi-instance operation to a separate service type class that is created on-demand by one of entrypoint service methods. For example: -

-
class myservice : public service_base {
-public:
-	//this method accesses per-instance member data of the implementation class
-	virtual void workerfunction(const void * p_databuffer,t_size p_buffersize) = 0;
-	//this method is used to determine which implementation can be used to process specific data stream.
-	virtual bool queryfunction(const char * p_dataformat) = 0;
- 
-	FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(myservice);
-};
-(...)
-service_ptr_t<myservice> findservice(const char * p_dataformat) {
-	service_enum_t<myservice> e; service_ptr_t<myservice> ptr;
-	//BOTTLENECK, this dynamically instantiates the service for each query.
-	while(e.next(ptr)) {
-		if (ptr->queryfunction(p_dataformat)) return ptr;
-	}
-	throw exception_io_data();
-}
-

-.. should be changed to: -

-
//no longer an entrypoint service - use myservice::instantiate to get an instance instead.
-class myservice_instance : public service_base {
-public:
-	virtual void workerfunction(const void * p_databuffer,t_size p_buffersize) = 0;
-	FB2K_MAKE_SERVICE_INTERFACE(myservice_instance,service_base);
-};
- 
-class myservice : public service_base {
-public:
-	//this method is used to determine which implementation can be used to process specific data stream.
-	virtual bool queryfunction(const char * p_dataformat) = 0;
-	virtual service_ptr_t<myservice_instance> instantiate() = 0;
-	FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(myservice);
-};
- 
-template<typename t_myservice_instance_impl>
-class myservice_impl_t : public myservice {
-public:
-	//implementation of myservice_instance must provide static bool g_queryformatfunction(const char*);
-	bool queryfunction(const char * p_dataformat) {return t_myservice_instance_impl::g_queryfunction(p_dataformat);}
-	service_ptr_t<myservice_instance> instantiate() {return new service_impl_t<t_myservice_instance_impl>();}
-};
- 
-template<typename t_myservice_instance_impl> class myservice_factory_t :
-	public service_factory_single_t<myservice_impl_t<t_myservice_instance_impl> > {};
-//usage: static myservice_factory_t<myclass> g_myclass_factory;
- 
-(...)
- 
-service_ptr_t<myservice_instance> findservice(const char * p_dataformat) {
-	service_enum_t<myservice> e; service_ptr_t<myservice> ptr;
-	//no more bottleneck, enumerated service does not perform inefficient operations when requesting an instance.
-	while(e.next(ptr)) {
-		//"inefficient" part is used only once, with implementation that actually supports what we request.
-		if (ptr->queryfunction(p_dataformat)) return ptr->instantiate();
-	}
-	throw exception_io_data();
-}
-
-
- - diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/audio_chunk.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/audio_chunk.cpp deleted file mode 100644 index f28e69a48..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/audio_chunk.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include "foobar2000.h" - -bool audio_chunk::set_data(const audio_sample * src,unsigned samples,unsigned nch,unsigned srate) -{ - bool rv = false; - unsigned size = samples * nch; - audio_sample * out = check_data_size(size); - if (out) - { - if (src) - mem_ops::copy(out,src,size); - else - mem_ops::set(out,0,size); - set_sample_count(samples); - set_channels(nch); - set_srate(srate); - rv = true; - } - else reset(); - return rv; -} - -static bool check_exclusive(unsigned val, unsigned mask) -{ - return (val&mask)!=0 && (val&mask)!=mask; -} - -//leet superfast fixedpoint->floatingpoint convertah -//somewhat big though due to excess templating - -namespace { - - template class msvc6_sucks_v2 { public: - inline static void do_fixedpoint_convert(const void * source,unsigned bps,unsigned count,audio_sample* buffer) - { - const char * src = (const char *) source; - unsigned bytes = bps>>3; - unsigned n; - T max = ((T)1)<<(bps-1); - - T negmask = - max; - - ASSUME(bytes<=sizeof(T)); - - double div = 1.0 / (double)(1<<(bps-1)); - for(n=0;n(src); - } - - if (b_swap) byte_order_helper::swap_order(&temp,bytes); - - if (!b_signed) temp ^= max; - - if (b_pad) - { - if (temp & max) temp |= negmask; - } - - if (b_pad) - src += bytes; - else - src += sizeof(T); - - - buffer[n] = (audio_sample) ( (double)temp * div ); - } - } - }; - - template class msvc6_sucks { public: - inline static void do_fixedpoint_convert(bool b_swap,bool b_signed,const void * source,unsigned bps,unsigned count,audio_sample* buffer) - { - if (sizeof(T)==1) - { - if (b_signed) - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - else - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - } - else if (b_swap) - { - if (b_signed) - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - else - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - } - else - { - if (b_signed) - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - else - { - msvc6_sucks_v2::do_fixedpoint_convert(source,bps,count,buffer); - } - } - } - }; - - -}; - - -bool audio_chunk::set_data_fixedpoint_ex(const void * source,unsigned size,unsigned srate,unsigned nch,unsigned bps,unsigned flags) -{ - assert( check_exclusive(flags,FLAG_SIGNED|FLAG_UNSIGNED) ); - assert( check_exclusive(flags,FLAG_LITTLE_ENDIAN|FLAG_BIG_ENDIAN) ); - - bool need_swap = !!(flags & FLAG_BIG_ENDIAN); - if (byte_order_helper::machine_is_big_endian()) need_swap = !need_swap; - - unsigned count = size / (bps/8); - audio_sample * buffer = check_data_size(count); - if (buffer==0) {reset();return false;} - bool b_signed = !!(flags & FLAG_SIGNED); - - switch(bps) - { - case 8: - msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - case 16: - msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - case 24: - msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - case 32: - msvc6_sucks::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; - case 40: - case 48: - case 56: - case 64: - msvc6_sucks<__int64,true>::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break; -/* - additional template would bump size while i doubt if anyone playing PCM above 32bit would care about performance gain - msvc6_sucks<__int64,false>::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer); - break;*/ - default: - //unknown size, cant convert - mem_ops::setval(buffer,0,count); - break; - } - set_sample_count(count/nch); - set_srate(srate); - set_channels(nch); - return true; -} - -bool audio_chunk::set_data_floatingpoint_ex(const void * ptr,unsigned size,unsigned srate,unsigned nch,unsigned bps,unsigned flags) -{ - assert(bps==32 || bps==64); - assert( check_exclusive(flags,FLAG_LITTLE_ENDIAN|FLAG_BIG_ENDIAN) ); - assert( ! (flags & (FLAG_SIGNED|FLAG_UNSIGNED) ) ); - - void (* p_orderfunc)(void * ptr,unsigned bytes) = (flags & FLAG_BIG_ENDIAN) ? byte_order_helper::order_be_to_native : byte_order_helper::order_le_to_native; - - unsigned bytes_per_sample = bps>>3; - - unsigned count = size / bytes_per_sample; - audio_sample * out = check_data_size(count); - if (out==0) {reset();return false;} - unsigned char temp[64/8]; - const unsigned char * src = (const unsigned char *) ptr; - while(count) - { - audio_sample val; - memcpy(temp,src,bytes_per_sample); - p_orderfunc(temp,bytes_per_sample); - if (bps==32) val = (audio_sample) *(float*)&temp; - else val = (audio_sample) *(double*)&temp; - *(out++) = val; - src += bytes_per_sample; - count--; - } - return true; -} - -#if audio_sample_size == 64 -bool audio_chunk::set_data_32(const float * src,UINT samples,UINT nch,UINT srate) -{ - unsigned size = samples * nch; - audio_sample * out = check_data_size(size); - if (out==0) {reset();return false;} - dsp_util::convert_32_to_64(src,out,size); - set_sample_count(samples); - set_channels(nch); - set_srate(srate); - return true; -} -#else -bool audio_chunk::set_data_64(const double * src,UINT samples,UINT nch,UINT srate) -{ - unsigned size = samples * nch; - audio_sample * out = check_data_size(size); - if (out==0) {reset();return false;} - dsp_util::convert_64_to_32(src,out,size); - set_sample_count(samples); - set_channels(nch); - set_srate(srate); - return true; -} -#endif - -bool audio_chunk::is_valid() -{ - unsigned nch = get_channels(); - if (nch==0 || nch>256) return false; - unsigned srate = get_srate(); - if (srate<1000 || srate>1000000) return false; - unsigned samples = get_sample_count(); - if (samples==0 || samples >= 0x80000000 / (sizeof(audio_sample) * nch) ) return false; - unsigned size = get_data_size(); - if (samples * nch > size) return false; - if (!get_data()) return false; - return true; -} - - -bool audio_chunk::pad_with_silence_ex(unsigned samples,unsigned hint_nch,unsigned hint_srate) -{ - if (is_empty()) - { - if (hint_srate && hint_nch) - { - return set_data(0,samples,hint_nch,hint_srate); - } - else return false; - } - else - { - if (hint_srate && hint_srate != get_srate()) samples = MulDiv(samples,get_srate(),hint_srate); - if (samples > get_sample_count()) - { - unsigned old_size = get_sample_count() * get_channels(); - unsigned new_size = samples * get_channels(); - audio_sample * ptr = check_data_size(new_size); - if (ptr) - { - mem_ops::set(ptr + old_size,0,new_size - old_size); - set_sample_count(samples); - return true; - } - else return false; - } - else return true; - } -} - -bool audio_chunk::pad_with_silence(unsigned samples) -{ - if (samples > get_sample_count()) - { - unsigned old_size = get_sample_count() * get_channels(); - unsigned new_size = samples * get_channels(); - audio_sample * ptr = check_data_size(new_size); - if (ptr) - { - mem_ops::set(ptr + old_size,0,new_size - old_size); - set_sample_count(samples); - return true; - } - else return false; - } - else return true; -} - -bool audio_chunk::insert_silence_fromstart(unsigned samples) -{ - unsigned old_size = get_sample_count() * get_channels(); - unsigned delta = samples * get_channels(); - unsigned new_size = old_size + delta; - audio_sample * ptr = check_data_size(new_size); - if (ptr) - { - mem_ops::move(ptr+delta,ptr,old_size); - mem_ops::set(ptr,0,delta); - set_sample_count(get_sample_count() + samples); - return true; - } - else return false; -} - -unsigned audio_chunk::skip_first_samples(unsigned samples_delta) -{ - unsigned samples_old = get_sample_count(); - if (samples_delta >= samples_old) - { - set_sample_count(0); - set_data_size(0); - return samples_old; - } - else - { - unsigned samples_new = samples_old - samples_delta; - unsigned nch = get_channels(); - audio_sample * ptr = get_data(); - mem_ops::move(ptr,ptr+nch*samples_delta,nch*samples_new); - set_sample_count(samples_new); - set_data_size(nch*samples_new); - return samples_delta; - } -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/audio_chunk.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/audio_chunk.h deleted file mode 100644 index 3d8c3e288..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/audio_chunk.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef _AUDIO_CHUNK_H_ -#define _AUDIO_CHUNK_H_ - -#define audio_sample_size 64 - -#if audio_sample_size == 32 -typedef float audio_sample; -#define audio_sample_asm dword -#elif audio_sample_size == 64 -typedef double audio_sample; -#define audio_sample_asm qword -#else -#error wrong audio_sample_size -#endif - -#define audio_sample_bytes (audio_sample_size/8) - - -//channel order same as in windows APIs - for 4ch: L/R/BL/BR, for 5.1: L/R/C/LF/BL/BR - -class NOVTABLE audio_chunk -{ -protected: - audio_chunk() {} - ~audio_chunk() {} -public: - - - virtual audio_sample * get_data()=0; - virtual const audio_sample * get_data() const = 0; - virtual unsigned get_data_size() const = 0;//buffer size in audio_samples; must be at least samples * nch; - virtual audio_sample * set_data_size(unsigned new_size)=0; - - virtual unsigned get_srate() const = 0; - virtual void set_srate(unsigned val)=0; - virtual unsigned get_channels() const = 0; - virtual void set_channels(unsigned val)=0; - - virtual unsigned get_sample_count() const = 0; - virtual void set_sample_count(unsigned val)=0; - - inline audio_sample * check_data_size(unsigned new_size) {if (new_size > get_data_size()) return set_data_size(new_size); else return get_data();} - - inline bool copy_from(const audio_chunk * src) - { - return set_data(src->get_data(),src->get_sample_count(),src->get_channels(),src->get_srate()); - } - - inline double get_duration() const - { - double rv = 0; - unsigned srate = get_srate (), samples = get_sample_count(); - if (srate>0 && samples>0) rv = (double)samples/(double)srate; - return rv; - } - - inline bool is_empty() const {return get_channels()==0 || get_srate()==0 || get_sample_count()==0;} - - bool is_valid(); - - inline unsigned get_data_length() const {return get_sample_count() * get_channels();}//actual amount of audio_samples in buffer - - inline void reset() - { - set_sample_count(0); - set_srate(0); - set_channels(0); - } - inline void reset_data() - { - reset(); - set_data_size(0); - } - - bool set_data(const audio_sample * src,unsigned samples,unsigned nch,unsigned srate);//returns false on failure (eg. memory error) - - - //helper routines for converting different input data formats - inline bool set_data_fixedpoint(const void * ptr,unsigned bytes,unsigned srate,unsigned nch,unsigned bps) - { - return set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,(bps==8 ? FLAG_UNSIGNED : FLAG_SIGNED) | flags_autoendian()); - } - - inline bool set_data_fixedpoint_unsigned(const void * ptr,unsigned bytes,unsigned srate,unsigned nch,unsigned bps) - { - return set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,FLAG_UNSIGNED | flags_autoendian()); - } - - inline bool set_data_fixedpoint_signed(const void * ptr,unsigned bytes,unsigned srate,unsigned nch,unsigned bps) - { - return set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,FLAG_SIGNED | flags_autoendian()); - } - - enum - { - FLAG_LITTLE_ENDIAN = 1, - FLAG_BIG_ENDIAN = 2, - FLAG_SIGNED = 4, - FLAG_UNSIGNED = 8, - }; - - inline static unsigned flags_autoendian() - { - return byte_order_helper::machine_is_big_endian() ? FLAG_BIG_ENDIAN : FLAG_LITTLE_ENDIAN; - } - - bool set_data_fixedpoint_ex(const void * ptr,unsigned bytes,unsigned srate,unsigned nch,unsigned bps,unsigned flags);//flags - see FLAG_* above - - bool set_data_floatingpoint_ex(const void * ptr,unsigned bytes,unsigned srate,unsigned nch,unsigned bps,unsigned flags);//signed/unsigned flags dont apply - -#if audio_sample_size == 64 - bool set_data_32(const float * src,unsigned samples,unsigned nch,unsigned srate); - inline bool set_data_64(const double * src,unsigned samples,unsigned nch,unsigned srate) {return set_data(src,samples,nch,srate);} -#else - inline bool set_data_32(const float * src,unsigned samples,unsigned nch,unsigned srate) {return set_data(src,samples,nch,srate);} - bool set_data_64(const double * src,unsigned samples,unsigned nch,unsigned srate); -#endif - - bool pad_with_silence_ex(unsigned samples,unsigned hint_nch,unsigned hint_srate); - bool pad_with_silence(unsigned samples); - bool insert_silence_fromstart(unsigned samples); - unsigned skip_first_samples(unsigned samples); -}; - -class audio_chunk_i : public audio_chunk -{ - mem_block_aligned_t m_data; - unsigned m_srate,m_nch,m_samples; -public: - audio_chunk_i() : m_srate(0), m_nch(0), m_samples(0) {} - audio_chunk_i(const audio_sample * src,unsigned samples,unsigned nch,unsigned srate) : m_srate(0), m_nch(0), m_samples(0) - {set_data(src,samples,nch,srate);} - - virtual audio_sample * get_data() {return m_data;} - virtual const audio_sample * get_data() const {return m_data;} - virtual unsigned get_data_size() const {return m_data.get_size();} - virtual audio_sample * set_data_size(unsigned new_size) {return m_data.set_size(new_size);} - - virtual unsigned get_srate() const {return m_srate;} - virtual void set_srate(unsigned val) {m_srate=val;} - virtual unsigned get_channels() const {return m_nch;} - virtual void set_channels(unsigned val) {m_nch = val;} - - virtual unsigned get_sample_count() const {return m_samples;} - virtual void set_sample_count(unsigned val) {m_samples = val;} - -}; - -struct output_chunk //used by float->pcm and output -{ - void * data; - int size;//in bytes - int srate; - int nch;//number of interleaved channels - int bps;//bits-per-sample -}; - -#endif //_AUDIO_CHUNK_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/commandline.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/commandline.cpp deleted file mode 100644 index 192547e89..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/commandline.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "foobar2000.h" - -void commandline_handler_metadb_handle::on_file(const char * url) -{ - playlist_loader_callback_i callback; - - playlist_loader::process_path_ex(url,&callback); - - { - unsigned n,m=callback.get_count(); - for(n=0;n on_token() => deletion - scenario #2: - creation => on_token() returning RESULT_PROCESSED_EXPECT_FILES => on_file(), on_file().... => on_files_done() => deletion -*/ - -template -class commandline_handler_factory : public service_factory_t {}; - - - -#endif //_FOOBAR2000_SDK_COMMANDLINE_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/component.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/component.h deleted file mode 100644 index 547986e84..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/component.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _COMPONENT_H_ -#define _COMPONENT_H_ - -#include "foobar2000.h" - -class foobar2000_client -{ -public: - enum {FOOBAR2000_CLIENT_VERSION_COMPATIBLE = 27, FOOBAR2000_CLIENT_VERSION=35}; //changes everytime global compatibility is broken - virtual int get_version() {return FOOBAR2000_CLIENT_VERSION;} - virtual service_factory_base * get_service_list() {return service_factory_base::list_get_pointer();} - - virtual void get_config(cfg_var::write_config_callback * out) - { - cfg_var::config_write_file(out); - } - - virtual void set_config(const void * data,int size) - { - cfg_var::config_read_file(data,size); - } - - virtual void reset_config() - { - //0.8: deprecated - } - - virtual void set_library_path(const char * path,const char * name); - - virtual void services_init(bool val); - -}; - -class NOVTABLE foobar2000_api -{ -public: - virtual service_base * service_enum_create(const GUID &g,int n)=0; - virtual int service_enum_get_count(const GUID &g)=0; - virtual HWND get_main_window()=0; - virtual bool assert_main_thread()=0; - virtual bool is_main_thread()=0; - virtual const char * get_profile_path()=0; -}; - -extern foobar2000_client g_client; -extern foobar2000_api * g_api; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/component_client.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/component_client.h deleted file mode 100644 index 46aa84888..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/component_client.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _COMPONENT_CLIENT_H_ -#define _COMPONENT_CLIENT_H_ - - - -#endif //_COMPONENT_CLIENT_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/components_menu.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/components_menu.h deleted file mode 100644 index 835237331..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/components_menu.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _COMPONENTS_MENU_H_ -#define _COMPONENTS_MENU_H_ - -#error deprecated, see menu_item.h - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/componentversion.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/componentversion.h deleted file mode 100644 index f56d93a8a..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/componentversion.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _COMPONENTVERSION_H_ -#define _COMPONENTVERSION_H_ - -#include "service.h" -#include "interface_helper.h" - -//reminder: all strings are UTF-8 - -class NOVTABLE componentversion : public service_base -{ -public: - virtual void get_file_name(string_base & out)=0; - virtual void get_component_name(string_base & out)=0; - virtual void get_component_version(string_base & out)=0; - virtual void get_about_message(string_base & out)=0;//about message uses "\n" for line separators - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class componentversion_i_simple : public componentversion -{ - const char * name,*version,*about; -public: - //do not derive/override - virtual void get_file_name(string_base & out) {out.set_string(service_factory_base::get_my_file_name());} - virtual void get_component_name(string_base & out) {out.set_string(name?name:"");} - virtual void get_component_version(string_base & out) {out.set_string(version?version:"");} - virtual void get_about_message(string_base & out) {out.set_string(about?about:"");} - componentversion_i_simple(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {} -}; - -class componentversion_i_copy : public componentversion -{ - string_simple name,version,about; -public: - //do not derive/override - virtual void get_file_name(string_base & out) {out.set_string(service_factory_base::get_my_file_name());} - virtual void get_component_name(string_base & out) {out.set_string(name);} - virtual void get_component_version(string_base & out) {out.set_string(version);} - virtual void get_about_message(string_base & out) {out.set_string(about);} - componentversion_i_copy(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {} -}; - - -#define DECLARE_COMPONENT_VERSION(NAME,VERSION,ABOUT) \ - static service_factory_single_transparent_p3_t g_componentversion_service(NAME,VERSION,ABOUT); - -#define DECLARE_COMPONENT_VERSION_COPY(NAME,VERSION,ABOUT) \ - static service_factory_single_transparent_p3_t g_componentversion_service(NAME,VERSION,ABOUT); - -//usage: DECLARE_COMPONENT_VERSION("blah","v1.337",0) -//about message is optional can be null -//_copy version copies strings around instead of keeping pointers (bigger but sometimes needed, eg. if strings are created as string_printf() or something inside constructor - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/config.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/config.h deleted file mode 100644 index b0d96cd17..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/config.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -#include "service.h" - -class NOVTABLE config : public service_base -{ -public: //NOTE your config class instance will get deleted BEFORE returned window is destroyed or even used - virtual HWND create(HWND parent)=0; - virtual const char * get_name()=0; - virtual const char * get_parent_name() {return 0;}//optional, retuns name of parent config item - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -template -class config_factory : public service_factory_single_t {}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/config_var.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/config_var.h deleted file mode 100644 index 365b0f1bf..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/config_var.h +++ /dev/null @@ -1,475 +0,0 @@ -#ifndef _FOOBAR2000_CONFIG_VAR_H_ -#define _FOOBAR2000_CONFIG_VAR_H_ - -#include "service.h" - -#include "interface_helper.h" - -#include "initquit.h" - -// "externally visible" config vars that can be accessed by other components - -//note: callbacks from different threads are allowed, keep your stuff mt-safe - - -class config_var; - -class config_var_callback -{ -public: - virtual void on_changed(const config_var * ptr)=0; -}; - - -class callback_list -{ - ptr_list_simple< config_var_callback > list; -public: - void add(config_var_callback * ptr) {list.add_item(ptr);} - void remove(config_var_callback * ptr) {list.remove_item(ptr);} - void call(const config_var * ptr) const - { - int n,m=list.get_count(); - for(n=0;non_changed(ptr); - } -}; - - - -class config_var : public service_base -{ -public: - class NOVTABLE write_config_callback - { - public: - virtual void write(const void * ptr,int bytes)=0; - }; - - class write_config_callback_i : public write_config_callback - { - public: - mem_block data; - write_config_callback_i() {data.set_mem_logic(mem_block::ALLOC_FAST_DONTGODOWN);} - virtual void write(const void * ptr,int bytes) {data.append(ptr,bytes);} - }; - - virtual const char * get_name() const = 0; - virtual bool is_public() const {return true;} - virtual void get_raw_data(config_var::write_config_callback * out) const = 0; - virtual void set_raw_data(const void * data,int size) = 0; - virtual void reset()=0; - virtual GUID get_type() const = 0; - virtual void add_callback(config_var_callback * ptr,bool calloninit=false)=0; - virtual void remove_callback(config_var_callback * ptr)=0; - virtual const char * get_library() {return core_api::get_my_file_name();} - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static config_var * g_find(GUID type,const char * name) - { - service_enum_t e; - config_var * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_type()==type && ptr->is_public() && !stricmp_utf8(name,ptr->get_name())) return ptr; - ptr->service_release(); - } - return 0; - } - - static void g_add_callback(GUID type,const char * name,config_var_callback * cb,bool calloninit=false) - { - config_var * ptr = g_find(type,name); - if (ptr) {ptr->add_callback(cb,calloninit);ptr->service_release();} - } - - static void g_remove_callback(GUID type,const char * name,config_var_callback * cb) - { - config_var * ptr = g_find(type,name); - if (ptr) {ptr->remove_callback(cb);ptr->service_release();} - } - -}; - -class NOVTABLE config_var_int : public config_var -{ -public: - static const GUID var_type; - inline static const GUID & get_var_type() {return var_type;} - - virtual const char * get_name() const = 0; - virtual void get_raw_data(config_var::write_config_callback * out) const = 0; - virtual void set_raw_data(const void * data,int size) = 0; - virtual void reset()=0; - virtual GUID get_type() const {return get_var_type();} - - virtual int get_value() const = 0; - virtual void set_value(int val) = 0; - - static config_var_int * g_find(const char * name) - { - return static_cast(config_var::g_find(get_var_type(),name)); - } - - static int g_get_value(const char * name) - { - int rv = 0; - config_var_int * ptr = g_find(name); - if (ptr) {rv = ptr->get_value();ptr->service_release();} - return rv; - } - - static void g_set_value(const char * name,int val) - { - config_var_int * ptr = g_find(name); - if (ptr) {ptr->set_value(val);ptr->service_release();} - } - - static void g_add_callback(const char * name,config_var_callback * cb,bool calloninit=false) - { - config_var_int * ptr = g_find(name); - if (ptr) {ptr->add_callback(cb,calloninit);ptr->service_release();} - } - - static void g_remove_callback(const char * name,config_var_callback * cb) - { - config_var_int * ptr = g_find(name); - if (ptr) {ptr->remove_callback(cb);ptr->service_release();} - } -}; - -extern const GUID config_var_struct_var_type; - -template -class NOVTABLE config_var_struct : public config_var -{ -public: - inline static const GUID & get_var_type() {return config_var_struct_var_type;} - - virtual const char * get_name() const = 0; - virtual void get_raw_data(config_var::write_config_callback * out) const = 0; - virtual void set_raw_data(const void * data,int size) = 0; - virtual void reset()=0; - virtual GUID get_type() const {return get_var_type();} - virtual unsigned get_struct_size() {return sizeof(T);} - - virtual void get_value(T & out) const = 0; - virtual void set_value(const T& src) = 0; - - static config_var_struct * g_find(const char * name) - { - config_var_struct * temp = static_cast*>(config_var::g_find(get_var_type(),name)); - assert(temp==0 || temp->get_struct_size() == sizeof(T) ); - return temp; - } - - static bool g_get_value(const char * name,T& out) - { - bool rv = false; - config_var_struct * ptr = g_find(name); - if (ptr) {ptr->get_value(out);ptr->service_release();rv=true;} - return rv; - } - - static void g_set_value(const char * name,const T& val) - { - config_var_struct * ptr = g_find(name); - if (ptr) {ptr->set_value(val);ptr->service_release();} - } - - static void g_add_callback(const char * name,config_var_callback * cb,bool calloninit=false) - { - config_var_struct * ptr = g_find(name); - if (ptr) {ptr->add_callback(cb,calloninit);ptr->service_release();} - } - - static void g_remove_callback(const char * name,config_var_callback * cb) - { - config_var_struct * ptr = g_find(name); - if (ptr) {ptr->remove_callback(cb);ptr->service_release();} - } -}; - -template -class config_var_struct_i : public config_var_struct -{ - string_simple name; - T value,def; - mutable critical_section sync; - callback_list callbacks; -public: - virtual const char * get_name() const {return name;} - virtual void get_raw_data(config_var::write_config_callback * out) const {insync(sync);out->write(&value,sizeof(value));} - virtual void set_raw_data(const void * data,int size) - { - insync(sync); - if (size==sizeof(value)) value = *(T*)data; - callbacks.call(this); - } - virtual void reset() - { - insync(sync); - value = def; - callbacks.call(this); - } - - virtual void add_callback(config_var_callback * ptr,bool calloninit=false) - { - insync(sync); - callbacks.add(ptr); - if (calloninit) ptr->on_changed(this); - } - virtual void remove_callback(config_var_callback * ptr) - { - insync(sync); - callbacks.remove(ptr); - } - - virtual void get_value(T & out) const {insync(sync);out = value;} - virtual void set_value(const T & p_val) - { - insync(sync); - if (memcmp(&value,&p_val,sizeof(value))) - { - value = p_val; - callbacks.call(this); - } - } - - config_var_struct_i(const char * p_name,T p_value) : name(p_name), value(p_value), def(p_value) {} - - void operator=(const T& v) {set_value(v);} - inline operator T() const {T temp;get_value(temp);return temp;} -}; - - -class NOVTABLE config_var_string : public config_var -{ -public: - static const GUID var_type; - inline static const GUID & get_var_type() {return var_type;} - - virtual const char * get_name() const = 0; - virtual void get_raw_data(config_var::write_config_callback * out) const = 0; - virtual void set_raw_data(const void * data,int size) = 0; - virtual void reset()=0; - virtual GUID get_type() const {return get_var_type();} - - virtual void get_value(string_base & out) const = 0; - virtual void set_value(const char * val) = 0; - - static config_var_string * g_find(const char * name) - { - return static_cast(config_var::g_find(get_var_type(),name)); - } - - static void g_get_value(const char * name,string_base & out) - { - config_var_string * ptr = g_find(name); - if (ptr) {ptr->get_value(out);ptr->service_release();} - } - - static void g_set_value(const char * name,const char * val) - { - config_var_string * ptr = g_find(name); - if (ptr) {ptr->set_value(val);ptr->service_release();} - } - - static void g_add_callback(const char * name,config_var_callback * cb,bool calloninit=false) - { - config_var_string * ptr = g_find(name); - if (ptr) {ptr->add_callback(cb,calloninit);ptr->service_release();} - } - - static void g_remove_callback(const char * name,config_var_callback * cb) - { - config_var_string * ptr = g_find(name); - if (ptr) {ptr->remove_callback(cb);ptr->service_release();} - } -}; - -class config_var_int_i : public config_var_int -{ - string_simple name; - int value,def; - mutable critical_section sync; - callback_list callbacks; -public: - virtual const char * get_name() const {return name;} - virtual void get_raw_data(config_var::write_config_callback * out) const {insync(sync);out->write(&value,sizeof(int));} - virtual void set_raw_data(const void * data,int size)//bah not endian safe - { - insync(sync); - if (size==sizeof(int)) value = *(int*)data; - callbacks.call(this); - } - virtual void reset() - { - insync(sync); - value = def; - callbacks.call(this); - } - - virtual void add_callback(config_var_callback * ptr,bool calloninit=false) - { - insync(sync); - callbacks.add(ptr); - if (calloninit) ptr->on_changed(this); - } - virtual void remove_callback(config_var_callback * ptr) - { - insync(sync); - callbacks.remove(ptr); - } - - virtual int get_value() const {insync(sync);return value;} - virtual void set_value(int p_val) - { - insync(sync); - if (value!=p_val) - { - value = p_val; - callbacks.call(this); - } - } - - config_var_int_i(const char * p_name,int p_value) : name(p_name), value(p_value), def(p_value) {} - - int operator=(int v) {set_value(v);return v;} - operator int() const {return get_value();} -}; - -class config_var_string_i : public config_var_string -{ - string_simple name,value,def; - mutable critical_section sync; - callback_list callbacks; -public: - virtual const char * get_name() const {return name;} - virtual void get_raw_data(config_var::write_config_callback * out) const - { - insync(sync); - out->write(value.get_ptr(),strlen(value)); - } - virtual void set_raw_data(const void * data,int size) - { - insync(sync); - value.set_string_n((const char*)data,size); - callbacks.call(this); - } - virtual void reset() - { - insync(sync); - value = def; - callbacks.call(this); - } - - virtual GUID get_type() const {return get_var_type();} - - virtual void get_value(string_base & out) const - { - insync(sync); - out.set_string(value); - } - - virtual void set_value(const char * val) - { - insync(sync); - if (strcmp(value,val)) - { - value.set_string(val); - callbacks.call(this); - } - } - - virtual void add_callback(config_var_callback * ptr,bool calloninit=false) - { - insync(sync); - callbacks.add(ptr); - if (calloninit) ptr->on_changed(this); - } - virtual void remove_callback(config_var_callback * ptr) - { - insync(sync); - callbacks.remove(ptr); - } - config_var_string_i(const char * p_name,const char * p_value) : name(p_name), value(p_value), def(p_value) {} -}; - -//only static creation! -template -class config_var_callback_autoreg : public config_var_callback -{ - class callback_autoreg_initquit : public initquit_autoreg - { - config_var_callback_autoreg * cb; - public: - callback_autoreg_initquit(config_var_callback_autoreg * p_cb) {cb = p_cb;} - virtual void on_init() {cb->on_init();} - virtual void on_quit() {cb->on_quit();} - }; - - vartype * var; - string_simple varname; - virtual void on_changed(const config_var * ptr) {on_changed(static_cast(ptr));} - callback_autoreg_initquit * p_initquit; - bool calloninit; -protected: - virtual void on_changed(const vartype * ptr)=0; -public: - void on_init() - { - if (!var && !varname.is_empty()) - var = vartype::g_find(varname); - if (var) var->add_callback(this,calloninit); - } - void on_quit() - { - if (var) var->remove_callback(this); - } - config_var_callback_autoreg(vartype * p_var,bool p_calloninit = false) - { - calloninit = p_calloninit; - var = p_var; - p_initquit = new callback_autoreg_initquit(this); - } - config_var_callback_autoreg(const char * name,bool p_calloninit = false) - { - calloninit = p_calloninit; - var = 0; - varname = name; - p_initquit = new callback_autoreg_initquit(this); - } - ~config_var_callback_autoreg() - { - delete p_initquit; - } -}; - -template -class config_var_callback_simple : public config_var_callback_autoreg -{ - void (*func)(const vartype *); - virtual void on_changed(const vartype * ptr) {func(ptr);} -public: - config_var_callback_simple(vartype * p_var,void (*p_func)(const vartype *),bool p_calloninit = false) - : config_var_callback_autoreg(p_var,p_calloninit) {func = p_func;} - - config_var_callback_simple(const char * name,void (*p_func)(const vartype *),bool p_calloninit = false) - : config_var_callback_autoreg(name,p_calloninit) {func = p_func;} -}; - -#define DECLARE_CONFIG_VAR_INT(VARNAME,NAME,VALUE) \ - static service_factory_single_transparent_p2_t VARNAME(NAME,VALUE); - - -#define DECLARE_CONFIG_VAR_STRING(VARNAME,NAME,VALUE) \ - static service_factory_single_transparent_p2_t VARNAME(NAME,VALUE); - -#define DECLARE_CONFIG_VAR_STRUCT(TYPE,VARNAME,NAME,VALUE) \ - static service_factory_single_transparent_p2_t,const char*,TYPE> VARNAME(NAME,VALUE); - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/console.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/console.cpp deleted file mode 100644 index a9b1e3c80..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/console.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "foobar2000.h" - -bool console::present() -{ - bool rv = false; - console * ptr = service_enum_create_t(console,0); - if (ptr) - { - rv = true; - ptr->service_release(); - } - return rv; -} - -void console::popup() -{ - console * ptr = service_enum_create_t(console,0); - if (ptr) - { - ptr->_popup(); - ptr->service_release(); - } -} - -void console::beep() -{ - console * ptr = service_enum_create_t(console,0); - if (ptr) - { - ptr->_beep(); - ptr->service_release(); - } -} - -void console::output(int severity,const char * message,const char * source) -{ - console * ptr = service_enum_create_t(console,0); - if (ptr) - { - ptr->_output(severity,message,source); - ptr->service_release(); - } -} - -void console::output(int severity,const char * message) -{ - output(severity,message,core_api::get_my_file_name()); -} - -void console::info_location(const class playable_location * src) -{ - const char * path = src->get_path(); - int number = src->get_subsong_index(); - info(uStringPrintf("location: \"%s\" (%i)",path,number)); -} - -void console::info_location(class metadb_handle * src) -{ - info_location(src->handle_get_location()); -} - -void console::info_location(const class file_info * src) -{ - info_location(src->get_location()); -} - -void console::info_full(const class file_info * src) -{ - info_location(src); - string8_fastalloc temp; - unsigned n,m; - m = src->meta_get_count(); - info("meta:"); - for(n=0;nmeta_enum_name(n); - temp += "="; - temp += src->meta_enum_value(n); - info(temp); - } - info(temp); - m = src->info_get_count(); - info("info:"); - for(n=0;ninfo_enum_name(n); - temp += "="; - temp += src->info_enum_value(n); - info(temp); - } - info(temp); -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/console.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/console.h deleted file mode 100644 index 279c23b6b..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/console.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _CONSOLE_H_ -#define _CONSOLE_H_ - -#include "service.h" - -//for sending text (errors etc) to console component -//strings are all utf-8 - -class NOVTABLE console : public service_base -{ -protected: - virtual void _output(int severity,const char * source,const char * message)=0; - virtual void _popup()=0; - virtual void _beep()=0; -public: - enum { - SEVERITY_INFO = 1, - SEVERITY_WARNING = 2, - SEVERITY_CRITICAL = 3, - }; - - static void output(int severity,const char * message,const char * source); - static void output(int severity,const char * message); - static void info(const char * message) {output(SEVERITY_INFO,message);} - static void warning(const char * message) {output(SEVERITY_WARNING,message);} - static void error(const char * message) {output(SEVERITY_CRITICAL,message);} - static bool present();//returns if console component is present - static void popup(); - static void beep(); - static void info_location(const class playable_location * src); - static void info_location(class metadb_handle * src); - static void info_location(const class file_info * src); - static void info_full(const class file_info * src); - - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - //usage: console::warning("blah warning !"); -}; - -//all console methods are multi-thread safe, you can call them from any context - -#define __crash_to_messagebox(x) __except(uMessageBox(0,string_print_crash(GetExceptionInformation(),x),0,0),1) -#define __crash_to_console __except(console::error(string_print_crash(GetExceptionInformation())),1) -#define __crash_to_console_ex(x) __except(console::error(string_print_crash(GetExceptionInformation(),x)),1) -/* -usage -__try { - blah(); -} __crash_to_console_ex("blah()") -{ - //might want to print additional info about what caused the crash here -} - -*/ - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/contextmenu.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/contextmenu.h deleted file mode 100644 index cfc068aec..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/contextmenu.h +++ /dev/null @@ -1 +0,0 @@ -#error DEPRECATED diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/core_api.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/core_api.h deleted file mode 100644 index 00a485402..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/core_api.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _CORE_API_H_ -#define _CORE_API_H_ - -#include "../../pfc/pfc.h" - -namespace core_api -{ - HINSTANCE get_my_instance(); - const char * get_my_file_name();// eg. "foo_asdf" for foo_asdf.dll - const char * get_my_full_path();//eg. file://c:\blah\foobar2000\foo_asdf.dll - HWND get_main_window(); - bool are_services_available(); - bool assert_main_thread(); - bool is_main_thread(); - const char * get_profile_path();//eg. "c:\documents_and_settings\username\blah\foobar2000\" -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/coreversion.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/coreversion.h deleted file mode 100644 index e10bbf093..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/coreversion.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _COREVERSION_H_ -#define _COREVERSION_H_ - -#include "service.h" - -class core_version_info : public service_base -{ -private: - virtual const char * _get_version_string()=0; -public: - static const char * get_version_string() - { - const char * ret = ""; - core_version_info * ptr = service_enum_create_t(core_version_info,0); - if (ptr) - { - ret = ptr->_get_version_string(); - ptr->service_release(); - } - return ret; - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - -}; - -#endif //_COREVERSION_H_ diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/cvt_float_to_linear.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/cvt_float_to_linear.h deleted file mode 100644 index 151b7e3de..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/cvt_float_to_linear.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _CVT_FLOAT_TO_LINEAR_H_ -#define _CVT_FLOAT_TO_LINEAR_H_ - -#include "service.h" -#include "audio_chunk.h" - -//use this for converting floatingpoint -> linear PCM, one implementation in core, do not override -class NOVTABLE cvt_float_to_linear : public service_base -{ -public: - virtual int run(const audio_chunk * chunk,output_chunk * out_chunk,UINT out_bps,UINT use_dither,UINT use_pad=0)=0; - //return 1 on success, 0 on failure (eg. unsupported bps) - //use_pad = bps to pad to, 0 for auto - - //if you want to flush on seek or between tracks or whatever, just service_release() and recreate - - static cvt_float_to_linear * get()//helper - { - return service_enum_create_t(cvt_float_to_linear,0); - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - -}; - -/* - -Notes on output data format. - -Following win32 conventions, out_chunk will point to buffer containing signed integers of specified size (physically always aligned to 8bits, actual resolution might be smaller according to passed params). -EXception, if output format is 8bit, values in the buffer are unsigned (just like everywhere in win32). -If out_bps isn't a multiply of 8, it will be used as conversion resolution, but results will be padded to multiply of 8-bit (and out_chunk's bps member will be set to padded bps). -out_chunk pointers are maintained by cvt_float_to_linear object, and become invalid after releasing the object or calling run() again. -*/ - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/diskwriter.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/diskwriter.cpp deleted file mode 100644 index 99420b989..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/diskwriter.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "foobar2000.h" - - -diskwriter * diskwriter::instantiate(const GUID & guid) -{ - service_enum_t e; - diskwriter * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_guid() == guid) return ptr; - ptr->service_release(); - } - return 0; -} - -bool diskwriter::instantiate_test(const GUID & guid) -{ - service_enum_t e; - diskwriter * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - bool found = (ptr->get_guid() == guid) ? true : false; - ptr->service_release(); - if (found) return true; - } - return false; -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/diskwriter.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/diskwriter.h deleted file mode 100644 index 3ed8d6d24..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/diskwriter.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef _DISKWRITER_H_ -#define _DISKWRITER_H_ - -#include "service.h" -#include "interface_helper.h" -#include "audio_chunk.h" -#include "file_info.h" - -//one instance of object will be called *only* with one output file -class NOVTABLE diskwriter : public service_base -{ -public: - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - virtual void get_name(string_base & out)=0;//name of your diskwriter service. never supposed to change - virtual bool get_extension(string_base & out)=0;//return false if you don't actually write files; result is allowed to depend on preset - - virtual bool open(const char * out_path,unsigned expected_sample_rate,unsigned expected_bps,double expected_length,bool should_dither)=0; - //expected_sample_rate may be null in rare cases, rely on it only as much as you must - //expected_sample_rate/expected_bps are pulled from first file on to-encode list (there may be more), if you actually need them and start getting chunks with different specs, return error - //expected_length is only as reliable as inputs reporting length, may not be strictly accurate - - virtual bool on_source_track(metadb_handle * ptr) {return true;}//return false to abort - - virtual bool process_samples(const audio_chunk * src)=0;//return true on success, false on failure - - virtual void flush()=0; - //close output file etc - - virtual GUID get_guid()=0;//GUID of your diskwriter subclass, for storing config - - virtual void preset_set_data(const void * ptr,unsigned bytes)=0; - virtual void preset_get_data(cfg_var::write_config_callback * out)=0; - virtual bool preset_configurable()=0;//return if you support config dialog or not - virtual bool preset_configure(HWND parent)=0;//return false if user aborted the operation - - virtual unsigned preset_default_get_count()=0; - virtual void preset_default_enumerate(unsigned index,cfg_var::write_config_callback * out)=0; - virtual bool preset_get_description(string_base & out)=0; - - - static diskwriter * instantiate(const GUID & guid); - static bool instantiate_test(const GUID & guid); -}; - -class NOVTABLE diskwriter_presetless : public diskwriter //helper, preset-less -{ -public: - virtual void preset_set_data(const void * ptr,unsigned bytes) {} - virtual void preset_get_data(cfg_var::write_config_callback * out) {} - virtual bool preset_configurable() {return false;} - virtual bool preset_configure(HWND parent) {return false;} - - - virtual unsigned preset_default_get_count() {return 1;} - virtual void preset_default_enumerate(unsigned index,cfg_var::write_config_callback * out) {} - virtual bool preset_get_description(string_base & out) {return false;} - -}; - - -template -class diskwriter_factory : public service_factory_t {}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp.cpp deleted file mode 100644 index 937b2e148..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp.cpp +++ /dev/null @@ -1,316 +0,0 @@ -#include "foobar2000.h" -#include - -#if defined(_MSC_VER) && !defined(_DEBUG) && defined(_M_IX86) -#define DSP_HAVE_ASM -#endif - -GUID dsp::guid_from_name(const char * name) -{ - service_enum_t e; - dsp * ptr; - for(ptr=e.first();ptr;ptr = e.next()) - { - if (!stricmp_utf8(ptr->get_name(),name)) - { - GUID g = ptr->get_guid(); - ptr->service_release(); - return g; - } - ptr->service_release(); - } - return mem_ops::make_null_item(); -} - -const char * dsp::name_from_guid(GUID g) -{ - service_enum_t e; - dsp * ptr; - for(ptr=e.first();ptr;ptr = e.next()) - { - if (ptr->get_guid()==g) - { - const char * name = ptr->get_name(); - ptr->service_release(); - return name; - } - ptr->service_release(); - } - return 0; -} - -dsp * dsp::instance_from_guid(GUID g) -{ - service_enum_t e; - dsp * ptr; - for(ptr=e.first();ptr;ptr = e.next()) - { - if (ptr->get_guid()==g) return ptr; - ptr->service_release(); - } - return 0; -} - -#ifndef DSP_HAVE_ASM -void dsp_util::scale(audio_sample * ptr,double scale,unsigned count) -{ - for(;count;count--) - { - (*ptr) = (audio_sample)((*ptr) * scale); - ptr++; - } -} -#else - -__declspec(naked) void dsp_util::scale(audio_sample * ptr,double scale,unsigned count) -{ - _asm - {//ptr: [esp+4], scale: [esp+8], count: [esp+16] - mov ecx,[esp+16] - mov edx,[esp+4] - fld qword ptr [esp+8] - mov eax,ecx - shr ecx,1 - jz l12 -l1: - fld audio_sample_asm ptr [edx] - fld audio_sample_asm ptr [edx+audio_sample_bytes] - fmul st,st(2) - fxch - dec ecx - fmul st,st(2) - fstp audio_sample_asm ptr [edx] - fstp audio_sample_asm ptr [edx+audio_sample_bytes] - lea edx,[edx+audio_sample_bytes*2] - jnz l1 -l12: - test eax,1 - jz l2 - fld audio_sample_asm ptr [edx] - fmul st,st(1) - fstp audio_sample_asm ptr [edx] -l2: - fstp st - ret - } -} -#endif - -void dsp_util::kill_denormal_32(float * fptr,unsigned count) -{ - DWORD * ptr = reinterpret_cast(fptr); - for(;count;count--) - { - DWORD t = *ptr; - if ((t & 0x007FFFFF) && !(t & 0x7F800000)) *ptr=0; - ptr++; - } -} - -void dsp_util::kill_denormal_64(double * fptr,unsigned count) -{ - unsigned __int64 * ptr = reinterpret_cast(fptr); - for(;count;count--) - { - unsigned __int64 t = *ptr; - if ((t & 0x000FFFFFFFFFFFFF) && !(t & 0x7FF0000000000000)) *ptr=0; - ptr++; - } -} - - -unsigned dsp_chunk_list_i::get_count() const {return data.get_count();} - -audio_chunk * dsp_chunk_list_i::get_item(unsigned n) const {return n>=0 && n<(unsigned)data.get_count() ? data[n] : 0;} - -void dsp_chunk_list_i::remove_by_idx(unsigned idx) -{ - if (idx>=0 && idx<(unsigned)data.get_count()) - recycled.add_item(data.remove_by_idx(idx)); -} - -void dsp_chunk_list_i::remove_mask(const bit_array & mask) -{ - unsigned n, m = data.get_count(); - for(n=0;nmax) idx = max; - audio_chunk_i * ret = 0; - if (recycled.get_count()>0) - { - unsigned best; - if (hint_size>0) - { - best = 0; - unsigned best_found = recycled[0]->get_data_size(), n, total = recycled.get_count(); - for(n=1;nget_data_size(); - int delta_old = abs((int)best_found - (int)hint_size), delta_new = abs((int)size - (int)hint_size); - if (delta_new < delta_old) - { - best_found = size; - best = n; - } - } - } - else best = recycled.get_count()-1; - - ret = recycled.remove_by_idx(best); - ret->set_sample_count(0); - ret->set_channels(0); - ret->set_srate(0); - } - else ret = new audio_chunk_i; - if (idx==max) data.add_item(ret); - else data.insert_item(ret,idx); - return ret; -} - -dsp_chunk_list_i::~dsp_chunk_list_i() {data.delete_all();recycled.delete_all();} - -void dsp_chunk_list::remove_bad_chunks() -{ - bool blah = false; - unsigned idx; - for(idx=0;idxis_valid()) - { - chunk->reset(); - remove_by_idx(idx); - blah = true; - } - else idx++; - } - if (blah) console::error("one or more bad chunks removed from dsp chunk list"); -} - -__int64 dsp_util::duration_samples_from_time(double time,unsigned srate) -{ - return (__int64)floor((double)srate * time + 0.5); -} - - -#ifdef DSP_HAVE_ASM - -__declspec(naked) void __fastcall dsp_util::convert_32_to_64(const float * src,double * dest,unsigned count) -{ - _asm//src: ecx, dest: edx, count: eax - { - mov eax,dword ptr [esp+4] - shr eax,2 - jz l2 -l1: fld dword ptr [ecx] - fld dword ptr [ecx+4] - fstp qword ptr [edx+8] - fstp qword ptr [edx] - dec eax - fld dword ptr [ecx+8] - fld dword ptr [ecx+12] - fstp qword ptr [edx+24] - fstp qword ptr [edx+16] - lea ecx,[ecx+16] - lea edx,[edx+32] - jnz l1 -l2: mov eax,dword ptr [esp+4] - and eax,3 - jz l4 -l3: fld dword ptr [ecx] - dec eax - fstp qword ptr [edx] - lea ecx,[ecx+4] - lea edx,[edx+8] - jnz l3 -l4: ret 4 - } -} - -__declspec(naked) void __fastcall dsp_util::convert_64_to_32(const double * src,float * dest,unsigned count) -{ - _asm//src: ecx, dest: edx, count: eax - { - mov eax,dword ptr [esp+4] - shr eax,2 - jz l2 -l1: fld qword ptr [ecx] - fld qword ptr [ecx+8] - fstp dword ptr [edx+4] - fstp dword ptr [edx] - dec eax - fld qword ptr [ecx+16] - fld qword ptr [ecx+24] - fstp dword ptr [edx+12] - fstp dword ptr [edx+8] - lea ecx,[ecx+32] - lea edx,[edx+16] - jnz l1 -l2: mov eax,dword ptr [esp+4] - and eax,3 - jz l4 -l3: fld qword ptr [ecx] - dec eax - fstp dword ptr [edx] - lea ecx,[ecx+8] - lea edx,[edx+4] - jnz l3 -l4: ret 4 - } -} - -#else - -void __fastcall dsp_util::convert_32_to_64(const float * src,double * dest,unsigned count) -{ - for(;count;count--) - *(dest++) = (double)*(src++); -} - -void __fastcall dsp_util::convert_64_to_32(const double * src,float * dest,unsigned count) -{ - for(;count;count--) - *(dest++) = (float)*(src++); -} - -#endif - - -void dsp::get_config(cfg_var::write_config_callback * out) -{ - dsp_v2 * this_v2 = service_query_t(dsp_v2,this); - if (this_v2) - { - this_v2->get_config(out); - this_v2->service_release(); - } -} -void dsp::set_config(const void * src,unsigned bytes) -{ - dsp_v2 * this_v2 = service_query_t(dsp_v2,this); - if (this_v2) - { - this_v2->set_config(src,bytes); - this_v2->service_release(); - } -} -bool dsp::popup_config(HWND parent) -{ - bool rv = false; - dsp_v2 * this_v2 = service_query_t(dsp_v2,this); - if (this_v2) - { - rv = this_v2->popup_config(parent); - this_v2->service_release(); - } - return rv; -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp.h deleted file mode 100644 index d96cdeca0..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef _DSP_H_ -#define _DSP_H_ - -#include "service.h" -#include "audio_chunk.h" -#include "interface_helper.h" - -namespace dsp_util -{ - __int64 duration_samples_from_time(double time,unsigned srate); - - void kill_denormal_32(float * ptr,unsigned count); - void kill_denormal_64(double * ptr,unsigned count); - void scale(audio_sample * ptr,double scale,unsigned count); - inline void kill_denormal(audio_sample * ptr,unsigned count) - { -#if audio_sample_size == 32 - kill_denormal_32(ptr,count); -#else - kill_denormal_64(ptr,count); -#endif - } - inline void scale_chunk(audio_chunk * ptr,double scale) {dsp_util::scale(ptr->get_data(),scale,ptr->get_data_length());} - - void __fastcall convert_32_to_64(const float * src,double * dest,unsigned count); - void __fastcall convert_64_to_32(const double * src,float * dest,unsigned count); -}; - -class NOVTABLE dsp_chunk_list//interface (cross-dll safe) -{ -public: - virtual unsigned get_count() const = 0; - virtual audio_chunk * get_item(unsigned n) const = 0; - virtual void remove_by_idx(unsigned idx) = 0; - virtual void remove_mask(const bit_array & mask) = 0; - virtual audio_chunk * insert_item(unsigned idx,unsigned hint_size=0) = 0; - - audio_chunk * add_item(unsigned hint_size=0) {return insert_item(get_count(),hint_size);} - - void remove_all() {remove_mask(bit_array_true());} - - double get_duration() - { - double rv = 0; - unsigned n,m = get_count(); - for(n=0;nget_duration(); - return rv; - } - - void add_chunk(const audio_chunk * chunk) - { - audio_chunk * dst = insert_item(get_count(),chunk->get_data_length()); - if (dst) dst->copy_from(chunk); - } - - void remove_bad_chunks(); -}; - -class dsp_chunk_list_i : public dsp_chunk_list//implementation -{ - ptr_list_simple data,recycled; -public: - virtual unsigned get_count() const; - virtual audio_chunk * get_item(unsigned n) const; - virtual void remove_by_idx(unsigned idx); - virtual void remove_mask(const bit_array & mask); - virtual audio_chunk * insert_item(unsigned idx,unsigned hint_size=0); - ~dsp_chunk_list_i(); -}; - -class NOVTABLE dsp : public service_base -{ -public: - enum - { - END_OF_TRACK = 1, //flush whatever you need to when tracks change - FLUSH = 2 //flush everything - }; - - virtual GUID get_guid()=0; - virtual const char * get_name()=0; - virtual void run(dsp_chunk_list * list,class metadb_handle * cur_file,int flags)=0;//int flags <= see flags above - //cur_file is OPTIONAL and may be null - virtual void flush() {}//after seek etc - virtual double get_latency() {return 0;}//amount of data buffered (in seconds) - virtual int need_track_change_mark() {return 0;}//return 1 if you need to know exact track change point (eg. for crossfading, removing silence), will force-flush any DSPs placed before you so when you get END_OF_TRACK, chunks you get contain last samples of the track; will often break regular gapless playback so don't use it unless you have reasons to - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static GUID guid_from_name(const char * name);//may fail if DSP isn't present (eg. dll got removed) - static const char * name_from_guid(GUID g);//may fail if DSP isn't present (eg. dll got removed) - static dsp * instance_from_guid(GUID g);//may fail if DSP isn't present (eg. dll got removed) - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - void get_config(cfg_var::write_config_callback * out); - void set_config(const void * src,unsigned bytes); - bool popup_config(HWND parent); - -}; - -class NOVTABLE dsp_v2 : public dsp -{ -public: - virtual void config_get(cfg_var::write_config_callback * out) {}; - virtual void config_set(const void * src,unsigned bytes) {}; - virtual bool config_popup(HWND parent) {return false;};//return false if you don't support config dialog - virtual bool config_supported()=0; - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return dsp::service_query(guid); - } - -}; - -template -class dsp_i_base_t : public T -{ -private: - dsp_chunk_list * list; - unsigned chunk_ptr; - metadb_handle * cur_file; - virtual void run(dsp_chunk_list * p_list,class metadb_handle * p_cur_file,int flags); -protected: - inline metadb_handle * get_cur_file() {return cur_file;}// call only from on_chunk / on_endoftrack (on_endoftrack will give info on track being finished); may return null !! - dsp_i_base_t() {list = 0;cur_file=0;chunk_ptr=0;} - audio_chunk * insert_chunk(unsigned hint_size = 0) //call only from on_endoftrack / on_endofplayback / on_chunk - {//hint_size - optional, amout of buffer space you want to use - return list ? list->insert_item(chunk_ptr++,hint_size) : 0; - } - //override these - virtual void on_endoftrack()//use insert_chunk() if you have data you want to dump - { - } - virtual void on_endofplayback() - {//use insert_chunk() if you have data you want to dump - - } - virtual bool on_chunk(audio_chunk * chunk) - {//return true if your chunk, possibly modified needs to be put back into chain, false if you want it removed - //use insert_chunk() if you want to insert pending data before current chunk - return true; - } - -public: - virtual GUID get_guid()=0; - virtual const char * get_name()=0; - - virtual void flush() {}//after seek etc - virtual double get_latency() {return 0;}//amount of data buffered (in seconds) - virtual int need_track_change_mark() {return 0;}//return 1 if you need to know exact track change point (eg. for crossfading, removing silence), will force-flush any DSPs placed before you so when you get END_OF_TRACK, chunks you get contain last samples of the track; will often break regular gapless playback so don't use it unless you have reasons to - -}; - -template -void dsp_i_base_t::run(dsp_chunk_list * p_list,class metadb_handle * p_cur_file,int flags) -{ - list = p_list; - cur_file = p_cur_file; - for(chunk_ptr = 0;chunk_ptrget_count();chunk_ptr++) - { - audio_chunk * c = list->get_item(chunk_ptr); - if (c->is_empty() || !on_chunk(c)) - list->remove_by_idx(chunk_ptr--); - } - if (flags & FLUSH) - on_endofplayback(); - else if (flags & END_OF_TRACK) - on_endoftrack(); - - list = 0; - cur_file = 0; -} - - -class dsp_i_base : public dsp_i_base_t {}; - -template -class dsp_factory : public service_factory_t {}; - - -#include "dsp_manager.h" - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp_manager.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp_manager.h deleted file mode 100644 index b85e9b9cf..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/dsp_manager.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _DSP_MANAGER_H_ -#define _DSP_MANAGER_H_ - -#include "dsp.h" - -//use this to run user-configured DSPs on your data stream -//one implementation in main exe, dont override -class NOVTABLE dsp_manager : public service_base -{ -public: - virtual double run(dsp_chunk_list * list,class metadb_handle * cur_file,int eof)=0; - virtual void flush(); - - virtual void set_chain(int b_use_custom,unsigned int count,const GUID * list)=0; - //user settings from core config will be used when b_use_custom is zero, custom DSP list specified by count/list params will be used when non-zero - //user settings are used by default if you don't call set_chain() - - class NOVTABLE get_default_chain_callback - { - public: - virtual void on_list(unsigned int num,const GUID * ptr)=0; - }; - - class get_default_chain_callback_i : public get_default_chain_callback - { - mem_block_t & data; - public: - virtual void on_list(unsigned int num,const GUID * ptr) - { - data.set_size(num); - data.copy(ptr,num); - } - get_default_chain_callback_i(mem_block_t & param) : data(param) {} - }; - - //use this to get user's DSP config from core preferences - virtual void get_default_chain(get_default_chain_callback * cb)=0; - - void get_default_chain(mem_block_t & dest)//helper - { - get_default_chain(&get_default_chain_callback_i(dest)); - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static dsp_manager* create() {return service_enum_create_t(dsp_manager,0);} -}; - - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info.cpp deleted file mode 100644 index d498b1e46..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info.cpp +++ /dev/null @@ -1,221 +0,0 @@ -#include "foobar2000.h" -#include -#include -#include - -void file_info::copy(const file_info * src) -{ - meta_remove_all(); - info_remove_all(); - set_location(src->get_location()); - set_length(src->get_length()); - int n; - for(n=0;nmeta_get_count();n++) - meta_add(src->meta_enum_name(n),src->meta_enum_value(n)); - for(n=0;ninfo_get_count();n++) - info_set(src->info_enum_name(n),src->info_enum_value(n)); -} - -void file_info::info_set_int(const char * name,__int64 value) -{ - assert(is_valid_utf8(name)); - char temp[32]; - _i64toa(value,temp,10); - info_set(name,temp); -} - -void file_info::info_set_float(const char * name,double value,unsigned precision,bool force_sign,const char * unit) -{ - assert(is_valid_utf8(name)); - assert(unit==0 || strlen(unit) <= 64); - char temp[128]; - pfc_float_to_string(temp,value,precision,force_sign); - if (unit) - { - strcat(temp," "); - strcat(temp,unit); - } - info_set(name,temp); -} - -void file_info::info_set_replaygain_track_gain(double value) -{ - info_set_float("replaygain_track_gain",value,2,true,"dB"); -} - -void file_info::info_set_replaygain_album_gain(double value) -{ - info_set_float("replaygain_album_gain",value,2,true,"dB"); -} - -void file_info::info_set_replaygain_track_peak(double value) -{ - info_set_float("replaygain_track_peak",value,6,false); -} - -void file_info::info_set_replaygain_album_peak(double value) -{ - info_set_float("replaygain_album_peak",value,6,false); -} - - -int file_info::info_get_idx(const char * name) const -{ - assert(is_valid_utf8(name)); - int n,m=info_get_count(); - for(n=0;n0 && len>0) - { - ret = dsp_util::duration_samples_from_time(len,(unsigned)srate); - } - return ret; -} - - - - - -void file_info::meta_add_wide(const WCHAR * name,const WCHAR* value) -{//unicode (UTF-16) version - meta_add(string_utf8_from_wide(name),string_utf8_from_wide(value)); -} - -void file_info::meta_add_ansi(const char * name,const char * value) -{//ANSI version - meta_add(string_utf8_from_ansi(name),string_utf8_from_ansi(value)); -} - -void file_info::meta_set_wide(const WCHAR * name,const WCHAR* value) -{//widechar version - meta_set(string_utf8_from_wide(name),string_utf8_from_wide(value)); -} - -void file_info::meta_set_ansi(const char * name,const char * value) -{//ANSI version - meta_set(string_utf8_from_ansi(name),string_utf8_from_ansi(value)); -} - - -void file_info::meta_add_n(const char * name,int name_len,const char * value,int value_len) -{ - meta_add(string_simple(name,name_len),string_simple(value,value_len)); -} - -void file_info::meta_remove_field(const char * name)//removes ALL fields of given name -{ - assert(is_valid_utf8(name)); - int n; - for(n=meta_get_count()-1;n>=0;n--) - { - if (!stricmp_utf8(meta_enum_name(n),name)) - meta_remove(n); - } - -} - -void file_info::meta_set(const char * name,const char * value) //deletes all fields of given name (if any), then adds new one -{ - assert(is_valid_utf8(name)); - assert(is_valid_utf8(value)); - meta_remove_field(name); - meta_add(name,value); -} - -const char * file_info::meta_get(const char * name,int num) const -{ - assert(is_valid_utf8(name)); - int idx = meta_get_idx(name,num); - if (idx<0) return 0; - else return meta_enum_value(idx); -} - -int file_info::meta_get_count_by_name(const char* name) const -{ - assert(is_valid_utf8(name)); - int n,m=meta_get_count(); - int rv=0; - for(n=0;n=0;n--) - { - if (!stricmp_utf8(name,info_enum_name(n))) - info_remove(n); - } - -} - -static bool is_valid_bps(__int64 val) -{ - return val>0 && val<=256; -} - -unsigned file_info::info_get_decoded_bps() -{ - __int64 val = info_get_int("decoded_bitspersample"); - if (is_valid_bps(val)) return (unsigned)val; - val = info_get_int("bitspersample"); - if (is_valid_bps(val)) return (unsigned)val; - return 0; -} - -double file_info::info_get_float(const char * name) -{ - const char * ptr = info_get(name); - if (ptr) return pfc_string_to_float(ptr); - else return 0; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info.h deleted file mode 100644 index 212cac816..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef _FILE_INFO_H_ -#define _FILE_INFO_H_ - -#include "playable_location.h" -#include "playlist_entry.h"//for compatibility with old code - -//file_info == playable_location + length + metadata + tech infos -//also see: metadb.h - -//all char* strings are UTF-8, including filenames, unless comments state otherwise - -class NOVTABLE file_info //interface (cross-dll-safe) -{ -public: - virtual ~file_info() {} - //interface - - virtual void copy(const file_info * src);//can be overridden - - //multiple fields of the same name ARE allowed. - virtual int meta_get_count() const = 0; - virtual const char * meta_enum_name(int n) const = 0; - virtual const char * meta_enum_value(int n) const = 0; - virtual void meta_modify_value(int n,const char * new_value) = 0; - virtual void meta_insert(int index,const char * name,const char * value) = 0; - virtual void meta_add(const char * name,const char * value) = 0; - virtual void meta_remove(int n) = 0; - virtual void meta_remove_all() = 0; - virtual int meta_get_idx(const char * name,int num = 0) const; - //tech infos (bitrate, replaygain, etc), not user-editable - //multiple fields of the same are NOT allowed. - virtual void info_set(const char * name,const char * value) = 0;//replaces existing field if found - virtual int info_get_count() const = 0; - virtual const char * info_enum_name(int n) const = 0; - virtual const char * info_enum_value(int n) const = 0; - virtual void info_remove(int n) = 0; - virtual void info_remove_all() = 0; - virtual int info_get_idx(const char * name) const; - - virtual const playable_location * get_location() const = 0; - virtual void set_location(const playable_location *)=0; - - virtual void set_length(double) = 0;//length in seconds - virtual double get_length() const = 0; - - - inline int get_subsong_index() const {return get_location()->get_number();} - inline const char * get_file_path() const {return get_location()->get_path();} - - - inline void reset() {meta_remove_all();info_remove_all();set_length(0);} - -//helper stuff for setting meta - void meta_add_wide(const WCHAR * name,const WCHAR* value); - void meta_add_ansi(const char * name,const char * value); - void meta_set_wide(const WCHAR * name,const WCHAR* value); - void meta_set_ansi(const char * name,const char * value); - void meta_add_n(const char * name,int name_len,const char * value,int value_len); - void meta_remove_field(const char * name);//removes ALL fields of given name - void meta_set(const char * name,const char * value); //deletes all fields of given name (if any), then adds new one - const char * meta_get(const char * name,int num = 0) const; - int meta_get_count_by_name(const char* name) const; - const char * info_get(const char * name) const; - void info_remove_field(const char * name); - - __int64 info_get_int(const char * name) const; - __int64 info_get_length_samples() const; - double info_get_float(const char * name); - void info_set_int(const char * name,__int64 value); - void info_set_float(const char * name,double value,unsigned precision,bool force_sign = false,const char * unit = 0); - void info_set_replaygain_track_gain(double value); - void info_set_replaygain_album_gain(double value); - void info_set_replaygain_track_peak(double value); - void info_set_replaygain_album_peak(double value); - - inline __int64 info_get_bitrate_vbr() {return info_get_int("bitrate_dynamic");} - inline void info_set_bitrate_vbr(__int64 val) {info_set_int("bitrate_dynamic",val);} - inline __int64 info_get_bitrate() {return info_get_int("bitrate");} - inline void info_set_bitrate(__int64 val) {info_set_int("bitrate",val);} - - unsigned info_get_decoded_bps();//what bps the stream originally was (before converting to audio_sample), 0 if unknown -}; - -/* -recommended meta types: -TITLE -ARTIST -ALBUM -TRACKNUMBER (not TRACK) -DATE (not YEAR) -DISC (for disc number in a multidisc album) -GENRE -COMMENT -*/ - -#endif //_FILE_INFO_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info_helper.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info_helper.h deleted file mode 100644 index f14ab53df..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/file_info_helper.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef _FILE_INFO_HELPER_H_ -#define _FILE_INFO_HELPER_H_ - -#include "file_info.h" -#include "metadb_handle.h" - -class file_info_i : public file_info -{ -private: - playable_location_i location; - double length; - - struct entry - { - string_simple name,value; - entry(const char * p_name,const char * p_value) : name(p_name), value(p_value) {} - }; - ptr_list_t meta,info; -public: - file_info_i(const playable_location & src) : location(src), length(0) {} - file_info_i(const playable_location * src) : location(*src), length(0) {} - - file_info_i(const char * fn,int num) : location(fn,num), length(0) {} - - file_info_i() : length(0) {} - - file_info_i(metadb_handle * src) - : location(*src->handle_get_location()), length(0) - { - src->handle_query(this); - } - - file_info_i(const file_info & src) : length(0) {copy(&src);} - - - ~file_info_i() {meta.delete_all();info.delete_all();} - - //multiple fields of the same name ARE allowed. - virtual int meta_get_count() const {return meta.get_count();} - virtual const char * meta_enum_name(int n) const {return meta[n]->name;} - virtual const char * meta_enum_value(int n) const {return meta[n]->value;} - - virtual void meta_modify_value(int n,const char * new_value) - { - assert(is_valid_utf8(new_value)); - meta[n]->value=new_value; - } - - virtual void meta_insert(int index,const char * name,const char * value) - { - assert(is_valid_utf8(name)); - assert(is_valid_utf8(value)); - meta.insert_item(new entry(name,value),index); - } - - virtual void meta_add(const char * name,const char * value) - { - assert(is_valid_utf8(name)); - assert(is_valid_utf8(value)); - meta.add_item(new entry(name,value)); - } - - virtual void meta_remove(int n) {meta.delete_by_idx(n);} - virtual void meta_remove_all() {meta.delete_all();} - - //tech infos (bitrate, replaygain, etc), not user-editable - //multiple fields of the same are NOT allowed. - virtual void info_set(const char * name,const char * value) - { - assert(is_valid_utf8(name)); - assert(is_valid_utf8(value)); - info_remove_field(name); - info.add_item(new entry(name,value)); - } - - virtual int info_get_count() const {return info.get_count();} - virtual const char * info_enum_value(int n) const {return info[n]->value;} - virtual const char * info_enum_name(int n) const {return info[n]->name;} - virtual void info_remove(int n) {info.delete_by_idx(n);} - virtual void info_remove_all() {info.delete_all();} - - - virtual const playable_location * get_location() const {return &location;} - virtual void set_location(const playable_location * z) {location.copy(z);} - - virtual void set_length(double v) {length = v;} - virtual double get_length() const {return length;} - -}; - -#define file_info_i_full file_info_i - -#endif //_FILE_INFO_HELPER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/foobar2000.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/foobar2000.h deleted file mode 100644 index 69d9028bd..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/foobar2000.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _FOOBAR2000_H_ -#define _FOOBAR2000_H_ - -#include "../../pfc/pfc.h" - -#include "utf8api.h" - -#include "service.h" - -#include "audio_chunk.h" -#include "componentversion.h" -#include "config.h" -#include "config_var.h" -#include "console.h" -#include "coreversion.h" -#include "cvt_float_to_linear.h" -#include "diskwriter.h" -#include "dsp.h" -#include "dsp_manager.h" -#include "file_info.h" -#include "file_info_helper.h" -#include "initquit.h" -#include "input.h" -#include "input_helpers.h" -#include "menu_item.h" -#include "menu_manager.h" -#include "modeless_dialog.h" -#include "output.h" -#include "output_manager.h" -#include "play_callback.h" -#include "play_control.h" -#include "playable_location.h" -#include "playback_core.h" -#include "playlist.h" -#include "playlist_loader.h" -#include "reader.h" -#include "replaygain.h" -#include "resampler.h" -#include "service_helper.h" -#include "tagread.h" -#include "titleformat.h" -#include "ui.h" -#include "unpack.h" -#include "vis.h" -#include "playlist_switcher.h" -#include "packet_decoder.h" -#include "commandline.h" - -#endif //_FOOBAR2000_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/foobar2000_SDK.dsp b/tools/vio2sf/src/foobar8/foobar2000/SDK/foobar2000_SDK.dsp deleted file mode 100644 index d62b04b36..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/foobar2000_SDK.dsp +++ /dev/null @@ -1,399 +0,0 @@ -# Microsoft Developer Studio Project File - Name="foobar2000_SDK" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=foobar2000_SDK - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "foobar2000_SDK.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "foobar2000_SDK.mak" CFG="foobar2000_SDK - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "foobar2000_SDK - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "foobar2000_SDK - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "foobar2000_SDK - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -F90=df.exe -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MD /W3 /O1 /Oy /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "UNICODE" /D "_UNICODE" /Yu"foobar2000.h" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "foobar2000_SDK - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -F90=df.exe -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "UNICODE" /D "_UNICODE" /Yu"foobar2000.h" /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "foobar2000_SDK - Win32 Release" -# Name "foobar2000_SDK - Win32 Debug" -# Begin Source File - -SOURCE=.\audio_chunk.cpp -# End Source File -# Begin Source File - -SOURCE=.\audio_chunk.h -# End Source File -# Begin Source File - -SOURCE=.\commandline.cpp -# End Source File -# Begin Source File - -SOURCE=.\commandline.h -# End Source File -# Begin Source File - -SOURCE=.\component.h -# End Source File -# Begin Source File - -SOURCE=.\componentversion.h -# End Source File -# Begin Source File - -SOURCE=.\config.h -# End Source File -# Begin Source File - -SOURCE=.\config_var.h -# End Source File -# Begin Source File - -SOURCE=.\console.cpp -# End Source File -# Begin Source File - -SOURCE=.\console.h -# End Source File -# Begin Source File - -SOURCE=.\core_api.h -# End Source File -# Begin Source File - -SOURCE=.\coreversion.h -# End Source File -# Begin Source File - -SOURCE=.\cvt_float_to_linear.h -# End Source File -# Begin Source File - -SOURCE=.\diskwriter.cpp -# End Source File -# Begin Source File - -SOURCE=.\diskwriter.h -# End Source File -# Begin Source File - -SOURCE=.\dsp.cpp -# End Source File -# Begin Source File - -SOURCE=.\dsp.h -# End Source File -# Begin Source File - -SOURCE=.\dsp_manager.h -# End Source File -# Begin Source File - -SOURCE=.\file_info.cpp -# End Source File -# Begin Source File - -SOURCE=.\file_info.h -# End Source File -# Begin Source File - -SOURCE=.\file_info_helper.h -# End Source File -# Begin Source File - -SOURCE=.\foobar2000.h -# End Source File -# Begin Source File - -SOURCE=.\guids.cpp -# End Source File -# Begin Source File - -SOURCE=.\initquit.h -# End Source File -# Begin Source File - -SOURCE=.\input.cpp -# End Source File -# Begin Source File - -SOURCE=.\input.h -# End Source File -# Begin Source File - -SOURCE=.\input_helpers.cpp -# End Source File -# Begin Source File - -SOURCE=.\input_helpers.h -# End Source File -# Begin Source File - -SOURCE=.\menu_item.h -# End Source File -# Begin Source File - -SOURCE=.\menu_manager.cpp -# End Source File -# Begin Source File - -SOURCE=.\menu_manager.h -# End Source File -# Begin Source File - -SOURCE=.\metadb.cpp -# End Source File -# Begin Source File - -SOURCE=.\metadb.h -# End Source File -# Begin Source File - -SOURCE=.\metadb_handle.cpp -# End Source File -# Begin Source File - -SOURCE=.\metadb_handle.h -# End Source File -# Begin Source File - -SOURCE=.\modeless_dialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\modeless_dialog.h -# End Source File -# Begin Source File - -SOURCE=.\output.cpp -# End Source File -# Begin Source File - -SOURCE=.\output.h -# End Source File -# Begin Source File - -SOURCE=.\output_manager.h -# End Source File -# Begin Source File - -SOURCE=.\packet_decoder.cpp -# End Source File -# Begin Source File - -SOURCE=.\packet_decoder.h -# End Source File -# Begin Source File - -SOURCE=.\play_callback.h -# End Source File -# Begin Source File - -SOURCE=.\play_control.cpp -# End Source File -# Begin Source File - -SOURCE=.\play_control.h -# End Source File -# Begin Source File - -SOURCE=.\playable_location.cpp -# End Source File -# Begin Source File - -SOURCE=.\playable_location.h -# End Source File -# Begin Source File - -SOURCE=.\playback_core.h -# End Source File -# Begin Source File - -SOURCE=.\playlist.cpp -# End Source File -# Begin Source File - -SOURCE=.\playlist.h -# End Source File -# Begin Source File - -SOURCE=.\playlist_entry.h -# End Source File -# Begin Source File - -SOURCE=.\playlist_loader.cpp -# End Source File -# Begin Source File - -SOURCE=.\playlist_loader.h -# End Source File -# Begin Source File - -SOURCE=.\playlist_switcher.h -# End Source File -# Begin Source File - -SOURCE=.\reader.cpp -# End Source File -# Begin Source File - -SOURCE=.\reader.h -# End Source File -# Begin Source File - -SOURCE=.\reader_helper.h -# End Source File -# Begin Source File - -SOURCE=.\reader_helper_mem.h -# End Source File -# Begin Source File - -SOURCE=.\replaygain.h -# End Source File -# Begin Source File - -SOURCE=.\resampler.h -# End Source File -# Begin Source File - -SOURCE=.\service.cpp -# End Source File -# Begin Source File - -SOURCE=.\service.h -# End Source File -# Begin Source File - -SOURCE=.\service_helper.h -# End Source File -# Begin Source File - -SOURCE=.\service_impl.h -# End Source File -# Begin Source File - -SOURCE=.\stdafx.cpp - -!IF "$(CFG)" == "foobar2000_SDK - Win32 Release" - -# ADD CPP /Yc - -!ELSEIF "$(CFG)" == "foobar2000_SDK - Win32 Debug" - -# ADD CPP /Yc"foobar2000.h" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\tagread.cpp -# End Source File -# Begin Source File - -SOURCE=.\tagread.h -# End Source File -# Begin Source File - -SOURCE=.\titleformat.cpp -# End Source File -# Begin Source File - -SOURCE=.\titleformat.h -# End Source File -# Begin Source File - -SOURCE=.\ui.cpp -# End Source File -# Begin Source File - -SOURCE=.\ui.h -# End Source File -# Begin Source File - -SOURCE=.\unpack.h -# End Source File -# Begin Source File - -SOURCE=.\utf8api.cpp -# End Source File -# Begin Source File - -SOURCE=.\utf8api.h -# End Source File -# Begin Source File - -SOURCE=.\vis.h -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/guids.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/guids.cpp deleted file mode 100644 index 5bce2a4c7..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/guids.cpp +++ /dev/null @@ -1,583 +0,0 @@ -#include "foobar2000.h" - -#ifdef _MSC_VER -#define FOOGUIDDECL __declspec(selectany) //hack against msvc linker stupidity -#else -#define FOOGUIDDECL -#endif - -// {10BB3EBD-DDF7-4975-A3CC-23084829453E} -FOOGUIDDECL const GUID componentversion::class_guid = -{ 0x10bb3ebd, 0xddf7, 0x4975, { 0xa3, 0xcc, 0x23, 0x8, 0x48, 0x29, 0x45, 0x3e } }; - -// {7255E8D0-3FCF-4781-B93B-D06CB88DFAFA} -FOOGUIDDECL const GUID config::class_guid = -{ 0x7255e8d0, 0x3fcf, 0x4781, { 0xb9, 0x3b, 0xd0, 0x6c, 0xb8, 0x8d, 0xfa, 0xfa } }; - -// {056B51C7-E78C-4a4e-B84E-6BFF3F8AB8F2} -FOOGUIDDECL const GUID console::class_guid = -{ 0x56b51c7, 0xe78c, 0x4a4e, { 0xb8, 0x4e, 0x6b, 0xff, 0x3f, 0x8a, 0xb8, 0xf2 } }; - -// {0C36A649-9EA0-4f48-B229-0CB2AA9AB6F4} -FOOGUIDDECL const GUID core_version_info::class_guid = -{ 0xc36a649, 0x9ea0, 0x4f48, { 0xb2, 0x29, 0xc, 0xb2, 0xaa, 0x9a, 0xb6, 0xf4 } }; - -// {545F99D1-602D-4175-867F-F7C6AD680A81} -FOOGUIDDECL const GUID cvt_float_to_linear::class_guid = -{ 0x545f99d1, 0x602d, 0x4175, { 0x86, 0x7f, 0xf7, 0xc6, 0xad, 0x68, 0xa, 0x81 } }; - -// {D9239DB0-210B-4680-82AF-C37DBDD6A43D} -FOOGUIDDECL const GUID dsp_v2::class_guid = -{ 0xd9239db0, 0x210b, 0x4680, { 0x82, 0xaf, 0xc3, 0x7d, 0xbd, 0xd6, 0xa4, 0x3d } }; - -// {2A42AFEA-940B-455b-AEFF-CFDACAF52AFF} -FOOGUIDDECL const GUID dsp::class_guid = -{ 0x2a42afea, 0x940b, 0x455b, { 0xae, 0xff, 0xcf, 0xda, 0xca, 0xf5, 0x2a, 0xff } }; - -// {D63655B2-B0CE-4069-BDF9-E364E43FF23C} -FOOGUIDDECL const GUID input::class_guid = -{ 0xd63655b2, 0xb0ce, 0x4069, { 0xbd, 0xf9, 0xe3, 0x64, 0xe4, 0x3f, 0xf2, 0x3c } }; - -// {113773C4-B387-4b48-8BDF-AB58BC6CE538} -FOOGUIDDECL const GUID initquit::class_guid = -{ 0x113773c4, 0xb387, 0x4b48, { 0x8b, 0xdf, 0xab, 0x58, 0xbc, 0x6c, 0xe5, 0x38 } }; - -// {609D48C8-C6A6-4784-8BBD-FDD32BF0740E} -FOOGUIDDECL const GUID metadb::class_guid = -{ 0x609d48c8, 0xc6a6, 0x4784, { 0x8b, 0xbd, 0xfd, 0xd3, 0x2b, 0xf0, 0x74, 0xe } }; - -// {D5286BB4-FDED-47ef-A623-4C3FF056DEC1} -FOOGUIDDECL const GUID metadb_callback::class_guid = -{ 0xd5286bb4, 0xfded, 0x47ef, { 0xa6, 0x23, 0x4c, 0x3f, 0xf0, 0x56, 0xde, 0xc1 } }; - -// {065190FC-9C8A-4b2b-A5EC-E21EBE288234} -FOOGUIDDECL const GUID metadb_callback_simple::class_guid = -{ 0x65190fc, 0x9c8a, 0x4b2b, { 0xa5, 0xec, 0xe2, 0x1e, 0xbe, 0x28, 0x82, 0x34 } }; - -// {1C0802F7-CF24-49ef-B914-8B9866F19779} -FOOGUIDDECL const GUID menu_item::class_guid = -{ 0x1c0802f7, 0xcf24, 0x49ef, { 0xb9, 0x14, 0x8b, 0x98, 0x66, 0xf1, 0x97, 0x79 } }; - -// {C1CAF378-BCAF-4271-AE4D-45A49B9C3B79} -FOOGUIDDECL const GUID output::class_guid = -{ 0xc1caf378, 0xbcaf, 0x4271, { 0xae, 0x4d, 0x45, 0xa4, 0x9b, 0x9c, 0x3b, 0x79 } }; - -// {D9CF88FF-AC2B-4a8a-8A50-DA0933A03792} -FOOGUIDDECL const GUID visualisation::class_guid = -{ 0xd9cf88ff, 0xac2b, 0x4a8a, { 0x8a, 0x50, 0xda, 0x9, 0x33, 0xa0, 0x37, 0x92 } }; - -// {A7E799BC-9774-41cf-8785-0D91634F937B} -FOOGUIDDECL const GUID packet_decoder::class_guid = -{ 0xa7e799bc, 0x9774, 0x41cf, { 0x87, 0x85, 0xd, 0x91, 0x63, 0x4f, 0x93, 0x7b } }; - -// {D3BD5F53-A6D6-4346-991F-CF14DFAD2B3A} -FOOGUIDDECL const GUID menu_manager::class_guid = -{ 0xd3bd5f53, 0xa6d6, 0x4346, { 0x99, 0x1f, 0xcf, 0x14, 0xdf, 0xad, 0x2b, 0x3a } }; - -// {61CF61E5-7C8E-469b-88E7-CE9B217DD38E} -FOOGUIDDECL const GUID menu_manager_defaults::class_guid = -{ 0x61cf61e5, 0x7c8e, 0x469b, { 0x88, 0xe7, 0xce, 0x9b, 0x21, 0x7d, 0xd3, 0x8e } }; - -// {640E006E-2934-4d6c-8327-4FA9F341ECF2} -FOOGUIDDECL const GUID input_file_type::class_guid = -{ 0x640e006e, 0x2934, 0x4d6c, { 0x83, 0x27, 0x4f, 0xa9, 0xf3, 0x41, 0xec, 0xf2 } }; - -// {B2518A41-A251-4941-9E28-BC51F7B840C3} -FOOGUIDDECL const GUID input_v2::class_guid = -{ 0xb2518a41, 0xa251, 0x4941, { 0x9e, 0x28, 0xbc, 0x51, 0xf7, 0xb8, 0x40, 0xc3 } }; - -// {2DEB68AB-49ED-460a-BFC0-4936AD39BA4F} -FOOGUIDDECL const GUID diskwriter::class_guid = -{ 0x2deb68ab, 0x49ed, 0x460a, { 0xbf, 0xc0, 0x49, 0x36, 0xad, 0x39, 0xba, 0x4f } }; - -// {8C6775A2-56FC-4a64-89F4-2609595C86A2} -FOOGUIDDECL const GUID ui_control::class_guid = -{ 0x8c6775a2, 0x56fc, 0x4a64, { 0x89, 0xf4, 0x26, 0x9, 0x59, 0x5c, 0x86, 0xa2 } }; - -// {52BD7A17-540C-4a97-B812-72BC84EC4FF5} -FOOGUIDDECL const GUID ui_drop_item_callback::class_guid = -{ 0x52bd7a17, 0x540c, 0x4a97, { 0xb8, 0x12, 0x72, 0xbc, 0x84, 0xec, 0x4f, 0xf5 } }; - -// {85605A78-101A-47cb-9541-4101EEBAC724} -FOOGUIDDECL const GUID track_indexer_v2::class_guid = -{ 0x85605a78, 0x101a, 0x47cb, { 0x95, 0x41, 0x41, 0x1, 0xee, 0xba, 0xc7, 0x24 } }; - -// {550B3A19-42A4-4c0f-91F2-90550189CBFF} -FOOGUIDDECL const GUID commandline_handler::class_guid = -{ 0x550b3a19, 0x42a4, 0x4c0f, { 0x91, 0xf2, 0x90, 0x55, 0x1, 0x89, 0xcb, 0xff } }; - -// {B92230CE-12A1-49f4-AFC7-3B5C57AD3760} -FOOGUIDDECL const GUID playback_flow_control::class_guid = -{ 0xb92230ce, 0x12a1, 0x49f4, { 0xaf, 0xc7, 0x3b, 0x5c, 0x57, 0xad, 0x37, 0x60 } }; - -// {7E82BE03-5956-412b-A9C4-6D1A3E2D7123} -FOOGUIDDECL const GUID playback_flow_control_v2::class_guid = -{ 0x7e82be03, 0x5956, 0x412b, { 0xa9, 0xc4, 0x6d, 0x1a, 0x3e, 0x2d, 0x71, 0x23 } }; - -// {8A17F5C7-0EA0-409c-93F6-3A2BF9CE65BF} -FOOGUIDDECL const GUID dsp_manager::class_guid = -{ 0x8a17f5c7, 0xea0, 0x409c, { 0x93, 0xf6, 0x3a, 0x2b, 0xf9, 0xce, 0x65, 0xbf } }; - -// {C71B99BD-12C5-48fe-A9C0-469F6FEA88BF} -FOOGUIDDECL const GUID modeless_dialog_manager::class_guid = -{ 0xc71b99bd, 0x12c5, 0x48fe, { 0xa9, 0xc0, 0x46, 0x9f, 0x6f, 0xea, 0x88, 0xbf } }; - -// {05C42951-1373-43ed-8F0C-F7B55D867868} -FOOGUIDDECL const GUID output_manager::class_guid = -{ 0x5c42951, 0x1373, 0x43ed, { 0x8f, 0xc, 0xf7, 0xb5, 0x5d, 0x86, 0x78, 0x68 } }; - -// {CF91D5CB-743B-401a-A8CC-E149F8944CCB} -FOOGUIDDECL const GUID play_callback::class_guid = -{ 0xcf91d5cb, 0x743b, 0x401a, { 0xa8, 0xcc, 0xe1, 0x49, 0xf8, 0x94, 0x4c, 0xcb } }; - -// {66E4FD37-5839-4233-A2D3-787E86A69011} -FOOGUIDDECL const GUID play_control::class_guid = -{ 0x66e4fd37, 0x5839, 0x4233, { 0xa2, 0xd3, 0x78, 0x7e, 0x86, 0xa6, 0x90, 0x11 } }; - -// {04AEC60C-BF22-46a6-B69E-BB8B4BE31AC2} -FOOGUIDDECL const GUID playback_core::class_guid = -{ 0x4aec60c, 0xbf22, 0x46a6, { 0xb6, 0x9e, 0xbb, 0x8b, 0x4b, 0xe3, 0x1a, 0xc2 } }; - -// {1673784D-E82E-4a70-8FFE-3D5613BD7C3C} -FOOGUIDDECL const GUID play_sound::class_guid = -{ 0x1673784d, 0xe82e, 0x4a70, { 0x8f, 0xfe, 0x3d, 0x56, 0x13, 0xbd, 0x7c, 0x3c } }; - -// {F384709D-7B49-472f-8D41-9D622877BA4E} -FOOGUIDDECL const GUID playlist_callback::class_guid = -{ 0xf384709d, 0x7b49, 0x472f, { 0x8d, 0x41, 0x9d, 0x62, 0x28, 0x77, 0xba, 0x4e } }; - -// {D2E5F92B-3424-4822-AE60-8663E6D26EAB} -FOOGUIDDECL const GUID playlist_loader::class_guid = -{ 0xd2e5f92b, 0x3424, 0x4822, { 0xae, 0x60, 0x86, 0x63, 0xe6, 0xd2, 0x6e, 0xab } }; - -// {95510C89-9968-4ebe-9968-5290CAAB39D2} -FOOGUIDDECL const GUID track_indexer::class_guid = -{ 0x95510c89, 0x9968, 0x4ebe, { 0x99, 0x68, 0x52, 0x90, 0xca, 0xab, 0x39, 0xd2 } }; - -// {2FBCE1E5-902E-49e0-B9CF-CE0FBA765348} -FOOGUIDDECL const GUID file::class_guid = -{ 0x2fbce1e5, 0x902e, 0x49e0, { 0xb9, 0xcf, 0xce, 0xf, 0xba, 0x76, 0x53, 0x48 } }; - -// {E84E9847-ADBB-447b-92F8-E9446EF2F427} -FOOGUIDDECL const GUID directory::class_guid = -{ 0xe84e9847, 0xadbb, 0x447b, { 0x92, 0xf8, 0xe9, 0x44, 0x6e, 0xf2, 0xf4, 0x27 } }; - -// {9098AF12-61A3-4caa-8AA9-BB95C2EF8346} -FOOGUIDDECL const GUID unpacker::class_guid = -{ 0x9098af12, 0x61a3, 0x4caa, { 0x8a, 0xa9, 0xbb, 0x95, 0xc2, 0xef, 0x83, 0x46 } }; - -// {EC707440-FA3E-4d12-9876-FC369F04D4A4} -FOOGUIDDECL const GUID archive::class_guid = -{ 0xec707440, 0xfa3e, 0x4d12, { 0x98, 0x76, 0xfc, 0x36, 0x9f, 0x4, 0xd4, 0xa4 } }; - -// {B2F9FC40-3E55-4b23-A2C9-22BAAD8795B1} -FOOGUIDDECL const GUID reader::class_guid = -{ 0xb2f9fc40, 0x3e55, 0x4b23, { 0xa2, 0xc9, 0x22, 0xba, 0xad, 0x87, 0x95, 0xb1 } }; - -// {C40598AA-089B-4c9f-AFCA-5FEE1CA1973D} -FOOGUIDDECL const GUID reader_dynamicinfo::class_guid = -{ 0xc40598aa, 0x89b, 0x4c9f, { 0xaf, 0xca, 0x5f, 0xee, 0x1c, 0xa1, 0x97, 0x3d } }; - -// {376B8EA5-DA53-4a83-881B-E92CF73D8D60} -FOOGUIDDECL const GUID reader_filetime::class_guid = -{ 0x376b8ea5, 0xda53, 0x4a83, { 0x88, 0x1b, 0xe9, 0x2c, 0xf7, 0x3d, 0x8d, 0x60 } }; - -// {A00CB77D-ED72-4031-806B-4E45AF995241} -FOOGUIDDECL const GUID replaygain::class_guid = -{ 0xa00cb77d, 0xed72, 0x4031, { 0x80, 0x6b, 0x4e, 0x45, 0xaf, 0x99, 0x52, 0x41 } }; - -// {3FEED4FC-A400-4a30-8E73-F0ECD114D7E8} -FOOGUIDDECL const GUID resampler::class_guid = -{ 0x3feed4fc, 0xa400, 0x4a30, { 0x8e, 0x73, 0xf0, 0xec, 0xd1, 0x14, 0xd7, 0xe8 } }; - -// {BB360EDA-1E11-4604-87FC-56CE6C249DD7} -FOOGUIDDECL const GUID tag_reader::class_guid = -{ 0xbb360eda, 0x1e11, 0x4604, { 0x87, 0xfc, 0x56, 0xce, 0x6c, 0x24, 0x9d, 0xd7 } }; - -// {2BE790FB-070F-4b96-BF68-DA579EACE69A} -FOOGUIDDECL const GUID tag_writer::class_guid = -{ 0x2be790fb, 0x70f, 0x4b96, { 0xbf, 0x68, 0xda, 0x57, 0x9e, 0xac, 0xe6, 0x9a } }; - -// {E434F1CA-92DA-482c-A76A-2129EE1CD2E3} -FOOGUIDDECL const GUID tag_remover::class_guid = -{ 0xe434f1ca, 0x92da, 0x482c, { 0xa7, 0x6a, 0x21, 0x29, 0xee, 0x1c, 0xd2, 0xe3 } }; - -// {3F7674AB-044C-4796-8801-6C443C244D88} -FOOGUIDDECL const GUID titleformat::class_guid = -{ 0x3f7674ab, 0x44c, 0x4796, { 0x88, 0x1, 0x6c, 0x44, 0x3c, 0x24, 0x4d, 0x88 } }; - -// {A2AC631F-38D0-46ee-B9B1-F1599DF02BB6} -FOOGUIDDECL const GUID user_interface::class_guid = -{ 0xa2ac631f, 0x38d0, 0x46ee, { 0xb9, 0xb1, 0xf1, 0x59, 0x9d, 0xf0, 0x2b, 0xb6 } }; - -// {8634CA5E-7CE1-419c-97C9-B47B5B6C538F} -FOOGUIDDECL const GUID playlist_switcher::class_guid = -{ 0x8634ca5e, 0x7ce1, 0x419c, { 0x97, 0xc9, 0xb4, 0x7b, 0x5b, 0x6c, 0x53, 0x8f } }; - -// {7F0FB76C-6BB7-4435-8337-8E7598F44BDA} -FOOGUIDDECL const GUID playlist_switcher_callback::class_guid = -{ 0x7f0fb76c, 0x6bb7, 0x4435, { 0x83, 0x37, 0x8e, 0x75, 0x98, 0xf4, 0x4b, 0xda } }; - -// {8CC36FD2-9BC6-46b9-A748-1568DE4CD602} -FOOGUIDDECL const GUID playlist_oper::class_guid = -{ 0x8cc36fd2, 0x9bc6, 0x46b9, { 0xa7, 0x48, 0x15, 0x68, 0xde, 0x4c, 0xd6, 0x2 } }; - -// {994C0D0E-319E-45f3-92FC-518616E73ADC} -FOOGUIDDECL const GUID menu_item::caller_now_playing = -{ 0x994c0d0e, 0x319e, 0x45f3, { 0x92, 0xfc, 0x51, 0x86, 0x16, 0xe7, 0x3a, 0xdc } }; - -// {47502BA1-816D-4a3e-ADE5-A7A9860A67DB} -FOOGUIDDECL const GUID menu_item::caller_playlist = -{ 0x47502ba1, 0x816d, 0x4a3e, { 0xad, 0xe5, 0xa7, 0xa9, 0x86, 0xa, 0x67, 0xdb } }; - -// {00000000-0000-0000-0000-000000000000} -FOOGUIDDECL const GUID menu_item::caller_undefined = -{ 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; - -// {79D28AA9-4E71-4b9b-98BA-36DB16593FDF} -FOOGUIDDECL const GUID menu_item_v2::class_guid = -{ 0x79d28aa9, 0x4e71, 0x4b9b, { 0x98, 0xba, 0x36, 0xdb, 0x16, 0x59, 0x3f, 0xdf } }; - -// {95DE5842-30F5-4f72-B40C-191663782F80} -FOOGUIDDECL const GUID keyboard_shortcut_manager::class_guid = -{ 0x95de5842, 0x30f5, 0x4f72, { 0xb4, 0xc, 0x19, 0x16, 0x63, 0x78, 0x2f, 0x80 } }; - -// {FF77A2C6-7ACD-483d-841C-A052E5CA5E03} -FOOGUIDDECL const GUID config_var::class_guid = -{ 0xff77a2c6, 0x7acd, 0x483d, { 0x84, 0x1c, 0xa0, 0x52, 0xe5, 0xca, 0x5e, 0x3 } }; - -// {30F95BEB-FDF4-4a75-B597-60CAF93B39C4} -FOOGUIDDECL const GUID packet_decoder::owner_MP4 = -{ 0x30f95beb, 0xfdf4, 0x4a75, { 0xb5, 0x97, 0x60, 0xca, 0xf9, 0x3b, 0x39, 0xc4 } }; - -// {5C2DE804-EAEE-4b8e-8C14-9207A2549BBE} -FOOGUIDDECL const GUID packet_decoder::owner_matroska = -{ 0x5c2de804, 0xeaee, 0x4b8e, { 0x8c, 0x14, 0x92, 0x7, 0xa2, 0x54, 0x9b, 0xbe } }; - -// {7B741A69-1AC7-440d-A01D-88536DD4DE1C} -FOOGUIDDECL const GUID packet_decoder::owner_MP3 = -{ 0x7b741a69, 0x1ac7, 0x440d, { 0xa0, 0x1d, 0x88, 0x53, 0x6d, 0xd4, 0xde, 0x1c } }; - -// {BC73F9FC-0107-480e-BF0E-BE58AF7AF328} -FOOGUIDDECL const GUID packet_decoder::property_samplerate = -{ 0xbc73f9fc, 0x107, 0x480e, { 0xbf, 0xe, 0xbe, 0x58, 0xaf, 0x7a, 0xf3, 0x28 } }; - -// {E5D19AAD-931B-48ac-AA6E-95E2C23BEC37} -FOOGUIDDECL const GUID packet_decoder::property_bitspersample = -{ 0xe5d19aad, 0x931b, 0x48ac, { 0xaa, 0x6e, 0x95, 0xe2, 0xc2, 0x3b, 0xec, 0x37 } }; - -// {1AFA1145-E774-4c26-91D6-3F5DD61E260E} -FOOGUIDDECL const GUID packet_decoder::property_channels = -{ 0x1afa1145, 0xe774, 0x4c26, { 0x91, 0xd6, 0x3f, 0x5d, 0xd6, 0x1e, 0x26, 0xe } }; - -// {29C556DA-065A-4d24-8A11-0F9DBC05A817} -FOOGUIDDECL const GUID packet_decoder::property_byteorder = -{ 0x29c556da, 0x65a, 0x4d24, { 0x8a, 0x11, 0xf, 0x9d, 0xbc, 0x5, 0xa8, 0x17 } }; - -// {0759C32F-E78E-4479-B0C0-B653DFA014D8} -FOOGUIDDECL const GUID packet_decoder::property_signed = -{ 0x759c32f, 0xe78e, 0x4479, { 0xb0, 0xc0, 0xb6, 0x53, 0xdf, 0xa0, 0x14, 0xd8 } }; - -// {646930F3-30AC-40e7-B7E4-EB7DFD2C0A47} -FOOGUIDDECL const GUID config_var_int::var_type = -{ 0x646930f3, 0x30ac, 0x40e7, { 0xb7, 0xe4, 0xeb, 0x7d, 0xfd, 0x2c, 0xa, 0x47 } }; - -// {335B8AA3-D05F-459a-A15C-115A3AEB2507} -FOOGUIDDECL const GUID config_var_struct_var_type = -{ 0x335b8aa3, 0xd05f, 0x459a, { 0xa1, 0x5c, 0x11, 0x5a, 0x3a, 0xeb, 0x25, 0x7 } }; - -// {FA9DA2B0-1F5E-42ab-866B-A567E1CE861B} -FOOGUIDDECL const GUID config_var_string::var_type = -{ 0xfa9da2b0, 0x1f5e, 0x42ab, { 0x86, 0x6b, 0xa5, 0x67, 0xe1, 0xce, 0x86, 0x1b } }; - -// {6F441057-1D18-4a58-9AC4-8F409CDA7DFD} -FOOGUIDDECL const GUID standard_commands::guid_context_file_properties = -{ 0x6f441057, 0x1d18, 0x4a58, { 0x9a, 0xc4, 0x8f, 0x40, 0x9c, 0xda, 0x7d, 0xfd } }; - -// {6F441057-1D18-4a58-9AC4-8F409CDA7DFD} -FOOGUIDDECL const GUID standard_commands::guid_context_file_open_directory = -{ 0x6f441057, 0x1d18, 0x4a58, { 0x9a, 0xc4, 0x8f, 0x40, 0x9c, 0xda, 0x7d, 0xfd } }; - -// {FFE18008-BCA2-4b29-AB88-8816B492C434} -FOOGUIDDECL const GUID standard_commands::guid_context_copy_names = -{ 0xffe18008, 0xbca2, 0x4b29, { 0xab, 0x88, 0x88, 0x16, 0xb4, 0x92, 0xc4, 0x34 } }; - -// {44B8F02B-5408-4361-8240-18DEC881B95E} -FOOGUIDDECL const GUID standard_commands::guid_context_send_to_playlist = -{ 0x44b8f02b, 0x5408, 0x4361, { 0x82, 0x40, 0x18, 0xde, 0xc8, 0x81, 0xb9, 0x5e } }; - -// {8C3BA2CB-BC4D-4752-8282-C6F9AED75A78} -FOOGUIDDECL const GUID standard_commands::guid_context_reload_info = -{ 0x8c3ba2cb, 0xbc4d, 0x4752, { 0x82, 0x82, 0xc6, 0xf9, 0xae, 0xd7, 0x5a, 0x78 } }; - -// {BD045EA4-E5E9-4206-8FF9-12AD9F5DCDE1} -FOOGUIDDECL const GUID standard_commands::guid_context_reload_info_if_changed = -{ 0xbd045ea4, 0xe5e9, 0x4206, { 0x8f, 0xf9, 0x12, 0xad, 0x9f, 0x5d, 0xcd, 0xe1 } }; - -// {684D9FBB-4383-44a2-9789-7EE1376209C6} -FOOGUIDDECL const GUID standard_commands::guid_context_rewrite_info = -{ 0x684d9fbb, 0x4383, 0x44a2, { 0x97, 0x89, 0x7e, 0xe1, 0x37, 0x62, 0x9, 0xc6 } }; - -// {860179B7-962F-4340-ACAD-0DDAF060A6B8} -FOOGUIDDECL const GUID standard_commands::guid_context_remove_tags = -{ 0x860179b7, 0x962f, 0x4340, { 0xac, 0xad, 0xd, 0xda, 0xf0, 0x60, 0xa6, 0xb8 } }; - -// {4DD1E1AD-F481-480c-BC3E-DD9C878EAFC3} -FOOGUIDDECL const GUID standard_commands::guid_context_remove_from_database = -{ 0x4dd1e1ad, 0xf481, 0x480c, { 0xbc, 0x3e, 0xdd, 0x9c, 0x87, 0x8e, 0xaf, 0xc3 } }; - -// {A7E7ECB7-1943-4907-83B3-60E92353C7FA} -FOOGUIDDECL const GUID standard_commands::guid_context_convert_run = -{ 0xa7e7ecb7, 0x1943, 0x4907, { 0x83, 0xb3, 0x60, 0xe9, 0x23, 0x53, 0xc7, 0xfa } }; - -// {A58AE6EA-A34F-4879-B25C-F31F2CBC4DA9} -FOOGUIDDECL const GUID standard_commands::guid_context_convert_run_singlefile = -{ 0xa58ae6ea, 0xa34f, 0x4879, { 0xb2, 0x5c, 0xf3, 0x1f, 0x2c, 0xbc, 0x4d, 0xa9 } }; - -// {A8EFA42D-76CB-42bc-8803-70516567B13D} -FOOGUIDDECL const GUID standard_commands::guid_context_write_cd = -{ 0xa8efa42d, 0x76cb, 0x42bc, { 0x88, 0x3, 0x70, 0x51, 0x65, 0x67, 0xb1, 0x3d } }; - -// {487DAED1-02FB-4336-A813-5E90317AB041} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_track = -{ 0x487daed1, 0x2fb, 0x4336, { 0xa8, 0x13, 0x5e, 0x90, 0x31, 0x7a, 0xb0, 0x41 } }; - -// {3850F34C-F619-4296-B8A0-26C617B1D16C} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_album = -{ 0x3850f34c, 0xf619, 0x4296, { 0xb8, 0xa0, 0x26, 0xc6, 0x17, 0xb1, 0xd1, 0x6c } }; - -// {6A2DBA02-260C-436f-8F41-0190A4298266} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_scan_album_multi = -{ 0x6a2dba02, 0x260c, 0x436f, { 0x8f, 0x41, 0x1, 0x90, 0xa4, 0x29, 0x82, 0x66 } }; - -// {54C82A92-5824-4381-8D1B-79FBB1E2ABB8} -FOOGUIDDECL const GUID standard_commands::guid_context_rg_remove = -{ 0x54c82a92, 0x5824, 0x4381, { 0x8d, 0x1b, 0x79, 0xfb, 0xb1, 0xe2, 0xab, 0xb8 } }; - -// {69EAA594-13D9-4237-9BD7-11A39FDD1454} -FOOGUIDDECL const GUID standard_commands::guid_context_save_playlist = -{ 0x69eaa594, 0x13d9, 0x4237, { 0x9b, 0xd7, 0x11, 0xa3, 0x9f, 0xdd, 0x14, 0x54 } }; - -// {2BEB6836-C657-40ef-BB6E-D5B222AB89CE} -FOOGUIDDECL const GUID standard_commands::guid_context_masstag_edit = -{ 0x2beb6836, 0xc657, 0x40ef, { 0xbb, 0x6e, 0xd5, 0xb2, 0x22, 0xab, 0x89, 0xce } }; - -// {A579FF07-5D0B-48ed-A071-B6FCE4385AA9} -FOOGUIDDECL const GUID standard_commands::guid_context_masstag_rename = -{ 0xa579ff07, 0x5d0b, 0x48ed, { 0xa0, 0x71, 0xb6, 0xfc, 0xe4, 0x38, 0x5a, 0xa9 } }; - -// {77CFBCD0-98DC-4015-B327-D7142C664806} -FOOGUIDDECL const GUID standard_commands::guid_main_always_on_top = -{ 0x77cfbcd0, 0x98dc, 0x4015, { 0xb3, 0x27, 0xd7, 0x14, 0x2c, 0x66, 0x48, 0x6 } }; - -// {11213A01-9F36-4e69-A1BB-7A72F418DE3A} -FOOGUIDDECL const GUID standard_commands::guid_main_preferences = -{ 0x11213a01, 0x9f36, 0x4e69, { 0xa1, 0xbb, 0x7a, 0x72, 0xf4, 0x18, 0xde, 0x3a } }; - -// {EDA23441-5D38-4499-A22C-FE0CE0A987D9} -FOOGUIDDECL const GUID standard_commands::guid_main_about = -{ 0xeda23441, 0x5d38, 0x4499, { 0xa2, 0x2c, 0xfe, 0xc, 0xe0, 0xa9, 0x87, 0xd9 } }; - -// {6D38C73A-15D8-472c-8E68-6F946B82ECB4} -FOOGUIDDECL const GUID standard_commands::guid_main_exit = -{ 0x6d38c73a, 0x15d8, 0x472c, { 0x8e, 0x68, 0x6f, 0x94, 0x6b, 0x82, 0xec, 0xb4 } }; - -// {EF9B60FE-CB03-4c40-A8FD-3F1821020B37} -FOOGUIDDECL const GUID standard_commands::guid_main_restart = -{ 0xef9b60fe, 0xcb03, 0x4c40, { 0xa8, 0xfd, 0x3f, 0x18, 0x21, 0x2, 0xb, 0x37 } }; - -// {90500F09-F16F-415e-A047-AC5045C95FFE} -FOOGUIDDECL const GUID standard_commands::guid_main_activate = -{ 0x90500f09, 0xf16f, 0x415e, { 0xa0, 0x47, 0xac, 0x50, 0x45, 0xc9, 0x5f, 0xfe } }; - -// {13C17E8D-0D6F-41a4-B24A-59371043E925} -FOOGUIDDECL const GUID standard_commands::guid_main_hide = -{ 0x13c17e8d, 0xd6f, 0x41a4, { 0xb2, 0x4a, 0x59, 0x37, 0x10, 0x43, 0xe9, 0x25 } }; - -// {D9473FB2-BF11-4be0-972F-0E43F166A118} -FOOGUIDDECL const GUID standard_commands::guid_main_activate_or_hide = -{ 0xd9473fb2, 0xbf11, 0x4be0, { 0x97, 0x2f, 0xe, 0x43, 0xf1, 0x66, 0xa1, 0x18 } }; - -// {91E349DA-8800-42e5-BC8C-F3A92577AE84} -FOOGUIDDECL const GUID standard_commands::guid_main_titleformat_help = -{ 0x91e349da, 0x8800, 0x42e5, { 0xbc, 0x8c, 0xf3, 0xa9, 0x25, 0x77, 0xae, 0x84 } }; - -// {FBCFE01C-6C57-4e6a-A9F1-62334640DC91} -FOOGUIDDECL const GUID standard_commands::guid_main_follow_cursor = -{ 0xfbcfe01c, 0x6c57, 0x4e6a, { 0xa9, 0xf1, 0x62, 0x33, 0x46, 0x40, 0xdc, 0x91 } }; - -// {E58895A0-A2F0-45b6-8799-1440E4DB7284} -FOOGUIDDECL const GUID standard_commands::guid_main_next = -{ 0xe58895a0, 0xa2f0, 0x45b6, { 0x87, 0x99, 0x14, 0x40, 0xe4, 0xdb, 0x72, 0x84 } }; - -// {059C4566-4708-4ebf-8139-6A8EA5A9DFC8} -FOOGUIDDECL const GUID standard_commands::guid_main_previous = -{ 0x59c4566, 0x4708, 0x4ebf, { 0x81, 0x39, 0x6a, 0x8e, 0xa5, 0xa9, 0xdf, 0xc8 } }; - -// {18B1278A-F1BB-4b48-BC3D-6EC9EF80AD19} -FOOGUIDDECL const GUID standard_commands::guid_main_next_or_random = -{ 0x18b1278a, 0xf1bb, 0x4b48, { 0xbc, 0x3d, 0x6e, 0xc9, 0xef, 0x80, 0xad, 0x19 } }; - -// {42BDA765-30A8-40fa-BFA4-6A4E2F2B2CE9} -FOOGUIDDECL const GUID standard_commands::guid_main_random = -{ 0x42bda765, 0x30a8, 0x40fa, { 0xbf, 0xa4, 0x6a, 0x4e, 0x2f, 0x2b, 0x2c, 0xe9 } }; - -// {FCEF5262-7FA5-452e-A527-C14E0CB582DE} -FOOGUIDDECL const GUID standard_commands::guid_main_pause = -{ 0xfcef5262, 0x7fa5, 0x452e, { 0xa5, 0x27, 0xc1, 0x4e, 0xc, 0xb5, 0x82, 0xde } }; - -// {D3F83B15-D4AF-4586-8BD0-4EA415E31FE1} -FOOGUIDDECL const GUID standard_commands::guid_main_play = -{ 0xd3f83b15, 0xd4af, 0x4586, { 0x8b, 0xd0, 0x4e, 0xa4, 0x15, 0xe3, 0x1f, 0xe1 } }; - -// {8DEBC44E-EDA2-48d4-8696-31FC29D1F383} -FOOGUIDDECL const GUID standard_commands::guid_main_play_or_pause = -{ 0x8debc44e, 0xeda2, 0x48d4, { 0x86, 0x96, 0x31, 0xfc, 0x29, 0xd1, 0xf3, 0x83 } }; - -// {2DF17F25-80B9-4a43-B21D-620458FDDE1E} -FOOGUIDDECL const GUID standard_commands::guid_main_rg_set_album = -{ 0x2df17f25, 0x80b9, 0x4a43, { 0xb2, 0x1d, 0x62, 0x4, 0x58, 0xfd, 0xde, 0x1e } }; - -// {C26F1955-5753-4836-887F-84A563DD6DD9} -FOOGUIDDECL const GUID standard_commands::guid_main_rg_set_track = -{ 0xc26f1955, 0x5753, 0x4836, { 0x88, 0x7f, 0x84, 0xa5, 0x63, 0xdd, 0x6d, 0xd9 } }; - -// {8D2D808E-6AA2-455b-A2F1-CDB019328140} -FOOGUIDDECL const GUID standard_commands::guid_main_rg_disable = -{ 0x8d2d808e, 0x6aa2, 0x455b, { 0xa2, 0xf1, 0xcd, 0xb0, 0x19, 0x32, 0x81, 0x40 } }; - -// {C3378028-165F-4374-966C-2FA2E0FCD3A8} -FOOGUIDDECL const GUID standard_commands::guid_main_stop = -{ 0xc3378028, 0x165f, 0x4374, { 0x96, 0x6c, 0x2f, 0xa2, 0xe0, 0xfc, 0xd3, 0xa8 } }; - -// {EE057982-22F9-4862-A986-859E463316FB} -FOOGUIDDECL const GUID standard_commands::guid_main_stop_after_current = -{ 0xee057982, 0x22f9, 0x4862, { 0xa9, 0x86, 0x85, 0x9e, 0x46, 0x33, 0x16, 0xfb } }; - -// {11DC6526-73C4-44f0-91B1-DE5C2D26B0C7} -FOOGUIDDECL const GUID standard_commands::guid_main_volume_down = -{ 0x11dc6526, 0x73c4, 0x44f0, { 0x91, 0xb1, 0xde, 0x5c, 0x2d, 0x26, 0xb0, 0xc7 } }; - -// {A313E630-A04A-4ae8-B5B4-0A944AC964FF} -FOOGUIDDECL const GUID standard_commands::guid_main_volume_up = -{ 0xa313e630, 0xa04a, 0x4ae8, { 0xb5, 0xb4, 0xa, 0x94, 0x4a, 0xc9, 0x64, 0xff } }; - -// {4A36285B-B4AF-46ed-A1AA-6333057F485B} -FOOGUIDDECL const GUID standard_commands::guid_main_volume_mute = -{ 0x4a36285b, 0xb4af, 0x46ed, { 0xa1, 0xaa, 0x63, 0x33, 0x5, 0x7f, 0x48, 0x5b } }; - -// {2DC43C22-CA09-4ef9-A61E-7A0C1DAAE21E} -FOOGUIDDECL const GUID standard_commands::guid_main_add_directory = -{ 0x2dc43c22, 0xca09, 0x4ef9, { 0xa6, 0x1e, 0x7a, 0xc, 0x1d, 0xaa, 0xe2, 0x1e } }; - -// {FC89C278-4475-4853-96C9-F7F05E8CC837} -FOOGUIDDECL const GUID standard_commands::guid_main_add_files = -{ 0xfc89c278, 0x4475, 0x4853, { 0x96, 0xc9, 0xf7, 0xf0, 0x5e, 0x8c, 0xc8, 0x37 } }; - -// {9CA39D38-AC9B-4cca-B0CE-C0F62D188114} -FOOGUIDDECL const GUID standard_commands::guid_main_add_location = -{ 0x9ca39d38, 0xac9b, 0x4cca, { 0xb0, 0xce, 0xc0, 0xf6, 0x2d, 0x18, 0x81, 0x14 } }; - -// {73D6E69D-0DC9-4d5c-A7EE-FF4BE3896B08} -FOOGUIDDECL const GUID standard_commands::guid_main_add_playlist = -{ 0x73d6e69d, 0xdc9, 0x4d5c, { 0xa7, 0xee, 0xff, 0x4b, 0xe3, 0x89, 0x6b, 0x8 } }; - -// {55559142-7AEA-4c20-9B72-1D48E970A274} -FOOGUIDDECL const GUID standard_commands::guid_main_clear_playlist = -{ 0x55559142, 0x7aea, 0x4c20, { 0x9b, 0x72, 0x1d, 0x48, 0xe9, 0x70, 0xa2, 0x74 } }; - -// {BF72488F-36AC-46b3-A36D-193E60C79BC5} -FOOGUIDDECL const GUID standard_commands::guid_main_create_playlist = -{ 0xbf72488f, 0x36ac, 0x46b3, { 0xa3, 0x6d, 0x19, 0x3e, 0x60, 0xc7, 0x9b, 0xc5 } }; - -// {59E99BEE-42A3-4526-B06D-56C0C49F0BC1} -FOOGUIDDECL const GUID standard_commands::guid_main_highlight_playing = -{ 0x59e99bee, 0x42a3, 0x4526, { 0xb0, 0x6d, 0x56, 0xc0, 0xc4, 0x9f, 0xb, 0xc1 } }; - -// {D94393D4-9DBB-4e5c-BE8C-BE9CA80E214D} -FOOGUIDDECL const GUID standard_commands::guid_main_load_playlist = -{ 0xd94393d4, 0x9dbb, 0x4e5c, { 0xbe, 0x8c, 0xbe, 0x9c, 0xa8, 0xe, 0x21, 0x4d } }; - -// {EE1308C5-EBD2-48f1-959D-2627069C2E0F} -FOOGUIDDECL const GUID standard_commands::guid_main_next_playlist = -{ 0xee1308c5, 0xebd2, 0x48f1, { 0x95, 0x9d, 0x26, 0x27, 0x6, 0x9c, 0x2e, 0xf } }; - -// {486ECDA3-7BA2-49e9-BB44-4DB9DF9320C7} -FOOGUIDDECL const GUID standard_commands::guid_main_previous_playlist = -{ 0x486ecda3, 0x7ba2, 0x49e9, { 0xbb, 0x44, 0x4d, 0xb9, 0xdf, 0x93, 0x20, 0xc7 } }; - -// {69C778AA-B836-40a0-89CD-7A2E50C102CB} -FOOGUIDDECL const GUID standard_commands::guid_main_open = -{ 0x69c778aa, 0xb836, 0x40a0, { 0x89, 0xcd, 0x7a, 0x2e, 0x50, 0xc1, 0x2, 0xcb } }; - -// {EB7FB5A4-5904-4d2c-B66C-D882A3B15277} -FOOGUIDDECL const GUID standard_commands::guid_main_remove_playlist = -{ 0xeb7fb5a4, 0x5904, 0x4d2c, { 0xb6, 0x6c, 0xd8, 0x82, 0xa3, 0xb1, 0x52, 0x77 } }; - -// {C297BADB-8098-45a9-A5E8-B53A0D780CE3} -FOOGUIDDECL const GUID standard_commands::guid_main_remove_dead_entries = -{ 0xc297badb, 0x8098, 0x45a9, { 0xa5, 0xe8, 0xb5, 0x3a, 0xd, 0x78, 0xc, 0xe3 } }; - -// {D08C2921-7750-4979-98F9-3A513A31FF96} -FOOGUIDDECL const GUID standard_commands::guid_main_remove_duplicates = -{ 0xd08c2921, 0x7750, 0x4979, { 0x98, 0xf9, 0x3a, 0x51, 0x3a, 0x31, 0xff, 0x96 } }; - -// {D3A25E47-BA98-4e6b-95AD-A7502919EB75} -FOOGUIDDECL const GUID standard_commands::guid_main_rename_playlist = -{ 0xd3a25e47, 0xba98, 0x4e6b, { 0x95, 0xad, 0xa7, 0x50, 0x29, 0x19, 0xeb, 0x75 } }; - -// {0FDCFC65-9B39-445a-AA88-4D245F217480} -FOOGUIDDECL const GUID standard_commands::guid_main_save_all_playlists = -{ 0xfdcfc65, 0x9b39, 0x445a, { 0xaa, 0x88, 0x4d, 0x24, 0x5f, 0x21, 0x74, 0x80 } }; - -// {370B720B-4CF7-465b-908C-2D2ADD027900} -FOOGUIDDECL const GUID standard_commands::guid_main_save_playlist = -{ 0x370b720b, 0x4cf7, 0x465b, { 0x90, 0x8c, 0x2d, 0x2a, 0xdd, 0x2, 0x79, 0x0 } }; - -// {A6CFC2A8-56B3-4d12-88E7-0237961AC47E} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_search = -{ 0xa6cfc2a8, 0x56b3, 0x4d12, { 0x88, 0xe7, 0x2, 0x37, 0x96, 0x1a, 0xc4, 0x7e } }; - -// {383D4E8D-7E30-4fb8-B5DD-8C975D89E58E} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_crop = -{ 0x383d4e8d, 0x7e30, 0x4fb8, { 0xb5, 0xdd, 0x8c, 0x97, 0x5d, 0x89, 0xe5, 0x8e } }; - -// {E0EEA319-E282-4e6c-8B82-4DFD42A1D4ED} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_remove = -{ 0xe0eea319, 0xe282, 0x4e6c, { 0x8b, 0x82, 0x4d, 0xfd, 0x42, 0xa1, 0xd4, 0xed } }; - -// {F0845920-7F6D-40ac-B2EB-3D00C2C8260B} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_sel_invert = -{ 0xf0845920, 0x7f6d, 0x40ac, { 0xb2, 0xeb, 0x3d, 0x0, 0xc2, 0xc8, 0x26, 0xb } }; - -// {29910B33-79E9-40da-992B-5A4AA4281F78} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_undo = -{ 0x29910b33, 0x79e9, 0x40da, { 0x99, 0x2b, 0x5a, 0x4a, 0xa4, 0x28, 0x1f, 0x78 } }; - -// {02D89A8A-5F7D-41c3-A215-6731D8621036} -FOOGUIDDECL const GUID standard_commands::guid_main_show_console = -{ 0x2d89a8a, 0x5f7d, 0x41c3, { 0xa2, 0x15, 0x67, 0x31, 0xd8, 0x62, 0x10, 0x36 } }; - -// {E6970E91-33BE-4288-AC01-4B02F07B5D38} -FOOGUIDDECL const GUID standard_commands::guid_main_play_cd = -{ 0xe6970e91, 0x33be, 0x4288, { 0xac, 0x1, 0x4b, 0x2, 0xf0, 0x7b, 0x5d, 0x38 } }; - -// {1073AB1D-38ED-4957-8B06-38BC878C1F40} -FOOGUIDDECL const GUID standard_commands::guid_main_restart_resetconfig = -{ 0x1073ab1d, 0x38ed, 0x4957, { 0x8b, 0x6, 0x38, 0xbc, 0x87, 0x8c, 0x1f, 0x40 } }; - -// {FDC8A1C2-93EF-4415-8C20-60B6517F0B5F} -FOOGUIDDECL const GUID standard_commands::guid_main_record = -{ 0xfdc8a1c2, 0x93ef, 0x4415, { 0x8c, 0x20, 0x60, 0xb6, 0x51, 0x7f, 0xb, 0x5f } }; - -// {45EB37D2-3CD9-4f0a-9B20-8EAE649D7A9F} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_moveback = -{ 0x45eb37d2, 0x3cd9, 0x4f0a, { 0x9b, 0x20, 0x8e, 0xae, 0x64, 0x9d, 0x7a, 0x9f } }; - -// {02298938-596A-41f7-A398-19766A06E6EB} -FOOGUIDDECL const GUID standard_commands::guid_main_playlist_moveforward = -{ 0x2298938, 0x596a, 0x41f7, { 0xa3, 0x98, 0x19, 0x76, 0x6a, 0x6, 0xe6, 0xeb } }; - -// {DE5A47E0-28BE-4c49-BEEA-F0DE65C489A4} -FOOGUIDDECL const GUID playlist_loader_v2::class_guid= -{ 0xde5a47e0, 0x28be, 0x4c49, { 0xbe, 0xea, 0xf0, 0xde, 0x65, 0xc4, 0x89, 0xa4 } }; diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/initquit.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/initquit.h deleted file mode 100644 index 4e7fc3672..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/initquit.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _INITQUIT_H_ -#define _INITQUIT_H_ - -#include "service.h" - -//init/quit callback, on_init is called after main window has been created, on_quit is called before main window is destroyed -class NOVTABLE initquit : public service_base -{ -public: - virtual void on_init() {} - virtual void on_quit() {} - virtual void on_system_shutdown() {}//called instead of on_quit() when system is shutting down - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -template -class initquit_factory : public service_factory_single_t {}; - -class initquit_autoreg : public service_impl_single_t -{ -private: - service_factory_single_ref_t * p_factory; -public: - initquit_autoreg() {p_factory = new service_factory_single_ref_t(*this);} - ~initquit_autoreg() {delete p_factory;} -}; - -class initquit_simple : public initquit_autoreg -{ - void (*func)(bool is_init); - virtual void on_init() {func(true);} - virtual void on_quit() {func(false);} -public: - initquit_simple(void (*p_func)(bool is_init)) {func=p_func;} -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/input.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/input.cpp deleted file mode 100644 index 1f9b72c8b..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/input.cpp +++ /dev/null @@ -1,497 +0,0 @@ -#include "foobar2000.h" -#include - -input* input::g_open(reader * r,file_info * info,unsigned flags,__int64 * modtime,__int64 * filesize,bool * new_info) -{ - TRACK_CALL_TEXT("input::g_open"); - - service_enum_t e; - input * i; - const char * filename = info->get_file_path(); - - if (r)//check mime types first - { - string8 content_type; - if (r->get_content_type(content_type)) - { - for(i=e.first();i;i = e.next()) - { - if (i->needs_reader() && i->is_our_content_type(filename,content_type)) - { - if (i->open_ex(r,info,flags,modtime,filesize,new_info)) return i; - if (!r->seek(0)) {i->service_release(); return 0;} - } - i->service_release(); - } - } - } - - string_extension_8 extension(filename); - for(i=e.first();i;i = e.next()) - { - if (!!r == !!i->needs_reader()) - { - if (i->test_filename(filename,extension)) - { - if (i->open_ex(r,info,flags,modtime,filesize,new_info)) return i; - if (r) - { - if (!r->seek(0)) {i->service_release();return 0;} - } - } - } - i->service_release(); - } - return 0; -} - -static bool g_get_info_internal(unsigned flags,file_info * info,reader * r,__int64 * modtime,__int64 * filesize,bool * b_new_info) -{ - //return 0 on failure, 1 on success - bool my_reader = false; - const char * filename = info->get_file_path(); - string_extension_8 extension(filename); - bool rv = false; - - if (r==0) //try readerless inputs first - { - service_enum_t e; - input * i; - for(i=e.first();i;i = e.next()) - { - rv = false; - if (!i->needs_reader()) - { - if (i->test_filename(filename,extension)) - rv = i->open_ex(0,info,flags,modtime,filesize,b_new_info); - } - i->service_release(); - if (rv) return true; - } - - r = file::g_open(info->get_file_path(),reader::MODE_READ); - if (r==0) - { - return false; - } - my_reader = true; - } - - service_enum_t e; - input * i; - - {//check content type - string8 content_type; - if (r->get_content_type(content_type)) - { - for(i=e.first();i;i = e.next()) - { - rv = false; - if (i->needs_reader() && i->is_our_content_type(info->get_file_path(),content_type)) - { - if (!r->seek(0)) - { - i->service_release(); - if (my_reader) r->reader_release(); - return false; - } - rv = i->open_ex(r,info,flags,modtime,filesize,b_new_info); - } - i->service_release(); - if (rv) break; - } - } - } - - - if (!rv)//if no luck with content type, proceed with classic open method - { - for(i=e.first();i;i = e.next()) - { - rv = false; - if (i->needs_reader()) - { - if (!r->seek(0)) - { - i->service_release(); - if (my_reader) r->reader_release(); - return false; - } - if (i->test_filename(filename,extension)) - rv= i->open_ex(r,info,flags,modtime,filesize,b_new_info); - } - i->service_release(); - if (rv) break; - } - } - - if (my_reader) r->reader_release(); - - return rv; -} - -bool input::g_check_info(file_info * info,reader * r,__int64 * modtime,__int64 * filesize) -{ - if (modtime==0) return false; - __int64 time = *modtime; - __int64 size = -1; - bool new_info = false; - if (!g_get_info_internal(0,info,r,&time,&size,&new_info)) return false; - if (new_info) - { - *modtime = time; - *filesize = size; - return true; - } - return false; -} - -bool input::g_get_info(file_info * info,reader * r,__int64 * modtime,__int64 * filesize) -{ - return g_get_info_internal(OPEN_FLAG_GET_INFO,info,r,modtime,filesize,0); -} - -bool input::g_test_filename(const char * filename) -{ - service_enum_t e; - input * i; - string_extension_8 extension(filename); - for(i=e.first();i;i = e.next()) - { - bool rv = false; - rv = i->test_filename(filename,extension); - i->service_release(); - if (rv) return true; - } - return false; -} - -int input_pcm::run(audio_chunk * chunk) -{ - int bps,srate,nch; - void * source; - int size; - int rv = get_samples_pcm(&source,&size,&srate,&bps,&nch); - if (rv>0) chunk->set_data_fixedpoint(source,size,srate,nch,bps); - return rv; -} - -input::set_info_t input::g_set_info_readerless(const file_info * info,__int64 * modtime,__int64 * filesize) -{ - set_info_t rv = SET_INFO_FAILURE; - const char * filename = info->get_file_path(); - string_extension_8 extension(filename); - service_enum_t e; - input * i; - for(i=e.first();i;i = e.next()) - { - rv = SET_INFO_FAILURE; - if (!i->needs_reader()) - { - if (i->test_filename(filename,extension)) - rv = i->set_info_ex(0,info,modtime,filesize); - } - i->service_release(); - if (rv != SET_INFO_FAILURE) return rv; - } - return SET_INFO_FAILURE; -} - -input::set_info_t input::g_set_info_reader(const file_info * info,reader * r,__int64 * modtime,__int64 * filesize) -{ - const char * filename = info->get_file_path(); - string_extension_8 extension(filename); - set_info_t rv = SET_INFO_FAILURE; - - service_enum_t e; - input * i; - bool got_busy = false; - for(i=e.first();i;i = e.next()) - { - rv = SET_INFO_FAILURE; - if (i->needs_reader()) - { - r->seek(0); - if (i->test_filename(filename,extension)) - rv = i->set_info_ex(r,info,modtime,filesize); - } - i->service_release(); - if (rv==SET_INFO_SUCCESS) break; - else if (rv==SET_INFO_BUSY) got_busy = true; - } - - return rv == SET_INFO_SUCCESS ? SET_INFO_SUCCESS : got_busy ? SET_INFO_BUSY : SET_INFO_FAILURE; -} - - -input::set_info_t input::g_set_info(const file_info * info,reader * r,__int64 * modtime,__int64 * filesize) -{ - bool my_reader = false; - set_info_t rv = SET_INFO_FAILURE; - - if (r==0) - { - rv = g_set_info_readerless(info,modtime,filesize); - if (rv != SET_INFO_FAILURE) return rv; - - r = file::g_open(info->get_file_path(),reader::MODE_WRITE_EXISTING); - if (r==0) - { - int flags = file::g_exists(info->get_file_path()); - if (flags & file::FILE_EXISTS_WRITEABLE) return SET_INFO_BUSY; - else return SET_INFO_FAILURE; - } - my_reader = true; - } - - - rv = g_set_info_reader(info,r,modtime,filesize); - - if (my_reader) r->reader_release(); - - return rv; -} - - -bool input::is_entry_dead(const playable_location * entry) -{ - const char * path = entry->get_path(); - if (file::g_dont_read_infos(path)) return false; - int exists = file::g_exists(path); - if (exists) - { - return !g_test_filename(path); - } - else - { - //special fix to keep bloody flac tag updating hack from breaking things - //allow non-existent files ONLY when some readerless input accepts them and no reader-based inputs accept them - string_extension_8 extension(path); - service_enum_t e; - input * i; - bool found_reader = false, found_readerless = false; - for(i=e.first();i;i = e.next()) - { - if (i->test_filename(path,extension)) - { - if (i->needs_reader()) - found_reader = true; - else - found_readerless = true; - } - i->service_release(); - } - - return ! ( found_readerless && !found_reader ); - } -} - -bool input_test_filename_helper::test_filename(const char * filename) -{ - if (!inited) - { - service_enum_t e; - input * i; - for(i=e.first();i;i = e.next()) - inputs.add_item(i); - inited=true; - } - - string_extension_8 extension(filename); - - int n,m=inputs.get_count(); - for(n=0;ntest_filename(filename,extension)) return true; - } - return false; -} - -input_test_filename_helper::~input_test_filename_helper() -{ - unsigned n; - for(n=0;nservice_release(); - inputs.remove_all(); -} - -void input_file_type::build_openfile_mask(string_base & out, bool b_include_playlists) -{ - string8_fastalloc name,mask,mask_alltypes,out_temp; - - if (b_include_playlists) - { - playlist_loader * ptr; - service_enum_t e; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (!mask.is_empty()) mask += ";"; - mask += "*."; - mask += ptr->get_extension(); - } - out_temp += "Playlists"; - out_temp += "|"; - out_temp += mask; - out_temp += "|"; - - if (!mask_alltypes.is_empty()) - { - if (mask_alltypes[mask_alltypes.length()-1]!=';') - mask_alltypes += ";"; - } - mask_alltypes += mask; - } - - { - input_file_type * ptr; - service_enum_t e; - for(ptr=e.first();ptr;ptr=e.next()) - { - unsigned n,m = ptr->get_count(); - for(n=0;nget_name(n,name) && ptr->get_mask(n,mask)) - { - if (!strchr(name,'|') && !strchr(mask,'|')) - { - out_temp += name; - out_temp += "|"; - out_temp += mask; - out_temp += "|"; - if (!mask_alltypes.is_empty()) - { - if (mask_alltypes[mask_alltypes.length()-1]!=';') - mask_alltypes += ";"; - } - mask_alltypes += mask; - } - } - } - ptr->service_release(); - } - } - out.reset(); - out += "All files|*.*|"; - if (!mask_alltypes.is_empty()) - { - out += "All supported types|"; - out += mask_alltypes; - out += "|"; - } - out += out_temp; -} - -static bool open_ex_internal(input * i,reader * r,file_info * info,unsigned flags,__int64 * modtime,__int64 * filesize,bool * b_new_info) -{ - if (!!r != !!i->needs_reader()) return false; - if (r) - { - __int64 newmodtime; - __int64 newfilesize; - if (modtime) - { - newmodtime = r->get_modification_time(); - if (newmodtime != *modtime) flags |= input::OPEN_FLAG_GET_INFO; - } - if (filesize) - { - newfilesize = r->get_length(); - if (newfilesize != *filesize) flags |= input::OPEN_FLAG_GET_INFO; - } - - if (!(flags&(input::OPEN_FLAG_GET_INFO|input::OPEN_FLAG_DECODE))) return true; - - if (!i->open(r,info,flags)) return false; - - if (b_new_info && (flags & input::OPEN_FLAG_GET_INFO)) *b_new_info = true; - - if (filesize) *filesize = r->get_length(); - if (modtime) *modtime = newmodtime; - - return true; - } - else - { - - if (!i->open(0,info,flags)) return false; - - if (b_new_info && (flags & input::OPEN_FLAG_GET_INFO)) *b_new_info = true; - - if (filesize) *filesize = -1; - if (modtime) *modtime = 0; - - - - return true; - } -} - -bool input::open_ex(reader * r,file_info * info,unsigned flags,__int64 * modtime,__int64 * filesize,bool * b_new_info) -{ - { - input_v2 * this_v2 = service_query_t(input_v2,this); - if (this_v2) - { - bool rv = this_v2->open_ex(r,info,flags,modtime,filesize,b_new_info); - this_v2->service_release(); - return rv; - } - } - - return open_ex_internal(this,r,info,flags,modtime,filesize,b_new_info); -} - -bool input_v2::open_ex(reader * r,file_info * info,unsigned flags,__int64 * modtime,__int64 * filesize,bool * b_new_info) -{//to be overridden if needed (possibly needed for weird readerless inputs), this implementation is the default behavior - return open_ex_internal(this,r,info,flags,modtime,filesize,b_new_info); -} - -static input::set_info_t set_info_ex_internal(input * i,reader *r,const file_info * info,__int64 * modtime,__int64 * filesize) -{ - input::set_info_t rv = i->set_info(r,info); - if (r) - { - if (modtime) *modtime = r->get_modification_time(); - if (filesize) *filesize = r->get_length(); - } - else - { - if (modtime) *modtime = 0; - if (filesize) *filesize = -1; - } - return rv; -} - -input::set_info_t input::set_info_ex(reader *r,const file_info * info,__int64 * modtime,__int64 * filesize) -{ - { - input_v2 * this_v2 = service_query_t(input_v2,this); - if (this_v2) - { - set_info_t rv = this_v2->set_info_ex(r,info,modtime,filesize); - this_v2->service_release(); - return rv; - } - } - - return set_info_ex_internal(this,r,info,modtime,filesize); -} - -input::set_info_t input_v2::set_info_ex(reader *r,const file_info * info,__int64 * modtime,__int64 * filesize) -{ - return set_info_ex_internal(this,r,info,modtime,filesize); -} - -bool input::is_reopen_safe() -{ - bool rv = false; - input_v2 * this_v2 = service_query_t(input_v2,this); - if (this_v2) - { - rv = this_v2->is_reopen_safe(); - this_v2->service_release(); - } - return rv; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/input.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/input.h deleted file mode 100644 index f166dd897..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/input.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef _INPUT_H_ -#define _INPUT_H_ - -#include "service.h" - -#include "reader.h" -#include "file_info.h" - -#include "audio_chunk.h" - -/*************************** -how input class is used - - case 0: checking filename - create => test_filename() => destroy - - case 1: info reading - create => test_filename() => open(r,info,OPEN_FLAG_GET_INFO) => destroy - - case 2: playback - create => testfilename() => open(r,info,OPEN_FLAG_DECODE | [blah blah blah]) => run() .... => destroy - note: you must fill file_info stuff too if you get OPEN_FLAG_GET_INFO - - case 3: info writing - create => testfilename() => set_info(r,info) => destroy - - - there's no possibility of opening different files from the same input instance. - - when you get set_info() call, you have exclusive write access to the file; if user attempts to update currently played file, fb2k will wait until the file is free - - NOTE: when trying to decode unseekable source (reader->can_seek() returns 0), you should expect the reader you get to be able to seek back up to 64k - - - REMINDER: ALL strings are UTF-8 - - -***************************/ - -class NOVTABLE input : public service_base -{ -public: - enum - { - OPEN_FLAG_GET_INFO = 1,//if specified, you must pass all metadata/etc to file_info, otherwise you dont need to pass any data to file_info (but it wont blow up if you do, it will be just ignored) - OPEN_FLAG_DECODE = 2,//open for decoding - OPEN_FLAG_NO_SEEKING = 4,//when combined with OPEN_FLAG_DECODE, informs you that you don't need to be able to seek (still need to extract track length though) - OPEN_FLAG_NO_LOOPING = 8,//when combined with OPEN_FLAG_DECODE, you're being replaygainscanned or something, if your input can decode indefinitely, disable that - }; - - //you should expect either OPEN_FLAG_GET_INFO alone, or OPEN_FLAG_DECODE (possibly with modifiers), or both OPEN_FLAG_GET_INFO and OPEN_FLAG_DECODE (extract info and start decoding) - - enum set_info_t - { - SET_INFO_SUCCESS, - SET_INFO_FAILURE, - SET_INFO_BUSY, - }; - - virtual bool open(reader * r,file_info * info,unsigned flags)=0; - //caller is responsible for deleting the reader; reader pointer is valid until you get deleted; pass all your metadata/etc to info - //flags => see OPEN_FLAG_* above - //lazy solution: ignore flags, fill info and set up decoder - //somewhat more efficient solution: avoid either setting up decoder or filling info depending on flags - - virtual bool is_our_content_type(const char * url,const char * type) {return 0;}//for mime type checks, before test_filename - virtual bool test_filename(const char * full_path,const char * extension)=0; //perform extension/filename tests, return 1 if the file might be one of our types; do ONLY file extension checks etc, no opening; doesn't hurt if you return 1 for a file that doesn't actually belong to you - - - virtual set_info_t set_info(reader *r,const file_info * info)=0;//reader with exclusive write access - - virtual bool needs_reader() {return true;}//return if you read files or not (if you return 0, reader pointer in open/set_info will be null - virtual int run(audio_chunk * chunk)=0; - // return 1 on success, -1 on failure, 0 on EOF - - virtual bool seek(double seconds)=0;//return 1 on success, 0 on failure; if EOF, return 1 and return 0 in next run() pass - - virtual bool can_seek() {return true;}//return 0 if the file you're playing can't be seeked - - virtual void abort() {} //async call, abort current seek()/run(), ensure multithread safety on your side - - virtual bool get_dynamic_info(file_info * out, double * timestamp_delta,bool * b_track_change) {return false;} - //for dynamic song titles / VBR bitrate / etc - //out initially contains currently displayed info (either last get_dynamic_info result or current database info) - //timestamp_delta - you can use it to tell the core when this info should be displayed (in seconds, relative to first sample of last decoded chunk), initially set to 0 - //get_dynamic_info is called after each run() (or not called at all if caller doesn't care about dynamic info) - //return false to keep old info, or true to modify it - //set b_track_change to true if you want to indicate new song - //please keep in mind that updating dynamic info (returning true from this func) generates some overhead (mallocing to pass new info around, play_callback calls, GUI updates and titleformatting), ; if you implement useless features like realtime vbr bitrate display, make sure that they are optional and disabled by default - - static input* g_open(reader * r,file_info * info,unsigned flags,__int64 * modtime = 0,__int64 * filesize=0,bool * new_info=0); - static bool g_test_filename(const char * fn); - static bool g_get_info(file_info * info,reader * r = 0,__int64 * modtime = 0,__int64 * filesize=0); - static bool g_check_info(file_info * info,reader * r = 0,__int64 * modtime = 0,__int64 * filesize=0);//loads info if newer - static set_info_t g_set_info_readerless(const file_info * info,__int64 * modtime = 0,__int64 * filesize=0); - static set_info_t g_set_info_reader(const file_info * info,reader * r, __int64 * modtime = 0,__int64 * filesize=0); - static set_info_t g_set_info(const file_info * info,reader * r = 0,__int64 * modtime = 0,__int64 * filesize=0); - static bool is_entry_dead(const playable_location * entry);//tests if playlist_entry appears to be alive or not - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - bool open_ex(reader * r,file_info * info,unsigned flags,__int64 * modification_time,__int64 * file_size,bool * new_info); - set_info_t set_info_ex(reader *r,const file_info * info,__int64 * modtime,__int64 * filesize);//reader with exclusive write access - bool is_reopen_safe(); -}; - -class input_v2 : public input//extension for readerless operations in 0.8, to allow modification_time processing -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return input::service_query(guid); - } - - - //time is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601; 0 for invalid/unknown time - virtual bool open_ex(reader * r,file_info * info,unsigned flags,__int64 * modification_time,__int64 * file_size,bool * new_info); - //if modification_time pointer is null, open as usual - //otherwise, if file time is different than *modification_time, set *modification_time to modification time and proceed as if flags had OPEN_FLAG_GET_INFO - //if new_info pointer isnt null, set *new_info to true/false depending if you used OPEN_FLAG_GET_INFO - - virtual set_info_t set_info_ex(reader *r,const file_info * info,__int64 * modtime,__int64 * filesize);//reader with exclusive write access - - virtual bool get_album_art(const playable_location * src,reader * in,reader * out) {return false;};//reserved - - virtual bool is_reopen_safe() {return false;} - -}; - -template -class input_factory : public service_factory_t {}; - - -class input_file_type : public service_base -{ -public: - virtual unsigned get_count()=0; - virtual bool get_name(unsigned idx,string_base & out)=0;//e.g. "MPEG file" - virtual bool get_mask(unsigned idx,string_base & out)=0;//e.g. "*.MP3;*.MP2"; separate with semicolons - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - static void build_openfile_mask(string_base & out,bool b_include_playlists=true); -}; - -class input_file_type_i : public service_impl_single_t -{ - const char * name, * mask; -public: - virtual unsigned get_count() {return 1;} - input_file_type_i(const char * p_name, const char * p_mask) : name(p_name), mask(p_mask) {} - virtual bool get_name(unsigned idx,string_base & out) {if (idx==0) {out = name; return true;} else return false;} - virtual bool get_mask(unsigned idx,string_base & out) {if (idx==0) {out = mask; return true;} else return false;} -}; - -template -class input_file_type_factory : public service_factory_t {}; - -#define DECLARE_FILE_TYPE(NAME,MASK) \ - namespace { static input_file_type_i g_filetype_instance(NAME,MASK); \ - static service_factory_single_ref_t g_filetype_service(g_filetype_instance); } - - -//USAGE: DECLARE_FILE_TYPE("Blah file","*.blah;*.bleh"); - -#include "input_helpers.h" - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/input_helpers.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/input_helpers.cpp deleted file mode 100644 index 2d1b2efad..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/input_helpers.cpp +++ /dev/null @@ -1,348 +0,0 @@ -#include "foobar2000.h" - -input_helper::input_helper() -{ - seek_to = -1; - full_buffer_limit = 0; - p_input=0; - p_reader=0; - reader_overridden = false; - b_no_seek = false; - b_no_loop = false; - b_want_info = true; - b_aborting = false; -} - -input_helper::~input_helper() -{ - close(); -} - -bool input_helper::open_internal(file_info * info,reader * p_reader_override,__int64 *modification_time,__int64 * file_size,bool * new_info) -{ - TRACK_CALL_TEXT("input_helper::open_internal"); - - info->meta_remove_all(); - info->info_remove_all(); - - - if (attempt_reopen_internal(info,p_reader_override,modification_time,file_size,new_info)) - { - return true; - } - - const char * path = info->get_file_path();//file_info always has canonic path - - sync.enter(); - - close_input_internal(); - - sync.leave(); - - - if (p_reader_override) - { - sync.enter(); - close_reader_internal(); - override_reader(p_reader_override); - sync.leave(); - } - else if (p_reader && !stricmp_utf8(my_location.get_path(),path) && p_reader->can_seek()) - { - p_reader->seek(0); - } - else - { - sync.enter(); - close_reader_internal(); - sync.leave(); - } - - if (p_reader == 0) - { - input * p_input_temp = input::g_open(0,info,get_open_flags(),modification_time,file_size,new_info); - if (p_input_temp) - { - sync.enter(); - p_input = p_input_temp; - sync.leave(); - return true; - } - - sync.enter(); - - p_reader = file::g_get_reader(path); - - sync.leave(); - - if (p_reader==0) return false; - - if (p_reader->open(path,reader::MODE_READ)==0) {close();return false;} - - setup_fullbuffer(); - } - - - - { - input * temp = input::g_open(p_reader,info,get_open_flags(),modification_time,file_size,new_info); - if (temp) - { - sync.enter(); - p_input = temp; - sync.leave(); - } - else {close();return false;} - } - - my_location.copy(info->get_location()); - - seek_to = -1; - - return true; -} - -bool input_helper::open(file_info * info,reader * p_reader_override) -{ - b_want_info = true; - return open_internal(info,p_reader_override,0,0,0); -} - -bool input_helper::open_noinfo(file_info * info, reader * p_reader_override) -{ - b_want_info = false; - return open_internal(info,p_reader_override,0,0,0); -} - -bool input_helper::open(const playable_location * src,reader * p_reader_override) -{ - b_want_info = false; - file_info_i_full info(src); - return open_internal(&info,p_reader_override,0,0,0); -} - -bool input_helper::open(metadb_handle * p_handle, reader * p_reader_override) -{ - bool l_want_info = !p_handle->handle_query(0,true); - - __int64 time = p_handle->handle_get_modification_time(); - __int64 newtime = time; - __int64 file_size = p_handle->handle_get_file_size(); - bool b_new_info = false; - - b_want_info = l_want_info; - file_info_i_full info(p_handle->handle_get_location()); - bool rv = open_internal(&info,p_reader_override,&newtime,&file_size,&b_new_info); - if (rv) - { - if (b_new_info) p_handle->handle_hint_ex(&info,newtime,file_size,true); - } - else - { - if (input::is_entry_dead(p_handle->handle_get_location())) - p_handle->handle_entry_dead(); - } - return rv; -} - -void input_helper::close_input_internal() -{ - if (p_input) - { - p_input->service_release(); - p_input = 0; - } -} - -void input_helper::close_reader_internal() -{ - if (p_reader) - { - if (!reader_overridden) p_reader->service_release(); - p_reader=0; - reader_overridden = false; - } -} - - -void input_helper::close() -{ - TRACK_CALL_TEXT("input_helper::close"); - insync(sync); - close_input_internal(); - close_reader_internal(); -} - -bool input_helper::is_open() {return !!p_input;} - -int input_helper::run(audio_chunk * chunk)//fucko: syncing this will break abort -{ - chunk->reset(); - - if (p_input==0) return -1; - - if (seek_to>=0) - { - double target = seek_to; - seek_to = -1; - - { - TRACK_CALL_TEXT("input::seek"); - if (!p_input->seek(target)) return -1; - } - } - - int rv; - - { - TRACK_CALL_TEXT("input::seek::run"); - rv = p_input->run(chunk); - } - - if (rv>0 && !chunk->is_valid()) - { - console::error("input::run() produced invalid chunk:"); - console::info_location(&my_location); - chunk->reset(); - rv = -1; - } - - return rv; -} - -bool input_helper::seek(double seconds) -{ - insync(sync); - if (!p_input || b_no_seek) return false; - seek_to = seconds; - return true; -} - -bool input_helper::can_seek() -{ - insync(sync); - return p_input ? p_input->can_seek() : 0; -} - -void input_helper::abort() -{ - TRACK_CALL_TEXT("input_helper::abort"); - insync(sync); - b_aborting = true; - if (p_reader) p_reader->abort(); - if (p_input) p_input->abort(); -} - -void input_helper::on_idle() -{ - insync(sync); - if (p_reader) p_reader->on_idle(); -} - -bool input_helper::get_dynamic_info(file_info * out,double * timestamp_delta, bool * b_track_change) -{ - TRACK_CALL_TEXT("input_helper::get_dynamic_info"); - insync(sync); - return p_input ? p_input->get_dynamic_info(out,timestamp_delta,b_track_change) : false; -} - -bool input_helper::attempt_reopen_internal(file_info * info,reader * p_reader_override,__int64 * modification_time,__int64* file_size,bool * new_info) -{ - TRACK_CALL_TEXT("input_helper::attempt_reopen_internal"); - assert(sync.get_lock_count_check()==0); - const char * path = info->get_file_path(); - - bool b_reopen_available,b_same_file; - sync.enter(); - b_same_file = p_input && !p_reader_override && my_location.compare(info->get_location())==0 && p_input->can_seek(); - if (!b_same_file) - b_reopen_available = !(!p_input || (p_reader_override && !p_reader) || !p_input->is_reopen_safe() || !p_input->test_filename(path,string_extension(path))); - sync.leave(); - if (b_same_file && !b_want_info) - { - return p_input->seek(0); - } - else if (!b_reopen_available) return false; - - if (p_reader_override) - {//caller wants us to get their reader - sync.enter(); - close_reader_internal(); - override_reader(p_reader_override); - sync.leave(); - } - else if (p_reader && !stricmp_utf8(my_location.get_path(),path) && p_reader->can_seek()) - {//same file - p_reader->seek(0); - } - else if (p_reader) - {//different file - sync.enter(); - close_reader_internal(); - p_reader = file::g_get_reader(path); - sync.leave(); - if (p_reader==0) return false; - if (p_reader->open(path,reader::MODE_READ) == 0) - { - sync.enter(); - close_reader_internal(); - sync.leave(); - return false; - } - setup_fullbuffer(); - } - //else must be readerless input - - if (p_input->open_ex(p_reader,info,get_open_flags(),modification_time,file_size,new_info)) - { - my_location.copy(info->get_location()); - return true; - } - else return false; -} - -void input_helper::override_reader(reader* p_reader_override) -{ - assert(sync.get_lock_count_check()>0); - assert(p_reader == 0); - p_reader = p_reader_override; - reader_overridden = !!p_reader_override; -} - -void input_helper::setup_fullbuffer() -{ - assert(p_reader); - assert(sync.get_lock_count_check()==0); - if (full_buffer_limit>0) - { - __int64 size = p_reader->get_length(); - if (size>0 && size<=full_buffer_limit) - { - reader * temp = reader_membuffer::create(p_reader,p_reader->get_modification_time()); - if (temp) - { - sync.enter(); - p_reader->service_release(); - p_reader = temp; - sync.leave(); - } - } - } -} - - -unsigned input_helper::get_open_flags() -{ - return input::OPEN_FLAG_DECODE | (b_want_info ? input::OPEN_FLAG_GET_INFO : 0) | (b_no_seek ? input::OPEN_FLAG_NO_SEEKING : 0) | (b_no_loop ? input::OPEN_FLAG_NO_LOOPING : 0); -} - -void input_helper::override(const playable_location * new_location,input * new_input,reader * new_reader) -{ - insync(sync); - close(); - if (new_location) my_location.copy(new_location); - else my_location.copy(make_playable_location("UNKNOWN",0)); - p_input = new_input; - p_reader = new_reader; - seek_to = -1; -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/input_helpers.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/input_helpers.h deleted file mode 100644 index b76e3e0ba..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/input_helpers.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef _INPUT_HELPERS_H_ -#define _INPUT_HELPERS_H_ - -#include "input.h" - -class NOVTABLE input_pcm : public input -{ -public: - virtual int run(audio_chunk * chunk); -protected: - virtual int get_samples_pcm(void ** buffer,int * size,int * srate,int * bps,int * nch)=0;//same return value as input::run() -}; - -class input_helper//takes care of opening inputs etc -{ -private: - critical_section sync; - playable_location_i my_location; - input * p_input; - reader * p_reader; - __int64 full_buffer_limit; - bool b_aborting; - bool reader_overridden; - bool b_no_seek,b_no_loop,b_want_info; - double seek_to; - - bool open_file_internal(const char * path,reader * p_reader_override); - bool attempt_reopen_internal(file_info * info,reader * p_reader_override,__int64 * modtime,__int64* filesize,bool * new_info); - bool open_internal(file_info * info,reader * p_reader_override,__int64 * modtime,__int64* filesize,bool * new_info); - void close_input_internal(); - void close_reader_internal(); - void override_reader(reader*); - void setup_fullbuffer(); - unsigned get_open_flags(); -public: - input_helper(); - ~input_helper(); - bool open(file_info * info,reader * p_reader_override = 0); - bool open_noinfo(file_info * info, reader * p_reader_override=0); - bool open(const playable_location * src,reader * p_reader_override = 0);//helper - inline bool open(const char * path,reader * p_reader_override = 0) - {return open(make_playable_location(path,0),p_reader_override);} - - bool open(class metadb_handle * p_handle, reader * p_reader_override=0); - - - - - void override(const playable_location * new_location,input * new_input,reader * new_reader); - - void close(); - bool is_open(); - int run(audio_chunk * chunk); - bool seek(double seconds); - bool can_seek(); - void abort(); - void set_full_buffer(__int64 val) {full_buffer_limit = val;}//default 0 to disable, any positive value to set upper file size limit for full file buffering - void on_idle(); - bool get_dynamic_info(file_info * out,double *timestamp_delta,bool *b_track_change); - - //call these before opening - inline void hint_no_seeking(bool state) {b_no_seek = state;} - inline void hint_no_looping(bool state) {b_no_loop = state;} - - bool open_errorhandled(class metadb_handle * p_handle, reader * p_reader_override=0); - int run_errorhandled(audio_chunk * chunk); - bool seek_errorhandled(double seconds); - void close_errorhandled(); -}; - -class input_test_filename_helper//avoids bloody bottleneck with creating inputs when mass-testing filenames -{ - ptr_list_t inputs; - bool inited; -public: - inline input_test_filename_helper() {inited=false;} - - bool test_filename(const char * filename); - ~input_test_filename_helper(); -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/interface_helper.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/interface_helper.h deleted file mode 100644 index 9bc3c8a36..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/interface_helper.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _PTR_LIST_INTERFACE_H_ -#define _PTR_LIST_INTERFACE_H_ - -#include "../../pfc/pfc.h" - - -//DEPRECATED (wheee) - -#define make_string_interface(blah) blah; - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_item.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_item.h deleted file mode 100644 index 6e7dd7f67..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_item.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef _FOOBAR2000_MENU_ITEM_H_ -#define _FOOBAR2000_MENU_ITEM_H_ - -#include "service.h" -#include "interface_helper.h" -#include "metadb_handle.h" - -class NOVTABLE menu_item : public service_base -{ -public: - enum type - { - TYPE_MAIN, - TYPE_CONTEXT, - }; - - enum enabled_state - { - DEFAULT_OFF, - DEFAULT_ON, - FORCE_ON, - FORCE_OFF, - }; - - enum - { - FLAG_CHECKED = 1, - FLAG_DISABLED = 2, - FLAG_GRAYED = 4, - FLAG_DISABLED_GRAYED = FLAG_DISABLED|FLAG_GRAYED, - }; - - virtual enabled_state get_enabled_state(unsigned idx) {return DEFAULT_ON;}//return if menu item should be enabled by default or not - - virtual type get_type()=0; - virtual unsigned get_num_items()=0; - virtual void enum_item(unsigned n,string_base & out)=0;//return full formal name, like "playback/play", 0<=n & data,string_base & out,unsigned & displayflags)=0;//displayflags - see FLAG_* above; displayflags are set to 0 before calling - virtual void perform_command(unsigned n,const ptr_list_base & data)=0; - - virtual bool get_description(unsigned n,string_base & out) {return false;} - - virtual void * get_glyph(unsigned n) {return 0;}//RESERVED, do not override - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - static const GUID caller_now_playing; - static const GUID caller_playlist; - static const GUID caller_undefined; - - bool get_display_data(unsigned n,const ptr_list_base & data,string_base & out,unsigned & displayflags,const GUID & caller); - void perform_command(unsigned n,const ptr_list_base & data,const GUID & caller); - bool enum_item_guid(unsigned n,GUID & out); -}; - -class NOVTABLE menu_item_v2 : public menu_item -{ - virtual bool get_display_data(unsigned n,const ptr_list_base & data,string_base & out,unsigned & displayflags) - {return get_display_data(n,data,out,displayflags,caller_undefined);} - virtual void perform_command(unsigned n,const ptr_list_base & data) - {perform_command(n,data,caller_undefined);} -public: - virtual bool get_display_data(unsigned n,const ptr_list_base & data,string_base & out,unsigned & displayflags,const GUID & caller)=0; - virtual void perform_command(unsigned n,const ptr_list_base & data,const GUID & caller)=0; - virtual bool enum_item_guid(unsigned n,GUID & out) {return false;}//returns false if item doesnt have a GUID - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return menu_item::service_query(guid); - } -}; - -class NOVTABLE menu_item_main : public menu_item_v2 -{ - virtual type get_type() {return TYPE_MAIN;} - - virtual bool get_display_data(unsigned n,const ptr_list_base & data,string_base & out,unsigned & displayflags,const GUID & caller) - { - assert(n>=0 && n & data,const GUID & caller) {perform_command(n);} -protected: - //override these - virtual unsigned get_num_items()=0; - virtual void enum_item(unsigned n,string_base & out)=0; - virtual void perform_command(unsigned n)=0; - virtual bool is_checked(unsigned n) {return false;} - virtual bool is_disabled(unsigned n) {return false;} - virtual bool is_available(unsigned n) {return true;} - virtual bool get_description(unsigned n,string_base & out) {return false;} -}; - -class NOVTABLE menu_item_main_single : public menu_item_main //helper -{ - virtual unsigned get_num_items() {return 1;} - virtual void enum_item(unsigned n,string_base & out) - { - if (n==0) get_name(out); - } - virtual void perform_command(unsigned n) - { - if (n==0) run(); - } - virtual bool is_checked(unsigned n) {assert(n==0); return is_checked();}; - virtual bool is_disabled(unsigned n) {assert(n==0); return is_disabled();} - virtual bool get_description(unsigned n,string_base & out) {assert(n==0); return get_description(out);} -protected://override these - virtual void get_name(string_base & out)=0; - virtual void run()=0; - virtual bool is_checked() {return false;} - virtual bool is_disabled() {return false;} - virtual bool get_description(string_base & out) {return false;} -}; - -class NOVTABLE menu_item_context : public menu_item_v2 -{ - virtual type get_type() {return TYPE_CONTEXT;} - virtual bool get_display_data(unsigned n,const ptr_list_base & data,string_base & out,unsigned & displayflags,const GUID & caller) - { - bool rv = false; - assert(n>=0 && n0) - { - rv = context_get_display(n,data,out,displayflags,caller); - } - return rv; - } - virtual void perform_command(unsigned n,const ptr_list_base & data,const GUID & caller) - { - if (data.get_count()>0) context_command(n,data,caller); - } - virtual bool is_checked(unsigned n,const ptr_list_base & data) {return false;} -protected: - //override these - virtual unsigned get_num_items()=0; - virtual void enum_item(unsigned n,string_base & out)=0; - virtual void context_command(unsigned n,const ptr_list_base & data,const GUID& caller)=0; - virtual bool context_get_display(unsigned n,const ptr_list_base & data,string_base & out,unsigned & displayflags,const GUID &) - { - assert(n>=0 && n -class menu_item_factory : public service_factory_single_t {}; - - -#endif //_FOOBAR2000_MENU_ITEM_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_manager.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_manager.cpp deleted file mode 100644 index 101bd1d8d..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_manager.cpp +++ /dev/null @@ -1,632 +0,0 @@ -#include "foobar2000.h" - -#ifdef WIN32 - -static void fix_ampersand(const char * src,string_base & out) -{ - unsigned ptr = 0; - while(src[ptr]) - { - if (src[ptr]=='&') - { - out.add_string("&&"); - ptr++; - while(src[ptr]=='&') - { - out.add_string("&&"); - ptr++; - } - } - else out.add_byte(src[ptr++]); - } -} - -static unsigned flags_to_win32(unsigned flags) -{ - unsigned ret = 0; - if (flags & menu_item::FLAG_CHECKED) ret |= MF_CHECKED; - if (flags & menu_item::FLAG_DISABLED) ret |= MF_DISABLED; - if (flags & menu_item::FLAG_GRAYED) ret |= MF_GRAYED; - return ret; -} - -void menu_manager::win32_build_menu(HMENU menu,menu_node * parent,int base_id,int max_id)//menu item identifiers are base_id<=Nget_type()==menu_node::TYPE_POPUP) - { - string8_fastalloc temp; - int child_idx,child_num = parent->get_num_children(); - for(child_idx=0;child_idxget_child(child_idx); - if (child) - { - const char * name = child->get_name(); - if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;} - menu_node::type type = child->get_type(); - if (type==menu_node::TYPE_POPUP) - { - HMENU new_menu = CreatePopupMenu(); - uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(child->get_display_flags()),(UINT)new_menu,name); - win32_build_menu(new_menu,child,base_id,max_id); - } - else if (type==menu_node::TYPE_SEPARATOR) - { - uAppendMenu(menu,MF_SEPARATOR,0,0); - } - else if (type==menu_node::TYPE_COMMAND) - { - int id = child->get_id(); - if (id>=0 && (max_id<0 || idget_display_flags()),base_id+id,name); - } - } - } - } - } -} - -#endif - -static bool run_command_internal(menu_item::type type,const char * name,const ptr_list_base & data,const GUID & caller) -{ - service_enum_t e; - menu_item * ptr; - bool done = false; - string8_fastalloc action_name; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_type()==type) - { - unsigned action,num_actions = ptr->get_num_items(); - for(action=0;actionenum_item(action,action_name); - if (!stricmp_utf8(name,action_name)) - { - TRACK_CALL_TEXT(uStringPrintf("menu_manager::run_command()/\"%s\"",action_name.get_ptr())); - ptr->perform_command(action,data,caller); - done = true; - break; - } - } - } - ptr->service_release(); - if (done) break; - } - return done; -} - -static bool run_command_internal(menu_item::type type,const GUID & guid,const ptr_list_base & data,const GUID & caller) -{ - service_enum_t e; - menu_item * ptr; - bool done = false; - GUID action_guid; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_type()==type) - { - unsigned action,num_actions = ptr->get_num_items(); - for(action=0;actionenum_item_guid(action,action_guid)) - { - if (action_guid == guid) - { - TRACK_CALL_TEXT("menu_manager::run_command(), by GUID"); - ptr->perform_command(action,data,caller); - done = true; - break; - } - } - } - } - ptr->service_release(); - if (done) break; - } - return done; -} - -bool menu_manager::run_command(const GUID & guid) -{ - return run_command_internal(menu_item::TYPE_MAIN,guid,ptr_list_t(),menu_item::caller_undefined); -} - -bool menu_manager::run_command_context(const GUID & guid,const ptr_list_base & data) -{ - return run_command_internal(menu_item::TYPE_CONTEXT,guid,data,menu_item::caller_undefined); -} - -bool menu_manager::run_command_context_ex(const GUID & guid,const ptr_list_base & data,const GUID & caller) -{ - return run_command_internal(menu_item::TYPE_CONTEXT,guid,data,caller); -} - - -bool menu_manager::run_command(const char * name) -{ - return run_command_internal(menu_item::TYPE_MAIN,name,ptr_list_t(),menu_item::caller_undefined); -} - -bool menu_manager::run_command_context_ex(const char * name,const ptr_list_base & data,const GUID & caller) -{ - return run_command_internal(menu_item::TYPE_CONTEXT,name,data,caller); -} - -bool menu_manager::run_command_context(const char * name,const ptr_list_base &data) -{ - return run_command_internal(menu_item::TYPE_CONTEXT,name,data,menu_item::caller_undefined); -} - -bool menu_manager::run_command_context_playlist(const char * name) -{ - metadb_handle_list temp; - playlist_oper::get()->get_sel_items(temp); - bool rv = run_command_context_ex(name,temp,menu_item::caller_playlist); - temp.delete_all(); - return rv; -} - - -static bool g_test_command(const char * name,menu_item::type m_type) -{ - service_enum_t e; - menu_item * ptr; - bool done = false; - string8_fastalloc action_name; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_type()==m_type) - { - unsigned action,num_actions = ptr->get_num_items(); - for(action=0;actionenum_item(action,action_name); - if (!stricmp_utf8(name,action_name)) - { - done = true; - break; - } - } - } - ptr->service_release(); - if (done) break; - } - return done; -} - -bool menu_manager::test_command(const char * name) -{ - return g_test_command(name,menu_item::TYPE_MAIN); -} - -bool menu_manager::test_command_context(const char * name) -{ - return g_test_command(name,menu_item::TYPE_CONTEXT); -} - -static bool g_is_checked(const char * name,menu_item::type type, const ptr_list_base & data,const GUID & caller) -{ - service_enum_t e; - menu_item * ptr; - bool done = false, rv = false; - string8_fastalloc dummystring,action_name; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_type()==type) - { - unsigned action,num_actions = ptr->get_num_items(); - for(action=0;actionenum_item(action,action_name); - if (!stricmp_utf8(name,action_name)) - { - unsigned displayflags = 0; - if (ptr->get_display_data(action,data,dummystring,displayflags,caller)) - { - rv = !!(displayflags & menu_item::FLAG_CHECKED); - done = true; - break; - } - } - } - } - ptr->service_release(); - if (done) break; - } - return rv; -} - -static bool g_is_checked(const GUID & guid,menu_item::type type, const ptr_list_base & data,const GUID & caller) -{ - service_enum_t e; - menu_item * ptr; - bool done = false, rv = false; - string8_fastalloc dummystring; - GUID action_guid; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_type()==type) - { - unsigned action,num_actions = ptr->get_num_items(); - for(action=0;actionenum_item_guid(action,action_guid)) - { - if (action_guid == guid) - { - unsigned displayflags = 0; - if (ptr->get_display_data(action,data,dummystring,displayflags,caller)) - { - rv = !!(displayflags & menu_item::FLAG_CHECKED); - done = true; - break; - } - } - } - } - } - ptr->service_release(); - if (done) break; - } - return rv; -} - -bool menu_manager::is_command_checked(const GUID & guid) -{ - return g_is_checked(guid,menu_item::TYPE_MAIN,ptr_list_t(),menu_item::caller_undefined); -} - -bool menu_manager::is_command_checked(const char * name) -{ - return g_is_checked(name,menu_item::TYPE_MAIN,ptr_list_t(),menu_item::caller_undefined); -} - -bool menu_manager::is_command_checked_context(const GUID & guid,metadb_handle_list & data) -{ - return g_is_checked(guid,menu_item::TYPE_MAIN,data,menu_item::caller_undefined); -} - -bool menu_manager::is_command_checked_context(const char * name,metadb_handle_list & data) -{ - return g_is_checked(name,menu_item::TYPE_MAIN,data,menu_item::caller_undefined); -} - -bool menu_manager::is_command_checked_context_playlist(const GUID & guid) -{ - bool rv; - metadb_handle_list temp; - playlist_oper::get()->get_data(temp); - rv = g_is_checked(guid,menu_item::TYPE_MAIN,temp,menu_item::caller_playlist); - temp.delete_all(); - return rv; -} - -bool menu_manager::is_command_checked_context_playlist(const char * name) -{ - bool rv; - metadb_handle_list temp; - playlist_oper::get()->get_data(temp); - rv = g_is_checked(name,menu_item::TYPE_MAIN,temp,menu_item::caller_playlist); - temp.delete_all(); - return rv; -} - -bool menu_manager::execute_by_id(unsigned id) -{ - bool rv = false; - menu_node * ptr = find_by_id(id); - if (ptr) {rv=true;ptr->execute();} - return rv; -} - -#ifdef WIN32 - -void menu_manager::win32_run_menu_popup(HWND parent,const POINT * pt) -{ - enum {ID_CUSTOM_BASE = 1}; - - int cmd; - - { - POINT p; - if (pt) p = *pt; - else GetCursorPos(&p); - HMENU hmenu = CreatePopupMenu(); - - v_win32_build_menu(hmenu,ID_CUSTOM_BASE,-1); - v_win32_auto_mnemonics(hmenu); - - cmd = TrackPopupMenu(hmenu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,p.x,p.y,0,parent,0); - - DestroyMenu(hmenu); - } - - if (cmd>0) - { - if (cmd>=ID_CUSTOM_BASE) - { - execute_by_id(cmd - ID_CUSTOM_BASE); - } - } -} - -void menu_manager::win32_run_menu_context(HWND parent,const metadb_handle_list & data,const POINT * pt,unsigned flags) -{ - menu_manager * p_manager = menu_manager::create(); - p_manager->init_context(data,flags); - p_manager->win32_run_menu_popup(parent,pt); - p_manager->service_release(); -} - -void menu_manager::win32_run_menu_context_playlist(HWND parent,const POINT * pt,unsigned flags) -{ - menu_manager * p_manager = menu_manager::create(); - p_manager->init_context_playlist(flags); - p_manager->win32_run_menu_popup(parent,pt); - p_manager->service_release(); -} - -void menu_manager::win32_run_menu_main(HWND parent,const char * path,const POINT * pt,unsigned flags) -{ - menu_manager * p_manager = menu_manager::create(); - p_manager->init_main(path,flags); - p_manager->win32_run_menu_popup(parent,pt); - p_manager->service_release(); -} - -namespace { - class mnemonic_manager - { - string8_fastalloc used; - bool is_used(unsigned c) - { - char temp[8]; - temp[utf8_encode_char(char_lower(c),temp)]=0; - return !!strstr(used,temp); - } - - static bool is_alphanumeric(char c) - { - return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'); - } - - - - - void insert(const char * src,unsigned idx,string_base & out) - { - out.reset(); - out.add_string(src,idx); - out.add_string("&"); - out.add_string(src+idx); - used.add_char(char_lower(src[idx])); - } - public: - bool check_string(const char * src) - {//check for existing mnemonics - const char * ptr = src; - while(ptr = strchr(ptr,'&')) - { - if (ptr[1]=='&') ptr+=2; - else - { - unsigned c = 0; - if (utf8_decode_char(ptr+1,&c)>0) - { - if (!is_used(c)) used.add_char(char_lower(c)); - } - return true; - } - } - return false; - } - bool process_string(const char * src,string_base & out)//returns if changed - { - if (check_string(src)) {out=src;return false;} - unsigned idx=0; - while(src[idx]==' ') idx++; - while(src[idx]) - { - if (is_alphanumeric(src[idx]) && !is_used(src[idx])) - { - insert(src,idx,out); - return true; - } - - while(src[idx] && src[idx]!=' ' && src[idx]!='\t') idx++; - if (src[idx]=='\t') break; - while(src[idx]==' ') idx++; - } - - //no success picking first letter of one of words - idx=0; - while(src[idx]) - { - if (src[idx]=='\t') break; - if (is_alphanumeric(src[idx]) && !is_used(src[idx])) - { - insert(src,idx,out); - return true; - } - idx++; - } - - //giving up - out = src; - return false; - } - }; -} - -void menu_manager::win32_auto_mnemonics(HMENU menu) -{ - mnemonic_manager mgr; - unsigned n, m = GetMenuItemCount(menu); - string8_fastalloc temp,temp2; - for(n=0;n e; - menu_item * ptr; - string8_fastalloc action_name; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_type()==type) - { - unsigned action,num_actions = ptr->get_num_items(); - for(action=0;actionenum_item(action,action_name); - if (!stricmp_utf8(name,action_name)) - { - bool rv = ptr->get_description(action,out); - ptr->service_release(); - if (!rv) out.reset(); - return rv; - } - } - } - ptr->service_release(); - } - return false; -} - -static bool test_key(unsigned k) -{ - return (GetKeyState(k) & 0x8000) ? true : false; -} - -#define F_SHIFT (HOTKEYF_SHIFT<<8) -#define F_CTRL (HOTKEYF_CONTROL<<8) -#define F_ALT (HOTKEYF_ALT<<8) -#define F_WIN (HOTKEYF_EXT<<8) - -static unsigned get_key_code(WPARAM wp) -{ - unsigned code = wp & 0xFF; - if (test_key(VK_CONTROL)) code|=F_CTRL; - if (test_key(VK_SHIFT)) code|=F_SHIFT; - if (test_key(VK_MENU)) code|=F_ALT; - if (test_key(VK_LWIN) || test_key(VK_RWIN)) code|=F_WIN; - return code; -} - -bool keyboard_shortcut_manager::on_keydown(shortcut_type type,WPARAM wp) -{ - if (type==TYPE_CONTEXT) return false; - metadb_handle_list dummy; - return process_keydown(type,dummy,get_key_code(wp)); -} - -bool keyboard_shortcut_manager::on_keydown_context(const ptr_list_base & data,WPARAM wp,const GUID & caller) -{ - if (data.get_count()==0) return false; - return process_keydown_ex(TYPE_CONTEXT,data,get_key_code(wp),caller); -} - -bool keyboard_shortcut_manager::on_keydown_auto(WPARAM wp) -{ - if (on_keydown(TYPE_MAIN,wp)) return true; - if (on_keydown(TYPE_CONTEXT_PLAYLIST,wp)) return true; - if (on_keydown(TYPE_CONTEXT_NOW_PLAYING,wp)) return true; - return false; -} - -bool keyboard_shortcut_manager::on_keydown_auto_playlist(WPARAM wp) -{ - metadb_handle_list data; - bool rv = false; - playlist_oper::get()->get_sel_items(data); - rv = on_keydown_auto_context(data,wp,menu_item::caller_playlist); - data.delete_all(); - return rv; -} - -bool keyboard_shortcut_manager::on_keydown_auto_context(const ptr_list_base & data,WPARAM wp,const GUID & caller) -{ - if (on_keydown_context(data,wp,caller)) return true; - else return on_keydown_auto(wp); -} - - -bool menu_item::get_display_data(unsigned n,const ptr_list_base & data,string_base & out,unsigned & displayflags,const GUID & caller) -{ - bool rv; - menu_item_v2 * this_v2 = service_query_t(menu_item_v2,this); - if (this_v2) - { - rv = this_v2->get_display_data(n,data,out,displayflags,caller); - this_v2->service_release(); - } - else - { - rv = get_display_data(n,data,out,displayflags); - } - return rv; -} - -void menu_item::perform_command(unsigned n,const ptr_list_base & data,const GUID & caller) -{ - menu_item_v2 * this_v2 = service_query_t(menu_item_v2,this); - if (this_v2) - { - this_v2->perform_command(n,data,caller); - this_v2->service_release(); - } - else - { - perform_command(n,data); - } -} - -bool menu_item::enum_item_guid(unsigned n,GUID & out) -{ - bool rv = false; - menu_item_v2 * this_v2 = service_query_t(menu_item_v2,this); - if (this_v2) - { - rv = this_v2->enum_item_guid(n,out); - this_v2->service_release(); - } - return rv; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_manager.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_manager.h deleted file mode 100644 index bd09aa1bb..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/menu_manager.h +++ /dev/null @@ -1,286 +0,0 @@ -#ifndef _FOOBAR2000_MENU_MANAGER_H_ -#define _FOOBAR2000_MENU_MANAGER_H_ - -#include "menu_item.h" -#include "metadb_handle.h" - - - -class NOVTABLE keyboard_shortcut_manager : public service_base -{ -public: - static keyboard_shortcut_manager * get() {return service_enum_create_t(keyboard_shortcut_manager,0);} - - enum shortcut_type - { - TYPE_MAIN, - TYPE_CONTEXT, - TYPE_CONTEXT_PLAYLIST, - TYPE_CONTEXT_NOW_PLAYING, - }; - - - virtual bool process_keydown(shortcut_type type,const ptr_list_base & data,unsigned keycode)=0; - virtual bool process_keydown_ex(shortcut_type type,const ptr_list_base & data,unsigned keycode,const GUID & caller)=0; -//caller guid - see menu_item_v2, menu_item::caller_* - bool on_keydown(shortcut_type type,WPARAM wp); - bool on_keydown_context(const ptr_list_base & data,WPARAM wp,const GUID & caller); - bool on_keydown_auto(WPARAM wp); - bool on_keydown_auto_playlist(WPARAM wp); - bool on_keydown_auto_context(const ptr_list_base & data,WPARAM wp,const GUID & caller); - - virtual bool get_key_description_for_action(const char * action_name, string_base & out, shortcut_type type, bool is_global)=0; - - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - -/* -usage: - - in a windowproc: - - case WM_KEYDOWN: - keyboard_shortcut_manager::get()->on_keydown(wparam); - break; - case WM_SYSKEYDOWN: - keyboard_shortcut_manager::get()->on_keydown(wparam); - break; - - return value is true if key got translated to one of user-configured actions, false if not - */ -}; - - - - -class NOVTABLE menu_node -{ -public: - enum type - { - TYPE_POPUP,TYPE_COMMAND,TYPE_SEPARATOR - }; - virtual type get_type()=0; - virtual const char * get_name()=0; - virtual unsigned get_num_children()=0;//TYPE_POPUP only - virtual menu_node * get_child(unsigned n)=0;//TYPE_POPUP only - virtual unsigned get_display_flags()=0;//TYPE_COMMAND/TYPE_POPUP only, see menu_item::FLAG_* - virtual unsigned get_id()=0;//TYPE_COMMAND only, returns zero-based index (helpful for win32 menu command ids) - virtual void execute()=0;//TYPE_COMMAND only - virtual bool get_description(string_base & out)=0;//TYPE_COMMAND only - virtual bool get_full_name(string_base & out)=0;//TYPE_COMMAND only - virtual void * get_glyph()=0;//RESERVED, do not use -}; - - - -class NOVTABLE menu_manager : public service_base -{ -public: - enum - { - FLAG_SHOW_SHORTCUTS = 1, - FLAG_SHOW_SHORTCUTS_GLOBAL = 2, - }; - virtual void init_context(const ptr_list_base & data,unsigned flags)=0;//flags - see FLAG_* above - virtual void init_context_playlist(unsigned flags)=0; - virtual void init_main(const char * path,unsigned flags)=0; - virtual menu_node * get_root()=0;//releasing menu_manager service releaases nodes; root may be null in case of error or something - virtual menu_node * find_by_id(unsigned id)=0; - virtual void set_shortcut_preference(const keyboard_shortcut_manager::shortcut_type * data,unsigned count)=0; - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static menu_manager * create() {return service_enum_create_t(menu_manager,0);}//you must service_release pointers you obtained - -#ifdef WIN32 - static void win32_build_menu(HMENU menu,menu_node * parent,int base_id,int max_id);//menu item identifiers are base_id<=N & list) {run_command_context(name,list);} - virtual void v_run_command_context_playlist(const char * name) {run_command_context_playlist(name);} - - virtual void v_win32_auto_mnemonics(HMENU menu) {win32_auto_mnemonics(menu);} -#endif - - //new (0.8 beta3) - virtual void init_context_ex(const ptr_list_base & data,unsigned flags,const GUID & caller)=0; - virtual bool init_context_now_playing(unsigned flags)=0;//returns false if not playing - virtual void init_main_ex(const char * path,unsigned flags,const GUID & caller)=0; - - bool execute_by_id(unsigned id); - - static bool run_command(const GUID & guid); - static bool run_command_context(const GUID & guid,const ptr_list_base & data); - static bool run_command_context_ex(const GUID & guid,const ptr_list_base & data,const GUID & caller); - - static bool run_command(const char * name);//returns false if not found - static bool run_command_context(const char * name,const ptr_list_base & data); - static bool run_command_context_playlist(const char * name); - static bool run_command_context_ex(const char * name,const ptr_list_base & data,const GUID & caller); - - static bool test_command(const char * name);//checks if a command of this name exists - static bool test_command_context(const char * name); - - static bool is_command_checked(const char * name); - static bool is_command_checked(const GUID & guid); - static bool is_command_checked_context(const char * name,metadb_handle_list & data); - static bool is_command_checked_context(const GUID & guid,metadb_handle_list & data); - static bool is_command_checked_context_playlist(const char * name); - static bool is_command_checked_context_playlist(const GUID & guid); - - static bool get_description(menu_item::type type,const char * path,string_base & out); - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - - - -}; - -class NOVTABLE menu_manager_defaults_callback -{ -public: - virtual void set_path(const char * path)=0; - virtual void add_command(const char * name)=0;//full name/path of a command, according to menu_item::enum_item, case-sensitive! - virtual void add_separator()=0; - virtual bool is_command_present(const char * name)=0; -}; - -class NOVTABLE menu_manager_defaults : public service_base -{ -public: - virtual GUID get_guid()=0; - virtual menu_item::type get_type()=0; - virtual void run(menu_manager_defaults_callback * callback)=0; - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - - - -class standard_commands -{ -public: - static const GUID - guid_context_file_properties, guid_context_file_open_directory, guid_context_copy_names, - guid_context_send_to_playlist, guid_context_reload_info, guid_context_reload_info_if_changed, - guid_context_rewrite_info, guid_context_remove_tags, guid_context_remove_from_database, - guid_context_convert_run, guid_context_convert_run_singlefile,guid_context_write_cd, - guid_context_rg_scan_track, guid_context_rg_scan_album, guid_context_rg_scan_album_multi, - guid_context_rg_remove, guid_context_save_playlist, guid_context_masstag_edit, - guid_context_masstag_rename, - guid_main_always_on_top, guid_main_preferences, guid_main_about, - guid_main_exit, guid_main_restart, guid_main_activate, - guid_main_hide, guid_main_activate_or_hide, guid_main_titleformat_help, - guid_main_follow_cursor, guid_main_next, guid_main_previous, - guid_main_next_or_random, guid_main_random, guid_main_pause, - guid_main_play, guid_main_play_or_pause, guid_main_rg_set_album, - guid_main_rg_set_track, guid_main_rg_disable, guid_main_stop, - guid_main_stop_after_current, guid_main_volume_down, guid_main_volume_up, - guid_main_volume_mute, guid_main_add_directory, guid_main_add_files, - guid_main_add_location, guid_main_add_playlist, guid_main_clear_playlist, - guid_main_create_playlist, guid_main_highlight_playing, guid_main_load_playlist, - guid_main_next_playlist, guid_main_previous_playlist, guid_main_open, - guid_main_remove_playlist, guid_main_remove_dead_entries, guid_main_remove_duplicates, - guid_main_rename_playlist, guid_main_save_all_playlists, guid_main_save_playlist, - guid_main_playlist_search, guid_main_playlist_sel_crop, guid_main_playlist_sel_remove, - guid_main_playlist_sel_invert, guid_main_playlist_undo, guid_main_show_console, - guid_main_play_cd, guid_main_restart_resetconfig, guid_main_record, - guid_main_playlist_moveback, guid_main_playlist_moveforward - ; - - static inline bool run_main(const GUID & guid) {return menu_manager::run_command(guid);} - static inline bool run_context(const GUID & guid,const ptr_list_base &data) {return menu_manager::run_command_context(guid,data);} - static inline bool run_context(const GUID & guid,const ptr_list_base &data,const GUID& caller) {return menu_manager::run_command_context_ex(guid,data,caller);} - - static inline bool context_file_properties(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_file_properties,data,caller);} - static inline bool context_file_open_directory(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_file_open_directory,data,caller);} - static inline bool context_copy_names(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_copy_names,data,caller);} - static inline bool context_send_to_playlist(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_send_to_playlist,data,caller);} - static inline bool context_reload_info(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_reload_info,data,caller);} - static inline bool context_reload_info_if_changed(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_reload_info_if_changed,data,caller);} - static inline bool context_rewrite_info(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_rewrite_info,data,caller);} - static inline bool context_remove_tags(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_remove_tags,data,caller);} - static inline bool context_remove_from_database(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_remove_from_database,data,caller);} - static inline bool context_convert_run(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_convert_run,data,caller);} - static inline bool context_convert_run_singlefile(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_convert_run_singlefile,data,caller);} - static inline bool context_write_cd(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_write_cd,data,caller);} - static inline bool context_rg_scan_track(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_rg_scan_track,data,caller);} - static inline bool context_rg_scan_album(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_rg_scan_album,data,caller);} - static inline bool context_rg_scan_album_multi(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_rg_scan_album_multi,data,caller);} - static inline bool context_rg_remove(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_rg_remove,data,caller);} - static inline bool context_save_playlist(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_save_playlist,data,caller);} - static inline bool context_masstag_edit(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_masstag_edit,data,caller);} - static inline bool context_masstag_rename(const ptr_list_base &data,const GUID& caller = menu_item::caller_undefined) {return run_context(guid_context_masstag_rename,data,caller);} - static inline bool main_always_on_top() {return run_main(guid_main_always_on_top);} - static inline bool main_preferences() {return run_main(guid_main_preferences);} - static inline bool main_about() {return run_main(guid_main_about);} - static inline bool main_exit() {return run_main(guid_main_exit);} - static inline bool main_restart() {return run_main(guid_main_restart);} - static inline bool main_activate() {return run_main(guid_main_activate);} - static inline bool main_hide() {return run_main(guid_main_hide);} - static inline bool main_activate_or_hide() {return run_main(guid_main_activate_or_hide);} - static inline bool main_titleformat_help() {return run_main(guid_main_titleformat_help);} - static inline bool main_follow_cursor() {return run_main(guid_main_follow_cursor);} - static inline bool main_next() {return run_main(guid_main_next);} - static inline bool main_previous() {return run_main(guid_main_previous);} - static inline bool main_next_or_random() {return run_main(guid_main_next_or_random);} - static inline bool main_random() {return run_main(guid_main_random);} - static inline bool main_pause() {return run_main(guid_main_pause);} - static inline bool main_play() {return run_main(guid_main_play);} - static inline bool main_play_or_pause() {return run_main(guid_main_play_or_pause);} - static inline bool main_rg_set_album() {return run_main(guid_main_rg_set_album);} - static inline bool main_rg_set_track() {return run_main(guid_main_rg_set_track);} - static inline bool main_rg_disable() {return run_main(guid_main_rg_disable);} - static inline bool main_stop() {return run_main(guid_main_stop);} - static inline bool main_stop_after_current() {return run_main(guid_main_stop_after_current);} - static inline bool main_volume_down() {return run_main(guid_main_volume_down);} - static inline bool main_volume_up() {return run_main(guid_main_volume_up);} - static inline bool main_volume_mute() {return run_main(guid_main_volume_mute);} - static inline bool main_add_directory() {return run_main(guid_main_add_directory);} - static inline bool main_add_files() {return run_main(guid_main_add_files);} - static inline bool main_add_location() {return run_main(guid_main_add_location);} - static inline bool main_add_playlist() {return run_main(guid_main_add_playlist);} - static inline bool main_clear_playlist() {return run_main(guid_main_clear_playlist);} - static inline bool main_create_playlist() {return run_main(guid_main_create_playlist);} - static inline bool main_highlight_playing() {return run_main(guid_main_highlight_playing);} - static inline bool main_load_playlist() {return run_main(guid_main_load_playlist);} - static inline bool main_next_playlist() {return run_main(guid_main_next_playlist);} - static inline bool main_previous_playlist() {return run_main(guid_main_previous_playlist);} - static inline bool main_open() {return run_main(guid_main_open);} - static inline bool main_remove_playlist() {return run_main(guid_main_remove_playlist);} - static inline bool main_remove_dead_entries() {return run_main(guid_main_remove_dead_entries);} - static inline bool main_remove_duplicates() {return run_main(guid_main_remove_duplicates);} - static inline bool main_rename_playlist() {return run_main(guid_main_rename_playlist);} - static inline bool main_save_all_playlists() {return run_main(guid_main_save_all_playlists);} - static inline bool main_save_playlist() {return run_main(guid_main_save_playlist);} - static inline bool main_playlist_search() {return run_main(guid_main_playlist_search);} - static inline bool main_playlist_sel_crop() {return run_main(guid_main_playlist_sel_crop);} - static inline bool main_playlist_sel_remove() {return run_main(guid_main_playlist_sel_remove);} - static inline bool main_playlist_sel_invert() {return run_main(guid_main_playlist_sel_invert);} - static inline bool main_playlist_undo() {return run_main(guid_main_playlist_undo);} - static inline bool main_show_console() {return run_main(guid_main_show_console);} - static inline bool main_play_cd() {return run_main(guid_main_play_cd);} - static inline bool main_restart_resetconfig() {return run_main(guid_main_restart_resetconfig);} - static inline bool main_playlist_moveback() {return run_main(guid_main_playlist_moveback);} - static inline bool main_playlist_moveforward() {return run_main(guid_main_playlist_moveforward);} -}; - -#endif //_FOOBAR2000_MENU_MANAGER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb.cpp deleted file mode 100644 index 95f504007..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include "foobar2000.h" - -int metadb::query(file_info * out) -{ - playable_location_i temp(*out->get_location()); - return query(&temp,out); -} - -int metadb::query_flush(file_info * out) -{ - playable_location_i temp(*out->get_location()); - return query_flush(&temp,out); -} - -int metadb::query_dbonly(file_info * out) -{ - playable_location_i temp(*out->get_location()); - return query_dbonly(&temp,out); -} - -int metadb::query_meta_field(const playable_location * src,const char * name,int num,string8 & out) -{ - int rv = 0; - metadb_handle * ptr = handle_create(src); - if (ptr) - { - rv = ptr->handle_query_meta_field(name,num,out); - ptr->handle_release(); - } - return rv; -} - -int metadb::update_info(const file_info * info,bool dbonly)//using playable_location from file_info, return -1 on failure, 0 if pending, 1 on immediate success; may take a few good seconds to execute -{ - int rv; - metadb_handle * handle = handle_create(info->get_location()); - rv = handle->handle_update_info(info,dbonly); - handle->handle_release(); - return rv; -} - -void metadb::user_requested_remove(const playable_location * entry)//use this when user requests files to be removed from database (but not deleted physically) -{ - metadb_handle * ptr = handle_create(entry); - ptr->handle_user_requested_remove(); - ptr->handle_release(); -} - -int metadb::query(const playable_location * entry,file_info * out) -{ - int rv; - metadb_handle * handle = handle_create(entry); - rv = handle->handle_query(out,false); - handle->handle_release(); - return rv; -} - -int metadb::query_flush(const playable_location * entry,file_info * out) -{ - int rv; - metadb_handle * handle = handle_create(entry); - handle->handle_flush_info(); - rv = handle->handle_query(out,false); - handle->handle_release(); - return rv; -} - -int metadb::query_dbonly(const playable_location * entry,file_info * out) -{ - int rv; - metadb_handle * handle = handle_create(entry); - rv = handle->handle_query(out,true); - handle->handle_release(); - return rv; -} - -int metadb::precache(const playable_location * entry,reader * r) -{ - int rv; - metadb_handle * handle = handle_create(entry); - rv = handle->handle_precache(r); - handle->handle_release(); - return rv; -} - -void metadb::precache(const char * filename,reader * r) -{ - if (r) - { - metadb_handle_list temp; - track_indexer::g_get_tracks_ex(filename,temp,r); - unsigned n,m=temp.get_count(); - for(n=0;nhandle_get_path())) - { - r->seek(0); - ptr->handle_precache(r); - } - } - temp.delete_all(); - } -} - - -void metadb::hint(const file_info * src) -{ - metadb_handle * handle = handle_create_hint(src); - handle->handle_release(); -} - - -int metadb::format_title(const playable_location * source,string_base & out,const char * spec,const char * extra_items) -{ - int rv; - metadb_handle * handle = handle_create(source); - rv = handle->handle_format_title(out,spec,extra_items); - handle->handle_release(); - return rv; -} - - -metadb * metadb::get()//safe not to release it; don't call from DLL startup / static object constructor -{ - static metadb * ptr; - if (ptr==0) ptr = service_enum_create_t(metadb,0); - return ptr; -} -#ifdef _DEBUG -int metadb::database_lock_count() -{ - int val = database_try_lock(); - if (val) - val = database_unlock(); - return val; -} - -void metadb::database_delockify(int wanted_count) -{ - assert(wanted_count >= 0); - if (wanted_count<0) wanted_count = 0; - int count = database_lock_count(); - while(count < wanted_count) count = database_lock(); - while(count > wanted_count) count = database_unlock(); -} -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb.h deleted file mode 100644 index 711cdcd84..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef _METADB_H_ -#define _METADB_H_ - -#include "service.h" -#include "interface_helper.h" -#include "file_info.h" - -class input; -class reader; - - -#include "metadb_handle.h" - -//only one implementation in main exe, DO NOT DERIVE FROM THIS -class NOVTABLE metadb : public service_base -{ -public: - virtual int update_info_flush()=0;//tries to perform any pending tag update operations, may take a few good seconds to execute - - virtual void file_moved(const char * src,const char * dst)=0;//will transfer existing database data to new path (and notify callbacks about file being moved) - virtual void file_copied(const char * src,const char * dst)=0; - virtual void file_removed(const char * src)=0;//use this to tell database that url [src] is dead - virtual void entry_dead(const playable_location * entry)=0;//same as file_removed but taking playable_location - - virtual int database_lock()=0;//enters database's internal critical section, prevents other threads from accessing database as long as it's locked - virtual int database_try_lock()=0;//returns immediately without waiting, may fail, returns 0 on failure - virtual int database_unlock()=0; - - - virtual metadb_handle * handle_create(const playable_location * src)=0;//should never fail - virtual metadb_handle * handle_create_hint(const file_info * src)=0;//should never fail - - virtual void get_all_entries(ptr_list_base & out)=0;//you get duplicate handles of all database items, you are responsible for releasing them - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static metadb * get();//safe not to release it; don't call from DLL startup / static object constructor - - //helper - static int g_format_title(const playable_location * source,string_base & out,const char * spec,const char * extra_items=0) - { - return get()->format_title(source,out,spec,extra_items); - } - - int query(file_info * out); - int query_flush(file_info * out); - int query_dbonly(file_info * out); - int query_meta_field(const playable_location * src,const char * name,int num,string8 & out); - int update_info(const file_info * info,bool dbonly=false);//using playable_location from file_info, return -1 on failure, 0 if pending, 1 on immediate success; may take a few good seconds to execute - void user_requested_remove(const playable_location * entry);//use this when user requests files to be removed from database (but not deleted physically) - int query(const playable_location * entry,file_info * out); - int query_flush(const playable_location * entry,file_info * out); - int query_dbonly(const playable_location * entry,file_info * out); - int precache(const playable_location * entry,reader * r); - void precache(const char * filename,reader * r); - void hint(const file_info * src); - - int format_title(const playable_location * source,string_base & out,const char * spec,const char * extra_items); - //reminder: see titleformat.h for descriptions of titleformatting parameters - //return 1 on success, 0 on failure (cant get info, used empty fields and filename) - - inline void update_info_dbonly(const file_info * info) {update_info(info,true);} //updates database, doesnt modify files - -#ifdef _DEBUG - int database_lock_count(); - void database_delockify(int wanted_count); - inline void assert_not_locked() - { - assert(database_lock_count()==0); - } - inline void assert_locked() - { - assert(database_lock_count()>0); - } -#endif - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - virtual void handle_release_multi(metadb_handle * const * list,unsigned count)=0; - virtual void handle_add_ref_multi(metadb_handle * const * list,unsigned count)=0; -}; - -class NOVTABLE metadb_callback : public service_base//use service_factory_single_t to instantiate, you will get called with database notifications -{//IMPORTANT: metadb_callback calls may happen from different threads ! watch out for deadlocks / calling things that work only from main thread / etc -public: - virtual void on_info_edited(metadb_handle * handle) {} - virtual void on_info_reloaded(metadb_handle * handle) {} - virtual void on_file_removed(metadb_handle * handle) {} - virtual void on_file_moved(metadb_handle * src,metadb_handle * dst) {} - virtual void on_file_new(metadb_handle * handle) {}//reserved for future use - virtual void on_file_removed_user(metadb_handle * handle) {}//user requested file to be removed from db, file didn't get physically removed -//warning: all callback methods are called inside database_lock section ! watch out for deadlock conditions if you use SendMessage() or critical sections - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE metadb_callback_simple : public service_base -{//this is always properly sync'd to main thread, unlike metadb_callback above -public: - virtual void on_info_change(metadb_handle * handle)=0; - virtual void on_file_moved(metadb_handle * src,metadb_handle * dst)=0; - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - - -class in_metadb_sync -{ -public: - in_metadb_sync() {metadb::get()->database_lock();} - ~in_metadb_sync() {metadb::get()->database_unlock();} -}; - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb_handle.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb_handle.cpp deleted file mode 100644 index 8b438bfcb..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb_handle.cpp +++ /dev/null @@ -1,224 +0,0 @@ -#include "foobar2000.h" - -namespace { - struct custom_sort_data - { - HANDLE text; - int index; - custom_sort_data(const char * p_text,int p_idx) - : text(uSortStringCreate(p_text)), index(p_idx) - {} - ~custom_sort_data() {uSortStringFree(text);} - }; -} -static int __cdecl custom_sort_compare(const custom_sort_data * &elem1, const custom_sort_data *&elem2 ) -{//depends on unicode/ansi shit, nonportable (win32 lstrcmpi) - return uSortStringCompare(elem1->text,elem2->text);//uStringCompare -} - - -void metadb_handle_list::sort_by_format_get_order(int * order,const char * spec,const char * extra_items) const -{ - ptr_list_simple data; - unsigned n; - string8 temp; - string8 temp2; - temp.set_mem_logic(mem_block::ALLOC_FAST_DONTGODOWN); - temp.prealloc(512); - temp2.set_mem_logic(mem_block::ALLOC_FAST_DONTGODOWN); - for(n=0;nhandle_format_title(temp,spec,extra_items); - const char * ptr = temp.get_ptr(); - if (strchr(ptr,3)) - { - titleformat::remove_color_marks(ptr,temp2); - ptr = temp2; - } - data.add_item(new custom_sort_data(ptr,n)); - } - - data.sort(custom_sort_compare); - - for(n=0;nindex; - } - - data.delete_all(); -} - -void metadb_handle_list::sort_by_format(const char * spec,const char * extra_items) -{ - unsigned count = get_count(); - mem_block_t order(count); - sort_by_format_get_order(order,spec,extra_items); - apply_order(order,count); -} - -bool metadb_handle::handle_query_meta_field(const char * name,int num,string_base & out) -{ - bool rv = false; - handle_lock(); - const file_info * info = handle_query_locked(); - if (info) - { - const char * val = info->meta_get(name,num); - if (val) - { - out = val; - rv = true; - } - } - handle_unlock(); - return rv; -} - -int metadb_handle::handle_query_meta_field_int(const char * name,int num)//returns 0 if not found -{ - int rv = 0; - handle_lock(); - const file_info * info = handle_query_locked(); - if (info) - { - const char * val = info->meta_get(name,num); - if (val) - { - rv = atoi(val); - } - } - handle_unlock(); - return rv; -} - -double metadb_handle::handle_get_length() -{ - double rv = 0; - handle_lock(); - const file_info * info = handle_query_locked(); - if (info) - rv = info->get_length(); - handle_unlock(); - return rv; -} - -__int64 metadb_handle::handle_get_length_samples() -{ - __int64 rv = 0; - handle_lock(); - const file_info * info = handle_query_locked(); - if (info) - rv = info->info_get_length_samples(); - handle_unlock(); - return rv; -} - - -void metadb_handle_list::delete_item(metadb_handle * ptr) -{ - remove_item(ptr); - ptr->handle_release(); -} - -void metadb_handle_list::delete_by_idx(int idx) -{ - metadb_handle * ptr = remove_by_idx(idx); - if (ptr) ptr->handle_release(); -} - -void metadb_handle_list::delete_all() -{ - if (get_count()>0) - { - metadb::get()->handle_release_multi(get_ptr(),get_count()); - remove_all(); - } -} - -void metadb_handle_list::add_ref_all() -{ - if (get_count()>0) metadb::get()->handle_add_ref_multi(get_ptr(),get_count()); -} - -void metadb_handle_list::delete_mask(const bit_array & mask) -{ - unsigned n,m=get_count(); - for_each_bit_array(n,mask,true,0,m) - get_item(n)->handle_release(); - remove_mask(mask); -} - -void metadb_handle_list::filter_mask_del(const bit_array & mask) -{ - unsigned n,m=get_count(); - for_each_bit_array(n,mask,false,0,m) - get_item(n)->handle_release(); - filter_mask(mask); -} - -void metadb_handle_list::remove_duplicates(bool b_release) -{ - unsigned count = get_count(); - if (count>0) - { - bit_array_bittable mask(count); - mem_block_t order(count); - - sort_by_format_get_order(order,"%_path_raw%|$num(%_subsong%,9)",0); - - unsigned n; - for(n=0;nval2) return 1; - else return 0; -} - -void metadb_handle_list::remove_duplicates_quick(bool b_release) -{ - unsigned count = get_count(); - if (count>0) - { - sort(remove_duplicates_quick_compare); - bit_array_bittable mask(count); - unsigned n; - bool b_found = false; - for(n=0;n & source) -{ - unsigned n,m = source.get_count(); - for(n=0;nhandle_duplicate()); -} - -void metadb_handle_list::sort_by_path_quick() -{ - sort_by_format("%_path_raw%",0); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb_handle.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb_handle.h deleted file mode 100644 index 9cd3f20fa..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/metadb_handle.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _FOOBAR2000_METADB_HANDLE_H_ -#define _FOOBAR2000_METADB_HANDLE_H_ - -#include "file_info.h" - -class reader; - -//metadb_handle is a reference to file_info stored in database (see: file_info.h) -//as long as handle is active, info about particular is kept in database and immediately available (unless file i/o error occurs or the file gets removed) -//metadb_handle is the most efficient way of passing around playable resource locations and info about them, since all you have to do is to copy a pointer (and possibly call handle_add_ref) -//metadb_handle also lets you efficiently store locations of playable resources without having to waste memory on file path strings allocated by playable_location etc -//metadb_handle lets you pull file_info immediately without searching database, unlike metadb::query and other metadb api calls -//metadb_handle objects keep their reference counts, eg. you need to make a matching handle_release() call for every handle_add_ref() - -/* -common n00b FAQ: - -getting file location from metadb_handle -> use handle_get_location(), it never fails, returned pointer valid until you release the handle -handle_query_locked MAY fail and return null when file io error occurs or something, so CHECK the result BEFORE using it -make sure you call handle_lock/handle_unlock when you use handle_query_locked, otherwise some other thread might modify database data while you are working with result and thing will be fucked - -unless commented otherwise, functions taking metadb_handle as parameter don't release the handle and add a reference if they store it; when function returns a metadb_handle, calling code is responsible for releasing it -EXCEPTION: all ptr_list-style objects dont touch reference counts when they receive/return metadb_handle; that includes ptr_list_interface, ptr_list_t and metadb_handle_list - -*/ - - -class NOVTABLE metadb_handle -{ -public: - virtual void handle_add_ref()=0; - virtual void handle_release()=0; - virtual int handle_query(file_info * dest,bool dbonly = false)=0;//dest can be null if you're only checking if info is available - virtual const file_info * handle_query_locked(bool dbonly = false)=0;//must be inside database_lock()-protected section, may return 0 if info is not available for some reason - virtual const playable_location * handle_get_location() const = 0;//never fails, returned pointer valid till you call release - virtual void handle_hint(const file_info * src)=0; - virtual int handle_format_title(string_base & out,const char * spec,const char * extra_items)=0;//reminder: see titleformat.h for descriptions of titleformatting parameters - virtual int handle_flush_info()=0;//tries to reload info from file - virtual int handle_update_info(const file_info * src,bool dbonly=false)=0;//return value - see metadb::update_info(); src may be null if you want to update file with info which is currently in database - virtual void handle_entry_dead()=0;//for reporting dead files; need to call handle_release() separately - virtual int handle_precache(reader * r=0)=0;//makes sure that info is in database; reader is optional - virtual void handle_user_requested_remove()=0;//user requests this object to be removed from database (but file isn't being physically removed) - virtual int handle_lock()=0;//same as metadb::database_lock() - virtual int handle_try_lock()=0; - virtual int handle_unlock()=0;//same as metadb::database_unlock() - virtual int handle_update_and_unlock(const file_info * info)=0;//new in 0.7.1; will unlock even if update fails - - //new in 0.8 - //time is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601; 0 for invalid/unknown time - virtual __int64 handle_get_modification_time() const = 0; - virtual void handle_set_modification_time(__int64)=0; - virtual __int64 handle_get_file_size() const = 0; - virtual void handle_set_file_size(__int64)=0; - virtual void handle_hint_ex(const file_info * src,__int64 time,__int64 size,bool b_fresh)=0; - virtual int handle_check_if_changed()=0;//compares known modification time with file system and reloads info if needed - virtual int handle_is_permcached() const = 0;//returns if this object is in "database" or not - virtual int handle_get_relative_path(string_base & out) const = 0; - - - inline int handle_query_dbonly(file_info * dest) {return handle_query(dest,true);} - inline const file_info * handle_query_locked_dbonly() {return handle_query_locked(true);} - - - inline metadb_handle * handle_duplicate() {handle_add_ref();return this;} - - bool handle_query_meta_field(const char * name,int num,string_base & out); - int handle_query_meta_field_int(const char * name,int num);//returns 0 if not found - double handle_get_length(); - __int64 handle_get_length_samples(); - - inline const char * handle_get_path() const//never fails - { - return handle_get_location()->get_path(); - } - inline int handle_get_subsong_index() const - { - return handle_get_location()->get_subsong_index(); - } - - - -protected: - metadb_handle() {} - ~metadb_handle() {}//verboten, avoid ptr_list_t stupidity -}; - -//important: standard conventions with addref'ing before returning / functions addref'ing their params DO NOT apply to pointer lists !!! - -class metadb_handle_list : public ptr_list_t -{ -public: - void delete_item(metadb_handle * ptr); - void delete_by_idx(int idx); - void delete_all(); - void add_ref_all(); - void delete_mask(const bit_array & mask); - void filter_mask_del(const bit_array & mask); - void duplicate_list(const ptr_list_base & source); - - void sort_by_format_get_order(int * order,const char * spec,const char * extra_items) const; //only outputs order, doesnt modify list - void sort_by_format(const char * spec,const char * extra_items); - void remove_duplicates(bool b_release = true); - void remove_duplicates_quick(bool b_release = true);//sorts by pointer values internally - void sort_by_path_quick(); - -}; - -class metadb_handle_lock -{ - metadb_handle * ptr; -public: - inline metadb_handle_lock(metadb_handle * param) - { - ptr = param->handle_duplicate(); - ptr->handle_lock(); - } - inline ~metadb_handle_lock() {ptr->handle_unlock();ptr->handle_release();} -}; - - -#endif //_FOOBAR2000_METADB_HANDLE_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/modeless_dialog.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/modeless_dialog.cpp deleted file mode 100644 index 9d212a977..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/modeless_dialog.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "foobar2000.h" - -void modeless_dialog_manager::add(HWND wnd) -{ - service_enum_t e; - modeless_dialog_manager * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - ptr->_add(wnd); - ptr->service_release(); - } -} - -void modeless_dialog_manager::remove(HWND wnd) -{ - service_enum_t e; - modeless_dialog_manager * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - ptr->_remove(wnd); - ptr->service_release(); - } -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/modeless_dialog.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/modeless_dialog.h deleted file mode 100644 index 7d05e558f..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/modeless_dialog.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _MODELESS_DIALOG_H_ -#define _MODELESS_DIALOG_H_ - -#include "service.h" - -//use this to hook your modeless dialogs to main message loop and get IsDialogMessage() stuff -//not needed for config pages - -class modeless_dialog_manager : public service_base -{ -private: - virtual void _add(HWND wnd)=0; - virtual void _remove(HWND wnd)=0; -public: - static void add(HWND wnd); - static void remove(HWND wnd); - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -#endif //_MODELESS_DIALOG_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/output.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/output.cpp deleted file mode 100644 index 2354286b8..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/output.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "foobar2000.h" - -output * output::create(GUID g) -{ - output * ptr; - service_enum_t e; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->get_guid()==g) return ptr; - ptr->service_release(); - } - return 0; -} - - -void output_i_base::set_error(const char * msg) -{ - console::error(msg); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/output.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/output.h deleted file mode 100644 index 70c2be0d0..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/output.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef _OUTPUT_H_ -#define _OUTPUT_H_ - -#include "service.h" -#include "audio_chunk.h" -#include "interface_helper.h" - - -class NOVTABLE output : public service_base -{ -public: - virtual double get_latency()=0;//in seconds - virtual int process_samples(const output_chunk * chunk,int format_code)=0;//1 on success, 0 on error, no sleeping, copies data to its own buffer immediately; format_code - see enums below - virtual int update()=0;//return 1 if ready for next write, 0 if still working with last process_samples(), -1 on error - virtual void pause(int state)=0; - virtual void flush()=0; - virtual void force_play()=0; - virtual GUID get_guid()=0;//for storing config - virtual const char * get_name()=0;//for preferences - virtual const char * get_config_page_name() {return 0;}//for "go to settings" button, return 0 if you dont have a config page - - enum - { - DATA_FORMAT_LINEAR_PCM, - DATA_FORMAT_IEEE_FLOAT,//32bit float - }; - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static output * create(GUID g); - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - -}; - -//implementation helper, you can derive from this instead of deriving directly from output -class NOVTABLE output_i_base : public output -{ - mem_block_t chunk; - int chunk_size,chunk_ptr; - int new_bps,new_srate,new_nch; - int cur_bps,cur_srate,cur_nch; - int is_open; - int cur_format_code,new_format_code; - - -protected: - output_i_base() - { - is_open = 0; - chunk_size = chunk_ptr = 0; - } - - void set_error(const char * msg); - - //override me - virtual int open_ex(int srate,int bps,int nch,int format_code)//return 1 on success, 0 on failure, might get called when you are open already (eg. new PCM format) - { - if (format_code==DATA_FORMAT_LINEAR_PCM) - { - return open(srate,bps,nch);//call old version if not overridden - } - else - { - set_error("Unsupported output data format."); - return 0; - } - } - virtual int open(int srate,int bps,int nch) {return 0;}//old version - virtual int can_write()=0;//in bytes - virtual int write(const char * data,int bytes)=0;//return 1 on success, 0 on error, bytes always <= last can_write() return value - virtual int get_latency_bytes()=0;//amount of data buffered (write_offset-playback_offset), in bytes - virtual void pause(int state)=0; - virtual void force_play()=0; - virtual int do_flush() {return 1;} //return 1 if you need reopen, 0 if successfully flushed - virtual int is_playing() {return get_latency_bytes()>0;} - virtual GUID get_guid()=0; - virtual const char * get_name()=0; - -public: - virtual double get_latency() - { - double rv = 0; - if (is_open) - { - int delta = get_latency_bytes(); - if (delta<0) delta=0; - rv += (double) (delta / (cur_nch * cur_bps/8)) / (double) cur_srate; - } - if (chunk_size>0 && chunk_ptrdata,p_chunk->size); - chunk_size = p_chunk->size; - chunk_ptr = 0; - new_bps = p_chunk->bps; - new_srate = p_chunk->srate; - new_nch = p_chunk->nch; - new_format_code = format_code; - return 1; - } - virtual int update() - { - if (chunk_size<=0 || chunk_ptr>=chunk_size) return 1; - if (is_open && (cur_bps!=new_bps || cur_srate!=new_srate || cur_nch!=new_nch || cur_format_code!=new_format_code)) - { - force_play(); - if (is_playing()) return 0; - is_open = 0; - } - if (!is_open) - { - if (!open_ex(new_srate,new_bps,new_nch,new_format_code)) - return -1;//error - cur_srate = new_srate; - cur_nch = new_nch; - cur_bps = new_bps; - cur_format_code = new_format_code; - is_open = 1; - } - - int cw; - while((cw = can_write())>0 && chunk_ptrcw) d=cw; - if (!write(chunk+chunk_ptr,d)) return -1; - chunk_ptr+=d; - } - if (chunk_ptr -class output_factory : public service_factory_t {}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/output_manager.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/output_manager.h deleted file mode 100644 index 6ba758af2..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/output_manager.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef _OUTPUT_MANAGER_H_ -#define _OUTPUT_MANAGER_H_ - -#include "output.h" - -struct output_config -{ - GUID output;//null guid for default user-configured device - - int b_override_format; - - struct format_t - { - int bps,bps_pad; - int b_float; - int b_dither; - - }; - - format_t format;//format valid only if b_override_format is set to non-zero, otherwise user settings from core preferences are used - - output_config() - { - memset(&output,0,sizeof(output)); - b_override_format = 0; - - format.bps = 16; - format.bps_pad = 16; - format.b_float = 0; - format.b_dither = 1; - } -}; - -class NOVTABLE output_manager : public service_base -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static output_manager * create() {return service_enum_create_t(output_manager,0);}//may fail on pre-0.63 - - virtual void get_default_config(output_config * out)=0;//retrieves current user settings from core preferences; do not pass returned data to set_config (same effect as not calling set_config at all or passing uninitialized struct) - - virtual void set_config(const output_config * param)=0;//optionally call before first use - - virtual double get_latency()=0;//in seconds - virtual int process_samples(const audio_chunk* chunk)=0;//1 on success, 0 on error, no sleeping, copies data to its own buffer immediately; format_code - see enums below - virtual int update()=0;//return 1 if ready for next write, 0 if still working with last process_samples(), -1 on error - virtual void pause(int state)=0; - virtual void flush()=0; - virtual void force_play()=0; -}; - -#endif //_OUTPUT_MANAGER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/packet_decoder.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/packet_decoder.cpp deleted file mode 100644 index 692a9f21e..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/packet_decoder.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "foobar2000.h" - -packet_decoder * packet_decoder::g_open(const GUID & owner,unsigned param1,const void * param2,unsigned param2size,file_info * info) -{ - service_enum_t e; - packet_decoder * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->open_stream(owner,param1,param2,param2size,info)) return ptr; - ptr->service_release(); - } - return 0; -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/packet_decoder.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/packet_decoder.h deleted file mode 100644 index 79691e881..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/packet_decoder.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef _FOOBAR2000_PACKET_DECODER_H_ -#define _FOOBAR2000_PACKET_DECODER_H_ - -#include "service.h" -#include "audio_chunk.h" - -class packet_decoder : public service_base -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual bool open_stream(const GUID & owner,unsigned param1,const void * param2,unsigned param2size,file_info * info)=0;//owner - container GUID, param1/2 - contents depend on owner - virtual unsigned set_stream_property(const GUID & type,unsigned param1,const void * param2,unsigned param2size,file_info * info) {return 0;}//optional, return values depend on guid, return 0 by default - - virtual unsigned get_max_frame_dependency()=0; - virtual double get_max_frame_dependency_time()=0; - - virtual void reset_after_seek()=0; - virtual bool decode(const void * buffer,unsigned bytes,audio_chunk * out)=0;//may return empty chunk (decoder delay etc), caller must check for it (and not crash on samplerate==0 etc) - virtual const char * get_name()=0;//for diagnostic purposes, codec list, etc - - static packet_decoder * g_open(const GUID & owner,unsigned param1,const void * param2,unsigned param2size,file_info * info); - - static const GUID owner_MP4,owner_matroska,owner_MP3; - - struct matroska_setup - { - const char * codec_id; - unsigned sample_rate,sample_rate_output; - unsigned channels; - unsigned codec_private_size; - const void * codec_private; - }; - //owner_MP4: param1 - codec ID (MP4 audio type), param2 - MP4 codec initialization data - //owner_MP3: raw MP3/MP2 file, parameters ignored - //owner_matroska: param2 = matroska_setup struct, param2size size must be equal to sizeof(matroska_setup) - - - //these are used to initialize PCM decoder - static const GUID property_samplerate,property_bitspersample,property_channels,property_byteorder,property_signed; - //property_samplerate : param1 == sample rate in hz - //property_bitspersample : param1 == bits per sample - //property_channels : param1 == channel count - //property_byteorder : if (param1) little_endian; else big_endian; - //property_signed : if (param1) signed; else unsigned; -}; - - -template -class packet_decoder_factory : public service_factory_t {}; - - -#endif //_FOOBAR2000_PACKET_DECODER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/play_callback.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/play_callback.h deleted file mode 100644 index ce346a857..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/play_callback.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _PLAY_CALLBACK_H_ -#define _PLAY_CALLBACK_H_ - -#include "service.h" - -#include "metadb_handle.h" -//callbacks for getting notified about playback status -//multithread safety: all play_callback api calls come from main thread. - -#include "play_control.h" - -class NOVTABLE play_callback : public service_base -{ -public: - - enum { - MASK_on_playback_starting = 1<<0, MASK_on_playback_new_track = 1<<1, MASK_on_playback_stop = 1<<2, - MASK_on_playback_seek = 1<<3, MASK_on_playback_pause = 1<<4, MASK_on_playback_edited = 1<<5, - MASK_on_playback_dynamic_info = 1<<6, MASK_on_playback_time = 1<<7, MASK_on_volume_change = 1<<8, - }; - - virtual unsigned get_callback_mask() {return (unsigned)(-1);} - //returns combination of MASK_* above, return value must be constant, called only once - //system uses it as a hint to avoid calling you when not needed, to reduce working code size (and "memory usage") - - virtual void on_playback_starting()=0; - virtual void on_playback_new_track(metadb_handle * track)=0; - virtual void on_playback_stop(play_control::stop_reason reason)=0; - virtual void on_playback_seek(double time)=0; - virtual void on_playback_pause(int state)=0; - virtual void on_playback_edited(metadb_handle * track)=0;//currently played file got edited - virtual void on_playback_dynamic_info(const file_info * info,bool b_track_change)=0; - virtual void on_playback_time(metadb_handle * track,double val) {}//called every second - virtual void on_volume_change(int new_val) {};//may also happen when not playing - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -template -class play_callback_factory : public service_factory_single_t {}; - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/play_control.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/play_control.cpp deleted file mode 100644 index d708e992a..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/play_control.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "foobar2000.h" - - -play_control * play_control::get() -{ - static play_control * ptr; - if (!ptr) ptr = service_enum_create_t(play_control,0); - return ptr; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/play_control.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/play_control.h deleted file mode 100644 index 73a95b554..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/play_control.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _PLAY_CONTROL_H_ -#define _PLAY_CONTROL_H_ - -#include "service.h" -#include "interface_helper.h" -#include "metadb_handle.h" -//important: you should call api commands declared in this header ONLY from main thread !! -//do not call them from a database_lock section, some commands (eg. those stopping playback) will deadlock if you do ! - - -//note: -//all methods returning metadb_handle return add_ref'd handles, you have to handle_release them -//all methods taking metadb_handle will add_ref them if they store them, so it's your responsibility to later release handles you pass - -class NOVTABLE play_control : public service_base -{ -public: - - enum stop_reason { - STOP_REASON_USER = 0, - STOP_REASON_EOF, - STOP_REASON_STARTING_ANOTHER, - }; - - - enum track_command { - TRACK_COMMAND_ABORT = -1, - TRACK_COMMAND_DEFAULT = 0, - TRACK_COMMAND_PLAY, - TRACK_COMMAND_NEXT, - TRACK_COMMAND_PREV, - TRACK_COMMAND_SETTRACK, - TRACK_COMMAND_RAND, - }; - - virtual metadb_handle * get_now_playing()=0;//will return 0 if not playing - virtual void play_item(metadb_handle * handle)=0; - virtual void play_start(track_command cmd = TRACK_COMMAND_PLAY)=0; - virtual void play_stop(stop_reason reason = STOP_REASON_USER)=0; - virtual bool is_playing()=0; - virtual bool is_paused()=0; - virtual double get_playback_time()=0; - virtual void pause()=0; - - virtual void show_config(const char * page_name)=0; - - virtual bool get_stop_after_current()=0; - virtual void set_stop_after_current(bool state)=0; - virtual void set_volume(int)=0; - virtual int get_volume()=0;//volume is in 0.01 dB - virtual void volume_up()=0; - virtual void volume_down()=0; - virtual void volume_mute_toggle()=0; - - virtual void playback_seek(double param)=0; - virtual void playback_seek_delta(double param)=0; - virtual bool playback_can_seek()=0; - virtual double playback_get_position()=0; - - //reminder: see titleformat.h for descriptions of titleformatting parameters - virtual void playback_format_title(string_base & out,const char * spec,const char * extra_items=0)=0; - - virtual bool playback_format_title_ex(metadb_handle * handle,string_base & out,const char * spec,const char * extra_items,bool b_include_time,bool b_include_dynamicinfo)=0;//0.7.1 and above - - double playback_get_length() - { - double rv = 0; - metadb_handle * ptr = get_now_playing(); - if (ptr) - { - rv = ptr->handle_get_length(); - ptr->handle_release(); - } - return rv; - } - - inline void toggle_stop_after_current() {set_stop_after_current(!get_stop_after_current());} - - static play_control * get(); - - static void g_show_config(const char * page_name) - { - get()->show_config(page_name); - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - - -//playlist_oper moved to playlist.h - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playable_location.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/playable_location.cpp deleted file mode 100644 index 9dac871e4..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playable_location.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "foobar2000.h" - -int playable_location::compare(const playable_location * src) const -{ - int ret = uStringCompare(get_path(),src->get_path()); - if (ret!=0) return ret; - else - { - int n1 = get_number(), n2 = src->get_number(); - if (n1n2) return 1; - else return 0; - } -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playable_location.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/playable_location.h deleted file mode 100644 index 98d508e92..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playable_location.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef _FOOBAR2000_PLAYABLE_LOCATION_H_ -#define _FOOBAR2000_PLAYABLE_LOCATION_H_ - -#include "service.h" - -#include "interface_helper.h" - -//playable_location stores location of a playable resource, currently implemented as file path and integer for indicating multiple playable "subsongs" per file -//also see: file_info.h -//for getting more info about resource referenced by a playable_location, see metadb.h - -//char* strings are all UTF-8 - -class playable_location//interface (for passing around between DLLs) -{ -public: - virtual const char * get_path() const =0; - virtual void set_path(const char*)=0; - virtual int get_number() const =0; - virtual void set_number(int)=0; - virtual ~playable_location() {}; - - void copy(const playable_location * src) - { - set_path(src->get_path()); - set_number(src->get_number()); - } -#if 0 - int compare_sort(const playable_location * src) const - { - int ret = stricmp_utf8_full(file_path_display(get_path()),file_path_display(src->get_path())); - if (ret!=0) return ret; - else return compare(src); - }; -#endif - - int compare(const playable_location * src) const; - - const playable_location & operator=(const playable_location & src) - { - copy(&src); - return *this; - } - - inline bool is_empty() {return get_path()[0]==0 && get_number()==0;} - inline void reset() {set_path("");set_number(0);} - inline int get_subsong_index() const {return get_number();} - inline void set_subsong_index(int v) {set_number(v);} -}; - -class playable_location_i : public playable_location//implementation -{ - string_simple path; - int number; -public: - - virtual const char * get_path() const {return path;} - virtual void set_path(const char* z) {path=z;} - virtual int get_number() const {return number;} - virtual void set_number(int z) {number=z;} - - playable_location_i() {number=0;} - - const playable_location_i & operator=(const playable_location & src) - { - copy(&src); - return *this; - } - - playable_location_i(const char * p_path,int p_number) : path(p_path), number(p_number) {} - - playable_location_i(const playable_location & src) {copy(&src);} -}; - - -// usage: something( make_playable_location("file://c:\blah.ogg",0) ); -// only for use as a parameter to a function taking const playable_location* -class make_playable_location : private playable_location -{ - const char * path; - int num; - virtual const char * get_path() const {return path;} - virtual void set_path(const char*) {} - virtual int get_number() const {return num;} - virtual void set_number(int) {} - -public: - make_playable_location(const char * p_path,int p_num) : path(p_path), num(p_num) {} - operator const playable_location * () {return this;} -}; - - -#endif //_FOOBAR2000_PLAYABLE_LOCATION_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playback_core.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/playback_core.h deleted file mode 100644 index 8021eccd0..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playback_core.h +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef _PLAYBACK_CORE_H_ -#define _PLAYBACK_CORE_H_ - -#include "service.h" -#include "metadb_handle.h" -#include "replaygain.h" -#include "output_manager.h" - -struct playback_config -{ - enum dsp_mode_t - { - DSP_DEFAULT,//DSP enabled, use core settings - DSP_DISABLED, - DSP_CUSTOM,//DSP enabled, use custom settings - }; - - replaygain::mode_t replaygain_mode; - dsp_mode_t dsp_mode; - int process_total_time_counter;//boolean - int low_priority;//boolean - int process_dynamic_info;//boolean - - - - struct - { - unsigned int count; - const GUID * guids; - } dsp_custom;//valid only if dsp_mode = DSP_CUSTOM - - output_config output; - - playback_config() - { - replaygain_mode = replaygain::MODE_DEFAULT; - dsp_mode = DSP_DEFAULT; - dsp_custom.count = 0; - dsp_custom.guids = 0; - process_total_time_counter = 0; - low_priority = 0; - process_dynamic_info = 0; - } -}; - - -class NOVTABLE playback_core : public service_base -{ -public: - - struct track//reminder: if you pass this around, functions you call will not free the metadb_handle; if you return this, make sure you handle_add_ref(), because the code calling you will be responsible for freeing - { - metadb_handle * handle; - int user; - }; - - - class NOVTABLE callback - { - public: - enum file_error_handler - { - file_error_abort, - file_error_continue, - file_error_replace - }; - virtual bool get_next_track(track * out)=0;//return false if end-of-playlist, true if out struct is filled with data - virtual void on_file_open(const track * src) {}//called before attempting file open; use only for logging etc - virtual void on_file_open_success(const track * ptr) {} - virtual file_error_handler on_file_error(const track * src,track * replace) {return file_error_abort;} - virtual void on_track_change(const track * ptr) {};//called when currently played track has changed, some time after get_next_track - virtual void on_dynamic_info(const file_info * info,bool b_track_change) {} - virtual void on_exiting(bool error) {};//called when terminating (either end-of-last-track or some kind of error or stop()) - - //DO NOT call any playback_core methods from inside callback methods ! - //all callback methods are called from playback thread, you are responsible for taking proper anti-deadlock measures (eg. dont call SendMessage() directly) - //safest way to handle end-of-playback: create a window from main thread, PostMessage to it when you get callbacks, execute callback handlers (and safely call playback_core api) from message handlers - }; - - class NOVTABLE vis_callback - { - public: - virtual void on_data(class audio_chunk * chunk,double timestamp)=0;//timestamp == timestamp of first sample in the chunk, according to get_cur_time_fromstart() timing - virtual void on_flush()=0; - }; - - struct stats - { - double decoding_position,playback_position,dsp_latency,output_latency; - }; - - - //MUST be called first, immediately after creation (hint: create() does this for you) - virtual void set_callback(callback * ptr)=0; - - virtual void set_vis_callback(vis_callback * ptr)=0;//optional - - virtual void set_config(const playback_config * data)=0;//call before starting playback - - virtual void start()=0; - virtual void stop()=0; - virtual bool is_playing()=0; - virtual bool is_finished()=0; - virtual bool is_paused()=0; - virtual void pause(int paused)=0; - - virtual bool can_seek()=0; - virtual void seek(double time)=0; - virtual void seek_delta(double time_delta)=0; - - virtual double get_cur_time()=0; - virtual double get_cur_time_fromstart()=0; - virtual bool get_cur_track(track * out)=0; - virtual bool get_stats(stats * out)=0; - - - metadb_handle * get_cur_track_handle() - { - track t; - if (get_cur_track(&t)) return t.handle; - else return 0; - } - - double get_total_time() - { - double rv = 0; - metadb_handle * ptr = get_cur_track_handle(); - if (ptr) - { - rv = ptr->handle_get_length(); - ptr->handle_release(); - } - return rv; - } - - static playback_core * create(callback * cb) - { - playback_core * ptr = service_enum_create_t(playback_core,0); - if (ptr) ptr->set_callback(cb); - return ptr; - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE play_sound : public service_base -{ -public: - enum - { - USE_REPLAYGAIN = 1, - USE_DSP = 2, - }; - - virtual void play(metadb_handle * file,const playback_config * settings=0)=0;//settings are optional; if non-zero, they will be passed to playback_core being used - virtual void stop_all()=0; - - static play_sound * get() {return service_enum_create_t(play_sound,0);}//safe not to release - - static void g_play(metadb_handle * file,const playback_config * settings) - { - play_sound * ptr = get(); - if (ptr) ptr->play(file,settings); - } - - static void g_stop_all() - { - play_sound * ptr = get(); - if (ptr) ptr->stop_all(); - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist.cpp deleted file mode 100644 index 5eac144c9..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include "foobar2000.h" - -void playlist_oper::move_items(int delta) -{ - if (delta==0) return; - - int count = get_count(); - int n; - - mem_block_t order(count); - mem_block_t selection(count); - - for(n=0;n0;delta--) - { - int idx; - for(idx=count-2;idx>=0;idx--) - { - if (selection[idx] && !selection[idx+1]) - { - order.swap(idx,idx+1); - selection.swap(idx,idx+1); - } - } - } - } - - apply_order(order,count); -} -/* -void playlist_callback::on_order(const int * order,int count) -{ - int n; - for(n=0;nget_focus(); - if (focus>=0 && order[focus]!=focus) on_focus_change(order[focus],focus); -} -*/ -playlist_oper * playlist_oper::get() -{//since this is called really often, lets cache a pointer instead of flooding service core - static playlist_oper * g_ptr; - if (g_ptr==0) g_ptr = service_enum_create_t(playlist_oper,0); - return g_ptr; -} - -void playlist_oper::remove_sel(bool crop) -{ - bit_array_bittable mask(get_count()); - get_sel_mask(mask); - if (crop) remove_mask(bit_array_not(mask)); - else remove_mask(mask); -} - -unsigned playlist_switcher::find_playlist(const char * name) -{ - unsigned n,max = get_num_playlists(); - string8_fastalloc temp; - for(n=0;n=num || num<=1) return false; - if (idx==active) - { - if (idx+1>=num) active = idx-1; - else active = idx+1; - set_active_playlist(active); - } - return delete_playlist(idx); -} - -bool playlist_switcher::find_or_create_playlist_activate(const char * name) -{ - bool rv = false; - unsigned idx = find_or_create_playlist(name); - if (idx != (unsigned)(-1)) - rv = set_active_playlist(idx); - return rv; -} - -int playback_flow_control::get_next(int previous_index,int focus_item,int total,int advance,bool follow_focus,bool user_advance,unsigned playlist) -{ - int rv = -1; - playback_flow_control_v2 * this_v2 = service_query_t(playback_flow_control_v2,this); - if (this_v2) - { - rv = this_v2->get_next(previous_index,focus_item,total,advance,follow_focus,user_advance,playlist); - this_v2->service_release(); - } - else - { - console::error(uStringPrintf("\"%s\" needs to be updated to 0.8 SDK or newer in order to function.",get_name())); - } - return rv; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist.h deleted file mode 100644 index 888a9407e..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef _PLAYLIST_H_ -#define _PLAYLIST_H_ - -#include "service.h" -#include "metadb_handle.h" -#include "play_control.h" -#include "interface_helper.h" - -//important: playlist engine is SINGLE-THREADED. call any APIs not from main thread and things will either blow up or refuse to work. all callbacks can be assumed to come from main thread. - - -//notes: -//all methods returning metadb_handle return add_ref'd handles, you have to handle_release them -//all methods taking metadb_handle will add_ref them if they store them, so it's your responsibility to later release handles you pass - -class NOVTABLE playlist_oper : public service_base -{ -public: - //retrieving info - virtual int get_count()=0; - virtual bool get_sel(int idx)=0;//returns reference to a static object that holds state of playlist selection - virtual bool get_sel_mask(bool * out,unsigned count)=0; - virtual void get_sel_mask(bit_array_var & out); - virtual metadb_handle * get_item(int index)=0; - virtual int get_now_playing()=0;//will return -1 when not playing or currently played track isn't on playlist - virtual int get_focus()=0; - virtual int get_playback_cursor()=0; - virtual void format_title(int idx,string_base & out,const char * spec,const char * extra_items)=0;//spec may be null, will use core settings; extra items are optional - virtual void get_format_spec(string_base & out)=0; - - //modifying playlist - virtual void set_sel_mask(const bit_array & sel,const bit_array & mask)=0; - virtual void remove_mask(const bit_array & items)=0; - virtual void replace_item(int idx,metadb_handle * handle)=0; - virtual void set_focus(int idx)=0; - virtual void add_items(const ptr_list_base & data,bool replace = false,int insert_idx = -1,bool select = false,bool filter = true)=0; - //data - entries to insert, replace = replace-current-playlist flag, insert_idx - where to insert (-1 will append them), select - should new items be selected or not - virtual void add_locations(const ptr_list_base & urls,bool replace = false,int insert_idx = -1,bool select = false,bool filter = true)=0; - - virtual void apply_order(const int * order,int count)=0; - virtual void sort_by_format(const char * spec,int sel_only)=0;//spec==0 => randomizes - virtual void set_playback_cursor(int idx)=0; - virtual metadb_handle * playback_advance(play_control::track_command cmd)=0;//deprecated in 0.8 - virtual void undo_restore()=0; - virtual void undo_reset()=0; - virtual void ensure_visible(int idx)=0; - - //other - virtual void play_item(int idx)=0; - - - //new (0.8) - virtual bool process_locations(const ptr_list_base & urls,ptr_list_base & out,bool filter = true,const char * mask = 0)=0; - virtual bool process_dropped_files(interface IDataObject * pDataObject,ptr_list_base & out,bool filter = true)=0; - virtual bool process_dropped_files_check(interface IDataObject * pDataObject)=0; - virtual interface IDataObject * create_dataobject(const ptr_list_base & data)=0; - virtual void get_sel_items(ptr_list_base & out)=0; - virtual int get_sel_count()=0; - virtual void get_items_mask(ptr_list_base & out, const bit_array & mask)=0; - - //helper - - inline void add_location(const char * url,bool replace = false,int insert_idx = -1,bool select = false,bool filter = true) - { - ptr_list_t temp; - temp.add_item(url); - add_locations(temp,replace,insert_idx,select,filter); - } - - inline void set_sel_mask(const bit_array & sel) {set_sel_mask(sel,bit_array_true());} - inline void set_sel(int idx,bool state) {set_sel_mask(bit_array_val(state),bit_array_one(idx));} - inline void remove_item(int idx) {remove_mask(bit_array_one(idx));} - inline void set_focus_sel(int idx) {set_focus(idx);set_sel_mask(bit_array_one(idx));} - inline void reset() {remove_mask(bit_array_true());} - inline void remove_all() {remove_mask(bit_array_true());} - inline void set_sel_one(int idx) {set_sel_mask(bit_array_one(idx));} - - inline bool is_sel_count_greater(int v) - { - return get_sel_count()>v; - } - - - - void remove_sel(bool crop); - - void move_items(int delta); - - static playlist_oper * get(); - - inline metadb_handle * get_focus_item() - { - return get_item(get_focus());//may return null - } - - void get_data(ptr_list_interface & out) - { - get_items_mask(out,bit_array_true()); - } - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - - -//note: certain methods may get called outside initquit ! -//playlist_callback methods are called by playlist engine. -class NOVTABLE playlist_callback : public service_base -{ -public: - virtual void on_items_added(int start, int count)=0;//inside any of these methods, you can call playlist_oper APIs to get exact info about what happened (but only methods that read playlist state, not those that modify it) - virtual void on_order(const int * order,int count)=0;//changes selection too; doesnt actually change set of items that are selected or item having focus, just changes their order - virtual void on_items_removing(const bit_array & mask)=0;//called before actually removing them - virtual void on_items_removed(const bit_array & mask)=0;//note: items being removed are de-selected first always - virtual void on_sel_change(int idx,bool state)=0; - virtual void on_sel_change_multi(const bit_array & before,const bit_array & after,int count)=0; - virtual void on_focus_change(int from,int to)=0;//focus may be -1 when no item has focus; reminder: focus may also change on other callbacks - virtual void on_modified(int idx)=0; - virtual void on_replaced(int idx) {on_modified(idx);} - virtual void on_ensure_visible(int idx) {} - virtual void on_default_format_changed() {} - //note: if you cache strings or whatever, make sure to flush cache when total item count changes, because stuff like %_playlist_total% may change as well (not to mention %_playlist_number% everywhere) - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE playback_flow_control : public service_base -{ -public: - virtual const char * get_name()=0; - - virtual int get_next(int previous_index,int focus_item,int total,int advance,bool follow_focus,bool user_advance) {return -1;}//deprecated - - int get_next(int previous_index,int focus_item,int total,int advance,bool follow_focus,bool user_advance,unsigned playlist); - - //int advance : -1 for prev, 0 for play, 1 for next - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } -}; - -class NOVTABLE playback_flow_control_v2 : public playback_flow_control -{ -public: - virtual int get_next(int previous_index,int focus_item,int total,int advance,bool follow_focus,bool user_advance,unsigned playlist)=0; - //previous_index and focus_item may be -1; return -1 to stop - //IMPORTANT (changed in 0.8): you are in playlist indicated by , use playlist_switcher methods to access data - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return playback_flow_control::service_query(guid); - } - -}; - -template -class playback_flow_control_factory : public service_factory_single_t {}; - -//helper code for manipulating configuration of playback flow control (repeat/shuffle/whatever) => see ../helpers/playback_order_helper.h - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_entry.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_entry.h deleted file mode 100644 index 197bd0063..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_entry.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _PLAYLIST_ENTRY_H_ -#define _PLAYLIST_ENTRY_H_ - -//DEPRECATED (or rather, renamed to playable_location to prevent further confusion with playlist-related operations) - -#include "playable_location.h" - -//backwards-compatibility defines - -#define playlist_entry playable_location -#define playlist_entry_i playable_location_i -#define make_playlist_entry make_playable_location - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_loader.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_loader.cpp deleted file mode 100644 index 3c5a96df9..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_loader.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "foobar2000.h" - -int playlist_loader::load_playlist(const char * p_filename,playlist_loader_callback * callback) -{ - TRACK_CALL_TEXT("playlist_loader::load_playlist"); - string8 filename = file_path_canonical(p_filename); - service_enum_t e; - playlist_loader * l; - - string_extension_8 extension(filename); - - bool found = 0; - reader * r = 0; - - for(l=e.first();l && !found;l = e.next()) - { - if (!stricmp_utf8(l->get_extension(),extension)) - { - found = 1; - if (r==0) - r = file::g_open(filename,reader::MODE_READ); - if (r) - { - r->seek(0); - int rv=l->open(filename,r,callback); - if (!rv) found=0; - } - } - l->service_release(); - } - if (r) r->reader_release(); - return found ? 1 : 0; -} - -void playlist_loader::process_path(const char * p_filename,playlist_loader_callback * callback,playlist_loader_callback::entry_type type) -{ - TRACK_CALL_TEXT("playlist_loader::process_path"); - file_path_canonical filename(p_filename); - if (!callback->on_progress(0)) return; - - { - directory_callback_i dir_list; - if (directory::g_list(filename,&dir_list,callback)) - { - unsigned n; - for(n=0;non_progress(0)) break; - } - return; - } - - bool found = false; - - - service_enum_t e; - archive * d; - for(d=e.first();d;d=e.next()) - { - int rv; - rv = d->list(filename,&dir_list,callback); - - if (rv) - { - unsigned n; - for(n=0;non_progress(0)) break; - } - - if (!callback->on_progress(0)) break; - d->precache(filename,callback); - - found = true; - } - d->service_release(); - if (found) break; - - if (!callback->on_progress(0)) break; - } - - if (found || !callback->on_progress(0)) return; - - } - -// if (input::g_test_filename(filename)) - { - track_indexer::g_get_tracks_wrap(filename,callback,type,0); - } -} - -int playlist_loader::save_playlist(const char * p_filename,const ptr_list_base & data) -{ - TRACK_CALL_TEXT("playlist_loader::save_playlist"); - string8 filename = file_path_canonical(p_filename); - reader * r = file::g_open(filename,reader::MODE_WRITE_NEW); - if (!r) return 0; - int rv = 0; - - string_extension ext(filename); - - service_enum_t e; - playlist_loader * l; - for(l=e.first();l;l = e.next()) - { - if (l->can_write() && !stricmp_utf8(ext,l->get_extension()) && l->write(filename,r,data)) - { - rv=1; - break; - } - l->service_release(); - } - - r->reader_release(); - - if (!rv) file::g_remove(filename); - - return rv; -} - -int track_indexer::g_get_tracks_callback(const char * filename,callback * out,reader * r) -{ - TRACK_CALL_TEXT("track_indexer::g_get_tracks_callback"); - service_enum_t e; - track_indexer * t; - - for(t=e.first();t;t = e.next()) - { - int rv; - rv = t->get_tracks(filename,out,r); - t->service_release(); - if (rv>0) return rv; - } - out->on_entry(make_playable_location(filename,0));//assume single track if noone reports - return 0; -} - - -int track_indexer::get_tracks_ex(const char * filename,ptr_list_base & out,reader * r) -{ - { - track_indexer_v2 * this_v2 = service_query_t(track_indexer_v2,this); - if (this_v2) - { - int rv = this_v2->get_tracks_ex(filename,out,r); - this_v2->service_release(); - return rv; - } - } - - return get_tracks(filename,&callback_i_metadb(out),r); -} - -int track_indexer::g_get_tracks_ex(const char * filename,ptr_list_base & out,reader * r) -{ - TRACK_CALL_TEXT("track_indexer::g_get_tracks_ex"); - service_enum_t e; - track_indexer * t; - - for(t=e.first();t;t = e.next()) - { - int rv; - rv = t->get_tracks_ex(filename,out,r); - t->service_release(); - if (rv>0) return rv; - } - out.add_item(metadb::get()->handle_create(make_playable_location(filename,0)));//assume single track if noone reports - return 0; -} - - -int track_indexer::g_get_tracks_wrap(const char * filename,playlist_loader_callback * out,playlist_loader_callback::entry_type type,reader * r) -{ - service_enum_t e; - track_indexer * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - int rv = 0; - track_indexer_v2 * ptr_v2 = service_query_t(track_indexer_v2,ptr); - if (ptr_v2) - { - metadb_handle_list temp; - rv = ptr_v2->get_tracks_ex(filename,temp,r); - ptr_v2->service_release(); - if (rv>0) - { - unsigned n, m = temp.get_count(); - for(n=0;non_entry_dbhandle(temp[n],type); - } - temp.delete_all(); - } - else - { - rv = ptr->get_tracks(filename,&callback_i_wrap(out,type),r); - } - ptr->service_release(); - if (rv>0) return rv; - } - - out->on_entry(make_playable_location(filename,0),type); - return 0; - -} - - -bool playlist_loader::is_our_content_type(const char * param) -{ - bool rv = false; - playlist_loader_v2 * this_v2 = service_query_t(playlist_loader_v2,this); - if (this_v2) - { - rv = this_v2->is_our_content_type(param); - this_v2->service_release(); - } - return rv; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_loader.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_loader.h deleted file mode 100644 index 93402e3ce..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_loader.h +++ /dev/null @@ -1,188 +0,0 @@ -#ifndef _PLAYLIST_LOADER_H_ -#define _PLAYLIST_LOADER_H_ - -#include "service.h" - -#include "reader.h" - -#include "metadb.h" - -class NOVTABLE playlist_loader_callback //receives new playlist entries from playlists/filesystem/whatever -{ -public: - enum entry_type - { - USER_REQUESTED, - DIRECTORY_ENUMERATED, - FROM_PLAYLIST, - }; - virtual int on_progress(const char * path) {return 1;} - //for monitoring progress only, return 1 to continue, 0 to abort; note that you will most likely get called a few times after first 0 return - //path might be null if playlist loader is just checking if you are aborting or not - - virtual void on_entry(const playable_location * src,entry_type type)=0; - virtual void on_entry_have_info(const file_info * src,entry_type type) {on_entry(src->get_location(),type);} - virtual void on_entry_dbhandle(metadb_handle * ptr,entry_type type) {on_entry(ptr->handle_get_location(),type);} -}; - -class playlist_loader_callback_i : public playlist_loader_callback -{ - metadb_handle_list data; -public: - - ~playlist_loader_callback_i() {data.delete_all();} - - metadb_handle * get_item(unsigned idx) {return data[idx];} - metadb_handle * operator[](unsigned idx) {return data[idx];} - unsigned get_count() {return data.get_count();} - - const metadb_handle_list & get_data() {return data;} - - virtual int on_progress(const char * path) {return 1;} - virtual void on_entry(const playable_location * src,entry_type type) - {data.add_item(metadb::get()->handle_create(src));} - virtual void on_entry_have_info(const file_info * src,entry_type type) - {data.add_item(metadb::get()->handle_create_hint(src));} - virtual void on_entry_dbhandle(metadb_handle * ptr,entry_type type) - {data.add_item(ptr->handle_duplicate());} -}; - -class NOVTABLE playlist_loader : public service_base -{ -public: - virtual int open(const char * filename, reader * r,playlist_loader_callback * callback)=0; //send new entries to callback - virtual int write(const char * filename, reader * r,const ptr_list_base & data)=0; - virtual const char * get_extension()=0; - virtual bool can_write()=0; - bool is_our_content_type(const char*); - - static int load_playlist(const char * filename,playlist_loader_callback * callback); - //attempts to load file as a playlist, return 0 on failure - - static int save_playlist(const char * filename,const ptr_list_base & data); - //saves playlist into file - - static void process_path(const char * filename,playlist_loader_callback * callback,playlist_loader_callback::entry_type type = playlist_loader_callback::USER_REQUESTED); - //adds contents of filename (can be directory) to playlist, doesnt load playlists - - //this helper also loads playlists - //return 1 if loaded as playlist, 0 if loaded as files - static int process_path_ex(const char * filename,playlist_loader_callback * callback,playlist_loader_callback::entry_type type = playlist_loader_callback::USER_REQUESTED) - { - if (!load_playlist(filename,callback)) - { - process_path(filename,callback,type); - return 0; - } - else return 1; - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE playlist_loader_v2 : public playlist_loader -{ -public: - virtual bool is_our_content_type(const char * param) = 0; - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE track_indexer : public service_base -{ -public: - - class NOVTABLE callback - { - public: - virtual void on_entry(const playable_location * src)=0; - }; - - class callback_i : public callback - { - public: - ptr_list_t data; - virtual void on_entry(const playable_location * src) {data.add_item(new playable_location_i(*src));} - ~callback_i() {data.delete_all();} - }; - - class callback_i_ref : public callback - { - ptr_list_t &data; - public: - virtual void on_entry(const playable_location * src) {data.add_item(new playable_location_i(*src));} - callback_i_ref(ptr_list_t &p_data) : data(p_data) {} - }; - - class callback_i_wrap : public callback - { - playlist_loader_callback * out; - playlist_loader_callback::entry_type type; - public: - virtual void on_entry(const playable_location * src) {out->on_entry(src,type);} - callback_i_wrap(playlist_loader_callback * p_out,playlist_loader_callback::entry_type p_type) : out(p_out), type(p_type) {} - }; - - class callback_i_metadb : public callback - { - ptr_list_base & out; - metadb * p_metadb; - public: - virtual void on_entry(const playable_location * src) {out.add_item(p_metadb->handle_create(src));} - callback_i_metadb(ptr_list_base & p_out) : out(p_out), p_metadb(metadb::get()) {} - }; - -public: - virtual int get_tracks(const char * filename,callback* out,reader * r)=0;//return 0 on failure / not our file, 1 on success; send your subsongs to out; reader CAN BE NULL, if so, create/destroy your own one - //return either playlist entries with same filename, or playlist entries belonging to a readerless input (eg. cdda://) - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static int g_get_tracks_callback(const char * filename,callback * out,reader * r=0); - static int g_get_tracks(const char * filename,ptr_list_t & out,reader * r=0) - { - return g_get_tracks_callback(filename,&callback_i_ref(out),r); - } - - static int g_get_tracks_wrap(const char * filename,playlist_loader_callback * out,playlist_loader_callback::entry_type type,reader * r=0); - int get_tracks_ex(const char * filename,ptr_list_base & out,reader * r = 0); - static int g_get_tracks_ex(const char * filename,ptr_list_base & out,reader * r = 0); - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return service_base::service_query(guid); - } -}; - -class NOVTABLE track_indexer_v2 : public track_indexer -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - //since you usually have to parse the damn file anyway, here's a method that lets you precache info to database already to avoid redundant file operations later - virtual int get_tracks_ex(const char * filename,ptr_list_base & out,reader * r = 0)=0;//return 0 on failure / not our file, 1 on success; send your subsongs to out; reader CAN BE NULL, if so, create/destroy your own one - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return track_indexer::service_query(guid); - } - -}; - -template -class track_indexer_factory : public service_factory_t {}; - - -#endif //_PLAYLIST_LOADER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_switcher.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_switcher.h deleted file mode 100644 index 06da2d690..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/playlist_switcher.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _FOOBAR2000_PLAYLIST_SWITCHER_ -#define _FOOBAR2000_PLAYLIST_SWITCHER_ - - -//all calls from main app thread only ! - -class NOVTABLE playlist_switcher : public service_base -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual unsigned get_num_playlists()=0; - virtual bool get_playlist_name(unsigned idx,string_base & out)=0; - virtual bool get_playlist_data(unsigned idx,ptr_list_interface & out)=0; - virtual unsigned get_playlist_size(unsigned idx)=0;//returns number of entries - virtual bool get_playlist_selection_mask(unsigned idx,bit_array_var & out)=0; - virtual unsigned get_active_playlist()=0; - - virtual bool set_active_playlist(unsigned idx)=0; - virtual unsigned create_playlist(const char * name,const ptr_list_interface & data)=0;//returns index (or 0 on failure; index is always >0 because there is always at least one playlist present) - virtual unsigned create_playlist_fixname(string_base & name,const ptr_list_interface & data)=0;//name may change when playlist of this name is already present or passed name contains invalid chars; returns index (or 0 on failure; index is always >0 because there is always at least one playlist present) - virtual bool delete_playlist(unsigned idx)=0;//will fail if you are trying to delete only playlist, or currently active playlist - virtual bool reorder(const int * order,unsigned count)=0; - virtual bool rename_playlist(unsigned idx,const char * new_name)=0;//will fail if name exists or contains invalid chars - virtual bool rename_playlist_fixname(unsigned idx,string_base & name)=0;//will attempt to correct the name before failing - - virtual metadb_handle * get_item(unsigned playlist,unsigned idx)=0; - virtual bool format_title(unsigned playlist,unsigned idx,string_base & out,const char * spec,const char * extra_items)=0;//spec may be null, will use core settings; extra items are optional - - //new (0.8) - virtual unsigned get_playing_playlist()=0; - virtual metadb_handle * playback_advance(play_control::track_command cmd,unsigned * p_playlist,unsigned * p_item,bool * b_is_active_playlist)=0;//deprecated in 0.8 - virtual void reset_playing_playlist()=0; - virtual void highlight_playing_item()=0; - - static playlist_switcher * get(); - - unsigned find_playlist(const char * name);//returns ((unsigned)-1) when not found - unsigned find_or_create_playlist(const char * name); - bool find_or_create_playlist_activate(const char * name); - bool delete_playlist_autoswitch(unsigned idx); -}; - -class playlist_switcher_callback : public service_base -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual void on_playlist_switch_before(unsigned from,unsigned to)=0;//called before switching - virtual void on_playlist_switch_after(unsigned from,unsigned to)=0;//called after switching - - virtual void on_reorder(const int * order,unsigned count)=0; - virtual void on_new_playlist(const char * name,unsigned idx,const ptr_list_interface & data)=0; - virtual void on_delete_playlist(unsigned idx)=0; - virtual void on_rename_playlist(unsigned idx,const char * new_name)=0; - - virtual void on_item_replaced(unsigned pls,unsigned item,metadb_handle * from,metadb_handle * to)=0;//workaround for inactive-playlist-needs-modification-when-using-masstagger-autorename; does not work for active playlist ! -}; - -template -class playlist_switcher_callback_factory : public service_factory_single_t {}; - - -#endif//_FOOBAR2000_PLAYLIST_SWITCHER_ diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/reader.cpp deleted file mode 100644 index 49169a762..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader.cpp +++ /dev/null @@ -1,709 +0,0 @@ -#include "foobar2000.h" - - -reader * unpacker::g_open(reader * p) -{ - service_enum_t e; - unpacker * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - p->seek(0); - reader * r = ptr->open(p); - ptr->service_release(); - if (r) return r; - } - return 0; - -} - -bool reader::seek2(__int64 position,int mode) -{ - switch(mode) - { - case SEEK_CUR: - { - __int64 delta = get_position(); - if (delta<0) return false; - position+=delta; - } - break; - case SEEK_END: - { - __int64 delta = get_length(); - if (delta<0) return false; - position+=delta; - } - break; - } - return seek(position); -} - -__int64 reader::transfer(reader * src,reader * dst,__int64 bytes) -{ - enum{BUFSIZE = 1024*1024}; - mem_block temp; - void* ptr = temp.set_size((int)(BUFSIZEBUFSIZE) delta = BUFSIZE; - delta = src->read(ptr,(int)delta); - if (delta<=0) break; - delta = dst->write(ptr,(int)delta); - if (delta<=0) break; - done += delta; - - } - return done; -} - - -void file::g_get_canonical_path(const char * path,string_base & out) -{ - service_enum_t e; - file * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - int rv = ptr->get_canonical_path(path,out); - ptr->service_release(); - if (rv) return; - } - //fucko: noone wants to process this, lets copy over - out.set_string(path); -} - -void file::g_get_display_path(const char * path,string_base & out) -{ - file * ptr = g_get_interface(path); - if (ptr==0) - { - //fucko: noone wants to process this, lets copy over - out.set_string(path); - } - else - { - if (!ptr->get_display_path(path,out)) - out.set_string(path); - ptr->service_release(); - } -} - -file * file::g_get_interface(const char * path) -{ - service_enum_t e; - file * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->is_our_path(path)) - return ptr; - ptr->service_release(); - } - return 0; -} - -reader * file::g_get_reader(const char * path) -{ - file * ptr = g_get_interface(path); - if (ptr==0) return 0; - reader * r = ptr->get_reader(path); - ptr->service_release(); - if (r==0) return 0; - return r; -} - -reader * file::g_open(const char * path,reader::MODE mode) -{ - string8 path_c; - g_get_canonical_path(path,path_c); - file * ptr = g_get_interface(path_c); - if (ptr==0) return 0; - reader * r = ptr->get_reader(path_c); - ptr->service_release(); - if (r!=0) - { - if (r->open(path_c,mode)==0) - { - r->reader_release(); - r=0; - } - } - return r; -} - -int file::g_exists(const char * path) -{ - string8 path_c; - g_get_canonical_path(path,path_c); - file * ptr = g_get_interface(path_c); - if (ptr==0) return 0; - int rv = ptr->exists(path_c); - ptr->service_release(); - return rv; -} - -int file::g_remove(const char * path) -{ - string8 path_c; - g_get_canonical_path(path,path_c); - file * ptr = g_get_interface(path_c); - if (ptr==0) return 0; - int rv = ptr->remove(path_c); - ptr->service_release(); - return rv; -} - -int file::g_create_directory(const char * path) -{ - string8 path_c; - g_get_canonical_path(path,path_c); - file * ptr = g_get_interface(path_c); - if (ptr==0) return 0; - int rv = ptr->create_directory(path_c); - ptr->service_release(); - return rv; -} - -int file::g_move(const char * src,const char * dst) -{ - service_enum_t e; - file * ptr; - int rv = 0; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->is_our_path(src) && ptr->is_our_path(dst)) - { - rv = ptr->move(src,dst); - } - ptr->service_release(); - if (rv) break; - } - return rv; -} - -int file::g_move_ex(const char * _src,const char * _dst) -{ - string8 src,dst; - g_get_canonical_path(_src,src); - g_get_canonical_path(_dst,dst); - - service_enum_t e; - file * ptr; - int rv = 0; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (ptr->is_our_path(src) && ptr->is_our_path(dst)) - { - rv = ptr->move(src,dst); - } - ptr->service_release(); - if (rv) break; - } - return rv; -} - -int directory::g_list(const char * path,directory_callback * out,playlist_loader_callback * callback,bool b_recur) -{ - service_enum_t e; - directory * d; - for(d=e.first();d;d=e.next()) - { - int rv; - rv = d->list(path,out,callback,b_recur); - d->service_release(); - if (rv) return 1; - if (callback && !callback->on_progress(0)) break; - } - return 0; -} - - -static void path_pack_string(string8 & out,const char * src) -{ - out.add_char('|'); - out.add_int(strlen(src)); - out.add_char('|'); - out.add_string(src); - out.add_char('|'); -} - -static int path_unpack_string(string8 & out,const char * src) -{ - int ptr=0; - if (src[ptr++]!='|') return -1; - int len = atoi(src+ptr); - if (len<=0) return -1; - while(src[ptr]!=0 && src[ptr]!='|') ptr++; - if (src[ptr]!='|') return -1; - ptr++; - int start = ptr; - while(ptr-startdont_read_infos(path)) - { - ptr->service_release(); - return 0; - } - reader * r = ptr->get_reader(path_c); - ptr->service_release(); - if (r!=0) - { - if (r->open(path_c,reader::MODE_READ)==0) - { - r->reader_release(); - r=0; - } - } - return r; -} - -int file::g_dont_read_infos(const char * path) -{ - int rv = -1; - file * ptr = g_get_interface(path); - if (ptr) - { - rv = ptr->dont_read_infos(path); - ptr->service_release(); - } - return rv; -} - - - -bool reader_backbuffer_wrap::seek(__int64 position) -{ - if (aborting) return false; - if (position>reader_pos) - { - if (position > reader_pos + buffer.get_size()) - { - reader_pos = position - buffer.get_size(); - m_reader->seek(reader_pos); - buffered = 0; - } - - read_pos = reader_pos; - __int64 skip = (position-reader_pos); - char temp[256]; - while(skip>0) - { - __int64 delta = sizeof(temp); - if (delta>skip) delta=skip; - if (read(temp,(int)delta)!=delta) return false; - skip-=delta; - } - return true; - } - else if (reader_pos-position>(__int64)buffered) - { - read_pos = reader_pos = position; - m_reader->seek(reader_pos); - buffered = 0; - return true; - } - else - { - read_pos = position; - return true; - } -} - -int file::g_relative_path_create(const char * file_path,const char * playlist_path,string_base & out) -{ - file * ptr = g_get_interface(file_path); - int rv = 0; - if (ptr) - { - rv = ptr->relative_path_create(file_path,playlist_path,out); - ptr->service_release(); - } - return rv; -} - -int file::g_relative_path_parse(const char * relative_path,const char * playlist_path,string_base & out) -{ - service_enum_t e; - file * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - int rv = ptr->relative_path_parse(relative_path,playlist_path,out); - ptr->service_release(); - if (rv) return rv; - } - return 0; -} - - - -int archive_i::get_canonical_path(const char * path,string_base & out) -{ - if (is_our_path(path)) - { - out.set_string(path); - return 1; - } - else return 0; -} - -int archive_i::is_our_path(const char * path) -{ - if (strncmp(path,"unpack://",9)) return 0; - const char * type = get_archive_type(); - path += 9; - while(*type) - { - if (*type!=*path) return 0; - type++; - path++; - } - if (*path!='|') return 0; - return 1; -} - -int archive_i::get_display_path(const char * path,string_base & out) -{ - string8 archive,file; - if (parse_unpack_path(path,archive,file)) - { - g_get_display_path(archive,out); - out.add_string("|"); - out.add_string(file); - return 1; - } - else return 0; -} - -int archive_i::exists(const char * path) -{ - string8 archive,file; - if (parse_unpack_path(path,archive,file)) - { - if (g_exists(archive)) - { - if (g_dont_read_infos(archive)) return 1; - else return exists_in_archive(archive,file); - } - } - return 0; -} - -int archive_i::remove(const char * path) -{ - return 0; -} - -int archive_i::move(const char * src,const char * dst) -{ - return 0; -} - -int archive_i::dont_read_infos(const char * src) -{ - string8 archive,file; - if (parse_unpack_path(src,archive,file)) - { - return g_dont_read_infos(archive); - } - else return 1; -} - -int archive_i::relative_path_create(const char * file_path,const char * playlist_path,string_base & out) -{ - string8 archive,file; - if (parse_unpack_path(file_path,archive,file)) - { - string8 archive_rel; - if (g_relative_path_create(archive,playlist_path,archive_rel)) - { - string8 out_path; - make_unpack_path(out_path,archive_rel,file); - out.set_string(out_path); - return 1; - } - } - return 0; -} - -int archive_i::relative_path_parse(const char * relative_path,const char * playlist_path,string_base & out) -{ - if (!is_our_path(relative_path)) return 0; - string8 archive_rel,file; - if (parse_unpack_path(relative_path,archive_rel,file)) - { - string8 archive; - if (g_relative_path_parse(archive_rel,playlist_path,archive)) - { - string8 out_path; - make_unpack_path(out_path,archive,file); - out.set_string(out_path); - return 1; - } - } - return 0; -} - -// "unpack://zip|17|file://c:\unf.rar|meh.mp3" - -bool archive_i::parse_unpack_path(const char * path,string8 & archive,string8 & file) -{ - path = strchr(path,'|'); - if (!path) return false; - int delta = path_unpack_string(archive,path); - if (delta<0) return false; - path += delta; - file = path; - return true; -} - -void archive_i::make_unpack_path(string8 & path,const char * archive,const char * file,const char * name) -{ - path = "unpack://"; - path += name; - path_pack_string(path,archive); - path += file; -} - -void archive_i::make_unpack_path(string8 & path,const char * archive,const char * file) {make_unpack_path(path,archive,file,get_archive_type());} - - -FILE * file::streamio_open(const char * path,const char * flags) -{ - FILE * ret = 0; - string8 temp; - g_get_canonical_path(path,temp); - if (!strncmp(temp,"file://",7)) - { - ret = _wfopen(string_wide_from_utf8(path+7),string_wide_from_utf8(flags)); - } - return ret; -} - -void reader::reader_release_safe() -{ - reader_release(); -/* try { - if (this) reader_release(); - } catch(...) {}*/ -} -#if 0 - -bool reader::read_byte(BYTE & val) -{ - return read(&val,sizeof(val))==sizeof(val); -} - -bool reader::read_word(WORD & val) -{ - return read(&val,sizeof(val))==sizeof(val); -} - -bool reader::read_dword(DWORD & val) -{ - return read(&val,sizeof(val))==sizeof(val); -} - -bool reader::read_qword(QWORD & val) -{ - return read(&val,sizeof(val))==sizeof(val); -} - -bool reader::write_byte(BYTE val) -{ - return write(&val,sizeof(val))==sizeof(val); -} - -bool reader::write_word(WORD val) -{ - return write(&val,sizeof(val))==sizeof(val); -} - -bool reader::write_dword(DWORD val) -{ - return write(&val,sizeof(val))==sizeof(val); -} - -bool reader::write_qword(QWORD val) -{ - return write(&val,sizeof(val))==sizeof(val); -} - -//endian helpers -bool reader::read_word_be(WORD &val) -{ - WORD temp; - if (!read_word(temp)) return false; - val = byte_order_helper::word_be_to_native(temp); - return true; -} - -bool reader::read_word_le(WORD &val) -{ - WORD temp; - if (!read_word(temp)) return false; - val = byte_order_helper::word_le_to_native(temp); - return true; -} - -bool reader::read_dword_be(DWORD &val) -{ - DWORD temp; - if (!read_dword(temp)) return false; - val = byte_order_helper::dword_be_to_native(temp); - return true; -} -bool reader::read_dword_le(DWORD &val) -{ - DWORD temp; - if (!read_dword(temp)) return false; - val = byte_order_helper::dword_le_to_native(temp); - return true; - -} -bool reader::read_qword_be(QWORD &val) -{ - QWORD temp; - if (!read_qword(temp)) return false; - val = byte_order_helper::qword_be_to_native(temp); - return true; -} - -bool reader::read_qword_le(QWORD &val) -{ - QWORD temp; - if (!read_qword(temp)) return false; - val = byte_order_helper::qword_le_to_native(temp); - return true; -} - -bool reader::write_word_be(WORD val) -{ - return write_word(byte_order_helper::word_native_to_be(val)); -} -bool reader::write_word_le(WORD val) -{ - return write_word(byte_order_helper::word_native_to_le(val)); -} -bool reader::write_dword_be(DWORD val) -{ - return write_dword(byte_order_helper::dword_native_to_be(val)); -} -bool reader::write_dword_le(DWORD val) -{ - return write_dword(byte_order_helper::dword_native_to_le(val)); -} -bool reader::write_qword_be(QWORD val) -{ - return write_qword(byte_order_helper::qword_native_to_be(val)); -} -bool reader::write_qword_le(QWORD val) -{ - return write_qword(byte_order_helper::qword_native_to_le(val)); -} - -#endif - -bool reader::read_guid_le(GUID & g) -{ - if (read(&g,sizeof(g))!=sizeof(g)) return false; - byte_order_helper::guid_le_to_native(g); - return true; -} - -bool reader::read_guid_be(GUID & g) -{ - if (read(&g,sizeof(g))!=sizeof(g)) return false; - byte_order_helper::guid_be_to_native(g); - return true; -} - -bool reader::write_guid_le(const GUID & g) -{ - GUID temp = g; - byte_order_helper::guid_native_to_le(temp); - return write(&temp,sizeof(temp))==sizeof(temp); -} - -bool reader::write_guid_be(const GUID & g) -{ - GUID temp = g; - byte_order_helper::guid_native_to_be(temp); - return write(&temp,sizeof(temp))==sizeof(temp); -} - -__int64 reader::get_modification_time() -{ - __int64 rv = 0; - reader_filetime * ptr = service_query_t(reader_filetime,this); - if (ptr) - { - rv = ptr->get_modification_time(); - ptr->service_release(); - } - return rv; -} - -namespace { - - class directory_callback_isempty : public directory_callback - { - bool m_isempty; - public: - directory_callback_isempty() : m_isempty(true) {} - void on_file(const char * url) {m_isempty = false;}//api fixme: should signal enumeration abort - bool isempty() {return m_isempty;} - }; - - class directory_callback_dummy : public directory_callback - { - public: - void on_file(const char * url) {} - }; - -} - -bool directory::g_is_empty(const char * path) -{ - service_enum_t e; - directory * d; - for(d=e.first();d;d=e.next()) - { - int rv; - directory_callback_isempty callback; - rv = d->list(path,&callback,0,true);//blargh @ old API not reporting directories inside, need to run in recur mode, fixme - d->service_release(); - if (rv) return callback.isempty(); - } - return true; -} - -bool directory::g_is_valid_dir(const char * path) -{ - service_enum_t e; - directory * d; - for(d=e.first();d;d=e.next()) - { - int rv; - directory_callback_isempty callback; - rv = d->list(path,&directory_callback_dummy(),0,false);//another API fixme - d->service_release(); - if (rv) return true; - } - return false; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/reader.h deleted file mode 100644 index 64d9da16d..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader.h +++ /dev/null @@ -1,319 +0,0 @@ -#ifndef _READER_H_ -#define _READER_H_ - -#include "service.h" -#include "interface_helper.h" - -class playlist_loader_callback; - -//file paths are all UTF-8 - -class NOVTABLE reader : public service_base -{ -protected: - virtual ~reader() {}; - reader() {}; -public: - enum MODE { - MODE_READ = 1,//open with READ access and READ-only sharing - MODE_WRITE_EXISTING,//open existing file with full R/W access and NO sharing - MODE_WRITE_NEW,//create new file with full R/W access and NO sharing - }; - - virtual bool open(const char *path,MODE mode)=0; - //open should be called ONLY ONCE on a reader instance, with the same path as passed to file::get_reader - //you MAY get deleted before open() - - virtual unsigned read(void *buffer, unsigned length)=0; //0 on error/eof, number of bytes read otherwise ( - bool read_x_le(T & val) - { - if (read(&val,sizeof(val))!=sizeof(val)) return false; - byte_order_helper::order_le_to_native(&val,sizeof(val)); - return true; - } - - template - bool read_x_be(T & val) - { - if (read(&val,sizeof(val))!=sizeof(val)) return false; - byte_order_helper::order_be_to_native(&val,sizeof(val)); - return true; - } - - template - bool write_x_le(T val) - { - byte_order_helper::order_native_to_le(&val,sizeof(val)); - return write(&val,sizeof(val))==sizeof(val); - } - - template - bool write_x_be(T val) - { - byte_order_helper::order_native_to_be(&val,sizeof(val)); - return write(&val,sizeof(val))==sizeof(val); - } - - //endian helpers - inline bool read_word_be(WORD & val) {return read_x_be(val);} - inline bool read_word_le(WORD & val) {return read_x_le(val);} - inline bool read_dword_be(DWORD & val) {return read_x_be(val);} - inline bool read_dword_le(DWORD & val) {return read_x_le(val);} - inline bool read_qword_be(QWORD & val) {return read_x_be(val);} - inline bool read_qword_le(QWORD & val) {return read_x_le(val);} - inline bool read_float_be(float & val) {return read_x_be(val);} - inline bool read_float_le(float & val) {return read_x_le(val);} - inline bool read_double_be(double & val) {return read_x_be(val);} - inline bool read_double_le(double & val) {return read_x_le(val);} - inline bool write_word_be(WORD val) {return write_x_be(val);} - inline bool write_word_le(WORD val) {return write_x_le(val);} - inline bool write_dword_be(DWORD val) {return write_x_be(val);} - inline bool write_dword_le(DWORD val) {return write_x_le(val);} - inline bool write_qword_be(QWORD val) {return write_x_be(val);} - inline bool write_qword_le(QWORD val) {return write_x_le(val);} - inline bool write_float_be(float val) {return write_x_be(val);} - inline bool write_float_le(float val) {return write_x_le(val);} - inline bool write_double_be(double val) {return write_x_be(val);} - inline bool write_double_le(double val) {return write_x_le(val);} - bool read_guid_le(GUID & g); - bool read_guid_be(GUID & g); - bool write_guid_le(const GUID & g); - bool write_guid_be(const GUID & g); -}; - -class reader_filetime : public reader -{ -public: - //time is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601; 0 for invalid/unknown time - virtual __int64 get_modification_time()=0; - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return reader::service_query(guid); - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;}//only for service_query - -}; - -class reader_dynamicinfo : public reader//for shoutcast metadata BS -{ -public: - - virtual bool is_dynamic_info_enabled()=0;//checks if currently open stream gets dynamic metadata - - virtual bool get_dynamic_info(class file_info * out, bool * b_track_change)=0;//see input::get_dynamic_info - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return reader::service_query(guid); - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;}//only for service_query -}; - -class NOVTABLE file : public service_base -{ -public: - virtual int get_canonical_path(const char * path,string_base & out)=0;//return 1 on success, 0 on failure / not our file - virtual int is_our_path(const char * path)=0; - - virtual int get_display_path(const char * path,string_base & out)=0; - //converts canonical path to "human-readable" path (eg. removes file:// ) - //return 1 on success, 0 on failure - //generally OK to leave it returning 0 - - //in in all subsequent calls other than get_canonical_path, you should expect file path that has been accepted by your is_our_path - - //everything else than get_canonical_path() should expect strings that have already been processed by get_canonical_path() - //get_canonical_path() is called WITHOUT calling is_our_file first - virtual reader * get_reader(const char * path)=0;//note: reader will usually stay alive after you are service_release'd; do not open the file at this point, just create a reader capable of opening this file and return it - virtual int exists(const char * path)=0;//for return values, see FILE_EXISTS* below - virtual int remove(const char * path)=0;//return 1 on success and 0 on failure; also removes directories - virtual int move(const char * src,const char * dst)=0; - virtual int dont_read_infos(const char * src) {return 0;}//return 1 if infos shouldn't be precached from you (eg. HTTP) - - virtual int relative_path_create(const char * file_path,const char * playlist_path,string_base & out) {return 0;} - //eg. file_path : "file://z:\dir\subdir\blah.mpc", playlist_path: "file://z:\dir\playlist.fpl", out: "file://subdir\blah.mpc" - //file_path == canonical path accepted by your class, playlist_path == canonical path possibly belonging to some other file class, set out to a string your relative_path_parse will recognize (use url-style notation to prevent confusion) - //dont worry about output string being possibly passed to anything else than relative_path_parse - //return 1 on success, 0 if relative path can't be created (will store as full path) - virtual int relative_path_parse(const char * relative_path,const char * playlist_path,string_base & out) {return 0;} - //eg. relative_path: "file://subdir\blah.mpc", playlist_path: "file://z:\dir\playlist.fpl", out: "file://z:\dir\subdir\blah.mpc" - //relative_path == relative path produced by some file class (possibly you), check it before processing) - //output canonical path to the file on success - //return: 1 on success, 0 on failure / not-our-file - - virtual int create_directory(const char * path) {return 0;} - - //helpers - static void g_get_canonical_path(const char * path,string_base & out); - static void g_get_display_path(const char * path,string_base & out); - - static file * g_get_interface(const char * path);//path is AFTER get_canonical_path - static reader * g_get_reader(const char * path);//path is AFTER get_canonical_path (you're gonna need canonical version for reader::open() anyway) - static int g_dont_read_infos(const char * path);//path is AFTER get_canonical_path - //these below do get_canonical_path internally - static reader * g_open(const char * path,reader::MODE mode);//get_canonical_path + get_reader + reader->open; slow with http etc (you cant abort it) - static reader * g_open_read(const char * path) {return g_open(path,reader::MODE_READ);} - static reader * g_open_precache(const char * path);//open only for precaching data (eg. will fail on http etc) - static int g_exists(const char * path); - static int g_remove(const char * path); - static int g_move(const char * src,const char * dst);//needs canonical path - static int g_move_ex(const char * src,const char * dst);//converts to canonical path first - static int g_relative_path_create(const char * file_path,const char * playlist_path,string_base & out); - static int g_relative_path_parse(const char * relative_path,const char * playlist_path,string_base & out); - - static int g_create_directory(const char * path); - - static FILE * streamio_open(const char * path,const char * flags); // if for some bloody reason you ever need stream io compatibility, use this, INSTEAD of calling fopen() on the path string you've got; will only work with file:// (and not with http://, unpack:// or whatever) - - inline static reader * g_open_temp() {return g_open("tempfile://",reader::MODE_WRITE_NEW);} - inline static reader * g_open_tempmem() - { - reader * r = g_open("tempmem://",reader::MODE_WRITE_NEW); - if (r==0) r = g_open_temp(); - return r; - } - - enum { - FILE_EXISTS = 1,//use as flags, FILE_EXISTS_WRITEABLE implies FILE_EXISTS - FILE_EXISTS_WRITEABLE = 2 - }; - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE directory_callback -{ -public: - virtual void on_file(const char * url)=0; -}; - -class directory_callback_i : public directory_callback -{ - ptr_list_t data; - static int sortfunc(const char * & p1, const char * & p2) {return stricmp_utf8(p1,p2);} -public: - virtual void on_file(const char * url) {data.add_item(strdup(url));} - ~directory_callback_i() {data.free_all();} - unsigned get_count() {return data.get_count();} - const char * operator[](unsigned n) {return data[n];} - const char * get_item(unsigned n) {return data[n];} - void sort() {data.sort(sortfunc);} -}; - -class NOVTABLE directory : public service_base -{ -public: - virtual int list(const char * path,directory_callback * out,playlist_loader_callback * callback,bool b_recur = true)=0; - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - //helper - static int g_list(const char * path,directory_callback * out,playlist_loader_callback * callback,bool b_recur = true); - //playlist_loader_callback pointer is optional and used only for querying if enumeration should be aborted - - static bool g_is_valid_dir(const char * path); - static bool g_is_empty(const char * path); -}; - -class NOVTABLE archive : public file//dont derive from this, use archive_i class below -{ -public: - virtual int list(const char * path,directory_callback * out,playlist_loader_callback * callback)=0; - virtual int precache(const char * path,playlist_loader_callback * callback) {return 0;} //optional - if you are slow (eg. rar), metadb::precache() your files in optimal way using supplied reader pointer - //playlist_loader_callback ONLY for on_progress calls - - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE archive_i : public archive // derive from this -{ -private: - //do not override these - virtual int get_canonical_path(const char * path,string_base & out); - virtual int is_our_path(const char * path); - virtual int get_display_path(const char * path,string_base & out); - virtual int exists(const char * path); - virtual int remove(const char * path); - virtual int move(const char * src,const char * dst); - virtual int dont_read_infos(const char * src); - virtual int relative_path_create(const char * file_path,const char * playlist_path,string_base & out); - virtual int relative_path_parse(const char * relative_path,const char * playlist_path,string_base & out); -protected: - //override these - virtual const char * get_archive_type()=0;//eg. "zip", must be lowercase - virtual int exists_in_archive(const char * archive,const char * file) {return 1;} - -public: - //override these - virtual reader * get_reader(const char * path)=0; - virtual int list(const char * path,directory_callback * out,playlist_loader_callback * callback)=0; - virtual int precache(const char * path,playlist_loader_callback * callback) {return 0;}//optional - if you are slow (eg. rar), metadb::precache() your files in optimal way using supplied reader pointer - //playlist_loader_callback ONLY for on_progress calls - - - static bool parse_unpack_path(const char * path,string8 & archive,string8 & file); - static void make_unpack_path(string8 & path,const char * archive,const char * file,const char * name); - void make_unpack_path(string8 & path,const char * archive,const char * file); - -}; - -template -class archive_factory -{ - service_factory_single_t factory1; - service_factory_single_t factory2; -public: - archive_factory() {} - T& get_static_instance() {return factory1.get_static_instance();} -}; - -//register as: -// static archive_factory foo; - - -#include "reader_helper.h" - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader_helper.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/reader_helper.h deleted file mode 100644 index 7bd26eba5..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader_helper.h +++ /dev/null @@ -1,263 +0,0 @@ -#ifndef _READER_HELPER_H_ -#define _READER_HELPER_H_ - -//helper -class file_path_canonical : public string8 -{ -public: - file_path_canonical(const char * src) - { - file::g_get_canonical_path(src,*this); - } - operator const char * () {return get_ptr();} -}; - -class file_path_display : public string8 -{ -public: - file_path_display(const char * src) - { - file::g_get_display_path(src,*this); - } - operator const char * () {return get_ptr();} -}; - - -//HELPER, allows short seek back on unseekable reader, readonly -template -class reader_seekback_t : public T -{ -protected: - bool aborting; - mem_block_t buffer; - virtual ~reader_seekback_t() {} - virtual int seekback_read(void * buffer,int size)=0; - __int64 read_pos,reader_pos; - int buffer_pos,buffered; -public: - enum - { - DEFAULT_SEEKBACK_SIZE = 0x10000 - }; - reader_seekback_t(int size = DEFAULT_SEEKBACK_SIZE) : buffer(size) {aborting=0;read_pos=0;reader_pos=0;buffered=0;buffer_pos=0;} - virtual unsigned read(void *buffer, unsigned length); - virtual unsigned write(const void *buffer, unsigned length) {return 0;} -// virtual __int64 get_length() {return m_reader->get_length();} - virtual __int64 get_position() {return read_pos;} - virtual bool set_eof() {return false;} - virtual bool seek(__int64 position); - virtual bool can_seek() {return 0;} - virtual void abort() {aborting=1;} -}; - -typedef reader_seekback_t< reader > reader_seekback; - -class reader_seekback_wrap : public reader_seekback -{ -protected: - reader * m_reader; - virtual int seekback_read(void * buffer,int size) - { - return m_reader->read(buffer,size); - } -public: - reader_seekback_wrap(reader * p_reader,int size) - : reader_seekback(size), m_reader(p_reader) {} - virtual bool open(const char *path,MODE mode) {return false;}//dummy - virtual __int64 get_length() {return m_reader->get_length();} - virtual void abort() {m_reader->abort();reader_seekback::abort();} -}; - - -class reader_backbuffer_wrap : public reader_seekback_wrap -{ -public: - reader_backbuffer_wrap(reader * p_reader,int size) - : reader_seekback_wrap(p_reader,size) {} - virtual bool seek(__int64 position); -}; - - -class reader_membuffer : public reader_filetime -{ -public: - mem_block_t buffer; - int buffer_pos; - reader_membuffer(__int64 modtime) : m_modtime(modtime) {} - virtual unsigned write(const void*, unsigned) {return 0;} - __int64 m_modtime; -protected: - bool init(reader * src) - { - if (src->is_in_memory()) return false;//already buffered - __int64 size64 = src->get_length(); - if (size64<=0 || size64>0x7FFFFFFF) return false; - unsigned size = (unsigned)size64; - if (!buffer.set_size(size)) - { - return false; - } - src->seek(0); - buffer_pos=0; - if (src->read(buffer.get_ptr(),size)!=size) - { - return false; - } - return true; - } -public: - static reader * create(reader * src,__int64 modtime = 0) - { - reader_membuffer * ptr = new service_impl_p1_t(modtime); - if (ptr) - { - if (!ptr->init(src)) {delete ptr; ptr = 0;} - } - return ptr; - } - - virtual bool open(const char *path,MODE mode) {return false;}//dummy - - virtual unsigned read(void *out, unsigned length) - { - unsigned max = buffer.get_size() - buffer_pos; - if (length>max) length = max; - memcpy(out,buffer.get_ptr()+buffer_pos,length); - buffer_pos += length; - return length; - } - - virtual int write(const void *buffer, int length) {return 0;} - virtual __int64 get_length() {return buffer.get_size();} - virtual __int64 get_position() {return buffer_pos;} - virtual bool set_eof() {return 0;} - virtual bool seek(__int64 position) - { - if (position>(__int64)buffer.get_size()) - position = (__int64)buffer.get_size(); - else if (position<0) position=0; - - buffer_pos = (int)position; - - return true; - } - virtual bool can_seek() {return true;} - virtual bool is_in_memory() {return true;} - virtual __int64 get_modification_time() {return m_modtime;} -}; - -class reader_limited : public reader -{ - virtual bool open(const char * filename,MODE mode) {return false;}//dummy - reader * r; - __int64 begin; - __int64 end; - virtual unsigned write(const void * , unsigned) {return 0;} -public: - reader_limited() {r=0;begin=0;end=0;} - reader_limited(reader * p_r,__int64 p_begin,__int64 p_end) - { - r = p_r; - begin = p_begin; - end = p_end; - r->seek(begin); - } - - void init(reader * p_r,__int64 p_begin,__int64 p_end) - { - r = p_r; - begin = p_begin; - end = p_end; - r->seek(begin); - } - - virtual unsigned read(void *buffer, unsigned length) - { - __int64 pos = r->get_position(); - if ((__int64)length > end - pos) length = (unsigned)(end - pos); - return r->read(buffer,length); - } - - virtual __int64 get_length() - { - return end-begin; - } - virtual __int64 get_position() - { - return r->get_position()-begin; - } - - virtual bool seek(__int64 position) - { - return r->seek(position+begin); - } - virtual bool can_seek() {return r->can_seek();} -}; - - -template -bool reader_seekback_t::seek(__int64 position) -{ - if (aborting) return false; - if (position>reader_pos) - { - read_pos = reader_pos; - __int64 skip = (int)(position-reader_pos); - char temp[256]; - while(skip>0) - { - __int64 delta = sizeof(temp); - if (delta>skip) delta=skip; - if (read(temp,(int)delta)!=delta) return 0; - skip-=delta; - } - return true; - } - else if (reader_pos-position>(__int64)buffered) - { - return false; - } - else - { - read_pos = position; - return true; - } -} -template -unsigned reader_seekback_t::read(void *p_out, unsigned length) -{ - if (aborting) return 0; - //buffer can be null - int done = 0; - char * out = (char*)p_out; - if (read_pos(__int64)buffered) return 0; - unsigned delta = (unsigned)(reader_pos-read_pos); - if (delta>length) delta = length; - buffer.read_circular(buffer_pos - (unsigned)(reader_pos-read_pos),out,delta); - read_pos+=delta; - length-=delta; - out+=delta; - done += delta; - } - if (length>0) - { - unsigned delta = seekback_read(out,length); - buffer_pos = buffer.write_circular(buffer_pos,out,delta); - read_pos+=delta; - reader_pos+=delta; - length-=delta; - out+=delta; - done+=delta; - - buffered+=delta; - if (buffered>(int)buffer.get_size()) buffered=buffer.get_size(); - } - - return done; -} - - - -#endif//_READER_HELPER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader_helper_mem.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/reader_helper_mem.h deleted file mode 100644 index 9487a3189..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/reader_helper_mem.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef _READER_HELPER_MEM_ -#define _READER_HELPER_MEM_ - -template -class reader_mem_base_t : public T -{ -private: - char * data; - unsigned size,pos; -protected: - bool free_on_exit; - void mem_init(void * p_data,int p_size) - { - if (data && free_on_exit) free(data); - data = (char*)p_data; - size = p_size; - pos=0; - } -public: - reader_mem_base_t() {data=0;size=0;pos=0;free_on_exit=true;} - ~reader_mem_base_t() {if (free_on_exit && data) free(data);} - - virtual unsigned write(const void*, unsigned) {return 0;} - - virtual unsigned read(void *buffer, unsigned length) - { - if (pos + length > size) length = size - pos; - memcpy(buffer,data+pos,length); - pos+=length; - return length; - } - - virtual __int64 get_length() - { - return (__int64)size; - } - virtual __int64 get_position() - { - return (__int64)pos; - } - - virtual bool seek(__int64 position) - { - if (position < 0) position=0; - else if (position>(__int64)size) position=size; - pos = (int)position; - return true; - } - virtual bool is_in_memory() {return 1;} -}; - -#define reader_mem_base reader_mem_base_t< service_impl_t > - -class reader_mem_temp : public reader_mem_base_t< service_impl_t > -{ - __int64 m_time; - virtual bool open(const char * filename,MODE mode) {return 0;}//dummy - virtual __int64 get_modification_time() {return m_time;} -public: - reader_mem_temp(void * p_data,int p_size,__int64 p_time = 0) : m_time(p_time) - { - free_on_exit = false; - mem_init(p_data,p_size); - } -}; - - -class reader_mem : public reader_mem_base -{ - virtual bool open(const char * filename,MODE mode) {return 0;}//dummy -public: - reader_mem(void * p_data,int p_size) - { - free_on_exit = true; - mem_init(p_data,p_size); - } -}; - -#endif //_READER_HELPER_MEM_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/replaygain.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/replaygain.h deleted file mode 100644 index 080aaa465..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/replaygain.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef _FOOBAR2000_SDK_REPLAYGAIN_H_ -#define _FOOBAR2000_SDK_REPLAYGAIN_H_ - -#include "service.h" - -#include "file_info.h" -#include "metadb_handle.h" -#include "metadb.h" - - -class NOVTABLE replaygain : public service_base -{ -public: - enum mode_t - { - MODE_DEFAULT,//uses settings from core config - MODE_DISABLED, - MODE_TRACK, - MODE_ALBUM, - }; - - virtual double query_scale(const file_info * info,mode_t mode = MODE_DEFAULT)=0; - virtual mode_t get_user_settings()=0; - - static replaygain * get()//helper - { - return service_enum_create_t(replaygain,0); - } - - static mode_t g_get_user_settings()//returns whatever MODE_DEFAULT currently corresponds to - { - mode_t rv = MODE_DISABLED; - replaygain * ptr = get(); - if (ptr) - { - rv = ptr->get_user_settings(); - ptr->service_release(); - } - return rv; - } - - static double g_query_scale(const file_info* info,mode_t mode = MODE_DEFAULT) - { - double rv = 1; - replaygain * ptr = get(); - if (ptr) - { - rv = ptr->query_scale(info,mode); - ptr->service_release(); - } - return rv; - } - - static double g_query_scale(const playable_location* entry,mode_t mode = MODE_DEFAULT) - { - double rv = 1; - metadb * p_metadb = metadb::get(); - if (p_metadb) - { - metadb_handle * handle = p_metadb->handle_create(entry); - if (handle) - { - rv = g_query_scale(handle,mode); - handle->handle_release(); - } - } - return rv; - } - - static double g_query_scale(metadb_handle * handle,mode_t mode = MODE_DEFAULT) - { - double rv = 1; - handle->handle_lock(); - const file_info * info = handle->handle_query_locked(); - if (info) - rv = g_query_scale(info,mode); - handle->handle_unlock(); - return rv; - } - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -#endif //_FOOBAR2000_SDK_REPLAYGAIN_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/resampler.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/resampler.h deleted file mode 100644 index 34b89be97..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/resampler.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef _RESAMPLER_H_ -#define _RESAMPLER_H_ - -#include "dsp.h" - -//hint: use resampler_helper class declared below to resample - -class NOVTABLE resampler : public dsp -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual void set_dest_sample_rate(unsigned srate)=0; - virtual void set_config(unsigned flags)=0;//flags - see below - virtual bool is_conversion_supported(unsigned src_srate,unsigned dst_srate)=0; - - virtual service_base * service_query(const GUID & guid) - { - if (guid == get_class_guid()) {service_add_ref();return this;} - else return dsp::service_query(guid); - } - - enum - { - FLAG_FAST = 0x0, - FLAG_SLOW = 0x1, - }; - - //helper - static bool get_interface(resampler ** out_resampler,dsp ** out_dsp)//may fail if no resampler DSP is installed - {//you need to release both returned pointers - service_enum_t e; - dsp * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - resampler * ptr2 = service_query_t(resampler,ptr); - if (ptr2) - { - *out_resampler = ptr2; - *out_dsp = ptr; - return true; - } - ptr->service_release(); - } - return false; - } - - static bool get_interface_ex(resampler ** out_resampler,dsp ** out_dsp,unsigned src_srate,unsigned dst_srate)//may fail if no resampler DSP is installed or installed ones cant handle this conversion - {//you need to release both returned pointers - service_enum_t e; - dsp * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - resampler * ptr2 = service_query_t(resampler,ptr); - if (ptr2) - { - if (ptr2->is_conversion_supported(src_srate,dst_srate)) - { - *out_resampler = ptr2; - *out_dsp = ptr; - return true; - } - else - { - ptr2->service_release(); - } - } - ptr->service_release(); - } - return false; - } - - static dsp * create(unsigned srate,unsigned flags) - { - dsp * p_resampler_dsp; - resampler * p_resampler; - if (resampler::get_interface(&p_resampler,&p_resampler_dsp)) - { - p_resampler->set_config(flags); - p_resampler->set_dest_sample_rate(srate); - p_resampler->service_release(); - } - else - { - p_resampler_dsp = 0; - } - return p_resampler_dsp; - } - - static dsp * create_ex(unsigned src_srate,unsigned dst_srate,unsigned flags) - { - dsp * p_resampler_dsp; - resampler * p_resampler; - if (resampler::get_interface_ex(&p_resampler,&p_resampler_dsp,src_srate,dst_srate)) - { - p_resampler->set_config(flags); - p_resampler->set_dest_sample_rate(dst_srate); - p_resampler->service_release(); - } - else - { - p_resampler_dsp = 0; - } - return p_resampler_dsp; - } - -}; - -class resampler_helper -{ - dsp * p_dsp; - unsigned expected_dst_srate; -public: - explicit resampler_helper() - { - p_dsp = 0; - expected_dst_srate = 0; - } - - void setup_ex(unsigned src_srate,unsigned dst_srate,unsigned flags) - { - if (!p_dsp) p_dsp = resampler::create_ex(src_srate,dst_srate,flags); - expected_dst_srate = dst_srate; - } - - void setup(unsigned flags,unsigned dst_srate) - { - if (!p_dsp) p_dsp = resampler::create(dst_srate,flags); - expected_dst_srate = dst_srate; - } - - bool run(dsp_chunk_list * list,unsigned flags)//returns false on failure; flags - see dsp.h - { - if (!p_dsp || expected_dst_srate<=0) return false; - else - { - p_dsp->run(list,0,flags); - bool rv = true; - unsigned n,m=list->get_count(); - for(n=0;nget_item(n)->get_srate() != expected_dst_srate) {rv = false;break;} - } - return rv; - } - } - - void flush() {if (p_dsp) p_dsp->flush();} - - double get_latency() - { - return p_dsp ? p_dsp->get_latency() : 0;; - } - - - ~resampler_helper() - { - if (p_dsp) p_dsp->service_release(); - } -}; - - -#endif//_RESAMPLER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/service.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/service.cpp deleted file mode 100644 index 4c98f36f5..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/service.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "foobar2000.h" -#include "component.h" - -foobar2000_client g_client; -foobar2000_api * g_api; - -service_base * service_factory_base::enum_create(const GUID &g,int n) -{ - assert(core_api::are_services_available()); - return g_api->service_enum_create(g,n); -} - -int service_factory_base::enum_get_count(const GUID &g) -{ - assert(core_api::are_services_available()); - return g_api->service_enum_get_count(g); -} - -service_factory_base * service_factory_base::list=0; - -service_enum::service_enum(const GUID &g) -{ - guid = g; - reset(); -} - -void service_enum::reset() -{ - service_ptr=0; -} - -service_base * service_enum::next() -{ - return service_factory_base::enum_create(guid,service_ptr++); -} - -/* -void service_base::service_release_safe() -{ - try { - if (this) service_release(); - } - catch(...) - { - } -} -*/ -#ifdef WIN32 - -long interlocked_increment(long * var) -{ - assert(!((unsigned)var&3)); - return InterlockedIncrement(var); -} - -long interlocked_decrement(long * var) -{ - assert(!((unsigned)var&3)); - return InterlockedDecrement(var); -} - -#else - -#error portme - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/service.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/service.h deleted file mode 100644 index 3c6d05beb..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/service.h +++ /dev/null @@ -1,246 +0,0 @@ -#ifndef _SERVICE_H_ -#define _SERVICE_H_ - -#include "../../pfc/pfc.h" - -#include "utf8api.h" - -#include "core_api.h" - -long interlocked_increment(long * var);//note: win32 sucks, return values arent reliable, they can be used only to determine if new value is <0, 0 or >0 -long interlocked_decrement(long * var); - -class NOVTABLE service_base //ALL service classes MUST inherit from this -{ -public: - virtual int service_release() = 0; - virtual int service_add_ref() = 0; - virtual service_base * service_query(const GUID & guid) {return 0;} -}; - -#include "service_impl.h" -/* -//msvc6 sucks - -template - static T* service_query_t(service_base * ptr) {return static_cast(ptr->service_query(T::get_class_guid()));} - -*/ -#define service_query_t(T,ptr) (static_cast(ptr->service_query(T::get_class_guid()))) -//user service_release on returned object when youre done - -class NOVTABLE service_factory_base -{ -private: - static service_factory_base *list; - service_factory_base * next; - GUID guid; -protected: - service_factory_base(const GUID & p_guid) {assert(!core_api::are_services_available());guid=p_guid;next=list;list=this;} -public: - - inline const GUID & get_class_guid() const {return guid;} - - inline static service_factory_base * list_get_pointer() {return list;} - inline service_factory_base * list_get_next() {return next;} - - static service_base * enum_create(const GUID &g,int n); - static int enum_get_count(const GUID &g); - inline static bool is_service_present(const GUID & g) {return enum_get_count(g)>0;} - -#ifdef FOOBAR2000_EXE - static void process_components_directory(const char * path,service_factory_base ** & blah); - static void on_app_init(const char * exe_path); - static void on_app_shutdown(); - static void config_reset(const char * name = 0); - static void on_app_post_init(); - static void on_saveconfig(bool b_reset=false); -#endif - - //obsolete, use core_api - inline static HINSTANCE get_my_instance() {return core_api::get_my_instance();} - inline static const char * get_my_file_name() {return core_api::get_my_file_name();} - inline static const char * get_my_full_path() {return core_api::get_my_full_path();} - inline static HWND get_main_window() {return core_api::get_main_window();} - - virtual service_base * instance_create() = 0; - -}; - - -/* - -//msvc6 sucks - -template - static T * service_enum_create_t(int n) {return (T*)service_factory_base::enum_create(T::get_class_guid(),n);} -template - static int service_enum_get_count_t() {return service_factory_base::enum_get_count(T::get_class_guid());} -*/ - -#define service_enum_create_t(T,n) (static_cast(service_factory_base::enum_create(T::get_class_guid(),n))) -#define service_enum_get_count_t(T) (service_factory_base::enum_get_count(T::get_class_guid())) -#define service_enum_is_present(g) (service_factory_base::is_service_present(g)) -#define service_enum_is_present_t(T) (service_factory_base::is_service_present(T::get_class_guid())) - - -class service_enum -{ -private: - int service_ptr; - GUID guid; -public: - service_enum(const GUID &); - void reset(); - service_base * first() {reset();return next();} - service_base * next(); -}; - -template -class service_enum_t : private service_enum -{ -public: - service_enum_t() : service_enum(B::get_class_guid()) {} - void reset() {service_enum::reset();} - B * first() {return (B*)(service_enum::first());} - B * next() {return (B*)(service_enum::next());} -}; - - -template -class service_factory_t : public service_factory_base -{ -public: - service_factory_t() : service_factory_base(B::get_class_guid()) - { - } - - ~service_factory_t() - { - } - - virtual service_base * instance_create() - { - return (service_base*)(B*)(T*)new service_impl_t; - } -}; - -template -class service_factory_single_t : public service_factory_base -{ - service_impl_single_t g_instance; -public: - service_factory_single_t() : service_factory_base(B::get_class_guid()) {} - - ~service_factory_single_t() {} - - virtual service_base * instance_create() - { - g_instance.service_add_ref(); - return (service_base*)(B*)(T*)&g_instance; - } - - inline T& get_static_instance() const {return (T&)g_instance;} -}; - -template -class service_factory_single_ref_t : public service_factory_base -{ -private: - T & instance; -public: - service_factory_single_ref_t(T& param) : instance(param), service_factory_base(B::get_class_guid()) {} - - virtual service_base * instance_create() - { - service_base * ret = dynamic_cast(&instance); - ret->service_add_ref(); - return ret; - } - - inline T& get_static_instance() {return instance;} - - virtual void instance_release(service_base * ptr) {assert(0);} -}; - - -template -class service_factory_single_transparent_t : public service_factory_base, public service_impl_single_t -{ -public: - service_factory_single_transparent_t() : service_factory_base(B::get_class_guid()) {} - - virtual service_base * instance_create() - { - service_add_ref(); - return (service_base*)(B*)(T*)this; - } - - inline T& get_static_instance() const {return *(T*)this;} -}; - -template -class service_factory_single_transparent_p1_t : public service_factory_base, public service_impl_single_p1_t -{ -public: - service_factory_single_transparent_p1_t(P1 p1) : service_factory_base(B::get_class_guid()), service_impl_single_p1_t(p1) {} - - - virtual service_base * instance_create() - { - service_add_ref(); - return (service_base*)(B*)(T*)this; - } - - inline T& get_static_instance() const {return *(T*)this;} -}; - -template -class service_factory_single_transparent_p2_t : public service_factory_base, public service_impl_single_p2_t -{ -public: - service_factory_single_transparent_p2_t(P1 p1,P2 p2) : service_factory_base(B::get_class_guid()), service_impl_single_p2_t(p1,p2) {} - - - virtual service_base * instance_create() - { - service_add_ref(); - return (service_base*)(B*)(T*)this; - } - - inline T& get_static_instance() const {return *(T*)this;} -}; - -template -class service_factory_single_transparent_p3_t : public service_factory_base, public service_impl_single_p3_t -{ -public: - service_factory_single_transparent_p3_t(P1 p1,P2 p2,P3 p3) : service_factory_base(B::get_class_guid()), service_impl_single_p3_t(p1,p2,p3) {} - - - virtual service_base * instance_create() - { - service_add_ref(); - return (service_base*)(B*)(T*)this; - } - - inline T& get_static_instance() const {return *(T*)this;} -}; - -template -class service_factory_single_transparent_p4_t : public service_factory_base, public service_impl_single_p4_t -{ -public: - service_factory_single_transparent_p4_t(P1 p1,P2 p2,P3 p3,P4 p4) : service_factory_base(B::get_class_guid()), service_impl_single_p4_t(p1,p2,p3,p4) {} - - - virtual service_base * instance_create() - { - service_add_ref(); - return (service_base*)(B*)(T*)this; - } - - inline T& get_static_instance() const {return *(T*)this;} -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/service_helper.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/service_helper.h deleted file mode 100644 index 409e27381..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/service_helper.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _FOOBAR2000_SERVICE_HELPER_H_ -#define _FOOBAR2000_SERVICE_HELPER_H_ - -#include "service.h" - -template -class service_list_t : public ptr_list_t -{ -public: - void delete_item(T * ptr) - { - remove_item(ptr); - ptr->service_release(); - } - - void delete_by_idx(int idx) - { - T * ptr = remove_by_idx(idx); - if (ptr) ptr->service_release(); - } - - void delete_all() - { - int n,max=get_count(); - for(n=0;nservice_release(); - } - remove_all(); - } - - void delete_mask(const bit_array & mask) - { - int n,m=get_count(); - for(n=0;nservice_release(); - remove_mask(mask); - } -}; - -template -class service_list_autodel_t : public service_list_t -{ -public: - inline ~service_list_autodel_t() {delete_all();} -}; - -template -class service_ptr_autodel_t -{ - T * ptr; -public: - inline T* operator=(T* param) {return ptr = param;} - inline T* operator->() {return ptr;} - inline ~service_ptr_autodel_t() {if (ptr) ptr->service_release();} - inline service_ptr_autodel_t(T * param=0) {ptr=param;} - inline operator T* () {return ptr;} - inline void release() - { - T* temp = ptr; - ptr = 0; - if (temp) temp->service_release_safe(); - } - inline bool is_empty() {return ptr==0;} -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/service_impl.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/service_impl.h deleted file mode 100644 index 5c73582e6..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/service_impl.h +++ /dev/null @@ -1,104 +0,0 @@ -//only meant to be included from service.h - -class service_reference_counter -{ -private: - long refcount; -public: - inline service_reference_counter() : refcount(1) {} - inline long increment() {return interlocked_increment(&refcount);} - inline long decrement() {return interlocked_decrement(&refcount);} -}; - -#define __implement_service_base \ - private: \ - service_reference_counter m_reference_counter; \ - public: \ - virtual int service_release() {long ret = m_reference_counter.decrement(); if (ret == 0) delete this; return ret;} \ - virtual int service_add_ref() {return m_reference_counter.increment();} - -#define __implement_service_base_single \ - public: \ - virtual int service_release() {return 1;} \ - virtual int service_add_ref() {return 1;} - -template -class service_impl_t : public T -{ - __implement_service_base; -}; - -template -class service_impl_p1_t : public T -{ - __implement_service_base; -public: - service_impl_p1_t(P1 p1) : T(p1) {} -}; - -template -class service_impl_p2_t : public T -{ - __implement_service_base; -public: - service_impl_p2_t(P1 p1,P2 p2) : T(p1,p2) {} -}; - -template -class service_impl_p3_t : public T -{ - __implement_service_base; -public: - service_impl_p3_t(P1 p1,P2 p2,P3 p3) : T(p1,p2,p3) {} -}; - -template -class service_impl_p4_t : public T -{ - __implement_service_base; -public: - service_impl_p4_t(P1 p1,P2 p2,P3 p3,P4 p4) : T(p1,p2,p3,p4) {} -}; - - -template -class service_impl_single_t : public T -{ - __implement_service_base_single; -}; - -template -class service_impl_single_p1_t : public T -{ - __implement_service_base_single; -public: - service_impl_single_p1_t(P1 p1) : T(p1) {} -}; - -template -class service_impl_single_p2_t : public T -{ - __implement_service_base_single; -public: - service_impl_single_p2_t(P1 p1,P2 p2) : T(p1,p2) {} -}; - -template -class service_impl_single_p3_t : public T -{ - __implement_service_base_single; -public: - service_impl_single_p3_t(P1 p1,P2 p2,P3 p3) : T(p1,p2,p3) {} -}; - -template -class service_impl_single_p4_t : public T -{ - __implement_service_base_single; -public: - service_impl_single_p4_t(P1 p1,P2 p2,P3 p3,P4 p4) : T(p1,p2,p3,p4) {} -}; - - -#undef __implement_service_base -#undef __implement_service_base_single diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/shortcut_actions.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/shortcut_actions.h deleted file mode 100644 index cfc068aec..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/shortcut_actions.h +++ /dev/null @@ -1 +0,0 @@ -#error DEPRECATED diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/stdafx.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/stdafx.cpp deleted file mode 100644 index ea4f0bdf1..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ -//cpp used to generate precompiled header -#include "foobar2000.h" \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/tagread.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/tagread.cpp deleted file mode 100644 index 0347be79f..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/tagread.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "foobar2000.h" - -int tag_reader::g_run(reader * r,file_info * info,const char * name) -{ - if (!r->can_seek()) return 0;//dont bother - __int64 offset = r->get_position(); - int rv=0; - service_enum_t e; - tag_reader * ptr; - for(ptr=e.first();ptr && !rv;ptr = e.next()) - { - const char * s_name = ptr->get_name(); - if (!stricmp_utf8(name,s_name)) - { - r->seek(0); - rv = ptr->run(r,info); - } - ptr->service_release(); - } - r->seek(offset); -// if (rv) info->info_set("tagtype",name); - return rv; -} - -int tag_reader::g_run_multi(reader * r,file_info * info,const char * list) -{ - for(;;) - { - const char * sep = strchr(list,'|'); - if (sep==0) return *list ? g_run(r,info,list) : 0; - if (sep>list && g_run(r,info,string8(list,sep-list))) return 1; - list = sep + 1; - } -} - -int tag_writer::g_run(reader * r,const file_info * info,const char * name) -{ - if (!r->can_seek()) return 0;//dont bother - __int64 offset = r->get_position(); - int rv=0; - service_enum_t e; - tag_writer * ptr; - for(ptr=e.first();ptr && !rv;ptr = e.next()) - { - const char * s_name = ptr->get_name(); - - if (!stricmp_utf8(name,s_name)) - { - r->seek(0); - rv = ptr->run(r,info); - } - - ptr->service_release(); - } - r->seek(offset); - return rv; - -} - -void tag_remover::g_run(reader * r) -{ - service_enum_t e; - tag_remover * ptr; - for(ptr=e.first();ptr;ptr = e.next()) - { - r->seek(0); - ptr->run(r); - ptr->service_release(); - } -} - -bool tag_reader::g_have_type(const char * name) -{ - service_enum_t e; - tag_reader * ptr; - bool found = false; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (!stricmp_utf8(name,ptr->get_name())) found = true; - ptr->service_release(); - if (found) break; - } - return found; -} - -bool tag_writer::g_have_type(const char * name) -{ - service_enum_t e; - tag_writer * ptr; - bool found = false; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (!stricmp_utf8(name,ptr->get_name())) found = true; - ptr->service_release(); - if (found) break; - } - return found; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/tagread.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/tagread.h deleted file mode 100644 index 783098110..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/tagread.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _TAGREAD_H_ -#define _TAGREAD_H_ - -#include "service.h" -#include "reader.h" -#include "file_info.h" - -//helper class to let others use "standard" tag readers/writers in foo_input_std, do not reimplement - -class NOVTABLE tag_reader : public service_base -{ -public: - virtual const char * get_name()=0; - virtual int run(reader * r,file_info * info)=0;//return 1 on success, 0 on failure / unknown format - - static int g_run(reader * r,file_info * info,const char * name);//will seek back to original file offset - static int g_run_multi(reader * r,file_info * info,const char * list);//will seek back to original file offset - static bool g_have_type(const char * name); - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE tag_writer : public service_base -{ -public: - virtual const char * get_name()=0; - virtual int run(reader * r,const file_info * info)=0;//return 1 on success, 0 on failure / unknown format - - static int g_run(reader * r,const file_info * info,const char * name);//will seek back to original file offset - static bool g_have_type(const char * name); - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -class NOVTABLE tag_remover : public service_base -{ -public: - virtual void run(reader * r)=0; - - static void g_run(reader * r); - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/titleformat.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/titleformat.cpp deleted file mode 100644 index 32be5d6b4..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/titleformat.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "foobar2000.h" - -void titleformat::g_run(const file_info * source,string_base & out,const char * spec,const char * extra_items) -{ - titleformat * ptr = service_enum_create_t(titleformat,0); - if (ptr) - { - ptr->run(source,out,spec,extra_items); - ptr->service_release();//actually safe not to release it - } -} - -void titleformat::remove_color_marks(const char * src,string8 & out)//helper -{ - out.reset(); - while(*src) - { - if (*src==3) - { - src++; - while(*src && *src!=3) src++; - if (*src==3) src++; - } - else out.add_byte(*src++); - } -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/titleformat.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/titleformat.h deleted file mode 100644 index 4f87634a5..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/titleformat.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _FOOBAR2000_TITLEFORMAT_H_ -#define _FOOBAR2000_TITLEFORMAT_H_ - -#include "service.h" - -#include "file_info.h" -#include "config_var.h" - -//use this to call titleformatting directly (bypassing database) -//implemented in the core, dont override - -class titleformat : public service_base -{ -public: - virtual void run(const file_info * source,string_base & out,const char * spec,const char * extra_items)=0; - //source - file info to use - //out - string receiving results - //spec - formatting specification string to use, e.g. "%ARTIST% - %TITLE%" - //extra_items - %_name% variables, name=value pairs, null-separated, terminated with two nulls, e.g. "name=value\0name=value\0" - //extra_items can be null - - //helpers - static void g_run(const file_info * source,string_base & out,const char * spec,const char * extra_items); - - static void remove_color_marks(const char * src,string8 & out);//helper - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} -}; - - -#endif //_FOOBAR2000_TITLEFORMAT_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/ui.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/ui.cpp deleted file mode 100644 index 1d4b0be06..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/ui.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "foobar2000.h" - -bool ui_drop_item_callback::g_on_drop(interface IDataObject * pDataObject) -{ - service_enum_t e; - ui_drop_item_callback * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - bool status = ptr->on_drop(pDataObject); - ptr->service_release(); - if (status) return true; - } - return false; -} - -bool ui_drop_item_callback::g_is_accepted_type(interface IDataObject * pDataObject) -{ - service_enum_t e; - ui_drop_item_callback * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - bool status = ptr->is_accepted_type(pDataObject); - ptr->service_release(); - if (status) return true; - } - return false; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/ui.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/ui.h deleted file mode 100644 index 2d4890b99..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/ui.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef _FOOBAR2000_UI_H_ -#define _FOOBAR2000_UI_H_ - -#include "service.h" - -#ifndef WIN32 -#error PORTME -#endif - -class NOVTABLE user_interface : public service_base -{ -public: - typedef BOOL (WINAPI * HookProc_t)(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,LRESULT * ret); - //HookProc usage: - //in your windowproc, call HookProc first, and if it returns true, return LRESULT value it passed to you - - virtual const char * get_name()=0; - virtual HWND init(HookProc_t hook)=0;//create your window here - virtual void shutdown(bool endsession)=0;//you need to destroy your window here - virtual void activate()=0; - virtual void hide()=0; - virtual bool is_visible()=0;//for activate/hide command - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static user_interface * g_find(const char * name) - { - service_enum_t e; - user_interface * ptr; - for(ptr=e.first();ptr;ptr=e.next()) - { - if (!stricmp_utf8(ptr->get_name(),name)) return ptr; - ptr->service_release(); - } - return 0; - } -}; - -template -class user_interface_factory : public service_factory_single_t {}; - -//new (0.8) -class NOVTABLE ui_control : public service_base//implemented in the core, do not override -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual bool is_visible()=0; - virtual void activate()=0; - virtual void hide()=0; - virtual HICON get_main_icon()=0;//no need to free returned handle - virtual HICON load_main_icon(unsigned width,unsigned height)=0;//use DestroyIcon() to free it - - static ui_control * get() {return service_enum_create_t(ui_control,0);}//no need to service_release -}; - -class NOVTABLE ui_drop_item_callback : public service_base //called from UI when some object (ie. files from explorer) is dropped -{ -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - virtual bool on_drop(interface IDataObject * pDataObject)=0;//return true if you processed the data, false if not - virtual bool is_accepted_type(interface IDataObject * pDataObject)=0; - - static bool g_on_drop(interface IDataObject * pDataObject); - static bool g_is_accepted_type(interface IDataObject * pDataObject); -}; - -template -class ui_drop_item_callback_factory : public service_factory_single_t {}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/unpack.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/unpack.h deleted file mode 100644 index 8a797e5e7..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/unpack.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _UNPACK_H_ -#define _UNPACK_H_ - -#include "reader.h" - -class NOVTABLE unpacker : public service_base -{ -private: - //override this - virtual reader * open(reader * src)=0; -public: - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static reader * g_open(reader * r); -}; - -/* -usage: -you have a reader to an zip/rar/gzip/whatever archive containing just a single file you want to read, eg. a module -do unpacker::g_open() on that reader -returns 0 on failure (not a known archive or cant read it) or pointer to a new reader reading contents of that archive on success -*/ - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/utf8api.cpp b/tools/vio2sf/src/foobar8/foobar2000/SDK/utf8api.cpp deleted file mode 100644 index ac58e927d..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/utf8api.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "foobar2000.h" - -HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,long param) -{ - return uCreateDialog(core_api::get_my_instance(),id,parent,proc,param); -} - -int uDialogBox(UINT id,HWND parent,DLGPROC proc,long param) -{ - return uDialogBox(core_api::get_my_instance(),id,parent,proc,param); -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/utf8api.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/utf8api.h deleted file mode 100644 index cde1bffd7..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/utf8api.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _FOOBAR2000_UTF8API_H_ -#define _FOOBAR2000_UTF8API_H_ - -#include "../utf8api/utf8api.h" - -HWND uCreateDialog(UINT id,HWND parent,DLGPROC proc,long param=0); -int uDialogBox(UINT id,HWND parent,DLGPROC proc,long param=0); - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/SDK/vis.h b/tools/vio2sf/src/foobar8/foobar2000/SDK/vis.h deleted file mode 100644 index 54f1d41cd..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/SDK/vis.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _FOOBAR2000_VIS_H_ -#define _FOOBAR2000_VIS_H_ - -#include "service.h" -#include "audio_chunk.h" - -typedef float vis_sample; - -struct vis_chunk -{ - enum - { - FLAG_LAGGED = 1, //unless you need to process all samples in the stream for some reason (eg. scanning for peak), you should ignore chunks marked as "lagged" - }; - - vis_sample * data; - unsigned samples;// sizeof(data) == sizeof(vis_sample) * samples * nch; - unsigned srate,nch; - vis_sample * spectrum; - unsigned spectrum_size;// sizeof(spectrum) == sizeof(vis_sample) * spectrum_size * nch; - unsigned flags;//see FLAG_* above - - inline double get_duration() const {return srate>0 ? (double)samples / (double)srate : 0;} - -};//both data and spectrum are channel-interleaved - -#define visualisation visualization -#define visualisation_factory visualization_factory - -class visualization : public service_base -{ -public://all calls are from main thread - virtual void on_data(const vis_chunk * data)=0; - virtual void on_flush()=0; - virtual double get_expected_latency() {return 0;}//return time in seconds; allowed to change when running - - //allowed to change in runtime - virtual bool is_active()=0; - virtual bool need_spectrum()=0; - - static const GUID class_guid; - static inline const GUID & get_class_guid() {return class_guid;} - - static bool is_vis_manager_present() - { - static const GUID guid = - { 0x5ca94fe1, 0x7593, 0x47de, { 0x8a, 0xdf, 0x8e, 0x36, 0xb4, 0x93, 0xa6, 0xd0 } }; - return service_enum_is_present(guid); - } -}; - -template -class visualization_factory : public service_factory_single_t {}; - -//usage: static visualisation_factory blah; - -#endif //_FOOBAR2000_VIS_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/foobar2000.dsw b/tools/vio2sf/src/foobar8/foobar2000/foobar2000.dsw deleted file mode 100644 index 1e2faf867..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/foobar2000.dsw +++ /dev/null @@ -1,1346 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "7z_static"=.\foo_unpack\7zip\7zip\Bundles\Format7z\7z_static\7z_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "MACLib"=..\MAC_SDK_398a1\Source\MACLib\MACLib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "foo_abx"=.\foo_abx\foo_abx.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_albumlist"=.\foo_albumlist\foo_albumlist.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_ape"=.\foo_ape\foo_ape.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name MACLib - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_bitcompare"=.\foo_bitcompare\foo_bitcompare.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_burn"=.\foo_burn\foo_burn.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_cdda"=.\foo_cdda\foo_cdda.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_clienc"=.\foo_clienc\foo_clienc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_console"=.\foo_console\foo_console.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_diskwriter"=.\foo_diskwriter\foo_diskwriter.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_dsp_declick"=.\foo_dsp_declick\foo_dsp_declick.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency -}}} - -############################################################################### - -Project: "foo_dsp_extra"=.\foo_dsp_extra\foo_dsp_extra.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_dsp_pitch"=.\foo_dsp_pitch\foo_dsp_pitch.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_dsp_stereo3x"=.\foo_dsp_stereo3x\foo_dsp_stereo3x.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_flac"=.\foo_flac\foo_flac.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name libFLAC_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name libOggFLAC_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_infobox_simple"=.\foo_infobox_simple\foo_infobox_simple.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_input_std"=.\foo_input_std\foo_input_std.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name ogg_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name vorbis_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name vorbisfile_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name pfc - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name mpcdec - End Project Dependency - Begin Project Dependency - Project_Dep_Name mpglib - End Project Dependency - Begin Project Dependency - Project_Dep_Name libfaad - End Project Dependency - Begin Project Dependency - Project_Dep_Name mp4ff - End Project Dependency -}}} - -############################################################################### - -Project: "foo_masstag"=.\foo_masstag\foo_masstag.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_matroska"=.\foo_matroska\foo_matroska.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency - Begin Project Dependency - Project_Dep_Name libebml - End Project Dependency - Begin Project Dependency - Project_Dep_Name libmatroska - End Project Dependency -}}} - -############################################################################### - -Project: "foo_mod"=.\foo_mod\foo_mod.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_mpeg4u"=.\foo_mpeg4u\foo_mpeg4u.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libmp4av_st - End Project Dependency - Begin Project Dependency - Project_Dep_Name libmp4v2_st - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency - Begin Project Dependency - Project_Dep_Name libmp4v2_cb - End Project Dependency -}}} - -############################################################################### - -Project: "foo_oggpreview"=.\foo_oggpreview\foo_oggpreview.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency - Begin Project Dependency - Project_Dep_Name libOggFLAC_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name vorbis_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name vorbisfile_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name vorbisenc_static - End Project Dependency -}}} - -############################################################################### - -Project: "foo_out_dsound_ex"=.\foo_out_dsound_ex\foo_out_dsound_ex.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_out_ks"=.\foo_out_ks\foo_out_ks.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_output_std"=.\foo_output_std\foo_output_std.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_playlist_switcher"=.\foo_playlist_switcher\foo_playlist_switcher.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_playlistgen"=.\foo_playlistgen\foo_playlistgen.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_read_http"=.\foo_read_http\foo_read_http.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name jnetlib - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_rgscan"=.\foo_rgscan\foo_rgscan.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_search_ex"=.\foo_search_ex\foo_search_ex.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_spc"=.\foo_spc\foo_spc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name openspc - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_tagstress"=.\foo_tagstress\foo_tagstress.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_tfmx"=.\foo_tfmx\foo_tfmx.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_ui_std"=.\foo_ui_std\foo_ui_std.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_ui_std_ex"=.\foo_ui_std\foo_ui_std_ex.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency -}}} - -############################################################################### - -Project: "foo_ui_test"=.\foo_ui_test\foo_ui_test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_unpack"=.\foo_unpack\foo_unpack.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name unrar - End Project Dependency - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name 7z_static - End Project Dependency -}}} - -############################################################################### - -Project: "foo_vis_manager"=.\foo_vis_manager\foo_vis_manager.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency -}}} - -############################################################################### - -Project: "foo_vis_test"=.\foo_vis_test\foo_vis_test.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_vorbisenc"=.\foo_vorbisenc\foo_vorbisenc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name vorbis_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name vorbisenc_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name ogg_static - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foo_wavpack"=.\foo_wavpack\foo_wavpack.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foobar2000"=.\exe\foobar2000.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foo_abx - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_albumlist - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_ape - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_bitcompare - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_cdda - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_console - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_diskwriter - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_dsp_extra - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_dsp_pitch - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_infobox_simple - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_input_std - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_masstag - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_mod - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_out_ks - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_output_std - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_read_http - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_rgscan - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_spc - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_tfmx - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_ui_std - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_ui_test - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_unpack - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_vis_manager - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_vis_test - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_vorbisenc - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_wavpack - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_search_ex - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_ui_std_ex - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_playlist_switcher - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_out_dsound_ex - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_dsp_declick - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_flac - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_cltag - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_tagstress - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_mp4 - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_mpeg4u - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_matroska - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_playlistgen - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_clienc - End Project Dependency - Begin Project Dependency - Project_Dep_Name foo_mad - End Project Dependency -}}} - -############################################################################### - -Project: "foobar2000_SDK"=.\SDK\foobar2000_SDK.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pfc - End Project Dependency - Begin Project Dependency - Project_Dep_Name utf8api - End Project Dependency -}}} - -############################################################################### - -Project: "foobar2000_component_client"=.\foobar2000_component_client\foobar2000_component_client.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "foobar2000_sdk_helpers"=.\helpers\foobar2000_sdk_helpers.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "jnetlib"=.\foo_read_http\jnetlib\jnetlib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libFLAC_static"=..\flac\src\libFLAC\libFLAC_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libOggFLAC_static"=..\flac\src\libOggFLAC\libOggFLAC_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name ogg_static - End Project Dependency -}}} - -############################################################################### - -Project: "libebml"=..\libebml\make\vc6\lib\static\libebml.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libfaad"=..\faad2\libfaad\libfaad.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libmad"="..\libmad-0.15.1b\msvc++\libmad.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libmatroska"=..\libmatroska\make\vc6\lib\static\libmatroska.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libmp4av_st"=..\faad2\common\mp4av\libmp4av_st.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libmp4v2_cb"=..\faad2\common\mp4v2\libmp4v2_cb.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "libspeex"=..\speex\win32\libspeex\libspeex.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mp4ff"=..\faad2\common\mp4ff\mp4ff.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mpcdec"=.\foo_input_std\mpc\mpcdec.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mpglib"=.\foo_input_std\mpglib\mpglib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "ogg_static"=..\ogg\win32\ogg_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "openspc"=..\libopenspc\openspc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "pfc"=..\pfc\pfc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "unrar"=..\UnrarSrc\unrar.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "utf8api"=.\utf8api\utf8api.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pfc - End Project Dependency -}}} - -############################################################################### - -Project: "vorbis_static"=..\vorbis\win32\vorbis_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "vorbisenc_static"=..\vorbis\win32\vorbisenc_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "vorbisfile_static"=..\vorbis\win32\vorbisfile_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "zlib"=..\zlib\zlib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/tools/vio2sf/src/foobar8/foobar2000/foobar2000_component_client/component_client.cpp b/tools/vio2sf/src/foobar8/foobar2000/foobar2000_component_client/component_client.cpp deleted file mode 100644 index c93549bb1..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/foobar2000_component_client/component_client.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "../SDK/foobar2000.h" -#include "../SDK/component.h" - -static HINSTANCE g_hIns; - -static string_simple g_name,g_full_path; - -static bool g_services_available = false; - -#ifdef _DEBUG -static void selftest() -{ - assert(sizeof(bool)==1); - assert(sizeof(int)==4); - assert(sizeof(__int64)==8); -} -#endif - -extern "C" -{ - __declspec(dllexport) foobar2000_client * _cdecl foobar2000_get_interface(foobar2000_api * p_api,HINSTANCE hIns) - { -#ifdef _DEBUG - selftest(); -#endif - cfg_var::config_on_app_init(); - g_hIns = hIns; - g_api = p_api; - - return &g_client; - } -} - - -namespace core_api -{ - - HINSTANCE get_my_instance() - { - return g_hIns; - } - - HWND get_main_window() - { - return g_api->get_main_window(); - } - const char * get_my_file_name() - { - return g_name; - } - - const char * get_my_full_path() - { - return g_full_path; - } - - bool are_services_available() - { - return g_services_available; - } - bool assert_main_thread() - { - return (g_services_available && g_api) ? g_api->assert_main_thread() : true; - } - - bool is_main_thread() - { - return (g_services_available && g_api) ? g_api->is_main_thread() : true; - } - const char * get_profile_path() - { - return (g_services_available && g_api) ? g_api->get_profile_path() : 0; - } -} - -void foobar2000_client::set_library_path(const char * path,const char * name) -{ - g_full_path = path; - g_name = name; -} - -void foobar2000_client::services_init(bool val) -{ - g_services_available = val; -} - -#ifndef _DEBUG -#ifdef _MSC_VER -#if _MSC_VER==1200 -#pragma comment(linker,"/opt:nowin98") -#endif -#endif -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/foobar2000_component_client/foobar2000_component_client.dsp b/tools/vio2sf/src/foobar8/foobar2000/foobar2000_component_client/foobar2000_component_client.dsp deleted file mode 100644 index aeaf93383..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/foobar2000_component_client/foobar2000_component_client.dsp +++ /dev/null @@ -1,92 +0,0 @@ -# Microsoft Developer Studio Project File - Name="foobar2000_component_client" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=foobar2000_component_client - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "foobar2000_component_client.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "foobar2000_component_client.mak" CFG="foobar2000_component_client - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "foobar2000_component_client - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "foobar2000_component_client - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "foobar2000_component_client - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -MTL=midl.exe -F90=df.exe -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX- /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "foobar2000_component_client - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -MTL=midl.exe -F90=df.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "foobar2000_component_client - Win32 Release" -# Name "foobar2000_component_client - Win32 Debug" -# Begin Source File - -SOURCE=.\component_client.cpp -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/StdAfx.cpp b/tools/vio2sf/src/foobar8/foobar2000/helpers/StdAfx.cpp deleted file mode 100644 index 9dc5b543a..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/StdAfx.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// foobar2000_sdk_helpers.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/StdAfx.h b/tools/vio2sf/src/foobar8/foobar2000/helpers/StdAfx.h deleted file mode 100644 index 50a4e7bf8..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/StdAfx.h +++ /dev/null @@ -1,22 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_) -#define AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -#include "../SDK/foobar2000.h" -#include "helpers.h" - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__6356EC2B_6DD1_4BE8_935C_87ECBA8697E4__INCLUDED_) diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/create_directory_helper.cpp b/tools/vio2sf/src/foobar8/foobar2000/helpers/create_directory_helper.cpp deleted file mode 100644 index aa785337f..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/create_directory_helper.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "stdafx.h" -#include "create_directory_helper.h" - -namespace create_directory_helper -{ - void create_directory_structure(const char * path) - { - mem_block_t temp(strlen(path)+1); - strcpy(temp,path); - char * ptr = strstr(temp,":\\"); - if (ptr) - { - ptr+=2; - while(*ptr) - { - if (*ptr == '\\') - { - *ptr = 0; - file::g_create_directory(temp); - *ptr = '\\'; - } - ptr++; - } - } - } - - static bool is_bad_dirchar(char c) - { - return c==' ' || c=='.'; - } - - void make_path(const char * parent,const char * filename,const char * extension,bool allow_new_dirs,string8 & out) - { - out.reset(); - if (parent && *parent) - { - out = parent; - out.fix_dir_separator('\\'); - } - bool last_char_is_dir_sep = true; - while(*filename) - { -#ifdef WIN32 - if (allow_new_dirs && is_bad_dirchar(*filename)) - { - const char * ptr = filename+1; - while(is_bad_dirchar(*ptr)) ptr++; - if (*ptr!='\\' && *ptr!='/') out.add_string_n(filename,ptr-filename); - filename = ptr; - if (*filename==0) break; - } -#endif - if (is_path_bad_char(*filename)) - { - if (allow_new_dirs && (*filename=='\\' || *filename=='/')) - { - if (!last_char_is_dir_sep) - { - out.add_char('\\'); - last_char_is_dir_sep = true; - } - } - else - out.add_char('_'); - } - else - { - out.add_byte(*filename); - last_char_is_dir_sep = false; - } - filename++; - } - if (out.length()>0 && out[out.length()-1]=='\\') - { - out.add_string("noname"); - } - if (extension && *extension) - { - out.add_char('.'); - out.add_string(extension); - } - } -} - -void create_directory_helper::format_filename(metadb_handle * handle,const char * spec,string8 & out,const char * extra) -{ - out = ""; - string8 temp; - for(;;) - { - const char * ptr1 = strchr(spec,'\\'), *ptr2 = strchr(spec,'/'); - if ((!ptr1 && ptr2) || (ptr1 && ptr2 && ptr2handle_format_title(temp,string_simple(spec,ptr1-spec),extra); - temp.fix_filename_chars(); - spec = ptr1+1; - out += temp; - out += "\\"; - } - else - { - handle->handle_format_title(temp,spec,extra); - temp.fix_filename_chars(); - out += temp; - break; - } - } -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/create_directory_helper.h b/tools/vio2sf/src/foobar8/foobar2000/helpers/create_directory_helper.h deleted file mode 100644 index 08fd44d32..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/create_directory_helper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _CREATE_DIRECTORY_HELPER_H_ -#define _CREATE_DIRECTORY_HELPER_H_ - -namespace create_directory_helper { - void create_directory_structure(const char * path); - void make_path(const char * parent,const char * filename,const char * extension,bool allow_new_dirs,string8 & out); - void format_filename(class metadb_handle * handle,const char * spec,string8 & out,const char * extra=0); -}; - -#endif//_CREATE_DIRECTORY_HELPER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/dialog_resize_helper.cpp b/tools/vio2sf/src/foobar8/foobar2000/helpers/dialog_resize_helper.cpp deleted file mode 100644 index ecf2fe50d..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/dialog_resize_helper.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "stdafx.h" -#include "dialog_resize_helper.h" - -void resize::calc_xy(HWND wnd,UINT id,RECT &r,RECT & o) -{ - RECT c; - GetClientRect(wnd,&c); - SetWindowPos(GetDlgItem(wnd,id),0,0,0, - r.right-r.left+c.right-o.right, - r.bottom-r.top+c.bottom-o.bottom, - SWP_NOMOVE|SWP_NOZORDER); -} - -void resize::calc_move_xy(HWND wnd,UINT id,RECT &r,RECT & o) -{ - RECT c; - GetClientRect(wnd,&c); - SetWindowPos(GetDlgItem(wnd,id),0, - c.right-o.right+r.left, - c.bottom-o.bottom+r.top, - 0,0,SWP_NOSIZE|SWP_NOZORDER); -} - -void resize::calc_move_x(HWND wnd,UINT id,RECT &r,RECT & o) -{ - RECT c; - GetClientRect(wnd,&c); - SetWindowPos(GetDlgItem(wnd,id),0, - c.right-o.right+r.left, - r.top, - 0,0,SWP_NOSIZE|SWP_NOZORDER); -} - -void resize::calc_move_x_size_y(HWND wnd,UINT id,RECT &r,RECT & o) -{ - RECT c; - GetClientRect(wnd,&c); - SetWindowPos(GetDlgItem(wnd,id),0, - c.right-o.right+r.left, - r.top, - r.right-r.left, - r.bottom-r.top+c.bottom-o.bottom, - SWP_NOZORDER); -} - -void resize::calc_move_y(HWND wnd,UINT id,RECT &r,RECT & o) -{ - RECT c; - GetClientRect(wnd,&c); - SetWindowPos(GetDlgItem(wnd,id),0, - r.left, - c.bottom-o.bottom+r.top, - 0,0,SWP_NOSIZE|SWP_NOZORDER); -} - -void resize::calc_x(HWND wnd,UINT id,RECT &r,RECT & o) -{ - RECT c; - GetClientRect(wnd,&c); - SetWindowPos(GetDlgItem(wnd,id),0,0,0, - r.right-r.left+c.right-o.right, - r.bottom-r.top, - SWP_NOMOVE|SWP_NOZORDER); -} - -void GetChildRect(HWND wnd,UINT id,RECT* child) -{ - RECT temp; - GetWindowRect(GetDlgItem(wnd,id),&temp); - MapWindowPoints(0,wnd,(POINT*)&temp,2); - *child = temp; -} - -/* -class dialog_resize_helper -{ - struct entry { RECT orig; UINT id; UINT flags }; - mem_block_list data; - RECT orig_client; - HWND parent; -public: - enum { - X_MOVE = 1, X_SIZE = 2, Y_MOVE = 4, Y_SIZE = 8 - }; - void set_parent(HWND wnd); - void add_item(UINT id,UINT flags); - void reset(); -}; -*/ - -void dialog_resize_helper::set_parent(HWND wnd) -{ - reset(); - parent = wnd; - GetClientRect(parent,&orig_client); -} - -void dialog_resize_helper::reset() -{ - parent = 0; -} - -void dialog_resize_helper::on_wm_size() -{ - if (parent) - { - unsigned n; - for(n=0;nptMaxTrackSize.x = r.right; - info->ptMaxTrackSize.y = r.bottom; - } - if (min_x && min_y) - { - r.left = 0; r.right = min_x; - r.top = 0; r.bottom = min_y; - MapDialogRect(wnd,&r); - info->ptMinTrackSize.x = r.right; - info->ptMinTrackSize.y = r.bottom; - } - } - return true; - case WM_INITDIALOG: - set_parent(wnd); - { - unsigned n; - for(n=0;n & out) -{ - const char * src = data; - while(*src) - { - int ptr = 0; - while(src[ptr] && src[ptr]!=separator) ptr++; - if (ptr>0) - { - out.add_item(strdup_n(src,ptr)); - src += ptr; - } - while(*src==separator) src++; - } -} - -void cfg_dropdown_history::parse_list(const ptr_list_simple & src) -{ - unsigned n; - string8 temp; - temp.set_mem_logic(mem_block::ALLOC_FAST); - for(n=0;n list; - build_list(list); - unsigned n; - for(n=0;n list; - build_list(list); - unsigned n; - bool found = false; - for(n=0;n max) list.delete_by_idx(list.get_count()-1); - list.insert_item(strdup(item),0); - } - parse_list(list); - list.free_all(); -} - -bool cfg_dropdown_history::is_empty() -{ - const char * src = data; - while(*src) - { - if (*src!=separator) return false; - src++; - } - return true; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/dropdown_helper.h b/tools/vio2sf/src/foobar8/foobar2000/helpers/dropdown_helper.h deleted file mode 100644 index abe027600..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/dropdown_helper.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _DROPDOWN_HELPER_H_ -#define _DROPDOWN_HELPER_H_ - - -class cfg_dropdown_history -{ - enum {separator = '\n'}; - cfg_string data; - unsigned max; - void build_list(ptr_list_simple & out); - void parse_list(const ptr_list_simple & src); -public: - cfg_dropdown_history(const char * name,unsigned p_max = 10,const char * init_vals = "") : data(name,init_vals) {max = p_max;} - void setup_dropdown(HWND wnd); - void setup_dropdown(HWND wnd,UINT id) {setup_dropdown(GetDlgItem(wnd,id));} - void add_item(const char * item); - bool is_empty(); -}; - - -#endif //_DROPDOWN_HELPER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/foobar2000_sdk_helpers.dsp b/tools/vio2sf/src/foobar8/foobar2000/helpers/foobar2000_sdk_helpers.dsp deleted file mode 100644 index 4f482c293..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/foobar2000_sdk_helpers.dsp +++ /dev/null @@ -1,165 +0,0 @@ -# Microsoft Developer Studio Project File - Name="foobar2000_sdk_helpers" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=foobar2000_sdk_helpers - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "foobar2000_sdk_helpers.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "foobar2000_sdk_helpers.mak" CFG="foobar2000_sdk_helpers - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "foobar2000_sdk_helpers - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "foobar2000_sdk_helpers - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "foobar2000_sdk_helpers - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -F90=df.exe -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MD /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Yu"stdafx.h" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "foobar2000_sdk_helpers - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -F90=df.exe -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Yu"stdafx.h" /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "foobar2000_sdk_helpers - Win32 Release" -# Name "foobar2000_sdk_helpers - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\create_directory_helper.cpp -# End Source File -# Begin Source File - -SOURCE=.\dialog_resize_helper.cpp -# End Source File -# Begin Source File - -SOURCE=.\dropdown_helper.cpp -# End Source File -# Begin Source File - -SOURCE=.\playback_order_helper.cpp -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"stdafx.h" -# End Source File -# Begin Source File - -SOURCE=.\wildcard.cpp -# End Source File -# Begin Source File - -SOURCE=.\win32_dialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\window_placement_helper.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\create_directory_helper.h -# End Source File -# Begin Source File - -SOURCE=.\dialog_resize_helper.h -# End Source File -# Begin Source File - -SOURCE=.\dropdown_helper.h -# End Source File -# Begin Source File - -SOURCE=.\helpers.h -# End Source File -# Begin Source File - -SOURCE=.\playback_order_helper.h -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# Begin Source File - -SOURCE=.\wildcard.h -# End Source File -# Begin Source File - -SOURCE=.\win32_dialog.h -# End Source File -# Begin Source File - -SOURCE=.\window_placement_helper.h -# End Source File -# End Group -# End Target -# End Project diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/helpers.h b/tools/vio2sf/src/foobar8/foobar2000/helpers/helpers.h deleted file mode 100644 index 64a59e5f5..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/helpers.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _FOOBAR2000_SDK_HELPERS_H_ -#define _FOOBAR2000_SDK_HELPERS_H_ - -#include "create_directory_helper.h" -#include "dialog_resize_helper.h" -#include "dropdown_helper.h" -#include "window_placement_helper.h" -#include "win32_dialog.h" -#include "playback_order_helper.h" -#include "wildcard.h" - -#endif //_FOOBAR2000_SDK_HELPERS_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/playback_order_helper.cpp b/tools/vio2sf/src/foobar8/foobar2000/helpers/playback_order_helper.cpp deleted file mode 100644 index 38c250a24..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/playback_order_helper.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "stdafx.h" - - -namespace playback_order_helper -{ - static const char variable_name[] = "CORE/Playback flow control"; - - unsigned get_count() - { - return service_enum_get_count_t(playback_flow_control); - } - - const char * get_name_from_index(unsigned idx) - { - const char * ret = 0; - assert(idx>=0); - assert(idxget_name(); - ptr->service_release(); - return ret; - } - - unsigned get_index_from_name(const char * name) - { - unsigned idx, max = get_count(); - for(idx=0;idx(variable_name,calloninit), func(p_func) {} - - void modify_callback::on_changed(const config_var_string * ptr) - { - string8 name; - ptr->get_value(name); - func(name,get_index_from_name(name)); - } - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/playback_order_helper.h b/tools/vio2sf/src/foobar8/foobar2000/helpers/playback_order_helper.h deleted file mode 100644 index a591e3811..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/playback_order_helper.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _FOOBAR2000_PLAYBACK_ORDER_HELPER_H_ -#define _FOOBAR2000_PLAYBACK_ORDER_HELPER_H_ - -namespace playback_order_helper { - enum { order_invalid = (unsigned)(-1) }; - unsigned get_count(); - const char * get_name_from_index(unsigned idx); //index is 0 ... get_count()-1 - unsigned get_index_from_name(const char * name);//returns order_invalid if not found - unsigned get_config_by_index();//order_invalid on error - const char * get_config_by_name();//reverts to "default" on error - void get_config_by_name(string_base & out);//may return name of order that doesn't exist anymore (e.g. user removing dlls) - void set_config_by_name(const char * name); - void set_config_by_index(unsigned idx); - - class modify_callback : public config_var_callback_autoreg - { - void (*func)(const char * newval,unsigned newidx); - virtual void on_changed(const config_var_string * ptr); - public: - modify_callback(void (*p_func)(const char * newval,unsigned newidx), bool calloninit = false); - }; - - - inline order_exists(const char * name) {return get_index_from_name(name)!=order_invalid;} -}; - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/wildcard.cpp b/tools/vio2sf/src/foobar8/foobar2000/helpers/wildcard.cpp deleted file mode 100644 index 1c3901bf9..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/wildcard.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "stdafx.h" - -static bool test_recur(const char * fn,const char * rm,bool b_sep) -{ - for(;;) - { - if ((b_sep && *rm==';') || *rm==0) return *fn==0; - else if (*rm=='*') - { - rm++; - do - { - if (test_recur(fn,rm,b_sep)) return true; - } while(utf8_advance(fn)); - return false; - } - else if (*fn==0) return false; - else if (*rm!='?' && char_lower(utf8_get_char(fn))!=char_lower(utf8_get_char(rm))) return false; - - fn = utf8_char_next(fn); rm = utf8_char_next(rm); - } -} - -bool wildcard_helper::test_path(const char * path,const char * pattern,bool b_sep) {return test(path + string8::g_scan_filename(path),pattern,b_sep);} - -bool wildcard_helper::test(const char * fn,const char * pattern,bool b_sep) -{ - if (!b_sep) return test_recur(fn,pattern,false); - const char * rm=pattern; - while(*rm) - { - if (test_recur(fn,rm,true)) return true; - while(*rm && *rm!=';') rm++; - if (*rm==';') - { - while(*rm==';') rm++; - while(*rm==' ') rm++; - } - }; - - return false; -} - -bool wildcard_helper::has_wildcards(const char * str) {return strchr(str,'*') || strchr(str,'?');} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/wildcard.h b/tools/vio2sf/src/foobar8/foobar2000/helpers/wildcard.h deleted file mode 100644 index 4282094f1..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/wildcard.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __FOOBAR2000_HELPER_WILDCARD_H__ -#define __FOOBAR2000_HELPER_WILDCARD_H__ - -namespace wildcard_helper -{ - bool test_path(const char * path,const char * pattern,bool b_separate_by_semicolon = false);//will extract filename from path first - bool test(const char * str,const char * pattern,bool b_separate_by_semicolon = false);//tests if str matches pattern - bool has_wildcards(const char * str); -}; - -#endif //__FOOBAR2000_HELPER_WILDCARD_H__ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/win32_dialog.cpp b/tools/vio2sf/src/foobar8/foobar2000/helpers/win32_dialog.cpp deleted file mode 100644 index e49fc26c0..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/win32_dialog.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "stdafx.h" - - -namespace dialog_helper { - - - BOOL CALLBACK dialog::DlgProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) - { - dialog * p_this; - BOOL rv; - if (msg==WM_INITDIALOG) - { - p_this = reinterpret_cast(lp); - p_this->wnd = wnd; - uSetWindowLong(wnd,DWL_USER,lp); - } - else p_this = reinterpret_cast(uGetWindowLong(wnd,DWL_USER)); - - rv = p_this ? p_this->on_message(msg,wp,lp) : FALSE; - - if (msg==WM_DESTROY && p_this) - { - uSetWindowLong(wnd,DWL_USER,0); - wnd = 0; - } - - return rv; - } - - void set_item_text_multi(HWND wnd,const set_item_text_multi_param * param,unsigned count) - { - unsigned n; - for(n=0;n(this));} - - inline HWND run_modeless(unsigned id,HWND parent) {return uCreateDialog(id,parent,DlgProc,reinterpret_cast(this));} - }; - - struct set_item_text_multi_param - { - unsigned id; - const char * text; - }; - - void set_item_text_multi(HWND wnd,const set_item_text_multi_param * param,unsigned count); - -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/window_placement_helper.cpp b/tools/vio2sf/src/foobar8/foobar2000/helpers/window_placement_helper.cpp deleted file mode 100644 index 006e8d545..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/window_placement_helper.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "stdafx.h" -#include "window_placement_helper.h" - -//introduced in win98/win2k -typedef HANDLE (WINAPI * t_MonitorFromRect)(const RECT*, DWORD); - -#ifndef MONITOR_DEFAULTTONULL -#define MONITOR_DEFAULTTONULL 0x00000000 -#endif - -static bool test_rect(const RECT * rc) -{ - t_MonitorFromRect p_MonitorFromRect = (t_MonitorFromRect)GetProcAddress(GetModuleHandle("user32"),"MonitorFromRect"); - if (!p_MonitorFromRect) - { - //if (!SystemParametersInfo(SPI_GETWORKAREA,0,&workarea,0)) return true; - int max_x = GetSystemMetrics(SM_CXSCREEN), max_y = GetSystemMetrics(SM_CYSCREEN); - return rc->left < max_x && rc->right > 0 && rc->top < max_y && rc->bottom > 0; - } - return !!p_MonitorFromRect(rc,MONITOR_DEFAULTTONULL); -} - - -bool apply_window_placement(const cfg_struct_t & src,HWND wnd) -{ - bool rv = false; - if (config_var_int::g_get_value("CORE/remember window positions")) - { - WINDOWPLACEMENT wp = src; - if (wp.length==sizeof(wp) && test_rect(&wp.rcNormalPosition)) - { - if (SetWindowPlacement(wnd,&wp)) - rv = true; - } - } - return rv; -} - -void read_window_placement(cfg_struct_t & dst,HWND wnd) -{ - WINDOWPLACEMENT wp; - memset(&wp,0,sizeof(wp)); - if (config_var_int::g_get_value("CORE/remember window positions")) - { - wp.length = sizeof(wp); - if (!GetWindowPlacement(wnd,&wp)) - memset(&wp,0,sizeof(wp)); - } - dst = wp; -} - diff --git a/tools/vio2sf/src/foobar8/foobar2000/helpers/window_placement_helper.h b/tools/vio2sf/src/foobar8/foobar2000/helpers/window_placement_helper.h deleted file mode 100644 index 1e3a020e5..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/helpers/window_placement_helper.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _WINDOW_PLACEMENT_HELPER_H_ -#define _WINDOW_PLACEMENT_HELPER_H_ - -void read_window_placement(cfg_struct_t & dst,HWND wnd); -bool apply_window_placement(const cfg_struct_t & src,HWND wnd); - -#endif //_WINDOW_PLACEMENT_HELPER_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/crash_info.cpp b/tools/vio2sf/src/foobar8/foobar2000/utf8api/crash_info.cpp deleted file mode 100644 index 8983982d7..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/crash_info.cpp +++ /dev/null @@ -1,569 +0,0 @@ -#include "utf8api.h" -#include - -typedef BOOL (__stdcall * t_SymInitialize)(IN HANDLE hProcess,IN LPSTR UserSearchPath,IN BOOL fInvadeProcess); -typedef BOOL (__stdcall * t_SymCleanup)(IN HANDLE hProcess); -typedef BOOL (__stdcall * t_SymGetModuleInfo)(IN HANDLE hProcess,IN DWORD dwAddr,OUT PIMAGEHLP_MODULE ModuleInfo); -typedef BOOL (__stdcall * t_SymGetSymFromAddr)(IN HANDLE hProcess,IN DWORD dwAddr,OUT PDWORD pdwDisplacement,OUT PIMAGEHLP_SYMBOL Symbol); -typedef BOOL (__stdcall * t_SymEnumerateModules)(IN HANDLE hProcess,IN PSYM_ENUMMODULES_CALLBACK EnumModulesCallback,IN PVOID UserContext); - -static t_SymInitialize p_SymInitialize; -static t_SymCleanup p_SymCleanup; -static t_SymGetModuleInfo p_SymGetModuleInfo; -static t_SymGetSymFromAddr p_SymGetSymFromAddr; -static t_SymEnumerateModules p_SymEnumerateModules; - -static HMODULE hImageHlp; - -static critical_section g_imagehelp_sync; - -static string_simple version_string; - -static long crash_no; - -static __declspec(thread) char g_thread_call_stack[1024]; -static __declspec(thread) unsigned g_thread_call_stack_length; - -static bool load_imagehelp() -{ - static bool error; - if (hImageHlp) return true; - if (error) return false; - hImageHlp = LoadLibraryA("imagehlp.dll"); - if (hImageHlp==0) {error = true; return false; } - p_SymInitialize = (t_SymInitialize)GetProcAddress(hImageHlp,"SymInitialize"); - p_SymCleanup = (t_SymCleanup)GetProcAddress(hImageHlp,"SymCleanup"); - p_SymGetModuleInfo = (t_SymGetModuleInfo)GetProcAddress(hImageHlp,"SymGetModuleInfo"); - p_SymGetSymFromAddr = (t_SymGetSymFromAddr)GetProcAddress(hImageHlp,"SymGetSymFromAddr"); - p_SymEnumerateModules = (t_SymEnumerateModules)GetProcAddress(hImageHlp,"SymEnumerateModules"); - - if (!p_SymInitialize || !p_SymCleanup || !p_SymGetModuleInfo || !p_SymGetSymFromAddr || !p_SymEnumerateModules) - { - FreeLibrary(hImageHlp); - hImageHlp = 0; - error = true; - return false; - } - - return true; -} - -#define LOG_PATH_LEN (MAX_PATH + 32) - -static HANDLE create_failure_log(char * filename_used,TCHAR * fullpath_used) -{ - bool rv = false; - TCHAR path[LOG_PATH_LEN]; - path[0]=0; - GetModuleFileName(0,path,MAX_PATH); - path[MAX_PATH-1]=0; - { - TCHAR * ptr = path + _tcslen(path); - while(ptr>path && *ptr!='\\') ptr--; - ptr[1]=0; - } - TCHAR * fn_out = path + _tcslen(path); - HANDLE hFile = INVALID_HANDLE_VALUE; - unsigned attempts = 0; - for(;;) - { - if (*fn_out==0) - { - _tcscpy(fn_out,TEXT("failure.txt")); - if (filename_used) strcpy(filename_used,"failure.txt"); - } - else - { - attempts++; - wsprintf(fn_out,TEXT("failure_%08u.txt"),attempts); - if (filename_used) wsprintfA(filename_used,"failure_%08u.txt",attempts); - } - hFile = CreateFile(path,GENERIC_WRITE,0,0,CREATE_NEW,0,0); - if (hFile!=INVALID_HANDLE_VALUE) break; - if (attempts > 1000) break; - } - if (hFile!=INVALID_HANDLE_VALUE && fullpath_used) - { - _tcscpy(fullpath_used,path); - } - return hFile; -} - -static void WriteFileString_internal(HANDLE hFile,const char * ptr,unsigned len) -{ - DWORD bah; - WriteFile(hFile,ptr,len,&bah,0); -} - -static void WriteFileString(HANDLE hFile,const char * str) -{ - const char * ptr = str; - for(;;) - { - const char * start = ptr; - ptr = strchr(ptr,'\n'); - if (ptr) - { - if (ptr>start) WriteFileString_internal(hFile,start,ptr-start); - WriteFileString_internal(hFile,"\x0d\x0a",2); - ptr++; - } - else - { - WriteFileString_internal(hFile,start,strlen(start)); - break; - } - } -} - -static char * hexdump8(char * out,unsigned address,const char * msg,int from,int to) -{ - unsigned max = (to-from)*16; - if (!IsBadReadPtr((const void*)(address+(from*16)),max)) - { - out += sprintf(out,"%s (%08Xh):",msg,address); - unsigned n; - const unsigned char * src = (const unsigned char*)(address)+(from*16); - - for(n=0;nExceptionRecord->ExceptionAddress; - sprintf(temp,"Illegal operation:\nCode: %08Xh, flags: %08Xh, address: %08Xh\n",param->ExceptionRecord->ExceptionCode,param->ExceptionRecord->ExceptionFlags,address); - WriteFileString(hFile,temp); - - if (param->ExceptionRecord->ExceptionCode==EXCEPTION_ACCESS_VIOLATION && param->ExceptionRecord->NumberParameters>=2) - { - sprintf(temp,"Access violation, operation: %s, address: %08Xh\n",param->ExceptionRecord->ExceptionInformation[0] ? "write" : "read",param->ExceptionRecord->ExceptionInformation[1]); - WriteFileString(hFile,temp); - } - - WriteFileString(hFile,"Call path:\n"); - WriteFileString(hFile,g_thread_call_stack); - WriteFileString(hFile,"\n"); - if (number==1) - { - WriteFileString(hFile,"This is the first crash logged by this instance.\n"); - } - else - { - const char * meh; - switch(number%10) - { - case 1: - meh = "st"; - break; - case 2: - meh = "nd"; - break; - case 3: - meh = "rd"; - break; - default: - meh = "th"; - break; - } - sprintf(temp,"This is your %u-%s crash. When reporting the problem to a developer, please try to post info about the first crash instead.\n",number,meh); - WriteFileString(hFile,temp); - } - - hexdump8(temp,address,"Code bytes",-4,+4); - WriteFileString(hFile,temp); - hexdump32(temp,param->ContextRecord->Esp,"Stack",-2,+18); - WriteFileString(hFile,temp); - sprintf(temp,"Registers:\nEAX: %08X, EBX: %08X, ECX: %08X, EDX: %08X\nESI: %08X, EDI: %08X, EBP: %08X, ESP: %08X\n",param->ContextRecord->Eax,param->ContextRecord->Ebx,param->ContextRecord->Ecx,param->ContextRecord->Edx,param->ContextRecord->Esi,param->ContextRecord->Edi,param->ContextRecord->Ebp,param->ContextRecord->Esp); - WriteFileString(hFile,temp); - - { - bool imagehelp_succeeded = false; - insync(g_imagehelp_sync); - if (load_imagehelp()) - { - HANDLE hProcess = GetCurrentProcess(); - char exepath[MAX_PATH]; - exepath[0]=0; - GetModuleFileNameA(0,exepath,tabsize(exepath)); - exepath[tabsize(exepath)-1]=0; - { - char * ptr = exepath + strlen(exepath); - while(ptr>exepath && *ptr!='\\') ptr--; - *ptr=0; - } - if (p_SymInitialize(hProcess,exepath,TRUE)) - { - { - IMAGEHLP_MODULE mod; - memset(&mod,0,sizeof(mod)); - mod.SizeOfStruct = sizeof(mod); - if (p_SymGetModuleInfo(hProcess,address,&mod)) - { - sprintf(temp,"Crash location: \"%s\", loaded at %08Xh - %08Xh\n",mod.ModuleName,mod.BaseOfImage,mod.BaseOfImage+mod.ImageSize); - WriteFileString(hFile,temp); - } - else - { - sprintf(temp,"Unable to identify crash location\n"); - WriteFileString(hFile,temp); - } - } - - { - union - { - char buffer[128]; - IMAGEHLP_SYMBOL symbol; - }; - memset(buffer,0,sizeof(buffer)); - symbol.SizeOfStruct = sizeof(symbol); - symbol.MaxNameLength = buffer + sizeof(buffer) - symbol.Name; - DWORD offset = 0; - if (p_SymGetSymFromAddr(hProcess,address,&offset,&symbol)) - { - buffer[tabsize(buffer)-1]=0; - if (symbol.Name[0]) - { - sprintf(temp,"Symbol: \"%s\" (+%08Xh)\n",symbol.Name,offset); - WriteFileString(hFile,temp); - } - } - } - - WriteFileString(hFile,"\nLoaded modules:\n"); - p_SymEnumerateModules(hProcess,EnumModulesCallback,hFile); - - - call_stack_parse(param->ContextRecord->Esp,hFile,temp,hProcess); - - p_SymCleanup(hProcess); - imagehelp_succeeded = true; - } - } - if (!imagehelp_succeeded) - { - WriteFileString(hFile,"Failed to get module/symbol info.\n"); - } - - WriteFileString(hFile,"\nVersion info: \n"); - WriteFileString(hFile,version_string); - WriteFileString(hFile,"\n"); - WriteFileString(hFile, - #ifdef UNICODE - "UNICODE" - #else - "ANSI" - #endif - ); - - CloseHandle(hFile); - ShellExecute(0,0,log_path,0,0,SW_SHOW); - } - } -} - -//not really being utf8 here, all chars should be in 128 ascii range -UTF8API_EXPORT UINT uPrintCrashInfo(LPEXCEPTION_POINTERS param,const char * extra_info,char * outbase) -{ - uDumpCrashInfo(param); - if (extra_info==0) extra_info = g_thread_call_stack; - char * out = outbase; - long number = InterlockedIncrement(&crash_no); - - unsigned address = (unsigned)param->ExceptionRecord->ExceptionAddress; - out += sprintf(out,"Illegal operation:\nCode: %08Xh, flags: %08Xh, address: %08Xh",param->ExceptionRecord->ExceptionCode,param->ExceptionRecord->ExceptionFlags,address); - - if (param->ExceptionRecord->ExceptionCode==EXCEPTION_ACCESS_VIOLATION && param->ExceptionRecord->NumberParameters>=2) - { - out += sprintf(out,"\nAccess violation, operation: %s, address: %08Xh",param->ExceptionRecord->ExceptionInformation[0] ? "write" : "read",param->ExceptionRecord->ExceptionInformation[1]); - } - - { - bool imagehelp_succeeded = false; - insync(g_imagehelp_sync); - if (load_imagehelp()) - { - HANDLE hProcess = GetCurrentProcess(); - char exepath[MAX_PATH]; - exepath[0]=0; - GetModuleFileNameA(0,exepath,tabsize(exepath)); - exepath[tabsize(exepath)-1]=0; - { - char * ptr = exepath + strlen(exepath); - while(ptr>exepath && *ptr!='\\') ptr--; - *ptr=0; - } - if (p_SymInitialize(hProcess,exepath,TRUE)) - { - { - IMAGEHLP_MODULE mod; - memset(&mod,0,sizeof(mod)); - mod.SizeOfStruct = sizeof(mod); - if (p_SymGetModuleInfo(hProcess,address,&mod)) - { - out += sprintf(out,"\nCrash location: \"%s\", loaded at %08Xh - %08Xh",mod.ModuleName,mod.BaseOfImage,mod.BaseOfImage+mod.ImageSize); - } - else - { - out += sprintf(out,"\nUnable to identify crash location"); - } - } - - { - union - { - char buffer[128]; - IMAGEHLP_SYMBOL symbol; - }; - memset(buffer,0,sizeof(buffer)); - symbol.SizeOfStruct = sizeof(symbol); - symbol.MaxNameLength = buffer + sizeof(buffer) - symbol.Name; - DWORD offset = 0; - if (p_SymGetSymFromAddr(hProcess,address,&offset,&symbol)) - { - buffer[tabsize(buffer)-1]=0; - if (symbol.Name[0]) - { - out += sprintf(out,"\nSymbol: \"%s\" (+%08Xh)",symbol.Name,offset); - } - } - } - - p_SymCleanup(hProcess); - imagehelp_succeeded = true; - } - } - if (!imagehelp_succeeded) - { - out += sprintf(out,"\n(failed to get module/symbol info)"); - } - if (extra_info && *extra_info) - { - unsigned len = strlen_max(extra_info,256); - out += sprintf(out,"\nAdditional info: "); - memcpy(out,extra_info,len); - out+=len; - *out=0; - } - if (number==1) - { - out += sprintf(out,"\nThis is the first crash logged by this instance."); - } - else - { - const char * meh; - switch(number%10) - { - case 1: - meh = "st"; - break; - case 2: - meh = "nd"; - break; - case 3: - meh = "rd"; - break; - default: - meh = "th"; - break; - } - out += sprintf(out,"\nThis is your %u-%s crash. When reporting the problem to a developer, please try to post info about the first crash instead.",number,meh); - } - } - - out += sprintf(out,"\n"); - out = hexdump8(out,address,"Code bytes",-2,+2); - - return strlen(outbase); -} - -static LPTOP_LEVEL_EXCEPTION_FILTER filterproc; - -static LONG WINAPI exceptfilter(LPEXCEPTION_POINTERS param) -{ - uDumpCrashInfo(param); - ExitProcess(0); - return filterproc(param);//never called -} - -UTF8API_EXPORT void uPrintCrashInfo_Init(const char * name)//called only by exe on startup -{ - version_string = name; - filterproc = SetUnhandledExceptionFilter(exceptfilter); -} - -static void callstack_add(const char * param) -{ - enum { MAX = tabsize(g_thread_call_stack) - 1} ; - unsigned len = strlen(param); - if (g_thread_call_stack_length + len > MAX) len = MAX - g_thread_call_stack_length; - if (len>0) - { - memcpy(g_thread_call_stack+g_thread_call_stack_length,param,len); - g_thread_call_stack_length += len; - g_thread_call_stack[g_thread_call_stack_length]=0; - } -} - -uCallStackTracker::uCallStackTracker(const char * name) -{ - param = g_thread_call_stack_length; - if (g_thread_call_stack_length>0) callstack_add("=>"); - callstack_add(name); -} - -uCallStackTracker::~uCallStackTracker() -{ - g_thread_call_stack_length = param; - g_thread_call_stack[param]=0; - -} - -extern "C" {UTF8API_EXPORT const char * uGetCallStackPath() {return g_thread_call_stack;} } \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/stdafx.cpp b/tools/vio2sf/src/foobar8/foobar2000/utf8api/stdafx.cpp deleted file mode 100644 index 65ef0eea8..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/stdafx.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "utf8api.h" \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/systray.cpp b/tools/vio2sf/src/foobar8/foobar2000/utf8api/systray.cpp deleted file mode 100644 index d21fa7065..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/systray.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include "utf8api.h" - -#include - -#ifdef UNICODE - -//mega-fucko: i dont have latest definitions in my platform sdk that came with msvc6 - -#define NIF_MESSAGE 0x00000001 -#define NIF_ICON 0x00000002 -#define NIF_TIP 0x00000004 -#define NIF_STATE 0x00000008 -#define NIF_INFO 0x00000010 -#define NIF_GUID 0x00000020 - -#define NIIF_INFO 0x00000001 -#define NIIF_WARNING 0x00000002 -#define NIIF_ERROR 0x00000003 -#define NIIF_ICON_MASK 0x0000000F -#define NIIF_NOSOUND 0x00000010 - -#pragma pack(push,4) - -typedef struct { - DWORD cbSize; - HWND hWnd; - UINT uID; - UINT uFlags; - UINT uCallbackMessage; - HICON hIcon; - WCHAR szTip[128]; - DWORD dwState; - DWORD dwStateMask; - WCHAR szInfo[256]; - union { - UINT uTimeout; - UINT uVersion; - } DUMMYUNIONNAME; - WCHAR szInfoTitle[64]; - DWORD dwInfoFlags; -} NOTIFYICONDATA_NEW; - - -#pragma pack(pop) - -static bool is_win2k_or_newer() -{ - OSVERSIONINFO ov; - ov.dwOSVersionInfoSize = sizeof(ov); - GetVersionEx(&ov); - switch(ov.dwPlatformId) - { - default: - case VER_PLATFORM_WIN32_WINDOWS: - case VER_PLATFORM_WIN32s: - return false; - case VER_PLATFORM_WIN32_NT: - return ov.dwMajorVersion>4; - } -} - - -#endif - -UTF8API_EXPORT void uFixAmpersandChars(const char * src,string_base & out) -{ - out.reset(); - while(*src) - { - if (*src=='&') - { - out.add_string("&&&"); - src++; - while(*src=='&') - { - out.add_string("&&"); - src++; - } - } - else out.add_byte(*(src++)); - } -} - -UTF8API_EXPORT void uFixAmpersandChars_v2(const char * src,string_base & out) -{ - out.reset(); - while(*src) - { - if (*src=='&') - { - out.add_string("&&"); - src++; - } - else out.add_byte(*(src++)); - } -} - -static BOOL do_action(DWORD action,NOTIFYICONDATA * data) -{ - if (Shell_NotifyIcon(action,data)) return TRUE; - if (action==NIM_MODIFY) - { - if (Shell_NotifyIcon(NIM_ADD,data)) return TRUE; - } - return FALSE; -} - -extern "C" -{ - - UTF8API_EXPORT BOOL uShellNotifyIcon(DWORD action,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip) - { - NOTIFYICONDATA nid; - NOTIFYICONDATA * p_nid = &nid; -#ifdef UNICODE - NOTIFYICONDATA_NEW nid_new; - if (is_win2k_or_newer()) - { - memset(&nid_new,0,sizeof(nid_new)); - nid_new.cbSize = sizeof(nid_new); - nid_new.hWnd = wnd; - nid_new.uID = id; - nid_new.uFlags = 0; - if (callbackmsg) - { - nid_new.uFlags |= NIF_MESSAGE; - nid_new.uCallbackMessage = callbackmsg; - } - if (icon) - { - nid_new.uFlags |= NIF_ICON; - nid_new.hIcon = icon; - } - if (tip) - { - nid_new.uFlags |= NIF_TIP; - _tcsncpy(nid_new.szTip,string_os_from_utf8(tip),tabsize(nid_new.szTip)-1); - } - - p_nid = reinterpret_cast(&nid_new); - } - else -#endif - { - memset(&nid,0,sizeof(nid)); - nid.cbSize = sizeof(nid); - nid.hWnd = wnd; - nid.uID = id; - nid.uFlags = 0; - if (callbackmsg) - { - nid.uFlags |= NIF_MESSAGE; - nid.uCallbackMessage = callbackmsg; - } - if (icon) - { - nid.uFlags |= NIF_ICON; - nid.hIcon = icon; - } - if (tip) - { - nid.uFlags |= NIF_TIP; - _tcsncpy(nid.szTip,string_os_from_utf8(tip),tabsize(nid.szTip)-1); - } - } - - return do_action(action,p_nid); - } - - UTF8API_EXPORT BOOL uShellNotifyIconEx(DWORD action,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip,const char * balloon_title,const char * balloon_msg) - { - //if (!balloon_title && !balloon_msg) return uShellNotifyIcon(action,wnd,id,callbackmsg,icon,tip); -#ifdef UNICODE - if (!is_win2k_or_newer()) return FALSE; - - NOTIFYICONDATA_NEW nid; - memset(&nid,0,sizeof(nid)); - nid.cbSize = sizeof(nid); - nid.hWnd = wnd; - nid.uID = id; - if (callbackmsg) - { - nid.uFlags |= NIF_MESSAGE; - nid.uCallbackMessage = callbackmsg; - } - if (icon) - { - nid.uFlags |= NIF_ICON; - nid.hIcon = icon; - } - if (tip) - { - nid.uFlags |= NIF_TIP; - _tcsncpy(nid.szTip,string_os_from_utf8(tip),tabsize(nid.szTip)-1); - } - - nid.dwInfoFlags = NIIF_INFO | NIIF_NOSOUND; - //if (balloon_title || balloon_msg) - { - nid.uFlags |= NIF_INFO; - if (balloon_title) _tcsncpy(nid.szInfoTitle,string_os_from_utf8(balloon_title),tabsize(nid.szInfoTitle)-1); - if (balloon_msg) _tcsncpy(nid.szInfo,string_os_from_utf8(balloon_msg),tabsize(nid.szInfo)-1); - } - return do_action(action,reinterpret_cast(&nid)); - -#else - return FALSE; -#endif - - } - -}//extern "C" \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/text_drawing.cpp b/tools/vio2sf/src/foobar8/foobar2000/utf8api/text_drawing.cpp deleted file mode 100644 index da24d687f..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/text_drawing.cpp +++ /dev/null @@ -1,233 +0,0 @@ -#include "utf8api.h" - -static bool is_rect_null(const RECT * r) -{ - return r->right <= r->left || r->bottom <= r->top; -} - -UTF8API_EXPORT UINT uGetTextHeight(HDC dc) -{ - TEXTMETRIC tm; - POINT poo; - GetTextMetrics(dc,&tm); - poo.x = 0; - poo.y = tm.tmHeight; - LPtoDP(dc,&poo,1); - return poo.y>1 ? poo.y : 1; -} - -static int get_text_width(HDC dc,const TCHAR * src,int len) -{ - if (len<=0) return 0; - else - { - SIZE s; - GetTextExtentPoint32(dc,src,len,&s); - return s.cx; - } -} - -//GetTextExtentPoint32 wrapper, removes color marks -int get_text_width_color(HDC dc,const TCHAR * src,int len) -{ - int ptr = 0; - int start = 0; - int rv = 0; - if (len<0) len = _tcslen(src); - while(ptrright<=pos_x || clip->bottom<=pos_y) return TRUE; - } - SetTextAlign(dc,TA_LEFT); - SetBkMode(dc,TRANSPARENT); - SetTextColor(dc,selected ? 0xFFFFFF - default_color : default_color); - - int height = uGetTextHeight(dc); - - int title_ptr = 0; - int textout_start = 0; - int position = pos_x;//item.left+BORDER; - - for(;;) - { - if (title_ptr>=len || src[title_ptr]==3) - { - if (title_ptr>textout_start) - { - int width = get_text_width(dc,src+textout_start,title_ptr-textout_start); - ExtTextOut(dc,position,pos_y,clip ? ETO_CLIPPED : 0,clip,src+textout_start,title_ptr-textout_start,0); - position += width; - textout_start = title_ptr; - } - if (title_ptr>=len) break; - } - if (src[title_ptr]==3) - { - DWORD new_color; - DWORD new_inverted; - bool have_inverted = false; - - if (src[title_ptr+1]==3) {new_color=default_color;title_ptr+=2;} - else - { - title_ptr++; - new_color = _tcstoul(src+title_ptr,0,16); - while(title_ptrtop + (item->bottom-item->top - uGetTextHeight(dc)) / 2; - - int n_tabs = 0; - int total_width = 0; - { - int start = 0; - int n; - for(n=0;nright - item->left; - if (!columns) tab_total -= total_width; - int ptr = display_len; - int tab_ptr = 0; - int written = 0; - int clip_x = item->right; - do - { - int ptr_end = ptr; - while(ptr>0 && display[ptr-1]!='\t') ptr--; - const TCHAR * t_string = display + ptr; - int t_length = ptr_end - ptr; - if (t_length>0) - { - int t_width = get_text_width_color(dc,t_string,t_length) + border*2; - - int pos_x; - int pos_x_right; - - if (!columns) - { - pos_x_right = item->right - MulDiv(tab_ptr,tab_total,n_tabs) - written; - } - else - { - if (tab_ptr==0) pos_x_right = item->right; - else pos_x_right = item->right - MulDiv(tab_ptr,tab_total,n_tabs) + t_width; - } - - if (ptr==0) - { - pos_x = 0; - } - else - { - pos_x = pos_x_right - t_width ; - if (pos_x<0) pos_x = 0; - } - - RECT t_clip = clip; - - if (t_clip.right > clip_x) t_clip.right = clip_x; - - text_out_colors(dc,t_string,t_length,pos_x+border,pos_y,&t_clip,selected,default_color); - - if (clip_x>pos_x) clip_x = pos_x; - - written += t_width; - } - - if (ptr>0) - { - ptr--;//tab char - tab_ptr++; - } - } - while(ptr>0); - - return TRUE; -} - -extern "C" { - -UTF8API_EXPORT BOOL uTextOutColors(HDC dc,const char * text,UINT len,int x,int y,const RECT * clip,BOOL is_selected,DWORD default_color) -{ - unsigned temp_len = estimate_utf8_to_os(text,len); - mem_block_t temp_block; - TCHAR * temp = (temp_len * sizeof(TCHAR) <= PFC_ALLOCA_LIMIT) ? (TCHAR*)alloca(temp_len * sizeof(TCHAR)) : temp_block.set_size(temp_len); - assert(temp); - convert_utf8_to_os(text,temp,len); - - return text_out_colors(dc,temp,_tcslen(temp),x,y,clip,!!is_selected,default_color); -} - -UTF8API_EXPORT BOOL uTextOutColorsTabbed(HDC dc,const char * text,UINT len,const RECT * item,int border,const RECT * clip,BOOL selected,DWORD default_color,BOOL use_columns) -{ - unsigned temp_len = estimate_utf8_to_os(text,len); - mem_block_t temp_block; - TCHAR * temp = (temp_len * sizeof(TCHAR) <= PFC_ALLOCA_LIMIT) ? (TCHAR*)alloca(temp_len * sizeof(TCHAR)) : temp_block.set_size(temp_len); - assert(temp); - convert_utf8_to_os(text,temp,len); - - return text_out_colors_tab(dc,temp,_tcslen(temp),item,border,clip,!!selected,default_color,!!use_columns); -} - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8.cpp b/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8.cpp deleted file mode 100644 index b9a34f003..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include "utf8api.h" -#include - -extern "C" { - -static unsigned q_tolower(unsigned c) -{ - if (c>='A' && c<='Z') c += 'a' - 'A'; - return c; -} - - -#ifdef WIN32 -static UINT char_convert_win9x(UINT param,bool b_upper) -{ - assert(param && param<0x10000); - char temp[16]; - WCHAR temp_w[16]; - temp_w[0] = (WCHAR)param; - temp_w[1] = 0; - if (WideCharToMultiByte(CP_ACP,0,temp_w,-1,temp,16,0,0)==0) return param; - temp[15] = 0; - if (b_upper) CharUpperA(temp); else CharLowerA(temp); - if (MultiByteToWideChar(CP_ACP,0,temp,-1,temp_w,16)==0) return param; - if (temp_w[0]==0 || temp_w[1]!=0) return param; - return temp_w[0]; -} - -#endif - -UTF8API_EXPORT UINT uCharLower(UINT param) -{ - if (param<128) - { - if (param>='A' && param<='Z') param += 'a' - 'A'; - return param; - } -#ifdef WIN32 - else if (param<0x10000) - { - unsigned ret; -#ifdef UNICODE - ret = (unsigned)CharLowerW((WCHAR*)param); -#else - ret = char_convert_win9x(param,false); -#endif - return ret; - } - else return param; -#else - else - { - setlocale(LC_CTYPE,""); - return towlower(param); - } -#endif -} - -UTF8API_EXPORT UINT uCharUpper(UINT param) -{ - if (param<128) - { - if (param>='a' && param<='z') param += 'A' - 'a'; - return param; - } -#ifdef WIN32 - else if (param<0x10000) - { - unsigned ret; -#ifdef UNICODE - ret = (unsigned)CharUpperW((WCHAR*)param); -#else - ret = char_convert_win9x(param,true); -#endif - return ret; - } - else return param; -#else - else - { - setlocale(LC_CTYPE,""); - return towupper(param); - } -#endif -} - -static inline int compare_wchar(unsigned c1,unsigned c2) -{ - if (c1==c2) return 0; - c1 = char_lower(c1); - c2 = char_lower(c2); - if (c1c2) return 1; - else return 0; -} - - -UTF8API_EXPORT int stricmp_utf8(const char * p1,const char * p2) -{ - for(;;) - { - if (*p1==0 && *p2==0) return 0; - else if (*p1>0 && *p2>0)//signed char - { - unsigned c1 = q_tolower(*p1), c2 = q_tolower(*p2); - if (c1c2) return 1; - else - { - p1++; - p2++; - } - } - else - { - unsigned int w1,w2,d1,d2; - d1 = utf8_decode_char(p1,&w1); - d2 = utf8_decode_char(p2,&w2); - if (w1==0 && w2==0) return 0; - int rv = compare_wchar(w1,w2); - if (rv) return rv; - p1 += d1; - p2 += d2; - } - } -} - -UTF8API_EXPORT int stricmp_utf8_stringtoblock(const char * p1,const char * p2,unsigned p2_bytes) -{ - return stricmp_utf8_ex(p1,-1,p2,p2_bytes); -} - -UTF8API_EXPORT int stricmp_utf8_partial(const char * p1,const char * p2,unsigned num) -{ - for(;num;) - { - unsigned int w1,w2,d1,d2; - d1 = utf8_decode_char(p1,&w1); - d2 = utf8_decode_char(p2,&w2); - if (w2==0 || d2==0) return 0; - int rv = compare_wchar(w1,w2); - if (rv) return rv; - p1 += d1; - p2 += d2; - num--; - } - return 0; -} - -UTF8API_EXPORT int stricmp_utf8_max(const char * p1,const char * p2,unsigned p1_bytes) -{ - return stricmp_utf8_ex(p1,p1_bytes,p2,-1); -} - -namespace { - typedef bool (*t_replace_test)(const char * src,const char * test,unsigned len); - - static bool replace_test_i(const char * src,const char * test,unsigned len) - { - return stricmp_utf8_max(src,test,len)==0; - } - - static bool replace_test(const char * src,const char * test,unsigned len) - { - unsigned ptr; - bool rv = true; - for(ptr=0;ptr0) - { - unsigned ptr = 0; - while(ptr+len1<=len) - { - if (testfunc(src+ptr,s1,len1)) - { - count++; - out.add_string(s2,len2); - ptr += len1; - } - else out.add_byte(src[ptr++]); - } - if (ptr0); - assert(c2>0); - char s1[8],s2[8]; - unsigned len1,len2; - len1 = utf8_encode_char(c1,s1); - len2 = utf8_encode_char(c2,s2); - return uReplaceString(out,src,src_len,s1,len1,s2,len2,casesens); -} - - -UTF8API_EXPORT void uAddStringLower(string_base & out,const char * src,unsigned len) -{ - while(*src && len) - { - unsigned int c,d; - d = utf8_decode_char(src,&c); - if (d==0 || d>len) break; - out.add_char(char_lower(c)); - src+=d; - len-=d; - } -} - -UTF8API_EXPORT void uAddStringUpper(string_base & out,const char * src,unsigned len) -{ - while(*src && len) - { - unsigned int c,d; - d = utf8_decode_char(src,&c); - if (d==0 || d>len) break; - out.add_char(char_upper(c)); - src+=d; - len-=d; - } -} - -UTF8API_EXPORT int stricmp_utf8_ex(const char * p1,unsigned p1_bytes,const char * p2,unsigned p2_bytes) -{ - p1_bytes = strlen_max(p1,p1_bytes); - p2_bytes = strlen_max(p2,p2_bytes); - for(;;) - { - if (p1_bytes == 0 && p2_bytes == 0) return 0; - else if (p1_bytes == 0) return 1; - else if (p2_bytes == 0) return -1; - else if (*p1>0 && *p2>0)//signed char - { - unsigned c1 = q_tolower(*p1), c2 = q_tolower(*p2); - if (c1c2) return 1; - else - { - p1++; - p2++; - p1_bytes--; - p2_bytes--; - } - } - else - { - unsigned w1,w2,d1,d2; - d1 = utf8_decode_char(p1,&w1,p1_bytes); - d2 = utf8_decode_char(p2,&w2,p2_bytes); - if (d1==0) return -1; - if (d2==0) return 1; - int rv = compare_wchar(w1,w2); - if (rv) return rv; - p1 += d1; - p2 += d2; - p1_bytes -= d1; - p2_bytes -= d2; - } - } -} - -} diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.cpp b/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.cpp deleted file mode 100644 index 462970675..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.cpp +++ /dev/null @@ -1,1471 +0,0 @@ -#include "utf8api.h" - - -#include -#include - - - -UTF8API_EXPORT UINT UTF8API_GetVersion() -{ - return UTF8API_VERSION; -} - - -class param_os_from_utf8 : public string_os_from_utf8 -{ - bool is_null; - WORD low_word; -public: - param_os_from_utf8(const char * p) : - is_null(p==0), - low_word( HIWORD((DWORD)p)==0 ? LOWORD((DWORD)p) : 0), - string_os_from_utf8( p && HIWORD((DWORD)p)!=0 ?p:"") - {} - inline operator const TCHAR *() - { - return get_ptr(); - } - const TCHAR * get_ptr() - { - return low_word ? (const TCHAR*)(DWORD)low_word : is_null ? 0 : string_os_from_utf8::get_ptr(); - } - -}; - - -static void strncpy_addnull(char * dest,const char * src,int max) -{ - int n; - for(n=0;nFree(li); - rv = 1; - } - - pMalloc->Release(); - return rv; -} - -extern "C" { - -UTF8API_EXPORT BOOL IsUnicode() -{ -#ifdef UNICODE - return TRUE; -#else - return FALSE; -#endif -} - -UTF8API_EXPORT LRESULT uSendMessage(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) -{ - return SendMessage(wnd,msg,wp,lp); -} - -UTF8API_EXPORT LRESULT uSendMessageText(HWND wnd,UINT msg,WPARAM wp,const char * text) -{//this is called somewhat often (playlist search listbox...), so lets avoid mallocing - if (text==0) return SendMessage(wnd,msg,wp,0); - else - { - unsigned temp_len = estimate_utf8_to_os(text); - mem_block_t temp_block; - TCHAR * temp = (temp_len * sizeof(TCHAR) <= PFC_ALLOCA_LIMIT) ? (TCHAR*)alloca(temp_len * sizeof(TCHAR)) : temp_block.set_size(temp_len); - assert(temp); - convert_utf8_to_os(text,temp); - - return SendMessage(wnd,msg,wp,(long)(const TCHAR*)temp); - } - //return SendMessage(wnd,msg,wp,(long)(const TCHAR*)param_os_from_utf8(text)); -} - -UTF8API_EXPORT LRESULT uSendDlgItemMessage(HWND wnd,UINT id,UINT msg,WPARAM wp,LPARAM lp) -{ - return SendDlgItemMessage(wnd,id,msg,wp,lp); -} - -UTF8API_EXPORT LRESULT uSendDlgItemMessageText(HWND wnd,UINT id,UINT msg,WPARAM wp,const char * text) -{ - return uSendMessageText(uGetDlgItem(wnd,id),msg,wp,text);//SendDlgItemMessage(wnd,id,msg,wp,(long)(const TCHAR*)string_os_from_utf8(text)); -} - -UTF8API_EXPORT BOOL uPostMessage(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) -{ - return PostMessage(wnd,msg,wp,lp); -} - -UTF8API_EXPORT BOOL uPostThreadMessage(DWORD id,UINT msg,WPARAM wp,LPARAM lp) -{ - return PostThreadMessage(id,msg,wp,lp); -} - -UTF8API_EXPORT BOOL uGetWindowText(HWND wnd,string_base & out) -{ - int len = GetWindowTextLength(wnd); - if (len>0) - { - len++; - mem_block_t temp(len); - temp[0]=0; - if (GetWindowText(wnd,temp,len)>0) - { - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; - } - } - return FALSE; -} - -UTF8API_EXPORT BOOL uSetWindowText(HWND wnd,const char * text) -{ - unsigned temp_len = estimate_utf8_to_os(text); - mem_block_t temp_block; - TCHAR * temp = (temp_len * sizeof(TCHAR) <= PFC_ALLOCA_LIMIT) ? (TCHAR*)alloca(temp_len * sizeof(TCHAR)) : temp_block.set_size(temp_len); - assert(temp); - - convert_utf8_to_os(text,temp); - return SetWindowText(wnd,temp); -} - - -UTF8API_EXPORT BOOL uGetDlgItemText(HWND wnd,UINT id,string_base & out) -{ - return uGetWindowText(GetDlgItem(wnd,id),out); -} - -UTF8API_EXPORT BOOL uSetDlgItemText(HWND wnd,UINT id,const char * text) -{ - unsigned temp_len = estimate_utf8_to_os(text); - mem_block_t temp_block; - TCHAR * temp = (temp_len * sizeof(TCHAR) <= PFC_ALLOCA_LIMIT) ? (TCHAR*)alloca(temp_len * sizeof(TCHAR)) : temp_block.set_size(temp_len); - assert(temp); - - convert_utf8_to_os(text,temp); - return SetDlgItemText(wnd,id,temp); -} - -UTF8API_EXPORT HWND uCreateDialog(HINSTANCE hIns,UINT id,HWND parent,DLGPROC proc,long param) -{ - return CreateDialogParam(hIns,MAKEINTRESOURCE(id),parent,proc,param); -} - -UTF8API_EXPORT int uDialogBox(HINSTANCE hIns,UINT id,HWND parent,DLGPROC proc,long param) -{ - return DialogBoxParam(hIns,MAKEINTRESOURCE(id),parent,proc,param); -} - -UTF8API_EXPORT BOOL uBrowseForFolder(HWND parent,const char * title,string_base & out) -{ - TCHAR temp[MAX_PATH]; - tcsncpy_addnull(temp,string_os_from_utf8(out),tabsize(temp)); - BOOL rv = browse_for_dir(parent,string_os_from_utf8(title),temp); - if (rv) - { - temp[tabsize(temp)-1]=0; - out.set_string(string_utf8_from_os(temp)); - } - return rv; -} - -UTF8API_EXPORT long uGetWindowLong(HWND wnd,int idx) -{ - return GetWindowLong(wnd,idx); -} - -UTF8API_EXPORT long uSetWindowLong(HWND wnd,int idx,long val) -{ - return SetWindowLong(wnd,idx,val); -} - -UTF8API_EXPORT int uMessageBox(HWND wnd,const char * text,const char * caption,UINT type) -{ - return MessageBox(wnd,param_os_from_utf8(text),param_os_from_utf8(caption),type); -} - -UTF8API_EXPORT void uOutputDebugString(const char * msg) {OutputDebugString(string_os_from_utf8(msg));} - -static void font_os_from_utf8(LOGFONT * dst,const uLOGFONT * src) -{ - memcpy(dst,src,sizeof(*src)-sizeof(src->lfFaceName)); - tcsncpy_addnull(dst->lfFaceName,string_os_from_utf8(src->lfFaceName),tabsize(dst->lfFaceName)); -} - -static void font_utf8_from_os(uLOGFONT * dst,const LOGFONT * src) -{ - memcpy(dst,src,sizeof(*src)-sizeof(src->lfFaceName)); - strncpy_addnull(dst->lfFaceName,string_utf8_from_os(src->lfFaceName),tabsize(dst->lfFaceName)); -} - -UTF8API_EXPORT HFONT uCreateFontIndirect(const uLOGFONT * p_font) -{ - LOGFONT font_os; - font_os_from_utf8(&font_os,p_font); - return CreateFontIndirect(&font_os); -} - -UTF8API_EXPORT void uGetDefaultFont(uLOGFONT * p_font) -{ - LOGFONT font_os; - GetObject(GetStockObject(DEFAULT_GUI_FONT),sizeof(font_os),&font_os); - font_utf8_from_os(p_font,&font_os); -} - -UTF8API_EXPORT BOOL uChooseFont(uLOGFONT * p_font,HWND parent) -{ - LOGFONT font_os; - font_os_from_utf8(&font_os,p_font); - - CHOOSEFONT cf; - memset(&cf,0,sizeof(cf)); - cf.lStructSize = sizeof(cf); - cf.hwndOwner=parent; - cf.lpLogFont=&font_os; - cf.Flags=CF_SCREENFONTS|CF_FORCEFONTEXIST|CF_INITTOLOGFONTSTRUCT; - cf.nFontType=SCREEN_FONTTYPE; - BOOL rv = ChooseFont(&cf); - if (rv) font_utf8_from_os(p_font,&font_os); - return rv; -} - -UTF8API_EXPORT LRESULT uCallWindowProc(WNDPROC lpPrevWndFunc,HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam) -{ - return CallWindowProc(lpPrevWndFunc,hWnd,Msg,wParam,lParam); -} - -UTF8API_EXPORT BOOL uAppendMenu(HMENU menu,UINT flags,UINT id,const char * content) -{ - return AppendMenu(menu,flags,id,param_os_from_utf8(content)); -} - -UTF8API_EXPORT BOOL uInsertMenu(HMENU menu,UINT position,UINT flags,UINT id,const char * content) -{ - return InsertMenu(menu,position,flags,id,param_os_from_utf8(content)); -} - -UTF8API_EXPORT int uStringCompare(const char * elem1, const char * elem2) -{ -#ifdef UNICODE - WCHAR temp1[4],temp2[4]; - for(;;) - { - UINT c1,c2,l1,l2; - l1 = utf8_decode_char(elem1,&c1); - l2 = utf8_decode_char(elem2,&c2); - if (l1==0 && l2==0) return 0; - if (c1!=c2) - { - temp1[utf16_encode_char(c1,temp1)]=0; - temp2[utf16_encode_char(c2,temp2)]=0; - int test = lstrcmpiW(temp1,temp2); - if (test) return test; - } - elem1 += l1; - elem2 += l2; - } -#else - WCHAR temp1[4],temp2[4]; - char ctemp1[20],ctemp2[20]; - for(;;) - { - UINT c1,c2,l1,l2; - l1 = utf8_decode_char(elem1,&c1); - l2 = utf8_decode_char(elem2,&c2); - if (l1==0 && l2==0) return 0; - if (c1!=c2) - { - temp1[utf16_encode_char(c1,temp1)]=0; - temp2[utf16_encode_char(c2,temp2)]=0; - WideCharToMultiByte(CP_ACP,0,temp1,-1,ctemp1,tabsize(ctemp1),0,0); - WideCharToMultiByte(CP_ACP,0,temp2,-1,ctemp2,tabsize(ctemp2),0,0); - int test = lstrcmpiA(ctemp1,ctemp2); - if (test) return test; - } - elem1 += l1; - elem2 += l2; - } -#endif -} - -UTF8API_EXPORT HINSTANCE uLoadLibrary(const char * name) -{ - return LoadLibrary(param_os_from_utf8(name)); -} - -UTF8API_EXPORT HANDLE uCreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes,BOOL bManualReset,BOOL bInitialState, const char * lpName) -{ - return CreateEvent(lpEventAttributes,bManualReset,bInitialState, param_os_from_utf8(lpName)); -} - - -UTF8API_EXPORT DWORD uGetModuleFileName(HMODULE hMod,string_base & out) -{ - TCHAR temp[MAX_PATH]; - temp[0] = 0; - DWORD ret = GetModuleFileName(hMod,temp,tabsize(temp)); - if (ret) - { - temp[tabsize(temp)-1] = 0; - out.set_string_os(temp); - } - return ret; -} - -UTF8API_EXPORT BOOL uSetClipboardString(const char * ptr) -{ - if (OpenClipboard(0)) - { - EmptyClipboard(); - - string_os_from_utf8 temp(ptr); - - HANDLE h_global = GlobalAlloc(GMEM_DDESHARE, (_tcslen(temp) + 1) * sizeof(TCHAR)); - if (h_global!=0) - { - TCHAR * ptr = (TCHAR*)GlobalLock(h_global); - _tcscpy(ptr,temp); - GlobalUnlock(h_global); - SetClipboardData( -#ifdef UNICODE - CF_UNICODETEXT -#else - CF_TEXT -#endif - ,h_global); - } - CloseClipboard(); - return TRUE; - } - else return FALSE; -} - -UTF8API_EXPORT LRESULT uDefWindowProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) -{ - return DefWindowProc(wnd,msg,wp,lp); -} - -UTF8API_EXPORT BOOL uIsDialogMessage(HWND dlg,LPMSG msg) -{ - return IsDialogMessage(dlg,msg); -} - -UTF8API_EXPORT BOOL uGetMessage(LPMSG msg,HWND wnd,UINT min,UINT max) -{ - return GetMessage(msg,wnd,min,max); -} - -UTF8API_EXPORT BOOL uGetClassName(HWND wnd,string_base & out) -{ - TCHAR temp[512]; - temp[0]=0; - if (GetClassName(wnd,temp,tabsize(temp))>0) - { - temp[tabsize(temp)-1]=0; - out.set_string_os(temp); - return TRUE; - } - else return FALSE; -} - -UTF8API_EXPORT UINT uCharLength(const char * src) {return utf8_char_len(src);} - -UTF8API_EXPORT BOOL uDragQueryFile(HDROP hDrop,UINT idx,string_base & out) -{ - UINT len = DragQueryFile(hDrop,idx,0,0); - if (len>0 && len!=(UINT)(-1)) - { - len++; - mem_block_t temp(len); - if (DragQueryFile(hDrop,idx,temp,len)>0) - { - out.set_string_os(temp); - return TRUE; - } - } - return FALSE; -} - -UTF8API_EXPORT UINT uDragQueryFileCount(HDROP hDrop) -{ - return DragQueryFile(hDrop,-1,0,0); -} - - -UTF8API_EXPORT LRESULT uSendMessageTimeout(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,UINT flags,UINT timeout,LPDWORD result) -{ - return SendMessageTimeout(wnd,msg,wp,lp,flags,timeout,result); -} - -UTF8API_EXPORT BOOL uGetTextExtentPoint32(HDC dc,const char * text,UINT cb,LPSIZE size) -{ - string_os_from_utf8 temp(text,cb); - return GetTextExtentPoint32(dc,temp,_tcslen(temp),size); -} - -UTF8API_EXPORT BOOL uExtTextOut(HDC dc,int x,int y,UINT flags,const RECT * rect,const char * text,UINT cb,const int * lpdx) -{ - string_os_from_utf8 temp(text,cb); - return ExtTextOut(dc,x,y,flags,rect,temp,_tcslen(temp),lpdx); -} - -UTF8API_EXPORT BOOL uChooseColor(DWORD * p_color,HWND parent,DWORD * p_custom_colors) -{ - CHOOSECOLOR cc; - memset(&cc,0,sizeof(cc)); - cc.lStructSize = sizeof(cc); - cc.hwndOwner = parent; - cc.rgbResult = *p_color; - cc.lpCustColors = p_custom_colors; - cc.Flags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT; - BOOL rv = ChooseColor(&cc); - if (rv) - { - *p_color = cc.rgbResult; - return TRUE; - } - else return FALSE; -} - -UTF8API_EXPORT BOOL uPeekMessage(LPMSG msg,HWND wnd,UINT min,UINT max,UINT flag) -{ - return PeekMessage(msg,wnd,min,max,flag); -} - -UTF8API_EXPORT LONG uDispatchMessage(const MSG * msg) -{ - return DispatchMessage(msg); -} - -UTF8API_EXPORT HCURSOR uLoadCursor(HINSTANCE hIns,const char * name) -{ - return LoadCursor(hIns,param_os_from_utf8(name)); -} - -UTF8API_EXPORT HICON uLoadIcon(HINSTANCE hIns,const char * name) -{ - return LoadIcon(hIns,param_os_from_utf8(name)); -} - -UTF8API_EXPORT HMENU uLoadMenu(HINSTANCE hIns,const char * name) -{ - return LoadMenu(hIns,param_os_from_utf8(name)); -} - - - -UTF8API_EXPORT BOOL uGetEnvironmentVariable(const char * name,string_base & out) -{ - string_os_from_utf8 name_t(name); - DWORD size = GetEnvironmentVariable(name_t,0,0); - if (size>0) - { - size++; - mem_block_t temp(size); - temp[0]=0; - if (GetEnvironmentVariable(name_t,temp,size)>0) - { - temp[size-1]=0; - out.set_string_os(temp); - return TRUE; - } - } - return FALSE; -} - -UTF8API_EXPORT HMODULE uGetModuleHandle(const char * name) -{ - return GetModuleHandle(param_os_from_utf8(name)); -} - -UTF8API_EXPORT UINT uRegisterWindowMessage(const char * name) -{ - return RegisterWindowMessage(string_os_from_utf8(name)); -} - -UTF8API_EXPORT BOOL uMoveFile(const char * src,const char * dst) -{ - return MoveFile(string_os_from_utf8(src),string_os_from_utf8(dst)); -} - -UTF8API_EXPORT BOOL uDeleteFile(const char * fn) -{ - return DeleteFile(string_os_from_utf8(fn)); -} - -UTF8API_EXPORT DWORD uGetFileAttributes(const char * fn) -{ - return GetFileAttributes(string_os_from_utf8(fn)); -} - -UTF8API_EXPORT BOOL uRemoveDirectory(const char * fn) -{ - return RemoveDirectory(string_os_from_utf8(fn)); -} - -UTF8API_EXPORT HANDLE uCreateFile(const char * fn,DWORD access,DWORD share,LPSECURITY_ATTRIBUTES blah,DWORD creat,DWORD flags,HANDLE tmpl) -{ - return CreateFile(string_os_from_utf8(fn),access,share,blah,creat,flags,tmpl); -} - -UTF8API_EXPORT BOOL uCreateDirectory(const char * fn,LPSECURITY_ATTRIBUTES blah) -{ - return CreateDirectory(string_os_from_utf8(fn),blah); -} - -UTF8API_EXPORT HANDLE uCreateMutex(LPSECURITY_ATTRIBUTES blah,BOOL bInitialOwner,const char * name) -{ - return name ? CreateMutex(blah,bInitialOwner,string_os_from_utf8(name)) : CreateMutex(blah,bInitialOwner,0); -} - -UTF8API_EXPORT BOOL uGetFullPathName(const char * name,string_base & out) -{ - string_os_from_utf8 name_os(name); - unsigned len = GetFullPathName(name_os,0,0,0); - if (len==0) return FALSE; - mem_block_t temp; - if (!temp.set_size(len+1)) return FALSE; - TCHAR * blah; - if (GetFullPathName(name_os,len+1,temp,&blah)==0) return FALSE; - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; -} - -UTF8API_EXPORT BOOL uGetLongPathName(const char * name,string_base & out) -{ - static bool inited; - typedef DWORD (_stdcall * PGETLONGPATHNAME)(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer); - static PGETLONGPATHNAME pGetLongPathName; - if (!inited) - { - pGetLongPathName = (PGETLONGPATHNAME)GetProcAddress(uGetModuleHandle("kernel32.dll"), -#ifdef UNICODE - "GetLongPathNameW" -#else - "GetLongPathNameA" -#endif - ); - inited = true; - } - if (pGetLongPathName) - { - TCHAR temp[4096]; - temp[0]=0; - if (pGetLongPathName(string_os_from_utf8(name),temp,tabsize(temp))) - { - temp[tabsize(temp)-1]=0; - out.set_string_os(temp); - return TRUE; - } - } - return FALSE; -} - -UTF8API_EXPORT void uGetCommandLine(string_base & out) -{ - out.set_string_os(GetCommandLine()); -} - -UTF8API_EXPORT BOOL uGetTempPath(string_base & out) -{ - TCHAR temp[MAX_PATH+1]; - temp[0]=0; - if (GetTempPath(tabsize(temp),temp)) - { - temp[tabsize(temp)-1]=0; - out.set_string_os(temp); - return TRUE; - } - return FALSE; - -} -UTF8API_EXPORT BOOL uGetTempFileName(const char * path_name,const char * prefix,UINT unique,string_base & out) -{ - if (path_name==0 || prefix==0) return FALSE; - TCHAR temp[MAX_PATH+1]; - temp[0]=0; - if (GetTempFileName(string_os_from_utf8(path_name),string_os_from_utf8(prefix),unique,temp)) - { - temp[tabsize(temp)-1]=0; - out.set_string_os(temp); - return TRUE; - } - return FALSE; -} - -class uFindFile_i : public uFindFile -{ - string8 fn; - WIN32_FIND_DATA fd; - HANDLE hFF; -public: - uFindFile_i() {hFF = INVALID_HANDLE_VALUE;} - bool FindFirst(const char * path) - { - hFF = FindFirstFile(string_os_from_utf8(path),&fd); - if (hFF==INVALID_HANDLE_VALUE) return false; - fn.set_string_os(fd.cFileName); - return true; - } - virtual BOOL FindNext() - { - if (hFF==INVALID_HANDLE_VALUE) return FALSE; - BOOL rv = FindNextFile(hFF,&fd); - if (rv) fn.set_string_os(fd.cFileName); - return rv; - } - - virtual const char * GetFileName() - { - return fn; - } - - virtual __int64 GetFileSize() - { - union - { - __int64 val64; - struct - { - DWORD lo,hi; - }; - } ret; - - ret.hi = fd.nFileSizeHigh; - ret.lo = fd.nFileSizeLow; - return ret.val64; - - } - virtual DWORD GetAttributes() - { - return fd.dwFileAttributes; - } - - virtual FILETIME GetCreationTime() - { - return fd.ftCreationTime; - } - virtual FILETIME GetLastAccessTime() - { - return fd.ftLastAccessTime; - } - virtual FILETIME GetLastWriteTime() - { - return fd.ftLastWriteTime; - } - virtual ~uFindFile_i() - { - if (hFF!=INVALID_HANDLE_VALUE) FindClose(hFF); - } -}; - -UTF8API_EXPORT uFindFile * uFindFirstFile(const char * path) -{ - uFindFile_i * ptr = new uFindFile_i; - if (!ptr->FindFirst(path)) - { - delete ptr; - ptr = 0; - } - return ptr; -} - -UTF8API_EXPORT BOOL uGetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,string_base & p_filename,BOOL b_save) -{ - string_os_from_utf8 ext_mask_t(p_ext_mask); - mem_block_t ext_mask(_tcslen(ext_mask_t)+2); - ext_mask.zeromemory(); - _tcscpy(ext_mask,ext_mask_t); - - { - UINT n; - for(n=0;n0 && buffer[ptr-1]==' ') buffer[--ptr] = 0; - } - - p_filename.set_string_os(buffer); - return TRUE; - } - else return FALSE; -} - -class uGetOpenFileNameMultiResult_i : public uGetOpenFileNameMultiResult -{ - ptr_list_simple items; -public: - void AddItem(const char * param) {items.add_item(strdup(param));} - virtual UINT GetCount() {return items.get_count();} - virtual const char * GetFileName(UINT index) {return index>=0 && index<(UINT)items.get_count() ? items[index] : 0;} - virtual ~uGetOpenFileNameMultiResult_i() {items.free_all();} -}; - -UTF8API_EXPORT uGetOpenFileNameMultiResult * uGetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory) -{ - string_os_from_utf8 ext_mask_t(p_ext_mask); - mem_block_t ext_mask(_tcslen(ext_mask_t)+2); - ext_mask.zeromemory(); - _tcscpy(ext_mask,ext_mask_t); - - { - UINT n; - for(n=0;n0 && buffer[ptr-1]==' ') buffer[--ptr] = 0; - } - - result->AddItem(string_utf8_from_os(buffer)); - } - else - { - string8 s; - s.set_string_os(buffer); - int ofs=s.length(); - if (s[ofs-1]!='\\') {s.add_char('\\');ofs++;} - while(*p) - { - s.truncate(ofs); - s.add_string_os(p); - s.skip_trailing_char(' '); - result->AddItem(s); - while(*p) p++; - p++; - } - } - return result; - } - else return 0; -} - -UTF8API_EXPORT HINSTANCE uShellExecute(HWND wnd,const char * oper,const char * file,const char * params,const char * dir,int cmd) -{ - return ShellExecute(wnd,param_os_from_utf8(oper),param_os_from_utf8(file),param_os_from_utf8(params),param_os_from_utf8(dir),cmd); -} - -UTF8API_EXPORT HWND uCreateStatusWindow(LONG style,const char * text,HWND parent,UINT id) -{ - return CreateStatusWindow(style,param_os_from_utf8(text),parent,id); -} - -UTF8API_EXPORT ATOM uRegisterClass(const uWNDCLASS * ptr) -{ - param_os_from_utf8 str_menu(ptr->lpszMenuName),str_class(ptr->lpszClassName); - WNDCLASS cl; - cl.style = ptr->style; - cl.lpfnWndProc = ptr->lpfnWndProc; - cl.cbClsExtra = ptr->cbClsExtra; - cl.cbWndExtra = ptr->cbWndExtra; - cl.hInstance = ptr->hInstance; - cl.hIcon = ptr->hIcon; - cl.hCursor = ptr->hCursor; - cl.hbrBackground = ptr->hbrBackground; - cl.lpszMenuName = str_menu; - cl.lpszClassName = str_class; - - return RegisterClass(&cl); -} - -UTF8API_EXPORT HWND uCreateWindowEx(DWORD dwExStyle,const char * lpClassName,const char * lpWindowName,DWORD dwStyle,int x,int y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam) -{ - return CreateWindowEx(dwExStyle,param_os_from_utf8(lpClassName),param_os_from_utf8(lpWindowName),dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam); -} - -UTF8API_EXPORT HANDLE uLoadImage(HINSTANCE hIns,const char * name,UINT type,int x,int y,UINT flags) -{ - return LoadImage(hIns,param_os_from_utf8(name),type,x,y,flags); -} - -UTF8API_EXPORT BOOL uGetSystemDirectory(string_base & out) -{ - UINT len = GetSystemDirectory(0,0); - if (len==0) len = MAX_PATH; - len++; - mem_block_t temp; - if (!temp.set_size(len)) return FALSE; - if (GetSystemDirectory(temp,len)==0) return FALSE; - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; -} - -UTF8API_EXPORT BOOL uGetWindowsDirectory(string_base & out) -{ - UINT len = GetWindowsDirectory(0,0); - if (len==0) len = MAX_PATH; - len++; - mem_block_t temp; - if (!temp.set_size(len)) return FALSE; - if (GetWindowsDirectory(temp,len)==0) return FALSE; - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; -} - -UTF8API_EXPORT BOOL uSetCurrentDirectory(const char * path) -{ - return SetCurrentDirectory(string_os_from_utf8(path)); -} - -UTF8API_EXPORT BOOL uGetCurrentDirectory(string_base & out) -{ - UINT len = GetCurrentDirectory(0,0); - if (len==0) len = MAX_PATH; - len++; - mem_block_t temp; - if (!temp.set_size(len)) return FALSE; - if (GetCurrentDirectory(len,temp)==0) return FALSE; - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; -} - -UTF8API_EXPORT BOOL uExpandEnvironmentStrings(const char * src,string_base & out) -{ - string_os_from_utf8 src_os(src); - UINT len = ExpandEnvironmentStrings(src_os,0,0); - if (len==0) len = 256; - len++; - mem_block_t temp; - if (!temp.set_size(len)) return FALSE; - if (ExpandEnvironmentStrings(src_os,temp,len)==0) return FALSE; - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; -} - -UTF8API_EXPORT BOOL uGetUserName(string_base & out) -{ - TCHAR temp[UNLEN+1]; - DWORD len = tabsize(temp); - if (GetUserName(temp,&len)) - { - temp[tabsize(temp)-1]=0; - out.set_string_os(temp); - return TRUE; - } - else return FALSE; -} - -UTF8API_EXPORT BOOL uGetShortPathName(const char * src,string_base & out) -{ - string_os_from_utf8 src_os(src); - UINT len = GetShortPathName(src_os,0,0); - if (len==0) len = MAX_PATH; - len++; - mem_block_t temp(len); - if (GetShortPathName(src_os,temp,len)) - { - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; - } - else return FALSE; -} - -UTF8API_EXPORT BOOL uUnregisterClass(const char * name,HINSTANCE ins) -{ - return UnregisterClass(param_os_from_utf8(name),ins); -} - -#ifdef UNICODE -#define DDE_CODEPAGE CP_WINUNICODE -#else -#define DDE_CODEPAGE CP_WINANSI -#endif - - -UTF8API_EXPORT HSZ uDdeCreateStringHandle(DWORD ins,const char * src) -{ - return DdeCreateStringHandle(ins,string_os_from_utf8(src),DDE_CODEPAGE); -} - -UTF8API_EXPORT BOOL uDdeQueryString(DWORD ins,HSZ hsz,string_base & out) -{ - mem_block_t temp; - UINT len = DdeQueryString(ins,hsz,0,0,DDE_CODEPAGE); - if (len==0) len = MAX_PATH; - len++; - if (temp.set_size(len)==0) return FALSE; - if (DdeQueryString(ins,hsz,temp,len,DDE_CODEPAGE)) - { - temp[len-1]=0; - out.set_string_os(temp); - return TRUE; - } - else return FALSE; -} - -UTF8API_EXPORT UINT uDdeInitialize(LPDWORD pidInst,PFNCALLBACK pfnCallback,DWORD afCmd,DWORD ulRes) -{ - return DdeInitialize(pidInst,pfnCallback,afCmd,ulRes); -} - -UTF8API_EXPORT BOOL uDdeAccessData_Text(HDDEDATA data,string_base & out) -{ - const TCHAR * ptr = (const TCHAR*) DdeAccessData(data,0); - if (ptr) - { - out.set_string_os(ptr); - return TRUE; - } - else return FALSE; -} - -UTF8API_EXPORT HANDLE uSortStringCreate(const char * src) -{ - TCHAR * ret = mem_ops::alloc(estimate_utf8_to_os(src)); - if (ret) - { - convert_utf8_to_os(src,ret); - ret = mem_ops::realloc(ret,_tcslen(ret)+1); - } - return (HANDLE)ret; -} - -UTF8API_EXPORT int uSortStringCompareEx(HANDLE string1,HANDLE string2,DWORD flags) -{ - return CompareString(LOCALE_USER_DEFAULT,flags,reinterpret_cast(string1),-1,reinterpret_cast(string2),-1); -} - -UTF8API_EXPORT int uSortStringCompare(HANDLE string1,HANDLE string2) -{ - return lstrcmpi(reinterpret_cast(string1),reinterpret_cast(string2)); -} - -UTF8API_EXPORT void uSortStringFree(HANDLE string) -{ - mem_ops::free(reinterpret_cast(string)); -} - -static void stringlist_os_from_utf8(const char * src,mem_block_t & out) -{ - unsigned p_out = 0; - if (src) - { - while(*src) - { - unsigned src_len = strlen(src); - out.check_size(p_out + estimate_utf8_to_os(src,src_len)); - p_out += 1 + convert_utf8_to_os(src,out.get_ptr() + p_out,src_len); - src += src_len + 1; - } - } - out.copy(TEXT("\0"),2,p_out); -} - -UTF8API_EXPORT int uSHFileOperation(uSHFILEOPSTRUCT * p_op) -{ - mem_block_t temp1,temp2; - stringlist_os_from_utf8(p_op->pFrom,temp1); - stringlist_os_from_utf8(p_op->pTo,temp2); - - param_os_from_utf8 progress_title(p_op->lpszProgressTitle); - - SHFILEOPSTRUCT op; - op.hwnd = p_op->hwnd; - op.wFunc = p_op->wFunc; - op.pFrom = temp1; - op.pTo = temp2; - op.fFlags = p_op->fFlags; - op.fAnyOperationsAborted = p_op->fAnyOperationsAborted; - op.hNameMappings = p_op->hNameMappings; - op.lpszProgressTitle = progress_title; - - int ret = SHFileOperation(&op); - p_op->fAnyOperationsAborted = op.fAnyOperationsAborted; - return ret; -} - -UTF8API_EXPORT BOOL uCreateProcess( - const char * lpApplicationName, - const char * lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - const char * lpEnvironment, - const char * lpCurrentDirectory, - const uSTARTUPINFO * lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation -) -{ - if (lpStartupInfo->cb!=sizeof(uSTARTUPINFO)) return FALSE; - STARTUPINFO si; - param_os_from_utf8 si_lpDesktop(lpStartupInfo->lpDesktop); - param_os_from_utf8 si_lpTitle(lpStartupInfo->lpTitle); - si.cb = sizeof(si); - si.lpReserved = 0; - si.lpDesktop = const_cast(si_lpDesktop.get_ptr()); - si.lpTitle = const_cast(si_lpTitle.get_ptr()); - si.dwX = lpStartupInfo->dwX; - si.dwY = lpStartupInfo->dwY; - si.dwXSize = lpStartupInfo->dwXSize; - si.dwYSize = lpStartupInfo->dwYSize; - si.dwXCountChars = lpStartupInfo->dwXCountChars; - si.dwYCountChars = lpStartupInfo->dwYCountChars; - si.dwFillAttribute = lpStartupInfo->dwFillAttribute; - si.dwFlags = lpStartupInfo->dwFlags; - si.wShowWindow = lpStartupInfo->wShowWindow; - si.cbReserved2 = 0; - si.lpReserved2 = 0; - si.hStdInput = lpStartupInfo->hStdInput; - si.hStdOutput = lpStartupInfo->hStdOutput; - si.hStdError = lpStartupInfo->hStdError; - - mem_block_fastalloc env; - if (lpEnvironment) - { - unsigned env_out = 0; - const char * p_env = lpEnvironment; - do { - env.check_size(env_out + estimate_utf8_to_os(p_env)); - env_out += convert_utf8_to_os(p_env,env+env_out) + 1; - p_env += strlen(p_env) + 1; - } while(*p_env); - env.check_size(env_out+1); - env[env_out]=0; - } - - mem_block_t gay; - gay.set_size(estimate_utf8_to_os(lpCommandLine)+MAX_PATH); - convert_utf8_to_os(lpCommandLine,gay); - - return CreateProcess(param_os_from_utf8(lpApplicationName), - gay, - lpProcessAttributes,lpThreadAttributes, - bInheritHandles, -#ifdef UNICODE - dwCreationFlags|CREATE_UNICODE_ENVIRONMENT, -#else - dwCreationFlags&~CREATE_UNICODE_ENVIRONMENT, -#endif - lpEnvironment ? env.get_ptr() : 0, - param_os_from_utf8(lpCurrentDirectory), - &si, - lpProcessInformation - ); -} - -UTF8API_EXPORT HTREEITEM uTreeView_InsertItem(HWND wnd,const uTVINSERTSTRUCT * param) -{ - mem_block_t temp; - unsigned needed_length = estimate_utf8_to_os(param->item.pszText); - TCHAR * pszText = (needed_length * sizeof(TCHAR) <= PFC_ALLOCA_LIMIT) ? (TCHAR*)alloca(needed_length * sizeof(TCHAR)) : temp.set_size(PFC_ALLOCA_LIMIT); - convert_utf8_to_os(param->item.pszText,pszText); - - - TVINSERTSTRUCT l_param; - memset(&l_param,0,sizeof(l_param)); - l_param.hParent = param->hParent; - l_param.hInsertAfter = param->hInsertAfter; - l_param.item.mask = param->item.mask; - l_param.item.hItem = param->item.hItem; - l_param.item.state = param->item.state; - l_param.item.stateMask = param->item.stateMask; - l_param.item.pszText = pszText; - l_param.item.cchTextMax = 0; - l_param.item.iImage = param->item.iImage; - l_param.item.iSelectedImage = param->item.iImage; - l_param.item.cChildren = param->item.cChildren; - l_param.item.lParam = param->item.lParam; - if (param->item.mask & TVIF_INTEGRAL) - { - l_param.itemex.iIntegral = param->itemex.iIntegral; - } - - return (HTREEITEM) uSendMessage(wnd,TVM_INSERTITEM,0,(LPARAM)&l_param); -} - -UTF8API_EXPORT UINT uGetFontHeight(HFONT font) -{ - UINT ret; - HDC dc = CreateCompatibleDC(0); - SelectObject(dc,font); - ret = uGetTextHeight(dc); - DeleteDC(dc); - return ret; -} - -UTF8API_EXPORT HHOOK uSetWindowsHookEx(int idhook,HOOKPROC fn,HINSTANCE hMod,DWORD threadid) -{ - return SetWindowsHookEx(idhook,fn,hMod,threadid); -} - -UTF8API_EXPORT HIMAGELIST uImageList_LoadImage(HINSTANCE hi, const char * lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags) -{ - return ImageList_LoadImage(hi,param_os_from_utf8(lpbmp),cx,cGrow,crMask,uType,uFlags); -} - -UTF8API_EXPORT BOOL uSendNotifyMessage(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) -{ - return SendNotifyMessage(wnd,msg,wp,lp); -} - -UTF8API_EXPORT BOOL uSendMessageCallback(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,SENDASYNCPROC cb,DWORD data) -{ - return SendMessageCallback(wnd,msg,wp,lp,cb,data); -} - -UTF8API_EXPORT unsigned uOSStringEstimateSize(const char * src,unsigned len) -{ - return estimate_utf8_to_os(src,len) * sizeof(TCHAR); -} - -UTF8API_EXPORT unsigned uOSStringConvert(const char * src,void * dst,unsigned len) -{ - return convert_utf8_to_os(src,(TCHAR*)dst,len); -} - -UTF8API_EXPORT int uTabCtrl_InsertItem(HWND wnd,int idx,const uTCITEM * item) -{ - param_os_from_utf8 text((item->mask & TCIF_TEXT) ? item->pszText : 0); - TCITEM l_item; - assert(sizeof(l_item)==sizeof(*item));//meh lazy - memcpy(&l_item,item,sizeof(l_item)); - l_item.pszText = const_cast(text.get_ptr()); - l_item.cchTextMax = 0; - return TabCtrl_InsertItem(wnd,idx,&l_item); -} - -UTF8API_EXPORT int uTabCtrl_SetItem(HWND wnd,int idx,const uTCITEM * item) -{ - param_os_from_utf8 text((item->mask & TCIF_TEXT) ? item->pszText : 0); - TCITEM l_item; - assert(sizeof(l_item)==sizeof(*item));//meh lazy - memcpy(&l_item,item,sizeof(l_item)); - l_item.pszText = const_cast(text.get_ptr()); - l_item.cchTextMax = 0; - return TabCtrl_SetItem(wnd,idx,&l_item); -} - -UTF8API_EXPORT int uGetKeyNameText(LONG lparam,string_base & out) -{ - TCHAR temp[256]; - temp[0]=0; - if (!GetKeyNameText(lparam,temp,tabsize(temp))) return 0; - temp[tabsize(temp)-1]=0; - out.set_string(string_utf8_from_os(temp)); - return 1; -} - -UTF8API_EXPORT HANDLE uCreateFileMapping(HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,const char * lpName) -{ - return CreateFileMapping(hFile,lpFileMappingAttributes,flProtect,dwMaximumSizeHigh,dwMaximumSizeLow,param_os_from_utf8(lpName)); -} - -UTF8API_EXPORT BOOL uListBox_GetText(HWND listbox,UINT index,string_base & out) -{ - unsigned len = uSendMessage(listbox,LB_GETTEXTLEN,index,0); - if (len==LB_ERR || len>16*1024*1024) return FALSE; - if (len==0) {out.reset();return TRUE;} - - mem_block_t temp(len+1); - if (temp.get_ptr()==0) return FALSE; - temp.zeromemory(); - len = uSendMessage(listbox,LB_GETTEXT,index,(LPARAM)temp.get_ptr()); - if (len==LB_ERR) return false; - out.set_string(string_utf8_from_os(temp)); - return TRUE; -} - -UTF8API_EXPORT void uPrintf(string_base & out,const char * fmt,...) -{ - va_list list; - va_start(list,fmt); - uPrintfV(out,fmt,list); - va_end(list); -} - -UTF8API_EXPORT void uPrintfV(string_base & out,const char * fmt,va_list arglist) -{ - string_printf::g_run(out,fmt,arglist); -} - -UTF8API_EXPORT int uCompareString(DWORD flags,const char * str1,unsigned len1,const char * str2,unsigned len2) -{ - return CompareString(LOCALE_USER_DEFAULT,flags,string_os_from_utf8(str1,len1),-1,string_os_from_utf8(str2,len2),-1); -} - -class uResource_i : public uResource -{ - unsigned size; - const void * ptr; -public: - inline uResource_i(const void * p_ptr,unsigned p_size) : ptr(p_ptr), size(p_size) - { - } - virtual const void * GetPointer() - { - return ptr; - } - virtual unsigned GetSize() - { - return size; - } - virtual ~uResource_i() - { - } -}; - -UTF8API_EXPORT uResource * uLoadResource(HMODULE hMod,const char * name,const char * type,WORD wLang) -{ - HRSRC res = uFindResource(hMod,name,type,wLang); - if (res==0) return 0; - HGLOBAL hglob = LoadResource(hMod,res); - if (hglob) - { - void * ptr = LockResource(hglob); - if (ptr) - { - return new uResource_i(ptr,SizeofResource(hMod,res)); - } - else return 0; - } - else return 0; - -} - -UTF8API_EXPORT HRSRC uFindResource(HMODULE hMod,const char * name,const char * type,WORD wLang) -{ - return wLang ? FindResourceEx(hMod,param_os_from_utf8(name),param_os_from_utf8(type),wLang) : FindResource(hMod,param_os_from_utf8(name),param_os_from_utf8(type)); -} - -UTF8API_EXPORT BOOL uLoadString(HINSTANCE ins,UINT id,string_base & out) -{ - BOOL rv = FALSE; - uResource * res = uLoadResource(ins,uMAKEINTRESOURCE(id),(const char*)(RT_STRING)); - if (res) - { - unsigned size = res->GetSize(); - const WCHAR * ptr = (const WCHAR*)res->GetPointer(); - if (size>=4) - { - unsigned len = *(const WORD*)(ptr+1); - if (len * 2 + 4 <= size) - { - out = string_utf8_from_wide(ptr+2,len); - } - } - - delete res; - rv = TRUE; - } - return rv; -} - -UTF8API_EXPORT BOOL uGetMenuString(HMENU menu,UINT id,string_base & out,UINT flag) -{ - unsigned len = GetMenuString(menu,id,0,0,flag); - if (len==0) - { - out.reset(); - return FALSE; - } - TCHAR * temp = (TCHAR*)malloc((len+1)*sizeof(TCHAR)); - if (temp==0) - { - out.reset(); - return FALSE; - } - if (GetMenuString(menu,id,temp,len+1,flag)==0) - { - free(temp); - out.reset(); - return FALSE; - } - out = string_utf8_from_os(temp); - free(temp); - return TRUE; -} - -UTF8API_EXPORT BOOL uModifyMenu(HMENU menu,UINT id,UINT flags,UINT newitem,const char * data) -{ - return ModifyMenu(menu,id,flags,newitem,param_os_from_utf8(data)); -} - -UTF8API_EXPORT UINT uGetMenuItemType(HMENU menu,UINT position) -{ - MENUITEMINFO info; - memset(&info,0,sizeof(info)); - info.cbSize = sizeof(info); - info.fMask = MIIM_TYPE; - if (!GetMenuItemInfo(menu,position,TRUE,&info)) - return 0; - return info.fType; -} - -static inline bool i_is_path_separator(unsigned c) -{ - return c=='\\' || c=='/' || c=='|' || c==':'; -} - -UTF8API_EXPORT int uSortPathCompare(HANDLE string1,HANDLE string2) -{ - const TCHAR * s1 = reinterpret_cast(string1); - const TCHAR * s2 = reinterpret_cast(string2); - const TCHAR * p1, * p2; - - while (*s1 || *s2) - { - if (*s1 == *s2) - { - s1++; - s2++; - continue; - } - - p1 = s1; while (*p1 && !i_is_path_separator(*p1)) p1++; - p2 = s2; while (*p2 && !i_is_path_separator(*p2)) p2++; - - if ((!*p1 && !*p2) || (*p1 && *p2)) - { - int test = CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE | NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH, s1, p1 - s1, s2, p2 - s2); - if (test && test != 2) return test - 2; - if (!*p1) return 0; - } - else - { - if (*p1) return -1; - else return 1; - } - - s1 = p1 + 1; - s2 = p2 + 1; - } - - return 0; -} - -UTF8API_EXPORT UINT uRegisterClipboardFormat(const char * name) -{ - return RegisterClipboardFormat(string_os_from_utf8(name)); -} - -UTF8API_EXPORT BOOL uGetClipboardFormatName(UINT format,string_base & out) -{ - TCHAR temp[1024]; - if (!GetClipboardFormatName(format,temp,tabsize(temp))) return FALSE; - temp[tabsize(temp)-1] = 0; - out.set_string_os(temp); - return TRUE; -} - -}//extern "C" -#ifdef _MSC_VER -#if _MSC_VER==1200 -#pragma comment(linker,"/opt:nowin98") -#endif -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.dsp b/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.dsp deleted file mode 100644 index e9ced9dd3..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.dsp +++ /dev/null @@ -1,159 +0,0 @@ -# Microsoft Developer Studio Project File - Name="utf8api" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=utf8api - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "utf8api.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "utf8api.mak" CFG="utf8api - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "utf8api - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "utf8api - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "utf8api - Win32 Release ANSI" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "utf8api - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "../Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UTF8API_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UTF8API_EXPORTS" /D "UNICODE" /D "_UNICODE" /Yu"utf8api.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x809 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comctl32.lib imagehlp.lib /nologo /dll /machine:I386 -# SUBTRACT LINK32 /debug - -!ELSEIF "$(CFG)" == "utf8api - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "../Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UTF8API_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UTF8API_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "_DEBUG" -# ADD RSC /l 0x809 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib imagehlp.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ELSEIF "$(CFG)" == "utf8api - Win32 Release ANSI" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release ANSI" -# PROP BASE Intermediate_Dir "Release ANSI" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "../Release_ANSI" -# PROP Intermediate_Dir "Release ANSI" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UTF8API_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UTF8API_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x809 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib imagehlp.lib /nologo /dll /machine:I386 - -!ENDIF - -# Begin Target - -# Name "utf8api - Win32 Release" -# Name "utf8api - Win32 Debug" -# Name "utf8api - Win32 Release ANSI" -# Begin Source File - -SOURCE=.\crash_info.cpp -# End Source File -# Begin Source File - -SOURCE=.\stdafx.cpp - -!IF "$(CFG)" == "utf8api - Win32 Release" - -# ADD CPP /Yc - -!ELSEIF "$(CFG)" == "utf8api - Win32 Debug" - -!ELSEIF "$(CFG)" == "utf8api - Win32 Release ANSI" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\systray.cpp -# End Source File -# Begin Source File - -SOURCE=.\text_drawing.cpp -# End Source File -# Begin Source File - -SOURCE=.\utf8.cpp -# End Source File -# Begin Source File - -SOURCE=.\utf8api.cpp -# End Source File -# Begin Source File - -SOURCE=.\utf8api.h -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.h b/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.h deleted file mode 100644 index 78014c989..000000000 --- a/tools/vio2sf/src/foobar8/foobar2000/utf8api/utf8api.h +++ /dev/null @@ -1,462 +0,0 @@ -#ifndef _UTF8API_DLL__UTF8API_H_ -#define _UTF8API_DLL__UTF8API_H_ - -#include "../../pfc/pfc.h" - -#ifndef WIN32 -#error N/A -#endif - -#ifndef STRICT -#define STRICT -#endif - -#include -#include -#include - -#ifndef UTF8API_EXPORTS -#define UTF8API_EXPORT _declspec(dllimport) -#else -#define UTF8API_EXPORT _declspec(dllexport) -#endif - -#define UTF8API_VERSION 3 - -extern "C" { - -UTF8API_EXPORT BOOL IsUnicode(); -UTF8API_EXPORT UINT UTF8API_GetVersion(); -UTF8API_EXPORT LRESULT uSendMessage(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); -UTF8API_EXPORT LRESULT uSendMessageText(HWND wnd,UINT msg,WPARAM wp,const char * text); -UTF8API_EXPORT LRESULT uSendDlgItemMessage(HWND wnd,UINT id,UINT msg,WPARAM wp,LPARAM lp); -UTF8API_EXPORT LRESULT uSendDlgItemMessageText(HWND wnd,UINT id,UINT msg,WPARAM wp,const char * text); -UTF8API_EXPORT LRESULT uSendMessageTimeout(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,UINT flags,UINT timeout,LPDWORD result); -UTF8API_EXPORT BOOL uSendNotifyMessage(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); -UTF8API_EXPORT BOOL uSendMessageCallback(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,SENDASYNCPROC cb,DWORD data); -UTF8API_EXPORT BOOL uPostMessage(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); -UTF8API_EXPORT BOOL uPostThreadMessage(DWORD id,UINT msg,WPARAM wp,LPARAM lp); -UTF8API_EXPORT BOOL uGetWindowText(HWND wnd,string_base & out); -UTF8API_EXPORT BOOL uSetWindowText(HWND wnd,const char * text); -UTF8API_EXPORT BOOL uGetDlgItemText(HWND wnd,UINT id,string_base & out); -UTF8API_EXPORT BOOL uSetDlgItemText(HWND wnd,UINT id,const char * text); -UTF8API_EXPORT HWND uCreateDialog(HINSTANCE hIns,UINT id,HWND parent,DLGPROC proc,long param=0); -UTF8API_EXPORT int uDialogBox(HINSTANCE hIns,UINT id,HWND parent,DLGPROC proc,long param=0); -UTF8API_EXPORT BOOL uBrowseForFolder(HWND parent,const char * title,string_base & out); -UTF8API_EXPORT long uGetWindowLong(HWND wnd,int idx); -UTF8API_EXPORT long uSetWindowLong(HWND wnd,int idx,long val); -UTF8API_EXPORT int uMessageBox(HWND wnd,const char * text,const char * caption,UINT type); -UTF8API_EXPORT void uOutputDebugString(const char * msg); -typedef LOGFONTA uLOGFONT; -UTF8API_EXPORT HFONT uCreateFontIndirect(const uLOGFONT * p_font); -UTF8API_EXPORT void uGetDefaultFont(uLOGFONT * p_font); -UTF8API_EXPORT BOOL uChooseFont(uLOGFONT * p_font,HWND parent); -UTF8API_EXPORT LRESULT uCallWindowProc(WNDPROC lpPrevWndFunc,HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam); -UTF8API_EXPORT BOOL uAppendMenu(HMENU menu,UINT flags,UINT id,const char * content); -UTF8API_EXPORT BOOL uInsertMenu(HMENU menu,UINT position,UINT flags,UINT id,const char * content); -UTF8API_EXPORT int uStringCompare(const char * elem1, const char * elem2); -UTF8API_EXPORT HINSTANCE uLoadLibrary(const char * name); -UTF8API_EXPORT HANDLE uCreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes,BOOL bManualReset,BOOL bInitialState, const char * lpName); -UTF8API_EXPORT DWORD uGetModuleFileName(HMODULE hMod,string_base & out); -UTF8API_EXPORT BOOL uSetClipboardString(const char * ptr); -UTF8API_EXPORT LRESULT uDefWindowProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp); -UTF8API_EXPORT BOOL uIsDialogMessage(HWND dlg,LPMSG msg); -UTF8API_EXPORT BOOL uGetMessage(LPMSG msg,HWND wnd,UINT min,UINT max); -UTF8API_EXPORT BOOL uGetClassName(HWND wnd,string_base & out); -UTF8API_EXPORT UINT uCharLength(const char * src); -UTF8API_EXPORT BOOL uDragQueryFile(HDROP hDrop,UINT idx,string_base & out); -UTF8API_EXPORT UINT uDragQueryFileCount(HDROP hDrop); -UTF8API_EXPORT BOOL uGetTextExtentPoint32(HDC dc,const char * text,UINT cb,LPSIZE size);//note, cb is number of bytes, not actual unicode characters in the string (read: plain strlen() will do) -UTF8API_EXPORT BOOL uExtTextOut(HDC dc,int x,int y,UINT flags,const RECT * rect,const char * text,UINT cb,const int * lpdx); -UTF8API_EXPORT BOOL uTextOutColors(HDC dc,const char * src,UINT len,int x,int y,const RECT * clip,BOOL is_selected,DWORD default_color); -UTF8API_EXPORT BOOL uTextOutColorsTabbed(HDC dc,const char * src,UINT src_len,const RECT * item,int border,const RECT * clip,BOOL selected,DWORD default_color,BOOL use_columns); -UTF8API_EXPORT UINT uGetTextHeight(HDC dc); -UTF8API_EXPORT UINT uGetFontHeight(HFONT font); -UTF8API_EXPORT BOOL uChooseColor(DWORD * p_color,HWND parent,DWORD * p_custom_colors); -UTF8API_EXPORT BOOL uPeekMessage(LPMSG msg,HWND wnd,UINT min,UINT max,UINT flag); -UTF8API_EXPORT LONG uDispatchMessage(const MSG * msg); -UTF8API_EXPORT HCURSOR uLoadCursor(HINSTANCE hIns,const char * name); -UTF8API_EXPORT HICON uLoadIcon(HINSTANCE hIns,const char * name); -UTF8API_EXPORT HMENU uLoadMenu(HINSTANCE hIns,const char * name); -UTF8API_EXPORT BOOL uGetEnvironmentVariable(const char * name,string_base & out); -UTF8API_EXPORT HMODULE uGetModuleHandle(const char * name); -UTF8API_EXPORT UINT uRegisterWindowMessage(const char * name); -UTF8API_EXPORT BOOL uMoveFile(const char * src,const char * dst); -UTF8API_EXPORT BOOL uDeleteFile(const char * fn); -UTF8API_EXPORT DWORD uGetFileAttributes(const char * fn); -UTF8API_EXPORT BOOL uRemoveDirectory(const char * fn); -UTF8API_EXPORT HANDLE uCreateFile(const char * fn,DWORD access,DWORD share,LPSECURITY_ATTRIBUTES blah,DWORD creat,DWORD flags,HANDLE tmpl); -UTF8API_EXPORT HANDLE uCreateFileMapping(HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,const char * lpName); -UTF8API_EXPORT BOOL uCreateDirectory(const char * fn,LPSECURITY_ATTRIBUTES blah); -UTF8API_EXPORT HANDLE uCreateMutex(LPSECURITY_ATTRIBUTES blah,BOOL bInitialOwner,const char * name); -UTF8API_EXPORT BOOL uGetLongPathName(const char * name,string_base & out);//may just fail to work on old windows versions, present on win98/win2k+ -UTF8API_EXPORT BOOL uGetFullPathName(const char * name,string_base & out); -UTF8API_EXPORT void uGetCommandLine(string_base & out); -UTF8API_EXPORT BOOL uGetTempPath(string_base & out); -UTF8API_EXPORT BOOL uGetTempFileName(const char * path_name,const char * prefix,UINT unique,string_base & out); -UTF8API_EXPORT BOOL uGetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,string_base & p_filename,BOOL b_save); -//note: uGetOpenFileName extension mask uses | as separator, not null -UTF8API_EXPORT HANDLE uLoadImage(HINSTANCE hIns,const char * name,UINT type,int x,int y,UINT flags); -UTF8API_EXPORT UINT uRegisterClipboardFormat(const char * name); -UTF8API_EXPORT BOOL uGetClipboardFormatName(UINT format,string_base & out); - -UTF8API_EXPORT HANDLE uSortStringCreate(const char * src); -UTF8API_EXPORT int uSortStringCompare(HANDLE string1,HANDLE string2); -UTF8API_EXPORT int uSortStringCompareEx(HANDLE string1,HANDLE string2,DWORD flags);//flags - see win32 CompareString -UTF8API_EXPORT int uSortPathCompare(HANDLE string1,HANDLE string2); -UTF8API_EXPORT void uSortStringFree(HANDLE string); - - -UTF8API_EXPORT int uCompareString(DWORD flags,const char * str1,unsigned len1,const char * str2,unsigned len2); - -class NOVTABLE uGetOpenFileNameMultiResult -{ -public: - virtual UINT GetCount()=0; - virtual const char * GetFileName(UINT index)=0; - virtual ~uGetOpenFileNameMultiResult() {} -}; - -UTF8API_EXPORT uGetOpenFileNameMultiResult * uGetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory); - -class NOVTABLE uFindFile -{ -protected: - uFindFile() {} -public: - virtual BOOL FindNext()=0; - virtual const char * GetFileName()=0; - virtual __int64 GetFileSize()=0; - virtual DWORD GetAttributes()=0; - virtual FILETIME GetCreationTime()=0; - virtual FILETIME GetLastAccessTime()=0; - virtual FILETIME GetLastWriteTime()=0; - virtual ~uFindFile() {}; - inline bool IsDirectory() {return (GetAttributes() & FILE_ATTRIBUTE_DIRECTORY) ? true : false;} -}; - -UTF8API_EXPORT uFindFile * uFindFirstFile(const char * path); - -UTF8API_EXPORT HINSTANCE uShellExecute(HWND wnd,const char * oper,const char * file,const char * params,const char * dir,int cmd); -UTF8API_EXPORT HWND uCreateStatusWindow(LONG style,const char * text,HWND parent,UINT id); - -typedef WNDCLASSA uWNDCLASS; -UTF8API_EXPORT ATOM uRegisterClass(const uWNDCLASS * ptr); -UTF8API_EXPORT BOOL uUnregisterClass(const char * name,HINSTANCE ins); - -UTF8API_EXPORT BOOL uShellNotifyIcon(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip); -UTF8API_EXPORT BOOL uShellNotifyIconEx(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip,const char * balloon_title,const char * balloon_msg); - -UTF8API_EXPORT HWND uCreateWindowEx(DWORD dwExStyle,const char * lpClassName,const char * lpWindowName,DWORD dwStyle,int x,int y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam); - -UTF8API_EXPORT BOOL uGetSystemDirectory(string_base & out); -UTF8API_EXPORT BOOL uGetWindowsDirectory(string_base & out); -UTF8API_EXPORT BOOL uSetCurrentDirectory(const char * path); -UTF8API_EXPORT BOOL uGetCurrentDirectory(string_base & out); -UTF8API_EXPORT BOOL uExpandEnvironmentStrings(const char * src,string_base & out); -UTF8API_EXPORT BOOL uGetUserName(string_base & out); -UTF8API_EXPORT BOOL uGetShortPathName(const char * src,string_base & out); - -UTF8API_EXPORT HSZ uDdeCreateStringHandle(DWORD ins,const char * src); -UTF8API_EXPORT BOOL uDdeQueryString(DWORD ins,HSZ hsz,string_base & out); -UTF8API_EXPORT UINT uDdeInitialize(LPDWORD pidInst,PFNCALLBACK pfnCallback,DWORD afCmd,DWORD ulRes); -UTF8API_EXPORT BOOL uDdeAccessData_Text(HDDEDATA data,string_base & out); - -UTF8API_EXPORT HIMAGELIST uImageList_LoadImage(HINSTANCE hi, const char * lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags); - -#define uDdeFreeStringHandle DdeFreeStringHandle -#define uDdeCmpStringHandles DdeCmpStringHandles -#define uDdeKeepStringHandle DdeKeepStringHandle -#define uDdeUninitialize DdeUninitialize -#define uDdeNameService DdeNameService -#define uDdeFreeDataHandle DdeFreeDataHandle - - -typedef TVINSERTSTRUCTA uTVINSERTSTRUCT; - -UTF8API_EXPORT HTREEITEM uTreeView_InsertItem(HWND wnd,const uTVINSERTSTRUCT * param); - -UTF8API_EXPORT HHOOK uSetWindowsHookEx(int idhook,HOOKPROC fn,HINSTANCE hMod,DWORD threadid); -#define uUnhookWindowsHookEx UnhookWindowsHookEx -#define uCallNextHookEx CallNextHookEx - - -typedef SHFILEOPSTRUCTA uSHFILEOPSTRUCT; -UTF8API_EXPORT int uSHFileOperation(uSHFILEOPSTRUCT * lpFileOp); - -typedef STARTUPINFOA uSTARTUPINFO; - -UTF8API_EXPORT BOOL uCreateProcess( - const char * lpApplicationName, - const char * lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - const char * lpEnvironment, - const char * lpCurrentDirectory, - const uSTARTUPINFO * lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation -); - -UTF8API_EXPORT unsigned uOSStringEstimateSize(const char * src,unsigned len = -1);//return value in bytes -UTF8API_EXPORT unsigned uOSStringConvert(const char * src,void * dst,unsigned len = -1);//length of src (will cut if found null earlier) -/* usage: - - const char * src = "something"; - - void * temp = malloc(uOSStringEstimateSize(src)); - uOSStringConvert(src,temp); - //now temp contains OS-friendly (TCHAR) version of src -*/ - -typedef TCITEMA uTCITEM; -UTF8API_EXPORT int uTabCtrl_InsertItem(HWND wnd,int idx,const uTCITEM * item); -UTF8API_EXPORT int uTabCtrl_SetItem(HWND wnd,int idx,const uTCITEM * item); - -UTF8API_EXPORT int uGetKeyNameText(LONG lparam,string_base & out); - -UTF8API_EXPORT void uFixAmpersandChars(const char * src,string_base & out);//for systray -UTF8API_EXPORT void uFixAmpersandChars_v2(const char * src,string_base & out);//for other controls -//gotta hate MS for shoving ampersand=>underline conversion into random things AND making each of them use different rules for inserting ampersand char instead of underline - - -//deprecated -UTF8API_EXPORT UINT uPrintCrashInfo(LPEXCEPTION_POINTERS param,const char * extrainfo,char * out); -#define uPrintCrashInfo_max_length 1024 - -UTF8API_EXPORT void uPrintCrashInfo_Init(const char * name);//called only by exe on startup - -UTF8API_EXPORT void uDumpCrashInfo(LPEXCEPTION_POINTERS param); - -UTF8API_EXPORT BOOL uListBox_GetText(HWND listbox,UINT index,string_base & out); - -UTF8API_EXPORT void uPrintf(string_base & out,const char * fmt,...); -UTF8API_EXPORT void uPrintfV(string_base & out,const char * fmt,va_list arglist); - -class NOVTABLE uResource -{ -public: - virtual const void * GetPointer() = 0; - virtual unsigned GetSize() = 0; - virtual ~uResource() {} -}; - -UTF8API_EXPORT uResource * uLoadResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); -UTF8API_EXPORT HRSRC uFindResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); - -UTF8API_EXPORT BOOL uLoadString(HINSTANCE ins,UINT id,string_base & out); - -UTF8API_EXPORT UINT uCharLower(UINT c); -UTF8API_EXPORT UINT uCharUpper(UINT c); - -UTF8API_EXPORT BOOL uGetMenuString(HMENU menu,UINT id,string_base & out,UINT flag); -UTF8API_EXPORT BOOL uModifyMenu(HMENU menu,UINT id,UINT flags,UINT newitem,const char * data); -UTF8API_EXPORT UINT uGetMenuItemType(HMENU menu,UINT position); - - -}//extern "C" - -inline char * uCharNext(char * src) {return src+uCharLength(src);} -inline const char * uCharNext(const char * src) {return src+uCharLength(src);} - - -class string_utf8_from_window : public string8 -{ -public: - string_utf8_from_window(HWND wnd) - { - uGetWindowText(wnd,*this); - } - string_utf8_from_window(HWND wnd,UINT id) - { - uGetDlgItemText(wnd,id,*this); - } -}; - -#define uMAKEINTRESOURCE(x) ((const char*)LOWORD(x)) - -class critical_section -{ -private: - CRITICAL_SECTION sec; - int count; -public: - int enter() {EnterCriticalSection(&sec);return ++count;} - int leave() {int rv = --count;LeaveCriticalSection(&sec);return rv;} - int get_lock_count() {return count;} - int get_lock_count_check() {enter();return leave();} - inline void assert_locked() {assert(get_lock_count_check()>0);} - inline void assert_not_locked() {assert(get_lock_count_check()==0);} - critical_section() {InitializeCriticalSection(&sec);count=0;} - ~critical_section() {DeleteCriticalSection(&sec);} -#ifdef CRITICAL_SECTION_HAVE_TRYENTER - bool try_enter() {return !!TryEnterCriticalSection(&sec);} -#endif -}; - -class c_insync -{ -private: - critical_section * ptr; -public: - c_insync(critical_section * p) {ptr=p;ptr->enter();} - c_insync(critical_section & p) {ptr=&p;ptr->enter();} - ~c_insync() {ptr->leave();} -}; - -#define insync(X) c_insync blah____sync(X) - - -class critical_section2 //smarter version, has try_enter() -{ -private: - HANDLE hMutex; - int count; -public: - int enter() {return enter_timeout(INFINITE);} - int leave() {int rv = --count;ReleaseMutex(hMutex);return rv;} - int get_lock_count() {return count;} - int get_lock_count_check() - { - int val = try_enter(); - if (val>0) val = leave(); - return val; - } - int enter_timeout(DWORD t) {return WaitForSingleObject(hMutex,t)==WAIT_OBJECT_0 ? ++count : 0;} - int try_enter() {return enter_timeout(0);} - int check_count() {enter();return leave();} - critical_section2() - { - hMutex = uCreateMutex(0,0,0); - count=0; - } - ~critical_section2() {CloseHandle(hMutex);} - - inline void assert_locked() {assert(get_lock_count_check()>0);} - inline void assert_not_locked() {assert(get_lock_count_check()==0);} - -}; - -class c_insync2 -{ -private: - critical_section2 * ptr; -public: - c_insync2(critical_section2 * p) {ptr=p;ptr->enter();} - c_insync2(critical_section2 & p) {ptr=&p;ptr->enter();} - ~c_insync2() {ptr->leave();} -}; - -#define insync2(X) c_insync2 blah____sync2(X) - - -//other -#define uEndDialog EndDialog -#define uDestroyWindow DestroyWindow -#define uGetDlgItem GetDlgItem -#define uEnableWindow EnableWindow -#define uGetDlgItemInt GetDlgItemInt -#define uSetDlgItemInt SetDlgItemInt -#define uHookWindowProc(WND,PROC) ((WNDPROC)uSetWindowLong(WND,GWL_WNDPROC,(long)(PROC))) -#define uCreateToolbarEx CreateToolbarEx -#define uIsBadStringPtr IsBadStringPtrA - - -class string_print_crash -{ - char block[uPrintCrashInfo_max_length]; -public: - inline operator const char * () const {return block;} - inline const char * get_ptr() const {return block;} - inline unsigned length() {return strlen(block);} - inline string_print_crash(LPEXCEPTION_POINTERS param,const char * extrainfo = 0) {uPrintCrashInfo(param,extrainfo,block);} -}; - -class uStringPrintf : private string8_fastalloc -{ -public: - inline explicit uStringPrintf(const char * fmt,...) - { - va_list list; - va_start(list,fmt); - uPrintfV(*this,fmt,list); - va_end(list); - } - operator const char * () {return get_ptr();} -}; - -inline LRESULT uButton_SetCheck(HWND wnd,UINT id,bool state) {return uSendDlgItemMessage(wnd,id,BM_SETCHECK,state ? BST_CHECKED : BST_UNCHECKED,0); } -inline bool uButton_GetCheck(HWND wnd,UINT id) {return uSendDlgItemMessage(wnd,id,BM_GETCHECK,0,0) == BST_CHECKED;} - -class UTF8API_EXPORT uCallStackTracker -{ - unsigned param; -public: - explicit uCallStackTracker(const char * name); - ~uCallStackTracker(); -}; - -extern "C" -{ - UTF8API_EXPORT const char * uGetCallStackPath(); -} - -#define TRACK_CALL(X) uCallStackTracker TRACKER__##X(#X) -#define TRACK_CALL_TEXT(X) uCallStackTracker TRACKER__BLAH(X) - - -extern "C" { -UTF8API_EXPORT int stricmp_utf8(const char * p1,const char * p2); -UTF8API_EXPORT int stricmp_utf8_ex(const char * p1,unsigned len1,const char * p2,unsigned len2); -UTF8API_EXPORT int stricmp_utf8_stringtoblock(const char * p1,const char * p2,unsigned p2_bytes); -UTF8API_EXPORT int stricmp_utf8_partial(const char * p1,const char * p2,unsigned num = (unsigned)(-1)); -UTF8API_EXPORT int stricmp_utf8_max(const char * p1,const char * p2,unsigned p1_bytes); -UTF8API_EXPORT unsigned uReplaceStringAdd(string_base & out,const char * src,unsigned src_len,const char * s1,unsigned len1,const char * s2,unsigned len2,bool casesens); -UTF8API_EXPORT unsigned uReplaceCharAdd(string_base & out,const char * src,unsigned src_len,unsigned c1,unsigned c2,bool casesens); -//all lengths in uReplaceString functions are optional, set to -1 if parameters is a simple null-terminated string -UTF8API_EXPORT void uAddStringLower(string_base & out,const char * src,unsigned len = (unsigned)(-1)); -UTF8API_EXPORT void uAddStringUpper(string_base & out,const char * src,unsigned len = (unsigned)(-1)); - -inline void uStringLower(string_base & out,const char * src,unsigned len = (unsigned)(-1)) {out.reset();uAddStringLower(out,src,len);} -inline void uStringUpper(string_base & out,const char * src,unsigned len = (unsigned)(-1)) {out.reset();uAddStringUpper(out,src,len);} - -inline unsigned uReplaceString(string_base & out,const char * src,unsigned src_len,const char * s1,unsigned len1,const char * s2,unsigned len2,bool casesens) -{ - out.reset(); - return uReplaceStringAdd(out,src,src_len,s1,len1,s2,len2,casesens); -} - -inline unsigned uReplaceChar(string_base & out,const char * src,unsigned src_len,unsigned c1,unsigned c2,bool casesens) -{ - out.reset(); - return uReplaceCharAdd(out,src,src_len,c1,c2,casesens); -} - -class string_lower : private string8 -{ -public: - explicit string_lower(const char * ptr,unsigned num=-1) {uAddStringLower(*this,ptr,num);} - operator const char * () {return string8::get_ptr();} -}; - -class string_upper : private string8 -{ -public: - explicit string_upper(const char * ptr,unsigned num=-1) {uAddStringUpper(*this,ptr,num);} - operator const char * () {return string8::get_ptr();} -}; - - -} - -#define char_lower uCharLower -#define char_upper uCharUpper - -inline BOOL uGetLongPathNameEx(const char * name,string_base & out) -{ - if (uGetLongPathName(name,out)) return TRUE; - return uGetFullPathName(name,out); -} - -#endif //_UTF8API_DLL__UTF8API_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/license.txt b/tools/vio2sf/src/foobar8/license.txt deleted file mode 100644 index d62a0729e..000000000 --- a/tools/vio2sf/src/foobar8/license.txt +++ /dev/null @@ -1,10 +0,0 @@ -Copyright (c) 2001-2004, Peter Pawlowski -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/vio2sf/src/foobar8/pfc/array.h b/tools/vio2sf/src/foobar8/pfc/array.h deleted file mode 100644 index 2ce8dfe00..000000000 --- a/tools/vio2sf/src/foobar8/pfc/array.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _PFC_ARRAY_H_ -#define _PFC_ARRAY_H_ - -template -class array_t -{ -public: - explicit array_t(unsigned size = 0) - { - m_data = 0; - m_size = 0; - resize(size); - } - - inline const T& operator[](unsigned n) const - { - assert(n m_size ? m_size : new_size; - for(n=0;n0 && get(ptr)!=val) {ptr+=d;todo--;} - return ptr; - } - inline bool operator[](int n) const {return get(n);} - - unsigned calc_count(bool val,int start,unsigned count) const//counts number of vals for start<=n class mem_block_t; //blah - -template -class bit_array_table_t : public bit_array -{ - const T * data; - int count; - bool before,after; -public: - inline bit_array_table_t(const T * p_data,int p_count,bool p_before = false,bool p_after = false) - : data(p_data), count(p_count), before(p_before), after(p_after) - { - } - - inline bit_array_table_t(const mem_block_t & p_data,bool p_before = false,bool p_after = false) - : data(p_data.get_ptr()), count(p_data.get_size()), before(p_before), after(p_after) - { - } - - virtual bool get(int n) const - { - if (n<0) return before; - else if (n bit_array_table; - -class bit_array_range : public bit_array -{ - int begin,end; - bool state; -public: - bit_array_range(int first,int count,bool p_state = true) : begin(first), end(first+count), state(p_state) {} - - virtual bool get(int n) const - { - bool rv = n>=begin && n0) - return (val>=start && valstart+count) ? val : start+count; - } - else - { - if (start == val) return count>0 ? start+1 : start-1; - else return start; - } - } -}; - -class bit_array_bittable : public bit_array_var -{ - unsigned char * data; - unsigned count; -public: - //helpers - inline static bool g_get(const unsigned char * ptr,unsigned idx) - { - return !! (ptr[idx>>3] & (1<<(idx&7))); - } - - inline static void g_set(unsigned char * ptr,unsigned idx,bool val) - { - unsigned char & dst = ptr[idx>>3]; - unsigned char mask = 1<<(idx&7); - dst = val ? dst|mask : dst&~mask; - } - - inline static unsigned g_estimate_size(unsigned count) {return (count+7)>>3;} - - void resize(unsigned p_count) - { - count = p_count; - unsigned bytes = g_estimate_size(count); - if (bytes==0) - { - if (data) {free(data);data=0;} - } - else - { - data = data ? (unsigned char*)realloc(data,bytes) : (unsigned char*)malloc(bytes); - memset(data,0,bytes); - } - } - - inline bit_array_bittable(unsigned p_count) {count=0;data=0;resize(p_count);} - inline ~bit_array_bittable() {free(data);} - - virtual void set(int n,bool val) - { - if ((unsigned)n>1;n++) - { - t = ptr[n]; - ptr[n] = ptr[bytes-n-1]; - ptr[bytes-n-1] = t; - } -} - -#if 0 -typedef struct _GUID { // size is 16 - DWORD Data1; - WORD Data2; - WORD Data3; - BYTE Data4[8]; -} GUID; -#endif - -void swap_guid(GUID & g) -{ - swap_order(&g.Data1,sizeof(g.Data1)); - swap_order(&g.Data2,sizeof(g.Data2)); - swap_order(&g.Data3,sizeof(g.Data3)); -} - - -void guid_native_to_le(GUID ¶m) -{ - if (machine_is_big_endian()) swap_guid(param); -} - -void guid_native_to_be(GUID ¶m) -{ - if (!machine_is_big_endian()) swap_guid(param); -} - -void guid_le_to_native(GUID ¶m) -{ - if (machine_is_big_endian()) swap_guid(param); -} - -void guid_be_to_native(GUID ¶m) -{ - if (!machine_is_big_endian()) swap_guid(param); -} - - -WORD swap_word(WORD p) -{ - return ((p&0x00FF)<<8)|((p&0xFF00)>>8); -} - -DWORD swap_dword(DWORD p) -{ - return ((p&0xFF000000)>>24) | ((p&0x00FF0000)>>8) | ((p&0x0000FF00)<<8) | ((p&0x000000FF)<<24); -} - - -#ifndef PFC_BYTE_ORDER_IS_BIG_ENDIAN -void swap_order_if_le(void * ptr,unsigned bytes) -{ - if (machine_is_little_endian()) swap_order(ptr,bytes); -} -void swap_order_if_be(void * ptr,unsigned bytes) -{ - if (machine_is_big_endian()) swap_order(ptr,bytes); -} -WORD swap_word_if_le(WORD p) -{ - return machine_is_little_endian() ? swap_word(p) : p; -} -WORD swap_word_if_be(WORD p) -{ - return machine_is_big_endian() ? swap_word(p) : p; -} -DWORD swap_dword_if_le(DWORD p) -{ - return machine_is_little_endian() ? swap_dword(p) : p; -} -DWORD swap_dword_if_be(DWORD p) -{ - return machine_is_big_endian() ? swap_dword(p) : p; -} -#endif - -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/byte_order_helper.h b/tools/vio2sf/src/foobar8/pfc/byte_order_helper.h deleted file mode 100644 index f35a0869b..000000000 --- a/tools/vio2sf/src/foobar8/pfc/byte_order_helper.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef _PFC_BYTE_ORDER_HELPER_ -#define _PFC_BYTE_ORDER_HELPER_ - -namespace byte_order_helper { - -#ifdef _M_IX86 -#define PFC_BYTE_ORDER_IS_BIG_ENDIAN 0 -#endif - -#ifdef PFC_BYTE_ORDER_IS_BIG_ENDIAN -#define PFC_BYTE_ORDER_IS_LITTLE_ENDIAN (!(PFC_BYTE_ORDER_IS_BIG_ENDIAN)) -#endif - //if not defined, use machine_is_big_endian() to detect in runtime - -#ifndef PFC_BYTE_ORDER_IS_BIG_ENDIAN - bool machine_is_big_endian(); -#else - inline bool machine_is_big_endian() {return PFC_BYTE_ORDER_IS_BIG_ENDIAN;} -#endif - - inline bool machine_is_little_endian() {return !machine_is_big_endian();} - - - void swap_order(void * ptr,unsigned bytes); - void swap_guid(GUID & g); - WORD swap_word(WORD); - DWORD swap_dword(DWORD); - -#ifdef PFC_BYTE_ORDER_IS_BIG_ENDIAN -#if PFC_BYTE_ORDER_IS_BIG_ENDIAN - inline void swap_order_if_le(void * ptr,unsigned bytes) {} - inline void swap_order_if_be(void * ptr,unsigned bytes) {swap_order(ptr,bytes);} - inline WORD swap_word_if_le(WORD p) {return p;} - inline WORD swap_word_if_be(WORD p) {return swap_word(p);} - inline DWORD swap_dword_if_le(DWORD p) {return p;} - inline DWORD swap_dword_if_be(DWORD p) {return swap_dword(p);} -#else - inline void swap_order_if_le(void * ptr,unsigned bytes) {swap_order(ptr,bytes);} - inline void swap_order_if_be(void * ptr,unsigned bytes) {} - inline WORD swap_word_if_le(WORD p) {return swap_word(p);} - inline WORD swap_word_if_be(WORD p) {return p;} - inline DWORD swap_dword_if_le(DWORD p) {return swap_dword(p);} - inline DWORD swap_dword_if_be(DWORD p) {return p;} -#endif -#else - void swap_order_if_le(void * ptr,unsigned bytes); - void swap_order_if_be(void * ptr,unsigned bytes); - WORD swap_word_if_le(WORD p); - WORD swap_word_if_be(WORD p); - DWORD swap_dword_if_le(DWORD p); - DWORD swap_dword_if_be(DWORD p); -#endif - - inline void order_be_to_native(void * ptr,unsigned bytes) {swap_order_if_le(ptr,bytes);} - inline void order_le_to_native(void * ptr,unsigned bytes) {swap_order_if_be(ptr,bytes);} - inline void order_native_to_be(void * ptr,unsigned bytes) {swap_order_if_le(ptr,bytes);} - inline void order_native_to_le(void * ptr,unsigned bytes) {swap_order_if_be(ptr,bytes);} - - inline QWORD swap_qword(QWORD param) {swap_order(¶m,sizeof(param));return param;} - - inline QWORD qword_be_to_native(QWORD param) {swap_order_if_le(¶m,sizeof(param));return param;} - inline QWORD qword_le_to_native(QWORD param) {swap_order_if_be(¶m,sizeof(param));return param;} - inline QWORD qword_native_to_be(QWORD param) {swap_order_if_le(¶m,sizeof(param));return param;} - inline QWORD qword_native_to_le(QWORD param) {swap_order_if_be(¶m,sizeof(param));return param;} - - inline DWORD dword_be_to_native(DWORD param) {return swap_dword_if_le(param);} - inline DWORD dword_le_to_native(DWORD param) {return swap_dword_if_be(param);} - inline DWORD dword_native_to_be(DWORD param) {return swap_dword_if_le(param);} - inline DWORD dword_native_to_le(DWORD param) {return swap_dword_if_be(param);} - - inline WORD word_be_to_native(WORD param) {return swap_word_if_le(param);} - inline WORD word_le_to_native(WORD param) {return swap_word_if_be(param);} - inline WORD word_native_to_be(WORD param) {return swap_word_if_le(param);} - inline WORD word_native_to_le(WORD param) {return swap_word_if_be(param);} - - void guid_native_to_le(GUID ¶m);//big F-U to whoever wrote original GUID declaration, writing it to files depends on byte order - void guid_native_to_be(GUID ¶m); - void guid_le_to_native(GUID ¶m); - void guid_be_to_native(GUID ¶m); -}; - -#endif diff --git a/tools/vio2sf/src/foobar8/pfc/cfg_memblock.h b/tools/vio2sf/src/foobar8/pfc/cfg_memblock.h deleted file mode 100644 index 285ee3f9c..000000000 --- a/tools/vio2sf/src/foobar8/pfc/cfg_memblock.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _PFC_CFG_VAR_MEMBLOCK_H_ -#define _PFC_CFG_VAR_MEMBLOCK_H_ - -#if 0 //deprecated - -template -class cfg_memblock : public cfg_var, public mem_block_list -{ -private: - const T* init_val; - unsigned init_size; -protected: - virtual void reset() - { - remove_all(); - if (init_val) - { - unsigned n; - for(n=0;nwrite(get_ptr(),get_count()*sizeof(T)); - } - - virtual void set_raw_data(const void * data,int size) - { - remove_all(); - const T * ptr = reinterpret_cast(data); - unsigned count = size/sizeof(T); - unsigned n; - for(n=0;nnext) ptr->reset(); -} -#endif - - - -void cfg_var::config_read_file(const void * p_src,unsigned p_size) -{ - read_config_helper r(p_src,p_size); - string8_fastalloc name; - DWORD size; - while(r.get_remaining()>4) - { - if (!r.read_string(name)) break; - if (!r.read_dword_le(size)) break; - if (size > r.get_remaining()) break; - - cfg_var * ptr; - for(ptr = list; ptr; ptr=ptr->next) - { - if (!strcmp(ptr->var_name,name)) - { - ptr->set_raw_data(r.get_ptr(),size); - break; - } - } - r.advance(size); - } -} - -void cfg_var::config_write_file(write_config_callback * out) -{ - cfg_var * ptr; - write_config_callback_i temp; - for(ptr = list; ptr; ptr=ptr->next) - { - temp.data.set_size(0); - if (ptr->get_raw_data(&temp)) - { - out->write_string(ptr->var_name); - unsigned size = temp.data.get_size(); - out->write_dword_le(size); - if (size>0) out->write(temp.data.get_ptr(),size); - } - } -} - -void cfg_var::config_on_app_init() -{ - cfg_var_notify::on_app_init(); -} - -void cfg_var_notify::on_app_init() -{ - cfg_var_notify * ptr = list; - while(ptr) - { - if (ptr->my_var) - ptr->my_var->add_notify(ptr); - ptr=ptr->next; - } -} - -void cfg_var::on_change() -{ - cfg_var_notify * ptr = notify_list; - while(ptr) - { - ptr->on_var_change(var_get_name(),this); - ptr = ptr->var_next; - } - -} - -cfg_var_notify * cfg_var_notify::list=0; - -void cfg_var::add_notify(cfg_var_notify * ptr) -{ - ptr->var_next = notify_list; - notify_list = ptr; -} - - -void cfg_var::write_config_callback::write_dword_le(DWORD param) -{ - DWORD temp = byte_order_helper::dword_native_to_le(param); - write(&temp,sizeof(temp)); -} - -void cfg_var::write_config_callback::write_dword_be(DWORD param) -{ - DWORD temp = byte_order_helper::dword_native_to_be(param); - write(&temp,sizeof(temp)); -} - -void cfg_var::write_config_callback::write_string(const char * param) -{ - unsigned len = strlen(param); - write_dword_le(len); - write(param,len); -} - -bool cfg_int::get_raw_data(write_config_callback * out) -{ - out->write_dword_le(val); - return true; -} - -void cfg_int::set_raw_data(const void * data,int size) -{ - if (size==sizeof(long)) - { - val = (long)read_dword_le_fromptr(data); - on_change(); - } -} - - -bool cfg_var::read_config_helper::read(void * out,unsigned bytes) -{ - if (bytes>remaining) return false; - memcpy(out,ptr,bytes); - advance(bytes); - return true; -} - -bool cfg_var::read_config_helper::read_dword_le(DWORD & val) -{ - DWORD temp; - if (!read(&temp,sizeof(temp))) return false; - val = byte_order_helper::dword_le_to_native(temp); - return true; -} -bool cfg_var::read_config_helper::read_dword_be(DWORD & val) -{ - DWORD temp; - if (!read(&temp,sizeof(temp))) return false; - val = byte_order_helper::dword_be_to_native(temp); - return true; -} - -bool cfg_var::read_config_helper::read_string(string_base & out) -{ - DWORD len; - if (!read_dword_le(len)) return false; - if (remainingwrite((const char*)val,strlen(val) * sizeof(char)); - return true; - } - - virtual void set_raw_data(const void * data,int size) - { - val.set_string_n((const char*)data,size/sizeof(char)); - on_change(); - } - -public: - explicit inline cfg_string(const char * name,const char * v) : cfg_var(name), val(v) {} - void operator=(const cfg_string & v) {val=v.get_val();on_change();} - inline operator const char * () const {return val;} - inline const char * operator=(const char* v) {val=v;on_change();return val;} - inline const char * get_val() const {return val;} - inline bool is_empty() {return !val[0];} -}; - -class cfg_guid : public cfg_var -{ - GUID val; - - virtual bool get_raw_data(write_config_callback * out) - { - out->write_guid_le(val); - return true; - } - - virtual void set_raw_data(const void * data,int size) - { - read_config_helper r(data,size); - r.read_guid_le(val); - } -public: - explicit inline cfg_guid(const char * name,GUID v) : cfg_var(name) {val=v;} - explicit inline cfg_guid(const char * name) : cfg_var(name) {memset(&val,0,sizeof(val));} - inline GUID operator=(GUID v) {val = v; on_change(); return v;} - inline GUID get_val() const {return val;} - inline operator GUID() const {return val;} -}; - -template -class cfg_struct_t : public cfg_var -{ -private: - T val; - - - virtual bool get_raw_data(write_config_callback * out) - { - out->write(&val,sizeof(val)); - return true; - } - - virtual void set_raw_data(const void * data,int size) - { - if (size==sizeof(T)) - { - memcpy(&val,data,sizeof(T)); - on_change(); - } - } -public: - explicit inline cfg_struct_t(const char * name,T v) : cfg_var(name) {val=v;} - explicit inline cfg_struct_t(const char * name,int filler) : cfg_var(name) {memset(&val,filler,sizeof(T));} - inline const T& operator=(const cfg_struct_t & v) {val = v.get_val();on_change();return val;} - inline T& get_val() {return val;} - inline const T& get_val() const {return val;} - inline operator T() const {return val;} - inline const T& operator=(const T& v) {val=v;on_change();return val;} -}; - -class cfg_var_notify -{ - friend cfg_var; -private: - cfg_var * my_var; - cfg_var_notify * next; - cfg_var_notify * var_next; - static cfg_var_notify * list; -public: - cfg_var_notify(cfg_var * var) {my_var=var;next=list;list=this;var_next=0;} - //override me - virtual void on_var_change(const char * name,cfg_var * var) {} - - static void on_app_init();//called by cfg_var::config_on_app_init() -}; - -class cfg_var_notify_func : public cfg_var_notify -{ -private: - void (*func)(); -public: - cfg_var_notify_func(cfg_var * var,void (*p_func)() ) : cfg_var_notify(var), func(p_func) {} - virtual void on_var_change(const char * name,cfg_var * var) {func();} -}; - - -#endif diff --git a/tools/vio2sf/src/foobar8/pfc/chainlist.h b/tools/vio2sf/src/foobar8/pfc/chainlist.h deleted file mode 100644 index 006ee5521..000000000 --- a/tools/vio2sf/src/foobar8/pfc/chainlist.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef _PFC_CHAINLIST_H_ -#define _PFC_CHAINLIST_H_ - - -template -class chain_list -{ - class elem - { - public: - T item; - elem * prev, * next; - elem(const T& param,int blah) : item(param) {} - elem(T param) : item(param) {} - elem(int, int, int) {} - }; - - elem * first, * last; - -public: - class enumerator; - -private: - static inline elem * parse_enum(const enumerator & en) {assert(en.ptr);return reinterpret_cast(en.ptr);} - static inline void modify_enum(enumerator & en, elem * ptr) {en.ptr = reinterpret_cast(ptr);} - - void remove(elem * ptr) - { - assert(ptr); - (ptr->prev ? ptr->prev->next : first) = ptr->next; - (ptr->next ? ptr->next->prev : last) = ptr->prev; - delete ptr; - } - - void init_last(elem * ptr) - { - ptr->prev = last; - ptr->next = 0; - last = ptr; - (ptr->prev ? ptr->prev->next : first) = ptr; - } - void init_first(elem * ptr) - { - ptr->next = first; - ptr->prev = 0; - first = ptr; - (ptr->next ? ptr->next->prev : last) = ptr; - } - -public: - inline ~chain_list() {remove_all();} - inline explicit chain_list() {first = 0; last = 0;} - - inline void advance(enumerator & en) const - { - modify_enum(en,parse_enum(en)->next); - } - - inline void reset(enumerator & en) const - { - modify_enum(en,first); - } - - inline T get_item(const enumerator & en) const - { - return parse_enum(en)->item; - } - - inline const T& get_item_ref(const enumerator & en) const - { - return parse_enum(en)->item; - } - - inline T& get_item_var(const enumerator & en) - { - return parse_enum(en)->item; - } - - void remove_all() - { - while(first) {remove(first);} - } - - unsigned get_count() const - { - unsigned val = 0; - elem * ptr = first; - while(ptr) {val++; ptr = ptr->next;} - return val; - } - - inline void add_item_first(T item) - { - init_first(new elem(item)); - } - - inline void add_item_first_ref(const T & item) - { - init_first(new elem(item,0)); - } - - inline void add_item(T item) - { - init_last(new elem(item)); - } - - inline void add_item_ref(const T & item) - { - init_last(new elem(item,0)); - } - - void remove_item(enumerator & en) - { - elem * freeme = parse_enum(en); - advance(en); - remove(freeme); - } - - inline T& add_item_noinit() - { - elem * ptr = new elem(0,0,0); - init_last(ptr); - return ptr->item; - } - - inline T& add_item_first_noinit() - { - elem * ptr = new elem(0,0,0); - init_first(ptr); - return ptr->item; - } - - class enumerator - { - const chain_list & list; - void * ptr; - friend class chain_list; - public: - explicit enumerator(const chain_list & p_list) : list(p_list), ptr(0) {reset();} - - inline void reset() {list.reset(*this);} - inline void advance() {list.advance(*this);} - - inline T get_item() const {return list.get_item(*this);} - inline const T& get_item_ref() const {return list.get_item(*this);} - - inline T first() {reset();return get_item();} - inline const T& first_ref() {reset();return get_item_ref();} - - inline T next() {advance();return get_item();} - inline const T& next_ref() {advance();return get_item_ref();} - - inline operator bool() const {return !!ptr;} - - }; - -}; - - -#endif _PFC_CHAINLIST_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/critsec.h b/tools/vio2sf/src/foobar8/pfc/critsec.h deleted file mode 100644 index f3ebb91f6..000000000 --- a/tools/vio2sf/src/foobar8/pfc/critsec.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _PFC_CRITSEC_H_ -#define _PFC_CRITSEC_H_ - -#error MOVED TO UTF8API.H - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/foobar2000.h b/tools/vio2sf/src/foobar8/pfc/foobar2000.h deleted file mode 100644 index f19f43488..000000000 --- a/tools/vio2sf/src/foobar8/pfc/foobar2000.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "../pfc/pfc.h" - diff --git a/tools/vio2sf/src/foobar8/pfc/guid.cpp b/tools/vio2sf/src/foobar8/pfc/guid.cpp deleted file mode 100644 index 58527b711..000000000 --- a/tools/vio2sf/src/foobar8/pfc/guid.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "pfc.h" - - -/* -6B29FC40-CA47-1067-B31D-00DD010662DA -. -typedef struct _GUID { // size is 16 - DWORD Data1; - WORD Data2; - WORD Data3; - BYTE Data4[8]; -} GUID; - -// {B296CF59-4D51-466f-8E0B-E57D3F91D908} -static const GUID <> = -{ 0xb296cf59, 0x4d51, 0x466f, { 0x8e, 0xb, 0xe5, 0x7d, 0x3f, 0x91, 0xd9, 0x8 } }; - -*/ - -unsigned GUID_from_text::read_hex(char c) -{ - if (c>='0' && c<='9') return (unsigned)c - '0'; - else if (c>='a' && c<='f') return 0xa + (unsigned)c - 'a'; - else if (c>='A' && c<='F') return 0xa + (unsigned)c - 'A'; - else return 0; -} - -unsigned GUID_from_text::read_byte(const char * ptr) -{ - return (read_hex(ptr[0])<<4) | read_hex(ptr[1]); -} -unsigned GUID_from_text::read_word(const char * ptr) -{ - return (read_byte(ptr)<<8) | read_byte(ptr+2); -} - -unsigned GUID_from_text::read_dword(const char * ptr) -{ - return (read_word(ptr)<<16) | read_word(ptr+4); -} - -void GUID_from_text::read_bytes(BYTE * out,unsigned num,const char * ptr) -{ - for(;num;num--) - { - *out = read_byte(ptr); - out++;ptr+=2; - } -} - - -GUID_from_text::GUID_from_text(const char * text) -{ - if (*text=='{') text++; - const char * max; - - { - const char * t = strchr(text,'}'); - if (t) max = t; - else max = text + strlen(text); - } - - (GUID)*this = mem_ops::make_null_item(); - - - do { - if (text+8>max) break; - Data1 = read_dword(text); - text += 8; - while(*text=='-') text++; - if (text+4>max) break; - Data2 = read_word(text); - text += 4; - while(*text=='-') text++; - if (text+4>max) break; - Data3 = read_word(text); - text += 4; - while(*text=='-') text++; - if (text+4>max) break; - read_bytes(Data4,2,text); - text += 4; - while(*text=='-') text++; - if (text+12>max) break; - read_bytes(Data4+2,6,text); - } while(false); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/guid.h b/tools/vio2sf/src/foobar8/pfc/guid.h deleted file mode 100644 index 6b176902a..000000000 --- a/tools/vio2sf/src/foobar8/pfc/guid.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _PFC_GUID_H_ -#define _PFC_GUID_H_ - - -class GUID_from_text : public GUID -{ - unsigned read_hex(char c); - unsigned read_byte(const char * ptr); - unsigned read_word(const char * ptr); - unsigned read_dword(const char * ptr); - void read_bytes(unsigned char * out,unsigned num,const char * ptr); - -public: - GUID_from_text(const char * text); -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/list.h b/tools/vio2sf/src/foobar8/pfc/list.h deleted file mode 100644 index c6005ba5d..000000000 --- a/tools/vio2sf/src/foobar8/pfc/list.h +++ /dev/null @@ -1,306 +0,0 @@ -#ifndef _PFC_LIST_H_ -#define _PFC_LIST_H_ - -template -class mem_block_list_t -{ -private: - mem_block_t buffer; -public: - mem_block_list_t() {buffer.set_mem_logic(mem_block::ALLOC_FAST);} - inline void set_mem_logic(mem_block::mem_logic_t v) {buffer.set_mem_logic(v);} - - unsigned add_items_repeat(T item,unsigned count)//returns first index - { - int idx = buffer.get_size(); - buffer.set_size(idx+count); - unsigned n; - for(n=0;nidx;n--) - buffer[n]=buffer[n-1]; - buffer[idx]=item; - } - - void insert_item_ref(const T & item,unsigned idx) - { - unsigned max = buffer.get_size() + 1; - buffer.set_size(max); - unsigned n; - for(n=max-1;n>idx;n--) - buffer[n]=buffer[n-1]; - buffer[idx]=item; - } - - T remove_by_idx(unsigned idx) - { - T ret = buffer[idx]; - int n; - int max = buffer.get_size(); - for(n=idx+1;n=0); - assert(n=0); - assert(n=0); - assert(n=count) add_items_fromptr(source,num); - else - { - buffer.set_size(count+num); - int n; - for(n=count-1;n>=idx;n--) - { - buffer[n+num]=buffer[n]; - } - for(n=0;n & source) - { - add_items_fromptr(source.buffer,source.get_count()); - } - - void add_items_fromptr(const T* source,unsigned num) - { - unsigned count = get_count(); - buffer.set_size(count+num); - unsigned n; - for(n=0;n & out,const bit_array & mask) - { - unsigned n,count = get_count(); - for_each_bit_array(n,mask,true,0,count) - out.add_item(buffer[n]); - } - - void filter_mask(const bit_array & mask) - { - unsigned n,count = get_count(), total = 0; - - n = total = mask.find(false,0,count); - - if (n=0); - assert(idx0) max = ptr; - else - { - if (index) *index = ptr; - return 1; - } - } - if (index) *index = min; - return 0; - } - - bool bsearch_ref(int (__cdecl *compare )(T const& elem1, T const& elem2 ),T const& item,int * index) const - { - int max = get_count(); - int min = 0; - int ptr; - while(min0) max = ptr; - else - { - if (index) *index = ptr; - return 1; - } - } - if (index) *index = min; - return 0; - } - - - bool bsearch_range(int (__cdecl *compare )(T elem1, T elem2 ),T item,int * index,int * count) const - { - int max = get_count(); - int min = 0; - int ptr; - while(min0) max = ptr; - else - { - int num = 1; - while(ptr>0 && !compare(buffer[ptr-1],item)) {ptr--;num++;} - while(ptr+num0) max = ptr; - else - { - if (index) *index = ptr; - return 1; - } - } - if (index) *index = min; - return 0; - } - - - - - inline void apply_order(const int * order,unsigned count) - { - assert(count==get_count()); - buffer.apply_order(order,count); - } - - void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));} - - void remove_mask(const bool * mask) {remove_mask(bit_array_table(mask,get_count()));} - void filter_mask(const bool * mask) {filter_mask(bit_array_table(mask,get_count()));} - - unsigned add_item_ref(const T& item) - { - unsigned idx = get_count(); - insert_item_ref(item,idx); - return idx; - } - - unsigned add_item(T item)//returns index - { - unsigned idx = get_count(); - insert_item(item,idx); - return idx; - } - - void remove_all() {remove_mask(bit_array_true());} - - void remove_item(T item) - { - unsigned n,max = get_count(); - mem_block_t mask(max); - for(n=0;n=0;} - - inline void swap(unsigned idx1,unsigned idx2) - { - replace_item(idx1,replace_item(idx2,get_item(idx1))); - } - -}; - -#define mem_block_list mem_block_list_t //for compatibility - -#endif //_PFC_LIST_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/mem_block.cpp b/tools/vio2sf/src/foobar8/pfc/mem_block.cpp deleted file mode 100644 index d9d203888..000000000 --- a/tools/vio2sf/src/foobar8/pfc/mem_block.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "pfc.h" - -#define HAVE_ALLOC_FAST - - -void * mem_block::set_size(UINT new_used) -{ - if (new_used==0) - { -#ifdef HAVE_ALLOC_FAST - if (mem_logic != ALLOC_FAST_DONTGODOWN) -#endif - { - if (data!=0) {free(data);data=0;} - size = 0; - } - } - else - { - UINT new_size; -#ifdef HAVE_ALLOC_FAST - if (mem_logic == ALLOC_FAST || mem_logic == ALLOC_FAST_DONTGODOWN) - { - new_size = size; - if (new_size < 1) new_size = 1; - while(new_size < new_used) new_size <<= 1; - if (mem_logic!=ALLOC_FAST_DONTGODOWN) while(new_size>>1 > new_used) new_size >>= 1; - } - else -#endif - { - new_size = new_used; - } - - if (new_size!=size) - { - if (data==0) - { - data = malloc(new_size); - } - else - { - void * new_data; - new_data = realloc(data,new_size); - if (new_data==0) free(data); - data = new_data; - - } - size = new_size; - } - } - used = new_used; - return data; -} - -void mem_block::prealloc(UINT num) -{ -#ifdef HAVE_ALLOC_FAST - if (size done_block; - unsigned char * done = done_size > PFC_ALLOCA_LIMIT ? done_block.set_size(done_size) : (unsigned char*)alloca(done_size); - memset(done,0,done_size); - unsigned n; - for(n=0;nn); - assert(n -class mem_ops -{ -public: - static void copy(T* dst,const T* src,unsigned count) {memcpy(dst,src,count*sizeof(T));} - static void move(T* dst,const T* src,unsigned count) {memmove(dst,src,count*sizeof(T));} - static void set(T* dst,int val,unsigned count) {memset(dst,val,count*sizeof(T));} - static void setval(T* dst,T val,unsigned count) {for(;count;count--) *(dst++)=val;} - static T* alloc(unsigned count) {return reinterpret_cast(malloc(count * sizeof(T)));} - static T* alloc_zeromem(unsigned count) - { - T* ptr = alloc(count); - if (ptr) set(ptr,0,count); - return ptr; - } - static T* realloc(T* ptr,unsigned count) - {return ptr ? reinterpret_cast(::realloc(reinterpret_cast(ptr),count * sizeof(T))) : alloc(count);} - - static void free(T* ptr) {::free(reinterpret_cast(ptr)); } - inline static T make_null_item() - { - char item[sizeof(T)]; - memset(&item,0,sizeof(T)); - return * reinterpret_cast(&item); - } - inline static void swap(T& item1,T& item2) {T temp; temp=item1; item1=item2; item2=temp;} -}; - -class mem_block -{ -public: - enum mem_logic_t {ALLOC_DEFAULT,ALLOC_FAST,ALLOC_FAST_DONTGODOWN}; -private: - void * data; - unsigned size,used; - mem_logic_t mem_logic; -public: - inline void set_mem_logic(mem_logic_t v) {mem_logic=v;} - inline mem_logic_t get_mem_logic() const {return mem_logic;} - - void prealloc(unsigned size); - - inline mem_block() {data=0;size=0;used=0;mem_logic=ALLOC_DEFAULT;} - inline ~mem_block() {if (data) free(data);} - - inline unsigned get_size() const {return used;} - - inline const void * get_ptr() const {return data;} - inline void * get_ptr() {return data;} - - void * set_size(unsigned new_used); - - inline void * check_size(unsigned new_size) - { - if (used -class mem_block_t //: public mem_block -{ - mem_block theBlock;//msvc7 sucks -public: - mem_block_t() {} - mem_block_t(unsigned s) {theBlock.set_size(s*sizeof(T));} - - inline void set_mem_logic(mem_block::mem_logic_t v) {theBlock.set_mem_logic(v);} - inline mem_block::mem_logic_t get_mem_logic() const {return theBlock.get_mem_logic();} - - inline unsigned get_size() const {return theBlock.get_size()/sizeof(T);} - - inline const T* get_ptr() const {return reinterpret_cast(theBlock.get_ptr());} - inline T* get_ptr() {return reinterpret_cast(theBlock.get_ptr());} - - inline T* set_size(unsigned new_size) {return reinterpret_cast(theBlock.set_size(new_size*sizeof(T)));} - - inline T* check_size(unsigned new_size) {return reinterpret_cast(theBlock.check_size(new_size*sizeof(T)));} - - inline operator const T * () const {return get_ptr();} - inline operator T * () {return get_ptr();} - - inline T* copy(const T* ptr,unsigned size,unsigned start=0) {return reinterpret_cast(theBlock.copy(reinterpret_cast(ptr),size*sizeof(T),start*sizeof(T)));} - inline T* append(const T* ptr,unsigned size) {return reinterpret_cast(theBlock.append(reinterpret_cast(ptr),size*sizeof(T)));} - inline void append(T item) {theBlock.append(reinterpret_cast(&item),sizeof(item));} - - inline void swap(unsigned idx1,unsigned idx2) - { - T * ptr = get_ptr(); - mem_ops::swap(ptr[idx1],ptr[idx2]); - } - - T* set_data(const T* src,unsigned count) - { - return reinterpret_cast(theBlock.set_data(reinterpret_cast(src),count*sizeof(T))); - } - - void operator=(const mem_block_t & src) {set_data(src.get_ptr(),src.get_size());} - - unsigned write_circular(unsigned offset,const T* src,unsigned count) - {//returns new offset - unsigned total = get_size(); - if ((int)offset<0) - { - offset = total - ( (-(int)offset)%total ); - } - else offset%=total; - - if (count>total) - { - src += count - total; - count = total; - } - - while(count>0) - { - unsigned delta = count; - if (delta > total - offset) delta = total - offset; - unsigned n; - for(n=0;n0) - { - unsigned delta = count; - if (delta > total - offset) delta = total - offset; - unsigned n; - for(n=0;n -class mem_block_fastalloc : public mem_block_t -{ -public: - mem_block_fastalloc(unsigned initsize=0) {set_mem_logic(mem_block::ALLOC_FAST_DONTGODOWN);if (initsize) prealloc(initsize);} -}; - -#if 0 - -#define mem_block_aligned_t mem_block_t - -#else - -template -class mem_block_aligned_t -{ - mem_block data; - T * ptr_aligned; -public: - mem_block_aligned_t() {ptr_aligned = 0;} - mem_block_aligned_t(unsigned size) {ptr_aligned = 0;set_size(size);} - - unsigned get_size() const {return data.get_size()/sizeof(T);} - - inline void set_mem_logic(mem_block::mem_logic_t v) {data.set_mem_logic(v);} - inline mem_block::mem_logic_t get_mem_logic() const {return data.get_mem_logic();} - - T * set_size(unsigned size) - { - unsigned size_old = get_size(); - int delta_old = (unsigned)ptr_aligned - (unsigned)data.get_ptr(); - unsigned ptr = (unsigned)data.set_size( (size+1) * sizeof(T) - 1), old_ptr = ptr; - ptr += sizeof(T) - 1; - ptr -= ptr % sizeof(T); - int delta_new = ptr - old_ptr; - if (delta_new != delta_old) - { - unsigned to_move = size_old > size ? size : size_old; - memmove((char*)ptr,(char*)ptr - (delta_new-delta_old),to_move * sizeof(T)); - } - ptr_aligned = (T*)ptr; - return ptr_aligned; - } - - T* check_size(unsigned size) - { - return size > get_size() ? set_size(size) : get_ptr(); - } - - void fill(T val) - { - unsigned n = get_size(); - T * dst = get_ptr(); - for(;n;n--) *(dst++) = val; - } - - inline void zeromemory() {data.zeromemory();} - inline const T * get_ptr() const {return ptr_aligned;} - inline T * get_ptr() {return ptr_aligned;} - inline operator const T * () const {return get_ptr();} - inline operator T * () {return get_ptr();} -}; -#endif - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/mem_block_mgr.h b/tools/vio2sf/src/foobar8/pfc/mem_block_mgr.h deleted file mode 100644 index daaead013..000000000 --- a/tools/vio2sf/src/foobar8/pfc/mem_block_mgr.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _MEM_BLOCK_MGR_H_ -#define _MEM_BLOCK_MGR_H_ - -#error DEPRECATED - - -template -class mem_block_manager -{ - struct entry - { - mem_block_t block; - bool used; - }; - ptr_list_t list; -public: - T * copy(const T* ptr,int size) - { - int n; - int found_size = -1,found_index = -1; - for(n=0;nused) - { - int block_size = list[n]->block.get_size(); - if (found_size<0) - { - found_index=n; found_size = block_size; - } - else if (found_sizefound_size) - { - found_index=n; found_size = block_size; - } - } - else if (found_size>size) - { - if (block_size>=size && block_size=0) - { - list[found_index]->used = true; - return list[found_index]->block.copy(ptr,size); - } - entry * new_entry = new entry; - new_entry->used = true; - list.add_item(new_entry); - return new_entry->block.copy(ptr,size); - } - - void mark_as_free() - { - int n; - for(n=0;nused = false; - } - } - - ~mem_block_manager() {list.delete_all();} -}; - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/other.cpp b/tools/vio2sf/src/foobar8/pfc/other.cpp deleted file mode 100644 index 76f94cd53..000000000 --- a/tools/vio2sf/src/foobar8/pfc/other.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "pfc.h" - -void order_helper::g_swap(int * data,unsigned ptr1,unsigned ptr2) -{ - int temp = data[ptr1]; - data[ptr1] = data[ptr2]; - data[ptr2] = temp; -} - - -int order_helper::g_find_reverse(const int * order,int val) -{ - int prev = val, next = order[val]; - while(next != val) - { - prev = next; - next = order[next]; - } - return prev; -} - - -void order_helper::g_reverse(int * order,unsigned base,unsigned count) -{ - unsigned max = count>>1; - unsigned n; - unsigned base2 = base+count-1; - for(n=0;n -class vartoggle_t -{ - T oldval; - T & var; -public: - vartoggle_t(T & p_var,T val) : var(p_var) - { - oldval = var; - var = val; - } - ~vartoggle_t() {var = oldval;} -}; - -typedef vartoggle_t booltoggle; - -class order_helper -{ - mem_block_t data; -public: - explicit order_helper(unsigned size) : data(size) - { - unsigned n; - for(n=0;n -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=pfc - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pfc.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pfc.mak" CFG="pfc - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pfc - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "pfc - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "pfc - Win32 Release ANSI" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pfc - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_unicode" -# PROP Intermediate_Dir "Release_unicode" -# PROP Target_Dir "" -F90=df.exe -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MD /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "pfc" /D "UNICODE" /D "_UNICODE" /Yu"pfc.h" /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "pfc - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_unicode" -# PROP Intermediate_Dir "Debug_unicode" -# PROP Target_Dir "" -F90=df.exe -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "pfc" /D "UNICODE" /D "_UNICODE" /Yu"pfc.h" /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "pfc - Win32 Release ANSI" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pfc___Win32_Release_ANSI0" -# PROP BASE Intermediate_Dir "pfc___Win32_Release_ANSI0" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_ANSI" -# PROP Intermediate_Dir "Release_ANSI" -# PROP Target_Dir "" -F90=df.exe -MTL=midl.exe -# ADD BASE CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "pfc" /D "UNICODE" /D "_UNICODE" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "pfc" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "pfc - Win32 Release" -# Name "pfc - Win32 Debug" -# Name "pfc - Win32 Release ANSI" -# Begin Source File - -SOURCE=.\array.h -# End Source File -# Begin Source File - -SOURCE=.\bit_array.h -# End Source File -# Begin Source File - -SOURCE=.\byte_order_helper.cpp -# End Source File -# Begin Source File - -SOURCE=.\byte_order_helper.h -# End Source File -# Begin Source File - -SOURCE=.\cfg_memblock.h -# End Source File -# Begin Source File - -SOURCE=.\cfg_var.cpp -# End Source File -# Begin Source File - -SOURCE=.\cfg_var.h -# End Source File -# Begin Source File - -SOURCE=.\chainlist.h -# End Source File -# Begin Source File - -SOURCE=.\critsec.h -# End Source File -# Begin Source File - -SOURCE=.\guid.cpp -# End Source File -# Begin Source File - -SOURCE=.\guid.h -# End Source File -# Begin Source File - -SOURCE=.\list.h -# End Source File -# Begin Source File - -SOURCE=.\mem_block.cpp -# End Source File -# Begin Source File - -SOURCE=.\mem_block.h -# End Source File -# Begin Source File - -SOURCE=.\other.cpp -# End Source File -# Begin Source File - -SOURCE=.\other.h -# End Source File -# Begin Source File - -SOURCE=.\pfc.h -# End Source File -# Begin Source File - -SOURCE=.\profiler.cpp -# End Source File -# Begin Source File - -SOURCE=.\profiler.h -# End Source File -# Begin Source File - -SOURCE=.\ptr_list.h -# End Source File -# Begin Source File - -SOURCE=.\stdafx.cpp - -!IF "$(CFG)" == "pfc - Win32 Release" - -# ADD CPP /Yc"pfc.h" - -!ELSEIF "$(CFG)" == "pfc - Win32 Debug" - -# ADD CPP /Yc - -!ELSEIF "$(CFG)" == "pfc - Win32 Release ANSI" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\string.cpp -# End Source File -# Begin Source File - -SOURCE=.\string.h -# End Source File -# Begin Source File - -SOURCE=.\utf8.cpp -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/src/foobar8/pfc/pfc.h b/tools/vio2sf/src/foobar8/pfc/pfc.h deleted file mode 100644 index ece76cb95..000000000 --- a/tools/vio2sf/src/foobar8/pfc/pfc.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef ___PFC_H___ -#define ___PFC_H___ - -#ifdef WIN32 -#ifndef STRICT -#define STRICT -#endif -#include -#endif - -#ifndef _MSC_VER -typedef long long __int64; -#endif - -#ifndef QWORD -typedef unsigned __int64 QWORD; -#endif - -#ifndef DWORD -typedef unsigned long DWORD; -#endif - -#ifndef WORD -typedef unsigned short WORD; -#endif - -#ifndef BYTE -typedef unsigned char BYTE; -#endif - -#define PFC_ALLOCA_LIMIT (4096) - -#define INDEX_INVALID ((unsigned)(-1)) - -#include - -#include -#include - -#include - -#include -#include - -#ifdef _MSC_VER - -#define NOVTABLE _declspec(novtable) - -#ifdef _DEBUG -#define ASSUME(X) assert(X) -#else -#define ASSUME(X) __assume(X) -#endif - -#else - -#define NOVTABLE - -#define ASSUME(X) assert(X) - -#endif - - -#define tabsize(x) (sizeof(x)/sizeof(*x)) - -#include "bit_array.h" -//#include "critsec.h" -#include "mem_block.h" -#include "list.h" -#include "ptr_list.h" -#include "string.h" -#include "profiler.h" -#include "cfg_var.h" -#include "cfg_memblock.h" -#include "guid.h" -#include "byte_order_helper.h" -#include "other.h" -#include "chainlist.h" -#include "array.h" -#endif //___PFC_H___ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/pfc.vcproj b/tools/vio2sf/src/foobar8/pfc/pfc.vcproj deleted file mode 100644 index 9df78ff5f..000000000 --- a/tools/vio2sf/src/foobar8/pfc/pfc.vcproj +++ /dev/null @@ -1,415 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/vio2sf/src/foobar8/pfc/profiler.cpp b/tools/vio2sf/src/foobar8/pfc/profiler.cpp deleted file mode 100644 index ba9effce3..000000000 --- a/tools/vio2sf/src/foobar8/pfc/profiler.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "pfc.h" - - -__declspec(naked) __int64 profiler_local::get_timestamp() -{ - __asm - { - rdtsc - ret - } -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/profiler.h b/tools/vio2sf/src/foobar8/pfc/profiler.h deleted file mode 100644 index ab4414147..000000000 --- a/tools/vio2sf/src/foobar8/pfc/profiler.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _PFC_PROFILER_H_ -#define _PFC_PROFILER_H_ - -class profiler_static -{ -private: - const char * name; - __int64 total_time,num_called; - -public: - profiler_static(const char * p_name) - { - name = p_name; - total_time = 0; - num_called = 0; - } - ~profiler_static() - { - char blah[256]; - char total_time_text[128]; - char num_text[128]; - _i64toa(total_time,total_time_text,10); - _i64toa(num_called,num_text,10); - sprintf(blah,"profiler: %s - %s cycles (executed %s times)\n",name,total_time_text,num_text); - OutputDebugStringA(blah); - } - void add_time(__int64 delta) {total_time+=delta;num_called++;} -}; - -class profiler_local -{ -private: - static __int64 get_timestamp(); - __int64 start; - profiler_static * owner; -public: - profiler_local(profiler_static * p_owner) - { - owner = p_owner; - start = get_timestamp(); - } - ~profiler_local() - { - __int64 end = get_timestamp(); - owner->add_time(end-start); - } - -}; - -#define profiler(name) \ - static profiler_static profiler_static_##name(#name); \ - profiler_local profiler_local_##name(&profiler_static_##name); - - - - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/ptr_list.cpp b/tools/vio2sf/src/foobar8/pfc/ptr_list.cpp deleted file mode 100644 index c91ec989a..000000000 --- a/tools/vio2sf/src/foobar8/pfc/ptr_list.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "pfc.h" - -#error verboten diff --git a/tools/vio2sf/src/foobar8/pfc/ptr_list.h b/tools/vio2sf/src/foobar8/pfc/ptr_list.h deleted file mode 100644 index 2e58aaf80..000000000 --- a/tools/vio2sf/src/foobar8/pfc/ptr_list.h +++ /dev/null @@ -1,201 +0,0 @@ -#ifndef __PFC_PTR_LIST_H_ -#define __PFC_PTR_LIST_H_ - -class NOVTABLE ptr_list_root//base interface (avoids bloating code with templated vtables) -{ -protected: - virtual unsigned _ptr_list_get_count() const = 0; - virtual void* _ptr_list_get_item(unsigned n) const = 0; - virtual void* _ptr_list_remove_by_idx(unsigned idx) = 0; - virtual void _ptr_list_filter_mask(const bit_array & mask) = 0; - virtual void _ptr_list_insert_item(void* item,unsigned idx) = 0; -}; - -template -class NOVTABLE ptr_list_interface : public ptr_list_root//cross-dll safe interface, use this for passing data around between components; you can typecast ptr_list_t to it -{ -public: - inline unsigned get_count() const {return _ptr_list_get_count();} - inline T* get_item(unsigned idx) const {return reinterpret_cast(_ptr_list_get_item(idx));} - inline T* remove_by_idx(unsigned idx) {return reinterpret_cast(_ptr_list_remove_by_idx(idx));} - inline void filter_mask(const bit_array & mask) {_ptr_list_filter_mask(mask);} - inline void insert_item(T* item,unsigned idx) {_ptr_list_insert_item(const_cast(reinterpret_cast(item)),idx);} - - inline unsigned add_item(T* item) {unsigned idx = get_count();insert_item(item,idx);return idx;} - inline void remove_mask(const bit_array & mask) {filter_mask(bit_array_not(mask));} - inline void remove_all() {filter_mask(bit_array_false());} - - inline T* operator[](unsigned n) const {return get_item(n);} -}; - -#define ptr_list_base ptr_list_interface - -#define void_cast(blah) const_cast(reinterpret_cast(blah)) - -class ptr_list : public mem_block_list, virtual public ptr_list_root -{ -private: - virtual unsigned _ptr_list_get_count() const {return get_count();} - virtual void* _ptr_list_get_item(unsigned idx) const {return void_cast(get_item(idx));} - virtual void* _ptr_list_remove_by_idx(unsigned idx) {return void_cast(remove_by_idx(idx));} - virtual void _ptr_list_filter_mask(const bit_array & mask) {filter_mask(mask);} - virtual void _ptr_list_insert_item(void* item,unsigned idx) {insert_item(item,idx);} -public: - using mem_block_list::get_count; - using mem_block_list::get_item; - using mem_block_list::remove_by_idx; - using mem_block_list::filter_mask; - using mem_block_list::insert_item; - using mem_block_list::apply_order; - - void * operator[](unsigned n) const {return get_item(n);} - - void free_by_idx(unsigned n) - { - void * ptr = remove_by_idx(n); - assert(ptr); - free(ptr); - } - void free_all() - { - unsigned n,max=get_count(); - for(n=0;n -class ptr_list_t : public ptr_list -{ -public: - using ptr_list::get_count; - inline T* get_item(unsigned idx) const {return reinterpret_cast(ptr_list::get_item(idx));} - inline T* remove_by_idx(unsigned idx) {return reinterpret_cast(ptr_list::remove_by_idx(idx));} - using ptr_list::filter_mask; - inline void insert_item(T* item,unsigned idx) {ptr_list::insert_item(void_cast(item),idx);} - - inline unsigned add_item(T* item) {return ptr_list::add_item(void_cast(item));} - - void sort(int (__cdecl *compare )(const T * &elem1, const T* &elem2 ) ) - { - ptr_list::sort(reinterpret_cast< int (__cdecl *)(void* const*, void* const*) >(compare)); - } - - void add_items_copy(const ptr_list_t & source) - { - unsigned n; - for(n=0;n(ptr_list::replace_item(idx,void_cast(item)));} - - inline void delete_item(T* ptr) {remove_item(ptr);delete ptr;} - - inline void delete_by_idx(unsigned idx) - { - T* ptr = remove_by_idx(idx); - assert(ptr); - delete ptr; - } - - void delete_all() - { - unsigned n,max=get_count(); - for(n=0;n & source) - { - add_items_fromptr(source.get_ptr(),source.get_count()); - } - - inline void add_items_fromptr(T*const* source,unsigned num) {ptr_list::add_items_fromptr((void*const*)source,num);} - - inline T* const * get_ptr() const {return (T*const*)ptr_list::get_ptr();} - - inline void remove_item(T * item) {ptr_list::remove_item(void_cast(item));} - inline int find_item(T* item) const {return ptr_list::find_item(void_cast(item));} - inline bool have_item(T* item) const {return ptr_list::have_item(void_cast(item));} - - inline T* operator[](unsigned n) const {return get_item(n);} - - inline ptr_list_interface & get_interface() {return * static_cast * > (&ptr_list::get_interface());} - inline const ptr_list_interface & get_interface_const() const {return * static_cast * > (&ptr_list::get_interface_const());} - - inline operator ptr_list_interface & () {return get_interface();} - inline operator const ptr_list_interface & () const {return get_interface_const();} - - using ptr_list::apply_order; -}; - -#define ptr_list_simple ptr_list_t - -template -class ptr_list_autodel_t : public ptr_list_t -{ -public: - ~ptr_list_autodel_t() {delete_all();} -}; - - -template -class ptr_list_autofree_t : public ptr_list_t -{ -public: - ~ptr_list_autofree_t() {free_all();} -}; - -#endif //__PFC_PTR_LIST_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/stdafx.cpp b/tools/vio2sf/src/foobar8/pfc/stdafx.cpp deleted file mode 100644 index 72044fc8b..000000000 --- a/tools/vio2sf/src/foobar8/pfc/stdafx.cpp +++ /dev/null @@ -1,2 +0,0 @@ -//cpp used to generate precompiled header -#include "pfc.h" \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/string.cpp b/tools/vio2sf/src/foobar8/pfc/string.cpp deleted file mode 100644 index b2f905866..000000000 --- a/tools/vio2sf/src/foobar8/pfc/string.cpp +++ /dev/null @@ -1,615 +0,0 @@ -#include "pfc.h" - -#ifdef WIN32 -#define STRICT -#include -#include -#endif - - -void string_base::add_char(unsigned c) -{ - char temp[8]; - unsigned len = utf8_encode_char(c,temp); - if (len>0) add_string(temp,len); -} - -void string_base::skip_trailing_char(unsigned skip) -{ - const char * str = get_ptr(); - unsigned ptr,trunc; - bool need_trunc = false; - for(ptr=0;str[ptr];) - { - unsigned c; - unsigned delta = utf8_decode_char(str+ptr,&c); - if (delta==0) break; - if (c==skip) - { - need_trunc = true; - trunc = ptr; - } - else - { - need_trunc = false; - } - ptr += delta; - } - if (need_trunc) truncate(trunc); -} - -string_print_time::string_print_time(__int64 length) -{ - if (length<0) length=0; - char * out = buffer; - int weeks,days,hours,minutes,seconds; - - weeks = (int)( ( length / (60*60*24*7) ) ); - days = (int)( ( length / (60*60*24) ) % 7 ); - hours = (int) ( ( length / (60 * 60) ) % 24); - minutes = (int) ( ( length / (60 ) ) % 60 ); - seconds = (int) ( ( length ) % 60 ); - - if (weeks) - { - out += sprintf(out,"%uwk ",weeks); - } - if (days || weeks) - { - out += sprintf(out,"%ud ",days); - } - if (hours || days || weeks) - { - out += sprintf(out,"%u:%02u:%02u",hours,minutes,seconds); - } - else out += sprintf(out,"%u:%02u",minutes,seconds); -} - -int strcmp_partial(const char * s1,const char * s2) -{ - while(*s2) - { - if (*s1<*s2) return -1; - else if (*s1>*s2) return 1; - s1++; - s2++; - } - return 0; -} - -void string_base::add_float(double val,unsigned digits) -{ - char temp[64]; - _gcvt(val,digits,temp); - add_string(temp); -} - -void string_base::add_int(signed __int64 val,unsigned base) -{ - char temp[64]; - _i64toa(val,temp,base); - add_string(temp); -} - -void string_base::add_uint(unsigned __int64 val,unsigned base) -{ - char temp[64]; - _ui64toa(val,temp,base); - add_string(temp); -} - -bool is_path_separator(unsigned c) -{ - return c=='\\' || c=='/' || c=='|' || c==':'; -} - -bool is_path_bad_char(unsigned c) -{ -#ifdef WIN32 - return c=='\\' || c=='/' || c=='|' || c==':' || c=='*' || c=='?' || c=='\"' || c=='>' || c=='<'; -#else -#error portme -#endif -} - - -void string_printf::g_run(string_base & out,const char * fmt,va_list list) -{ - out.reset(); - while(*fmt) - { - if (*fmt=='%') - { - fmt++; - if (*fmt=='%') - { - out.add_char('%'); - fmt++; - } - else - { - bool force_sign = false; - if (*fmt=='+') - { - force_sign = true; - fmt++; - } - char padchar = (*fmt == '0') ? '0' : ' '; - int pad = 0; - while(*fmt>='0' && *fmt<='9') - { - pad = pad * 10 + (*fmt - '0'); - fmt++; - } - - if (*fmt=='s' || *fmt=='S') - { - const char * ptr = va_arg(list,const char*); - int len = strlen(ptr); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(ptr); - fmt++; - - } - else if (*fmt=='i' || *fmt=='I' || *fmt=='d' || *fmt=='D') - { - char temp[8*sizeof(int)]; - int val = va_arg(list,int); - if (force_sign && val>0) out.add_char('+'); - itoa(val,temp,10); - int len = strlen(temp); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(temp); - fmt++; - } - else if (*fmt=='u' || *fmt=='U') - { - char temp[8*sizeof(int)]; - int val = va_arg(list,int); - if (force_sign && val>0) out.add_char('+'); - _ultoa(val,temp,10); - int len = strlen(temp); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(temp); - fmt++; - } - else if (*fmt=='x' || *fmt=='X') - { - char temp[8*sizeof(int)]; - int val = va_arg(list,int); - if (force_sign && val>0) out.add_char('+'); - _ultoa(val,temp,16); - if (*fmt=='X') - { - char * t = temp; - while(*t) - { - if (*t>='a' && *t<='z') - *t += 'A' - 'a'; - t++; - } - } - int len = strlen(temp); - if (pad>len) out.add_chars(padchar,pad-len); - out.add_string(temp); - fmt++; - } - else if (*fmt=='c' || *fmt=='C') - { - out.add_char(va_arg(list,char)); - fmt++; - } - } - } - else - { - out.add_char(*(fmt++)); - } - } -} - -string_printf::string_printf(const char * fmt,...) -{ - va_list list; - va_start(list,fmt); - run(fmt,list); - va_end(list); -} - - - -unsigned strlen_max(const char * ptr,unsigned max) -{ - if (ptr==0) return 0; - unsigned int n = 0; - while(ptr[n] && n=0;n--) - { - if (data[n]==c) return n; - } - return -1; -} - -int string8::find_first(const char * str,int start) -{ - unsigned n; - if (start<0) start=0; - for(n=start;n=0;n--) - { - if (!strcmp_partial(data.get_ptr()+n,str)) return n; - } - return -1; -} - -unsigned string8::g_scan_filename(const char * ptr) -{ - int n; - int _used = strlen(ptr); - for(n=_used-1;n>=0;n--) - { - if (is_path_separator(ptr[n])) return n+1; - } - return 0; -} - -unsigned string8::scan_filename() -{ - int n; - for(n=used-1;n>=0;n--) - { - if (is_path_separator(data[n])) return n+1; - } - return 0; -} - -void string8::fix_filename_chars(char def,char leave)//replace "bad" characters, leave can be used to keep eg. path separators -{ - unsigned n; - for(n=0;nused) first = used; - if (first+count>used) count = used-first; - if (count>0) - { - unsigned n; - for(n=first+count;n<=used;n++) - data[n-count]=data[n]; - used -= count; - makespace(used+1); - } -} - -//slow -void string8::insert_chars(unsigned first,const char * src, unsigned count) -{ - if (first > used) first = used; - - makespace(used+count+1); - unsigned n; - for(n=used;(int)n>=(int)first;n--) - data[n+count] = data[n]; - for(n=0;nfn) set_string_n(fn,dot-fn); - else set_string(fn); -} - -string_filename_ext::string_filename_ext(const char * fn) -{ - fn += string8::g_scan_filename(fn); - const char * ptr = fn; - while(*ptr && *ptr!='?') ptr++; - set_string_n(fn,ptr-fn); -} - -string_extension::string_extension(const char * src) -{ - buffer[0]=0; - const char * start = src + string8::g_scan_filename(src); - const char * end = start + strlen(start); - const char * ptr = end-1; - while(ptr>start && *ptr!='.') - { - if (*ptr=='?') end=ptr; - ptr--; - } - - if (ptr>=start && *ptr=='.') - { - ptr++; - unsigned len = end-ptr; - if (len='0' && *src<='9') - { - int d = *src - '0'; - val = val * 10 + d; - if (got_dot) div--; - src++; - } - else if (*src=='.' || *src==',') - { - if (got_dot) break; - got_dot = true; - src++; - } - else if (*src=='E' || *src=='e') - { - src++; - div += atoi(src); - break; - } - else break; - } - if (neg) val = -val; - return (double) val * pow(10.0,(double)div); -} - -bool string8::limit_length(unsigned length_in_chars,const char * append) -{ - bool rv = false; - const char * base = get_ptr(), * ptr = base; - while(length_in_chars && utf8_advance(ptr)) length_in_chars--; - if (length_in_chars==0) - { - truncate(ptr-base); - add_string(append); - rv = true; - } - return rv; -} - -void string_base::convert_to_lower_ascii(const char * src,char replace) -{ - reset(); - assert(replace>0); - while(*src) - { - unsigned c; - unsigned delta = utf8_decode_char(src,&c); - if (delta==0) {c = replace; delta = 1;} - else if (c>=0x80) c = replace; - add_byte((char)c); - src += delta; - } -} - -void convert_to_lower_ascii(const char * src,unsigned max,char * out,char replace) -{ - unsigned ptr = 0; - assert(replace>0); - while(src[ptr] && ptr=0x80) c = replace; - *(out++) = (char)c; - ptr += delta; - } - *out = 0; -} - -string_list_nulldelimited::string_list_nulldelimited() -{ - reset(); -} - -void string_list_nulldelimited::add_string(const char * src) -{ - unsigned src_len = strlen(src) + 1; - data.copy(src,src_len,len); - len += src_len; - data.copy("",1,len); -} - -void string_list_nulldelimited::add_string_multi(const char * src) -{ - unsigned src_len = 0; - while(src[src_len]) - { - src_len += strlen(src+src_len) + 1; - } - data.copy(src,src_len,len); - len += src_len; - data.copy("",1,len); -} - - -void string_list_nulldelimited::reset() -{ - len = 0; - data.copy("\0",2,len); -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/string.h b/tools/vio2sf/src/foobar8/pfc/string.h deleted file mode 100644 index c3a1f3131..000000000 --- a/tools/vio2sf/src/foobar8/pfc/string.h +++ /dev/null @@ -1,595 +0,0 @@ -#ifndef _PFC_STRING_H_ -#define _PFC_STRING_H_ - -#ifndef WCHAR -typedef unsigned short WCHAR; -#endif - -bool is_path_separator(unsigned c); -bool is_path_bad_char(unsigned c); -bool is_valid_utf8(const char * param); -bool is_lower_ascii(const char * param); -bool has_path_bad_chars(const char * param); -void recover_invalid_utf8(const char * src,char * out,unsigned replace);//out must be enough to hold strlen(char) + 1, or appropiately bigger if replace needs multiple chars -void convert_to_lower_ascii(const char * src,unsigned max,char * out,char replace = '?');//out should be at least strlen(src)+1 long - -class NOVTABLE string_base //cross-dll safe string for returing strings from api functions etc -{//all char* are UTF-8 unless local comments state otherwise -protected: - string_base() {} - ~string_base() {} -public: - virtual const char * get_ptr() const = 0; - virtual void add_string(const char * ptr,unsigned len=-1)=0;//stops adding new chars if encounters null before len - virtual void set_string(const char * ptr,unsigned len=-1) {reset();add_string(ptr,len);} - virtual void truncate(unsigned len)=0; - virtual unsigned length() const {return strlen(get_ptr());} - - inline operator const char * () const {return get_ptr();} - - - inline void reset() {truncate(0);} - - //for compatibility - inline void add_string_n(const char * ptr,unsigned len) {add_string(ptr,len);} - inline void set_string_n(const char * ptr,unsigned len) {set_string(ptr,len);} - - inline void add_byte(char c) {add_string_n(&c,1);} - inline bool is_empty() const {return *get_ptr()==0;} - - void add_char(unsigned c);//adds unicode char to the string - void skip_trailing_char(unsigned c = ' '); - - inline void add_chars(unsigned c,unsigned count) {for(;count;count--) add_char(c);} - - - void add_int(signed __int64 val,unsigned base = 10); - void add_uint(unsigned __int64 val,unsigned base = 10); - void add_float(double val,unsigned digits); - -/* void add_string_lower(const char * src,unsigned len = -1); - void add_string_upper(const char * src,unsigned len = -1); - inline void set_string_lower(const char * src,unsigned len = -1) {reset();add_string_lower(src,len);} - inline void set_string_upper(const char * src,unsigned len = -1) {reset();add_string_upper(src,len);} - - void to_lower(); - void to_upper(); -*/ - void add_string_ansi(const char * src,unsigned len = -1); //converts from ansi to utf8 - void set_string_ansi(const char * src,unsigned len = -1) {reset();add_string_ansi(src,len);} - void add_string_utf16(const WCHAR * src,unsigned len = -1);//converts from utf16 (widechar) to utf8 - void set_string_utf16(const WCHAR * src,unsigned len = -1) {reset();add_string_utf16(src,len);} - - bool is_valid_utf8() {return ::is_valid_utf8(get_ptr());} - - void convert_to_lower_ascii(const char * src,char replace = '?'); - - - - inline const char * operator = (const char * src) {set_string(src);return get_ptr();} - inline const char * operator += (const char * src) {add_string(src);return get_ptr();} - inline const char * operator = (const string_base & src) {set_string(src);return get_ptr();} -}; - -class string8 : public string_base -{ -protected: - mem_block_t data; - unsigned used; - - inline void makespace(unsigned s) - { - unsigned old_size = data.get_size(); - if (old_size < s) - data.set_size(s+16); - else if (old_size > s + 32) - data.set_size(s); - } - -public: - inline const char * operator = (const char * src) {set_string(src);return get_ptr();} - inline const char * operator += (const char * src) {add_string(src);return get_ptr();} - inline operator const char * () const {return get_ptr();} - inline const char * operator = (const string8 & src) {set_string(src);return get_ptr();} - - string8() {used=0;} - string8(const char * src) {used=0;set_string(src);} - string8(const char * src,unsigned num) {used=0;set_string_n(src,num);} - string8(const string8 & src) {used=0;set_string(src);} - - void set_mem_logic(mem_block::mem_logic_t v) {data.set_mem_logic(v);} - int get_mem_logic() const {return data.get_mem_logic();} - void prealloc(unsigned s) {s++;if (s>used) makespace(s);} - - const char * get_ptr() const - { - return used > 0 ? data.get_ptr() : ""; - } - - virtual void add_string(const char * ptr,unsigned len = -1); - virtual void set_string(const char * ptr,unsigned len = -1); - - virtual void truncate(unsigned len) - { - if (used>len) {used=len;data[len]=0;makespace(used+1);} - } - - virtual unsigned length() const {return used;} - -// ~string8() {} - - void set_char(unsigned offset,char c); - int find_first(char c,int start=0); //return -1 if not found - int find_last(char c,int start = -1); - int find_first(const char * str,int start = 0); - int find_last(const char * str,int start = -1); -// unsigned replace_string(const char * s1,unsigned len1,const char * s2,unsigned len2,bool casesens = true,unsigned start = 0);//len1/len2 can be -1 -// unsigned replace_byte(char c1,char c2,unsigned start = 0); - unsigned replace_char(unsigned c1,unsigned c2,unsigned start = 0); -// inline unsigned replace_byte_from(unsigned start,char c1,char c2) {return replace_byte(c1,c2,start);} -// inline unsigned replace_char_from(unsigned start,unsigned c1,unsigned c2) {return replace_char(c1,c2,start);} - static unsigned g_scan_filename(const char * ptr); - unsigned scan_filename(); - void fix_filename_chars(char def = '_',char leave=0);//replace "bad" characters, leave can be used to keep eg. path separators - void fix_dir_separator(char c); - void _xor(char x);//renamed from "xor" to keep weird compilers happy - void remove_chars(unsigned first,unsigned count); //slow - void insert_chars(unsigned first,const char * src, unsigned count);//slow - void insert_chars(unsigned first,const char * src); - bool truncate_eol(unsigned start = 0); - bool fix_eol(const char * append = " (...)",unsigned start = 0); - bool limit_length(unsigned length_in_chars,const char * append = " (...)"); - - //for string_buffer class - inline char * buffer_get(unsigned n) - { - makespace(n+1); - data.zeromemory(); - return data; - } - - inline void buffer_done() - { - used=strlen(data); - makespace(used+1); - } - - inline void force_reset() {used=0;data.force_reset();} - -}; - -class string8_fastalloc : public string8 -{ -public: - explicit string8_fastalloc(unsigned p_prealloc = 0) {set_mem_logic(mem_block::ALLOC_FAST_DONTGODOWN);if (p_prealloc) prealloc(p_prealloc);} - inline const char * operator=(const char * src) {set_string(src);return get_ptr();} - inline const char * operator+=(const char * src) {add_string(src);return get_ptr();} -}; - -class string_buffer -{ -private: - string8 * owner; - char * data; -public: - explicit string_buffer(string8 & s,unsigned siz) {owner=&s;data=s.buffer_get(siz);} - ~string_buffer() {owner->buffer_done();} - operator char* () {return data;} -}; - -class string_printf : public string8_fastalloc -{ -public: - static void g_run(string_base & out,const char * fmt,va_list list); - inline void run(const char * fmt,va_list list) {g_run(*this,fmt,list);} - - explicit string_printf(const char * fmt,...); -}; - -class string_printf_va : public string8_fastalloc -{ -public: - explicit string_printf_va(const char * fmt,va_list list) {string_printf::g_run(*this,fmt,list);} -}; - - -class string_print_time -{ -protected: - char buffer[128]; -public: - string_print_time(__int64 s); - operator const char * () const {return buffer;} -}; - - -class string_print_time_ex : private string_print_time -{ -public: - string_print_time_ex(double s,unsigned extra = 3) : string_print_time((__int64)s) - { - if (extra>0) - { - unsigned mul = 1, n; - for(n=0;n -class string_convert_base -{ -protected: - T * ptr; - inline void alloc(unsigned size) {ptr = mem_ops::alloc(size);} - inline ~string_convert_base() {mem_ops::free(ptr);} -public: - inline operator const T * () const {return ptr;} - inline const T * get_ptr() const {return ptr;} - - inline unsigned length() - { - unsigned ret = 0; - const T* p = ptr; - while(*p) {ret++;p++;} - return ret; - } -}; - -class string_utf8_from_utf16 : public string_convert_base -{ -public: - explicit string_utf8_from_utf16(const WCHAR * src,unsigned len = -1) - { - len = wcslen_max(src,len); - alloc(estimate_utf16_to_utf8(src,len)); - convert_utf16_to_utf8(src,ptr,len); - } -}; - -class string_utf16_from_utf8 : public string_convert_base -{ -public: - explicit string_utf16_from_utf8(const char * src,unsigned len = -1) - { - len = strlen_max(src,len); - alloc(estimate_utf8_to_utf16(src,len)); - convert_utf8_to_utf16(src,ptr,len); - } -}; - -class string_ansi_from_utf16 : public string_convert_base -{ -public: - explicit string_ansi_from_utf16(const WCHAR * src,unsigned len = -1) - { - len = wcslen_max(src,len); - alloc(estimate_utf16_to_ansi(src,len)); - convert_utf16_to_ansi(src,ptr,len); - } -}; - -class string_utf16_from_ansi : public string_convert_base -{ -public: - explicit string_utf16_from_ansi(const char * src,unsigned len = -1) - { - len = strlen_max(src,len); - alloc(estimate_ansi_to_utf16(src,len)); - convert_ansi_to_utf16(src,ptr,len); - } -}; - -class string_utf8_from_ansi : public string_convert_base -{ -public: - explicit string_utf8_from_ansi(const char * src,unsigned len = -1) - { - len = strlen_max(src,len); - alloc(estimate_ansi_to_utf8(src,len)); - convert_ansi_to_utf8(src,ptr,len); - } -}; - -class string_ansi_from_utf8 : public string_convert_base -{ -public: - explicit string_ansi_from_utf8(const char * src,unsigned len = -1) - { - len = strlen_max(src,len); - alloc(estimate_utf8_to_ansi(src,len)); - convert_utf8_to_ansi(src,ptr,len); - } -}; - -class string_ascii_from_utf8 : public string_convert_base -{ -public: - explicit string_ascii_from_utf8(const char * src,unsigned len = -1) - { - len = strlen_max(src,len); - alloc(len+1); - convert_to_lower_ascii(src,len,ptr,'?'); - } -}; - -#define string_wide_from_utf8 string_utf16_from_utf8 -#define string_utf8_from_wide string_utf8_from_utf16 -#define string_wide_from_ansi string_utf16_from_ansi -#define string_ansi_from_wide string_ansi_from_utf16 - -#ifdef UNICODE -#define string_os_from_utf8 string_wide_from_utf8 -#define string_utf8_from_os string_utf8_from_wide -#define _TX(X) L##X -#define estimate_utf8_to_os estimate_utf8_to_utf16 -#define estimate_os_to_utf8 estimate_utf16_to_utf8 -#define convert_utf8_to_os convert_utf8_to_utf16 -#define convert_os_to_utf8 convert_utf16_to_utf8 -#define add_string_os add_string_utf16 -#define set_string_os set_string_utf16 -#else -#define string_os_from_utf8 string_ansi_from_utf8 -#define string_utf8_from_os string_utf8_from_ansi -#define _TX(X) X -#define estimate_utf8_to_os estimate_utf8_to_ansi -#define estimate_os_to_utf8 estimate_ansi_to_utf8 -#define convert_utf8_to_os convert_utf8_to_ansi -#define convert_os_to_utf8 convert_ansi_to_utf8 -#define add_string_os add_string_ansi -#define set_string_os set_string_ansi -#endif - - -int strcmp_partial(const char * s1,const char * s2); -int skip_utf8_chars(const char * ptr,int count); -char * strdup_n(const char * src,unsigned len); - -unsigned utf8_get_char(const char * src); - -inline bool utf8_advance(const char * & var) -{ - UINT delta = utf8_char_len(var); - var += delta; - return delta>0; -} - -inline bool utf8_advance(char * & var) -{ - UINT delta = utf8_char_len(var); - var += delta; - return delta>0; -} - -inline const char * utf8_char_next(const char * src) {return src + utf8_char_len(src);} -inline char * utf8_char_next(char * src) {return src + utf8_char_len(src);} - - -#define filename_cmp(s1,s2) stricmp_utf8(s1,s2) //deprecated - -template -class string_simple_t//simplified string class, less efficient but smaller; could make it derive from string_base but it wouldn't be so light anymore (vtable) -{ -private: - T * ptr; - - void do_realloc(unsigned size) - { - ptr = mem_ops::realloc(ptr,size); - } - - static unsigned t_strlen(const T* src,unsigned max = -1) - { - unsigned ret; - for(ret=0;src[ret] && ret::alloc(t_strlen(src,max)+1); - if (ret) t_strcpy(ret,src,max); - return ret; - } - - inline static void t_memcpy(T* dst,const T* src,unsigned len) {mem_ops::copy(dst,src,len);} - -public: - inline const T * get_ptr() const {return ptr ? ptr : reinterpret_cast("\0\0\0\0");} - inline operator const T * () const {return get_ptr();} - inline string_simple_t(const T * param) {ptr = t_strdup(param);} - inline string_simple_t(const T * param,unsigned len) {ptr = t_strdup(param,len);} - inline string_simple_t() {ptr=0;} - inline string_simple_t(__int64 val) - { - T temp[64]; - if (sizeof(T)==1) - { - _i64toa(val,reinterpret_cast(&temp),10); - } - else if (sizeof(T)==2) - { - _i64tow(val,reinterpret_cast(&temp),10); - } - else - { - ASSUME(0); - } - ptr = t_strdup(temp); - } - inline ~string_simple_t() {if (ptr) mem_ops::free(ptr);} - inline const T * operator = (const T * param) {set_string(param);return get_ptr();} - inline const T * operator = (const string_simple_t & param) {set_string(param);return get_ptr();} - inline const T * operator += (const T * src) {add_string(src);return get_ptr();} - - inline string_simple(const string_simple_t & param) {ptr = t_strdup(param);} - inline void reset() {if (ptr) {mem_ops::free(ptr);ptr=0;}} - inline bool is_empty() {return !ptr || !*ptr;} - inline unsigned length() {return t_strlen(get_ptr());} - - void add_string(const T * param,unsigned len = -1) - { - len = t_strlen(param,len); - if (len>0) - { - unsigned old_len = length(); - do_realloc(old_len + len + 1); - t_memcpy(ptr+old_len,param,len); - ptr[old_len+len]=0; - } - } - - void set_string(const T * param,unsigned len = -1) - { - len = t_strlen(param,len); - if (len>0) - { - do_realloc(len + 1);//will malloc if old ptr was null - t_memcpy(ptr,param,len); - ptr[len]=0; - } - else reset(); - } - - //for compatibility - inline void set_string_n(const T * param,unsigned len) {set_string(param,len);} - inline void add_string_n(const T * param,unsigned len) {add_string(param,len);} - - void truncate(unsigned len) - { - if (len -#define w_string_simple string_simple_t -#define t_string_simple string_simple_t - -class string_filename : public string_simple -{ -public: - explicit string_filename(const char * fn); -}; - -class string_filename_ext : public string_simple -{ -public: - explicit string_filename_ext(const char * fn); -}; - -class string_extension -{ - char buffer[32]; -public: - inline const char * get_ptr() const {return buffer;} - inline unsigned length() const {return strlen(buffer);} - inline operator const char * () const {return buffer;} - explicit string_extension(const char * src); -}; - -#define string_extension_8 string_extension - -template -class string_buffer_t -{ -private: - string_simple_t & owner; - mem_block_t data; - unsigned size; -public: - string_buffer_t(string_simple_t & p_owner,unsigned p_size) : owner(p_owner), data(p_size+1), size(size) {data.zeromemory();} - operator T* () {return data.get_ptr();} - ~string_buffer_t() {owner.set_string(data,size);} -}; - -#define a_string_buffer string_buffer_t -#define t_string_buffer string_buffer_t -#define w_string_buffer string_buffer_t - -class make_string_n //trick for passing truncated char* to api that takes null-terminated strings, needs to temporarily modify string data -{ - char * ptr, *ptr0, old; -public: - inline explicit make_string_n(char * src,unsigned len) - { - ptr = src; ptr0 = src+len; - old = *ptr0; - *ptr0 = 0; - } - inline ~make_string_n() {*ptr0 = old;} - inline const char * get_ptr() const {return ptr;} - inline operator const char * () const {return ptr;} -}; - -void pfc_float_to_string(char * out,double val,unsigned precision,bool force_sign = false);//doesnt add E+X etc, has internal range limits, useful for storing float numbers as strings without having to bother with international coma/dot settings BS -double pfc_string_to_float(const char * src); - -class string_list_nulldelimited -{ - mem_block_fastalloc data; - unsigned len; -public: - string_list_nulldelimited(); - inline const char * get_ptr() const {return data;} - inline operator const char * () const {return data;} - void add_string(const char *); - void add_string_multi(const char *); - void reset(); -}; - -#endif //_PFC_STRING_H_ \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/pfc/utf8.cpp b/tools/vio2sf/src/foobar8/pfc/utf8.cpp deleted file mode 100644 index 6ffa429f5..000000000 --- a/tools/vio2sf/src/foobar8/pfc/utf8.cpp +++ /dev/null @@ -1,432 +0,0 @@ -#include "pfc.h" - -#include - -//utf8 stuff - -#ifndef BYTE -typedef unsigned char BYTE; -#endif - -#ifndef UINT -typedef unsigned int UINT; -#endif - -static const BYTE mask_tab[6]={0x80,0xE0,0xF0,0xF8,0xFC,0xFE}; - -static const BYTE val_tab[6]={0,0xC0,0xE0,0xF0,0xF8,0xFC}; - -unsigned utf8_decode_char(const char *p_utf8,unsigned * wide,unsigned max) -{ - const BYTE * utf8 = (const BYTE*)p_utf8; - - if (wide) *wide = 0; - - if (max==0) - return 0; - else if (max>6) max = 6; - - if (utf8[0]<0x80) - { - if (wide) *wide = utf8[0]; - return utf8[0]>0 ? 1 : 0; - } - - unsigned res=0; - unsigned n; - unsigned cnt=0; - while(1) - { - if ((*utf8&mask_tab[cnt])==val_tab[cnt]) break; - if (++cnt>=max) return 0; - } - cnt++; - - for(n=0;n>(cnt+1))&*utf8; - - for (n=1;n> (7 - cnt))) - return 0; - - res=(res<<6)|(utf8[n]&0x3F); - } - - if (wide) - *wide=res; - - return cnt; -} - - -unsigned utf8_encode_char(unsigned wide,char * target) -{ - unsigned int count; - - if (wide < 0x80) - count = 1; - else if (wide < 0x800) - count = 2; - else if (wide < 0x10000) - count = 3; - else if (wide < 0x200000) - count = 4; - else if (wide < 0x4000000) - count = 5; - else if (wide <= 0x7FFFFFFF) - count = 6; - else - return 0; - //if (count>max) return 0; - - if (target == 0) - return count; - - switch (count) - { - case 6: - target[5] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x4000000; - case 5: - target[4] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x200000; - case 4: - target[3] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x10000; - case 3: - target[2] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0x800; - case 2: - target[1] = 0x80 | (wide & 0x3F); - wide = wide >> 6; - wide |= 0xC0; - case 1: - target[0] = wide; - } - - return count; -} - -unsigned utf16_encode_char(unsigned cur_wchar,WCHAR * out) -{ - if (cur_wchar>0 && cur_wchar<(1<<20)) - { - if (cur_wchar>=0x10000) - { - unsigned c = cur_wchar - 0x10000; - //MSDN: - //The first (high) surrogate is a 16-bit code value in the range U+D800 to U+DBFF. The second (low) surrogate is a 16-bit code value in the range U+DC00 to U+DFFF. Using surrogates, Unicode can support over one million characters. For more details about surrogates, refer to The Unicode Standard, version 2.0. - out[0] = (WCHAR)(0xD800 | (0x3FF & (c>>10)) ); - out[1] = (WCHAR)(0xDC00 | (0x3FF & c) ) ; - return 2; - } - else - { - *out = (WCHAR)cur_wchar; - return 1; - } - } - return 0; -} - -unsigned utf16_decode_char(const WCHAR * src,unsigned * out) -{ - unsigned rv = 0; - unsigned int cur_wchar = *(src++); - if (cur_wchar) - { - rv = 1; - if ((cur_wchar & 0xFC00) == 0xD800) - { - unsigned int low = *src; - if ((low & 0xFC00) == 0xDC00) - { - src++; - cur_wchar = 0x10000 + ( ((cur_wchar & 0x3FF) << 10) | (low & 0x3FF) ); - rv = 2; - } - } - } - *out = cur_wchar; - return rv; -} - - -UINT utf8_get_char(const char * src) -{ - UINT rv = 0; - utf8_decode_char(src,&rv); - return rv; -} - - -unsigned utf8_char_len(const char * s) -{ - return utf8_decode_char(s,0); -} - -int skip_utf8_chars(const char * ptr,int count) -{ - int num = 0; - for(;count && ptr[num];count--) - { - int d = utf8_char_len(ptr+num); - if (d<=0) break; - num+=d; - } - return num; -} - -unsigned convert_utf8_to_utf16(const char * src,WCHAR * dst,unsigned len) -{ - unsigned rv = 0; - while(*src && len) - { - unsigned c,d; - d = utf8_decode_char(src,&c,len); - if (d==0 || d>len) break; - src += d; - len -= d; - d = utf16_encode_char(c,dst); - if (d==0) break; - dst += d; - rv += d; - } - *dst = 0; - return rv; -} - -unsigned convert_utf16_to_utf8(const WCHAR * src,char * dst,unsigned len) -{ - unsigned rv = 0; - while(*src && len) - { - unsigned c,d; - d = utf16_decode_char(src,&c); - if (d==0 || d>len) break; - src += d; - len -= d; - d = utf8_encode_char(c,dst); - if (d==0) break; - dst += d; - rv += d; - } - *dst = 0; - return rv; -} - -unsigned convert_ansi_to_utf16(const char * src,WCHAR * dst,unsigned len) -{ - len = strlen_max(src,len); - unsigned rv; -#ifdef WIN32 - rv = MultiByteToWideChar(CP_ACP,0,src,len,dst,estimate_ansi_to_utf16(src)); -#else - setlocale(LC_CTYPE,""); - rv = mbstowcs(dst,src,len); -#endif - if ((signed)rv<0) rv = 0; - dst[rv]=0; - return rv; -} - -unsigned convert_utf16_to_ansi(const WCHAR * src,char * dst,unsigned len) -{ - len = wcslen_max(src,len); - unsigned rv; -#ifdef WIN32 - rv = WideCharToMultiByte(CP_ACP,0,src,len,dst,estimate_utf16_to_ansi(src),0,0); -#else - setlocale(LC_CTYPE,""); - rv = wcstombs(dst,src,len); -#endif - if ((signed)rv<0) rv = 0; - dst[rv]=0; - return rv; -} - -unsigned convert_utf8_to_ansi(const char * src,char * dst,unsigned len) -{//meh - len = strlen_max(src,len); - - unsigned temp_len = estimate_utf8_to_utf16(src,len); - mem_block_t temp_block; - WCHAR * temp = (temp_len * sizeof(WCHAR) <= PFC_ALLOCA_LIMIT) ? (WCHAR*)alloca(temp_len * sizeof(WCHAR)) : temp_block.set_size(temp_len); - assert(temp); - - len = convert_utf8_to_utf16(src,temp,len); - return convert_utf16_to_ansi(temp,dst,len); -} - -unsigned convert_ansi_to_utf8(const char * src,char * dst,unsigned len) -{//meh - len = strlen_max(src,len); - - unsigned temp_len = estimate_ansi_to_utf16(src,len); - mem_block_t temp_block; - WCHAR * temp = (temp_len * sizeof(WCHAR) <= PFC_ALLOCA_LIMIT) ? (WCHAR*)alloca(temp_len * sizeof(WCHAR)) : temp_block.set_size(temp_len); - assert(temp); - - len = convert_ansi_to_utf16(src,temp,len); - return convert_utf16_to_utf8(temp,dst,len); -} - -void string_base::add_string_ansi(const char * src,unsigned len) -{ - len = strlen_max(src,len); - - unsigned temp_len = estimate_ansi_to_utf8(src,len); - mem_block_t temp_block; - char * temp = (temp_len * sizeof(char) <= PFC_ALLOCA_LIMIT) ? (char*)alloca(temp_len * sizeof(char)) : temp_block.set_size(temp_len); - assert(temp); - - len = convert_ansi_to_utf8(src,temp,len); - add_string_n(temp,len); -} - -void string_base::add_string_utf16(const WCHAR * src,unsigned len) -{ - len = wcslen_max(src,len); - - unsigned temp_len = estimate_utf16_to_utf8(src,len); - mem_block_t temp_block; - char * temp = (temp_len * sizeof(char) <= PFC_ALLOCA_LIMIT) ? (char*)alloca(temp_len * sizeof(char)) : temp_block.set_size(temp_len); - assert(temp); - - len = convert_utf16_to_utf8(src,temp,len); - add_string_n(temp,len); -} - -bool is_valid_utf8(const char * param) -{ - __try { - while(*param) - { - unsigned d; - d = utf8_decode_char(param,0); - if (d==0) return false; - param += d; - } - return true; - } - __except(1) - { - return false; - } -} - -bool is_lower_ascii(const char * param) -{ - while(*param) - { - if (*param<0) return false; - param++; - } - return true; -} - -static bool check_end_of_string(const char * ptr) -{ - __try { - return !*ptr; - } - __except(1) {return true;} -} - -unsigned strcpy_utf8_truncate(const char * src,char * out,unsigned maxbytes) -{ - unsigned rv = 0 , ptr = 0; - if (maxbytes>0) - { - maxbytes--;//for null - while(!check_end_of_string(src) && maxbytes>0) - { - __try { - unsigned delta = utf8_char_len(src); - if (delta>maxbytes || delta==0) break; - do - { - out[ptr++] = *(src++); - } while(--delta); - } __except(1) { break; } - rv = ptr; - } - out[rv]=0; - } - return rv; -} - -void recover_invalid_utf8(const char * src,char * out,unsigned replace) -{ - while(!check_end_of_string(src)) - { - unsigned c,d; - __try { - d = utf8_decode_char(src,&c); - } __except(1) {d = 0;} - if (d==0) c = replace; - out += utf8_encode_char(c,out); - } - *out = 0; -} - -unsigned string8::replace_char(unsigned c1,unsigned c2,unsigned start) -{ - string8 temp(get_ptr()+start); - truncate(start); - const char * ptr = temp; - unsigned rv = 0; - while(*ptr) - { - unsigned test; - unsigned delta = utf8_decode_char(ptr,&test); - if (delta==0 || test==0) break; - if (test == c1) {test = c2;rv++;} - add_char(test); - ptr += delta; - } - return rv; -} - -unsigned strlen_utf8(const char * p,unsigned num) -{ - unsigned w,d; - unsigned ret = 0; - for(;num;) - { - d = utf8_decode_char(p,&w); - if (w==0 || d<=0) break; - ret++; - p+=d; - num-=d; - } - return ret; -} - -unsigned utf8_chars_to_bytes(const char * string,unsigned count) -{ - unsigned bytes = 0; - while(count) - { - unsigned delta = utf8_decode_char(string+bytes,0); - if (delta==0) break; - bytes += delta; - count--; - } - return bytes; -} \ No newline at end of file diff --git a/tools/vio2sf/src/foobar8/readme.txt b/tools/vio2sf/src/foobar8/readme.txt deleted file mode 100644 index 61a81729a..000000000 --- a/tools/vio2sf/src/foobar8/readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -foobar2000 0.8 SDK readme - -All components need to be linked to pfc, foobar2000_SDK, utf8api and to component_client - hint: use dependencies in msvc, *do*not* include all .cpp files in your project - that will drastically increase time needed to compile and cause weird errors to occur. -Included workspace has all project dependencies set up, have a look at it if you can't figure how to make things compile correctly. - -This SDK is intended to work with 0.8 versions of foobar2000. It will not work with any earlier versions. You may need to recompile your components with newer version of this SDK in order to get them to work with post-0.8 versions of foobar2000. - -latest version of this SDK is available at http://www.foobar2000.org/ - -copyright stuff: - -SSRC SuperEQ libraries (c) Naoki Shibata, http://shibatch.sourceforge.net/ - -mpglib library (c) 1995-99 Michael Hipp - -mpc decoding library - (C) 1999-2002 Buschmann/Klemm/Piecha/Wolf - -tagread.cpp tag manipulating routines by Case - -SPC player sourcecode available at http://www.foobar2000.org/foo_spc_src.zip - -akrip.dll source Copyright (C) 1999 Jay A. Key - -JNetLib copyright (C) 2000-2001 Nullsoft, Inc. diff --git a/tools/vio2sf/src/kobarin/kmp_pi.h b/tools/vio2sf/src/kobarin/kmp_pi.h deleted file mode 100644 index 64c1811d3..000000000 --- a/tools/vio2sf/src/kobarin/kmp_pi.h +++ /dev/null @@ -1,214 +0,0 @@ -#ifndef KMP_PI_H -#define KMP_PI_H - -/* - - KbMedia Player Plugin SDK (2005/10/08 版) - - 開発者向けです。 - KbMedia Player のプラグインを開発してみたい人だけがお読み下さい。 - 手抜きでコメントは C++ 用になってますが、今時のコンパイラなら C でも大丈夫でしょう。 - - 実際のプラグインのソースコードは - - http://hp.vector.co.jp/authors/VA015058/source/ - - にあります。 - - 必要最小限の機能しかないため、出来ることはかなり制限されますが、 - その分プラグインを作るのは簡単なはずです。プラグインを使うのも簡単でしょう。 - -*/ - -#define KMPMODULE_VERSION 100 /* KMPMODULE のバージョン */ -#define KMP_GETMODULE kmp_GetTestModule /* まだ(いつまで?)テスト版... */ -#define SZ_KMP_GETMODULE "kmp_GetTestModule" /* まだ(いつまで?)テスト版... */ -#define SZ_KMP_CONFIG "kmp_Config" /* プラグイン設定用(v2.38beta2 以降で対応) */ - -typedef void* HKMP;/* 'K'b'M'edia 'P'layer Plugin の Handle */ - -typedef struct -{/* オープンしたサウンドデータの情報 */ - DWORD dwSamplesPerSec;/* サンプリング周波数(44100, 22050 など) */ - DWORD dwChannels; /* チャンネル数( mono = 1, stereo = 2) */ - DWORD dwBitsPerSample;/* 量子化ビット数( 8 or 16 or 24 or 32 or -32(32bit float) ) */ - DWORD dwLength; /* 曲の長さ(計算不可能な場合は 0xFFFFFFFF) */ - /* 1ファイル複数曲(dwReserved2 == 1)のときは、曲数を 1000 倍した値にする。 */ - /* 例えば 10 曲の場合は dwLength == 10000 とする。 */ - /* 1ファイル複数曲の場合、曲毎の演奏時間を取得することは出来ない。 */ - /* 駄目な仕様でスミマセン */ - DWORD dwSeekable; /* シークに対応している場合は 1、しない場合は 0 */ - DWORD dwUnitRender; /* Render 関数の第3引数はこの値が渡される(どんな値でも良い場合は 0) */ - DWORD dwReserved1; /* 無限ループして演奏終了しない曲の場合に 1, そうでない場合に 0 */ - /* Render の呼び出しを繰り返しても演奏終了しない場合に 1 にする */ - /* dwReserved1 == 1 の場合、 */ - /* ・プレイヤー本体の「単曲リピート」が有効になっている場合は無限ループ */ - /* ・dwLength != 0xFFFFFFFF の場合は dwLength だけ再生した後にプレイヤー */ - /* 本体によってフェードアウト・演奏終了される */ - /* ・dwLength == 0xFFFFFFFF の場合はプレイヤーの設定の「デフォルトの長さ」 */ - /* だけ再生した後にフェードアウト・演奏終了される */ - /* dwReserved1 == 0 の場合、 */ - /* ・Render の戻り値が第3引数(dwSize)より小さい値が返るまで再生される */ - DWORD dwReserved2; /* 1ファイル複数曲の場合に 1, 1ファイル1曲のときに 0 */ - /* dwReserved2 == 1 の場合、dwLength には曲数を 1000 倍した値を返すこと。 */ - /* dwReserved2 == 1 の場合、SetPosition の dwPos に(曲番号 * 1000)が渡される */ - /* ようになり、シークは出来なくなるので dwSeek == 0 とすること。 */ - /* 現在の仕様では、1ファイル複数曲の拡張子は KbMedia Player 本体で決め打ち */ - /* されており、本体が知らない拡張子に対してこの値を 1 にしても正常には動作 */ - /* しないし、本体が1ファイル複数曲として扱っている形式に対してこの値を 0 に */ - /* しても、やはり正常動作しない(ぉぃ */ - /* 駄目な仕様でスミマセン */ -}SOUNDINFO; - - -typedef struct -{ - DWORD dwVersion; - /* モジュールのバージョン。プラグインのバージョンではない。 */ - /* 必ず KMPMODULE_VERSION(=100) にすること。 */ - /* この値が KbMedia Player が期待する値と一致しない場合は、KbMedia Player */ - /* によって直ちに FreeLibrary が呼ばれる。 */ - /* その場合、Init() も Deinit() も呼ばれないことに注意。 */ - - DWORD dwPluginVersion; - /* プラグインのバージョン */ - /* 対応拡張子が競合するプラグインが見つかった場合は、数字が大きいものを優先的に使う */ - - const char *pszCopyright; - /* 著作権 */ - /* バージョン情報でこの部分の文字列を表示する */ - /* NULL にしてもよい */ - - const char *pszDescription; - /* 説明 */ - /* バージョン情報でこの部分の文字列を表示する */ - /* NULL にしてもよい */ - - const char **ppszSupportExts; - /* 対応拡張子の文字列の配列(ピリオド含む) */ - /* NULL で終わるようにする */ - /* 例:ppszSupportExts = {".mp1", ".mp2", ".mp3", "rmp", NULL}; */ - /* */ - /* ppszSupportExts == {NULL} (ppszSupportExts == NULL は不可)で、かつ Init と Deinit */ - /* が 非 NULL の場合は常駐プラグインとして扱われ、KbMedia Player が動作中は常にロード */ - /* されたままになる(非公式の機能) */ - /* 常駐プラグインとしての動作は Init 呼出し時に開始し、Deinit 呼出し時に終了すること。 */ - /* (LoadLibrary 時に動作開始、FreeLibrary 時に動作終了は不可) */ - /* */ - /* 上記以外で対応拡張子が1つもない場合、不正なプラグインと見なされ、KbMedia Player */ - /* によって直ちに FreeLibrary される。 */ - /* その場合は Init() も Deinit() も呼ばれないことに注意。 */ - - DWORD dwReentrant; - /* 複数ファイルの同時再生が可能な場合は 1, 不可能な場合は 0 */ - /* Open の戻り値の HKMP を2つ以上同時に持てない場合に 0 にする */ - /* 特別な事情がない限り、出来るだけ dwReentrant == 1 となるように実装するべきである */ - /* この値が 0 の場合、2つ目以降のファイルはプレイヤー本体とは別 EXE を経由して開く */ - /* ようになる。 */ - /* 何らかの理由により、常にプレイヤー本体とは別 EXE でファイルを開くようにしたい場合 */ - /* は dwReentrant == 0xFFFFFFFF とすること */ - /* 例えば、aaa.kpi と bbb.kpi が ccc.dll に依存し、ccc.dll がノンリエントラントである */ - /* 場合は、aaa.kpi も bbb.kpi も dwReentrant == 0xFFFFFFFF になっていた方が望ましい。 */ - - void (WINAPI *Init)(void); - /* プラグイン初期化。Open 等を呼び出す前に KbMedia Player によって一度だけ呼ばれる。 */ - /* 必要ない場合は NULL にしても良い。 */ - /* ただし、常駐プラグイン(非公式の機能)の場合は必ず実装すること。 */ - /* Init の呼び出しで常駐プラグインを動作開始する。 */ - /* LoadLibrary 時に常駐プラグインを動作開始してはいけない。 */ - - void (WINAPI *Deinit)(void); - /* プラグインの後始末。FreeLibrary の直前に一度だけ呼ばれる。 */ - /* Init() を一度も呼ばずに Deinit() を呼ぶ可能性もあることに注意。 */ - /* 必要ない場合は NULL にしても良い。 */ - /* ただし、常駐プラグイン(非公式の機能)の場合は必ず実装すること。 */ - /* Deinit の呼び出しで常駐プラグインを動作終了する */ - /* FreeLibrary 時に常駐プラグインを動作終了してはいけない。 */ - - HKMP (WINAPI *Open)(const char *cszFileName, SOUNDINFO *pInfo); - /* ファイルを開く。必ず実装すること。 */ - /* エラーの場合は NULL を返す。 */ - /* エラーでない場合は pInfo に適切な情報を入れること。適切な情報が入って */ - /* いない場合(dwBitsPerSample が 0 など)は KbMedia Player によって直ちに Close */ - /* が呼ばれる。 */ - /* Open に渡された pInfo->dwSampleRate/dwBitsPerSample/dwChannels の各値が 0 以外の */ - /* 場合、可能ならそれに従った形式(または最も近い形式)でファイルを開くようにすること。 */ - /* (例えば pInfo->dwBitsPerSample == -32(32bit float) になっている場合、可能なら */ - /* 32bit float で、32bit float が不可能でも 32bit int なら対応しているなら 32bit int */ - /* で返すなど) */ - - - HKMP (WINAPI *OpenFromBuffer)(const BYTE *Buffer, DWORD dwSize, SOUNDINFO *pInfo); - /* 未使用。NULL にすること。非 NULL でもエラーにはならないが、使用されない。 */ - - void (WINAPI *Close)(HKMP hKMP); - /* ハンドルを閉じる。必ず実装すること。 */ - - DWORD (WINAPI *Render)(HKMP hKMP, BYTE* Buffer, DWORD dwSize); - /* Buffer に PCM を入れる。必ず実装すること。 */ - /* dwSize は Buffer のサイズのバイト数。(サンプル数ではない) */ - /* 戻り値は Buffer に書き込んだバイト数。(サンプル数ではない) */ - /* dwSize より小さい値を返したら演奏終了。 */ - /* dwSize は SOUNDINFO::dwUnitRender の値が渡される。 */ - /* SOUNDINFO::dwUnitRender == 0 の場合は dwSize には任意の値が渡される。 */ - /* (dwSize はサンプルあたりのバイト数の倍数であることが保証されている) */ - - DWORD (WINAPI *SetPosition)(HKMP hKMP, DWORD dwPos); - /* シーク。必ず実装すること。 */ - /* dwPos はシーク先の再生位置。戻り値はシーク後の再生位置。単位はミリ秒。 */ - /* dwPos と戻り値は完全に一致する必要はない。戻り値と本当の再生位置の */ - /* 誤差が大きくなる(歌詞との同期再生時に支障をきたす)場合は Open 時に */ - /* SOUNDINFO の dwSeekable を 0 にしておくこと。誤差がないか、あっても */ - /* 非常に小さい場合は dwSeekable を 1 にしておくこと。戻り値が正確なら */ - /* ば、dwPos と戻り値の差が大きくても dwSeekable=1 として良い。 */ - /* ただし、実際のシーク先位置が dwPos より後方になることは避けること。 */ - /* (CueSheet 再生時に問題が起こりやすい) */ - /* */ - /* シークに全く対応しない場合は、先頭位置に戻して 0 を返すこと。 */ - /* */ - /* 1ファイル複数曲(SOUNDINFO::dwReserved2 == 1)の場合、この関数で選曲 */ - /* することになる。曲番号は 1 ベース(曲番号 0 は存在しない)で、dwPos */ - /* には、曲番号を 1000 倍した値が入る。例えば 5 番目の曲に切り替える場合 */ - /* は dwPos == 5000 となる。 */ - /* 切り替え後の再生位置は先頭に戻して 0 を返すこと。 */ - /* ただし、dwPos == 0 の場合は曲を切り替えずに再生位置を先頭に戻すこと。 */ - /* SetPosition が一度も呼ばれていない状態では 1 曲目が選択されているように */ - /* すること。 */ - /* 切り替えと同時にシークすることは出来ない。(駄目な仕様でスミマセン) */ - -}KMPMODULE; - -typedef KMPMODULE* (WINAPI *pfnGetKMPModule)(void); -/* KMPMODULE* WINAPI kmp_GetTestModule(void); */ -/* */ -/* KMPMODULE 構造体へのポインタを返す。必ずエクスポートすること。 */ -/* この関数はプラグインが LoadLibrary されてから FreeLibrary されるまでの間に */ -/* KbMedia Player 本体からは1回だけしか呼ばれない。 */ -/* この関数が返した KMPMODULE 構造体のデータメンバは、FreeLibrary されるまで */ -/* 変更してはいけない。 */ -/* 従って、例えば対応拡張子を設定によって変更されるようにしたい場合、対応拡張子 */ -/* の変更が KbMedia Player 本体に認識されるのは、プラグイン再ロード時ということ */ -/* になる。 */ - -typedef DWORD (WINAPI *pfnKmpConfig)(HWND hWnd, DWORD dwVersion, DWORD dwReserved); -/* DWORD WINAPI kmp_Config(HWND hWnd, DWORD dwVersion, DWORD dwReserved); */ -/* */ -/* KbMedia Player Version 2.38beta2 以降で対応。 */ -/* プラグインの設定を行う。特に設定の必要がない場合はエクスポートしなくても良い。 */ -/* ・dwVersion/dwReserved ともに 0 が渡される */ -/* ・戻り値は現状では 0 を返すのみ */ -/* ・HKMP のインスタンスごとの設定は現状では未対応(対応の必要があるのか?) */ -/* ・kmp_Config が呼ばれる前に KMPMODULE::Init() が呼ばれる */ -/* ・kmp_Config から戻っていない(設定ダイアログを表示している)状態では、 */ -/* ・二重に kmp_Config が呼ばれることはない */ -/* ・KMPMODULE::Deinit() は呼ばれない */ -/* ・FreeLibrary は呼ばれない */ -/* ・kmp_Config 呼び出し後、ダイアログを表示したまま直ちにリターンする場合は */ -/* この限りではない(その場合はプラグイン側で適切に処理すること) */ -/* */ -/* 設定はしたいが kmp_Config の実装が面倒、という場合は、プラグインと同じ場所に */ -/* プラグインと同名の INI ファイルを置けば、KbMedia Player 本体のプラグイン設定 */ -/* ダイアログから INI ファイルを開いて INI ファイルを直接編集出来るようになっている。 */ - -#endif - diff --git a/tools/vio2sf/src/loadpe/COPYING.LIB b/tools/vio2sf/src/loadpe/COPYING.LIB deleted file mode 100644 index b6bd51763..000000000 --- a/tools/vio2sf/src/loadpe/COPYING.LIB +++ /dev/null @@ -1,481 +0,0 @@ - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if -you distribute copies of the library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright -the library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain -that everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, so that any problems introduced by others will not reflect on -the original authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary -GNU General Public License, which was designed for utility programs. This -license, the GNU Library General Public License, applies to certain -designated libraries. This license is quite different from the ordinary -one; be sure to read it in full, and don't assume that anything in it is -the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that -they blur the distinction we usually make between modifying or adding to a -program and simply using it. Linking a program with a library, without -changing the library, is in some sense simply using the library, and is -analogous to running a utility program or application program. However, in -a textual and legal sense, the linked executable is a combined work, a -derivative of the original library, and the ordinary General Public License -treats it as such. - - Because of this blurred distinction, using the ordinary General -Public License for libraries did not effectively promote software -sharing, because most developers did not use the libraries. We -concluded that weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended to -permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to achieve -this as regards changes in header files, but we have achieved it as regards -changes in the actual functions of the Library.) The hope is that this -will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - - Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - - GNU LIBRARY GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the source code distributed need not include anything that is normally -distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Library General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/tools/vio2sf/src/loadpe/loadpe.c b/tools/vio2sf/src/loadpe/loadpe.c deleted file mode 100644 index 4abbbd7ad..000000000 --- a/tools/vio2sf/src/loadpe/loadpe.c +++ /dev/null @@ -1,563 +0,0 @@ -/* - libloadpe - Copyright (C)2007 Ku-Zu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - loadpe.c - - 0.5 (2008/03/19) - Added support for WindowsNT4.0/NT3.x/Win32s. - - 0.4 (2008/02/07) - Leak checker. - - 0.3 (2008/01/08) - Fixed to protect memory after relocation and importing. - - 0.2 (2007/12/25) - Fixed not to free depending libraries before DLL_PROCESS_DETACH. - - 0.1 (2007/12/24) - First release. - -*/ - - -#define STRICT -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - -#include "loadpe.h" - -#define MEMORY_CHECK 0 -/* - 0:Off - 1:Check MSVCRT.DLL - 2:Check CRTDLL.DLL -*/ - -#if MEMORY_CHECK -static int chkload = 0; -static int chkcnt = 0; - -typedef void * (__cdecl *LPFNMALLOC)(size_t s); -typedef void (__cdecl *LPFNFREE)(void *p); -typedef void * (__cdecl *LPFNREALLOC)(void *p, size_t s); -typedef const char * (__cdecl *LPFNSTRDUP)(const char *s); -typedef void * (__cdecl *LPFNCALLOC)(size_t num, size_t size); - -static LPFNMALLOC pmalloc = 0; -static LPFNFREE pfree = 0; -static LPFNREALLOC prealloc = 0; -static LPFNSTRDUP pstrdup = 0; -/* -functions not implemented yet - -calloc -_wcsdup,_mbsdup -_getcwd,_wgetcwd -_tempnam,_wtempnam,tmpnam,_wtmpnam -_fullpath,_wfullpath - -*/ - -static void * __cdecl lpe_chk_malloc(size_t s) -{ - void *r = (pmalloc) ? pmalloc(s) : 0; - if (r) chkcnt++; - return r; -} -static void __cdecl lpe_chk_free(void *p) -{ - if (p) - { - if (pfree) - { - chkcnt--; - pfree(p); - } - } -} -static void * __cdecl lpe_chk_realloc(void *p, size_t s) -{ - if (p) - { - if (s) - return prealloc(p, s); - else - lpe_chk_free(p); - } - else - { - if (s) - return lpe_chk_malloc(s); - } - return 0; -} -static const char * __cdecl lpe_chk_strdup(const char *p) -{ - char *r = 0; - if (p) - { - size_t s = lstrlenA(p) + 1; - r = lpe_chk_malloc(s); - if (r) MoveMemory(r, p, s); - } - return r; -} -#endif - -typedef BOOL (WINAPI *LPFNDLLENTRY)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); -typedef struct -{ - LPBYTE lpImageBase; - DWORD dwImageSize; - LPFNDLLENTRY lpEntry; - LPBYTE lpImport; - LPBYTE lpExport; - HMODULE *hModules; -} LOADPE; - -static WORD getwordle(BYTE *pData) -{ - return (WORD)(pData[0] | (((WORD)pData[1]) << 8)); -} - -static DWORD getdwordle(BYTE *pData) -{ - return pData[0] | (((DWORD)pData[1]) << 8) | (((DWORD)pData[2]) << 16) | (((DWORD)pData[3]) << 24); -} - -static void setdwordle(LPBYTE lpPtr, DWORD dwDat) -{ - lpPtr[0] = (BYTE)((dwDat >> 0) & 0xff); - lpPtr[1] = (BYTE)((dwDat >> 8) & 0xff); - lpPtr[2] = (BYTE)((dwDat >> 16) & 0xff); - lpPtr[3] = (BYTE)((dwDat >> 24) & 0xff); -} - -static void setwordle(LPBYTE lpPtr, WORD wDat) -{ - lpPtr[0] = (BYTE)((wDat >> 0) & 0xff); - lpPtr[1] = (BYTE)((wDat >> 8) & 0xff); -} - -static void *XLoadLibraryH(HANDLE h) -{ - LOADPE *ret = NULL; - LOADPE *lpe = NULL; - HMODULE *hModules = NULL; - LPBYTE lpImageBase = 0; - LPBYTE lpHeader = 0; - -#define iMZHeaderSize (0x40) -#define iPEHeaderSize (4 + 20 + 224) - DWORD dwOffsetPE; - DWORD dwNumberOfBytesRead; - - DWORD dwNumberOfSections; - DWORD dwSizeOfOptionalHeader; - DWORD dwAddressOfEntryPoint; - DWORD dwImageBase; - DWORD dwSizeOfImage; - DWORD dwSizeOfHeaders; - DWORD dwExportRVA; - DWORD dwExportSize; - DWORD dwImportRVA; - DWORD dwImportSize; - DWORD dwRelocationRVA; - DWORD dwRelocationSize; - DWORD dwIATRVA; - DWORD dwIATSize; - - LPBYTE lpSectionHeader; - LPBYTE lpSectionHeaderTop; - LPBYTE lpSectionHeaderEnd; - - DWORD i; - - BYTE peheader[iPEHeaderSize]; - - switch ((INT_PTR)h) - { - case (INT_PTR)INVALID_HANDLE_VALUE: - return 0; - default: - if (!ReadFile(h, peheader, iMZHeaderSize, &dwNumberOfBytesRead, NULL) || dwNumberOfBytesRead < iMZHeaderSize) - break; - dwOffsetPE = getdwordle(peheader + 0x3c); - if (0xffffffff == SetFilePointer(h, dwOffsetPE, 0, FILE_BEGIN)) - break; - if (!ReadFile(h, peheader, iPEHeaderSize, &dwNumberOfBytesRead, NULL) || dwNumberOfBytesRead < iPEHeaderSize) - break; - - /* check PE signature */ - if (getdwordle(peheader) != 0x00004550) - break; - - /* COFF file header */ - dwNumberOfSections = getwordle(peheader + 4 + 2); - dwSizeOfOptionalHeader = getwordle(peheader + 4 + 16); - /* optional header standard field */ - dwAddressOfEntryPoint = getdwordle(peheader + 4 + 20 + 16); - /* optional header WindowsNT field */ - dwImageBase = getdwordle(peheader + 4 + 20 + 28); - dwSizeOfImage = getdwordle(peheader + 4 + 20 + 56); - dwSizeOfHeaders = getdwordle(peheader + 4 + 20 + 60); - /* optinal header data directory */ - dwExportRVA = getdwordle(peheader + 4 + 20 + 96); - dwExportSize = getdwordle(peheader + 4 + 20 + 100); - dwImportRVA = getdwordle(peheader + 4 + 20 + 104); - dwImportSize = getdwordle(peheader + 4 + 20 + 108); - dwRelocationRVA = getdwordle(peheader + 4 + 20 + 136); - dwRelocationSize = getdwordle(peheader + 4 + 20 + 140); - dwIATRVA = getdwordle(peheader + 4 + 20 + 192); - dwIATSize = getdwordle(peheader + 4 + 20 + 196); - - lpImageBase = VirtualAlloc(0, dwSizeOfImage + dwSizeOfHeaders, MEM_RESERVE, PAGE_NOACCESS); - if (!lpImageBase) - break; - - if (0xffffffff == SetFilePointer(h, 0, 0, FILE_BEGIN)) - break; - - lpHeader = VirtualAlloc(lpImageBase, dwSizeOfHeaders, MEM_COMMIT, PAGE_READWRITE); - if (lpHeader != lpImageBase) - break; - - if (!ReadFile(h, lpImageBase, dwSizeOfHeaders, &dwNumberOfBytesRead, NULL) || dwNumberOfBytesRead < dwSizeOfHeaders) - break; - - if (0xffffffff == SetFilePointer(h, dwOffsetPE + 4 + 20 + dwSizeOfOptionalHeader, 0, FILE_BEGIN)) - break; - - lpSectionHeaderTop = lpImageBase + dwOffsetPE + 4 + 20 + dwSizeOfOptionalHeader; - lpSectionHeaderEnd = lpSectionHeaderTop + dwNumberOfSections * 40; - - if (lpSectionHeaderEnd >= lpImageBase + dwSizeOfHeaders) - break; - - /* load sections */ - lpSectionHeader = lpSectionHeaderTop; - for (i = 0; i < dwNumberOfSections; i++) - { - DWORD dwVirtualSize; - DWORD dwVirtualAddress; - DWORD dwSizeOfRawData; - DWORD dwPointerToRawData; - LPBYTE lpSection; - - dwVirtualSize = getdwordle(lpSectionHeader + 8); - dwVirtualAddress = getdwordle(lpSectionHeader + 12); - dwSizeOfRawData = getdwordle(lpSectionHeader + 16); - dwPointerToRawData = getdwordle(lpSectionHeader + 20); - - lpSection = VirtualAlloc(lpImageBase + dwVirtualAddress, dwVirtualSize, MEM_COMMIT, PAGE_READWRITE); - if (!lpSection) - break; - - ZeroMemory(lpImageBase + dwVirtualAddress, dwVirtualSize); - if (0xffffffff == SetFilePointer(h, dwPointerToRawData, 0, FILE_BEGIN)) - break; - - if (!ReadFile(h, lpImageBase + dwVirtualAddress, dwSizeOfRawData, &dwNumberOfBytesRead, NULL) || dwNumberOfBytesRead < dwSizeOfRawData) - break; - - lpSectionHeader += 40; - } - if (lpSectionHeader != lpSectionHeaderEnd) break; - - /* resolve relocations */ - if (dwRelocationRVA) - { - int iERROR = 0; - LPBYTE lpReloc = lpImageBase + dwRelocationRVA; - while (lpReloc < lpImageBase + dwRelocationRVA + dwRelocationSize) - { - DWORD dwPageRVA = getdwordle(lpReloc + 0); - DWORD dwBlockSize = getdwordle(lpReloc + 4); - for (i = 4; i < (dwBlockSize >> 1); i++) - { - DWORD dwOffset = getwordle(lpReloc + (i << 1)); - DWORD dwType = (dwOffset >> 12) & 0xf; - LPBYTE lpRPtr = lpImageBase + dwPageRVA + (dwOffset & 0xfff); - DWORD dwRDat; - switch (dwType) - { - case IMAGE_REL_BASED_ABSOLUTE: - break; - case IMAGE_REL_BASED_HIGHLOW: - dwRDat = getdwordle(lpRPtr); - dwRDat = dwRDat + ((INT_PTR)lpImageBase) - dwImageBase; - setdwordle(lpRPtr, dwRDat); - break; - case IMAGE_REL_BASED_HIGH: - dwRDat = getwordle(lpRPtr) << 16; - dwRDat = dwRDat + ((INT_PTR)lpImageBase) - dwImageBase; - setwordle(lpRPtr, (WORD)((dwRDat >> 16) & 0xffff)); - break; - case IMAGE_REL_BASED_LOW: - dwRDat = getwordle(lpRPtr); - dwRDat = dwRDat + ((INT_PTR)lpImageBase) - dwImageBase; - setwordle(lpRPtr, (WORD)(dwRDat & 0xffff)); - break; - case IMAGE_REL_BASED_HIGHADJ: - default: - iERROR = 1; - break; - } - } - lpReloc += dwBlockSize; - } - if (iERROR) - break; - } - - /* resolve imports */ - if (dwImportRVA) - { - int iError = 0; - LPBYTE lpImport; - DWORD dwModuleNumber = 0; - lpImport = lpImageBase + dwImportRVA; - while (getdwordle(lpImport + 12) && getdwordle(lpImport + 16)) - { - dwModuleNumber++; - lpImport += 20; - } - hModules = malloc(sizeof(HMODULE) * (dwModuleNumber + 1)); - if (!hModules) - break; - - i = 0; - lpImport = lpImageBase + dwImportRVA; - while (getdwordle(lpImport + 12) && getdwordle(lpImport + 16)) - { - LPCSTR lpszDllName = (LPCSTR)(lpImageBase + getdwordle(lpImport + 12)); - LPBYTE lpIAT = lpImageBase + getdwordle(lpImport + 16); - HMODULE hDll = LoadLibraryA(lpszDllName); - if (!hDll) - { - iError = 1; - break; - } -#if MEMORY_CHECK -#if MEMORY_CHECK == 2 - if (!lstrcmpi(lpszDllName, "CRTDLL.DLL")) -#else - if (!lstrcmpi(lpszDllName, "MSVCRT.DLL")) -#endif - { - pmalloc = (LPFNMALLOC)GetProcAddress(hDll, "malloc"); - pfree = (LPFNFREE)GetProcAddress(hDll, "free"); - prealloc = (LPFNREALLOC)GetProcAddress(hDll, "realloc"); - pstrdup = (LPFNSTRDUP)GetProcAddress(hDll, "_strdup"); - } -#endif - hModules[i++] = hDll; - while (getdwordle(lpIAT)) - { - DWORD dwIA = getdwordle(lpIAT); - LPCSTR lpszProcName = (dwIA & 0x80000000) ? MAKEINTRESOURCEA(dwIA & 0x7fffffff) : (LPCSTR)(lpImageBase + dwIA + 2); - DWORD dwProc = (DWORD)(INT_PTR)GetProcAddress(hDll, lpszProcName); -#if MEMORY_CHECK - if (dwProc && dwProc == (DWORD)pmalloc) - dwProc = (DWORD)lpe_chk_malloc; - if (dwProc && dwProc == (DWORD)pfree) - dwProc = (DWORD)lpe_chk_free; - if (dwProc && dwProc == (DWORD)prealloc) - dwProc = (DWORD)lpe_chk_realloc; - if (dwProc && dwProc == (DWORD)pstrdup) - dwProc = (DWORD)lpe_chk_strdup; -#endif - if (dwProc) - setdwordle(lpIAT, dwProc); - else - iError = 1; - lpIAT += 4; - } - lpImport += 20; - } - hModules[i] = 0; - - if (iError) - break; - } - - lpe = malloc(sizeof(LOADPE)); - if (!lpe) - break; - - lpe->lpEntry = (LPFNDLLENTRY)(INT_PTR)(dwAddressOfEntryPoint ? lpImageBase + dwAddressOfEntryPoint: 0); - lpe->lpImageBase = lpImageBase; - lpe->lpImport = dwImportRVA ? lpImageBase + dwImportRVA: 0; - lpe->dwImageSize = dwSizeOfImage + dwSizeOfHeaders; - lpe->lpExport = dwExportRVA ? lpImageBase + dwExportRVA: 0; - lpe->hModules = hModules; - - /* protect sections */ - lpSectionHeader = lpSectionHeaderTop; - for (i = 0; i < dwNumberOfSections; i++) - { - DWORD dwVirtualSize; - DWORD dwVirtualAddress; - DWORD dwCharacteristics; - - DWORD fNewProtect; - DWORD fOldProtect; - - dwVirtualSize = getdwordle(lpSectionHeader + 8); - dwVirtualAddress = getdwordle(lpSectionHeader + 12); - dwCharacteristics = getdwordle(lpSectionHeader + 36); - - switch ((dwCharacteristics >> 29) & 7) - { - default: - case 0: fNewProtect = PAGE_NOACCESS; break; - case 1: fNewProtect = PAGE_EXECUTE; break; - case 2: fNewProtect = PAGE_READONLY; break; - case 3: fNewProtect = PAGE_EXECUTE_READ; break; - case 4: - case 6: fNewProtect = PAGE_READWRITE; break; - case 5: - case 7: fNewProtect = PAGE_EXECUTE_READWRITE; break; - } - VirtualProtect(lpImageBase + dwVirtualAddress, dwVirtualSize, fNewProtect, &fOldProtect); - - lpSectionHeader += 40; - } - - /* call entry point */ - if (lpe->lpEntry) - { - BOOL fResult; - fResult = lpe->lpEntry((HMODULE)lpe->lpImageBase, DLL_PROCESS_ATTACH, 0); - if (fResult == FALSE) - break; - } - - ret = lpe; - lpe = 0; - lpImageBase = 0; - hModules = 0; - break; - } - if (hModules) - { - for (i = 0; hModules[i]; i++) - FreeLibrary(hModules[i]); - free(hModules); - } - if (lpImageBase) - { - VirtualFree(lpImageBase, dwSizeOfImage + dwSizeOfHeaders, MEM_DECOMMIT); - VirtualFree(lpImageBase, 0, MEM_RELEASE); - } - if (lpe) - free(lpe); - CloseHandle(h); -#if MEMORY_CHECK - if (ret) chkload++; -#endif - return ret; -} - -void *XLoadLibraryA(const char *lpszFileName) -{ - HANDLE h = CreateFileA(lpszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - return XLoadLibraryH(h); -} - -void *XLoadLibraryW(const WCHAR *lpszFileName) -{ - HANDLE h = CreateFileW(lpszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - return XLoadLibraryH(h); -} - -void XFreeLibrary(void *hModule) -{ - LOADPE *lpe = hModule; - if (lpe) - { - if (lpe->lpEntry) - { - lpe->lpEntry((HMODULE)lpe->lpImageBase, DLL_PROCESS_DETACH, 0); - } - - if (lpe->hModules) - { - HMODULE *hModules; - for (hModules = lpe->hModules; *hModules; hModules++) - FreeLibrary(*hModules); - free(lpe->hModules); - } - - if (lpe->lpImageBase) - { - VirtualFree(lpe->lpImageBase, lpe->dwImageSize, MEM_DECOMMIT); - VirtualFree(lpe->lpImageBase, 0, MEM_RELEASE); - } - free(lpe); -#if MEMORY_CHECK - if (--chkload == 0) - { - if (chkcnt) - { - char buf[1024]; - wsprintfA(buf, "loadpe - memory leak - count %d\n", chkcnt); - OutputDebugStringA(buf); - } - } -#endif - } -} - -FARPROC XGetProcAddress(void *hModule, const char *lpfn) -{ - LOADPE *lpe = hModule; - if (lpe) - { - if (lpe->lpExport) - { - DWORD dwOrdinal; - DWORD dwOrdinalBase = getdwordle(lpe->lpExport + 20); - DWORD dwAddressTableEntries = getdwordle(lpe->lpExport + 20); - DWORD dwNumberofNamePointers = getdwordle(lpe->lpExport + 24); - LPBYTE lpEAT = lpe->lpImageBase + getdwordle(lpe->lpExport + 28); - LPBYTE lpNPT = lpe->lpImageBase + getdwordle(lpe->lpExport + 32); - LPBYTE lpOT = lpe->lpImageBase + getdwordle(lpe->lpExport + 36); - if (((INT_PTR)lpfn) & (~((INT_PTR)0xffff))) - { - DWORD i; - for (i = 0; i < dwNumberofNamePointers; i++) - { - if (lstrcmpA(lpfn, (LPCSTR)(lpe->lpImageBase + getdwordle(lpNPT + (i << 2)))) == 0) - break; - } - if (i == dwNumberofNamePointers) - return 0; - dwOrdinal = getwordle(lpOT + (i << 1)) + dwOrdinalBase; - } - else - dwOrdinal = (DWORD)(((INT_PTR)lpfn) & 0xffff); - if (dwOrdinal >= dwOrdinalBase && dwOrdinal < dwOrdinalBase + dwAddressTableEntries) - return (FARPROC)(INT_PTR)(lpe->lpImageBase + getdwordle(lpEAT + ((dwOrdinal - dwOrdinalBase) << 3) + 0)); - } - } - return 0; -} diff --git a/tools/vio2sf/src/loadpe/loadpe.h b/tools/vio2sf/src/loadpe/loadpe.h deleted file mode 100644 index a19575c3d..000000000 --- a/tools/vio2sf/src/loadpe/loadpe.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - libloadpe - Copyright (C)2007 Ku-Zu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -void *XLoadLibraryA(const char *lpszFileName); -void *XLoadLibraryW(const WCHAR *lpszFileName); -void XFreeLibrary(void *hModule); -FARPROC XGetProcAddress(void *hModule, const char *lpfn); - -#ifdef __cplusplus -} -#endif - diff --git a/tools/vio2sf/src/pversion.h b/tools/vio2sf/src/pversion.h deleted file mode 100644 index 37f377d15..000000000 --- a/tools/vio2sf/src/pversion.h +++ /dev/null @@ -1,36 +0,0 @@ -#define XSFDRIVER_VERSIONS "0.22" -#define XSFDRIVER_MODULENAME "vio2sf.bin" -#define XSFDRIVER_ENTRYNAME "XSFSetup" -#define XSFDRIVER_ISSYSTEMTAG(taglen, tag) (((taglen) > 0) && ((tag)[0] == '_') && !(((taglen) > 8) && _strnicmp(tag, "_vio2sf_", 8))) -#define XSFDRIVER_GUID1 { 0xcfa2ca5c, 0xd9a3, 0x49a6, { 0x93, 0x31, 0xf4, 0x09, 0xa2, 0xc1, 0x67, 0xdc } } /* {CFA2CA5C-D9A3-49a6-9331-F409A2C167DC} */ -#define XSFDRIVER_GUID2 { 0x5ae3d5fd, 0x0f4b, 0x4ca8, { 0xa9, 0x87, 0xca, 0x60, 0xc0, 0x97, 0x8b, 0x6a } } /* {5AE3D5FD-0F4B-4ca8-A987-CA60C0978B6A} */ -#define XSFDRIVER_CHANNELMAP { { 16, "SPU %2d" } , { 0, 0 } } -#define XSFDRIVER_SIMPLENAME "2SF Decoder" - -#define DESMUME_VERSIONS "0.8.0" -#define DESMUME_COPYRIGHT "Copyright (C) 2006 yopyop\nCopyright (C) 2006-2007 DeSmuME team" - -#define WINAMPPLUGIN_COPYRIGHT DESMUME_COPYRIGHT -#define WINAMPPLUGIN_NAME "2SF Decorder " XSFDRIVER_VERSIONS "/ DeSmuME v" DESMUME_VERSIONS " (x86)" -#define WINAMPPLUGIN_EXTS "2SF;MINI2SF\0Double Screen Sound Format files(*.2SF;*.MINI2SF)\0\0\0" -#define WINAMPPLUGIN_TAG_XSFBY "2sfby" - -#define KBMEDIAPLUGIN_VERSION 22 -#define KBMEDIAPLUGIN_COPYRIGHT DESMUME_COPYRIGHT -#define KBMEDIAPLUGIN_NAME "2SF plugin " XSFDRIVER_VERSIONS " / DeSmuME v" DESMUME_VERSIONS -#define KBMEDIAPLUGIN_EXTS(n) \ - static const char n##_2sfext[] = ".2sf"; \ - static const char n##_mini2sfext[] = ".mini2sf"; \ - static const char * const (n) [] = { \ - n##_2sfext, \ - n##_mini2sfext, \ - 0, \ - }; - -#define FOOBAR2000COMPONENT_NAME "2SF decoder / DeSmuME v" DESMUME_VERSIONS -#define FOOBAR2000COMPONENT_VERSION XSFDRIVER_VERSIONS -#define FOOBAR2000COMPONENT_ABOUT "DeSmuME v" DESMUME_VERSIONS "\n" DESMUME_COPYRIGHT "\n" -#define FOOBAR2000COMPONENT_TYPE "Double Screen Sound Format files" -#define FOOBAR2000COMPONENT_EXTS "*.2SF;*.MINI2SF" -#define FOOBAR2000COMPONENT_EXT_CHECK (!stricmp_utf8(p_extension,"2SF") || !stricmp_utf8(p_extension,"MINI2SF")) -#define FOOBAR2000COMPONENT_ENCODING "2sf" diff --git a/tools/vio2sf/src/vio2sf/desmume/ARM9.h b/tools/vio2sf/src/vio2sf/desmume/ARM9.h deleted file mode 100644 index 4dae037d8..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/ARM9.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef ARM9_H -#define ARM9_H - -#include "types.h" - -typedef struct { - //ARM9 mem - u8 ARM9_ITCM[0x8000]; - u8 ARM9_DTCM[0x4000]; - u8 ARM9_WRAM[0x1000000]; - u8 MAIN_MEM[0x400000]; - u8 ARM9_REG[0x1000000]; - u8 ARM9_BIOS[0x8000]; - u8 ARM9_VMEM[0x800]; - u8 ARM9_ABG[0x80000]; - u8 ARM9_BBG[0x20000]; - u8 ARM9_AOBJ[0x40000]; - u8 ARM9_BOBJ[0x20000]; - u8 ARM9_LCD[0xA4000]; - u8 ARM9_OAM[0x800]; - - u8 * ExtPal[2][4]; - u8 * ObjExtPal[2][2]; - u8 * texPalSlot[4]; - - const u8 *textureSlotAddr[4]; - - u8 *blank_memory[0x20000]; -} ARM9_struct; - -extern ARM9_struct ARM9Mem; - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/COPYING b/tools/vio2sf/src/vio2sf/desmume/COPYING deleted file mode 100644 index d60c31a97..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/tools/vio2sf/src/vio2sf/desmume/FIFO.c b/tools/vio2sf/src/vio2sf/desmume/FIFO.c deleted file mode 100644 index c86017f71..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/FIFO.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "FIFO.h" - -void FIFOInit(FIFO * fifo) -{ - u32 i; - - fifo->begin = 0; - fifo->end = 0; - for(i = 0; i<0x8000; ++i) - fifo->data[i] = 0; - fifo->full = FALSE; - fifo->empty = TRUE; - fifo->error = FALSE; -} - -void FIFOAdd(FIFO * fifo, u32 v) -{ - if(fifo->full) - { - fifo->error = TRUE; - return; - } - fifo->data[fifo->end] = v; - fifo->end = (fifo->end + 1)& 0x7FFF; - fifo->full = (fifo->end == fifo->begin); - fifo->empty = FALSE; -} - -u32 FIFOValue(FIFO * fifo) -{ - u32 v; - - if(fifo->empty) - { - fifo->error = TRUE; - return 0; - } - v = fifo->data[fifo->begin]; - fifo->begin = (fifo->begin + 1)& 0x7FFF; - fifo->empty = (fifo->begin == fifo->end); - return v; -} diff --git a/tools/vio2sf/src/vio2sf/desmume/FIFO.h b/tools/vio2sf/src/vio2sf/desmume/FIFO.h deleted file mode 100644 index 86e282902..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/FIFO.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef FIFO_H -#define FIFO_H - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ - u32 data[0x8000]; - u32 begin; - u32 end; - BOOL full; - BOOL empty; - BOOL error; -} FIFO; - -void FIFOInit(FIFO * fifo); -void FIFOAdd(FIFO * fifo, u32 v); -u32 FIFOValue(FIFO * fifo); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/GPU.c b/tools/vio2sf/src/vio2sf/desmume/GPU.c deleted file mode 100644 index 4dcfe6c39..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/GPU.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2007 Theo Berkau - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -// CONTENTS -// INITIALIZATION -// ENABLING / DISABLING LAYERS -// PARAMETERS OF BACKGROUNDS -// PARAMETERS OF ROTOSCALE -// PARAMETERS OF EFFECTS -// PARAMETERS OF WINDOWS -// ROUTINES FOR INSIDE / OUTSIDE WINDOW CHECKS -// PIXEL RENDERING -// BACKGROUND RENDERING -TEXT- -// BACKGROUND RENDERING -ROTOSCALE- -// BACKGROUND RENDERING -HELPER FUNCTIONS- -// SPRITE RENDERING -HELPER FUNCTIONS- -// SPRITE RENDERING -// SCREEN FUNCTIONS -// GRAPHICS CORE -// GPU_ligne - -#include -#include -#include -#include "MMU.h" -#include "GPU.h" - -ARM9_struct ARM9Mem; - -NDS_Screen MainScreen; -NDS_Screen SubScreen; - -//#define DEBUG_TRI - -/*****************************************************************************/ -// INITIALIZATION -/*****************************************************************************/ - -GPU * GPU_Init(u8 l) -{ - GPU * g; - - if ((g = (GPU *) malloc(sizeof(GPU))) == NULL) - return NULL; - - GPU_Reset(g, l); - return g; -} - -void GPU_Reset(GPU *g, u8 l) -{ - memset(g, 0, sizeof(GPU)); -} - -void GPU_DeInit(GPU * gpu) -{ - if (gpu) free(gpu); -} - - -int Screen_Init(int coreid) { - MainScreen.gpu = GPU_Init(0); - SubScreen.gpu = GPU_Init(1); - - return 0; -} - -void Screen_Reset(void) { - GPU_Reset(MainScreen.gpu, 0); - GPU_Reset(SubScreen.gpu, 1); -} - -void Screen_DeInit(void) { - GPU_DeInit(MainScreen.gpu); - GPU_DeInit(SubScreen.gpu); - -} diff --git a/tools/vio2sf/src/vio2sf/desmume/GPU.h b/tools/vio2sf/src/vio2sf/desmume/GPU.h deleted file mode 100644 index ac89d9543..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/GPU.h +++ /dev/null @@ -1,813 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2007 Theo Berkau - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef GPU_H -#define GPU_H - -#include "ARM9.h" -#include -#include "mem.h" -#include "registers.h" -#include "FIFO.h" -#include "MMU.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/******************************************************************************* - this structure is for display control, - it holds flags for general display -*******************************************************************************/ - -#ifdef WORDS_BIGENDIAN -struct _DISPCNT -{ -/* 7*/ u8 ForceBlank:1; // A+B: -/* 6*/ u8 OBJ_BMP_mapping:1; // A+B: 0=2D (128KB), 1=1D (128..256KB) -/* 5*/ u8 OBJ_BMP_2D_dim:1; // A+B: 0=128x512, 1=256x256 pixels -/* 4*/ u8 OBJ_Tile_1D:1; // A+B: 0=2D (32KB), 1=1D (32..256KB) -/* 3*/ u8 BG0_3D:1; // A : 0=2D, 1=3D -/* 0*/ u8 BG_Mode:3; // A+B: -/*15*/ u8 WinOBJ_Enable:1; // A+B: 0=disable, 1=Enable -/*14*/ u8 Win1_Enable:1; // A+B: 0=disable, 1=Enable -/*13*/ u8 Win0_Enable:1; // A+B: 0=disable, 1=Enable -/*12*/ u8 OBJ_Enable:1; // A+B: 0=disable, 1=Enable -/*11*/ u8 BG3_Enable:1; // A+B: 0=disable, 1=Enable -/*10*/ u8 BG2_Enable:1; // A+B: 0=disable, 1=Enable -/* 9*/ u8 BG1_Enable:1; // A+B: 0=disable, 1=Enable -/* 8*/ u8 BG0_Enable:1; // A+B: 0=disable, 1=Enable -/*23*/ u8 OBJ_HBlank_process:1; // A+B: OBJ processed during HBlank (GBA bit5) -/*22*/ u8 OBJ_BMP_1D_Bound:1; // A : -/*20*/ u8 OBJ_Tile_1D_Bound:2; // A+B: -/*18*/ u8 VRAM_Block:2; // A : VRAM block (0..3=A..D) - -/*16*/ u8 DisplayMode:2; // A+B: coreA(0..3) coreB(0..1) GBA(Green Swap) - // 0=off (white screen) - // 1=on (normal BG & OBJ layers) - // 2=VRAM display (coreA only) - // 3=RAM display (coreA only, DMA transfers) - -/*31*/ u8 ExOBJPalette_Enable:1; // A+B: 0=disable, 1=Enable OBJ extended Palette -/*30*/ u8 ExBGxPalette_Enable:1; // A+B: 0=disable, 1=Enable BG extended Palette -/*27*/ u8 ScreenBase_Block:3; // A : Screen Base (64K step) -/*24*/ u8 CharacBase_Block:3; // A : Character Base (64K step) -}; -#else -struct _DISPCNT -{ -/* 0*/ u8 BG_Mode:3; // A+B: -/* 3*/ u8 BG0_3D:1; // A : 0=2D, 1=3D -/* 4*/ u8 OBJ_Tile_1D:1; // A+B: 0=2D (32KB), 1=1D (32..256KB) -/* 5*/ u8 OBJ_BMP_2D_dim:1; // A+B: 0=128x512, 1=256x256 pixels -/* 6*/ u8 OBJ_BMP_mapping:1; // A+B: 0=2D (128KB), 1=1D (128..256KB) - - // 7-15 same as GBA -/* 7*/ u8 ForceBlank:1; // A+B: -/* 8*/ u8 BG0_Enable:1; // A+B: 0=disable, 1=Enable -/* 9*/ u8 BG1_Enable:1; // A+B: 0=disable, 1=Enable -/*10*/ u8 BG2_Enable:1; // A+B: 0=disable, 1=Enable -/*11*/ u8 BG3_Enable:1; // A+B: 0=disable, 1=Enable -/*12*/ u8 OBJ_Enable:1; // A+B: 0=disable, 1=Enable -/*13*/ u8 Win0_Enable:1; // A+B: 0=disable, 1=Enable -/*14*/ u8 Win1_Enable:1; // A+B: 0=disable, 1=Enable -/*15*/ u8 WinOBJ_Enable:1; // A+B: 0=disable, 1=Enable - -/*16*/ u8 DisplayMode:2; // A+B: coreA(0..3) coreB(0..1) GBA(Green Swap) - // 0=off (white screen) - // 1=on (normal BG & OBJ layers) - // 2=VRAM display (coreA only) - // 3=RAM display (coreA only, DMA transfers) - -/*18*/ u8 VRAM_Block:2; // A : VRAM block (0..3=A..D) -/*20*/ u8 OBJ_Tile_1D_Bound:2; // A+B: -/*22*/ u8 OBJ_BMP_1D_Bound:1; // A : -/*23*/ u8 OBJ_HBlank_process:1; // A+B: OBJ processed during HBlank (GBA bit5) -/*24*/ u8 CharacBase_Block:3; // A : Character Base (64K step) -/*27*/ u8 ScreenBase_Block:3; // A : Screen Base (64K step) -/*30*/ u8 ExBGxPalette_Enable:1; // A+B: 0=disable, 1=Enable BG extended Palette -/*31*/ u8 ExOBJPalette_Enable:1; // A+B: 0=disable, 1=Enable OBJ extended Palette -}; -#endif - -typedef union -{ - struct _DISPCNT bits; - u32 val; -} DISPCNT; -#define BGxENABLED(cnt,num) ((num<8)? ((cnt.val>>8) & num):0) - - - - -/******************************************************************************* - this structure is for display control of a specific layer, - there are 4 background layers - their priority indicate which one to draw on top of the other - some flags indicate special drawing mode, size, FX -*******************************************************************************/ - -#ifdef WORDS_BIGENDIAN -struct _BGxCNT -{ -/* 7*/ u8 Palette_256:1; // 0=16x16, 1=1*256 palette -/* 6*/ u8 Mosaic_Enable:1; // 0=disable, 1=Enable mosaic -/* 2*/ u8 CharacBase_Block:4; // individual character base offset (n*16KB) -/* 0*/ u8 Priority:2; // 0..3=high..low -/*14*/ u8 ScreenSize:2; // text : 256x256 512x256 256x512 512x512 - // x/rot/s : 128x128 256x256 512x512 1024x1024 - // bmp : 128x128 256x256 512x256 512x512 - // large : 512x1024 1024x512 - - -/*13*/ u8 PaletteSet_Wrap:1; // BG0 extended palette set 0=set0, 1=set2 - // BG1 extended palette set 0=set1, 1=set3 - // BG2 overflow area wraparound 0=off, 1=wrap - // BG3 overflow area wraparound 0=off, 1=wrap -/* 8*/ u8 ScreenBase_Block:5; // individual screen base offset (text n*2KB, BMP n*16KB) -}; -#else -struct _BGxCNT -{ -/* 0*/ u8 Priority:2; // 0..3=high..low -/* 2*/ u8 CharacBase_Block:4; // individual character base offset (n*16KB) -/* 6*/ u8 Mosaic_Enable:1; // 0=disable, 1=Enable mosaic -/* 7*/ u8 Palette_256:1; // 0=16x16, 1=1*256 palette -/* 8*/ u8 ScreenBase_Block:5; // individual screen base offset (text n*2KB, BMP n*16KB) -/*13*/ u8 PaletteSet_Wrap:1; // BG0 extended palette set 0=set0, 1=set2 - // BG1 extended palette set 0=set1, 1=set3 - // BG2 overflow area wraparound 0=off, 1=wrap - // BG3 overflow area wraparound 0=off, 1=wrap -/*14*/ u8 ScreenSize:2; // text : 256x256 512x256 256x512 512x512 - // x/rot/s : 128x128 256x256 512x512 1024x1024 - // bmp : 128x128 256x256 512x256 512x512 - // large : 512x1024 1024x512 - - -}; -#endif - - -typedef union -{ - struct _BGxCNT bits; - u16 val; -} BGxCNT; - -/******************************************************************************* - this structure is for background offset -*******************************************************************************/ - -typedef struct { - u16 BGxHOFS; - u16 BGxVOFS; -} BGxOFS; - -/******************************************************************************* - this structure is for rotoscale parameters -*******************************************************************************/ - -typedef struct { - s16 BGxPA; - s16 BGxPB; - s16 BGxPC; - s16 BGxPD; - s32 BGxX; - s32 BGxY; -} BGxPARMS; - - -/******************************************************************************* - these structures are for window description, - windows are square regions and can "subclass" - background layers or object layers (i.e window controls the layers) - - screen - | - +-- Window0/Window1/OBJwindow/OutOfWindows - | - +-- BG0/BG1/BG2/BG3/OBJ -*******************************************************************************/ - -typedef union { - struct { - u8 end:8; - u8 start:8; - } bits ; - u16 val; -} WINxDIM; - -#ifdef WORDS_BIGENDIAN -typedef struct { -/* 6*/ u8 :2; -/* 5*/ u8 WINx_Effect_Enable:1; -/* 4*/ u8 WINx_OBJ_Enable:1; -/* 3*/ u8 WINx_BG3_Enable:1; -/* 2*/ u8 WINx_BG2_Enable:1; -/* 1*/ u8 WINx_BG1_Enable:1; -/* 0*/ u8 WINx_BG0_Enable:1; -} WINxBIT; -#else -typedef struct { -/* 0*/ u8 WINx_BG0_Enable:1; -/* 1*/ u8 WINx_BG1_Enable:1; -/* 2*/ u8 WINx_BG2_Enable:1; -/* 3*/ u8 WINx_BG3_Enable:1; -/* 4*/ u8 WINx_OBJ_Enable:1; -/* 5*/ u8 WINx_Effect_Enable:1; -/* 6*/ u8 :2; -} WINxBIT; -#endif - -#ifdef WORDS_BIGENDIAN -typedef union { - struct { - WINxBIT win0; - WINxBIT win1; - } bits; - struct { - u8 :3; - u8 win0_en:5; - u8 :3; - u8 win1_en:5; - } packed_bits; - struct { - u8 low; - u8 high; - } bytes; - u16 val ; -} WINxCNT ; -#else -typedef union { - struct { - WINxBIT win0; - WINxBIT win1; - } bits; - struct { - u8 win0_en:5; - u8 :3; - u8 win1_en:5; - u8 :3; - } packed_bits; - struct { - u8 low; - u8 high; - } bytes; - u16 val ; -} WINxCNT ; -#endif - -/* -typedef struct { - WINxDIM WIN0H; - WINxDIM WIN1H; - WINxDIM WIN0V; - WINxDIM WIN1V; - WINxCNT WININ; - WINxCNT WINOUT; -} WINCNT; -*/ - -/******************************************************************************* - this structure is for miscellanous settings - //TODO: needs further description -*******************************************************************************/ - -typedef struct { - u16 MOSAIC; - u16 unused1; - u16 unused2;//BLDCNT; - u16 unused3;//BLDALPHA; - u16 unused4;//BLDY; - u16 unused5; - /* - u16 unused6; - u16 unused7; - u16 unused8; - u16 unused9; - */ -} MISCCNT; - - -/******************************************************************************* - this structure is for 3D settings -*******************************************************************************/ - -struct _DISP3DCNT -{ -/* 0*/ u8 EnableTexMapping:1; // -/* 1*/ u8 PolygonShading:1; // 0=Toon Shading, 1=Highlight Shading -/* 2*/ u8 EnableAlphaTest:1; // see ALPHA_TEST_REF -/* 3*/ u8 EnableAlphaBlending:1; // see various Alpha values -/* 4*/ u8 EnableAntiAliasing:1; // -/* 5*/ u8 EnableEdgeMarking:1; // see EDGE_COLOR -/* 6*/ u8 FogOnlyAlpha:1; // 0=Alpha and Color, 1=Only Alpha (see FOG_COLOR) -/* 7*/ u8 EnableFog:1; // Fog Master Enable -/* 8*/ u8 FogShiftSHR:4; // 0..10 SHR-Divider (see FOG_OFFSET) -/*12*/ u8 AckColorBufferUnderflow:1; // Color Buffer RDLINES Underflow (0=None, 1=Underflow/Acknowledge) -/*13*/ u8 AckVertexRAMOverflow:1; // Polygon/Vertex RAM Overflow (0=None, 1=Overflow/Acknowledge) -/*14*/ u8 RearPlaneMode:1; // 0=Blank, 1=Bitmap -/*15*/ u8 :1; -/*16*/ u16 :16; -}; - -typedef union -{ - struct _DISP3DCNT bits; - u32 val; -} DISP3DCNT; - -/******************************************************************************* - this structure is for capture control (core A only) - - source: - http://nocash.emubase.de/gbatek.htm#dsvideocaptureandmainmemorydisplaymode -*******************************************************************************/ - -struct _DISPCAPCNT -{ -/* 0*/ u8 BlendFactor_A:5; // 0..16 = Blending Factor for Source A -/* 5*/ u8 :3; // -/* 8*/ u8 BlendFactor_B:5; // 0..16 = Blending Factor for Source B -/*13*/ u8 :3; // -/*16*/ u8 VRAM_Write_Block:2; // 0..3 = VRAM A..D -/*18*/ u8 VRAM_Write_Offset:2; // n x 0x08000 -/*20*/ u8 Capture_Size:2; // 0=128x128, 1=256x64, 2=256x128, 3=256x192 dots -/*22*/ u8 :2; // -/*24*/ u8 Source_A:1; // 0=Graphics Screen BG+3D+OBJ, 1=3D Screen -/*25*/ u8 Source_B:1; // 0=VRAM, 1=Main Memory Display FIFO -/*26*/ u8 VRAM_Read_Offset:2; // n x 0x08000 -/*28*/ u8 :1; // -/*29*/ u8 Capture_Source:2; // 0=Source A, 1=Source B, 2/3=Sources A+B blended -/*31*/ u8 Capture_Enable:1; // 0=Disable/Ready, 1=Enable/Busy -}; - -typedef union -{ - struct _DISPCAPCNT bits; - u32 val; -} DISPCAPCNT; - - -/******************************************************************************* - this structure holds everything and should be mapped to - * core A : 0x04000000 - * core B : 0x04001000 -*******************************************************************************/ - -typedef struct _reg_dispx { - DISPCNT dispx_DISPCNT; // 0x0400x000 - u16 dispA_DISPSTAT; // 0x04000004 - u16 dispx_VCOUNT; // 0x0400x006 - BGxCNT dispx_BGxCNT[4]; // 0x0400x008 - BGxOFS dispx_BGxOFS[4]; // 0x0400x010 - BGxPARMS dispx_BG2PARMS; // 0x0400x020 - BGxPARMS dispx_BG3PARMS; // 0x0400x030 - u8 filler[12]; // 0x0400x040 - MISCCNT dispx_MISC; // 0x0400x04C - DISP3DCNT dispA_DISP3DCNT; // 0x04000060 - DISPCAPCNT dispA_DISPCAPCNT; // 0x04000064 - u32 dispA_DISPMMEMFIFO; // 0x04000068 -} REG_DISPx ; - - - - - - - - -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif - -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) -#endif - -typedef BOOL (*fun_gl_Begin) (int screen); -typedef void (*fun_gl_End) (int screen); -// the GUI should use this function prior to all gl calls -// if call to beg succeeds opengl draw -void register_gl_fun(fun_gl_Begin beg,fun_gl_End end); - -#define GPU_MAIN 0 -#define GPU_SUB 1 - -/* human readable bitmask names */ -#define ADDRESS_STEP_512B 0x00200 -#define ADDRESS_STEP_1KB 0x00400 -#define ADDRESS_STEP_2KB 0x00800 -#define ADDRESS_STEP_4KB 0x01000 -#define ADDRESS_STEP_8KB 0x02000 -#define ADDRESS_STEP_16KB 0x04000 -#define ADDRESS_STEP_32KB 0x08000 -#define ADDRESS_STEP_64kB 0x10000 - -#ifdef WORDS_BIGENDIAN -struct _TILEENTRY -{ -/*14*/ unsigned Palette:4; -/*13*/ unsigned VFlip:1; // VERTICAL FLIP (top<-->bottom) -/*12*/ unsigned HFlip:1; // HORIZONTAL FLIP (left<-->right) -/* 0*/ unsigned TileNum:10; -}; -#else -struct _TILEENTRY -{ -/* 0*/ unsigned TileNum:10; -/*12*/ unsigned HFlip:1; // HORIZONTAL FLIP (left<-->right) -/*13*/ unsigned VFlip:1; // VERTICAL FLIP (top<-->bottom) -/*14*/ unsigned Palette:4; -}; -#endif -typedef union -{ - struct _TILEENTRY bits; - u16 val; -} TILEENTRY; - -struct _ROTOCOORD -{ -/* 0*/ unsigned Fraction:8; -/* 8*/ signed Integer:24; -// /*28*/ unsigned :4; -}; -typedef union -{ - struct _ROTOCOORD bits; - s32 val; -} ROTOCOORD; - - -/* - this structure is for color representation, - it holds 5 meaningful bits per color channel (red,green,blue) - and 1 meaningful bit for alpha representation - this bit can be unused or used for special FX -*/ - -struct _COLOR { // abgr x555 -#ifdef WORDS_BIGENDIAN - unsigned alpha:1; // sometimes it is unused (pad) - unsigned blue:5; - unsigned green:5; - unsigned red:5; -#else - unsigned red:5; - unsigned green:5; - unsigned blue:5; - unsigned alpha:1; // sometimes it is unused (pad) -#endif -}; -struct _COLORx { // abgr x555 - unsigned bgr:15; - unsigned alpha:1; // sometimes it is unused (pad) -}; - -typedef union -{ - struct _COLOR bits; - struct _COLORx bitx; - u16 val; -} COLOR; - -struct _COLOR32 { // ARGB - unsigned :3; - unsigned blue:5; - unsigned :3; - unsigned green:5; - unsigned :3; - unsigned red:5; - unsigned :7; - unsigned alpha:1; // sometimes it is unused (pad) -}; - -typedef union -{ - struct _COLOR32 bits; - u32 val; -} COLOR32; - -#define COLOR_16_32(w,i) \ - /* doesnt matter who's 16bit who's 32bit */ \ - i.bits.red = w.bits.red; \ - i.bits.green = w.bits.green; \ - i.bits.blue = w.bits.blue; \ - i.bits.alpha = w.bits.alpha; - - - - - - -/* - this structure is for Sprite description, - it holds flags & transformations for 1 sprite - (max 128 OBJs / screen) -ref: http://www.bottledlight.com/ds/index.php/Video/Sprites -*/ - -typedef struct -{ -#ifdef WORDS_BIGENDIAN -// attr0 -/* 0*/ unsigned Y:8; -/*14*/ unsigned Shape:2; // (00: Square, 01: Wide, 10: Tall, 11: Illegal) -/*13*/ unsigned Depth:1; // (0: 16, 1: 256) -/*12*/ unsigned Mosaic:1; // (1: Enabled) -/*10*/ unsigned Mode:2; // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) -/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale) -// attr1 -/* 0*/ signed X:9; -/*14*/ unsigned Size:2; -/*13*/ unsigned VFlip:1; -/*12*/ unsigned HFlip:1; -/* 9*/ unsigned RotScalIndex:3; // Rot/scale matrix index -// attr2 -/* 0*/ unsigned TileIndex:10; -/*12*/ unsigned PaletteIndex:4; -/*10*/ unsigned Priority:2; -// attr3 -unsigned attr3:16; -#else -// attr0 -/* 0*/ unsigned Y:8; -/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale) -/*10*/ unsigned Mode:2; // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) -/*12*/ unsigned Mosaic:1; // (1: Enabled) -/*13*/ unsigned Depth:1; // (0: 16, 1: 256) -/*14*/ unsigned Shape:2; // (00: Square, 01: Wide, 10: Tall, 11: Illegal) -// attr1 -/* 0*/ signed X:9; -/* 9*/ unsigned RotScalIndex:3; // Rot/scale matrix index -/*12*/ unsigned HFlip:1; -/*13*/ unsigned VFlip:1; -/*14*/ unsigned Size:2; -// attr2 -/* 0*/ unsigned TileIndex:10; -/*10*/ unsigned Priority:2; -/*12*/ unsigned PaletteIndex:4; -// attr3 - unsigned attr3:16; -#endif -} _OAM_; - -typedef struct -{ - u16 attr0; - u16 attr1; - u16 attr2; - u16 attr3; -} OAM; - - - -typedef struct -{ - s16 x; - s16 y; -} size; - - - - -/* - this structure holds information - for rendering. -*/ - -#define NB_PRIORITIES 4 -#define NB_BG 4 -typedef struct -{ - u8 BGs[NB_BG], nbBGs; - u8 PixelsX[256]; - // doh ! yoda says : 256 pixels we can have... - u16 nbPixelsX; -} itemsForPriority_t; - - -typedef struct _GPU GPU; - -struct _GPU -{ - // some structs are becoming redundant - // some functions too (no need to recopy some vars as it is done by MMU) - REG_DISPx * dispx_st; - - DISPCAPCNT dispCapCnt; - BOOL LayersEnable[5]; - itemsForPriority_t itemsForPriority[NB_PRIORITIES]; - u8 sprWin[256][256]; - -#define BGBmpBB BG_bmp_ram -#define BGChBB BG_tile_ram - - u8 *(BG_bmp_ram[4]); - u8 *(BG_tile_ram[4]); - u8 *(BG_map_ram[4]); - - u8 BGExtPalSlot[4]; - u32 BGSize[4][2]; - - u8 lcd; - u8 core; - - u8 dispMode; - u8 vramBlock; - - BOOL dispBG[4]; - BOOL dispOBJ; - - OAM * oam; - u8 * sprMem; - u8 sprBoundary; - u8 sprBMPBoundary; - u8 sprBMPMode; - u32 sprEnable; - - u8 WIN0H0; - u8 WIN0H1; - u8 WIN0V0; - u8 WIN0V1; - - u8 WIN1H0; - u8 WIN1H1; - u8 WIN1V0; - u8 WIN1V1; - - u8 WININ0; - u8 WININ0_SPECIAL; - u8 WININ1; - u8 WININ1_SPECIAL; - - u8 WINOUT; - u8 WINOUT_SPECIAL; - u8 WINOBJ; - u8 WINOBJ_SPECIAL; - - u8 WIN0_ENABLED; - u8 WIN1_ENABLED; - u8 WINOBJ_ENABLED; - - u16 BLDCNT; - u8 BLDALPHA_EVA; - u8 BLDALPHA_EVB; - u8 BLDY_EVY; - - u8 MasterBrightMode; - u32 MasterBrightFactor; - - BOOL (*setFinalColorSpr)(const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y); - BOOL (*setFinalColorBck)(const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y); - void (*spriteRender) (GPU * gpu, u16 l, u8 * dst, u8 * prioTab); -}; -/* -// normally should have same addresses -static void REG_DISPx_pack_test(GPU * gpu) -{ - REG_DISPx * r = gpu->dispx_st; - printf ("%08x %02x\n", r, (long)(&r->dispx_DISPCNT) - (long)r); - printf ("\t%02x\n", (long)(&r->dispA_DISPSTAT) - (long)r); - printf ("\t%02x\n", (long)(&r->dispx_VCOUNT) - (long)r); - printf ("\t%02x\n", (long)(&r->dispx_BGxCNT[0]) - (long)r); - printf ("\t%02x\n", (long)(&r->dispx_BGxOFS[0]) - (long)r); - printf ("\t%02x\n", (long)(&r->dispx_BG2PARMS) - (long)r); - printf ("\t%02x\n", (long)(&r->dispx_BG3PARMS) - (long)r); - printf ("\t%02x\n", (long)(&r->dispx_WINCNT) - (long)r); - printf ("\t%02x\n", (long)(&r->dispx_MISC) - (long)r); - printf ("\t%02x\n", (long)(&r->dispA_DISP3DCNT) - (long)r); - printf ("\t%02x\n", (long)(&r->dispA_DISPCAPCNT) - (long)r); - printf ("\t%02x\n", (long)(&r->dispA_DISPMMEMFIFO) - (long)r); -} -*/ - -extern u8 GPU_screen[4*256*192]; - - -GPU * GPU_Init(u8 l); -void GPU_Reset(GPU *g, u8 l); -void GPU_DeInit(GPU *); - -void textBG(const GPU * gpu, u8 num, u8 * DST); //Draw text based background -void rotBG(GPU * gpu, u8 num, u8 * DST); -void extRotBG(GPU * gpu, u8 num, u8 * DST); -void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab); -void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab); - -extern short sizeTab[4][4][2]; -extern size sprSizeTab[4][4]; -extern s8 mode2type[8][4]; -extern void (*modeRender[8][4])(GPU * gpu, u8 num, u16 l, u8 * DST); - -typedef struct { - GPU * gpu; - u16 offset; -} NDS_Screen; - -extern NDS_Screen MainScreen; -extern NDS_Screen SubScreen; - -int Screen_Init(int coreid); -void Screen_Reset(void); -void Screen_DeInit(void); - -extern MMU_struct MMU; - - - -#define GFXCORE_DEFAULT -1 -#define GFXCORE_DUMMY 0 - -#define GFXCORE_FULLSCREEN (1 << 0) - -typedef struct -{ - int id; // ID number for core(see above defines) - const char *Name; // Name of core - int flags; // What features the core supports(full screen, etc.) - int (*Init)(); // Initializes stuff related to core - void (*DeInit)(); // Deinitializes stuff related to core - void (*Resize)(int width, int height, BOOL fullscreen); // Resizes window or fullscreen - void (*OnScreenText)(char *string, ...); // For handling save state messages, etc. -} GraphicsInterface_struct; - -extern GraphicsInterface_struct GFXDummy; - -void GPU_setVideoProp(GPU *, u32 p); -void GPU_setBGProp(GPU *, u16 num, u16 p); - -void GPU_setBLDCNT(GPU *gpu, u16 v) ; -void GPU_setBLDALPHA(GPU *gpu, u16 v) ; -void GPU_setBLDY(GPU *gpu, u16 v) ; -void GPU_setMOSAIC(GPU *gpu, u16 v) ; - - -void GPU_remove(GPU *, u8 num); -void GPU_addBack(GPU *, u8 num); - -int GPU_ChangeGraphicsCore(int coreid); - -void GPU_set_DISPCAPCNT(GPU * gpu, u32 val) ; -void GPU_ligne(NDS_Screen * screen, u16 l) ; -void GPU_setMasterBrightness (GPU *gpu, u16 val); - -void GPU_setWIN0_H (GPU *gpu, u16 val); -void GPU_setWIN0_H0 (GPU *gpu, u8 val); -void GPU_setWIN0_H1 (GPU *gpu, u8 val); - -void GPU_setWIN0_V (GPU *gpu, u16 val); -void GPU_setWIN0_V0 (GPU *gpu, u8 val); -void GPU_setWIN0_V1 (GPU *gpu, u8 val); - -void GPU_setWIN1_H (GPU *gpu, u16 val); -void GPU_setWIN1_H0 (GPU *gpu, u8 val); -void GPU_setWIN1_H1 (GPU *gpu, u8 val); - -void GPU_setWIN1_V (GPU *gpu, u16 val); -void GPU_setWIN1_V0 (GPU *gpu, u8 val); -void GPU_setWIN1_V1 (GPU *gpu, u8 val); - -void GPU_setWININ (GPU *gpu, u16 val); -void GPU_setWININ0 (GPU *gpu, u8 val); -void GPU_setWININ1 (GPU *gpu, u8 val); - -void GPU_setWINOUT16(GPU *gpu, u16 val); -void GPU_setWINOUT (GPU *gpu, u8 val); -void GPU_setWINOBJ (GPU *gpu, u8 val); - -void GPU_setBLDCNT_LOW (GPU *gpu, u8 val); -void GPU_setBLDCNT_HIGH (GPU *gpu, u8 val); -void GPU_setBLDCNT (GPU *gpu, u16 val); - -void GPU_setBLDALPHA (GPU *gpu, u16 val); -void GPU_setBLDALPHA_EVA(GPU *gpu, u8 val); -void GPU_setBLDALPHA_EVB(GPU *gpu, u8 val); - -void GPU_setBLDY_EVY (GPU *gpu, u8 val); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/tools/vio2sf/src/vio2sf/desmume/MMU.c b/tools/vio2sf/src/vio2sf/desmume/MMU.c deleted file mode 100644 index 361af02bb..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/MMU.c +++ /dev/null @@ -1,3565 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -//#define RENDER3D - -#include -#include -#include - -//#include "gl_vertex.h" - -#include "debug.h" -#include "NDSSystem.h" -//#include "cflash.h" -#define cflash_read(a) 0 -#define cflash_write(a,d) -#include "cp15.h" -//#include "wifi.h" -#include "registers.h" - -#if VIO2SF_GPU_ENABLE -#include "render3D.h" -#else -#define GPU_setVideoProp(p1, p2) -#define GPU_setBGProp(p1, p2, p3) - -#define GPU_setBLDCNT(p1, p2) -#define GPU_setBLDALPHA(p1, p2) -#define GPU_setBLDY(p1, p2) -#define GPU_setMOSAIC(p1, p2) - - -#define GPU_remove(p1,p2) -#define GPU_addBack(p1,p2) - -#define GPU_ChangeGraphicsCore(p1) 0 - -#define GPU_set_DISPCAPCNT(p1, p2) -#define GPU_ligne(p1, p2) -#define GPU_setMasterBrightness(p1, p2) - -#define GPU_setWIN0_H(p1, p2) -#define GPU_setWIN0_H0(p1, p2) -#define GPU_setWIN0_H1(p1, p2) - -#define GPU_setWIN0_V(p1, p2) -#define GPU_setWIN0_V0(p1, p2) -#define GPU_setWIN0_V1(p1, p2) - -#define GPU_setWIN1_H(p1, p2) -#define GPU_setWIN1_H0(p1, p2) -#define GPU_setWIN1_H1(p1, p2) - -#define GPU_setWIN1_V(p1, p2) -#define GPU_setWIN1_V0(p1, p2) -#define GPU_setWIN1_V1(p1, p2) - -#define GPU_setWININ(p1, p2) -#define GPU_setWININ0(p1, p2) -#define GPU_setWININ1(p1, p2) - -#define GPU_setWINOUT16(p1, p2) -#define GPU_setWINOUT(p1, p2) -#define GPU_setWINOBJ(p1, p2) - -#define GPU_setBLDCNT_LOW(p1, p2) -#define GPU_setBLDCNT_HIGH(p1, p2) -#define GPU_setBLDCNT(p1, p2) - -#define GPU_setBLDALPHA(p1, p2) -#define GPU_setBLDALPHA_EVA(p1, p2) -#define GPU_setBLDALPHA_EVB(p1, p2) - -#define GPU_setBLDY_EVY(p1, p2) -#endif - -#define ROM_MASK 3 - -/* - * - */ -//#define PROFILE_MEMORY_ACCESS 1 -#define EARLY_MEMORY_ACCESS 1 - -#define INTERNAL_DTCM_READ 1 -#define INTERNAL_DTCM_WRITE 1 - -//#define LOG_CARD -//#define LOG_GPU -//#define LOG_DMA -//#define LOG_DMA2 -//#define LOG_DIV - -char szRomPath[512]; -char szRomBaseName[512]; - -#define DUP2(x) x, x -#define DUP4(x) x, x, x, x -#define DUP8(x) x, x, x, x, x, x, x, x -#define DUP16(x) x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x - -MMU_struct MMU; - -u8 * MMU_ARM9_MEM_MAP[256]={ -/* 0X*/ DUP16(ARM9Mem.ARM9_ITCM), -/* 1X*/ //DUP16(ARM9Mem.ARM9_ITCM) -/* 1X*/ DUP16(ARM9Mem.ARM9_WRAM), -/* 2X*/ DUP16(ARM9Mem.MAIN_MEM), -/* 3X*/ DUP16(MMU.SWIRAM), -/* 4X*/ DUP16(ARM9Mem.ARM9_REG), -/* 5X*/ DUP16(ARM9Mem.ARM9_VMEM), -/* 6X*/ DUP2(ARM9Mem.ARM9_ABG), - DUP2(ARM9Mem.ARM9_BBG), - DUP2(ARM9Mem.ARM9_AOBJ), - DUP2(ARM9Mem.ARM9_BOBJ), - DUP8(ARM9Mem.ARM9_LCD), -/* 7X*/ DUP16(ARM9Mem.ARM9_OAM), -/* 8X*/ DUP16(NULL), -/* 9X*/ DUP16(NULL), -/* AX*/ DUP16(MMU.CART_RAM), -/* BX*/ DUP16(MMU.UNUSED_RAM), -/* CX*/ DUP16(MMU.UNUSED_RAM), -/* DX*/ DUP16(MMU.UNUSED_RAM), -/* EX*/ DUP16(MMU.UNUSED_RAM), -/* FX*/ DUP16(ARM9Mem.ARM9_BIOS) -}; - -u32 MMU_ARM9_MEM_MASK[256]={ -/* 0X*/ DUP16(0x00007FFF), -/* 1X*/ //DUP16(0x00007FFF) -/* 1X*/ DUP16(0x00FFFFFF), -/* 2X*/ DUP16(0x003FFFFF), -/* 3X*/ DUP16(0x00007FFF), -/* 4X*/ DUP16(0x00FFFFFF), -/* 5X*/ DUP16(0x000007FF), -/* 6X*/ DUP2(0x0007FFFF), - DUP2(0x0001FFFF), - DUP2(0x0003FFFF), - DUP2(0x0001FFFF), - DUP8(0x000FFFFF), -/* 7X*/ DUP16(0x000007FF), -/* 8X*/ DUP16(ROM_MASK), -/* 9X*/ DUP16(ROM_MASK), -/* AX*/ DUP16(0x0000FFFF), -/* BX*/ DUP16(0x00000003), -/* CX*/ DUP16(0x00000003), -/* DX*/ DUP16(0x00000003), -/* EX*/ DUP16(0x00000003), -/* FX*/ DUP16(0x00007FFF) -}; - -u8 * MMU_ARM7_MEM_MAP[256]={ -/* 0X*/ DUP16(MMU.ARM7_BIOS), -/* 1X*/ DUP16(MMU.UNUSED_RAM), -/* 2X*/ DUP16(ARM9Mem.MAIN_MEM), -/* 3X*/ DUP8(MMU.SWIRAM), - DUP8(MMU.ARM7_ERAM), -/* 4X*/ DUP8(MMU.ARM7_REG), - DUP8(MMU.ARM7_WIRAM), -/* 5X*/ DUP16(MMU.UNUSED_RAM), -/* 6X*/ DUP16(ARM9Mem.ARM9_ABG), -/* 7X*/ DUP16(MMU.UNUSED_RAM), -/* 8X*/ DUP16(NULL), -/* 9X*/ DUP16(NULL), -/* AX*/ DUP16(MMU.CART_RAM), -/* BX*/ DUP16(MMU.UNUSED_RAM), -/* CX*/ DUP16(MMU.UNUSED_RAM), -/* DX*/ DUP16(MMU.UNUSED_RAM), -/* EX*/ DUP16(MMU.UNUSED_RAM), -/* FX*/ DUP16(MMU.UNUSED_RAM) -}; - -u32 MMU_ARM7_MEM_MASK[256]={ -/* 0X*/ DUP16(0x00003FFF), -/* 1X*/ DUP16(0x00000003), -/* 2X*/ DUP16(0x003FFFFF), -/* 3X*/ DUP8(0x00007FFF), - DUP8(0x0000FFFF), -/* 4X*/ DUP8(0x00FFFFFF), - DUP8(0x0000FFFF), -/* 5X*/ DUP16(0x00000003), -/* 6X*/ DUP16(0x0003FFFF), -/* 7X*/ DUP16(0x00000003), -/* 8X*/ DUP16(ROM_MASK), -/* 9X*/ DUP16(ROM_MASK), -/* AX*/ DUP16(0x0000FFFF), -/* BX*/ DUP16(0x00000003), -/* CX*/ DUP16(0x00000003), -/* DX*/ DUP16(0x00000003), -/* EX*/ DUP16(0x00000003), -/* FX*/ DUP16(0x00000003) -}; - -u32 MMU_ARM9_WAIT16[16]={ - 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1, -}; - -u32 MMU_ARM9_WAIT32[16]={ - 1, 1, 1, 1, 1, 2, 2, 1, 8, 8, 5, 1, 1, 1, 1, 1, -}; - -u32 MMU_ARM7_WAIT16[16]={ - 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1, -}; - -u32 MMU_ARM7_WAIT32[16]={ - 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 5, 1, 1, 1, 1, 1, -}; - -void MMU_Init(void) { - int i; - - LOG("MMU init\n"); - - memset(&MMU, 0, sizeof(MMU_struct)); - - MMU.CART_ROM = MMU.UNUSED_RAM; - - for(i = 0x80; i<0xA0; ++i) - { - MMU_ARM9_MEM_MAP[i] = MMU.CART_ROM; - MMU_ARM7_MEM_MAP[i] = MMU.CART_ROM; - } - - MMU.MMU_MEM[0] = MMU_ARM9_MEM_MAP; - MMU.MMU_MEM[1] = MMU_ARM7_MEM_MAP; - MMU.MMU_MASK[0]= MMU_ARM9_MEM_MASK; - MMU.MMU_MASK[1] = MMU_ARM7_MEM_MASK; - - MMU.ITCMRegion = 0x00800000; - - MMU.MMU_WAIT16[0] = MMU_ARM9_WAIT16; - MMU.MMU_WAIT16[1] = MMU_ARM7_WAIT16; - MMU.MMU_WAIT32[0] = MMU_ARM9_WAIT32; - MMU.MMU_WAIT32[1] = MMU_ARM7_WAIT32; - - for(i = 0;i < 16;i++) - FIFOInit(MMU.fifos + i); - - mc_init(&MMU.fw, MC_TYPE_FLASH); /* init fw device */ - mc_alloc(&MMU.fw, NDS_FW_SIZE_V1); - MMU.fw.fp = NULL; - - // Init Backup Memory device, this should really be done when the rom is loaded - mc_init(&MMU.bupmem, MC_TYPE_AUTODETECT); - mc_alloc(&MMU.bupmem, 1); - MMU.bupmem.fp = NULL; - -} - -void MMU_DeInit(void) { - LOG("MMU deinit\n"); -// if (MMU.fw.fp) -// fclose(MMU.fw.fp); - mc_free(&MMU.fw); -// if (MMU.bupmem.fp) -// fclose(MMU.bupmem.fp); - mc_free(&MMU.bupmem); -} - -//Card rom & ram - -u16 SPI_CNT = 0; -u16 SPI_CMD = 0; -u16 AUX_SPI_CNT = 0; -u16 AUX_SPI_CMD = 0; - -u32 rom_mask = 0; - -u32 DMASrc[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; -u32 DMADst[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; - -void MMU_clearMem() -{ - int i; - - memset(ARM9Mem.ARM9_ABG, 0, 0x080000); - memset(ARM9Mem.ARM9_AOBJ, 0, 0x040000); - memset(ARM9Mem.ARM9_BBG, 0, 0x020000); - memset(ARM9Mem.ARM9_BOBJ, 0, 0x020000); - memset(ARM9Mem.ARM9_DTCM, 0, 0x4000); - memset(ARM9Mem.ARM9_ITCM, 0, 0x8000); - memset(ARM9Mem.ARM9_LCD, 0, 0x0A4000); - memset(ARM9Mem.ARM9_OAM, 0, 0x0800); - memset(ARM9Mem.ARM9_REG, 0, 0x01000000); - memset(ARM9Mem.ARM9_VMEM, 0, 0x0800); - memset(ARM9Mem.ARM9_WRAM, 0, 0x01000000); - memset(ARM9Mem.MAIN_MEM, 0, 0x400000); - - memset(ARM9Mem.blank_memory, 0, 0x020000); - - memset(MMU.ARM7_ERAM, 0, 0x010000); - memset(MMU.ARM7_REG, 0, 0x010000); - - for(i = 0;i < 16;i++) - FIFOInit(MMU.fifos + i); - - MMU.DTCMRegion = 0; - MMU.ITCMRegion = 0x00800000; - - memset(MMU.timer, 0, sizeof(u16) * 2 * 4); - memset(MMU.timerMODE, 0, sizeof(s32) * 2 * 4); - memset(MMU.timerON, 0, sizeof(u32) * 2 * 4); - memset(MMU.timerRUN, 0, sizeof(u32) * 2 * 4); - memset(MMU.timerReload, 0, sizeof(u16) * 2 * 4); - - memset(MMU.reg_IME, 0, sizeof(u32) * 2); - memset(MMU.reg_IE, 0, sizeof(u32) * 2); - memset(MMU.reg_IF, 0, sizeof(u32) * 2); - - memset(MMU.DMAStartTime, 0, sizeof(u32) * 2 * 4); - memset(MMU.DMACycle, 0, sizeof(s32) * 2 * 4); - memset(MMU.DMACrt, 0, sizeof(u32) * 2 * 4); - memset(MMU.DMAing, 0, sizeof(BOOL) * 2 * 4); - - memset(MMU.dscard, 0, sizeof(nds_dscard) * 2); - - MainScreen.offset = 192; - SubScreen.offset = 0; - - /* setup the texture slot pointers */ -#if 0 - ARM9Mem.textureSlotAddr[0] = ARM9Mem.blank_memory; - ARM9Mem.textureSlotAddr[1] = ARM9Mem.blank_memory; - ARM9Mem.textureSlotAddr[2] = ARM9Mem.blank_memory; - ARM9Mem.textureSlotAddr[3] = ARM9Mem.blank_memory; -#else - ARM9Mem.textureSlotAddr[0] = &ARM9Mem.ARM9_LCD[0x20000 * 0]; - ARM9Mem.textureSlotAddr[1] = &ARM9Mem.ARM9_LCD[0x20000 * 1]; - ARM9Mem.textureSlotAddr[2] = &ARM9Mem.ARM9_LCD[0x20000 * 2]; - ARM9Mem.textureSlotAddr[3] = &ARM9Mem.ARM9_LCD[0x20000 * 3]; -#endif -} - -/* the VRAM blocks keep their content even when not blended in */ -/* to ensure that we write the content back to the LCD ram */ -/* FIXME: VRAM Bank E,F,G,H,I missing */ -void MMU_VRAMWriteBackToLCD(u8 block) -{ - u8 *destination; - u8 *source; - u32 size ; - u8 VRAMBankCnt; - #if 1 - return ; - #endif - destination = 0 ; - source = 0; - VRAMBankCnt = MMU_read8(ARMCPU_ARM9,REG_VRAMCNTA+block) ; - switch (block) - { - case 0: // Bank A - destination = ARM9Mem.ARM9_LCD ; - size = 0x20000 ; - break ; - case 1: // Bank B - destination = ARM9Mem.ARM9_LCD + 0x20000 ; - size = 0x20000 ; - break ; - case 2: // Bank C - destination = ARM9Mem.ARM9_LCD + 0x40000 ; - size = 0x20000 ; - break ; - case 3: // Bank D - destination = ARM9Mem.ARM9_LCD + 0x60000 ; - size = 0x20000 ; - break ; - case 4: // Bank E - destination = ARM9Mem.ARM9_LCD + 0x80000 ; - size = 0x10000 ; - break ; - case 5: // Bank F - destination = ARM9Mem.ARM9_LCD + 0x90000 ; - size = 0x4000 ; - break ; - case 6: // Bank G - destination = ARM9Mem.ARM9_LCD + 0x94000 ; - size = 0x4000 ; - break ; - case 8: // Bank H - destination = ARM9Mem.ARM9_LCD + 0x98000 ; - size = 0x8000 ; - break ; - case 9: // Bank I - destination = ARM9Mem.ARM9_LCD + 0xA0000 ; - size = 0x4000 ; - break ; - default: - return ; - } - switch (VRAMBankCnt & 7) { - case 0: - /* vram is allready stored at LCD, we dont need to write it back */ - MMU.vScreen = 1; - break ; - case 1: - switch(block){ - case 0: - case 1: - case 2: - case 3: - /* banks are in use for BG at ABG + ofs * 0x20000 */ - source = ARM9Mem.ARM9_ABG + ((VRAMBankCnt >> 3) & 3) * 0x20000 ; - break ; - case 4: - /* bank E is in use at ABG */ - source = ARM9Mem.ARM9_ABG ; - break; - case 5: - case 6: - /* banks are in use for BG at ABG + (0x4000*OFS.0)+(0x10000*OFS.1)*/ - source = ARM9Mem.ARM9_ABG + (((VRAMBankCnt >> 3) & 1) * 0x4000) + (((VRAMBankCnt >> 2) & 1) * 0x10000) ; - break; - case 8: - /* bank H is in use at BBG */ - source = ARM9Mem.ARM9_BBG ; - break ; - case 9: - /* bank I is in use at BBG */ - source = ARM9Mem.ARM9_BBG + 0x8000 ; - break; - default: return ; - } - break ; - case 2: - if (block < 2) - { - /* banks A,B are in use for OBJ at AOBJ + ofs * 0x20000 */ - source = ARM9Mem.ARM9_AOBJ + ((VRAMBankCnt >> 3) & 1) * 0x20000 ; - } else return ; - break ; - case 4: - switch(block){ - case 2: - /* bank C is in use at BBG */ - source = ARM9Mem.ARM9_BBG ; - break ; - case 3: - /* bank D is in use at BOBJ */ - source = ARM9Mem.ARM9_BOBJ ; - break ; - default: return ; - } - break ; - default: - return ; - } - if (!destination) return ; - if (!source) return ; - memcpy(destination,source,size) ; -} - -void MMU_VRAMReloadFromLCD(u8 block,u8 VRAMBankCnt) -{ - u8 *destination; - u8 *source; - u32 size; - #if 1 - return ; - #endif - destination = 0; - source = 0; - size = 0; - switch (block) - { - case 0: // Bank A - source = ARM9Mem.ARM9_LCD ; - size = 0x20000 ; - break ; - case 1: // Bank B - source = ARM9Mem.ARM9_LCD + 0x20000 ; - size = 0x20000 ; - break ; - case 2: // Bank C - source = ARM9Mem.ARM9_LCD + 0x40000 ; - size = 0x20000 ; - break ; - case 3: // Bank D - source = ARM9Mem.ARM9_LCD + 0x60000 ; - size = 0x20000 ; - break ; - case 4: // Bank E - source = ARM9Mem.ARM9_LCD + 0x80000 ; - size = 0x10000 ; - break ; - case 5: // Bank F - source = ARM9Mem.ARM9_LCD + 0x90000 ; - size = 0x4000 ; - break ; - case 6: // Bank G - source = ARM9Mem.ARM9_LCD + 0x94000 ; - size = 0x4000 ; - break ; - case 8: // Bank H - source = ARM9Mem.ARM9_LCD + 0x98000 ; - size = 0x8000 ; - break ; - case 9: // Bank I - source = ARM9Mem.ARM9_LCD + 0xA0000 ; - size = 0x4000 ; - break ; - default: - return ; - } - switch (VRAMBankCnt & 7) { - case 0: - /* vram is allready stored at LCD, we dont need to write it back */ - MMU.vScreen = 1; - break ; - case 1: - if (block < 4) - { - /* banks are in use for BG at ABG + ofs * 0x20000 */ - destination = ARM9Mem.ARM9_ABG + ((VRAMBankCnt >> 3) & 3) * 0x20000 ; - } else return ; - break ; - case 2: - switch(block){ - case 0: - case 1: - case 2: - case 3: - /* banks are in use for BG at ABG + ofs * 0x20000 */ - destination = ARM9Mem.ARM9_ABG + ((VRAMBankCnt >> 3) & 3) * 0x20000 ; - break ; - case 4: - /* bank E is in use at ABG */ - destination = ARM9Mem.ARM9_ABG ; - break; - case 5: - case 6: - /* banks are in use for BG at ABG + (0x4000*OFS.0)+(0x10000*OFS.1)*/ - destination = ARM9Mem.ARM9_ABG + (((VRAMBankCnt >> 3) & 1) * 0x4000) + (((VRAMBankCnt >> 2) & 1) * 0x10000) ; - break; - case 8: - /* bank H is in use at BBG */ - destination = ARM9Mem.ARM9_BBG ; - break ; - case 9: - /* bank I is in use at BBG */ - destination = ARM9Mem.ARM9_BBG + 0x8000 ; - break; - default: return ; - } - break ; - case 4: - switch(block){ - case 2: - /* bank C is in use at BBG */ - destination = ARM9Mem.ARM9_BBG ; - break ; - case 3: - /* bank D is in use at BOBJ */ - destination = ARM9Mem.ARM9_BOBJ ; - break ; - default: return ; - } - break ; - default: - return ; - } - if (!destination) return ; - if (!source) return ; - memcpy(destination,source,size) ; -} - -void MMU_setRom(u8 * rom, u32 mask) -{ - unsigned int i; - MMU.CART_ROM = rom; - - for(i = 0x80; i<0xA0; ++i) - { - MMU_ARM9_MEM_MAP[i] = rom; - MMU_ARM7_MEM_MAP[i] = rom; - MMU_ARM9_MEM_MASK[i] = mask; - MMU_ARM7_MEM_MASK[i] = mask; - } - rom_mask = mask; -} - -void MMU_unsetRom() -{ - unsigned int i; - MMU.CART_ROM=MMU.UNUSED_RAM; - - for(i = 0x80; i<0xA0; ++i) - { - MMU_ARM9_MEM_MAP[i] = MMU.UNUSED_RAM; - MMU_ARM7_MEM_MAP[i] = MMU.UNUSED_RAM; - MMU_ARM9_MEM_MASK[i] = ROM_MASK; - MMU_ARM7_MEM_MASK[i] = ROM_MASK; - } - rom_mask = ROM_MASK; -} -char txt[80]; - -u8 FASTCALL MMU_read8(u32 proc, u32 adr) -{ -#ifdef INTERNAL_DTCM_READ - if((proc==ARMCPU_ARM9)&((adr&(~0x3FFF))==MMU.DTCMRegion)) - { - return ARM9Mem.ARM9_DTCM[adr&0x3FFF]; - } -#endif - - // CFlash reading, Mic - if ((adr>=0x9000000)&&(adr<0x9900000)) - return (unsigned char)cflash_read(adr); - -#ifdef EXPERIMENTAL_WIFI - /* wifi mac access */ - if ((proc==ARMCPU_ARM7) && (adr>=0x04800000)&&(adr<0x05000000)) - { - if (adr & 1) - return (WIFI_read16(&wifiMac,adr) >> 8) & 0xFF; - else - return WIFI_read16(&wifiMac,adr) & 0xFF; - } -#endif - - return MMU.MMU_MEM[proc][(adr>>20)&0xFF][adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF]]; -} - - - -u16 FASTCALL MMU_read16(u32 proc, u32 adr) -{ -#ifdef INTERNAL_DTCM_READ - if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) - { - /* Returns data from DTCM (ARM9 only) */ - return T1ReadWord(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); - } -#endif - - // CFlash reading, Mic - if ((adr>=0x08800000)&&(adr<0x09900000)) - return (unsigned short)cflash_read(adr); - -#ifdef EXPERIMENTAL_WIFI - /* wifi mac access */ - if ((proc==ARMCPU_ARM7) && (adr>=0x04800000)&&(adr<0x05000000)) - return WIFI_read16(&wifiMac,adr) ; -#endif - - adr &= 0x0FFFFFFF; - - if(adr&0x04000000) - { - /* Adress is an IO register */ - switch(adr) - { - -#if VIO2SF_GPU_ENABLE - case 0x04000604: - return (gpu3D->NDS_3D_GetNumPolys()&2047); - case 0x04000606: - return (gpu3D->NDS_3D_GetNumVertex()&8191); -#endif - - case REG_IPCFIFORECV : /* TODO (clear): ??? */ - execute = FALSE; - return 1; - - case REG_IME : - return (u16)MMU.reg_IME[proc]; - - case REG_IE : - return (u16)MMU.reg_IE[proc]; - case REG_IE + 2 : - return (u16)(MMU.reg_IE[proc]>>16); - - case REG_IF : - return (u16)MMU.reg_IF[proc]; - case REG_IF + 2 : - return (u16)(MMU.reg_IF[proc]>>16); - - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - return MMU.timer[proc][(adr&0xF)>>2]; - - case 0x04000630 : - LOG("vect res\r\n"); /* TODO (clear): ??? */ - //execute = FALSE; - return 0; - case REG_POSTFLG : - return 1; - default : - break; - } - } - - /* Returns data from memory */ - return T1ReadWord(MMU.MMU_MEM[proc][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[proc][(adr >> 20) & 0xFF]); -} - -u32 FASTCALL MMU_read32(u32 proc, u32 adr) -{ -#ifdef INTERNAL_DTCM_READ - if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) - { - /* Returns data from DTCM (ARM9 only) */ - return T1ReadLong(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); - } -#endif - - // CFlash reading, Mic - if ((adr>=0x9000000)&&(adr<0x9900000)) - return (unsigned long)cflash_read(adr); - - adr &= 0x0FFFFFFF; - - if((adr >> 24) == 4) - { - /* Adress is an IO register */ - switch(adr) - { - // This is hacked due to the only current 3D core - case 0x04000600: - { - u32 fifonum = IPCFIFO+proc; - - u32 gxstat = (MMU.fifos[fifonum].empty<<26) | - (1<<25) | - (MMU.fifos[fifonum].full<<24) | - /*((NDS_nbpush[0]&1)<<13) | ((NDS_nbpush[2]&0x1F)<<8) |*/ - 2; - - LOG ("GXSTAT: 0x%X", gxstat); - - return gxstat; - } - - case 0x04000640: - case 0x04000644: - case 0x04000648: - case 0x0400064C: - case 0x04000650: - case 0x04000654: - case 0x04000658: - case 0x0400065C: - case 0x04000660: - case 0x04000664: - case 0x04000668: - case 0x0400066C: - case 0x04000670: - case 0x04000674: - case 0x04000678: - case 0x0400067C: - { - //LOG("4000640h..67Fh - CLIPMTX_RESULT - Read Current Clip Coordinates Matrix (R)"); -#if VIO2SF_GPU_ENABLE - return gpu3D->NDS_3D_GetClipMatrix ((adr-0x04000640)/4); -#else - return 0; -#endif - } - case 0x04000680: - case 0x04000684: - case 0x04000688: - case 0x0400068C: - case 0x04000690: - case 0x04000694: - case 0x04000698: - case 0x0400069C: - case 0x040006A0: - { -#if VIO2SF_GPU_ENABLE - //LOG("4000680h..6A3h - VECMTX_RESULT - Read Current Directional Vector Matrix (R)"); - return gpu3D->NDS_3D_GetDirectionalMatrix ((adr-0x04000680)/4); -#else - return 0; -#endif - } - - case 0x4000604: - { -#if VIO2SF_GPU_ENABLE - return (gpu3D->NDS_3D_GetNumPolys()&2047) & ((gpu3D->NDS_3D_GetNumVertex()&8191) << 16); - //LOG ("read32 - RAM_COUNT -> 0x%X", ((u32 *)(MMU.MMU_MEM[proc][(adr>>20)&0xFF]))[(adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF])>>2]); -#else - return 0; -#endif - } - - case REG_IME : - return MMU.reg_IME[proc]; - case REG_IE : - return MMU.reg_IE[proc]; - case REG_IF : - return MMU.reg_IF[proc]; - case REG_IPCFIFORECV : - { - u16 IPCFIFO_CNT = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); - if(IPCFIFO_CNT&0x8000) - { - //execute = FALSE; - u32 fifonum = IPCFIFO+proc; - u32 val = FIFOValue(MMU.fifos + fifonum); - u32 remote = (proc+1) & 1; - u16 IPCFIFO_CNT_remote = T1ReadWord(MMU.MMU_MEM[remote][0x40], 0x184); - IPCFIFO_CNT |= (MMU.fifos[fifonum].empty<<8) | (MMU.fifos[fifonum].full<<9) | (MMU.fifos[fifonum].error<<14); - IPCFIFO_CNT_remote |= (MMU.fifos[fifonum].empty) | (MMU.fifos[fifonum].full<<1); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, IPCFIFO_CNT); - T1WriteWord(MMU.MMU_MEM[remote][0x40], 0x184, IPCFIFO_CNT_remote); - if ((MMU.fifos[fifonum].empty) && (IPCFIFO_CNT & BIT(2))) - NDS_makeInt(remote,17) ; /* remote: SEND FIFO EMPTY */ - return val; - } - } - return 0; - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - { - u32 val = T1ReadWord(MMU.MMU_MEM[proc][0x40], (adr + 2) & 0xFFF); - return MMU.timer[proc][(adr&0xF)>>2] | (val<<16); - } - /* - case 0x04000640 : // TODO (clear): again, ??? - LOG("read proj\r\n"); - return 0; - case 0x04000680 : - LOG("read roat\r\n"); - return 0; - case 0x04000620 : - LOG("point res\r\n"); - return 0; - */ - case REG_GCDATAIN: - { - u32 val; - - if(!MMU.dscard[proc].adress) return 0; - - val = T1ReadLong(MMU.CART_ROM, MMU.dscard[proc].adress); - - MMU.dscard[proc].adress += 4; /* increment adress */ - - MMU.dscard[proc].transfer_count--; /* update transfer counter */ - if(MMU.dscard[proc].transfer_count) /* if transfer is not ended */ - { - return val; /* return data */ - } - else /* transfer is done */ - { - T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, T1ReadLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff) & ~(0x00800000 | 0x80000000)); - /* = 0x7f7fffff */ - - /* if needed, throw irq for the end of transfer */ - if(T1ReadWord(MMU.MMU_MEM[proc][(REG_AUXSPICNT >> 20) & 0xff], REG_AUXSPICNT & 0xfff) & 0x4000) - { - if(proc == ARMCPU_ARM7) NDS_makeARM7Int(19); - else NDS_makeARM9Int(19); - } - - return val; - } - } - - default : - break; - } - } - - /* Returns data from memory */ - return T1ReadLong(MMU.MMU_MEM[proc][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[proc][(adr >> 20) & 0xFF]); -} - -void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val) -{ -#ifdef INTERNAL_DTCM_WRITE - if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) - { - /* Writes data in DTCM (ARM9 only) */ - ARM9Mem.ARM9_DTCM[adr&0x3FFF] = val; - return ; - } -#endif - - // CFlash writing, Mic - if ((adr>=0x9000000)&&(adr<0x9900000)) { - cflash_write(adr,val); - return; - } - - adr &= 0x0FFFFFFF; - - // This is bad, remove it - if(proc == ARMCPU_ARM7) - { - if ((adr>=0x04000400)&&(adr<0x0400051D)) - { - SPU_WriteByte(adr, val); - return; - } - } - - if (adr & 0xFF800000 == 0x04800000) - { - /* is wifi hardware, dont intermix with regular hardware registers */ - /* FIXME handle 8 bit writes */ - return ; - } - - switch(adr) - { - case REG_DISPA_WIN0H: - if(proc == ARMCPU_ARM9) GPU_setWIN0_H1 (MainScreen.gpu, val); - break ; - case REG_DISPA_WIN0H+1: - if(proc == ARMCPU_ARM9) GPU_setWIN0_H0 (MainScreen.gpu, val); - break ; - case REG_DISPA_WIN1H: - if(proc == ARMCPU_ARM9) GPU_setWIN1_H1 (MainScreen.gpu,val); - break ; - case REG_DISPA_WIN1H+1: - if(proc == ARMCPU_ARM9) GPU_setWIN1_H0 (MainScreen.gpu,val); - break ; - - case REG_DISPB_WIN0H: - if(proc == ARMCPU_ARM9) GPU_setWIN0_H1(SubScreen.gpu,val); - break ; - case REG_DISPB_WIN0H+1: - if(proc == ARMCPU_ARM9) GPU_setWIN0_H0(SubScreen.gpu,val); - break ; - case REG_DISPB_WIN1H: - if(proc == ARMCPU_ARM9) GPU_setWIN1_H1(SubScreen.gpu,val); - break ; - case REG_DISPB_WIN1H+1: - if(proc == ARMCPU_ARM9) GPU_setWIN1_H0(SubScreen.gpu,val); - break ; - - case REG_DISPA_WIN0V: - if(proc == ARMCPU_ARM9) GPU_setWIN0_V1(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN0V+1: - if(proc == ARMCPU_ARM9) GPU_setWIN0_V0(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1V: - if(proc == ARMCPU_ARM9) GPU_setWIN1_V1(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1V+1: - if(proc == ARMCPU_ARM9) GPU_setWIN1_V0(MainScreen.gpu,val) ; - break ; - - case REG_DISPB_WIN0V: - if(proc == ARMCPU_ARM9) GPU_setWIN0_V1(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN0V+1: - if(proc == ARMCPU_ARM9) GPU_setWIN0_V0(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1V: - if(proc == ARMCPU_ARM9) GPU_setWIN1_V1(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1V+1: - if(proc == ARMCPU_ARM9) GPU_setWIN1_V0(SubScreen.gpu,val) ; - break ; - - case REG_DISPA_WININ: - if(proc == ARMCPU_ARM9) GPU_setWININ0(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WININ+1: - if(proc == ARMCPU_ARM9) GPU_setWININ1(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WINOUT: - if(proc == ARMCPU_ARM9) GPU_setWINOUT(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WINOUT+1: - if(proc == ARMCPU_ARM9) GPU_setWINOBJ(MainScreen.gpu,val); - break ; - - case REG_DISPB_WININ: - if(proc == ARMCPU_ARM9) GPU_setWININ0(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WININ+1: - if(proc == ARMCPU_ARM9) GPU_setWININ1(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WINOUT: - if(proc == ARMCPU_ARM9) GPU_setWINOUT(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WINOUT+1: - if(proc == ARMCPU_ARM9) GPU_setWINOBJ(SubScreen.gpu,val) ; - break ; - - - case REG_DISPA_BLDCNT: - if(proc == ARMCPU_ARM9) GPU_setBLDCNT_HIGH(MainScreen.gpu,val); - break; - case REG_DISPA_BLDCNT+1: - if(proc == ARMCPU_ARM9) GPU_setBLDCNT_LOW (MainScreen.gpu,val); - break; - - case REG_DISPB_BLDCNT: - if(proc == ARMCPU_ARM9) GPU_setBLDCNT_HIGH (SubScreen.gpu,val); - break; - case REG_DISPB_BLDCNT+1: - if(proc == ARMCPU_ARM9) GPU_setBLDCNT_LOW (SubScreen.gpu,val); - break; - - case REG_DISPA_BLDALPHA: - if(proc == ARMCPU_ARM9) GPU_setBLDALPHA_EVB(MainScreen.gpu,val) ; - break; - case REG_DISPA_BLDALPHA+1: - if(proc == ARMCPU_ARM9) GPU_setBLDALPHA_EVA(MainScreen.gpu,val) ; - break; - - case REG_DISPB_BLDALPHA: - if(proc == ARMCPU_ARM9) GPU_setBLDALPHA_EVB(SubScreen.gpu,val) ; - break; - case REG_DISPB_BLDALPHA+1: - if(proc == ARMCPU_ARM9) GPU_setBLDALPHA_EVA(SubScreen.gpu,val); - break; - - case REG_DISPA_BLDY: - if(proc == ARMCPU_ARM9) GPU_setBLDY_EVY(MainScreen.gpu,val) ; - break ; - case REG_DISPB_BLDY: - if(proc == ARMCPU_ARM9) GPU_setBLDY_EVY(SubScreen.gpu,val) ; - break; - - /* TODO: EEEK ! Controls for VRAMs A, B, C, D are missing ! */ - /* TODO: Not all mappings of VRAMs are handled... (especially BG and OBJ modes) */ - case REG_VRAMCNTA: - case REG_VRAMCNTB: - case REG_VRAMCNTC: - case REG_VRAMCNTD: - if(proc == ARMCPU_ARM9) - { - MMU_VRAMWriteBackToLCD(0) ; - MMU_VRAMWriteBackToLCD(1) ; - MMU_VRAMWriteBackToLCD(2) ; - MMU_VRAMWriteBackToLCD(3) ; - switch(val & 0x1F) - { - case 1 : - MMU.vram_mode[adr-REG_VRAMCNTA] = 0; // BG-VRAM - //MMU.vram_offset[0] = ARM9Mem.ARM9_ABG+(0x20000*0); // BG-VRAM - break; - case 1 | (1 << 3) : - MMU.vram_mode[adr-REG_VRAMCNTA] = 1; // BG-VRAM - //MMU.vram_offset[0] = ARM9Mem.ARM9_ABG+(0x20000*1); // BG-VRAM - break; - case 1 | (2 << 3) : - MMU.vram_mode[adr-REG_VRAMCNTA] = 2; // BG-VRAM - //MMU.vram_offset[0] = ARM9Mem.ARM9_ABG+(0x20000*2); // BG-VRAM - break; - case 1 | (3 << 3) : - MMU.vram_mode[adr-REG_VRAMCNTA] = 3; // BG-VRAM - //MMU.vram_offset[0] = ARM9Mem.ARM9_ABG+(0x20000*3); // BG-VRAM - break; - case 0: /* mapped to lcd */ - MMU.vram_mode[adr-REG_VRAMCNTA] = 4 | (adr-REG_VRAMCNTA) ; - break ; - } - /* - * FIXME: simply texture slot handling - * This is a first stab and is not correct. It does - * not handle a VRAM texture slot becoming - * unconfigured. - * Revisit all of VRAM control handling for future - * release? - */ - if ( val & 0x80) { - if ( (val & 0x7) == 3) { - int slot_index = (val >> 3) & 0x3; - - ARM9Mem.textureSlotAddr[slot_index] = - &ARM9Mem.ARM9_LCD[0x20000 * (adr - REG_VRAMCNTA)]; - } - } - MMU_VRAMReloadFromLCD(adr-REG_VRAMCNTA,val) ; - } - break; - case REG_VRAMCNTE : - if(proc == ARMCPU_ARM9) - { - MMU_VRAMWriteBackToLCD((u8)REG_VRAMCNTE) ; - if((val & 7) == 5) - { - ARM9Mem.ExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x80000; - ARM9Mem.ExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x82000; - ARM9Mem.ExtPal[0][2] = ARM9Mem.ARM9_LCD + 0x84000; - ARM9Mem.ExtPal[0][3] = ARM9Mem.ARM9_LCD + 0x86000; - } - else if((val & 7) == 3) - { - ARM9Mem.texPalSlot[0] = ARM9Mem.ARM9_LCD + 0x80000; - ARM9Mem.texPalSlot[1] = ARM9Mem.ARM9_LCD + 0x82000; - ARM9Mem.texPalSlot[2] = ARM9Mem.ARM9_LCD + 0x84000; - ARM9Mem.texPalSlot[3] = ARM9Mem.ARM9_LCD + 0x86000; - } - else if((val & 7) == 4) - { - ARM9Mem.ExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x80000; - ARM9Mem.ExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x82000; - ARM9Mem.ExtPal[0][2] = ARM9Mem.ARM9_LCD + 0x84000; - ARM9Mem.ExtPal[0][3] = ARM9Mem.ARM9_LCD + 0x86000; - } - - MMU_VRAMReloadFromLCD(adr-REG_VRAMCNTE,val) ; - } - break; - - case REG_VRAMCNTF : - if(proc == ARMCPU_ARM9) - { - switch(val & 0x1F) - { - case 4 : - ARM9Mem.ExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x90000; - ARM9Mem.ExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x92000; - break; - - case 4 | (1 << 3) : - ARM9Mem.ExtPal[0][2] = ARM9Mem.ARM9_LCD + 0x90000; - ARM9Mem.ExtPal[0][3] = ARM9Mem.ARM9_LCD + 0x92000; - break; - - case 3 : - ARM9Mem.texPalSlot[0] = ARM9Mem.ARM9_LCD + 0x90000; - break; - - case 3 | (1 << 3) : - ARM9Mem.texPalSlot[1] = ARM9Mem.ARM9_LCD + 0x90000; - break; - - case 3 | (2 << 3) : - ARM9Mem.texPalSlot[2] = ARM9Mem.ARM9_LCD + 0x90000; - break; - - case 3 | (3 << 3) : - ARM9Mem.texPalSlot[3] = ARM9Mem.ARM9_LCD + 0x90000; - break; - - case 5 : - case 5 | (1 << 3) : - case 5 | (2 << 3) : - case 5 | (3 << 3) : - ARM9Mem.ObjExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x90000; - ARM9Mem.ObjExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x92000; - break; - } - } - break; - case REG_VRAMCNTG : - if(proc == ARMCPU_ARM9) - { - switch(val & 0x1F) - { - case 4 : - ARM9Mem.ExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x94000; - ARM9Mem.ExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x96000; - break; - - case 4 | (1 << 3) : - ARM9Mem.ExtPal[0][2] = ARM9Mem.ARM9_LCD + 0x94000; - ARM9Mem.ExtPal[0][3] = ARM9Mem.ARM9_LCD + 0x96000; - break; - - case 3 : - ARM9Mem.texPalSlot[0] = ARM9Mem.ARM9_LCD + 0x94000; - break; - - case 3 | (1 << 3) : - ARM9Mem.texPalSlot[1] = ARM9Mem.ARM9_LCD + 0x94000; - break; - - case 3 | (2 << 3) : - ARM9Mem.texPalSlot[2] = ARM9Mem.ARM9_LCD + 0x94000; - break; - - case 3 | (3 << 3) : - ARM9Mem.texPalSlot[3] = ARM9Mem.ARM9_LCD + 0x94000; - break; - - case 5 : - case 5 | (1 << 3) : - case 5 | (2 << 3) : - case 5 | (3 << 3) : - ARM9Mem.ObjExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x94000; - ARM9Mem.ObjExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x96000; - break; - } - } - break; - - case REG_VRAMCNTH : - if(proc == ARMCPU_ARM9) - { - MMU_VRAMWriteBackToLCD((u8)REG_VRAMCNTH) ; - - if((val & 7) == 2) - { - ARM9Mem.ExtPal[1][0] = ARM9Mem.ARM9_LCD + 0x98000; - ARM9Mem.ExtPal[1][1] = ARM9Mem.ARM9_LCD + 0x9A000; - ARM9Mem.ExtPal[1][2] = ARM9Mem.ARM9_LCD + 0x9C000; - ARM9Mem.ExtPal[1][3] = ARM9Mem.ARM9_LCD + 0x9E000; - } - - MMU_VRAMReloadFromLCD(adr-REG_VRAMCNTH,val) ; - } - break; - - case REG_VRAMCNTI : - if(proc == ARMCPU_ARM9) - { - MMU_VRAMWriteBackToLCD((u8)REG_VRAMCNTI) ; - - if((val & 7) == 3) - { - ARM9Mem.ObjExtPal[1][0] = ARM9Mem.ARM9_LCD + 0xA0000; - ARM9Mem.ObjExtPal[1][1] = ARM9Mem.ARM9_LCD + 0xA2000; - } - - MMU_VRAMReloadFromLCD(adr-REG_VRAMCNTI,val) ; - } - break; - -#ifdef LOG_CARD - case 0x040001A0 : /* TODO (clear): ??? */ - case 0x040001A1 : - case 0x040001A2 : - case 0x040001A8 : - case 0x040001A9 : - case 0x040001AA : - case 0x040001AB : - case 0x040001AC : - case 0x040001AD : - case 0x040001AE : - case 0x040001AF : - LOG("%08X : %02X\r\n", adr, val); -#endif - - default : - break; - } - - MMU.MMU_MEM[proc][(adr>>20)&0xFF][adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF]]=val; -} - -u16 partie = 1; - -void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val) -{ -#ifdef INTERNAL_DTCM_WRITE - if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) - { - /* Writes in DTCM (ARM9 only) */ - T1WriteWord(ARM9Mem.ARM9_DTCM, adr & 0x3FFF, val); - return; - } -#endif - - // CFlash writing, Mic - if ((adr>=0x08800000)&&(adr<0x09900000)) - { - cflash_write(adr,val); - return; - } - -#ifdef EXPERIMENTAL_WIFI - - /* wifi mac access */ - if ((proc==ARMCPU_ARM7) && (adr>=0x04800000)&&(adr<0x05000000)) - { - WIFI_write16(&wifiMac,adr,val) ; - return ; - } -#else - if ((proc==ARMCPU_ARM7) && (adr>=0x04800000)&&(adr<0x05000000)) - return ; -#endif - - adr &= 0x0FFFFFFF; - - // This is bad, remove it - if(proc == ARMCPU_ARM7) - { - if ((adr>=0x04000400)&&(adr<0x0400051D)) - { - SPU_WriteWord(adr, val); - return; - } - } - - if((adr >> 24) == 4) - { - /* Adress is an IO register */ - switch(adr) - { -#if VIO2SF_GPU_ENABLE - case 0x0400035C: - { - ((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x35C>>1] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_FogOffset (val); - } - return; - } - case 0x04000340: - { - ((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x340>>1] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_AlphaFunc(val); - } - return; - } - case 0x04000060: - { - ((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x060>>1] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Control(val); - } - return; - } - case 0x04000354: - { - ((u16 *)(MMU.MMU_MEM[proc][0x40]))[0x354>>1] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_ClearDepth(val); - } - return; - } -#endif - - case REG_DISPA_BLDCNT: - if(proc == ARMCPU_ARM9) GPU_setBLDCNT(MainScreen.gpu,val) ; - break ; - case REG_DISPB_BLDCNT: - if(proc == ARMCPU_ARM9) GPU_setBLDCNT(SubScreen.gpu,val) ; - break ; - case REG_DISPA_BLDALPHA: - if(proc == ARMCPU_ARM9) GPU_setBLDALPHA(MainScreen.gpu,val) ; - break ; - case REG_DISPB_BLDALPHA: - if(proc == ARMCPU_ARM9) GPU_setBLDALPHA(SubScreen.gpu,val) ; - break ; - case REG_DISPA_BLDY: - if(proc == ARMCPU_ARM9) GPU_setBLDY_EVY(MainScreen.gpu,val) ; - break ; - case REG_DISPB_BLDY: - if(proc == ARMCPU_ARM9) GPU_setBLDY_EVY(SubScreen.gpu,val) ; - break; - case REG_DISPA_MASTERBRIGHT: - GPU_setMasterBrightness (MainScreen.gpu, val); - break; - /* - case REG_DISPA_MOSAIC: - if(proc == ARMCPU_ARM9) GPU_setMOSAIC(MainScreen.gpu,val) ; - break ; - case REG_DISPB_MOSAIC: - if(proc == ARMCPU_ARM9) GPU_setMOSAIC(SubScreen.gpu,val) ; - break ; - */ - - case REG_DISPA_WIN0H: - if(proc == ARMCPU_ARM9) GPU_setWIN0_H (MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1H: - if(proc == ARMCPU_ARM9) GPU_setWIN1_H(MainScreen.gpu,val) ; - break ; - case REG_DISPB_WIN0H: - if(proc == ARMCPU_ARM9) GPU_setWIN0_H(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1H: - if(proc == ARMCPU_ARM9) GPU_setWIN1_H(SubScreen.gpu,val) ; - break ; - case REG_DISPA_WIN0V: - if(proc == ARMCPU_ARM9) GPU_setWIN0_V(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1V: - if(proc == ARMCPU_ARM9) GPU_setWIN1_V(MainScreen.gpu,val) ; - break ; - case REG_DISPB_WIN0V: - if(proc == ARMCPU_ARM9) GPU_setWIN0_V(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1V: - if(proc == ARMCPU_ARM9) GPU_setWIN1_V(SubScreen.gpu,val) ; - break ; - case REG_DISPA_WININ: - if(proc == ARMCPU_ARM9) GPU_setWININ(MainScreen.gpu, val) ; - break ; - case REG_DISPA_WINOUT: - if(proc == ARMCPU_ARM9) GPU_setWINOUT16(MainScreen.gpu, val) ; - break ; - case REG_DISPB_WININ: - if(proc == ARMCPU_ARM9) GPU_setWININ(SubScreen.gpu, val) ; - break ; - case REG_DISPB_WINOUT: - if(proc == ARMCPU_ARM9) GPU_setWINOUT16(SubScreen.gpu, val) ; - break ; - - case REG_DISPB_MASTERBRIGHT: - GPU_setMasterBrightness (SubScreen.gpu, val); - break; - - case REG_POWCNT1 : - if(proc == ARMCPU_ARM9) - { - if(val & (1<<15)) - { - LOG("Main core on top\n"); - MainScreen.offset = 0; - SubScreen.offset = 192; - //nds.swapScreen(); - } - else - { - LOG("Main core on bottom (%04X)\n", val); - MainScreen.offset = 192; - SubScreen.offset = 0; - } - } - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x304, val); - return; - - case REG_AUXSPICNT: - T1WriteWord(MMU.MMU_MEM[proc][(REG_AUXSPICNT >> 20) & 0xff], REG_AUXSPICNT & 0xfff, val); - AUX_SPI_CNT = val; - - if (val == 0) - mc_reset_com(&MMU.bupmem); /* reset backup memory device communication */ - return; - - case REG_AUXSPIDATA: - if(val!=0) - { - AUX_SPI_CMD = val & 0xFF; - } - - T1WriteWord(MMU.MMU_MEM[proc][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); - return; - - case REG_SPICNT : - if(proc == ARMCPU_ARM7) - { - int reset_firmware = 1; - - if ( ((SPI_CNT >> 8) & 0x3) == 1) { - if ( ((val >> 8) & 0x3) == 1) { - if ( BIT11(SPI_CNT)) { - /* select held */ - reset_firmware = 0; - } - } - } - - //MMU.fw.com == 0; /* reset fw device communication */ - if ( reset_firmware) { - /* reset fw device communication */ - mc_reset_com(&MMU.fw); - } - SPI_CNT = val; - } - - T1WriteWord(MMU.MMU_MEM[proc][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff, val); - return; - - case REG_SPIDATA : - if(proc==ARMCPU_ARM7) - { - u16 spicnt; - - if(val!=0) - { - SPI_CMD = val; - } - - spicnt = T1ReadWord(MMU.MMU_MEM[proc][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff); - - switch((spicnt >> 8) & 0x3) - { - case 0 : - break; - - case 1 : /* firmware memory device */ - if(spicnt & 0x3 != 0) /* check SPI baudrate (must be 4mhz) */ - { - T1WriteWord(MMU.MMU_MEM[proc][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, 0); - break; - } - T1WriteWord(MMU.MMU_MEM[proc][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, val)); - - return; - - case 2 : - switch(SPI_CMD & 0x70) - { - case 0x00 : - val = 0; - break; - case 0x10 : - //execute = FALSE; - if(SPI_CNT&(1<<11)) - { - if(partie) - { - val = ((nds.touchY<<3)&0x7FF); - partie = 0; - //execute = FALSE; - break; - } - val = (nds.touchY>>5); - partie = 1; - break; - } - val = ((nds.touchY<<3)&0x7FF); - partie = 1; - break; - case 0x20 : - val = 0; - break; - case 0x30 : - val = 0; - break; - case 0x40 : - val = 0; - break; - case 0x50 : - if(spicnt & 0x800) - { - if(partie) - { - val = ((nds.touchX<<3)&0x7FF); - partie = 0; - break; - } - val = (nds.touchX>>5); - partie = 1; - break; - } - val = ((nds.touchX<<3)&0x7FF); - partie = 1; - break; - case 0x60 : - val = 0; - break; - case 0x70 : - val = 0; - break; - } - break; - - case 3 : - /* NOTICE: Device 3 of SPI is reserved (unused and unusable) */ - break; - } - } - - T1WriteWord(MMU.MMU_MEM[proc][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, val); - return; - - /* NOTICE: Perhaps we have to use gbatek-like reg names instead of libnds-like ones ...*/ - - case REG_DISPA_BG0CNT : - //GPULOG("MAIN BG0 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(MainScreen.gpu, 0, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x8, val); - return; - case REG_DISPA_BG1CNT : - //GPULOG("MAIN BG1 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(MainScreen.gpu, 1, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xA, val); - return; - case REG_DISPA_BG2CNT : - //GPULOG("MAIN BG2 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(MainScreen.gpu, 2, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xC, val); - return; - case REG_DISPA_BG3CNT : - //GPULOG("MAIN BG3 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(MainScreen.gpu, 3, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xE, val); - return; - case REG_DISPB_BG0CNT : - //GPULOG("SUB BG0 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(SubScreen.gpu, 0, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x1008, val); - return; - case REG_DISPB_BG1CNT : - //GPULOG("SUB BG1 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(SubScreen.gpu, 1, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x100A, val); - return; - case REG_DISPB_BG2CNT : - //GPULOG("SUB BG2 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(SubScreen.gpu, 2, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x100C, val); - return; - case REG_DISPB_BG3CNT : - //GPULOG("SUB BG3 SETPROP 16B %08X\r\n", val); - if(proc == ARMCPU_ARM9) GPU_setBGProp(SubScreen.gpu, 3, val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x100E, val); - return; - case REG_IME : { - u32 old_val = MMU.reg_IME[proc]; - u32 new_val = val & 1; - MMU.reg_IME[proc] = new_val; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x208, val); - if ( new_val && old_val != new_val) { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[proc] & MMU.reg_IF[proc]) { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } - return; - } - case REG_VRAMCNTA: - MMU_write8(proc,adr,val & 0xFF) ; - MMU_write8(proc,adr+1,val >> 8) ; - return ; - case REG_VRAMCNTC: - MMU_write8(proc,adr,val & 0xFF) ; - MMU_write8(proc,adr+1,val >> 8) ; - return ; - case REG_VRAMCNTE: - MMU_write8(proc,adr,val & 0xFF) ; - MMU_write8(proc,adr+1,val >> 8) ; - return ; - case REG_VRAMCNTG: - MMU_write8(proc,adr,val & 0xFF) ; - MMU_write8(proc,adr+1,val >> 8) ; - return ; - case REG_VRAMCNTI: - MMU_write8(proc,adr,val & 0xFF) ; - return ; - - case REG_IE : - MMU.reg_IE[proc] = (MMU.reg_IE[proc]&0xFFFF0000) | val; - if ( MMU.reg_IME[proc]) { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[proc] & MMU.reg_IF[proc]) { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } - return; - case REG_IE + 2 : - execute = FALSE; - MMU.reg_IE[proc] = (MMU.reg_IE[proc]&0xFFFF) | (((u32)val)<<16); - return; - - case REG_IF : - execute = FALSE; - MMU.reg_IF[proc] &= (~((u32)val)); - return; - case REG_IF + 2 : - execute = FALSE; - MMU.reg_IF[proc] &= (~(((u32)val)<<16)); - return; - - case REG_IPCSYNC : - { - u32 remote = (proc+1)&1; - u16 IPCSYNC_remote = T1ReadWord(MMU.MMU_MEM[remote][0x40], 0x180); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x180, (val&0xFFF0)|((IPCSYNC_remote>>8)&0xF)); - T1WriteWord(MMU.MMU_MEM[remote][0x40], 0x180, (IPCSYNC_remote&0xFFF0)|((val>>8)&0xF)); - MMU.reg_IF[remote] |= ((IPCSYNC_remote & (1<<14))<<2) & ((val & (1<<13))<<3);// & (MMU.reg_IME[remote] << 16);// & (MMU.reg_IE[remote] & (1<<16));// - //execute = FALSE; - } - return; - case REG_IPCFIFOCNT : - { - u32 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184) ; - u32 cnt_r = T1ReadWord(MMU.MMU_MEM[(proc+1) & 1][0x40], 0x184) ; - if ((val & 0x8000) && !(cnt_l & 0x8000)) - { - /* this is the first init, the other side didnt init yet */ - /* so do a complete init */ - FIFOInit(MMU.fifos + (IPCFIFO+proc)); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184,0x8101) ; - /* and then handle it as usual */ - } - - if(val & 0x4008) - { - FIFOInit(MMU.fifos + (IPCFIFO+((proc+1)&1))); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, (cnt_l & 0x0301) | (val & 0x8404) | 1); - T1WriteWord(MMU.MMU_MEM[proc^1][0x40], 0x184, (cnt_r & 0xC507) | 0x100); - MMU.reg_IF[proc] |= ((val & 4)<<15);// & (MMU.reg_IME[proc]<<17);// & (MMU.reg_IE[proc]&0x20000);// - return; - } - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184) | (val & 0xBFF4)); - } - return; - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - MMU.timerReload[proc][(adr>>2)&3] = val; - return; - case REG_TM0CNTH : - case REG_TM1CNTH : - case REG_TM2CNTH : - case REG_TM3CNTH : - if(val&0x80) - { - MMU.timer[proc][((adr-2)>>2)&0x3] = MMU.timerReload[proc][((adr-2)>>2)&0x3]; - } - MMU.timerON[proc][((adr-2)>>2)&0x3] = val & 0x80; - switch(val&7) - { - case 0 : - MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 0+1;//proc; - break; - case 1 : - MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 6+1;//proc; - break; - case 2 : - MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 8+1;//proc; - break; - case 3 : - MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 10+1;//proc; - break; - default : - MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 0xFFFF; - break; - } - if(!(val & 0x80)) - MMU.timerRUN[proc][((adr-2)>>2)&0x3] = FALSE; - T1WriteWord(MMU.MMU_MEM[proc][0x40], adr & 0xFFF, val); - return; - case REG_DISPA_DISPCNT+2 : - { - //execute = FALSE; - u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0) & 0xFFFF) | ((u32) val << 16); - GPU_setVideoProp(MainScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0, v); - } - return; - case REG_DISPA_DISPCNT : - if(proc == ARMCPU_ARM9) - { - u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0) & 0xFFFF0000) | val; - GPU_setVideoProp(MainScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0, v); - } - return; - case REG_DISPA_DISPCAPCNT : - if(proc == ARMCPU_ARM9) - { - GPU_set_DISPCAPCNT(MainScreen.gpu,val); - } - return; - case REG_DISPB_DISPCNT+2 : - if(proc == ARMCPU_ARM9) - { - //execute = FALSE; - u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x1000) & 0xFFFF) | ((u32) val << 16); - GPU_setVideoProp(SubScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x1000, v); - } - return; - case REG_DISPB_DISPCNT : - { - u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x1000) & 0xFFFF0000) | val; - GPU_setVideoProp(SubScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x1000, v); - } - return; - //case 0x020D8460 : - /*case 0x0235A904 : - LOG("ECRIRE %d %04X\r\n", proc, val); - execute = FALSE;*/ - case REG_DMA0CNTH : - { - u32 v; - - //if(val&0x8000) execute = FALSE; - //LOG("16 bit dma0 %04X\r\n", val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xBA, val); - DMASrc[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB0); - DMADst[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB4); - v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB8); - MMU.DMAStartTime[proc][0] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); - MMU.DMACrt[proc][0] = v; - if(MMU.DMAStartTime[proc][0] == 0) - MMU_doDMA(proc, 0); - #ifdef LOG_DMA2 - //else - { - LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 0, DMASrc[proc][0], DMADst[proc][0], (val&(1<<25))?"ON":"OFF"); - } - #endif - } - return; - case REG_DMA1CNTH : - { - u32 v; - //if(val&0x8000) execute = FALSE; - //LOG("16 bit dma1 %04X\r\n", val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xC6, val); - DMASrc[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xBC); - DMASrc[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC0); - v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC4); - MMU.DMAStartTime[proc][1] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); - MMU.DMACrt[proc][1] = v; - if(MMU.DMAStartTime[proc][1] == 0) - MMU_doDMA(proc, 1); - #ifdef LOG_DMA2 - //else - { - LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 1, DMASrc[proc][1], DMADst[proc][1], (val&(1<<25))?"ON":"OFF"); - } - #endif - } - return; - case REG_DMA2CNTH : - { - u32 v; - //if(val&0x8000) execute = FALSE; - //LOG("16 bit dma2 %04X\r\n", val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xD2, val); - DMASrc[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC8); - DMASrc[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xCC); - v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD0); - MMU.DMAStartTime[proc][2] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); - MMU.DMACrt[proc][2] = v; - if(MMU.DMAStartTime[proc][2] == 0) - MMU_doDMA(proc, 2); - #ifdef LOG_DMA2 - //else - { - LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 2, DMASrc[proc][2], DMADst[proc][2], (val&(1<<25))?"ON":"OFF"); - } - #endif - } - return; - case REG_DMA3CNTH : - { - u32 v; - //if(val&0x8000) execute = FALSE; - //LOG("16 bit dma3 %04X\r\n", val); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xDE, val); - DMASrc[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD4); - DMASrc[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD8); - v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xDC); - MMU.DMAStartTime[proc][3] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); - MMU.DMACrt[proc][3] = v; - - if(MMU.DMAStartTime[proc][3] == 0) - MMU_doDMA(proc, 3); - #ifdef LOG_DMA2 - //else - { - LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 3, DMASrc[proc][3], DMADst[proc][3], (val&(1<<25))?"ON":"OFF"); - } - #endif - } - return; - //case REG_AUXSPICNT : execute = FALSE; - default : - T1WriteWord(MMU.MMU_MEM[proc][0x40], adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); - return; - } - } - T1WriteWord(MMU.MMU_MEM[proc][(adr>>20)&0xFF], adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); -} - - -void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val) -{ -#ifdef INTERNAL_DTCM_WRITE - if((proc==ARMCPU_ARM9)&((adr&(~0x3FFF))==MMU.DTCMRegion)) - { - T1WriteLong(ARM9Mem.ARM9_DTCM, adr & 0x3FFF, val); - return ; - } -#endif - - // CFlash writing, Mic - if ((adr>=0x9000000)&&(adr<0x9900000)) { - cflash_write(adr,val); - return; - } - - adr &= 0x0FFFFFFF; - - // This is bad, remove it - if(proc == ARMCPU_ARM7) - { - if ((adr>=0x04000400)&&(adr<0x0400051D)) - { - SPU_WriteLong(adr, val); - return; - } - } - - if (adr & 0xFF800000 == 0x04800000) { - /* access to non regular hw registers */ - /* return to not overwrite valid data */ - return ; - } ; - - - if((adr>>24)==4) - { - if (adr >= 0x04000400 && adr < 0x04000440) - { - // Geometry commands (aka Dislay Lists) - Parameters:X - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x400>>2] = val; -#if VIO2SF_GPU_ENABLE - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_CallList(val); - } -#endif - } - else - switch(adr) - { -#if VIO2SF_GPU_ENABLE - // Alpha test reference value - Parameters:1 - case 0x04000340: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x340>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_AlphaFunc(val); - } - return; - } - // Clear background color setup - Parameters:2 - case 0x04000350: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x350>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_ClearColor(val); - } - return; - } - // Clear background depth setup - Parameters:2 - case 0x04000354: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x354>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_ClearDepth(val); - } - return; - } - // Fog Color - Parameters:4b - case 0x04000358: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x358>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_FogColor(val); - } - return; - } - case 0x0400035C: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x35C>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_FogOffset(val); - } - return; - } - // Matrix mode - Parameters:1 - case 0x04000440: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x440>>2] = val; - - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_MatrixMode(val); - } - return; - } - // Push matrix - Parameters:0 - case 0x04000444: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x444>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_PushMatrix(); - } - return; - } - // Pop matrix/es - Parameters:1 - case 0x04000448: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x448>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_PopMatrix(val); - } - return; - } - // Store matrix in the stack - Parameters:1 - case 0x0400044C: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x44C>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_StoreMatrix(val); - } - return; - } - // Restore matrix from the stack - Parameters:1 - case 0x04000450: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x450>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_RestoreMatrix(val); - } - return; - } - // Load Identity matrix - Parameters:0 - case 0x04000454: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x454>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_LoadIdentity(); - } - return; - } - // Load 4x4 matrix - Parameters:16 - case 0x04000458: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x458>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_LoadMatrix4x4(val); - } - return; - } - // Load 4x3 matrix - Parameters:12 - case 0x0400045C: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x45C>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_LoadMatrix4x3(val); - } - return; - } - // Multiply 4x4 matrix - Parameters:16 - case 0x04000460: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x460>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_MultMatrix4x4(val); - } - return; - } - // Multiply 4x4 matrix - Parameters:12 - case 0x04000464: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x464>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_MultMatrix4x3(val); - } - return; - } - // Multiply 3x3 matrix - Parameters:9 - case 0x04000468 : - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x468>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_MultMatrix3x3(val); - } - return; - } - // Multiply current matrix by scaling matrix - Parameters:3 - case 0x0400046C: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x46C>>2] = val; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_Scale(val); - } - return; - } - // Multiply current matrix by translation matrix - Parameters:3 - case 0x04000470: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x470>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Translate(val); - } - return; - } - // Set vertex color - Parameters:1 - case 0x04000480: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x480>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Color3b(val); - } - return; - } - // Set vertex normal - Parameters:1 - case 0x04000484: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x484>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Normal(val); - } - return; - } - // Set vertex texture coordinate - Parameters:1 - case 0x04000488: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x488>>2] = val; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_TexCoord(val); - } - return; - } - // Set vertex position 16b/coordinate - Parameters:2 - case 0x0400048C: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x48C>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Vertex16b(val); - } - return; - } - // Set vertex position 10b/coordinate - Parameters:1 - case 0x04000490: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x490>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Vertex10b(val); - } - return; - } - // Set vertex XY position - Parameters:1 - case 0x04000494: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x494>>2] = val; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_Vertex3_cord(0,1,val); - } - return; - } - // Set vertex XZ position - Parameters:1 - case 0x04000498: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x498>>2] = val; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_Vertex3_cord(0,2,val); - } - return; - } - // Set vertex YZ position - Parameters:1 - case 0x0400049C: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x49C>>2] = val; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_Vertex3_cord(1,2,val); - } - return; - } - // Set vertex difference position (offset from the last vertex) - Parameters:1 - case 0x040004A0: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4A0>>2] = val; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_Vertex_rel (val); - } - return; - } - // Set polygon attributes - Parameters:1 - case 0x040004A4: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4A4>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_PolygonAttrib(val); - } - return; - } - // Set texture parameteres - Parameters:1 - case 0x040004A8: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4A8>>2] = val; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_TexImage(val); - } - return; - } - // Set palette base address - Parameters:1 - case 0x040004AC: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4AC>>2] = val&0x1FFF; - if(proc==ARMCPU_ARM9) - { - gpu3D->NDS_3D_TexPalette(val&0x1FFFF); - } - return; - } - // Set material diffuse/ambient parameters - Parameters:1 - case 0x040004C0: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4C0>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Material0 (val); - } - return; - } - // Set material reflection/emission parameters - Parameters:1 - case 0x040004C4: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4C4>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Material1 (val); - } - return; - } - // Light direction vector - Parameters:1 - case 0x040004C8: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4C8>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_LightDirection (val); - } - return; - } - // Light color - Parameters:1 - case 0x040004CC: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4CC>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_LightColor(val); - } - return; - } - // Material Shininess - Parameters:32 - case 0x040004D0: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x4D0>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Shininess(val); - } - return; - } - // Begin vertex list - Parameters:1 - case 0x04000500: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x500>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Begin(val); - } - return; - } - // End vertex list - Parameters:0 - case 0x04000504: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x504>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_End(); - } - return; - } - // Swap rendering engine buffers - Parameters:1 - case 0x04000540: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x540>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_Flush(val); - } - return; - } - // Set viewport coordinates - Parameters:1 - case 0x04000580: - { - ((u32 *)(MMU.MMU_MEM[proc][0x40]))[0x580>>2] = val; - if(proc == ARMCPU_ARM9) - { - gpu3D->NDS_3D_ViewPort(val); - } - return; - } -#endif - - case REG_DISPA_WININ: - { - if(proc == ARMCPU_ARM9) - { - GPU_setWININ (MainScreen.gpu, val & 0xFFFF) ; - GPU_setWINOUT16 (MainScreen.gpu, (val >> 16) & 0xFFFF) ; - } - break; - } - case REG_DISPB_WININ: - { - if(proc == ARMCPU_ARM9) - { - GPU_setWININ (SubScreen.gpu, val & 0xFFFF) ; - GPU_setWINOUT16 (SubScreen.gpu, (val >> 16) & 0xFFFF) ; - } - break; - } - - case REG_DISPA_BLDCNT: - { - if (proc == ARMCPU_ARM9) - { - GPU_setBLDCNT (MainScreen.gpu,val&0xffff); - GPU_setBLDALPHA (MainScreen.gpu,val>>16); - } - break; - } - case REG_DISPB_BLDCNT: - { - if (proc == ARMCPU_ARM9) - { - GPU_setBLDCNT (SubScreen.gpu,val&0xffff); - GPU_setBLDALPHA (SubScreen.gpu,val>>16); - } - break; - } -/* - // Commented out, as this doesn't use the plug-in system, neither works - case cmd_3D_MTX_MODE // 0x04000440 : - if (proc == ARMCPU_ARM9) gl_MTX_MODE(val); - return; - case cmd_3D_MTX_PUSH // 0x04000444 : - case cmd_3D_MTX_POP // 0x04000448 : - case cmd_3D_MTX_STORE // 0x0400044C : - case cmd_3D_MTX_RESTORE // 0x04000450 : - if (proc == ARMCPU_ARM9) gl_print_cmd(adr); - return; - case cmd_3D_MTX_IDENTITY // 0x04000454 : - if (proc == ARMCPU_ARM9) gl_MTX_IDENTITY(); - return; - case cmd_3D_MTX_LOAD_4x4 // 0x04000458 : - if (proc == ARMCPU_ARM9) gl_MTX_LOAD_4x4(val); - return; - case cmd_3D_MTX_LOAD_4x3 // 0x0400045C : - if (proc == ARMCPU_ARM9) gl_MTX_LOAD_4x3(val); - return; - case cmd_3D_MTX_MULT_4x4 // 0x04000460 : - if (proc == ARMCPU_ARM9) gl_MTX_MULT_4x4(val); - return; - case cmd_3D_MTX_MULT_4x3 // 0x04000464 : - if (proc == ARMCPU_ARM9) gl_MTX_MULT_4x3(val); - return; - case cmd_3D_MTX_MULT_3x3 // 0x04000468 : - if (proc == ARMCPU_ARM9) gl_MTX_MULT_3x3(val); - return; - case cmd_3D_MTX_SCALE // 0x0400046C : - case cmd_3D_MTX_TRANS // 0x04000470 : - case cmd_3D_COLOR // 0x04000480 : - case cmd_3D_NORMA // 0x04000484 : - if (proc == ARMCPU_ARM9) gl_print_cmd(adr); - return; - case cmd_3D_TEXCOORD // 0x04000488 : - if (proc == ARMCPU_ARM9) gl_TEXCOORD(val); - return; - case cmd_3D_VTX_16 // 0x0400048C : - if (proc == ARMCPU_ARM9) gl_VTX_16(val); - return; - case cmd_3D_VTX_10 // 0x04000490 : - if (proc == ARMCPU_ARM9) gl_VTX_10(val); - return; - case cmd_3D_VTX_XY // 0x04000494 : - if (proc == ARMCPU_ARM9) gl_VTX_XY(val); - return; - case cmd_3D_VTX_XZ // 0x04000498 : - if (proc == ARMCPU_ARM9) gl_VTX_XZ(val); - return; - case cmd_3D_VTX_YZ // 0x0400049C : - if (proc == ARMCPU_ARM9) gl_VTX_YZ(val); - return; - case cmd_3D_VTX_DIFF // 0x040004A0 : - if (proc == ARMCPU_ARM9) gl_VTX_DIFF(val); - return; - case cmd_3D_POLYGON_ATTR // 0x040004A4 : - case cmd_3D_TEXIMAGE_PARAM // 0x040004A8 : - case cmd_3D_PLTT_BASE // 0x040004AC : - case cmd_3D_DIF_AMB // 0x040004C0 : - case cmd_3D_SPE_EMI // 0x040004C4 : - case cmd_3D_LIGHT_VECTOR // 0x040004C8 : - case cmd_3D_LIGHT_COLOR // 0x040004CC : - case cmd_3D_SHININESS // 0x040004D0 : - if (proc == ARMCPU_ARM9) gl_print_cmd(adr); - return; - case cmd_3D_BEGIN_VTXS // 0x04000500 : - if (proc == ARMCPU_ARM9) gl_VTX_begin(val); - return; - case cmd_3D_END_VTXS // 0x04000504 : - if (proc == ARMCPU_ARM9) gl_VTX_end(); - return; - case cmd_3D_SWAP_BUFFERS // 0x04000540 : - case cmd_3D_VIEWPORT // 0x04000580 : - case cmd_3D_BOX_TEST // 0x040005C0 : - case cmd_3D_POS_TEST // 0x040005C4 : - case cmd_3D_VEC_TEST // 0x040005C8 : - if (proc == ARMCPU_ARM9) gl_print_cmd(adr); - return; -*/ - case REG_DISPA_DISPCNT : - if(proc == ARMCPU_ARM9) GPU_setVideoProp(MainScreen.gpu, val); - - //GPULOG("MAIN INIT 32B %08X\r\n", val); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0, val); - return; - - case REG_DISPB_DISPCNT : - if (proc == ARMCPU_ARM9) GPU_setVideoProp(SubScreen.gpu, val); - //GPULOG("SUB INIT 32B %08X\r\n", val); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x1000, val); - return; - case REG_VRAMCNTA: - case REG_VRAMCNTE: - MMU_write8(proc,adr,val & 0xFF) ; - MMU_write8(proc,adr+1,val >> 8) ; - MMU_write8(proc,adr+2,val >> 16) ; - MMU_write8(proc,adr+3,val >> 24) ; - return ; - case REG_VRAMCNTI: - MMU_write8(proc,adr,val & 0xFF) ; - return ; - - case REG_IME : { - u32 old_val = MMU.reg_IME[proc]; - u32 new_val = val & 1; - MMU.reg_IME[proc] = new_val; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x208, val); - if ( new_val && old_val != new_val) { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[proc] & MMU.reg_IF[proc]) { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } - return; - } - - case REG_IE : - MMU.reg_IE[proc] = val; - if ( MMU.reg_IME[proc]) { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[proc] & MMU.reg_IF[proc]) { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } - return; - - case REG_IF : - MMU.reg_IF[proc] &= (~val); - return; - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - MMU.timerReload[proc][(adr>>2)&0x3] = (u16)val; - if(val&0x800000) - { - MMU.timer[proc][(adr>>2)&0x3] = MMU.timerReload[proc][(adr>>2)&0x3]; - } - MMU.timerON[proc][(adr>>2)&0x3] = val & 0x800000; - switch((val>>16)&7) - { - case 0 : - MMU.timerMODE[proc][(adr>>2)&0x3] = 0+1;//proc; - break; - case 1 : - MMU.timerMODE[proc][(adr>>2)&0x3] = 6+1;//proc; - break; - case 2 : - MMU.timerMODE[proc][(adr>>2)&0x3] = 8+1;//proc; - break; - case 3 : - MMU.timerMODE[proc][(adr>>2)&0x3] = 10+1;//proc; - break; - default : - MMU.timerMODE[proc][(adr>>2)&0x3] = 0xFFFF; - break; - } - if(!(val & 0x800000)) - { - MMU.timerRUN[proc][(adr>>2)&0x3] = FALSE; - } - T1WriteLong(MMU.MMU_MEM[proc][0x40], adr & 0xFFF, val); - return; - case REG_DIVDENOM : - { - u16 cnt; - s64 num = 0; - s64 den = 1; - s64 res; - s64 mod; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x298, val); - cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x280); - switch(cnt&3) - { - case 0: - { - num = (s64) (s32) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x290); - den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x298); - } - break; - case 1: - { - num = (s64) T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x290); - den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x298); - } - break; - case 2: - { - return; - } - break; - default: - break; - } - if(den==0) - { - res = 0; - mod = 0; - cnt |= 0x4000; - cnt &= 0x7FFF; - } - else - { - res = num / den; - mod = num % den; - cnt &= 0x3FFF; - } - DIVLOG("BOUT1 %08X%08X / %08X%08X = %08X%08X\r\n", (u32)(num>>32), (u32)num, - (u32)(den>>32), (u32)den, - (u32)(res>>32), (u32)res); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A0, (u32) res); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A4, (u32) (res >> 32)); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A8, (u32) mod); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2AC, (u32) (mod >> 32)); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x280, cnt); - } - return; - case REG_DIVDENOM+4 : - { - u16 cnt; - s64 num = 0; - s64 den = 1; - s64 res; - s64 mod; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x29C, val); - cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x280); - switch(cnt&3) - { - case 0: - { - return; - } - break; - case 1: - { - return; - } - break; - case 2: - { - num = (s64) T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x290); - den = (s64) T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x298); - } - break; - default: - break; - } - if(den==0) - { - res = 0; - mod = 0; - cnt |= 0x4000; - cnt &= 0x7FFF; - } - else - { - res = num / den; - mod = num % den; - cnt &= 0x3FFF; - } - DIVLOG("BOUT2 %08X%08X / %08X%08X = %08X%08X\r\n", (u32)(num>>32), (u32)num, - (u32)(den>>32), (u32)den, - (u32)(res>>32), (u32)res); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A0, (u32) res); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A4, (u32) (res >> 32)); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A8, (u32) mod); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2AC, (u32) (mod >> 32)); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x280, cnt); - } - return; - case REG_SQRTPARAM : - { - u16 cnt; - u64 v = 1; - //execute = FALSE; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B8, val); - cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x2B0); - switch(cnt&1) - { - case 0: - v = (u64) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x2B8); - break; - case 1: - return; - } - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B4, (u32) sqrt((s64)v)); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B0, cnt & 0x7FFF); - SQRTLOG("BOUT1 sqrt(%08X%08X) = %08X\r\n", (u32)(v>>32), (u32)v, - T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x2B4)); - } - return; - case REG_SQRTPARAM+4 : - { - u16 cnt; - u64 v = 1; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2BC, val); - cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x2B0); - switch(cnt&1) - { - case 0: - return; - //break; - case 1: - v = T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x2B8); - break; - } - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B4, (u32) sqrt((s64)v)); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B0, cnt & 0x7FFF); - SQRTLOG("BOUT2 sqrt(%08X%08X) = %08X\r\n", (u32)(v>>32), (u32)v, - T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x2B4)); - } - return; - case REG_IPCSYNC : - { - //execute=FALSE; - u32 remote = (proc+1)&1; - u32 IPCSYNC_remote = T1ReadLong(MMU.MMU_MEM[remote][0x40], 0x180); - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x180, (val&0xFFF0)|((IPCSYNC_remote>>8)&0xF)); - T1WriteLong(MMU.MMU_MEM[remote][0x40], 0x180, (IPCSYNC_remote&0xFFF0)|((val>>8)&0xF)); - MMU.reg_IF[remote] |= ((IPCSYNC_remote & (1<<14))<<2) & ((val & (1<<13))<<3);// & (MMU.reg_IME[remote] << 16);// & (MMU.reg_IE[remote] & (1<<16));// - } - return; - case REG_IPCFIFOCNT : - { - u32 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184) ; - u32 cnt_r = T1ReadWord(MMU.MMU_MEM[(proc+1) & 1][0x40], 0x184) ; - if ((val & 0x8000) && !(cnt_l & 0x8000)) - { - /* this is the first init, the other side didnt init yet */ - /* so do a complete init */ - FIFOInit(MMU.fifos + (IPCFIFO+proc)); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184,0x8101) ; - /* and then handle it as usual */ - } - if(val & 0x4008) - { - FIFOInit(MMU.fifos + (IPCFIFO+((proc+1)&1))); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, (cnt_l & 0x0301) | (val & 0x8404) | 1); - T1WriteWord(MMU.MMU_MEM[proc^1][0x40], 0x184, (cnt_r & 0xC507) | 0x100); - MMU.reg_IF[proc] |= ((val & 4)<<15);// & (MMU.reg_IME[proc]<<17);// & (MMU.reg_IE[proc]&0x20000);// - return; - } - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, val & 0xBFF4); - //execute = FALSE; - return; - } - case REG_IPCFIFOSEND : - { - u16 IPCFIFO_CNT = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); - if(IPCFIFO_CNT&0x8000) - { - //if(val==43) execute = FALSE; - u32 remote = (proc+1)&1; - u32 fifonum = IPCFIFO+remote; - u16 IPCFIFO_CNT_remote; - FIFOAdd(MMU.fifos + fifonum, val); - IPCFIFO_CNT = (IPCFIFO_CNT & 0xFFFC) | (MMU.fifos[fifonum].full<<1); - IPCFIFO_CNT_remote = T1ReadWord(MMU.MMU_MEM[remote][0x40], 0x184); - IPCFIFO_CNT_remote = (IPCFIFO_CNT_remote & 0xFCFF) | (MMU.fifos[fifonum].full<<10); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, IPCFIFO_CNT); - T1WriteWord(MMU.MMU_MEM[remote][0x40], 0x184, IPCFIFO_CNT_remote); - MMU.reg_IF[remote] |= ((IPCFIFO_CNT_remote & (1<<10))<<8);// & (MMU.reg_IME[remote] << 18);// & (MMU.reg_IE[remote] & 0x40000);// - //execute = FALSE; - } - } - return; - case REG_DMA0CNTL : - //LOG("32 bit dma0 %04X\r\n", val); - DMASrc[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB0); - DMADst[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB4); - MMU.DMAStartTime[proc][0] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); - MMU.DMACrt[proc][0] = val; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xB8, val); - if( MMU.DMAStartTime[proc][0] == 0 || - MMU.DMAStartTime[proc][0] == 7) // Start Immediately - MMU_doDMA(proc, 0); - #ifdef LOG_DMA2 - else - { - LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 0, DMASrc[proc][0], DMADst[proc][0], 0, ((MMU.DMACrt[proc][0]>>27)&7)); - } - #endif - //execute = FALSE; - return; - case REG_DMA1CNTL: - //LOG("32 bit dma1 %04X\r\n", val); - DMASrc[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xBC); - DMADst[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC0); - MMU.DMAStartTime[proc][1] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); - MMU.DMACrt[proc][1] = val; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xC4, val); - if(MMU.DMAStartTime[proc][1] == 0 || - MMU.DMAStartTime[proc][1] == 7) // Start Immediately - MMU_doDMA(proc, 1); - #ifdef LOG_DMA2 - else - { - LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 1, DMASrc[proc][1], DMADst[proc][1], 0, ((MMU.DMACrt[proc][1]>>27)&7)); - } - #endif - return; - case REG_DMA2CNTL : - //LOG("32 bit dma2 %04X\r\n", val); - DMASrc[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC8); - DMADst[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xCC); - MMU.DMAStartTime[proc][2] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); - MMU.DMACrt[proc][2] = val; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xD0, val); - if(MMU.DMAStartTime[proc][2] == 0 || - MMU.DMAStartTime[proc][2] == 7) // Start Immediately - MMU_doDMA(proc, 2); - #ifdef LOG_DMA2 - else - { - LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 2, DMASrc[proc][2], DMADst[proc][2], 0, ((MMU.DMACrt[proc][2]>>27)&7)); - } - #endif - return; - case 0x040000DC : - //LOG("32 bit dma3 %04X\r\n", val); - DMASrc[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD4); - DMADst[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD8); - MMU.DMAStartTime[proc][3] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); - MMU.DMACrt[proc][3] = val; - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xDC, val); - if( MMU.DMAStartTime[proc][3] == 0 || - MMU.DMAStartTime[proc][3] == 7) // Start Immediately - MMU_doDMA(proc, 3); - #ifdef LOG_DMA2 - else - { - LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 3, DMASrc[proc][3], DMADst[proc][3], 0, ((MMU.DMACrt[proc][3]>>27)&7)); - } - #endif - return; - case REG_GCROMCTRL : - { - int i; - - if(MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT) == 0xB7) - { - MMU.dscard[proc].adress = (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+1) << 24) | (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+2) << 16) | (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+3) << 8) | (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+4)); - MMU.dscard[proc].transfer_count = 0x80;// * ((val>>24)&7)); - } - else if (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT) == 0xB8) - { - // Get ROM chip ID - val |= 0x800000; // Data-Word Status - T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, val); - MMU.dscard[proc].adress = 0; - } - else - { - LOG("CARD command: %02X\n", MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT)); - } - - //CARDLOG("%08X : %08X %08X\r\n", adr, val, adresse[proc]); - val |= 0x00800000; - - if(MMU.dscard[proc].adress == 0) - { - val &= ~0x80000000; - T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, val); - return; - } - T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, val); - - /* launch DMA if start flag was set to "DS Cart" */ - if(proc == ARMCPU_ARM7) i = 2; - else i = 5; - - if(proc == ARMCPU_ARM9 && MMU.DMAStartTime[proc][0] == i) /* dma0/1 on arm7 can't start on ds cart event */ - { - MMU_doDMA(proc, 0); - return; - } - else if(proc == ARMCPU_ARM9 && MMU.DMAStartTime[proc][1] == i) - { - MMU_doDMA(proc, 1); - return; - } - else if(MMU.DMAStartTime[proc][2] == i) - { - MMU_doDMA(proc, 2); - return; - } - else if(MMU.DMAStartTime[proc][3] == i) - { - MMU_doDMA(proc, 3); - return; - } - return; - - } - return; - case REG_DISPA_DISPCAPCNT : - if(proc == ARMCPU_ARM9) - { - GPU_set_DISPCAPCNT(MainScreen.gpu,val); - T1WriteLong(ARM9Mem.ARM9_REG, 0x64, val); - } - return; - - case REG_DISPA_BG0CNT : - if (proc == ARMCPU_ARM9) - { - GPU_setBGProp(MainScreen.gpu, 0, (val&0xFFFF)); - GPU_setBGProp(MainScreen.gpu, 1, (val>>16)); - } - //if((val>>16)==0x400) execute = FALSE; - T1WriteLong(ARM9Mem.ARM9_REG, 8, val); - return; - case REG_DISPA_BG2CNT : - if (proc == ARMCPU_ARM9) - { - GPU_setBGProp(MainScreen.gpu, 2, (val&0xFFFF)); - GPU_setBGProp(MainScreen.gpu, 3, (val>>16)); - } - T1WriteLong(ARM9Mem.ARM9_REG, 0xC, val); - return; - case REG_DISPB_BG0CNT : - if (proc == ARMCPU_ARM9) - { - GPU_setBGProp(SubScreen.gpu, 0, (val&0xFFFF)); - GPU_setBGProp(SubScreen.gpu, 1, (val>>16)); - } - T1WriteLong(ARM9Mem.ARM9_REG, 0x1008, val); - return; - case REG_DISPB_BG2CNT : - if (proc == ARMCPU_ARM9) - { - GPU_setBGProp(SubScreen.gpu, 2, (val&0xFFFF)); - GPU_setBGProp(SubScreen.gpu, 3, (val>>16)); - } - T1WriteLong(ARM9Mem.ARM9_REG, 0x100C, val); - return; - case REG_DISPA_DISPMMEMFIFO: - { - // NOTE: right now, the capture unit is not taken into account, - // I don't know is it should be handled here or - - FIFOAdd(MMU.fifos + MAIN_MEMORY_DISP_FIFO, val); - break; - } - //case 0x21FDFF0 : if(val==0) execute = FALSE; - //case 0x21FDFB0 : if(val==0) execute = FALSE; - default : - T1WriteLong(MMU.MMU_MEM[proc][0x40], adr & MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); - return; - } - } - T1WriteLong(MMU.MMU_MEM[proc][(adr>>20)&0xFF], adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); -} - - -void FASTCALL MMU_doDMA(u32 proc, u32 num) -{ - u32 src = DMASrc[proc][num]; - u32 dst = DMADst[proc][num]; - u32 taille; - - if(src==dst) - { - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xB8 + (0xC*num), T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB8 + (0xC*num)) & 0x7FFFFFFF); - return; - } - - if((!(MMU.DMACrt[proc][num]&(1<<31)))&&(!(MMU.DMACrt[proc][num]&(1<<25)))) - { /* not enabled and not to be repeated */ - MMU.DMAStartTime[proc][num] = 0; - MMU.DMACycle[proc][num] = 0; - //MMU.DMAing[proc][num] = FALSE; - return; - } - - - /* word count */ - taille = (MMU.DMACrt[proc][num]&0xFFFF); - - // If we are in "Main memory display" mode just copy an entire - // screen (256x192 pixels). - // Reference: http://nocash.emubase.de/gbatek.htm#dsvideocaptureandmainmemorydisplaymode - // (under DISP_MMEM_FIFO) - if ((MMU.DMAStartTime[proc][num]==4) && // Must be in main memory display mode - (taille==4) && // Word must be 4 - (((MMU.DMACrt[proc][num]>>26)&1) == 1)) // Transfer mode must be 32bit wide - taille = 256*192/2; - - if(MMU.DMAStartTime[proc][num] == 5) - taille *= 0x80; - - MMU.DMACycle[proc][num] = taille + nds.cycles; - MMU.DMAing[proc][num] = TRUE; - - DMALOG("proc %d, dma %d src %08X dst %08X start %d taille %d repeat %s %08X\r\n", - proc, num, src, dst, MMU.DMAStartTime[proc][num], taille, - (MMU.DMACrt[proc][num]&(1<<25))?"on":"off",MMU.DMACrt[proc][num]); - - if(!(MMU.DMACrt[proc][num]&(1<<25))) - MMU.DMAStartTime[proc][num] = 0; - - // transfer - { - u32 i=0; - // 32 bit or 16 bit transfer ? - int sz = ((MMU.DMACrt[proc][num]>>26)&1)? 4 : 2; - int dstinc,srcinc; - int u=(MMU.DMACrt[proc][num]>>21); - switch(u & 0x3) { - case 0 : dstinc = sz; break; - case 1 : dstinc = -sz; break; - case 2 : dstinc = 0; break; - case 3 : dstinc = sz; break; //reload - } - switch((u >> 2)&0x3) { - case 0 : srcinc = sz; break; - case 1 : srcinc = -sz; break; - case 2 : srcinc = 0; break; - case 3 : // reserved - return; - } - if ((MMU.DMACrt[proc][num]>>26)&1) - for(; i < taille; ++i) - { - MMU_write32(proc, dst, MMU_read32(proc, src)); - dst += dstinc; - src += srcinc; - } - else - for(; i < taille; ++i) - { - MMU_write16(proc, dst, MMU_read16(proc, src)); - dst += dstinc; - src += srcinc; - } - } -} - -#ifdef MMU_ENABLE_ACL - -INLINE void check_access(u32 adr, u32 access) { - /* every other mode: sys */ - access |= 1; - if ((NDS_ARM9.CPSR.val & 0x1F) == 0x10) { - /* is user mode access */ - access ^= 1 ; - } - if (armcp15_isAccessAllowed((armcp15_t *)NDS_ARM9.coproc[15],adr,access)==FALSE) { - execute = FALSE ; - } -} -INLINE void check_access_write(u32 adr) { - u32 access = CP15_ACCESS_WRITE; - check_access(adr, access) -} - -u8 FASTCALL MMU_read8_acl(u32 proc, u32 adr, u32 access) -{ - /* on arm9 we need to check the MPU regions */ - if (proc == ARMCPU_ARM9) - check_access(u32 adr, u32 access); - return MMU_read8(proc,adr); -} -u16 FASTCALL MMU_read16_acl(u32 proc, u32 adr, u32 access) -{ - /* on arm9 we need to check the MPU regions */ - if (proc == ARMCPU_ARM9) - check_access(u32 adr, u32 access); - return MMU_read16(proc,adr); -} -u32 FASTCALL MMU_read32_acl(u32 proc, u32 adr, u32 access) -{ - /* on arm9 we need to check the MPU regions */ - if (proc == ARMCPU_ARM9) - check_access(u32 adr, u32 access); - return MMU_read32(proc,adr); -} - -void FASTCALL MMU_write8_acl(u32 proc, u32 adr, u8 val) -{ - /* check MPU region on ARM9 */ - if (proc == ARMCPU_ARM9) - check_access_write(adr); - MMU_write8(proc,adr,val); -} -void FASTCALL MMU_write16_acl(u32 proc, u32 adr, u16 val) -{ - /* check MPU region on ARM9 */ - if (proc == ARMCPU_ARM9) - check_access_write(adr); - MMU_write16(proc,adr,val) ; -} -void FASTCALL MMU_write32_acl(u32 proc, u32 adr, u32 val) -{ - /* check MPU region on ARM9 */ - if (proc == ARMCPU_ARM9) - check_access_write(adr); - MMU_write32(proc,adr,val) ; -} -#endif - - - -#ifdef PROFILE_MEMORY_ACCESS - -#define PROFILE_PREFETCH 0 -#define PROFILE_READ 1 -#define PROFILE_WRITE 2 - -struct mem_access_profile { - u64 num_accesses; - u32 address_mask; - u32 masked_value; -}; - -#define PROFILE_NUM_MEM_ACCESS_PROFILES 4 - -static u64 profile_num_accesses[2][3]; -static u64 profile_unknown_addresses[2][3]; -static struct mem_access_profile -profile_memory_accesses[2][3][PROFILE_NUM_MEM_ACCESS_PROFILES]; - -static void -setup_profiling( void) { - int i; - - for ( i = 0; i < 2; i++) { - int access_type; - - for ( access_type = 0; access_type < 3; access_type++) { - profile_num_accesses[i][access_type] = 0; - profile_unknown_addresses[i][access_type] = 0; - - /* - * Setup the access testing structures - */ - profile_memory_accesses[i][access_type][0].address_mask = 0x0e000000; - profile_memory_accesses[i][access_type][0].masked_value = 0x00000000; - profile_memory_accesses[i][access_type][0].num_accesses = 0; - - /* main memory */ - profile_memory_accesses[i][access_type][1].address_mask = 0x0f000000; - profile_memory_accesses[i][access_type][1].masked_value = 0x02000000; - profile_memory_accesses[i][access_type][1].num_accesses = 0; - - /* shared memory */ - profile_memory_accesses[i][access_type][2].address_mask = 0x0f800000; - profile_memory_accesses[i][access_type][2].masked_value = 0x03000000; - profile_memory_accesses[i][access_type][2].num_accesses = 0; - - /* arm7 memory */ - profile_memory_accesses[i][access_type][3].address_mask = 0x0f800000; - profile_memory_accesses[i][access_type][3].masked_value = 0x03800000; - profile_memory_accesses[i][access_type][3].num_accesses = 0; - } - } -} - -static void -profile_memory_access( int arm9, u32 adr, int access_type) { - static int first = 1; - int mem_profile; - int address_found = 0; - - if ( first) { - setup_profiling(); - first = 0; - } - - profile_num_accesses[arm9][access_type] += 1; - - for ( mem_profile = 0; - mem_profile < PROFILE_NUM_MEM_ACCESS_PROFILES && - !address_found; - mem_profile++) { - if ( (adr & profile_memory_accesses[arm9][access_type][mem_profile].address_mask) == - profile_memory_accesses[arm9][access_type][mem_profile].masked_value) { - /*printf( "adr %08x mask %08x res %08x expected %08x\n", - adr, - profile_memory_accesses[arm9][access_type][mem_profile].address_mask, - adr & profile_memory_accesses[arm9][access_type][mem_profile].address_mask, - profile_memory_accesses[arm9][access_type][mem_profile].masked_value);*/ - address_found = 1; - profile_memory_accesses[arm9][access_type][mem_profile].num_accesses += 1; - } - } - - if ( !address_found) { - profile_unknown_addresses[arm9][access_type] += 1; - } -} - - -static const char *access_type_strings[] = { - "prefetch", - "read ", - "write " -}; - -void -print_memory_profiling( void) { - int arm; - - printf("------ Memory access profile ------\n"); - - for ( arm = 0; arm < 2; arm++) { - int access_type; - - for ( access_type = 0; access_type < 3; access_type++) { - int mem_profile; - printf("ARM%c: num of %s %lld\n", - arm ? '9' : '7', - access_type_strings[access_type], - profile_num_accesses[arm][access_type]); - - for ( mem_profile = 0; - mem_profile < PROFILE_NUM_MEM_ACCESS_PROFILES; - mem_profile++) { - printf( "address %08x: %lld\n", - profile_memory_accesses[arm][access_type][mem_profile].masked_value, - profile_memory_accesses[arm][access_type][mem_profile].num_accesses); - } - - printf( "unknown addresses %lld\n", - profile_unknown_addresses[arm][access_type]); - - printf( "\n"); - } - } - - printf("------ End of Memory access profile ------\n\n"); -} -#else -void -print_memory_profiling( void) { -} -#endif /* End of PROFILE_MEMORY_ACCESS area */ - -static u16 FASTCALL -arm9_prefetch16( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_PREFETCH); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if((adr & ~0x3FFF) == MMU.DTCMRegion) - { - /* Returns data from DTCM (ARM9 only) */ - return T1ReadWord(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); - } - /* access to main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - return T1ReadWord( MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20) & 0xFF], - adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); - } -#endif - - return MMU_read16( ARMCPU_ARM9, adr); -} -static u32 FASTCALL -arm9_prefetch32( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_PREFETCH); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if((adr & ~0x3FFF) == MMU.DTCMRegion) - { - /* Returns data from DTCM (ARM9 only) */ - return T1ReadLong(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); - } - /* access to main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - return T1ReadLong( MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20) & 0xFF], - adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); - } -#endif - - return MMU_read32( ARMCPU_ARM9, adr); -} - -static u8 FASTCALL -arm9_read8( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_READ); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if( (adr&(~0x3FFF)) == MMU.DTCMRegion) - { - return ARM9Mem.ARM9_DTCM[adr&0x3FFF]; - } - /* access to main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - return MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20) & 0xFF] - [adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]]; - } -#endif - - return MMU_read8( ARMCPU_ARM9, adr); -} -static u16 FASTCALL -arm9_read16( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_READ); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if((adr & ~0x3FFF) == MMU.DTCMRegion) - { - /* Returns data from DTCM (ARM9 only) */ - return T1ReadWord(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); - } - - /* access to main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - return T1ReadWord( MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20) & 0xFF], - adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); - } -#endif - - return MMU_read16( ARMCPU_ARM9, adr); -} -static u32 FASTCALL -arm9_read32( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_READ); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if((adr & ~0x3FFF) == MMU.DTCMRegion) - { - /* Returns data from DTCM (ARM9 only) */ - return T1ReadLong(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); - } - /* access to main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - return T1ReadLong( MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20) & 0xFF], - adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); - } -#endif - - return MMU_read32( ARMCPU_ARM9, adr); -} - - -static void FASTCALL -arm9_write8(void *data, u32 adr, u8 val) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_WRITE); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if( (adr & ~0x3FFF) == MMU.DTCMRegion) - { - /* Writes data in DTCM (ARM9 only) */ - ARM9Mem.ARM9_DTCM[adr&0x3FFF] = val; - return ; - } - /* main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF] - [adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF]] = val; - return; - } -#endif - - MMU_write8( ARMCPU_ARM9, adr, val); -} -static void FASTCALL -arm9_write16(void *data, u32 adr, u16 val) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_WRITE); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if((adr & ~0x3FFF) == MMU.DTCMRegion) - { - /* Writes in DTCM (ARM9 only) */ - T1WriteWord(ARM9Mem.ARM9_DTCM, adr & 0x3FFF, val); - return; - } - /* main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - T1WriteWord( MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF], - adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF], val); - return; - } -#endif - - MMU_write16( ARMCPU_ARM9, adr, val); -} -static void FASTCALL -arm9_write32(void *data, u32 adr, u32 val) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 1, adr, PROFILE_WRITE); -#endif - -#ifdef EARLY_MEMORY_ACCESS - if((adr & ~0x3FFF) == MMU.DTCMRegion) - { - /* Writes in DTCM (ARM9 only) */ - T1WriteLong(ARM9Mem.ARM9_DTCM, adr & 0x3FFF, val); - return; - } - /* main memory */ - if ( (adr & 0x0f000000) == 0x02000000) { - T1WriteLong( MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF], - adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF], val); - return; - } -#endif - - MMU_write32( ARMCPU_ARM9, adr, val); -} - - - - -static u16 FASTCALL -arm7_prefetch16( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_PREFETCH); -#endif - -#ifdef EARLY_MEMORY_ACCESS - /* ARM7 private memory */ - if ( (adr & 0x0f800000) == 0x03800000) { - T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], - adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); - } -#endif - - return MMU_read16( ARMCPU_ARM7, adr); -} -static u32 FASTCALL -arm7_prefetch32( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_PREFETCH); -#endif - -#ifdef EARLY_MEMORY_ACCESS - /* ARM7 private memory */ - if ( (adr & 0x0f800000) == 0x03800000) { - T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], - adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); - } -#endif - - return MMU_read32( ARMCPU_ARM7, adr); -} - -static u8 FASTCALL -arm7_read8( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_READ); -#endif - - return MMU_read8( ARMCPU_ARM7, adr); -} -static u16 FASTCALL -arm7_read16( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_READ); -#endif - - return MMU_read16( ARMCPU_ARM7, adr); -} -static u32 FASTCALL -arm7_read32( void *data, u32 adr) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_READ); -#endif - - return MMU_read32( ARMCPU_ARM7, adr); -} - - -static void FASTCALL -arm7_write8(void *data, u32 adr, u8 val) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_WRITE); -#endif - - MMU_write8( ARMCPU_ARM7, adr, val); -} -static void FASTCALL -arm7_write16(void *data, u32 adr, u16 val) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_WRITE); -#endif - - MMU_write16( ARMCPU_ARM7, adr, val); -} -static void FASTCALL -arm7_write32(void *data, u32 adr, u32 val) { -#ifdef PROFILE_MEMORY_ACCESS - profile_memory_access( 0, adr, PROFILE_WRITE); -#endif - - MMU_write32( ARMCPU_ARM7, adr, val); -} - - - -/* - * the base memory interfaces - */ -struct armcpu_memory_iface arm9_base_memory_iface = { -#ifdef __GNUC__ - .prefetch32 = arm9_prefetch32, - .prefetch16 = arm9_prefetch16, - - .read8 = arm9_read8, - .read16 = arm9_read16, - .read32 = arm9_read32, - - .write8 = arm9_write8, - .write16 = arm9_write16, - .write32 = arm9_write32 -#else - arm9_prefetch32, - arm9_prefetch16, - - arm9_read8, - arm9_read16, - arm9_read32, - - arm9_write8, - arm9_write16, - arm9_write32 -#endif -}; - -struct armcpu_memory_iface arm7_base_memory_iface = { -#ifdef __GNUC__ - .prefetch32 = arm7_prefetch32, - .prefetch16 = arm7_prefetch16, - - .read8 = arm7_read8, - .read16 = arm7_read16, - .read32 = arm7_read32, - - .write8 = arm7_write8, - .write16 = arm7_write16, - .write32 = arm7_write32 -#else - arm7_prefetch32, - arm7_prefetch16, - - arm7_read8, - arm7_read16, - arm7_read32, - - arm7_write8, - arm7_write16, - arm7_write32 -#endif -}; - -/* - * The direct memory interface for the ARM9. - * This avoids the ARM9 protection unit when accessing - * memory. - */ -struct armcpu_memory_iface arm9_direct_memory_iface = { -#ifdef __GNUC__ - /* the prefetch is not used */ - .prefetch32 = NULL, - .prefetch16 = NULL, - - .read8 = arm9_read8, - .read16 = arm9_read16, - .read32 = arm9_read32, - - .write8 = arm9_write8, - .write16 = arm9_write16, - .write32 = arm9_write32 -#else - NULL, - NULL, - - arm9_read8, - arm9_read16, - arm9_read32, - - arm9_write8, - arm9_write16, - arm9_write32 -#endif -}; diff --git a/tools/vio2sf/src/vio2sf/desmume/MMU.h b/tools/vio2sf/src/vio2sf/desmume/MMU.h deleted file mode 100644 index 8cdbacc43..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/MMU.h +++ /dev/null @@ -1,200 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MMU_H -#define MMU_H - -#include "FIFO.h" -#include "dscard.h" - -#include "ARM9.h" -#include "mc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern char szRomPath[512]; -extern char szRomBaseName[512]; - -/* theses macros are designed for reading/writing in memory (m is a pointer to memory, like MMU.MMU_MEM[proc], and a is an adress, like 0x04000000 */ -#define MEM_8(m, a) (((u8*)(m[((a)>>20)&0xff]))[((a)&0xfff)]) - -/* theses ones for reading in rom data */ -#define ROM_8(m, a) (((u8*)(m))[(a)]) - -#define IPCFIFO 0 -#define MAIN_MEMORY_DISP_FIFO 2 - -typedef struct { - //ARM7 mem - u8 ARM7_BIOS[0x4000]; - u8 ARM7_ERAM[0x10000]; - u8 ARM7_REG[0x10000]; - u8 ARM7_WIRAM[0x10000]; - - u8 vram_mode[9]; - u8 vScreen; - - //Shared ram - u8 SWIRAM[0x8000]; - - //Card rom & ram - u8 * CART_ROM; - u8 CART_RAM[0x10000]; - - //Unused ram - u8 UNUSED_RAM[4]; - - u8 * * MMU_MEM[2]; - u32 * MMU_MASK[2]; - - u8 ARM9_RW_MODE; - - FIFO fifos[16]; - - u32 * MMU_WAIT16[2]; - u32 * MMU_WAIT32[2]; - - u32 DTCMRegion; - u32 ITCMRegion; - - u16 timer[2][4]; - s32 timerMODE[2][4]; - u32 timerON[2][4]; - u32 timerRUN[2][4]; - u16 timerReload[2][4]; - - u32 reg_IME[2]; - u32 reg_IE[2]; - u32 reg_IF[2]; - - u32 DMAStartTime[2][4]; - s32 DMACycle[2][4]; - u32 DMACrt[2][4]; - BOOL DMAing[2][4]; - - memory_chip_t fw; - memory_chip_t bupmem; - - nds_dscard dscard[2]; - u32 CheckTimers; - u32 CheckDMAs; - -} MMU_struct; - -extern MMU_struct MMU; - - -struct armcpu_memory_iface { - /** the 32 bit instruction prefetch */ - u32 FASTCALL (*prefetch32)( void *data, u32 adr); - - /** the 16 bit instruction prefetch */ - u16 FASTCALL (*prefetch16)( void *data, u32 adr); - - /** read 8 bit data value */ - u8 FASTCALL (*read8)( void *data, u32 adr); - /** read 16 bit data value */ - u16 FASTCALL (*read16)( void *data, u32 adr); - /** read 32 bit data value */ - u32 FASTCALL (*read32)( void *data, u32 adr); - - /** write 8 bit data value */ - void FASTCALL (*write8)( void *data, u32 adr, u8 val); - /** write 16 bit data value */ - void FASTCALL (*write16)( void *data, u32 adr, u16 val); - /** write 32 bit data value */ - void FASTCALL (*write32)( void *data, u32 adr, u32 val); - - void *data; -}; - - - -static void mmu_select_savetype(int type, int *bmemtype, u32 *bmemsize) { - if (type<0 || type > 5) return; - *bmemtype=save_types[type][0]; - *bmemsize=save_types[type][1]; - mc_realloc(&MMU.bupmem, *bmemtype, *bmemsize); -} - -void MMU_Init(void); -void MMU_DeInit(void); - -void MMU_clearMem( void); - -void MMU_setRom(u8 * rom, u32 mask); -void MMU_unsetRom( void); - - -/** - * Memory reading - */ -u8 FASTCALL MMU_read8(u32 proc, u32 adr); -u16 FASTCALL MMU_read16(u32 proc, u32 adr); -u32 FASTCALL MMU_read32(u32 proc, u32 adr); - -#ifdef MMU_ENABLE_ACL - u8 FASTCALL MMU_read8_acl(u32 proc, u32 adr, u32 access); - u16 FASTCALL MMU_read16_acl(u32 proc, u32 adr, u32 access); - u32 FASTCALL MMU_read32_acl(u32 proc, u32 adr, u32 access); -#else - #define MMU_read8_acl(proc,adr,access) MMU_read8(proc,adr) - #define MMU_read16_acl(proc,adr,access) MMU_read16(proc,adr) - #define MMU_read32_acl(proc,adr,access) MMU_read32(proc,adr) -#endif - -/** - * Memory writing - */ -void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val); -void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val); -void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val); - -#ifdef MMU_ENABLE_ACL - void FASTCALL MMU_write8_acl(u32 proc, u32 adr, u8 val); - void FASTCALL MMU_write16_acl(u32 proc, u32 adr, u16 val); - void FASTCALL MMU_write32_acl(u32 proc, u32 adr, u32 val); -#else - #define MMU_write8_acl MMU_write8 - #define MMU_write16_acl MMU_write16 - #define MMU_write32_acl MMU_write32 -#endif - -void FASTCALL MMU_doDMA(u32 proc, u32 num); - - -/* - * The base ARM memory interfaces - */ -extern struct armcpu_memory_iface arm9_base_memory_iface; -extern struct armcpu_memory_iface arm7_base_memory_iface; -extern struct armcpu_memory_iface arm9_direct_memory_iface; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/NDSSystem.c b/tools/vio2sf/src/vio2sf/desmume/NDSSystem.c deleted file mode 100644 index 65a473ee9..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/NDSSystem.c +++ /dev/null @@ -1,749 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include - -#include "NDSSystem.h" -#include "MMU.h" -//#include "cflash.h" -#include "spu_exports.h" - -//#include "ROMReader.h" - -/* the count of bytes copied from the firmware into memory */ -#define NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT 0x70 - -NDSSystem nds; - -static u32 -calc_CRC16( u32 start, const u8 *data, int count) { - int i,j; - u32 crc = start & 0xffff; - static u16 val[] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 }; - for(i = 0; i < count; i++) - { - crc = crc ^ data[i]; - - for(j = 0; j < 8; j++) { - int do_bit = 0; - - if ( crc & 0x1) - do_bit = 1; - - crc = crc >> 1; - - if ( do_bit) { - crc = crc ^ (val[j] << (7-j)); - } - } - } - return crc; -} - -static int -copy_firmware_user_data( u8 *dest_buffer, const u8 *fw_data) { - /* - * Determine which of the two user settings in the firmware is the current - * and valid one and then copy this into the destination buffer. - * - * The current setting will have a greater count. - * Settings are only valid if its CRC16 is correct. - */ - int user1_valid = 0; - int user2_valid = 0; - u32 user_settings_offset; - u32 fw_crc; - u32 crc; - int copy_good = 0; - - user_settings_offset = fw_data[0x20]; - user_settings_offset |= fw_data[0x21] << 8; - user_settings_offset <<= 3; - - if ( user_settings_offset <= 0x3FE00) { - s32 copy_settings_offset = -1; - - crc = calc_CRC16( 0xffff, &fw_data[user_settings_offset], - NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); - fw_crc = fw_data[user_settings_offset + 0x72]; - fw_crc |= fw_data[user_settings_offset + 0x73] << 8; - if ( crc == fw_crc) { - user1_valid = 1; - } - - crc = calc_CRC16( 0xffff, &fw_data[user_settings_offset + 0x100], - NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); - fw_crc = fw_data[user_settings_offset + 0x100 + 0x72]; - fw_crc |= fw_data[user_settings_offset + 0x100 + 0x73] << 8; - if ( crc == fw_crc) { - user2_valid = 1; - } - - if ( user1_valid) { - if ( user2_valid) { - u16 count1, count2; - - count1 = fw_data[user_settings_offset + 0x70]; - count1 |= fw_data[user_settings_offset + 0x71] << 8; - - count2 = fw_data[user_settings_offset + 0x100 + 0x70]; - count2 |= fw_data[user_settings_offset + 0x100 + 0x71] << 8; - - if ( count2 > count1) { - copy_settings_offset = user_settings_offset + 0x100; - } - else { - copy_settings_offset = user_settings_offset; - } - } - else { - copy_settings_offset = user_settings_offset; - } - } - else if ( user2_valid) { - /* copy the second user settings */ - copy_settings_offset = user_settings_offset + 0x100; - } - - if ( copy_settings_offset > 0) { - memcpy( dest_buffer, &fw_data[copy_settings_offset], - NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); - copy_good = 1; - } - } - - return copy_good; -} - - -#ifdef GDB_STUB -int NDS_Init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface) { -#else -int NDS_Init( void) { -#endif - nds.ARM9Cycle = 0; - nds.ARM7Cycle = 0; - nds.cycles = 0; - MMU_Init(); - nds.nextHBlank = 3168; - nds.VCount = 0; - nds.lignerendu = FALSE; - - if (Screen_Init(GFXCORE_DUMMY) != 0) - return -1; - - #ifdef GDB_STUB - armcpu_new(&NDS_ARM7,1, arm7_mem_if, arm7_ctrl_iface); - armcpu_new(&NDS_ARM9,0, arm9_mem_if, arm9_ctrl_iface); -#else - armcpu_new(&NDS_ARM7,1); - armcpu_new(&NDS_ARM9,0); -#endif - - if (SPU_Init(0, 0) != 0) - return -1; - -#ifdef EXPERIMENTAL_WIFI - WIFI_Init(&wifiMac) ; -#endif - - return 0; -} - -static void armcpu_deinit(armcpu_t *armcpu) -{ - if(armcpu->coproc[15]) - { - free(armcpu->coproc[15]); - armcpu->coproc[15] = 0; - } -} - -void NDS_DeInit(void) { - if(MMU.CART_ROM != MMU.UNUSED_RAM) - NDS_FreeROM(); - - armcpu_deinit(&NDS_ARM7); - armcpu_deinit(&NDS_ARM9); - - nds.nextHBlank = 3168; - SPU_DeInit(); - Screen_DeInit(); - MMU_DeInit(); -} - -BOOL NDS_SetROM(u8 * rom, u32 mask) -{ - MMU_setRom(rom, mask); - - return TRUE; -} - -NDS_header * NDS_getROMHeader(void) -{ - NDS_header * header = malloc(sizeof(NDS_header)); - - memcpy(header->gameTile, MMU.CART_ROM, 12); - memcpy(header->gameCode, MMU.CART_ROM + 12, 4); - header->makerCode = T1ReadWord(MMU.CART_ROM, 16); - header->unitCode = MMU.CART_ROM[18]; - header->deviceCode = MMU.CART_ROM[19]; - header->cardSize = MMU.CART_ROM[20]; - memcpy(header->cardInfo, MMU.CART_ROM + 21, 8); - header->flags = MMU.CART_ROM[29]; - header->ARM9src = T1ReadLong(MMU.CART_ROM, 32); - header->ARM9exe = T1ReadLong(MMU.CART_ROM, 36); - header->ARM9cpy = T1ReadLong(MMU.CART_ROM, 40); - header->ARM9binSize = T1ReadLong(MMU.CART_ROM, 44); - header->ARM7src = T1ReadLong(MMU.CART_ROM, 48); - header->ARM7exe = T1ReadLong(MMU.CART_ROM, 52); - header->ARM7cpy = T1ReadLong(MMU.CART_ROM, 56); - header->ARM7binSize = T1ReadLong(MMU.CART_ROM, 60); - header->FNameTblOff = T1ReadLong(MMU.CART_ROM, 64); - header->FNameTblSize = T1ReadLong(MMU.CART_ROM, 68); - header->FATOff = T1ReadLong(MMU.CART_ROM, 72); - header->FATSize = T1ReadLong(MMU.CART_ROM, 76); - header->ARM9OverlayOff = T1ReadLong(MMU.CART_ROM, 80); - header->ARM9OverlaySize = T1ReadLong(MMU.CART_ROM, 84); - header->ARM7OverlayOff = T1ReadLong(MMU.CART_ROM, 88); - header->ARM7OverlaySize = T1ReadLong(MMU.CART_ROM, 92); - header->unknown2a = T1ReadLong(MMU.CART_ROM, 96); - header->unknown2b = T1ReadLong(MMU.CART_ROM, 100); - header->IconOff = T1ReadLong(MMU.CART_ROM, 104); - header->CRC16 = T1ReadWord(MMU.CART_ROM, 108); - header->ROMtimeout = T1ReadWord(MMU.CART_ROM, 110); - header->ARM9unk = T1ReadLong(MMU.CART_ROM, 112); - header->ARM7unk = T1ReadLong(MMU.CART_ROM, 116); - memcpy(header->unknown3c, MMU.CART_ROM + 120, 8); - header->ROMSize = T1ReadLong(MMU.CART_ROM, 128); - header->HeaderSize = T1ReadLong(MMU.CART_ROM, 132); - memcpy(header->unknown5, MMU.CART_ROM + 136, 56); - memcpy(header->logo, MMU.CART_ROM + 192, 156); - header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348); - header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350); - memcpy(header->reserved, MMU.CART_ROM + 352, 160); - - return header; - - //return (NDS_header *)MMU.CART_ROM; -} - - - -void NDS_FreeROM(void) -{ - if (MMU.CART_ROM != MMU.UNUSED_RAM) - free(MMU.CART_ROM); - MMU_unsetRom(); -// if (MMU.bupmem.fp) -// fclose(MMU.bupmem.fp); -// MMU.bupmem.fp = NULL; -} - - - -void NDS_Reset( void) -{ - BOOL oldexecute=execute; - int i; - u32 src; - u32 dst; - NDS_header * header = NDS_getROMHeader(); - - if (!header) return ; - - execute = FALSE; - - MMU_clearMem(); - - src = header->ARM9src; - dst = header->ARM9cpy; - - for(i = 0; i < (header->ARM9binSize>>2); ++i) - { - MMU_write32(0, dst, T1ReadLong(MMU.CART_ROM, src)); - dst += 4; - src += 4; - } - - src = header->ARM7src; - dst = header->ARM7cpy; - - for(i = 0; i < (header->ARM7binSize>>2); ++i) - { - MMU_write32(1, dst, T1ReadLong(MMU.CART_ROM, src)); - dst += 4; - src += 4; - } - - armcpu_init(&NDS_ARM7, header->ARM7exe); - armcpu_init(&NDS_ARM9, header->ARM9exe); - - nds.ARM9Cycle = 0; - nds.ARM7Cycle = 0; - nds.cycles = 0; - memset(nds.timerCycle, 0, sizeof(s32) * 2 * 4); - memset(nds.timerOver, 0, sizeof(BOOL) * 2 * 4); - nds.nextHBlank = 3168; - nds.VCount = 0; - nds.old = 0; - nds.diff = 0; - nds.lignerendu = FALSE; - nds.touchX = nds.touchY = 0; - - MMU_write16(0, 0x04000130, 0x3FF); - MMU_write16(1, 0x04000130, 0x3FF); - MMU_write8(1, 0x04000136, 0x43); - - /* - * Setup a copy of the firmware user settings in memory. - * (this is what the DS firmware would do). - */ - { - u8 temp_buffer[NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT]; - int fw_index; - - if ( copy_firmware_user_data( temp_buffer, MMU.fw.data)) { - for ( fw_index = 0; fw_index < NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT; fw_index++) { - MMU_write8( 0, 0x027FFC80 + fw_index, temp_buffer[fw_index]); - } - } - } - - // Copy the whole header to Main RAM 0x27FFE00 on startup. - // Reference: http://nocash.emubase.de/gbatek.htm#dscartridgeheader - for (i = 0; i < ((0x170+0x90)/4); i++) - { - MMU_write32 (0, 0x027FFE00+i*4, LE_TO_LOCAL_32(((u32*)MMU.CART_ROM)[i])); - } - - MainScreen.offset = 0; - SubScreen.offset = 192; - - //MMU_write32(0, 0x02007FFC, 0xE92D4030); - - //ARM7 BIOS IRQ HANDLER - MMU_write32(1, 0x00, 0xE25EF002); - MMU_write32(1, 0x04, 0xEAFFFFFE); - MMU_write32(1, 0x18, 0xEA000000); - MMU_write32(1, 0x20, 0xE92D500F); - MMU_write32(1, 0x24, 0xE3A00301); - MMU_write32(1, 0x28, 0xE28FE000); - MMU_write32(1, 0x2C, 0xE510F004); - MMU_write32(1, 0x30, 0xE8BD500F); - MMU_write32(1, 0x34, 0xE25EF004); - - //ARM9 BIOS IRQ HANDLER - MMU_write32(0, 0xFFFF0018, 0xEA000000); - MMU_write32(0, 0xFFFF0020, 0xE92D500F); - MMU_write32(0, 0xFFFF0024, 0xEE190F11); - MMU_write32(0, 0xFFFF0028, 0xE1A00620); - MMU_write32(0, 0xFFFF002C, 0xE1A00600); - MMU_write32(0, 0xFFFF0030, 0xE2800C40); - MMU_write32(0, 0xFFFF0034, 0xE28FE000); - MMU_write32(0, 0xFFFF0038, 0xE510F004); - MMU_write32(0, 0xFFFF003C, 0xE8BD500F); - MMU_write32(0, 0xFFFF0040, 0xE25EF004); - - MMU_write32(0, 0x0000004, 0xE3A0010E); - MMU_write32(0, 0x0000008, 0xE3A01020); -// MMU_write32(0, 0x000000C, 0xE1B02110); - MMU_write32(0, 0x000000C, 0xE1B02040); - MMU_write32(0, 0x0000010, 0xE3B02020); -// MMU_write32(0, 0x0000010, 0xE2100202); - - free(header); - - GPU_Reset(MainScreen.gpu, 0); - GPU_Reset(SubScreen.gpu, 1); - SPU_Reset(); - - execute = oldexecute; -} - -static void dma_check(void) -{ - if((MMU.DMAing[0][0])&&(MMU.DMACycle[0][0]<=nds.cycles)) - { - T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*0), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*0)) & 0x7FFFFFFF); - if((MMU.DMACrt[0][0])&(1<<30)) NDS_makeARM9Int(8); - MMU.DMAing[0][0] = FALSE; - } - - if((MMU.DMAing[0][1])&&(MMU.DMACycle[0][1]<=nds.cycles)) - { - T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*1), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*1)) & 0x7FFFFFFF); - if((MMU.DMACrt[0][1])&(1<<30)) NDS_makeARM9Int(9); - MMU.DMAing[0][1] = FALSE; - } - - if((MMU.DMAing[0][2])&&(MMU.DMACycle[0][2]<=nds.cycles)) - { - T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*2), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*2)) & 0x7FFFFFFF); - if((MMU.DMACrt[0][2])&(1<<30)) NDS_makeARM9Int(10); - MMU.DMAing[0][2] = FALSE; - } - - if((MMU.DMAing[0][3])&&(MMU.DMACycle[0][3]<=nds.cycles)) - { - T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*3), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*3)) & 0x7FFFFFFF); - if((MMU.DMACrt[0][3])&(1<<30)) NDS_makeARM9Int(11); - MMU.DMAing[0][3] = FALSE; - } - - if((MMU.DMAing[1][0])&&(MMU.DMACycle[1][0]<=nds.cycles)) - { - T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*0), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*0)) & 0x7FFFFFFF); - if((MMU.DMACrt[1][0])&(1<<30)) NDS_makeARM7Int(8); - MMU.DMAing[1][0] = FALSE; - } - - if((MMU.DMAing[1][1])&&(MMU.DMACycle[1][1]<=nds.cycles)) - { - T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*1), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*1)) & 0x7FFFFFFF); - if((MMU.DMACrt[1][1])&(1<<30)) NDS_makeARM7Int(9); - MMU.DMAing[1][1] = FALSE; - } - - if((MMU.DMAing[1][2])&&(MMU.DMACycle[1][2]<=nds.cycles)) - { - T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*2), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*2)) & 0x7FFFFFFF); - if((MMU.DMACrt[1][2])&(1<<30)) NDS_makeARM7Int(10); - MMU.DMAing[1][2] = FALSE; - } - - if((MMU.DMAing[1][3])&&(MMU.DMACycle[1][3]<=nds.cycles)) - { - T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*3), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*3)) & 0x7FFFFFFF); - if((MMU.DMACrt[1][3])&(1<<30)) NDS_makeARM7Int(11); - MMU.DMAing[1][3] = FALSE; - } - - if((MMU.reg_IF[0]&MMU.reg_IE[0]) && (MMU.reg_IME[0])) - { -#ifdef GDB_STUB - if ( armcpu_flagIrq( &NDS_ARM9)) -#else - if ( armcpu_irqExeption(&NDS_ARM9)) -#endif - { - nds.ARM9Cycle = nds.cycles; - } - } - - if((MMU.reg_IF[1]&MMU.reg_IE[1]) && (MMU.reg_IME[1])) - { -#ifdef GDB_STUB - if ( armcpu_flagIrq( &NDS_ARM7)) -#else - if ( armcpu_irqExeption(&NDS_ARM7)) -#endif - { - nds.ARM7Cycle = nds.cycles; - } - } - -} - -static void timer_check(void) -{ - int p, t; - for (p = 0; p < 2; p++) - { - for (t = 0; t < 4; t++) - { - nds.timerOver[p][t] = 0; - if(MMU.timerON[p][t]) - { - if(MMU.timerRUN[p][t]) - { - switch(MMU.timerMODE[p][t]) - { - case 0xFFFF : - if(t > 0 && nds.timerOver[p][t - 1]) - { - ++(MMU.timer[p][t]); - nds.timerOver[p][t] = !MMU.timer[p][t]; - if (nds.timerOver[p][t]) - { - if (p == 0) - { - if(T1ReadWord(ARM9Mem.ARM9_REG, 0x102 + (t << 2)) & 0x40) - NDS_makeARM9Int(3 + t); - } - else - { - if(T1ReadWord(MMU.ARM7_REG, 0x102 + (t << 2)) & 0x40) - NDS_makeARM7Int(3 + t); - } - MMU.timer[p][t] = MMU.timerReload[p][t]; - } - } - break; - default : - { - nds.diff = (nds.cycles >> MMU.timerMODE[p][t]) - (nds.timerCycle[p][t] >> MMU.timerMODE[p][t]); - nds.old = MMU.timer[p][t]; - MMU.timer[p][t] += nds.diff; - nds.timerCycle[p][t] += nds.diff << MMU.timerMODE[p][t]; - nds.timerOver[p][t] = nds.old >= MMU.timer[p][t]; - if(nds.timerOver[p][t]) - { - if (p == 0) - { - if(T1ReadWord(ARM9Mem.ARM9_REG, 0x102 + (t << 2)) & 0x40) - NDS_makeARM9Int(3 + t); - } - else - { - if(T1ReadWord(MMU.ARM7_REG, 0x102 + (t << 2)) & 0x40) - NDS_makeARM7Int(3 + t); - } - MMU.timer[p][t] = MMU.timerReload[p][t] + MMU.timer[p][t] - nds.old; - } - } - break; - } - } - else - { - MMU.timerRUN[p][t] = TRUE; - nds.timerCycle[p][t] = nds.cycles; - } - } - } - } -} - -void NDS_exec_hframe(int cpu_clockdown_level_arm9, int cpu_clockdown_level_arm7) -{ - int h; - for (h = 0; h < 2; h++) - { - s32 nb = nds.cycles + (h ? (99 * 12) : (256 * 12)); - - while (nb > nds.ARM9Cycle && !NDS_ARM9.waitIRQ) - nds.ARM9Cycle += armcpu_exec(&NDS_ARM9) << (cpu_clockdown_level_arm9); - if (NDS_ARM9.waitIRQ) nds.ARM9Cycle = nb; - while (nb > nds.ARM7Cycle && !NDS_ARM7.waitIRQ) - nds.ARM7Cycle += armcpu_exec(&NDS_ARM7) << (1 + (cpu_clockdown_level_arm7)); - if (NDS_ARM7.waitIRQ) nds.ARM7Cycle = nb; - nds.cycles = (nds.ARM9Cycle>8)|((vmatch<<1)&(1<<8)))) - { - T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 4); - if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 32) - NDS_makeARM9Int(2); - } - else - T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0xFFFB); - - vmatch = T1ReadWord(MMU.ARM7_REG, 4); - if((nds.VCount==(vmatch>>8)|((vmatch<<1)&(1<<8)))) - { - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 4); - if(T1ReadWord(MMU.ARM7_REG, 4) & 32) - NDS_makeARM7Int(2); - } - else - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFB); - - timer_check(); - dma_check(); - } - } -} - -void NDS_exec_frame(int cpu_clockdown_level_arm9, int cpu_clockdown_level_arm7) -{ - int v; - for (v = 0; v < 263; v++) - { - NDS_exec_hframe(cpu_clockdown_level_arm9, cpu_clockdown_level_arm7); - } -} - diff --git a/tools/vio2sf/src/vio2sf/desmume/NDSSystem.h b/tools/vio2sf/src/vio2sf/desmume/NDSSystem.h deleted file mode 100644 index 1e05c7745..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/NDSSystem.h +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef NDSSYSTEM_H -#define NDSSYSTEM_H - -#include "armcpu.h" -#include "MMU.h" - -#include "GPU.h" - -#include "mem.h" -//#include "wifi.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -extern volatile BOOL execute; -extern BOOL click; - -/* - * The firmware language values - */ -#define NDS_FW_LANG_JAP 0 -#define NDS_FW_LANG_ENG 1 -#define NDS_FW_LANG_FRE 2 -#define NDS_FW_LANG_GER 3 -#define NDS_FW_LANG_ITA 4 -#define NDS_FW_LANG_SPA 5 -#define NDS_FW_LANG_CHI 6 -#define NDS_FW_LANG_RES 7 - - -//#define LOG_ARM9 -//#define LOG_ARM7 - -typedef struct -{ - char gameTile[12]; - char gameCode[4]; - u16 makerCode; - u8 unitCode; - u8 deviceCode; - u8 cardSize; - u8 cardInfo[8]; - u8 flags; - - u32 ARM9src; - u32 ARM9exe; - u32 ARM9cpy; - u32 ARM9binSize; - - u32 ARM7src; - u32 ARM7exe; - u32 ARM7cpy; - u32 ARM7binSize; - - u32 FNameTblOff; - u32 FNameTblSize; - - u32 FATOff; - u32 FATSize; - - u32 ARM9OverlayOff; - u32 ARM9OverlaySize; - u32 ARM7OverlayOff; - u32 ARM7OverlaySize; - - u32 unknown2a; - u32 unknown2b; - - u32 IconOff; - u16 CRC16; - u16 ROMtimeout; - u32 ARM9unk; - u32 ARM7unk; - - u8 unknown3c[8]; - u32 ROMSize; - u32 HeaderSize; - u8 unknown5[56]; - u8 logo[156]; - u16 logoCRC16; - u16 headerCRC16; - u8 reserved[160]; -} NDS_header; - -extern void debug(); - -typedef struct -{ - s32 ARM9Cycle; - s32 ARM7Cycle; - s32 cycles; - s32 timerCycle[2][4]; - BOOL timerOver[2][4]; - s32 nextHBlank; - u32 VCount; - u32 old; - s32 diff; - BOOL lignerendu; - - u16 touchX; - u16 touchY; -} NDSSystem; - -/** /brief A touchscreen calibration point. - */ -struct NDS_fw_touchscreen_cal { - u16 adc_x; - u16 adc_y; - - u8 screen_x; - u8 screen_y; -}; - -/** /brief The type of DS - */ -enum nds_fw_ds_type { - NDS_FW_DS_TYPE_FAT, - NDS_FW_DS_TYPE_LITE -}; - -#define MAX_FW_NICKNAME_LENGTH 10 -#define MAX_FW_MESSAGE_LENGTH 26 - -struct NDS_fw_config_data { - enum nds_fw_ds_type ds_type; - - u8 fav_colour; - u8 birth_month; - u8 birth_day; - - u16 nickname[MAX_FW_NICKNAME_LENGTH]; - u8 nickname_len; - - u16 message[MAX_FW_MESSAGE_LENGTH]; - u8 message_len; - - u8 language; - - /* touchscreen calibration */ - struct NDS_fw_touchscreen_cal touch_cal[2]; -}; - -extern NDSSystem nds; - -#ifdef GDB_STUB -int NDS_Init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface); -#else -int NDS_Init ( void); -#endif - -void NDS_DeInit(void); -void -NDS_FillDefaultFirmwareConfigData( struct NDS_fw_config_data *fw_config); - -BOOL NDS_SetROM(u8 * rom, u32 mask); -NDS_header * NDS_getROMHeader(void); - -void NDS_setTouchPos(u16 x, u16 y); -void NDS_releasTouch(void); - -int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize, - const char *cflash_disk_image_file); -void NDS_FreeROM(void); -void NDS_Reset(void); -int NDS_ImportSave(const char *filename); - -int NDS_WriteBMP(const char *filename); -int NDS_LoadFirmware(const char *filename); -int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings); -u32 -NDS_exec(s32 nb, BOOL force); - - static INLINE void NDS_ARM9HBlankInt(void) - { - if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0x10) - { - MMU.reg_IF[0] |= 2;// & (MMU.reg_IME[0] << 1);// (MMU.reg_IE[0] & (1<<1)); - NDS_ARM9.wIRQ = TRUE; - } - } - - static INLINE void NDS_ARM7HBlankInt(void) - { - if(T1ReadWord(MMU.ARM7_REG, 4) & 0x10) - { - MMU.reg_IF[1] |= 2;// & (MMU.reg_IME[1] << 1);// (MMU.reg_IE[1] & (1<<1)); - NDS_ARM7.wIRQ = TRUE; - } - } - - static INLINE void NDS_ARM9VBlankInt(void) - { - if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0x8) - { - MMU.reg_IF[0] |= 1;// & (MMU.reg_IME[0]);// (MMU.reg_IE[0] & 1); - NDS_ARM9.wIRQ = TRUE; - //execute = FALSE; - /*logcount++;*/ - } - } - - static INLINE void NDS_ARM7VBlankInt(void) - { - if(T1ReadWord(MMU.ARM7_REG, 4) & 0x8) - MMU.reg_IF[1] |= 1;// & (MMU.reg_IME[1]);// (MMU.reg_IE[1] & 1); - NDS_ARM7.wIRQ = TRUE; - //execute = FALSE; - } - - static INLINE void NDS_swapScreen(void) - { - u16 tmp = MainScreen.offset; - MainScreen.offset = SubScreen.offset; - SubScreen.offset = tmp; - } - - - -void NDS_exec_frame(int cpu_clockdown_level_arm9, int cpu_clockdown_level_arm7); -void NDS_exec_hframe(int cpu_clockdown_level_arm9, int cpu_clockdown_level_arm7); - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/tools/vio2sf/src/vio2sf/desmume/SPU.c b/tools/vio2sf/src/vio2sf/desmume/SPU.c deleted file mode 100644 index b9db8a078..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/SPU.c +++ /dev/null @@ -1,951 +0,0 @@ -/* Copyright (C) 2006 Theo Berkau - - Ideas borrowed from Stephane Dallongeville's SCSP core - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include - -#include "ARM9.h" -#include "MMU.h" -#include "SPU.h" -#include "mem.h" - -#include "armcpu.h" - -enum -{ - FORMAT_PCM8 = 0, - FORMAT_PCM16 = 1, - FORMAT_ADPCM = 2, - FORMAT_PSG = 3 -}; - -#define VOL_SHIFT 10 - -typedef struct -{ - int id; - int status; - int format; - u8 *buf8; s16 *buf16; - double pos, inc; - int loopend, looppos; - int loop, length; - s32 adpcm; - int adpcm_pos, adpcm_index; - s32 adpcm_loop; - int adpcm_loop_pos, adpcm_loop_index; - int psg_duty; - int timer; - int volume; - int pan; - int shift; - int repeat, hold; - u32 addr; - s32 volumel; - s32 volumer; - s16 output; -} SChannel; - -typedef struct -{ - s32 *pmixbuf; - s16 *pclipingbuf; - u32 buflen; - SChannel ch[16]; -} SPU_struct; - -static SPU_struct spu = { 0, 0, 0 }; - -static SoundInterface_struct *SNDCore=NULL; -extern SoundInterface_struct *SNDCoreList[]; - -int SPU_ChangeSoundCore(int coreid, int buffersize) -{ - int i; - SPU_DeInit(); - - // Allocate memory for sound buffer - spu.buflen = buffersize * 2; /* stereo */ - spu.pmixbuf = malloc(spu.buflen * sizeof(s32)); - if (!spu.pmixbuf) - { - SPU_DeInit(); - return -1; - } - - spu.pclipingbuf = malloc(spu.buflen * sizeof(s16)); - if (!spu.pclipingbuf) - { - SPU_DeInit(); - return -1; - } - - // So which core do we want? - if (coreid == SNDCORE_DEFAULT) - coreid = 0; // Assume we want the first one - - // Go through core list and find the id - for (i = 0; SNDCoreList[i] != NULL; i++) - { - if (SNDCoreList[i]->id == coreid) - { - // Set to current core - SNDCore = SNDCoreList[i]; - break; - } - } - - if (SNDCore == NULL) - { - SPU_DeInit(); - return -1; - } - - if (SNDCore->Init(spu.buflen) == -1) - { - // Since it failed, instead of it being fatal, we'll just use the dummy - // core instead - SNDCore = &SNDDummy; - } - - return 0; -} -int SPU_Init(int coreid, int buffersize) -{ - SPU_DeInit(); - SPU_Reset(); - return SPU_ChangeSoundCore(coreid, buffersize); -} -void SPU_Pause(int pause) -{ - if(pause) - SNDCore->MuteAudio(); - else - SNDCore->UnMuteAudio(); -} -void SPU_SetVolume(int volume) -{ - if (SNDCore) - SNDCore->SetVolume(volume); -} -void SPU_DeInit(void) -{ - spu.buflen = 0; - if (spu.pmixbuf) - { - free(spu.pmixbuf); - spu.pmixbuf = 0; - } - if (spu.pclipingbuf) - { - free(spu.pclipingbuf); - spu.pclipingbuf = 0; - } - if (SNDCore) - { - SNDCore->DeInit(); - } - SNDCore = &SNDDummy; -} - -static const short g_adpcm_index[16] = { -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 4, 4, 6, 6, 8, 8 }; - -static const int g_adpcm_mult[89] = -{ - 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x0010, 0x0011, - 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, 0x0022, 0x0025, 0x0029, 0x002D, - 0x0032, 0x0037, 0x003C, 0x0042, 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, - 0x0082, 0x008F, 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, - 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292, 0x02D4, 0x031C, - 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, 0x0610, 0x06AB, 0x0756, 0x0812, - 0x08E0, 0x09C3, 0x0ABD, 0x0BD0, 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, - 0x1706, 0x1954, 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, - 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF, -}; - -static const s16 g_psg_duty[8][8] = { - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, +0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, +0x7FFF, +0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF }, - { -0x7FFF, -0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF }, - { -0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF, +0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF }, -}; - - -static void reset_channel(SChannel *ch, int id) -{ - ch->status = 0; - ch->id = id; -} - -void SPU_Reset(void) -{ - int i; - for (i = 0;i < 16; i++) - reset_channel(&spu.ch[i], i); - - for (i = 0x400; i < 0x51D; i++) - T1WriteByte(MMU.ARM7_REG, i, 0); -} -void SPU_KeyOn(int channel) -{ -} - -static INLINE void adjust_channel_timer(SChannel *ch) -{ - ch->inc = (((double)33512000) / (44100 * 2)) / (double)(0x10000 - ch->timer); -} - -static int check_valid(u32 addr, u32 size) -{ - u32 t1, t2; - - if(size > MMU.MMU_MASK[1][(addr >> 20) & 0xff]) return 0; - - t1 = addr; - t2 = (addr + size); - t1 &= MMU.MMU_MASK[1][(addr >> 20) & 0xff]; - t2 &= MMU.MMU_MASK[1][(addr >> 20) & 0xff]; - - if(t2 < t1) return 0; - - return 1; -} - -static void start_channel(SChannel *ch) -{ - - switch(ch->format) - { - case FORMAT_PCM8: - { - u8 *p = MMU.MMU_MEM[1][(ch->addr >> 20) & 0xff]; - u32 ofs = MMU.MMU_MASK[1][(ch->addr >> 20) & 0xff] & ch->addr; - u32 size = ((ch->length + ch->loop) << 2); - if((p != NULL) && check_valid(ch->addr, size)) - { - ch->buf8 = p + ofs; - ch->looppos = ch->loop << 2; - ch->loopend = size; - ch->pos = 0; - ch->status = 1; - } - } - break; - case FORMAT_PCM16: - { - u8 *p = MMU.MMU_MEM[1][(ch->addr >> 20) & 0xff]; - u32 ofs = MMU.MMU_MASK[1][(ch->addr >> 20) & 0xff] & ch->addr; - u32 size = ((ch->length + ch->loop) << 1); - if((p != NULL) && check_valid(ch->addr, size << 1)) - { - ch->buf16 = (s16 *)(p + ofs - (ofs & 1)); - ch->looppos = ch->loop << 1; - ch->loopend = size; - ch->pos = 0; - ch->status = 1; - } - } - break; - case FORMAT_ADPCM: - { - u8 *p = MMU.MMU_MEM[1][(ch->addr >> 20) & 0xff]; - u32 ofs = MMU.MMU_MASK[1][(ch->addr >> 20) & 0xff] & ch->addr; - u32 size = ((ch->length + ch->loop) << 3); - if((p != NULL) && check_valid(ch->addr, size >> 1)) - { - ch->buf8 = p + ofs; -#ifdef WORDS_BIGENDIAN - ch->adpcm = ((s32)(s16)T1ReadWord((u8 *)ch->buf8, 0)) << 3; -#else - ch->adpcm = ((s32)*(s16 *)ch->buf8) << 3; -#endif - ch->adpcm_index = (ch->buf8[2] & 0x7F); - ch->adpcm_pos = 8; - ch->pos = 9; - ch->looppos = ch->loop << 3; - ch->loopend = size; - ch->adpcm_loop_index = -1; - ch->status = 1; - } - } - break; - case FORMAT_PSG: - ch->status = 1; - if(ch->id < 14) - { - ch->pos = 0; - } - else - { - ch->pos = 0x7FFF; - } - break; - } -} - -static void stop_channel(SChannel *ch) -{ - u32 addr = 0x400 + (ch->id << 4) + 3; - ch->status = 0; - T1WriteByte(MMU.ARM7_REG, addr, (u8)(T1ReadByte(MMU.ARM7_REG, addr) & ~0x80)); -} -static void set_channel_volume(SChannel *ch) -{ - s32 vol1 = (T1ReadByte(MMU.ARM7_REG, 0x500) & 0x7F) * ch->volume; - s32 vol2; - vol2 = vol1 * ch->pan; - vol1 = vol1 * (127-ch->pan); - ch->volumel = vol1 >> (21 - VOL_SHIFT + ch->shift); - ch->volumer = vol2 >> (21 - VOL_SHIFT + ch->shift); -} - -void SPU_WriteByte(u32 addr, u8 x) -{ - addr &= 0x00000FFF; - T1WriteByte(MMU.ARM7_REG, addr, x); - - if(addr < 0x500) - { - SChannel *ch; - switch(addr & 0x0F) - { - case 0x0: - ch = spu.ch + (addr >> 4 & 0xF); - ch->volume = (x & 0x7F); - set_channel_volume(ch); - break; - case 0x1: - ch = spu.ch + (addr >> 4 & 0xF); - ch->shift = (x & 0x03); - ch->hold = (x >> 7 & 0x01); - set_channel_volume(ch); - break; - case 0x2: - ch = spu.ch + (addr >> 4 & 0xF); - ch->pan = (x & 0x7F); - set_channel_volume(ch); - break; - case 0x3: - ch = spu.ch + (addr >> 4 & 0xF); - ch->psg_duty = (x & 0x07); - ch->repeat = (x >> 3 & 0x03); - ch->format = (x >> 5 & 0x03); - if(x & 0x80) start_channel(ch); else stop_channel(ch); - break; -#if !DISABLE_XSF_TESTS - case 0x04: - case 0x05: - case 0x06: - case 0x07: - ch = spu.ch + (addr >> 4 & 0xF); - ch->addr = (T1ReadLong(MMU.ARM7_REG, addr & ~3) & 0x07FFFFFF); - break; - case 0x08: - case 0x09: - ch = spu.ch + (addr >> 4 & 0xF); - ch->timer = T1ReadWord(MMU.ARM7_REG, addr & ~1); - adjust_channel_timer(ch); - break; - case 0x0a: - case 0x0b: - ch = spu.ch + (addr >> 4 & 0xF); - ch->loop = T1ReadWord(MMU.ARM7_REG, addr & ~1); - break; - case 0x0c: - case 0x0e: - case 0x0d: - case 0x0f: - ch = spu.ch + (addr >> 4 & 0xF); - ch->length = (T1ReadLong(MMU.ARM7_REG, addr & ~3) & 0x003FFFFF); - break; -#endif - } - } - -} - - -void SPU_WriteWord(u32 addr, u16 x) -{ - addr &= 0x00000FFF; - T1WriteWord(MMU.ARM7_REG, addr, x); - - if(addr < 0x500) - { - SChannel *ch; - switch(addr & 0x00F) - { - case 0x0: - ch = spu.ch + (addr >> 4 & 0xF); - ch->volume = (x & 0x007F); - ch->shift = (x >> 8 & 0x0003); - ch->hold = (x >> 15 & 0x0001); - set_channel_volume(ch); - break; - case 0x2: - ch = spu.ch + (addr >> 4 & 0xF); - ch->pan = (x & 0x007F); - ch->psg_duty = (x >> 8 & 0x0007); - ch->repeat = (x >> 11 & 0x0003); - ch->format = (x >> 13 & 0x0003); - set_channel_volume(ch); - if(x & 0x8000) start_channel(ch); else stop_channel(ch); - break; - case 0x08: - ch = spu.ch + (addr >> 4 & 0xF); - ch->timer = x; - adjust_channel_timer(ch); - break; - case 0x0a: - ch = spu.ch + (addr >> 4 & 0xF); - ch->loop = x; - break; -#if !DISABLE_XSF_TESTS - case 0x04: - case 0x06: - ch = spu.ch + (addr >> 4 & 0xF); - ch->addr = (T1ReadLong(MMU.ARM7_REG, addr & ~3) & 0x07FFFFFF); - break; - case 0x0c: - case 0x0e: - ch = spu.ch + (addr >> 4 & 0xF); - ch->length = (T1ReadLong(MMU.ARM7_REG, addr & ~3) & 0x003FFFFF); - break; -#endif - } - } -} - - -void SPU_WriteLong(u32 addr, u32 x) -{ - addr &= 0x00000FFF; - T1WriteLong(MMU.ARM7_REG, addr, x); - - if(addr < 0x500) - { - SChannel *ch; - switch(addr & 0x00F) - { - case 0x0: - ch = spu.ch + (addr >> 4 & 0xF); - ch->volume = (x & 0x7F); - ch->shift = (x >> 8 & 0x00000003); - ch->hold = (x >> 15 & 0x00000001); - ch->pan = (x >> 16 & 0x0000007F); - ch->psg_duty = (x >> 24 & 0x00000007); - ch->repeat = (x >> 27 & 0x00000003); - ch->format = (x >> 29 & 0x00000003); - set_channel_volume(ch); - if(x & 0x80000000) start_channel(ch); else stop_channel(ch); - break; - case 0x04: - ch = spu.ch + (addr >> 4 & 0xF); - ch->addr = (x & 0x07FFFFFF); - break; - case 0x08: - ch = spu.ch + (addr >> 4 & 0xF); - ch->timer = (x & 0x0000FFFF); - ch->loop = (x >> 16 & 0x0000FFFF); - adjust_channel_timer(ch); - break; - case 0x0C: - ch = spu.ch + (addr >> 4 & 0xF); - ch->length = (x & 0x003FFFFF); - break; - } - } -} - -////////////////////////////////////////////////////////////////////////////// - -u32 SPU_ReadLong(u32 addr) -{ - addr &= 0xFFF; - return T1ReadLong(MMU.ARM7_REG, addr); -} - -static INLINE s32 clipping(s32 x, s32 min, s32 max) { -#if 1 || defined(SIGNED_IS_NOT_2S_COMPLEMENT) - if (x < min) - { - return (min); - } - else if (x > max) - { - return (max); - } - return (x); -#else - return x ^ ((-(x < min)) & (x ^ min)) ^ ((-(x > max)) & (x ^ max)); -#endif -} - -extern unsigned long dwChannelMute; - -static void decode_pcm8(SChannel *ch, s32 *out, int length) -{ - int oi; - double pos, inc, len; - if (!ch->buf8) return; - - pos = ch->pos; inc = ch->inc; len = ch->loopend; - - for(oi = 0; oi < length; oi++) - { - ch->output = ((s16)(s8)ch->buf8[(int)pos]) << 8; - if (dwChannelMute & (1 << ch->id)) - { - out++; - out++; - } - else - { - *(out++) += (ch->output * ch->volumel) >> VOL_SHIFT; - *(out++) += (ch->output * ch->volumer) >> VOL_SHIFT; - } - pos += inc; - if(pos >= len) - { - switch(ch->repeat) - { -#if !DISABLE_XSF_TESTS - case 0: -#endif - case 1: - pos += ch->looppos - len; - break; - default: - stop_channel(ch); - oi = length; - break; - } - } - } - - ch->pos = pos; - return; -} - -static void decode_pcm16(SChannel *ch, s32 *out, int length) -{ - int oi; - double pos, inc, len; - - if (!ch->buf16) return; - - pos = ch->pos; inc = ch->inc; len = ch->loopend; - - for(oi = 0; oi < length; oi++) - { -#ifdef WORDS_BIGENDIAN - ch->output = (s16)T1ReadWord((u8 *)ch->buf16, pos << 1); -#else - ch->output = (s16)ch->buf16[(int)pos]; -#endif - if (dwChannelMute & (1 << ch->id)) - { - out++; - out++; - } - else - { - *(out++) += (ch->output * ch->volumel) >> VOL_SHIFT; - *(out++) += (ch->output * ch->volumer) >> VOL_SHIFT; - } - pos += inc; - if(pos >= len) - { - switch(ch->repeat) - { -#if !DISABLE_XSF_TESTS - case 0: -#endif - case 1: - pos += ch->looppos - len; - break; - default: - stop_channel(ch); - oi = length; - break; - } - } - } - - ch->pos = pos; -} - -static INLINE void decode_adpcmone_P4(SChannel *ch, int m) -{ - int i, ci0; - u8 *p; - s32 s; - int N; - - i = ch->adpcm_pos; - p = (ch->buf8 + (i >> 1)); - ci0 = ch->adpcm_index; - s = ch->adpcm; - - if (ch->adpcm_loop_index < 0 && m >= ch->looppos) - { - ch->adpcm_loop_index = ci0; - ch->adpcm_loop = s; - ch->adpcm_loop_pos = i; - } - - if(i++ & 1) - { - s32 x1, d1; - x1 = ((*(p++) >> 3) & 0x1F | 1); - d1 = ((x1 & 0xF) * g_adpcm_mult[ci0] & ~7); - ci0 = clipping((ci0 + g_adpcm_index[x1 & 0xE]), 0, 88); -#if 1 || defined(SIGNED_IS_NOT_2S_COMPLEMENT) - if(x1 & 0x10) d1 = -d1; -#else - d1 -= (d1 + d1) & (-(((x1 >> 4) & 1))); -#endif - - s = clipping((s + d1), (-32768 << 3), (32767 << 3)); - } - - N = (((m & ~1) - (i & ~1)) >> 1); - for(i = 0; i < N; i++) - { - s32 x0, d0; - s32 x1, d1; - int ci1; - x0 = ((*p << 1) & 0x1F | 1); - x1 = ((*p >> 3) & 0x1F | 1); - ci1 = clipping((ci0 + g_adpcm_index[x0 & 0xE]), 0, 88); - d0 = ((x0 & 0xF) * g_adpcm_mult[ci0] & ~7); - ci0 = clipping((ci1 + g_adpcm_index[x1 & 0xE]), 0, 88); - d1 = ((x1 & 0xF) * g_adpcm_mult[ci1] & ~7); -#if 1 || defined(SIGNED_IS_NOT_2S_COMPLEMENT) - if(x0 & 0x10) d0 = -d0; - if(x1 & 0x10) d1 = -d1; -#else - d0 -= (d0 + d0) & (-(((x0 >> 4) & 1))); - d1 -= (d1 + d1) & (-(((x1 >> 4) & 1))); -#endif - s = clipping((s + d0), (-32768 << 3), (32767 << 3)); - s = clipping((s + d1), (-32768 << 3), (32767 << 3)); - p++; - } - if(m & 1) - { - s32 x0, d0; - x0 = ((*p << 1) & 0x1F | 1); - d0 = ((x0 & 0xF) * g_adpcm_mult[ci0] & ~7); - ci0 = clipping((ci0 + g_adpcm_index[x0 & 0xE]), 0, 88); -#if 1 || defined(SIGNED_IS_NOT_2S_COMPLEMENT) - if(x0 & 0x10) d0 = -d0; -#else - d0 -= (d0 + d0) & (-(((x0 >> 4) & 1))); -#endif - s = clipping((s + d0), (-32768 << 3), (32767 << 3)); - } - - ch->output = (s16)(s >> 3); - - ch->adpcm = s; - ch->adpcm_index = ci0; - ch->adpcm_pos = m; -} - -static INLINE void decode_adpcmone_XX(SChannel *ch, int m) -{ - int i, ci0; - u8 *p; - s32 s; - - i = ch->adpcm_pos; - p = (ch->buf8 + (i >> 1)); - ci0 = ch->adpcm_index; - s = ch->adpcm; - - if (ch->adpcm_loop_index < 0 && m >= ch->looppos) - { - ch->adpcm_loop_index = ci0; - ch->adpcm_loop = s; - ch->adpcm_loop_pos = i; - } - - while (i < m) - { - s32 x1, d1; - x1 = ((s32)*p) >> ((i & 1) << 2) & 0xf; - x1 = x1 + x1 + 1; - d1 = ((x1 & 0xF) * g_adpcm_mult[ci0] & ~7); - ci0 = clipping((ci0 + g_adpcm_index[x1 & 0xE]), 0, 88); -#if 1 || defined(SIGNED_IS_NOT_2S_COMPLEMENT) - if(x1 & 0x10) d1 = -d1; -#else - d1 -= (d1 + d1) & (-(((x1 >> 4) & 1))); -#endif - - s = clipping((s + d1), (-32768 << 3), (32767 << 3)); - p += (i & 1); - i++; - } - - ch->output = (s16)(s >> 3); - - ch->adpcm = s; - ch->adpcm_index = ci0; - ch->adpcm_pos = m; -} - -#define decode_adpcmone decode_adpcmone_P4 - -static void decode_adpcm(SChannel *ch, s32 *out, int length) -{ - int oi; - double pos, inc, len; - if (!ch->buf8) return; - - pos = ch->pos; inc = ch->inc; len = ch->loopend; - - for(oi = 0; oi < length; oi++) - { - int m = (int)pos; - int i = ch->adpcm_pos; - if(i < m) - decode_adpcmone(ch, m); - - if (dwChannelMute & (1 << ch->id)) - { - out++; - out++; - } - else - { - *(out++) += (ch->output * ch->volumel) >> VOL_SHIFT; - *(out++) += (ch->output * ch->volumer) >> VOL_SHIFT; - } - pos += inc; - if(pos >= len) - { - switch(ch->repeat) - { - case 1: - if (ch->adpcm_loop_index >= 0) - { - pos += ch->looppos - len; - ch->adpcm_pos = ch->adpcm_loop_pos; - ch->adpcm_index = ch->adpcm_loop_index; - ch->adpcm = ch->adpcm_loop; - break; - } -#if !DISABLE_XSF_TESTS - case 0: - pos = 9 - len; -#ifdef WORDS_BIGENDIAN - ch->adpcm = ((s32)(s16)T1ReadWord((u8 *)ch->buf8, 0)) << 3; -#else - ch->adpcm = ((s32)*(s16 *)ch->buf8) << 3; -#endif - ch->adpcm_index = (ch->buf8[2] & 0x7F); - ch->adpcm_pos = 8; - break; -#endif - default: - stop_channel(ch); - oi = length; - break; - } - } - } - ch->pos = pos; -} - -static void decode_psg(SChannel *ch, s32 *out, int length) -{ - int oi; - - if(ch->id < 14) - { - // NOTE: square wave. - double pos, inc, len; - pos = ch->pos; inc = ch->inc; len = ch->length; - for(oi = 0; oi < length; oi++) - { - ch->output = (s16)g_psg_duty[ch->psg_duty][(int)pos & 0x00000007]; - if (dwChannelMute & (1 << ch->id)) - { - out++; - out++; - } - else - { - *(out++) += (ch->output * ch->volumel) >> VOL_SHIFT; - *(out++) += (ch->output * ch->volumer) >> VOL_SHIFT; - } - pos += inc; - } - ch->pos = pos; - } - else - { - // NOTE: noise. - u16 X; - X = (u16)ch->pos; - for(oi = 0; oi < length; oi++) - { - if(X & 1) - { - X >>= 1; - X ^= 0x6000; - ch->output = -0x8000; - } - else - { - X >>= 1; - ch->output = +0x7FFF; - } - } - if (dwChannelMute & (1 << ch->id)) - { - out++; - out++; - } - else - { - *(out++) += (ch->output * ch->volumel) >> VOL_SHIFT; - *(out++) += (ch->output * ch->volumer) >> VOL_SHIFT; - } - ch->pos = X; - } -} - - - -void SPU_EmulateSamples(u32 numsamples) -{ - u32 sizesmp = numsamples; - u32 sizebyte = sizesmp << 2; - if (sizebyte > spu.buflen * sizeof(s16)) sizebyte = spu.buflen * sizeof(s16); - sizesmp = sizebyte >> 2; - sizebyte = sizesmp << 2; - if (sizesmp > 0) - { - unsigned i; - SChannel *ch = spu.ch; - memset(spu.pmixbuf, 0, spu.buflen * sizeof(s32)); - for (i = 0; i < 16; i++) - { - if (ch->status) - { - switch (ch->format) - { - case 0: - decode_pcm8(ch, spu.pmixbuf, sizesmp); - break; - case 1: - decode_pcm16(ch, spu.pmixbuf, sizesmp); - break; - case 2: - decode_adpcm(ch, spu.pmixbuf, sizesmp); - break; - case 3: - decode_psg(ch, spu.pmixbuf, sizesmp); - break; - } - } - ch++; - } - for (i = 0; i < sizesmp * 2; i++) - spu.pclipingbuf[i] = (s16)clipping(spu.pmixbuf[i], -0x8000, 0x7fff); - SNDCore->UpdateAudio(spu.pclipingbuf, sizesmp); - } -} - -void SPU_Emulate(void) -{ - SPU_EmulateSamples(SNDCore->GetAudioSpace()); -} - - -////////////////////////////////////////////////////////////////////////////// -// Dummy Sound Interface -////////////////////////////////////////////////////////////////////////////// - -static int SNDDummyInit(int buffersize) -{ - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -static void SNDDummyDeInit() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -static void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples) -{ -} - -////////////////////////////////////////////////////////////////////////////// - -static u32 SNDDummyGetAudioSpace() -{ - return 735; -} - -////////////////////////////////////////////////////////////////////////////// - -static void SNDDummyMuteAudio() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -static void SNDDummyUnMuteAudio() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -static void SNDDummySetVolume(int volume) -{ -} - -////////////////////////////////////////////////////////////////////////////// - -SoundInterface_struct SNDDummy = -{ - SNDCORE_DUMMY, - "Dummy Sound Interface", - SNDDummyInit, - SNDDummyDeInit, - SNDDummyUpdateAudio, - SNDDummyGetAudioSpace, - SNDDummyMuteAudio, - SNDDummyUnMuteAudio, - SNDDummySetVolume -}; - diff --git a/tools/vio2sf/src/vio2sf/desmume/SPU.cpp b/tools/vio2sf/src/vio2sf/desmume/SPU.cpp deleted file mode 100644 index 7e1c3a712..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/SPU.cpp +++ /dev/null @@ -1,1134 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - Copyright (C) 2006 Theo Berkau - Copyright (C) 2008-2009 DeSmuME team - - Ideas borrowed from Stephane Dallongeville's SCSP core - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include -#include - -//#undef FORCEINLINE -//#define FORCEINLINE - -#define _SPU_CPP_ - -#define _USE_MATH_DEFINES -#include -#ifndef M_PI -#define M_PI 3.1415926535897932386 -#endif - -#define K_ADPCM_LOOPING_RECOVERY_INDEX 99999 - -#include "debug.h" -#include "MMU.h" -#include "SPU.h" -#include "mem.h" -#include "armcpu.h" -#include "NDSSystem.h" -#include "matrix.h" - -//===================CONFIGURATION======================== -#include "src/xsfc/drvimpl.h" -extern "C" unsigned long dwInterpolation; -bool isChannelMuted(int num) { return dwChannelMute&(1< -static FORCEINLINE T MinMax(T val, T min, T max) -{ - if (val < min) - return min; - else if (val > max) - return max; - - return val; -} - -////////////////////////////////////////////////////////////////////////////// - -extern "C" int SPU_ChangeSoundCore(int coreid, int buffersize) -{ - int i; - - delete SPU_user; SPU_user = 0; - - // Make sure the old core is freed - if (SNDCore) - SNDCore->DeInit(); - - // So which core do we want? - if (coreid == SNDCORE_DEFAULT) - coreid = 0; // Assume we want the first one - - SPU_currentCoreNum = coreid; - - // Go through core list and find the id - for (i = 0; SNDCoreList[i] != NULL; i++) - { - if (SNDCoreList[i]->id == coreid) - { - // Set to current core - SNDCore = SNDCoreList[i]; - break; - } - } - - //If the user picked the dummy core, disable the user spu - if(SNDCore == &SNDDummy) - return 0; - - //If the core wasnt found in the list for some reason, disable the user spu - if (SNDCore == NULL) - return -1; - - // Since it failed, instead of it being fatal, disable the user spu - if (SNDCore->Init(buffersize * 2) == -1) - { - SNDCore = 0; - return -1; - } - - //enable the user spu - //well, not really - //SPU_user = new SPU_struct(buffersize); - - return 0; -} - -SoundInterface_struct *SPU_SoundCore() -{ - return SNDCore; -} - -extern "C" void SPU_Reset(void) -{ - int i; - - SPU_core->reset(); - if(SPU_user) SPU_user->reset(); - - if(SNDCore && SPU_user) { - SNDCore->DeInit(); - SNDCore->Init(SPU_user->bufsize*2); - //todo - check success? - } - - // Reset Registers - for (i = 0x400; i < 0x51D; i++) - T1WriteByte(MMU.ARM7_REG, i, 0); - - samples = 0; -} - - -////////////////////////////////////////////////////////////////////////////// - -//static double cos_lut[256]; - -static long tot_samples; -static long update_trunc; - - -extern "C" int SPU_Init(int coreid, int buffersize) -{ - int i, j; - - //__asm int 3; - - //for(int i=0;i<256;i++) - // cos_lut[i] = cos(i/256.0*M_PI); - - SPU_core = new SPU_struct(44100); //pick a really big number just to make sure the plugin doesnt request more - SPU_Reset(); - - for(i = 0; i < 16; i++) - { - for(j = 0; j < 89; j++) - { - precalcdifftbl[j][i] = (((i & 0x7) * 2 + 1) * adpcmtbl[j] / 8); - if(i & 0x8) precalcdifftbl[j][i] = -precalcdifftbl[j][i]; - } - } - - for(i = 0; i < 8; i++) - { - for(j = 0; j < 89; j++) - { - precalcindextbl[j][i] = MinMax((j + indextbl[i]), 0, 88); - } - } - - tot_samples = 0; - update_trunc = 0; - - //return SPU_ChangeSoundCore(coreid, buffersize); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_Pause(int pause) -{ - if (SNDCore == NULL) return; - - if(pause) - SNDCore->MuteAudio(); - else - SNDCore->UnMuteAudio(); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_SetVolume(int volume) -{ - if (SNDCore) - SNDCore->SetVolume(volume); -} - -////////////////////////////////////////////////////////////////////////////// - - - -void SPU_struct::reset() -{ - memset(sndbuf,0,bufsize*2*4); - memset(outbuf,0,bufsize*2*2); - - memset((void *)channels, 0, sizeof(channel_struct) * 16); - - for(int i = 0; i < 16; i++) - { - channels[i].num = i; - } -} - -SPU_struct::SPU_struct(int buffersize) - : bufpos(0) - , buflength(0) - , sndbuf(0) - , outbuf(0) - , bufsize(buffersize) -{ - sndbuf = new s32[buffersize*2]; - outbuf = new s16[buffersize*2]; - reset(); -} - -SPU_struct::~SPU_struct() -{ - if(sndbuf) delete[] sndbuf; - if(outbuf) delete[] outbuf; -} - -extern "C" void SPU_DeInit(void) -{ - if(SNDCore) - SNDCore->DeInit(); - SNDCore = 0; - - delete SPU_core; SPU_core=0; - delete SPU_user; SPU_user=0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::ShutUp() -{ - for(int i=0;i<16;i++) - channels[i].status = CHANSTAT_STOPPED; -} - -static FORCEINLINE void adjust_channel_timer(channel_struct *chan) -{ - chan->sampinc = (((double)ARM7_CLOCK) / (44100 * 2)) / (double)(0x10000 - chan->timer); -} - -void SPU_struct::KeyOn(int channel) -{ - channel_struct &thischan = channels[channel]; - - adjust_channel_timer(&thischan); - - // LOG("Channel %d key on: vol = %d, datashift = %d, hold = %d, pan = %d, waveduty = %d, repeat = %d, format = %d, source address = %07X, timer = %04X, loop start = %04X, length = %06X, MMU.ARM7_REG[0x501] = %02X\n", channel, chan->vol, chan->datashift, chan->hold, chan->pan, chan->waveduty, chan->repeat, chan->format, chan->addr, chan->timer, chan->loopstart, chan->length, T1ReadByte(MMU.ARM7_REG, 0x501)); - switch(thischan.format) - { - case 0: // 8-bit - thischan.buf8 = (s8*)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; - // thischan.loopstart = thischan.loopstart << 2; - // thischan.length = (thischan.length << 2) + thischan.loopstart; - thischan.sampcnt = 0; - break; - case 1: // 16-bit - thischan.buf16 = (s16 *)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; - // thischan.loopstart = thischan.loopstart << 1; - // thischan.length = (thischan.length << 1) + thischan.loopstart; - thischan.sampcnt = 0; - break; - case 2: // ADPCM - { - thischan.buf8 = (s8*)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; - thischan.pcm16b = (s16)((thischan.buf8[1] << 8) | thischan.buf8[0]); - thischan.pcm16b_last = thischan.pcm16b; - thischan.index = thischan.buf8[2] & 0x7F; - thischan.lastsampcnt = 7; - thischan.sampcnt = 8; - thischan.loop_index = K_ADPCM_LOOPING_RECOVERY_INDEX; - // thischan.loopstart = thischan.loopstart << 3; - // thischan.length = (thischan.length << 3) + thischan.loopstart; - break; - } - case 3: // PSG - { - thischan.x = 0x7FFF; - break; - } - default: break; - } - - if(thischan.format != 3) - { - if(thischan.double_totlength_shifted == 0) - { - printf("INFO: Stopping channel %d due to zero length\n",channel); - thischan.status = CHANSTAT_STOPPED; - } - } - - thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::WriteByte(u32 addr, u8 val) -{ - channel_struct &thischan=channels[(addr >> 4) & 0xF]; - switch(addr & 0xF) { - case 0x0: - thischan.vol = val & 0x7F; - break; - case 0x1: { - thischan.datashift = val & 0x3; - if (thischan.datashift == 3) - thischan.datashift = 4; - thischan.hold = (val >> 7) & 0x1; - break; - } - case 0x2: - thischan.pan = val & 0x7F; - break; - case 0x3: { - thischan.waveduty = val & 0x7; - thischan.repeat = (val >> 3) & 0x3; - thischan.format = (val >> 5) & 0x3; - thischan.status = (val >> 7) & 0x1; - if(thischan.status) - KeyOn((addr >> 4) & 0xF); - break; - } - } - -} - -extern "C" void SPU_WriteByte(u32 addr, u8 val) -{ - addr &= 0xFFF; - - if (addr < 0x500) - { - SPU_core->WriteByte(addr,val); - if(SPU_user) SPU_user->WriteByte(addr,val); - } - - T1WriteByte(MMU.ARM7_REG, addr, val); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::WriteWord(u32 addr, u16 val) -{ - channel_struct &thischan=channels[(addr >> 4) & 0xF]; - switch(addr & 0xF) - { - case 0x0: - thischan.vol = val & 0x7F; - thischan.datashift = (val >> 8) & 0x3; - if (thischan.datashift == 3) - thischan.datashift = 4; - thischan.hold = (val >> 15) & 0x1; - break; - case 0x2: - thischan.pan = val & 0x7F; - thischan.waveduty = (val >> 8) & 0x7; - thischan.repeat = (val >> 11) & 0x3; - thischan.format = (val >> 13) & 0x3; - thischan.status = (val >> 15) & 0x1; - if (thischan.status) - KeyOn((addr >> 4) & 0xF); - break; - case 0x8: - thischan.timer = val & 0xFFFF; - adjust_channel_timer(&thischan); - break; - case 0xA: - thischan.loopstart = val; - thischan.totlength = thischan.length + thischan.loopstart; - thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); - break; - case 0xC: - WriteLong(addr,((u32)T1ReadWord(MMU.ARM7_REG, addr+2) << 16) | val); - break; - case 0xE: - WriteLong(addr,((u32)T1ReadWord(MMU.ARM7_REG, addr-2)) | ((u32)val<<16)); - break; - } -} - -extern "C" void SPU_WriteWord(u32 addr, u16 val) -{ - addr &= 0xFFF; - - if (addr < 0x500) - { - SPU_core->WriteWord(addr,val); - if(SPU_user) SPU_user->WriteWord(addr,val); - } - - T1WriteWord(MMU.ARM7_REG, addr, val); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::WriteLong(u32 addr, u32 val) -{ - channel_struct &thischan=channels[(addr >> 4) & 0xF]; - switch(addr & 0xF) - { - case 0x0: - thischan.vol = val & 0x7F; - thischan.datashift = (val >> 8) & 0x3; - if (thischan.datashift == 3) - thischan.datashift = 4; - thischan.hold = (val >> 15) & 0x1; - thischan.pan = (val >> 16) & 0x7F; - thischan.waveduty = (val >> 24) & 0x7; - thischan.repeat = (val >> 27) & 0x3; - thischan.format = (val >> 29) & 0x3; - thischan.status = (val >> 31) & 0x1; - if (thischan.status) - KeyOn((addr >> 4) & 0xF); - break; - case 0x4: - thischan.addr = val & 0x7FFFFFF; - break; - case 0x8: - thischan.timer = val & 0xFFFF; - thischan.loopstart = val >> 16; - adjust_channel_timer(&thischan); - break; - case 0xC: - thischan.length = val & 0x3FFFFF; - thischan.totlength = thischan.length + thischan.loopstart; - thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); - break; - } -} - -extern "C" void SPU_WriteLong(u32 addr, u32 val) -{ - addr &= 0xFFF; - - if (addr < 0x500) - { - SPU_core->WriteLong(addr,val); - if(SPU_user) SPU_user->WriteLong(addr,val); - } - - T1WriteLong(MMU.ARM7_REG, addr, val); -} - -////////////////////////////////////////////////////////////////////////////// -static FORCEINLINE s32 Interpolate(SPUInterpolationMode INTERPOLATE_MODE, s32 a, s32 b, double ratio) -{ - if(INTERPOLATE_MODE == SPUInterpolation_Cosine) - { - //why did we change it away from the lookup table? somebody should research that - ratio = ratio - sputrunc(ratio); - double ratio2 = ((1.0 - cos(ratio * M_PI)) * 0.5); - //double ratio2 = (1.0f - cos_lut[((int)(ratio*256.0))&0xFF]) / 2.0f; - return s32floor((float)(((1-ratio2)*a) + (ratio2*b))); - } - else - { - //linear interpolation - ratio = ratio - sputrunc(ratio); - return s32floor((float)((1-ratio)*a + ratio*b)); - } -} - -////////////////////////////////////////////////////////////////////////////// -typedef void (*TYPE_EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT)(unsigned long addr, int type); -typedef BOOL (*TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED)(unsigned long addr); -typedef unsigned long (*TYPE_EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME)(unsigned long addr); -typedef BOOL (*TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE)(); -double round(double r) -{ - return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5); -} - -extern "C" TYPE_EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT addInstrument; -extern "C" TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED isInstrumentMuted; -extern "C" TYPE_EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME getInstrumentVolume; -extern "C" TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE isInstrumentSelectionActive; - -static FORCEINLINE void Fetch8BitData(SPUInterpolationMode INTERPOLATE_MODE, channel_struct *chan, s32 *data) -{ - u32 loc = sputrunc(chan->sampcnt); - if(INTERPOLATE_MODE != SPUInterpolation_None) - { - s32 a = (s32)(chan->buf8[loc] << 8); - if(loc < (chan->totlength << 2) - 1) { - s32 b = (s32)(chan->buf8[loc + 1] << 8); - a = Interpolate(INTERPOLATE_MODE, a, b, chan->sampcnt); - } - *data = a; - } - else - *data = (s32)chan->buf8[loc] << 8; - - if (isInstrumentSelectionActive && isInstrumentSelectionActive() && addInstrument && isInstrumentMuted && getInstrumentVolume) - { - addInstrument(chan->addr, 0); - if (isInstrumentMuted(chan->addr)) *data = 0; - else *data = (s32)(round((double)(*data) * (double)getInstrumentVolume(chan->addr)*(double)getInstrumentVolume(chan->addr) / 10000.0)); - } -} - -static FORCEINLINE void Fetch16BitData(SPUInterpolationMode INTERPOLATE_MODE, const channel_struct * const chan, s32 *data) -{ - const s16* const buf16 = chan->buf16; - const int shift = 1; - if(INTERPOLATE_MODE != SPUInterpolation_None) - { - u32 loc = sputrunc(chan->sampcnt); - s32 a = (s32)buf16[loc], b; - if(loc < (chan->totlength << shift) - 1) - { - b = (s32)buf16[loc + 1]; - a = Interpolate(INTERPOLATE_MODE,a, b, chan->sampcnt); - } - *data = a; - } - else - *data = (s32)buf16[sputrunc(chan->sampcnt)]; - - if (isInstrumentSelectionActive && isInstrumentSelectionActive() && addInstrument && isInstrumentMuted && getInstrumentVolume) - { - addInstrument(chan->addr, 1); - if (isInstrumentMuted(chan->addr)) *data = 0; - else *data = (s32)(round((double)(*data) * (double)getInstrumentVolume(chan->addr)*(double)getInstrumentVolume(chan->addr) / 10000.0)); - } -} - -static FORCEINLINE void FetchADPCMData(SPUInterpolationMode INTERPOLATE_MODE, channel_struct * const chan, s32 * const data) -{ - // No sense decoding, just return the last sample - if (chan->lastsampcnt != sputrunc(chan->sampcnt)){ - - const u32 endExclusive = sputrunc(chan->sampcnt+1); - for (u32 i = chan->lastsampcnt+1; i < endExclusive; i++) - { - const u32 shift = (i&1)<<2; - const u32 data4bit = (((u32)chan->buf8[i >> 1]) >> shift); - - const s32 diff = precalcdifftbl[chan->index][data4bit & 0xF]; - chan->index = precalcindextbl[chan->index][data4bit & 0x7]; - - chan->pcm16b_last = chan->pcm16b; - chan->pcm16b = (s16)(MinMax(chan->pcm16b+diff, -0x8000L, 0x7FFFL)); - - if(i == (chan->loopstart<<3)) { - if(chan->loop_index != K_ADPCM_LOOPING_RECOVERY_INDEX) printf("over-snagging\n"); - chan->loop_pcm16b = chan->pcm16b; - chan->loop_index = chan->index; - } - } - - chan->lastsampcnt = sputrunc(chan->sampcnt); - } - - if(INTERPOLATE_MODE != SPUInterpolation_None) - *data = Interpolate(INTERPOLATE_MODE,(s32)chan->pcm16b_last,(s32)chan->pcm16b,chan->sampcnt); - else - *data = (s32)chan->pcm16b; - - if (isInstrumentSelectionActive && isInstrumentSelectionActive() && addInstrument && isInstrumentMuted && getInstrumentVolume) - { - addInstrument(chan->addr, 2); - if (isInstrumentMuted(chan->addr)) *data = 0; - else *data = (s32)(round((double)(*data) * (double)getInstrumentVolume(chan->addr)*(double)getInstrumentVolume(chan->addr) / 10000.0)); - } -} - -static FORCEINLINE void FetchPSGData(channel_struct *chan, s32 *data) -{ - if(chan->num < 8) - { - *data = 0; - } - else if(chan->num < 14) - { - *data = (s32)wavedutytbl[chan->waveduty][(sputrunc(chan->sampcnt)) & 0x7]; - } - else - { - if(chan->lastsampcnt == sputrunc(chan->sampcnt)) - { - *data = (s32)chan->psgnoise_last; - return; - } - - u32 max = sputrunc(chan->sampcnt); - for(u32 i = chan->lastsampcnt; i < max; i++) - { - if(chan->x & 0x1) - { - chan->x = (chan->x >> 1); - chan->psgnoise_last = -0x7FFF; - } - else - { - chan->x = ((chan->x >> 1) ^ 0x6000); - chan->psgnoise_last = 0x7FFF; - } - } - - chan->lastsampcnt = sputrunc(chan->sampcnt); - - *data = (s32)chan->psgnoise_last; - } - - if (isInstrumentSelectionActive && isInstrumentSelectionActive() && addInstrument && isInstrumentMuted && getInstrumentVolume) - { - addInstrument(0, 3); - if (isInstrumentMuted(0)) *data = 0; - else *data = (s32)(round((double)(*data) * (double)getInstrumentVolume(0)*(double)getInstrumentVolume(0) / 10000.0)); - } - -} - -////////////////////////////////////////////////////////////////////////////// - -static FORCEINLINE void MixL(SPU_struct* SPU, channel_struct *chan, s32 data) -{ - data = spumuldiv7(data, chan->vol) >> chan->datashift; - SPU->sndbuf[SPU->bufpos<<1] += data; -} - -static FORCEINLINE void MixR(SPU_struct* SPU, channel_struct *chan, s32 data) -{ - data = spumuldiv7(data, chan->vol) >> chan->datashift; - SPU->sndbuf[(SPU->bufpos<<1)+1] += data; -} - -static FORCEINLINE void MixLR(SPU_struct* SPU, channel_struct *chan, s32 data) -{ - data = spumuldiv7(data, chan->vol) >> chan->datashift; - SPU->sndbuf[SPU->bufpos<<1] += spumuldiv7(data, 127 - chan->pan); - SPU->sndbuf[(SPU->bufpos<<1)+1] += spumuldiv7(data, chan->pan); -} - -////////////////////////////////////////////////////////////////////////////// - -static FORCEINLINE void TestForLoop(int FORMAT, SPU_struct *SPU, channel_struct *chan) -{ - const int shift = (FORMAT == 0 ? 2 : 1); - - chan->sampcnt += chan->sampinc; - - if (chan->sampcnt > chan->double_totlength_shifted) - { - // Do we loop? Or are we done? - if (chan->repeat == 1) - { - while (chan->sampcnt > chan->double_totlength_shifted) - chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << shift); - //chan->sampcnt = (double)(chan->loopstart << shift); - } - else - { - chan->status = CHANSTAT_STOPPED; - - if(SPU == SPU_core) - MMU.ARM7_REG[0x403 + (((chan-SPU->channels) ) * 0x10)] &= 0x7F; - SPU->bufpos = SPU->buflength; - } - } -} - -static FORCEINLINE void TestForLoop2(SPU_struct *SPU, channel_struct *chan) -{ - chan->sampcnt += chan->sampinc; - - if (chan->sampcnt > chan->double_totlength_shifted) - { - // Do we loop? Or are we done? - if (chan->repeat == 1) - { - while (chan->sampcnt > chan->double_totlength_shifted) - chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << 3); - - if(chan->loop_index == K_ADPCM_LOOPING_RECOVERY_INDEX) - { - chan->pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]); - chan->index = chan->buf8[2] & 0x7F; - chan->lastsampcnt = 7; - } - else - { - chan->pcm16b = chan->loop_pcm16b; - chan->index = chan->loop_index; - chan->lastsampcnt = (chan->loopstart << 3); - } - } - else - { - chan->status = CHANSTAT_STOPPED; - if(SPU == SPU_core) - MMU.ARM7_REG[0x403 + (((chan-SPU->channels) ) * 0x10)] &= 0x7F; - SPU->bufpos = SPU->buflength; - } - } -} - -FORCEINLINE static void SPU_Mix(int CHANNELS, SPU_struct* SPU, channel_struct *chan, s32 data) -{ - switch(CHANNELS) - { - case 0: MixL(SPU, chan, data); break; - case 1: MixLR(SPU, chan, data); break; - case 2: MixR(SPU, chan, data); break; - } -} - -FORCEINLINE static void ____SPU_ChanUpdate(int CHANNELS, int FORMAT, SPUInterpolationMode INTERPOLATE_MODE, SPU_struct* const SPU, channel_struct* const chan) -{ - for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) - { - if(CHANNELS != -1) - { - s32 data; - switch(FORMAT) - { - case 0: Fetch8BitData(INTERPOLATE_MODE, chan, &data); break; - case 1: Fetch16BitData(INTERPOLATE_MODE, chan, &data); break; - case 2: FetchADPCMData(INTERPOLATE_MODE, chan, &data); break; - case 3: FetchPSGData(chan, &data); break; - } - SPU_Mix(CHANNELS, SPU, chan, data); - } - - switch(FORMAT) { - case 0: case 1: TestForLoop(FORMAT, SPU, chan); break; - case 2: TestForLoop2(SPU, chan); break; - case 3: chan->sampcnt += chan->sampinc; break; - } - } -} - -FORCEINLINE static void ___SPU_ChanUpdate(int FORMAT, SPUInterpolationMode INTERPOLATE_MODE, const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) -{ - if(!actuallyMix) - ____SPU_ChanUpdate(-1,FORMAT,INTERPOLATE_MODE,SPU,chan); - else if (chan->pan == 0) - ____SPU_ChanUpdate(0,FORMAT,INTERPOLATE_MODE,SPU,chan); - else if (chan->pan == 127) - ____SPU_ChanUpdate(2,FORMAT,INTERPOLATE_MODE,SPU,chan); - else - ____SPU_ChanUpdate(1,FORMAT,INTERPOLATE_MODE,SPU,chan); -} - -FORCEINLINE static void __SPU_ChanUpdate(SPUInterpolationMode INTERPOLATE_MODE, const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) -{ - ___SPU_ChanUpdate(chan->format,INTERPOLATE_MODE,actuallyMix, SPU, chan); -} - -FORCEINLINE static void _SPU_ChanUpdate(const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) -{ - __SPU_ChanUpdate(spuInterpolationMode(),actuallyMix, SPU, chan); -} - - -static void SPU_MixAudio(bool actuallyMix, SPU_struct *SPU, int length) -{ - u8 vol; - - if(actuallyMix) - { - memset(SPU->sndbuf, 0, length*4*2); - memset(SPU->outbuf, 0, length*2*2); - } - - //---not appropriate for 2sf player - // If the sound speakers are disabled, don't output audio - //if(!(T1ReadWord(MMU.ARM7_REG, 0x304) & 0x01)) - // return; - - // If Master Enable isn't set, don't output audio - //if (!(T1ReadByte(MMU.ARM7_REG, 0x501) & 0x80)) - // return; - //------------------------ - - vol = T1ReadByte(MMU.ARM7_REG, 0x500) & 0x7F; - - for(int i=0;i<16;i++) - { - channel_struct *chan = &SPU->channels[i]; - - if (chan->status != CHANSTAT_PLAY) - continue; - - SPU->bufpos = 0; - SPU->buflength = length; - - // Mix audio - _SPU_ChanUpdate(!isChannelMuted(i) && actuallyMix, SPU, chan); - } - - // convert from 32-bit->16-bit - if(actuallyMix) - for (int i = 0; i < length*2; i++) - { - // Apply Master Volume - SPU->sndbuf[i] = spumuldiv7(SPU->sndbuf[i], vol); - - if (SPU->sndbuf[i] > 0x7FFF) - SPU->outbuf[i] = 0x7FFF; - else if (SPU->sndbuf[i] < -0x8000) - SPU->outbuf[i] = -0x8000; - else - SPU->outbuf[i] = (s16)SPU->sndbuf[i]; - } -} - -////////////////////////////////////////////////////////////////////////////// - - -//emulates one hline of the cpu core. -//this will produce a variable number of samples, calculated to keep a 44100hz output -//in sync with the emulator framerate -static const int dots_per_clock = 6; -static const int dots_per_hline = 355; -static const double time_per_hline = (double)1.0/((double)ARM7_CLOCK/dots_per_clock/dots_per_hline); -static const double samples_per_hline = time_per_hline * 44100; -int spu_core_samples = 0; -void SPU_Emulate_core() -{ - samples += samples_per_hline; - spu_core_samples = (int)(samples); - samples -= spu_core_samples; - - //TODO - /*if(driver->AVI_IsRecording() || driver->WAV_IsRecording()) - SPU_MixAudio(SPU_core,spu_core_samples); - else - SPU_MixAudio(SPU_core,spu_core_samples);*/ -} - -extern "C" void SPU_EmulateSamples(int numsamples) -{ - tot_samples += numsamples; - long temp = tot_samples&~1023; - if(update_trunc != temp) - { - void SoundView_Refresh(); - SoundView_Refresh(); - update_trunc = temp; - } - SPU_MixAudio(true,SPU_core,numsamples); - SNDCoreList[0]->UpdateAudio(SPU_core->outbuf,numsamples); -} - -void SPU_Emulate_user(bool mix) -{ - if(!SPU_user) - return; - - u32 audiosize; - - // Check to see how much free space there is - // If there is some, fill up the buffer - audiosize = SNDCore->GetAudioSpace(); - - if (audiosize > 0) - { - //printf("mix %i samples\n", audiosize); - if (audiosize > SPU_user->bufsize) - audiosize = SPU_user->bufsize; - if (mix) SPU_MixAudio(true,SPU_user,audiosize); - SNDCore->UpdateAudio(SPU_user->outbuf, audiosize); - } -} - -////////////////////////////////////////////////////////////////////////////// -// Dummy Sound Interface -////////////////////////////////////////////////////////////////////////////// - -int SNDDummyInit(int buffersize); -void SNDDummyDeInit(); -void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples); -u32 SNDDummyGetAudioSpace(); -void SNDDummyMuteAudio(); -void SNDDummyUnMuteAudio(); -void SNDDummySetVolume(int volume); - -SoundInterface_struct SNDDummy = { - SNDCORE_DUMMY, - "Dummy Sound Interface", - SNDDummyInit, - SNDDummyDeInit, - SNDDummyUpdateAudio, - SNDDummyGetAudioSpace, - SNDDummyMuteAudio, - SNDDummyUnMuteAudio, - SNDDummySetVolume -}; - -////////////////////////////////////////////////////////////////////////////// - -int SNDDummyInit(int buffersize) -{ - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyDeInit() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples) -{ -} - -////////////////////////////////////////////////////////////////////////////// - -u32 SNDDummyGetAudioSpace() -{ - return 740; -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyMuteAudio() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyUnMuteAudio() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummySetVolume(int volume) -{ -} - -////////////////////////////////////////////////////////////////////////////// -// -//typedef struct { -// char id[4]; -// u32 size; -//} chunk_struct; -// -//typedef struct { -// chunk_struct riff; -// char rifftype[4]; -//} waveheader_struct; -// -//typedef struct { -// chunk_struct chunk; -// u16 compress; -// u16 numchan; -// u32 rate; -// u32 bytespersec; -// u16 blockalign; -// u16 bitspersample; -//} fmt_struct; -// -//WavWriter::WavWriter() -//: spufp(NULL) -//{ -//} -//bool WavWriter::open(const std::string & fname) -//{ -// waveheader_struct waveheader; -// fmt_struct fmt; -// chunk_struct data; -// size_t elems_written = 0; -// -// if ((spufp = fopen(fname.c_str(), "wb")) == NULL) -// return false; -// -// // Do wave header -// memcpy(waveheader.riff.id, "RIFF", 4); -// waveheader.riff.size = 0; // we'll fix this after the file is closed -// memcpy(waveheader.rifftype, "WAVE", 4); -// elems_written += fwrite((void *)&waveheader, 1, sizeof(waveheader_struct), spufp); -// -// // fmt chunk -// memcpy(fmt.chunk.id, "fmt ", 4); -// fmt.chunk.size = 16; // we'll fix this at the end -// fmt.compress = 1; // PCM -// fmt.numchan = 2; // Stereo -// fmt.rate = 44100; -// fmt.bitspersample = 16; -// fmt.blockalign = fmt.bitspersample / 8 * fmt.numchan; -// fmt.bytespersec = fmt.rate * fmt.blockalign; -// elems_written += fwrite((void *)&fmt, 1, sizeof(fmt_struct), spufp); -// -// // data chunk -// memcpy(data.id, "data", 4); -// data.size = 0; // we'll fix this at the end -// elems_written += fwrite((void *)&data, 1, sizeof(chunk_struct), spufp); -// -// return true; -//} -// -//void WavWriter::close() -//{ -// if(!spufp) return; -// size_t elems_written = 0; -// long length = ftell(spufp); -// -// // Let's fix the riff chunk size and the data chunk size -// fseek(spufp, sizeof(waveheader_struct)-0x8, SEEK_SET); -// length -= 0x8; -// elems_written += fwrite((void *)&length, 1, 4, spufp); -// -// fseek(spufp, sizeof(waveheader_struct)+sizeof(fmt_struct)+0x4, SEEK_SET); -// length -= sizeof(waveheader_struct)+sizeof(fmt_struct); -// elems_written += fwrite((void *)&length, 1, 4, spufp); -// fclose(spufp); -// spufp = NULL; -//} -// -//void WavWriter::update(void* soundData, int numSamples) -//{ -// if(!spufp) return; -// //TODO - big endian for the s16 samples?? -// size_t elems_written = fwrite(soundData, numSamples*2, 2, spufp); -//} -// -//bool WavWriter::isRecording() const -//{ -// return spufp != NULL; -//} -// -// -//static WavWriter wavWriter; -// -//void WAV_End() -//{ -// wavWriter.close(); -//} -// -//bool WAV_Begin(const char* fname) -//{ -// WAV_End(); -// -// if(!wavWriter.open(fname)) -// return false; -// -// driver->USR_InfoMessage("WAV recording started."); -// -// return true; -//} -// -//bool WAV_IsRecording() -//{as -// return wavWriter.isRecording(); -//} -// -//void WAV_WavSoundUpdate(void* soundData, int numSamples) -//{ -// wavWriter.update(soundData, numSamples); -//} -// diff --git a/tools/vio2sf/src/vio2sf/desmume/SPU.h b/tools/vio2sf/src/vio2sf/desmume/SPU.h deleted file mode 100644 index 59ca3aecf..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/SPU.h +++ /dev/null @@ -1,186 +0,0 @@ -/* SPU.h - - Copyright 2006 Theo Berkau - Copyright (C) 2006-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef SPU_H -#define SPU_H - -#include -#include "types.h" -#include -#include - -#define FORCEINLINE __forceinline - -FORCEINLINE u32 u32floor(float f) -{ -#ifdef ENABLE_SSE2 - return (u32)_mm_cvtt_ss2si(_mm_set_ss(f)); -#else - return (u32)f; -#endif -} -FORCEINLINE u32 u32floor(double d) -{ -#ifdef ENABLE_SSE2 - return (u32)_mm_cvttsd_si32(_mm_set_sd(d)); -#else - return (u32)d; -#endif -} - -//same as above but works for negative values too. -//be sure that the results are the same thing as floorf! -FORCEINLINE s32 s32floor(float f) -{ -#ifdef ENABLE_SSE2 - return _mm_cvtss_si32( _mm_add_ss(_mm_set_ss(-0.5f),_mm_add_ss(_mm_set_ss(f), _mm_set_ss(f))) ) >> 1; -#else - return (s32)floorf(f); -#endif -} - - -static FORCEINLINE u32 sputrunc(float f) { return u32floor(f); } -static FORCEINLINE u32 sputrunc(double d) { return u32floor(d); } -static FORCEINLINE s32 spumuldiv7(s32 val, u8 multiplier) { - assert(multiplier <= 127); - return (multiplier == 127) ? val : ((val * multiplier) >> 7); -} - -#define SNDCORE_DEFAULT -1 -#define SNDCORE_DUMMY 0 - -#define CHANSTAT_STOPPED 0 -#define CHANSTAT_PLAY 1 - - -enum SPUInterpolationMode -{ - SPUInterpolation_None = 0, - SPUInterpolation_Linear = 1, - SPUInterpolation_Cosine = 2 -}; - -struct SoundInterface_struct -{ - int id; - const char *Name; - int (*Init)(int buffersize); - void (*DeInit)(); - void (*UpdateAudio)(s16 *buffer, u32 num_samples); - u32 (*GetAudioSpace)(); - void (*MuteAudio)(); - void (*UnMuteAudio)(); - void (*SetVolume)(int volume); -}; - -extern SoundInterface_struct SNDDummy; -extern SoundInterface_struct SNDFile; -extern int SPU_currentCoreNum; - -struct channel_struct -{ - channel_struct() - {} - u32 num; - u8 vol; - u8 datashift; - u8 hold; - u8 pan; - u8 waveduty; - u8 repeat; - u8 format; - u8 status; - u32 addr; - u16 timer; - u16 loopstart; - u32 length; - u32 totlength; - double double_totlength_shifted; - union { - s8 *buf8; - s16 *buf16; - }; - double sampcnt; - double sampinc; - // ADPCM specific - u32 lastsampcnt; - s16 pcm16b, pcm16b_last; - s16 loop_pcm16b; - int index; - int loop_index; - u16 x; - s16 psgnoise_last; -} ; - -class SPU_struct -{ -public: - SPU_struct(int buffersize); - u32 bufpos; - u32 buflength; - s32 *sndbuf; - s16 *outbuf; - u32 bufsize; - channel_struct channels[16]; - - 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); - - //kills all channels but leaves SPU otherwise running normally - void ShutUp(); -}; - -SoundInterface_struct *SPU_SoundCore(); - -void SPU_Pause(int pause); -void SPU_SetVolume(int volume); -void SPU_KeyOn(int channel); -void SPU_Emulate_core(void); -void SPU_Emulate_user(bool mix = true); - -extern SPU_struct *SPU_core, *SPU_user; -extern int spu_core_samples; - -class WavWriter -{ -public: - WavWriter(); - bool open(const std::string & fname); - void close(); - void update(void* soundData, int numSamples); - bool isRecording() const; -private: - FILE *spufp; -}; - - -void WAV_End(); -bool WAV_Begin(const char* fname); -bool WAV_IsRecording(); -void WAV_WavSoundUpdate(void* soundData, int numSamples); - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/arm_instructions.c b/tools/vio2sf/src/vio2sf/desmume/arm_instructions.c deleted file mode 100644 index 40418c733..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/arm_instructions.c +++ /dev/null @@ -1,7928 +0,0 @@ -/* Copyright (C) 2006 yopyop - Copyright (C) 2006 shash - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "cp15.h" -#include "debug.h" -#include "MMU.h" - - -// Use this macros for reading/writing, so the GDB stub isn't broken -#ifdef GDB_STUB - #define READ32(a,b) cpu->mem_if->read32(a,b) - #define WRITE32(a,b,c) cpu->mem_if->write32(a,b,c) - #define READ16(a,b) cpu->mem_if->read16(a,b) - #define WRITE16(a,b,c) cpu->mem_if->write16(a,b,c) - #define READ8(a,b) cpu->mem_if->read8(a,b) - #define WRITE8(a,b,c) cpu->mem_if->write8(a,b,c) -#else - #define READ32(a,b) MMU_read32(cpu->proc_ID, b) - #define WRITE32(a,b,c) MMU_write32(cpu->proc_ID,b,c) - #define READ16(a,b) MMU_read16(cpu->proc_ID, b) - #define WRITE16(a,b,c) MMU_write16(cpu->proc_ID,b,c) - #define READ8(a,b) MMU_read8(cpu->proc_ID, b) - #define WRITE8(a,b,c) MMU_write8(cpu->proc_ID,b,c) -#endif - - - -#define LSL_IMM shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F); - -#define S_LSL_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ - shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F);\ - } - -#define LSL_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if(shift_op>=32)\ - shift_op=0;\ - else\ - shift_op=cpu->R[REG_POS(i,0)]<R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - if(shift_op<32)\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ - shift_op = cpu->R[REG_POS(i,0)]<R[REG_POS(i,0)]);\ - }\ - else\ - {\ - shift_op = 0;\ - c = 0;\ - } - -#define LSR_IMM shift_op = ((i>>7)&0x1F);\ - if(shift_op!=0)\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op; - -#define S_LSR_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ - } - -#define LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if(shift_op>=32)\ - shift_op = 0;\ - else\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op; - -#define S_LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - shift_op = cpu->R[REG_POS(i,0)];\ - }\ - else\ - if(shift_op<32)\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ - }\ - else\ - if(shift_op==32)\ - {\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - shift_op = 0;\ - }\ - else\ - {\ - c = 0;\ - shift_op = 0;\ - } - -#define ASR_IMM shift_op = ((i>>7)&0x1F);\ - if(shift_op==0)\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ - else\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op); - -#define S_ASR_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ - } - -#define ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - if(shift_op<32)\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ - else\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF; - -#define S_ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - if(shift_op<32)\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ - }\ - else\ - {\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ - } - -#define ROR_IMM shift_op = ((i>>7)&0x1F);\ - if(shift_op==0)\ - {\ - u32 tmp = cpu->CPSR.bits.C;\ - shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ - }\ - else\ - shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op); - -#define S_ROR_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - u32 tmp = cpu->CPSR.bits.C;\ - shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ - c = BIT0(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op);\ - } - -#define ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if((shift_op==0)||((shift_op&0xF)==0))\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0xF)); - -#define S_ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - {\ - shift_op&=0xF;\ - if(shift_op==0)\ - {\ - shift_op=cpu->R[REG_POS(i,0)];\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0xF));\ - }\ - } - -#define IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E); - -#define S_IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ - u32 c = cpu->CPSR.bits.C;\ - if((i>>8)&0xF)\ - c = BIT31(shift_op); - -#define IMM_OFF (((i>>4)&0xF0)+(i&0xF)) - -#define IMM_OFF_12 ((i)&0xFFF) - -extern BOOL execute; - -static u32 FASTCALL OP_UND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LOG("Undefined instruction: %08X\n", i); - execute = FALSE; - return 1; -} - -//-----------------------AND------------------------------------ - -#define OP_AND(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OP_ANDS(a, b)\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR;\ - cpu->R[15] = cpu->R[REG_POS(i,16)] & shift_op;\ - SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -static u32 FASTCALL OP_AND_LSL_IMM(register armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_AND(1, 3); -} - -static u32 FASTCALL OP_AND_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_AND(2, 4); -} - -static u32 FASTCALL OP_AND_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_AND(1, 3); -} - -static u32 FASTCALL OP_AND_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_AND(2, 4); -} - -static u32 FASTCALL OP_AND_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_AND(1, 3); -} - -static u32 FASTCALL OP_AND_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_AND(2, 4); -} - -static u32 FASTCALL OP_AND_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_AND(1, 3); -} - -static u32 FASTCALL OP_AND_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_AND(2, 4); -} - -static u32 FASTCALL OP_AND_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_AND(1, 3); -} - -static u32 FASTCALL OP_AND_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - OP_ANDS(2, 4); -} - -static u32 FASTCALL OP_AND_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - OP_ANDS(3, 5); -} - -static u32 FASTCALL OP_AND_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - OP_ANDS(2, 4); -} - -static u32 FASTCALL OP_AND_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - OP_ANDS(3, 5); -} - -static u32 FASTCALL OP_AND_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - OP_ANDS(2, 4); -} - -static u32 FASTCALL OP_AND_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - OP_ANDS(3, 5); -} - -static u32 FASTCALL OP_AND_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - OP_ANDS(2, 4); -} - -static u32 FASTCALL OP_AND_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - OP_ANDS(3, 5); -} - -static u32 FASTCALL OP_AND_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - OP_ANDS(2, 4); -} - -//--------------EOR------------------------------ - -#define OP_EOR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OP_EORS(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -static u32 FASTCALL OP_EOR_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_EOR(1, 3); -} - -static u32 FASTCALL OP_EOR_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_EOR(2, 4); -} - -static u32 FASTCALL OP_EOR_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_EOR(1, 3); -} - -static u32 FASTCALL OP_EOR_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_EOR(2, 4); -} - -static u32 FASTCALL OP_EOR_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_EOR(1, 3); -} - -static u32 FASTCALL OP_EOR_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_EOR(2, 4); -} - -static u32 FASTCALL OP_EOR_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_EOR(1, 3); -} - -static u32 FASTCALL OP_EOR_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_EOR(2, 4); -} - -static u32 FASTCALL OP_EOR_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_EOR(1, 3); -} - -static u32 FASTCALL OP_EOR_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - OP_EORS(2, 4); -} - -static u32 FASTCALL OP_EOR_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - OP_EORS(3, 5); -} - -static u32 FASTCALL OP_EOR_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - OP_EORS(2, 4); -} - -static u32 FASTCALL OP_EOR_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - OP_EORS(3, 5); -} - -static u32 FASTCALL OP_EOR_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - OP_EORS(2, 4); -} - -static u32 FASTCALL OP_EOR_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - OP_EORS(3, 5); -} - -static u32 FASTCALL OP_EOR_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - OP_EORS(2, 4); -} - -static u32 FASTCALL OP_EOR_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - OP_EORS(3, 5); -} - -static u32 FASTCALL OP_EOR_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - OP_EORS(2, 4); -} - -//-------------SUB------------------------------------- - -#define OP_SUB(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OPSUBS(a, b) cpu->R[REG_POS(i,12)] = v - shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - return a; - -static u32 FASTCALL OP_SUB_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_SUB(1, 3); -} - -static u32 FASTCALL OP_SUB_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_SUB(2, 4); -} - -static u32 FASTCALL OP_SUB_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_SUB(1, 3); -} - -static u32 FASTCALL OP_SUB_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_SUB(2, 4); -} - -static u32 FASTCALL OP_SUB_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_SUB(1, 3); -} - -static u32 FASTCALL OP_SUB_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_SUB(2, 4); -} - -static u32 FASTCALL OP_SUB_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_SUB(1, 3); -} - -static u32 FASTCALL OP_SUB_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_SUB(2, 4); -} - -static u32 FASTCALL OP_SUB_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_SUB(1, 3); -} - -static u32 FASTCALL OP_SUB_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OPSUBS(2, 4); -} - -static u32 FASTCALL OP_SUB_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OPSUBS(3, 5); -} - -static u32 FASTCALL OP_SUB_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OPSUBS(2, 4); -} - -static u32 FASTCALL OP_SUB_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OPSUBS(3, 5); -} - -static u32 FASTCALL OP_SUB_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OPSUBS(2, 4); -} - -static u32 FASTCALL OP_SUB_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OPSUBS(3, 5); -} - -static u32 FASTCALL OP_SUB_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OPSUBS(2, 4); -} - -static u32 FASTCALL OP_SUB_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OPSUBS(3, 5); -} - -static u32 FASTCALL OP_SUB_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OPSUBS(2, 4); -} - -//------------------RSB------------------------ - -#define OP_RSB(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)];\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OP_RSBS(a, b) cpu->R[REG_POS(i,12)] = shift_op - v;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ - return a; - -static u32 FASTCALL OP_RSB_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_RSB(1, 3); -} - -static u32 FASTCALL OP_RSB_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_RSB(2, 4); -} - -static u32 FASTCALL OP_RSB_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_RSB(1, 3); -} - -static u32 FASTCALL OP_RSB_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_RSB(2, 4); -} - -static u32 FASTCALL OP_RSB_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_RSB(1, 3); -} - -static u32 FASTCALL OP_RSB_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_RSB(2, 4); -} - -static u32 FASTCALL OP_RSB_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_RSB(1, 3); -} - -static u32 FASTCALL OP_RSB_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_RSB(2, 4); -} - -static u32 FASTCALL OP_RSB_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_RSB(1, 3); -} - -static u32 FASTCALL OP_RSB_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_RSBS(2, 4); -} - -static u32 FASTCALL OP_RSB_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_RSBS(3, 5); -} - -static u32 FASTCALL OP_RSB_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_RSBS(2, 4); -} - -static u32 FASTCALL OP_RSB_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_RSBS(3, 5); -} - -static u32 FASTCALL OP_RSB_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_RSBS(2, 4); -} - -static u32 FASTCALL OP_RSB_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_RSBS(3, 5); -} - -static u32 FASTCALL OP_RSB_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_RSBS(2, 4); -} - -static u32 FASTCALL OP_RSB_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_RSBS(3, 5); -} - -static u32 FASTCALL OP_RSB_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_RSBS(2, 4); -} - -//------------------ADD----------------------------------- - -#define OP_ADD(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -static u32 FASTCALL OP_ADD_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_ADD(1, 3); -} - -static u32 FASTCALL OP_ADD_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_ADD(2, 4); -} - -static u32 FASTCALL OP_ADD_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_ADD(1, 3); -} - -static u32 FASTCALL OP_ADD_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_ADD(2, 4); -} - -static u32 FASTCALL OP_ADD_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_ADD(1, 3); -} - -static u32 FASTCALL OP_ADD_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_ADD(2, 4); -} - -static u32 FASTCALL OP_ADD_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_ADD(1, 3); -} - -static u32 FASTCALL OP_ADD_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_ADD(2, 4); -} - -static u32 FASTCALL OP_ADD_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_ADD(1, 3); -} - -#define OP_ADDS(a, b) cpu->R[REG_POS(i,12)] = v + shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - return a; - -static u32 FASTCALL OP_ADD_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_ADDS(2, 4); -} - -static u32 FASTCALL OP_ADD_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_ADDS(3, 5); -} - -static u32 FASTCALL OP_ADD_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_ADDS(2, 4); -} - -static u32 FASTCALL OP_ADD_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_ADDS(3, 5); -} - -static u32 FASTCALL OP_ADD_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_ADDS(2, 4); -} - -static u32 FASTCALL OP_ADD_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_ADDS(3, 5); -} - -static u32 FASTCALL OP_ADD_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_ADDS(2, 4); -} - -static u32 FASTCALL OP_ADD_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_ADDS(3, 5); -} - -static u32 FASTCALL OP_ADD_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_ADDS(2, 4); -} - -//------------------ADC----------------------------------- - -#define OP_ADC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op + cpu->CPSR.bits.C;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -static u32 FASTCALL OP_ADC_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_ADC(1, 3); -} - -static u32 FASTCALL OP_ADC_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_ADC(2, 4); -} - -static u32 FASTCALL OP_ADC_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_ADC(1, 3); -} - -static u32 FASTCALL OP_ADC_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_ADC(2, 4); -} - -static u32 FASTCALL OP_ADC_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_ADC(1, 3); -} - -static u32 FASTCALL OP_ADC_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_ADC(2, 4); -} - -static u32 FASTCALL OP_ADC_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_ADC(1, 3); -} - -static u32 FASTCALL OP_ADC_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_ADC(2, 4); -} - -static u32 FASTCALL OP_ADC_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_ADC(1, 3); -} - -#define OP_ADCS(a, b) \ - { \ - u32 tmp = shift_op + cpu->CPSR.bits.C;\ - cpu->R[REG_POS(i,12)] = v + tmp;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(shift_op, cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_OVERFLOW(shift_op, cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ - return a; \ - } - -static u32 FASTCALL OP_ADC_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_ADCS(2, 4); -} - -static u32 FASTCALL OP_ADC_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_ADCS(3, 5); -} - -static u32 FASTCALL OP_ADC_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_ADCS(2, 4); -} - -static u32 FASTCALL OP_ADC_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_ADCS(3, 5); -} - -static u32 FASTCALL OP_ADC_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_ADCS(2, 4); -} - -static u32 FASTCALL OP_ADC_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_ADCS(3, 5); -} - -static u32 FASTCALL OP_ADC_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_ADCS(2, 4); -} - -static u32 FASTCALL OP_ADC_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_ADCS(3, 5); -} - -static u32 FASTCALL OP_ADC_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_ADCS(2, 4); -} - -//-------------SBC------------------------------------- - -#define OP_SBC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op - (!cpu->CPSR.bits.C);\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -static u32 FASTCALL OP_SBC_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_SBC(1, 3); -} - -static u32 FASTCALL OP_SBC_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_SBC(2, 4); -} - -static u32 FASTCALL OP_SBC_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_SBC(1, 3); -} - -static u32 FASTCALL OP_SBC_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_SBC(2, 4); -} - -static u32 FASTCALL OP_SBC_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_SBC(1, 3); -} - -static u32 FASTCALL OP_SBC_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_SBC(2, 4); -} - -static u32 FASTCALL OP_SBC_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_SBC(1, 3); -} - -static u32 FASTCALL OP_SBC_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_SBC(2, 4); -} - -static u32 FASTCALL OP_SBC_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_SBC(1, 3); -} - -#define OP_SBCS(a, b) \ - { \ - u32 tmp = v - (!cpu->CPSR.bits.C);\ - cpu->R[REG_POS(i,12)] = tmp - shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(v, (!cpu->CPSR.bits.C), tmp)) & (!UNSIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]));\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, (!cpu->CPSR.bits.C), tmp) | SIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]);\ - return a; \ - } - -static u32 FASTCALL OP_SBC_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_SBCS(2, 4); -} - -static u32 FASTCALL OP_SBC_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_SBCS(3, 5); -} - -static u32 FASTCALL OP_SBC_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_SBCS(2, 4); -} - -static u32 FASTCALL OP_SBC_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_SBCS(3, 5); -} - -static u32 FASTCALL OP_SBC_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_SBCS(2, 4); -} - -static u32 FASTCALL OP_SBC_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_SBCS(3, 5); -} - -static u32 FASTCALL OP_SBC_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_SBCS(2, 4); -} - -static u32 FASTCALL OP_SBC_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_SBCS(3, 5); -} - -static u32 FASTCALL OP_SBC_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_SBCS(2, 4); -} - -//---------------RSC---------------------------------- - -#define OP_RSC(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)] - (!cpu->CPSR.bits.C);\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -static u32 FASTCALL OP_RSC_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_RSC(1, 3); -} - -static u32 FASTCALL OP_RSC_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_RSC(2, 4); -} - -static u32 FASTCALL OP_RSC_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_RSC(1, 3); -} - -static u32 FASTCALL OP_RSC_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_RSC(2, 4); -} - -static u32 FASTCALL OP_RSC_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_RSC(1, 3); -} - -static u32 FASTCALL OP_RSC_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_RSC(2, 4); -} - -static u32 FASTCALL OP_RSC_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_RSC(1, 3); -} - -static u32 FASTCALL OP_RSC_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_RSC(2, 4); -} - -static u32 FASTCALL OP_RSC_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_RSC(1, 3); -} - -#define OP_RSCS(a,b) \ - { \ - u32 tmp = shift_op - (!cpu->CPSR.bits.C);\ - cpu->R[REG_POS(i,12)] = tmp - v;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(shift_op, (!cpu->CPSR.bits.C), tmp)) & (!UNSIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]));\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, (!cpu->CPSR.bits.C), tmp) | SIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]);\ - return a; \ - } - -static u32 FASTCALL OP_RSC_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_RSCS(2,4); -} - -static u32 FASTCALL OP_RSC_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_RSCS(3,5); -} - -static u32 FASTCALL OP_RSC_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_RSCS(2,4); -} - -static u32 FASTCALL OP_RSC_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_RSCS(3,5); -} - -static u32 FASTCALL OP_RSC_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_RSCS(2,4); -} - -static u32 FASTCALL OP_RSC_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_RSCS(3,5); -} - -static u32 FASTCALL OP_RSC_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_RSCS(2,4); -} - -static u32 FASTCALL OP_RSC_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_RSCS(3,5); -} - -static u32 FASTCALL OP_RSC_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_RSCS(2,4); -} - -//-------------------TST---------------------------- - -#define OP_TST(a) \ - { \ - unsigned tmp = cpu->R[REG_POS(i,16)] & shift_op;\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - return a; \ - } - -static u32 FASTCALL OP_TST_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - OP_TST(1); -} - -static u32 FASTCALL OP_TST_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - OP_TST(2); -} - -static u32 FASTCALL OP_TST_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - OP_TST(1); -} - -static u32 FASTCALL OP_TST_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - OP_TST(2); -} - -static u32 FASTCALL OP_TST_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - OP_TST(1); -} - -static u32 FASTCALL OP_TST_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - OP_TST(2); -} - -static u32 FASTCALL OP_TST_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - OP_TST(1); -} - -static u32 FASTCALL OP_TST_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - OP_TST(2); -} - -static u32 FASTCALL OP_TST_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - OP_TST(1); -} - -//-------------------TEQ---------------------------- - -#define OP_TEQ(a) \ - { \ - unsigned tmp = cpu->R[REG_POS(i,16)] ^ shift_op;\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - return a; \ - } - -static u32 FASTCALL OP_TEQ_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - OP_TEQ(1); -} - -static u32 FASTCALL OP_TEQ_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - OP_TEQ(2); -} - -static u32 FASTCALL OP_TEQ_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - OP_TEQ(1); -} - -static u32 FASTCALL OP_TEQ_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - OP_TEQ(2); -} - -static u32 FASTCALL OP_TEQ_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - OP_TEQ(1); -} - -static u32 FASTCALL OP_TEQ_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - OP_TEQ(2); -} - -static u32 FASTCALL OP_TEQ_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - OP_TEQ(1); -} - -static u32 FASTCALL OP_TEQ_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - OP_TEQ(2); -} - -static u32 FASTCALL OP_TEQ_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - OP_TEQ(1); -} - -//-------------CMP------------------------------------- - -#define OP_CMP(a) \ - { \ - u32 tmp = cpu->R[REG_POS(i,16)] - shift_op;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - return a; \ - } - -static u32 FASTCALL OP_CMP_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_CMP(1); -} - -static u32 FASTCALL OP_CMP_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_CMP(2); -} - -static u32 FASTCALL OP_CMP_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_CMP(1); -} - -static u32 FASTCALL OP_CMP_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_CMP(2); -} - -static u32 FASTCALL OP_CMP_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_CMP(1); -} - -static u32 FASTCALL OP_CMP_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_CMP(2); -} - -static u32 FASTCALL OP_CMP_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_CMP(1); -} - -static u32 FASTCALL OP_CMP_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_CMP(2); -} - -static u32 FASTCALL OP_CMP_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_CMP(1); -} - -//---------------CMN--------------------------- - -#define OP_CMN(a) \ - { \ - u32 tmp = cpu->R[REG_POS(i,16)] + shift_op;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - return a; \ - } - -static u32 FASTCALL OP_CMN_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_CMN(1); -} - -static u32 FASTCALL OP_CMN_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_CMN(2); -} - -static u32 FASTCALL OP_CMN_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_CMN(1); -} - -static u32 FASTCALL OP_CMN_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_CMN(2); -} - -static u32 FASTCALL OP_CMN_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_CMN(1); -} - -static u32 FASTCALL OP_CMN_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_CMN(2); -} - -static u32 FASTCALL OP_CMN_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_CMN(1); -} - -static u32 FASTCALL OP_CMN_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_CMN(2); -} - -static u32 FASTCALL OP_CMN_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_CMN(1); -} - -//------------------ORR------------------- - -#define OP_ORR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -static u32 FASTCALL OP_ORR_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_ORR(1, 3); -} - -static u32 FASTCALL OP_ORR_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OP_ORR(2, 4); -} - -static u32 FASTCALL OP_ORR_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_ORR(1, 3); -} - -static u32 FASTCALL OP_ORR_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OP_ORR(2, 4); -} - -static u32 FASTCALL OP_ORR_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_ORR(1, 3); -} - -static u32 FASTCALL OP_ORR_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_ORR(2, 4); -} - -static u32 FASTCALL OP_ORR_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_ORR(1, 3); -} - -static u32 FASTCALL OP_ORR_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_ORR(2, 4); -} - -static u32 FASTCALL OP_ORR_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_ORR(1, 3); -} - -static u32 FASTCALL OP_ORR_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 4; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 2; -} - -static u32 FASTCALL OP_ORR_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 5; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 3; -} - -static u32 FASTCALL OP_ORR_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 4; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 2; -} - -static u32 FASTCALL OP_ORR_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 5; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 3; -} - -static u32 FASTCALL OP_ORR_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 4; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 2; -} - -static u32 FASTCALL OP_ORR_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 5; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 3; -} - -static u32 FASTCALL OP_ORR_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 4; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 2; -} - -static u32 FASTCALL OP_ORR_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 5; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 3; -} - -static u32 FASTCALL OP_ORR_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; - if(REG_POS(i,12)==15) - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); - cpu->next_instruction = cpu->R[15]; - return 4; - } - cpu->CPSR.bits.C = c; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); - return 2; -} - -//------------------MOV------------------- - -#define OP_MOV(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = shift_op;\ - return b;\ - }\ - return a; - -#define OP_MOV_S(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ - if(BIT20(i) && REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a;\ - -static u32 FASTCALL OP_MOV_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_MOV(1,3); -} - -static u32 FASTCALL OP_MOV_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV(2,4); -} - -static u32 FASTCALL OP_MOV_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_MOV(1,3); -} - -static u32 FASTCALL OP_MOV_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV(2,4); -} - -static u32 FASTCALL OP_MOV_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_MOV(1,3); -} - -static u32 FASTCALL OP_MOV_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OP_MOV(2,4); -} - -static u32 FASTCALL OP_MOV_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_MOV(2,4); -} - -static u32 FASTCALL OP_MOV_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OP_MOV(2,4); -} - -static u32 FASTCALL OP_MOV_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OP_MOV(1,3); -} - -static u32 FASTCALL OP_MOV_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - OP_MOV_S(2,4); -} - -static u32 FASTCALL OP_MOV_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV_S(3,5); -} - -static u32 FASTCALL OP_MOV_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - OP_MOV_S(2,4); -} - -static u32 FASTCALL OP_MOV_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV_S(3,5); -} - -static u32 FASTCALL OP_MOV_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - OP_MOV_S(2,4); -} - -static u32 FASTCALL OP_MOV_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - OP_MOV_S(3,5); -} - -static u32 FASTCALL OP_MOV_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - OP_MOV_S(2,4); -} - -static u32 FASTCALL OP_MOV_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - OP_MOV_S(3,5); -} - -static u32 FASTCALL OP_MOV_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - OP_MOV_S(2,4); -} - -//------------------BIC------------------- -#define OPP_BIC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OPP_BIC_S(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -static u32 FASTCALL OP_BIC_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OPP_BIC(1,3); -} - -static u32 FASTCALL OP_BIC_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OPP_BIC(2,4); -} - -static u32 FASTCALL OP_BIC_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OPP_BIC(1,3); -} - -static u32 FASTCALL OP_BIC_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OPP_BIC(2,4); -} - -static u32 FASTCALL OP_BIC_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OPP_BIC(1,3); -} - -static u32 FASTCALL OP_BIC_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OPP_BIC(2,4); -} - -static u32 FASTCALL OP_BIC_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OPP_BIC(1,3); -} - -static u32 FASTCALL OP_BIC_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OPP_BIC(2,4); -} - -static u32 FASTCALL OP_BIC_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OPP_BIC(1,3); -} - -static u32 FASTCALL OP_BIC_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - OPP_BIC_S(2,4); -} - -static u32 FASTCALL OP_BIC_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - OPP_BIC_S(3,5); -} - -static u32 FASTCALL OP_BIC_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - OPP_BIC_S(2,4); -} - -static u32 FASTCALL OP_BIC_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - OPP_BIC_S(3,5); -} - -static u32 FASTCALL OP_BIC_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - OPP_BIC_S(2,4); -} - -static u32 FASTCALL OP_BIC_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - OPP_BIC_S(3,5); -} - -static u32 FASTCALL OP_BIC_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - OPP_BIC_S(2,4); -} - -static u32 FASTCALL OP_BIC_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - OPP_BIC_S(3,5); -} - -static u32 FASTCALL OP_BIC_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - OPP_BIC_S(2,4); -} - -//------------------MVN------------------- -#define OPP_MVN(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OPP_MVN_S(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -static u32 FASTCALL OP_MVN_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OPP_MVN(1,3); -} - -static u32 FASTCALL OP_MVN_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSL_REG; - OPP_MVN(2,4); -} - -static u32 FASTCALL OP_MVN_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OPP_MVN(1,3); -} - -static u32 FASTCALL OP_MVN_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - LSR_REG; - OPP_MVN(2,4); -} - -static u32 FASTCALL OP_MVN_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OPP_MVN(1,3); -} - -static u32 FASTCALL OP_MVN_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ASR_REG; - OPP_MVN(2,4); -} - -static u32 FASTCALL OP_MVN_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OPP_MVN(1,3); -} - -static u32 FASTCALL OP_MVN_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - ROR_REG; - OPP_MVN(2,4); -} - -static u32 FASTCALL OP_MVN_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - OPP_MVN(1,3); -} - -static u32 FASTCALL OP_MVN_S_LSL_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_IMM; - OPP_MVN_S(2,4); -} - -static u32 FASTCALL OP_MVN_S_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSL_REG; - OPP_MVN_S(3,5); -} - -static u32 FASTCALL OP_MVN_S_LSR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_IMM; - OPP_MVN_S(2,4); -} - -static u32 FASTCALL OP_MVN_S_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_LSR_REG; - OPP_MVN_S(3,5); -} - -static u32 FASTCALL OP_MVN_S_ASR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_IMM; - OPP_MVN_S(2,4); -} - -static u32 FASTCALL OP_MVN_S_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ASR_REG; - OPP_MVN_S(3,5); -} - -static u32 FASTCALL OP_MVN_S_ROR_IMM(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_IMM; - OPP_MVN_S(2,4); -} - -static u32 FASTCALL OP_MVN_S_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_ROR_REG; - OPP_MVN_S(3,5); -} - -static u32 FASTCALL OP_MVN_S_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - S_IMM_VALUE; - OPP_MVN_S(2,4); -} - -//-------------MUL------------------------ -#define OPP_M(a,b) v >>= 8;\ - if((v==0)||(v==0xFFFFFF))\ - return b;\ - v >>= 8;\ - if((v==0)||(v==0xFFFF))\ - return b+1;\ - v >>= 8;\ - if((v==0)||(v==0xFF))\ - return b+2;\ - return a;\ - -static u32 FASTCALL OP_MUL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; - OPP_M(5,2); -} - -static u32 FASTCALL OP_MLA(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u32 a = cpu->R[REG_POS(i,8)]; - u32 b = cpu->R[REG_POS(i,12)]; - cpu->R[REG_POS(i,16)] = a * v + b; - - OPP_M(6,3); -} - -static u32 FASTCALL OP_MUL_S(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); - - OPP_M(6,3); -} - -static u32 FASTCALL OP_MLA_S(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v + cpu->R[REG_POS(i,12)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); - OPP_M(7,4); -} - -//----------UMUL-------------------------- - -static u32 FASTCALL OP_UMULL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - OPP_M(6,3); -} - -static u32 FASTCALL OP_UMLAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - OPP_M(7,4); -} - -static u32 FASTCALL OP_UMULL_S(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - OPP_M(7,4); -} - -static u32 FASTCALL OP_UMLAL_S(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - OPP_M(8,5); -} - -//----------SMUL-------------------------- - -static u32 FASTCALL OP_SMULL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b; - - cpu->R[REG_POS(i,12)] = (u32)(res&0xFFFFFFFF); - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - v &= 0xFFFFFFFF; - - OPP_M(6,3); -} - -static u32 FASTCALL OP_SMLAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; - - //LOG("%08X * %08X + %08X%08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)]); - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - //LOG("= %08X%08X %08X%08X\r\n", cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)], res); - - v &= 0xFFFFFFFF; - - OPP_M(7,4); -} - -static u32 FASTCALL OP_SMULL_S(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - v &= 0xFFFFFFFF; - - OPP_M(7,4); -} - -static u32 FASTCALL OP_SMLAL_S(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - v &= 0xFFFFFFFF; - - OPP_M(8,5); -} - -//---------------SWP------------------------------ - -static u32 FASTCALL OP_SWP(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 tmp = ROR(READ32(cpu->mem_if->data, adr), ((cpu->R[REG_POS(i,16)]&3)<<3)); - - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,0)]); - cpu->R[REG_POS(i,12)] = tmp; - - return 4 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]*2; -} - -static u32 FASTCALL OP_SWPB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u8 tmp = READ8(cpu->mem_if->data, adr); - WRITE8(cpu->mem_if->data, adr, (u8)(cpu->R[REG_POS(i,0)]&0xFF)); - cpu->R[REG_POS(i,12)] = tmp; - - return 4 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]*2; -} - -//------------LDRH----------------------------- - -static u32 FASTCALL OP_LDRH_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_PRE_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] =(u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_PRE_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_POS_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_POS_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_POS_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_POS_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//------------STRH----------------------------- - -static u32 FASTCALL OP_STRH_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,16)] = adr; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_PRE_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_PRE_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_POS_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_POS_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_POS_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_POS_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//----------------LDRSH-------------------------- - -static u32 FASTCALL OP_LDRSH_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_PRE_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_PRE_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_POS_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_POS_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_POS_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_POS_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//----------------------LDRSB---------------------- - -static u32 FASTCALL OP_LDRSB_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_PRE_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_PRE_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_POS_INDE_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_POS_INDE_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_POS_INDE_P_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_POS_INDE_M_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//--------------MRS-------------------------------- - -static u32 FASTCALL OP_MRS_CPSR(armcpu_t *cpu) -{ - cpu->R[REG_POS(cpu->instruction,12)] = cpu->CPSR.val; - - return 1; -} - -static u32 FASTCALL OP_MRS_SPSR(armcpu_t *cpu) -{ - cpu->R[REG_POS(cpu->instruction,12)] = cpu->SPSR.val; - - return 1; -} - -//--------------MSR-------------------------------- - -static u32 FASTCALL OP_MSR_CPSR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 operand = cpu->R[REG_POS(i,0)]; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - armcpu_switchMode(cpu, operand & 0x1F); - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (operand & 0xFF); - } - if(BIT17(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (operand & 0xFF00); - if(BIT18(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (operand & 0xFF0000); - } - if(BIT19(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (operand & 0xFF000000); - - return 1; -} - -static u32 FASTCALL OP_MSR_SPSR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 operand = cpu->R[REG_POS(i,0)]; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (operand & 0XFF); - } - if(BIT17(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (operand & 0XFF00); - if(BIT18(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (operand & 0XFF0000); - } - if(BIT19(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0x00FFFFFF) | (operand & 0XFF000000); - - return 1; -} - -static u32 FASTCALL OP_MSR_CPSR_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - armcpu_switchMode(cpu, shift_op & 0x1F); - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); - } - if(BIT17(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); - if(BIT18(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); - } - if(BIT19(i)) - { - //cpu->CPSR.val = (cpu->CPSR.val & 0xFF000000) | (shift_op & 0XFF000000); - cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (shift_op & 0xFF000000); - } - - return 1; -} - -static u32 FASTCALL OP_MSR_SPSR_IMM_VAL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - IMM_VALUE; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); - } - if(BIT17(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); - if(BIT18(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); - } - if(BIT19(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFF000000) | (shift_op & 0XFF000000); - - return 1; -} - -//-----------------BRANCH-------------------------- - -static u32 FASTCALL OP_BX(armcpu_t *cpu) -{ - u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; - - cpu->CPSR.bits.T = BIT0(tmp); - cpu->R[15] = tmp & 0xFFFFFFFE; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -static u32 FASTCALL OP_BLX_REG(armcpu_t *cpu) -{ - u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; - - cpu->R[14] = cpu->next_instruction; - cpu->CPSR.bits.T = BIT0(tmp); - cpu->R[15] = tmp & 0xFFFFFFFE; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -#define SIGNEXTEND_24(i) (((s32)((i)<<8))>>8) - -static u32 FASTCALL OP_B(armcpu_t *cpu) -{ - u32 off = SIGNEXTEND_24(cpu->instruction); - if(CONDITION(cpu->instruction)==0xF) - { - cpu->R[14] = cpu->next_instruction; - cpu->CPSR.bits.T = 1; - } - cpu->R[15] += (off<<2); - cpu->next_instruction = cpu->R[15]; - - return 3; -} - -static u32 FASTCALL OP_BL(armcpu_t *cpu) -{ - u32 off = SIGNEXTEND_24(cpu->instruction); - if(CONDITION(cpu->instruction)==0xF) - { - cpu->CPSR.bits.T = 1; - cpu->R[15] += 2; - } - cpu->R[14] = cpu->next_instruction; - cpu->R[15] += (off<<2); - cpu->next_instruction = cpu->R[15]; - - return 3; -} - -//----------------CLZ------------------------------- - -u8 CLZ_TAB[16]= -{ - 0, // 0000 - 1, // 0001 - 2, 2, // 001X - 3, 3, 3, 3, // 01XX - 4, 4, 4, 4, 4, 4, 4, 4 // 1XXX -}; - -static u32 FASTCALL OP_CLZ(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 Rm = cpu->R[REG_POS(i,0)]; - u32 pos; - - if(Rm==0) - { - cpu->R[REG_POS(i,12)]=32; - return 2; - } - - Rm |= (Rm >>1); - Rm |= (Rm >>2); - Rm |= (Rm >>4); - Rm |= (Rm >>8); - Rm |= (Rm >>16); - - pos = - CLZ_TAB[Rm&0xF] + - CLZ_TAB[(Rm>>4)&0xF] + - CLZ_TAB[(Rm>>8)&0xF] + - CLZ_TAB[(Rm>>12)&0xF] + - CLZ_TAB[(Rm>>16)&0xF] + - CLZ_TAB[(Rm>>20)&0xF] + - CLZ_TAB[(Rm>>24)&0xF] + - CLZ_TAB[(Rm>>28)&0xF]; - - cpu->R[REG_POS(i,12)]=32 - pos; - - return 2; -} - -//--------------------QADD--QSUB------------------------------ - -static u32 FASTCALL OP_QADD(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 res = cpu->R[REG_POS(i,16)]+cpu->R[REG_POS(i,0)]; - - LOG("spe add\r\n"); - if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)],cpu->R[REG_POS(i,0)], res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -static u32 FASTCALL OP_QSUB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 res = cpu->R[REG_POS(i,0)]-cpu->R[REG_POS(i,16)]; - - LOG("spe add\r\n"); - if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,16)], res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -static u32 FASTCALL OP_QDADD(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 mul = cpu->R[REG_POS(i,16)]<<1; - u32 res; - - - LOG("spe add\r\n"); - if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) - { - cpu->CPSR.bits.Q=1; - mul = 0x80000000-BIT31(mul); - } - - res = mul + cpu->R[REG_POS(i,0)]; - if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,0)],mul, res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -static u32 FASTCALL OP_QDSUB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 mul = cpu->R[REG_POS(i,16)]<<1; - u32 res; - - - LOG("spe add\r\n"); - if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) - { - cpu->CPSR.bits.Q=1; - mul = 0x80000000-BIT31(mul); - } - - res = cpu->R[REG_POS(i,0)] - mul; - if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], mul, res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -//-----------------SMUL------------------------------- - -#define HWORD(i) ((s32)(((s32)(i))>>16)) -#define LWORD(i) (s32)(((s32)((i)<<16))>>16) - -static u32 FASTCALL OP_SMUL_B_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -static u32 FASTCALL OP_SMUL_B_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -static u32 FASTCALL OP_SMUL_T_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -static u32 FASTCALL OP_SMUL_T_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -//-----------SMLA---------------------------- - -static u32 FASTCALL OP_SMLA_B_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLABB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -static u32 FASTCALL OP_SMLA_B_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLABT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -static u32 FASTCALL OP_SMLA_T_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLATB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -static u32 FASTCALL OP_SMLA_T_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLATT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -//--------------SMLAL--------------------------------------- - -static u32 FASTCALL OP_SMLAL_B_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALBB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + (res + ((tmp<0)*0xFFFFFFFF))), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += (res + ((tmp<0)*0xFFFFFFFF)); - - return 2; -} - -static u32 FASTCALL OP_SMLAL_B_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALBT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); - - return 2; -} - -static u32 FASTCALL OP_SMLAL_T_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* (s64)LWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALTB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); - - return 2; -} - -static u32 FASTCALL OP_SMLAL_T_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALTT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); - - return 2; -} - -//--------------SMULW-------------------- - -static u32 FASTCALL OP_SMULW_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - - //LOG("SMULWB %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF); - - cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); - - return 2; -} - -static u32 FASTCALL OP_SMULW_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - - //LOG("SMULWT %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF)); - - cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); - - return 2; -} - -//--------------SMLAW------------------- -static u32 FASTCALL OP_SMLAW_B(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLAWB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, (tmp>>16) + a); - - tmp = (tmp>>16); - - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -static u32 FASTCALL OP_SMLAW_T(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLAWT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, ((tmp>>16)&0xFFFFFFFF) + a); - - tmp = ((tmp>>16)&0xFFFFFFFF); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -//------------LDR--------------------------- - -static u32 FASTCALL OP_LDR_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -//------------------------------------------------------------ -static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND2(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ32(cpu->mem_if->data, adr); - u32 old; - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - old = armcpu_switchMode(cpu, USR); - cpu->R[REG_POS(i,12)] = val; - armcpu_switchMode(cpu, old); - - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -//------------------------------------------------------------ - -static u32 FASTCALL OP_LDR_M_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - if(adr&3) - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -//-----------------LDRB------------------------------------------- - -static u32 FASTCALL OP_LDRB_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//----------------------STR-------------------------------- - -static u32 FASTCALL OP_STR_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - -// execute = false; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -//-----------------------STRB------------------------------------- - -static u32 FASTCALL OP_STRB_P_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//-----------------------LDRBT------------------------------------- - -static u32 FASTCALL OP_LDRBT_P_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_M_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_M_IMM_OFF_POSTIND\n"); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_P_REG_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_P_REG_OFF_POSTIND"); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_P_LSL_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_M_LSL_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_P_LSR_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_M_LSR_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_P_ASR_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_M_ASR_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_P_ROR_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRBT_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_LDRBT_M_ROR_IMM_OFF_POSTIND"); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//----------------------STRBT---------------------------- - -static u32 FASTCALL OP_STRBT_P_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_M_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_P_REG_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_M_REG_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - cpu->R[REG_POS(i,0)]; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRBT_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -//---------------------LDM----------------------------- - -#define OP_L_IA(reg, adr) if(BIT##reg(i))\ - {\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - adr += 4;\ - } - -#define OP_L_IB(reg, adr) if(BIT##reg(i))\ - {\ - adr += 4;\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - } - -#define OP_L_DA(reg, adr) if(BIT##reg(i))\ - {\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - adr -= 4;\ - } - -#define OP_L_DB(reg, adr) if(BIT##reg(i))\ - {\ - adr -= 4;\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - } - -static u32 FASTCALL OP_LDMIA(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - //start += 4; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - return c + 2; -} - -static u32 FASTCALL OP_LDMIB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i)) - { - u32 tmp; - start += 4; - c += waitState[(start>>24)&0xF]; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += 2 + (c==0); - } - - return c + 2; -} - -static u32 FASTCALL OP_LDMDA(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - return c + 2; -} - -static u32 FASTCALL OP_LDMDB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - return c + 2; -} - -static u32 FASTCALL OP_LDMIA_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, count; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - c += waitState[(start>>24)&0xF]; - start += 4; - cpu->next_instruction = registres[15]; - } - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -static u32 FASTCALL OP_LDMIB_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, count; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i)) - { - u32 tmp; - start += 4; - c += waitState[(start>>24)&0xF]; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += 2 + (c==0); - } - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -static u32 FASTCALL OP_LDMDA_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, count; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -static u32 FASTCALL OP_LDMDB_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, count; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - u32 * registres = cpu->R; - u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -static u32 FASTCALL OP_LDMIA2(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 oldmode; - - u32 c = 0; - - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - u32 * waitState; - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 1; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - Status_Reg SPSR; - cpu->R[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - //start += 4; - cpu->next_instruction = cpu->R[15]; - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - else - { - armcpu_switchMode(cpu, oldmode); - } - return c + 2; -} - -static u32 FASTCALL OP_LDMIB2(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 oldmode; - u32 c = 0; - - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - u32 * waitState; - //execute = FALSE; - LOG("Untested opcode: OP_LDMIB2"); - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i)) - { - u32 tmp; - Status_Reg SPSR; - start += 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - else - { - armcpu_switchMode(cpu, oldmode); - } - return c + 2; -} - -static u32 FASTCALL OP_LDMDA2(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - u32 oldmode; - u32 c = 0; - u32 * registres; - u32 * waitState; - - u32 start = cpu->R[REG_POS(i,16)]; - //execute = FALSE; - LOG("Untested opcode: OP_LDMDA2"); - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - } - else - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - } - - return c + 2; -} - -static u32 FASTCALL OP_LDMDB2(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - - u32 oldmode; - u32 c = 0; - u32 * registres; - u32 * waitState; - - u32 start = cpu->R[REG_POS(i,16)]; - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - } - else - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - } - - return 2 + c; -} - -static u32 FASTCALL OP_LDMIA2_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - - u32 oldmode; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - u32 * waitState; - u32 tmp; - Status_Reg SPSR; -// execute = FALSE; - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i)==0) - { - registres[REG_POS(i,16)] = start; - armcpu_switchMode(cpu, oldmode); - return c + 2; - } - - registres[REG_POS(i,16)] = start + 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - - return c + 2; -} - -static u32 FASTCALL OP_LDMIB2_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - - u32 oldmode; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - u32 * waitState; - u32 tmp; - Status_Reg SPSR; - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - registres[REG_POS(i,16)] = start; - - return c + 2; - } - - registres[REG_POS(i,16)] = start + 4; - tmp = READ32(cpu->mem_if->data, start + 4); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - cpu->next_instruction = registres[15]; - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - c += waitState[(start>>24)&0xF]; - - return c + 2; -} - -static u32 FASTCALL OP_LDMDA2_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - - u32 oldmode; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - u32 * waitState; - Status_Reg SPSR; -// execute = FALSE; - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - registres[REG_POS(i,16)] = start; - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - return c + 2; - } - - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - return c + 2; -} - -static u32 FASTCALL OP_LDMDB2_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 c = 0; - - u32 oldmode; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - u32 * waitState; - Status_Reg SPSR; -// execute = FALSE; - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[cpu->proc_ID]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - c += waitState[(start>>24)&0xF]; - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - cpu->next_instruction = registres[15]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - registres[REG_POS(i,16)] = start; - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - return c + 2; - } - - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - return c + 2; -} - -//------------------------------STM---------------------------------- - -static u32 FASTCALL OP_STMIA(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start += 4; - } - } - return c + 1; -} - -static u32 FASTCALL OP_STMIB(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - return c + 1; -} - -static u32 FASTCALL OP_STMDA(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start -= 4; - } - } - return c + 1; -} - -static u32 FASTCALL OP_STMDB(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - return c + 1; -} - -static u32 FASTCALL OP_STMIA_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start += 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -static u32 FASTCALL OP_STMIB_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -static u32 FASTCALL OP_STMDA_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start -= 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -static u32 FASTCALL OP_STMDB_W(armcpu_t *cpu) -{ - u32 i = cpu->instruction, c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -static u32 FASTCALL OP_STMIA2(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - //execute = FALSE; - LOG("Untested opcode: OP_STMIA2"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start += 4; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -static u32 FASTCALL OP_STMIB2(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - //execute = FALSE; - LOG("Untested opcode: OP_STMIB2"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -static u32 FASTCALL OP_STMDA2(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - //execute = FALSE; - LOG("Untested opcode: OP_STMDA2"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start -= 4; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -static u32 FASTCALL OP_STMDB2(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - i = cpu->instruction; - c=0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -static u32 FASTCALL OP_STMIA2_W(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c=0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - //execute = FALSE; - LOG("Untested opcode: OP_STMIA2_W"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start += 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -static u32 FASTCALL OP_STMIB2_W(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - i = cpu->instruction; - c=0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - armcpu_switchMode(cpu, oldmode); - cpu->R[REG_POS(i,16)] = start; - - return c + 1; -} - -static u32 FASTCALL OP_STMDA2_W(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - //execute = FALSE; - LOG("Untested opcode: OP_STMDA2_W"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - start -= 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -static u32 FASTCALL OP_STMDB2_W(armcpu_t *cpu) -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c = 0; - - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - //execute = FALSE; - LOG("Untested opcode: OP_STMDB2_W"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; - } - } - - cpu->R[REG_POS(i,16)] = start; - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -/* - * - * The Enhanced DSP Extension LDRD and STRD instructions. - * - */ -static u32 FASTCALL -OP_LDRD_STRD_POST_INDEX( armcpu_t *cpu) { - u32 i = cpu->instruction; - u32 Rd_num = REG_POS( i, 12); - u32 addr = cpu->R[REG_POS(i,16)]; - u32 index; - - /* I bit - immediate or register */ - if ( BIT22(i)) - index = IMM_OFF; - else - index = cpu->R[REG_POS(i,0)]; - - /* U bit - add or subtract */ - if ( BIT23(i)) - cpu->R[REG_POS(i,16)] += index; - else - cpu->R[REG_POS(i,16)] -= index; - - if ( !(Rd_num & 0x1)) { - /* Store/Load */ - if ( BIT5(i)) { - WRITE32(cpu->mem_if->data, addr, cpu->R[Rd_num]); - WRITE32(cpu->mem_if->data, addr + 4, cpu->R[Rd_num + 1]); - } - else { - cpu->R[Rd_num] = READ32(cpu->mem_if->data, addr); - cpu->R[Rd_num + 1] = READ32(cpu->mem_if->data, addr + 4); - } - } - - return 3 + (MMU.MMU_WAIT32[cpu->proc_ID][(addr>>24)&0xF] * 2); -} - -static u32 FASTCALL -OP_LDRD_STRD_OFFSET_PRE_INDEX( armcpu_t *cpu) { - u32 i = cpu->instruction; - u32 Rd_num = REG_POS( i, 12); - u32 addr = cpu->R[REG_POS(i,16)]; - u32 index; - - /* I bit - immediate or register */ - if ( BIT22(i)) - index = IMM_OFF; - else - index = cpu->R[REG_POS(i,0)]; - - /* U bit - add or subtract */ - if ( BIT23(i)) { - addr += index; - - /* W bit - writeback */ - if ( BIT21(i)) - cpu->R[REG_POS(i,16)] = addr; - } - else { - addr -= index; - - /* W bit - writeback */ - if ( BIT21(i)) - cpu->R[REG_POS(i,16)] = addr; - } - - if ( !(Rd_num & 0x1)) { - /* Store/Load */ - if ( BIT5(i)) { - WRITE32(cpu->mem_if->data, addr, cpu->R[Rd_num]); - WRITE32(cpu->mem_if->data, addr + 4, cpu->R[Rd_num + 1]); - } - else { - cpu->R[Rd_num] = READ32(cpu->mem_if->data, addr); - cpu->R[Rd_num + 1] = READ32(cpu->mem_if->data, addr + 4); - } - } - - return 3 + (MMU.MMU_WAIT32[cpu->proc_ID][(addr>>24)&0xF] * 2); -} - - - -//---------------------STC---------------------------------- - -static u32 FASTCALL OP_STC_P_IMM_OFF(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_STC_M_IMM_OFF(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_STC_P_PREIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_STC_M_PREIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_STC_P_POSTIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_STC_M_POSTIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_STC_OPTION(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - return 2; - } -} - -//---------------------LDC---------------------------------- - -static u32 FASTCALL OP_LDC_P_IMM_OFF(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_LDC_M_IMM_OFF(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_LDC_P_PREIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_LDC_M_PREIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_LDC_P_POSTIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_LDC_M_POSTIND(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - return 2; - } -} - -static u32 FASTCALL OP_LDC_OPTION(armcpu_t *cpu) -{ - { - /* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - return 2; - } -} - -//----------------MCR----------------------- - -static u32 FASTCALL OP_MCR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 cpnum = REG_POS(i, 8); - - if(!cpu->coproc[cpnum]) - { - execute = FALSE; - return 2; - } - - armcp15_moveARM2CP((armcp15_t*)cpu->coproc[cpnum], cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - //cpu->coproc[cpnum]->moveARM2CP(cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - return 2; -} - -//----------------MRC----------------------- - -static u32 FASTCALL OP_MRC(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 cpnum = REG_POS(i, 8); - - if(!cpu->coproc[cpnum]) - { - execute = FALSE; - return 2; - } - - armcp15_moveCP2ARM((armcp15_t*)cpu->coproc[cpnum], &cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - //cpu->coproc[cpnum]->moveCP2ARM(&cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - return 4; -} - -//--------------SWI------------------------------- -static u32 FASTCALL OP_SWI(armcpu_t *cpu) -{ - if (((cpu->intVector != 0) ^ (cpu->proc_ID == ARMCPU_ARM9))) - { - /* TODO (#1#): translocated SWI vectors */ - /* we use an irq thats not in the irq tab, as - it was replaced duie to a changed intVector */ - Status_Reg tmp = cpu->CPSR; - armcpu_switchMode(cpu, SVC); /* enter svc mode */ - cpu->R[14] = cpu->R[15] - 4; /* jump to swi Vector */ - cpu->SPSR = tmp; /* save old CPSR as new SPSR */ - cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ - cpu->CPSR.bits.I = cpu->SPSR.bits.I; /* keep int disable flag */ - cpu->R[15] = cpu->intVector + 0x08; - cpu->next_instruction = cpu->R[15]; - return 4; - } - else - { - u32 swinum = (cpu->instruction>>16)&0x1F; - return cpu->swi_tab[swinum](cpu) + 3; - } -} - -//----------------BKPT------------------------- -static u32 FASTCALL OP_BKPT(armcpu_t *cpu) -{ - execute = FALSE; - return 4; -} - -//----------------CDP----------------------- - -static u32 FASTCALL OP_CDP(armcpu_t *cpu) -{ - execute = FALSE; - return 4; -} - -#define TYPE_RETOUR u32 -#define PARAMETRES armcpu_t *cpu -#define CALLTYPE FASTCALL -#define NOM_TAB arm_instructions_set - -#include "instruction_tabdef.inc" diff --git a/tools/vio2sf/src/vio2sf/desmume/arm_instructions.h b/tools/vio2sf/src/vio2sf/desmume/arm_instructions.h deleted file mode 100644 index 350680aaf..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/arm_instructions.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef ARMINSTRUCTION_H -#define ARMINSTRUCTION_H - -#include "types.h" -#include "armcpu.h" - -extern u32 (FASTCALL* arm_instructions_set[4096])(armcpu_t * cpu); - -#endif - diff --git a/tools/vio2sf/src/vio2sf/desmume/armcpu.c b/tools/vio2sf/src/vio2sf/desmume/armcpu.c deleted file mode 100644 index a3071857e..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/armcpu.c +++ /dev/null @@ -1,579 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "arm_instructions.h" -#include "thumb_instructions.h" -#include "cp15.h" -#include "bios.h" -#include -#include - -const unsigned char arm_cond_table[16*16] = { - /* N=0, Z=0, C=0, V=0 */ - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=0, Z=0, C=0, V=1 */ - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x00, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=0, Z=0, C=1, V=0 */ - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF, - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=0, Z=0, C=1, V=1 */ - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00, - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=0, V=0 */ - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=0, V=1 */ - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x00, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=1, V=0 */ - 0xFF,0x00,0xFF,0x00,0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=1, V=1 */ - 0xFF,0x00,0xFF,0x00,0x00,0xFF,0xFF,0x00, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=0, C=0, V=0 */ - 0x00,0xFF,0x00,0xFF,0xFF,0x00,0x00,0xFF, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=0, C=0, V=1 */ - 0x00,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0x00, - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=1, Z=0, C=1, V=0 */ - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0x00,0xFF, - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=0, C=1, V=1 */ - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x00, - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=1, Z=1, C=0, V=0 */ - 0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=1, C=0, V=1 */ - 0xFF,0x00,0x00,0xFF,0xFF,0x00,0xFF,0x00, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, - /* N=1, Z=1, C=1, V=0 */ - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0xFF, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=1, C=1, V=1 */ - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, -}; - -armcpu_t NDS_ARM7; -armcpu_t NDS_ARM9; - -#define SWAP(a, b, c) do \ - { \ - c=a; \ - a=b; \ - b=c; \ - } \ - while(0) - -#ifdef GDB_STUB - -#define STALLED_CYCLE_COUNT 10 - -static void -stall_cpu( void *instance) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->stalled = 1; -} - -static void -unstall_cpu( void *instance) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->stalled = 0; -} - -static void -install_post_exec_fn( void *instance, - void (*ex_fn)( void *, u32 adr, int thumb), - void *fn_data) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->post_ex_fn = ex_fn; - armcpu->post_ex_fn_data = fn_data; -} - -static void -remove_post_exec_fn( void *instance) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->post_ex_fn = NULL; -} -#endif - -static u32 -read_cpu_reg( void *instance, u32 reg_num) { - armcpu_t *armcpu = (armcpu_t *)instance; - u32 reg_value = 0; - - if ( reg_num <= 14) { - reg_value = armcpu->R[reg_num]; - } - else if ( reg_num == 15) { - reg_value = armcpu->next_instruction; - } - else if ( reg_num == 16) { - /* CPSR */ - reg_value = armcpu->CPSR.val; - } - - return reg_value; -} - -static void -set_cpu_reg( void *instance, u32 reg_num, u32 value) { - armcpu_t *armcpu = (armcpu_t *)instance; - - if ( reg_num <= 14) { - armcpu->R[reg_num] = value; - } - else if ( reg_num == 15) { - armcpu->next_instruction = value; - } - else if ( reg_num == 16) { - /* FIXME: setting the CPSR */ - } -} - -#ifdef GDB_STUB -int armcpu_new( armcpu_t *armcpu, u32 id, - struct armcpu_memory_iface *mem_if, - struct armcpu_ctrl_iface **ctrl_iface_ret) -#else -int armcpu_new( armcpu_t *armcpu, u32 id) -#endif -{ - armcpu->proc_ID = id; - - if(id==0) - armcpu->swi_tab = ARM9_swi_tab; - else - armcpu->swi_tab = ARM7_swi_tab; - -#ifdef GDB_STUB - armcpu->mem_if = mem_if; - - /* populate the control interface */ - armcpu->ctrl_iface.stall = stall_cpu; - armcpu->ctrl_iface.unstall = unstall_cpu; - armcpu->ctrl_iface.read_reg = read_cpu_reg; - armcpu->ctrl_iface.set_reg = set_cpu_reg; - armcpu->ctrl_iface.install_post_ex_fn = install_post_exec_fn; - armcpu->ctrl_iface.remove_post_ex_fn = remove_post_exec_fn; - armcpu->ctrl_iface.data = armcpu; - - *ctrl_iface_ret = &armcpu->ctrl_iface; - - armcpu->stalled = 0; - armcpu->post_ex_fn = NULL; -#endif - - armcpu_init(armcpu, 0); - - return 0; -} - -void armcpu_init(armcpu_t *armcpu, u32 adr) -{ - u32 i; - - armcpu->LDTBit = (armcpu->proc_ID==0); //Si ARM9 utiliser le syte v5 pour le load - armcpu->intVector = 0xFFFF0000 * (armcpu->proc_ID==0); - armcpu->waitIRQ = FALSE; - armcpu->wirq = FALSE; - -#ifdef GDB_STUB - armcpu->irq_flag = 0; -#endif - - if(armcpu->coproc[15]) free(armcpu->coproc[15]); - - for(i = 0; i < 15; ++i) - { - armcpu->R[i] = 0; - armcpu->coproc[i] = NULL; - } - - armcpu->CPSR.val = armcpu->SPSR.val = SYS; - - armcpu->R13_usr = armcpu->R14_usr = 0; - armcpu->R13_svc = armcpu->R14_svc = 0; - armcpu->R13_abt = armcpu->R14_abt = 0; - armcpu->R13_und = armcpu->R14_und = 0; - armcpu->R13_irq = armcpu->R14_irq = 0; - armcpu->R8_fiq = armcpu->R9_fiq = armcpu->R10_fiq = armcpu->R11_fiq = armcpu->R12_fiq = armcpu->R13_fiq = armcpu->R14_fiq = 0; - - armcpu->SPSR_svc.val = armcpu->SPSR_abt.val = armcpu->SPSR_und.val = armcpu->SPSR_irq.val = armcpu->SPSR_fiq.val = 0; - -#ifdef GDB_STUB - armcpu->instruct_adr = adr; - armcpu->R[15] = adr + 8; -#else - armcpu->R[15] = adr; -#endif - - armcpu->next_instruction = adr; - - armcpu->coproc[15] = (armcp_t*)armcp15_new(armcpu); - -#ifndef GDB_STUB - armcpu_prefetch(armcpu); -#endif -} - -u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode) -{ - u32 oldmode = armcpu->CPSR.bits.mode; - - switch(oldmode) - { - case USR : - case SYS : - armcpu->R13_usr = armcpu->R[13]; - armcpu->R14_usr = armcpu->R[14]; - break; - - case FIQ : - { - u32 tmp; - SWAP(armcpu->R[8], armcpu->R8_fiq, tmp); - SWAP(armcpu->R[9], armcpu->R9_fiq, tmp); - SWAP(armcpu->R[10], armcpu->R10_fiq, tmp); - SWAP(armcpu->R[11], armcpu->R11_fiq, tmp); - SWAP(armcpu->R[12], armcpu->R12_fiq, tmp); - armcpu->R13_fiq = armcpu->R[13]; - armcpu->R14_fiq = armcpu->R[14]; - armcpu->SPSR_fiq = armcpu->SPSR; - break; - } - case IRQ : - armcpu->R13_irq = armcpu->R[13]; - armcpu->R14_irq = armcpu->R[14]; - armcpu->SPSR_irq = armcpu->SPSR; - break; - - case SVC : - armcpu->R13_svc = armcpu->R[13]; - armcpu->R14_svc = armcpu->R[14]; - armcpu->SPSR_svc = armcpu->SPSR; - break; - - case ABT : - armcpu->R13_abt = armcpu->R[13]; - armcpu->R14_abt = armcpu->R[14]; - armcpu->SPSR_abt = armcpu->SPSR; - break; - - case UND : - armcpu->R13_und = armcpu->R[13]; - armcpu->R14_und = armcpu->R[14]; - armcpu->SPSR_und = armcpu->SPSR; - break; - default : - break; - } - - switch(mode) - { - case USR : - case SYS : - armcpu->R[13] = armcpu->R13_usr; - armcpu->R[14] = armcpu->R14_usr; - //SPSR = CPSR; - break; - - case FIQ : - { - u32 tmp; - SWAP(armcpu->R[8], armcpu->R8_fiq, tmp); - SWAP(armcpu->R[9], armcpu->R9_fiq, tmp); - SWAP(armcpu->R[10], armcpu->R10_fiq, tmp); - SWAP(armcpu->R[11], armcpu->R11_fiq, tmp); - SWAP(armcpu->R[12], armcpu->R12_fiq, tmp); - armcpu->R[13] = armcpu->R13_fiq; - armcpu->R[14] = armcpu->R14_fiq; - armcpu->SPSR = armcpu->SPSR_fiq; - break; - } - - case IRQ : - armcpu->R[13] = armcpu->R13_irq; - armcpu->R[14] = armcpu->R14_irq; - armcpu->SPSR = armcpu->SPSR_irq; - break; - - case SVC : - armcpu->R[13] = armcpu->R13_svc; - armcpu->R[14] = armcpu->R14_svc; - armcpu->SPSR = armcpu->SPSR_svc; - break; - - case ABT : - armcpu->R[13] = armcpu->R13_abt; - armcpu->R[14] = armcpu->R14_abt; - armcpu->SPSR = armcpu->SPSR_abt; - break; - - case UND : - armcpu->R[13] = armcpu->R13_und; - armcpu->R[14] = armcpu->R14_und; - armcpu->SPSR = armcpu->SPSR_und; - break; - - default : - break; - } - - armcpu->CPSR.bits.mode = mode & 0x1F; - return oldmode; -} - -static u32 -armcpu_prefetch(armcpu_t *armcpu) -{ - u32 temp_instruction; - - if(armcpu->CPSR.bits.T == 0) - { -#ifdef GDB_STUB - temp_instruction = - armcpu->mem_if->prefetch32( armcpu->mem_if->data, - armcpu->next_instruction); - - if ( !armcpu->stalled) { - armcpu->instruction = temp_instruction; - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 4; - armcpu->R[15] = armcpu->next_instruction + 4; - } -#else - armcpu->instruction = MMU_read32_acl(armcpu->proc_ID, armcpu->next_instruction,CP15_ACCESS_EXECUTE); - - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 4; - armcpu->R[15] = armcpu->next_instruction + 4; -#endif - - return MMU.MMU_WAIT32[armcpu->proc_ID][(armcpu->instruct_adr>>24)&0xF]; - } - -#ifdef GDB_STUB - temp_instruction = - armcpu->mem_if->prefetch16( armcpu->mem_if->data, - armcpu->next_instruction); - - if ( !armcpu->stalled) { - armcpu->instruction = temp_instruction; - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction = armcpu->next_instruction + 2; - armcpu->R[15] = armcpu->next_instruction + 2; - } -#else - armcpu->instruction = MMU_read16_acl(armcpu->proc_ID, armcpu->next_instruction,CP15_ACCESS_EXECUTE); - - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 2; - armcpu->R[15] = armcpu->next_instruction + 2; -#endif - - return MMU.MMU_WAIT16[armcpu->proc_ID][(armcpu->instruct_adr>>24)&0xF]; -} - - -static BOOL FASTCALL test_EQ(Status_Reg CPSR) { return ( CPSR.bits.Z); } -static BOOL FASTCALL test_NE(Status_Reg CPSR) { return (!CPSR.bits.Z); } -static BOOL FASTCALL test_CS(Status_Reg CPSR) { return ( CPSR.bits.C); } -static BOOL FASTCALL test_CC(Status_Reg CPSR) { return (!CPSR.bits.C); } -static BOOL FASTCALL test_MI(Status_Reg CPSR) { return ( CPSR.bits.N); } -static BOOL FASTCALL test_PL(Status_Reg CPSR) { return (!CPSR.bits.N); } -static BOOL FASTCALL test_VS(Status_Reg CPSR) { return ( CPSR.bits.V); } -static BOOL FASTCALL test_VC(Status_Reg CPSR) { return (!CPSR.bits.V); } -static BOOL FASTCALL test_HI(Status_Reg CPSR) { return (CPSR.bits.C) && (!CPSR.bits.Z); } -static BOOL FASTCALL test_LS(Status_Reg CPSR) { return (CPSR.bits.Z) || (!CPSR.bits.C); } -static BOOL FASTCALL test_GE(Status_Reg CPSR) { return (CPSR.bits.N==CPSR.bits.V); } -static BOOL FASTCALL test_LT(Status_Reg CPSR) { return (CPSR.bits.N!=CPSR.bits.V); } -static BOOL FASTCALL test_GT(Status_Reg CPSR) { return (!CPSR.bits.Z) && (CPSR.bits.N==CPSR.bits.V); } -static BOOL FASTCALL test_LE(Status_Reg CPSR) { return ( CPSR.bits.Z) || (CPSR.bits.N!=CPSR.bits.V); } -static BOOL FASTCALL test_AL(Status_Reg CPSR) { return 1; } - -static BOOL (FASTCALL* test_conditions[])(Status_Reg CPSR)= { - test_EQ , test_NE , - test_CS , test_CC , - test_MI , test_PL , - test_VS , test_VC , - test_HI , test_LS , - test_GE , test_LT , - test_GT , test_LE , - test_AL -}; -#define TEST_COND2(cond, CPSR) \ - (cond<15&&test_conditions[cond](CPSR)) - - -BOOL armcpu_irqExeption(armcpu_t *armcpu) -{ - Status_Reg tmp; - - if(armcpu->CPSR.bits.I) return FALSE; - -#ifdef GDB_STUB - armcpu->irq_flag = 0; -#endif - - tmp = armcpu->CPSR; - armcpu_switchMode(armcpu, IRQ); - -#ifdef GDB_STUB - armcpu->R[14] = armcpu->next_instruction + 4; -#else - armcpu->R[14] = armcpu->instruct_adr + 4; -#endif - armcpu->SPSR = tmp; - armcpu->CPSR.bits.T = 0; - armcpu->CPSR.bits.I = 1; - armcpu->next_instruction = armcpu->intVector + 0x18; - armcpu->waitIRQ = 0; - -#ifndef GDB_STUB - armcpu->R[15] = armcpu->next_instruction + 8; - armcpu_prefetch(armcpu); -#endif - - return TRUE; -} -/* -static BOOL armcpu_prefetchExeption(armcpu_t *armcpu) -{ - Status_Reg tmp; - if(armcpu->CPSR.bits.I) return FALSE; - tmp = armcpu->CPSR; - armcpu_switchMode(armcpu, ABT); - armcpu->R[14] = armcpu->next_instruction + 4; - armcpu->SPSR = tmp; - armcpu->CPSR.bits.T = 0; - armcpu->CPSR.bits.I = 1; - armcpu->next_instruction = armcpu->intVector + 0xC; - armcpu->R[15] = armcpu->next_instruction + 8; - armcpu->waitIRQ = 0; - return TRUE; -} -*/ - -static BOOL armcpu_prefetchExeption(armcpu_t *armcpu) -{ - Status_Reg tmp; - if(armcpu->CPSR.bits.I) return FALSE; - tmp = armcpu->CPSR; - armcpu_switchMode(armcpu, ABT); - -#ifdef GDB_STUB - armcpu->R[14] = armcpu->next_instruction + 4; -#else - armcpu->R[14] = armcpu->instruct_adr + 4; -#endif - - armcpu->SPSR = tmp; - armcpu->CPSR.bits.T = 0; - armcpu->CPSR.bits.I = 1; - armcpu->next_instruction = armcpu->intVector + 0xC; - armcpu->waitIRQ = 0; - -#ifdef GDB_STUB - armcpu->R[15] = armcpu->next_instruction + 8; -#else - armcpu->R[15] = armcpu->next_instruction; - armcpu_prefetch(armcpu); -#endif - - return TRUE; -} - -BOOL -armcpu_flagIrq( armcpu_t *armcpu) { - if(armcpu->CPSR.bits.I) return FALSE; - - armcpu->waitIRQ = 0; - -#ifdef GDB_STUB - armcpu->irq_flag = 1; -#endif - - return TRUE; -} - - -u32 armcpu_exec(armcpu_t *armcpu) -{ - u32 c = 1; - -#ifdef GDB_STUB - if ( armcpu->stalled) - return STALLED_CYCLE_COUNT; - - /* check for interrupts */ - if ( armcpu->irq_flag) { - armcpu_irqExeption( armcpu); - } - - c = armcpu_prefetch(armcpu); - - if ( armcpu->stalled) { - return c; - } -#endif - - if(armcpu->CPSR.bits.T == 0) - { -/* if((TEST_COND(CONDITION(armcpu->instruction), armcpu->CPSR)) || ((CONDITION(armcpu->instruction)==0xF)&&(CODE(armcpu->instruction)==0x5)))*/ - if((TEST_COND(CONDITION(armcpu->instruction), CODE(armcpu->instruction), armcpu->CPSR))) - { - c += arm_instructions_set[INSTRUCTION_INDEX(armcpu->instruction)](armcpu); - } -#ifdef GDB_STUB - if ( armcpu->post_ex_fn != NULL) { - /* call the external post execute function */ - armcpu->post_ex_fn( armcpu->post_ex_fn_data, - armcpu->instruct_adr, 0); - } -#else - c += armcpu_prefetch(armcpu); -#endif - return c; - } - - c += thumb_instructions_set[armcpu->instruction>>6](armcpu); - -#ifdef GDB_STUB - if ( armcpu->post_ex_fn != NULL) { - /* call the external post execute function */ - armcpu->post_ex_fn( armcpu->post_ex_fn_data, armcpu->instruct_adr, 1); - } -#else - c += armcpu_prefetch(armcpu); -#endif - return c; -} - diff --git a/tools/vio2sf/src/vio2sf/desmume/armcpu.h b/tools/vio2sf/src/vio2sf/desmume/armcpu.h deleted file mode 100644 index 733716f64..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/armcpu.h +++ /dev/null @@ -1,288 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef ARM_CPU -#define ARM_CPU - -#include "types.h" -#include "bits.h" -#include "MMU.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ARMCPU_ARM7 1 -#define ARMCPU_ARM9 0 - -#define CODE(i) (((i)>>25)&0X7) -#define OPCODE(i) (((i)>>21)&0xF) -#define SIGNEBIT(i) BIT_N(i,20) - -#define INSTRUCTION_INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) - -#define ROR(i, j) ((((u32)(i))>>(j)) | (((u32)(i))<<(32-(j)))) - -#define UNSIGNED_OVERFLOW(a,b,c) ((BIT31(a)&BIT31(b)) | \ - ((BIT31(a)|BIT31(b))&BIT31(~c))) - -#define UNSIGNED_UNDERFLOW(a,b,c) ((BIT31(~a)&BIT31(b)) | \ - ((BIT31(~a)|BIT31(b))&BIT31(c))) - -#define SIGNED_OVERFLOW(a,b,c) ((BIT31(a)&BIT31(b)&BIT31(~c))|\ - (BIT31(~a)&BIT31(~(b))&BIT31(c))) - -#define SIGNED_UNDERFLOW(a,b,c) ((BIT31(a)&BIT31(~(b))&BIT31(~c))|\ - (BIT31(~a)&BIT31(b)&BIT31(c))) - -#define EQ 0x0 -#define NE 0x1 -#define CS 0x2 -#define CC 0x3 -#define MI 0x4 -#define PL 0x5 -#define VS 0x6 -#define VC 0x7 -#define HI 0x8 -#define LS 0x9 -#define GE 0xA -#define LT 0xB -#define GT 0xC -#define LE 0xD -#define AL 0xE - -/* -#define TEST_COND(cond, CPSR) (((cond)==AL) ||\ - (((cond)==EQ) && ( CPSR.bits.Z))||\ - (((cond)==NE) && (!CPSR.bits.Z))||\ - (((cond)==CS) && ( CPSR.bits.C))||\ - (((cond)==CC) && (!CPSR.bits.C))||\ - (((cond)==MI) && ( CPSR.bits.N))||\ - (((cond)==PL) && (!CPSR.bits.N))||\ - (((cond)==VS) && ( CPSR.bits.V))||\ - (((cond)==VC) && (!CPSR.bits.V))||\ - (((cond)==HI) && (CPSR.bits.C) && (!CPSR.bits.Z))||\ - (((cond)==LS) && ((CPSR.bits.Z) || (!CPSR.bits.C)))||\ - (((cond)==GE) && (CPSR.bits.N==CPSR.bits.V))||\ - (((cond)==LT) && (CPSR.bits.N!=CPSR.bits.V))||\ - (((cond)==GT) && (CPSR.bits.Z==0) && (CPSR.bits.N==CPSR.bits.V))||\ - (((cond)==LE) && ((CPSR.bits.Z) || (CPSR.bits.N!=CPSR.bits.V)))) -*/ - -extern const unsigned char arm_cond_table[16*16]; - -#define TEST_COND(cond, inst, CPSR) ((arm_cond_table[((CPSR.val >> 24) & 0xf0)+(cond)] >> (inst)) & 1) - - -enum Mode -{ - USR = 0x10, - FIQ = 0x11, - IRQ = 0x12, - SVC = 0x13, - ABT = 0x17, - UND = 0x1B, - SYS = 0x1F -}; - -#ifdef WORDS_BIGENDIAN -typedef union -{ - struct - { - u32 N : 1, - Z : 1, - C : 1, - V : 1, - Q : 1, - RAZ : 19, - I : 1, - F : 1, - T : 1, - mode : 5; - } bits; - u32 val; -} Status_Reg; -#else -typedef union -{ - struct - { - u32 mode : 5, - T : 1, - F : 1, - I : 1, - RAZ : 19, - Q : 1, - V : 1, - C : 1, - Z : 1, - N : 1; - } bits; - u32 val; -} Status_Reg; -#endif - -/** - * The control interface to a CPU - */ -struct armcpu_ctrl_iface { - /** stall the processor */ - void (*stall)( void *instance); - - /** unstall the processor */ - void (*unstall)( void *instance); - - /** read a register value */ - u32 (*read_reg)( void *instance, u32 reg_num); - - /** set a register value */ - void (*set_reg)( void *instance, u32 reg_num, u32 value); - - /** install the post execute function */ - void (*install_post_ex_fn)( void *instance, - void (*fn)( void *, u32 adr, int thumb), - void *fn_data); - - /** remove the post execute function */ - void (*remove_post_ex_fn)( void *instance); - - /** the private data passed to all interface functions */ - void *data; -}; - - -typedef void* armcp_t; - -typedef struct armcpu_t -{ - u32 proc_ID; - u32 instruction; //4 - u32 instruct_adr; //8 - u32 next_instruction; //12 - - u32 R[16]; //16 - Status_Reg CPSR; //80 - Status_Reg SPSR; - - u32 R13_usr, R14_usr; - u32 R13_svc, R14_svc; - u32 R13_abt, R14_abt; - u32 R13_und, R14_und; - u32 R13_irq, R14_irq; - u32 R8_fiq, R9_fiq, R10_fiq, R11_fiq, R12_fiq, R13_fiq, R14_fiq; - Status_Reg SPSR_svc, SPSR_abt, SPSR_und, SPSR_irq, SPSR_fiq; - - armcp_t *coproc[16]; - - u32 intVector; - u8 LDTBit; //1 : ARMv5 style 0 : non ARMv5 - BOOL waitIRQ; - BOOL wIRQ; - BOOL wirq; - - u32 (* *swi_tab)(struct armcpu_t * cpu); - -#ifdef GDB_STUB - /** there is a pending irq for the cpu */ - int irq_flag; - - /** the post executed function (if installed) */ - void (*post_ex_fn)( void *, u32 adr, int thumb); - - /** data for the post executed function */ - void *post_ex_fn_data; - - - /** flag indicating if the processor is stalled */ - int stalled; - - /** the memory interface */ - struct armcpu_memory_iface *mem_if; - - /** the ctrl interface */ - struct armcpu_ctrl_iface ctrl_iface; -#endif -} armcpu_t; - -#ifdef GDB_STUB -int armcpu_new( armcpu_t *armcpu, u32 id, struct armcpu_memory_iface *mem_if, - struct armcpu_ctrl_iface **ctrl_iface_ret); -#else -int armcpu_new( armcpu_t *armcpu, u32 id); -#endif -void armcpu_init(armcpu_t *armcpu, u32 adr); -u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode); -static u32 armcpu_prefetch(armcpu_t *armcpu); -u32 armcpu_exec(armcpu_t *armcpu); -BOOL armcpu_irqExeption(armcpu_t *armcpu); -//BOOL armcpu_prefetchExeption(armcpu_t *armcpu); -BOOL -armcpu_flagIrq( armcpu_t *armcpu); - -extern armcpu_t NDS_ARM7; -extern armcpu_t NDS_ARM9; - -static INLINE void NDS_makeARM9Int(u32 num) -{ - /* flag the interrupt request source */ - MMU.reg_IF[0] |= (1< -#include "MMU.h" -#include "spu_exports.h" -#include "debug.h" - -extern BOOL execute; - -static u16 getsinetbl[] = { -0x0000, 0x0324, 0x0648, 0x096A, 0x0C8C, 0x0FAB, 0x12C8, 0x15E2, -0x18F9, 0x1C0B, 0x1F1A, 0x2223, 0x2528, 0x2826, 0x2B1F, 0x2E11, -0x30FB, 0x33DF, 0x36BA, 0x398C, 0x3C56, 0x3F17, 0x41CE, 0x447A, -0x471C, 0x49B4, 0x4C3F, 0x4EBF, 0x5133, 0x539B, 0x55F5, 0x5842, -0x5A82, 0x5CB3, 0x5ED7, 0x60EB, 0x62F1, 0x64E8, 0x66CF, 0x68A6, -0x6A6D, 0x6C23, 0x6DC9, 0x6F5E, 0x70E2, 0x7254, 0x73B5, 0x7504, -0x7641, 0x776B, 0x7884, 0x7989, 0x7A7C, 0x7B5C, 0x7C29, 0x7CE3, -0x7D89, 0x7E1D, 0x7E9C, 0x7F09, 0x7F61, 0x7FA6, 0x7FD8, 0x7FF5 -}; - -static u16 getpitchtbl[] = { -0x0000, 0x003B, 0x0076, 0x00B2, 0x00ED, 0x0128, 0x0164, 0x019F, -0x01DB, 0x0217, 0x0252, 0x028E, 0x02CA, 0x0305, 0x0341, 0x037D, -0x03B9, 0x03F5, 0x0431, 0x046E, 0x04AA, 0x04E6, 0x0522, 0x055F, -0x059B, 0x05D8, 0x0614, 0x0651, 0x068D, 0x06CA, 0x0707, 0x0743, -0x0780, 0x07BD, 0x07FA, 0x0837, 0x0874, 0x08B1, 0x08EF, 0x092C, -0x0969, 0x09A7, 0x09E4, 0x0A21, 0x0A5F, 0x0A9C, 0x0ADA, 0x0B18, -0x0B56, 0x0B93, 0x0BD1, 0x0C0F, 0x0C4D, 0x0C8B, 0x0CC9, 0x0D07, -0x0D45, 0x0D84, 0x0DC2, 0x0E00, 0x0E3F, 0x0E7D, 0x0EBC, 0x0EFA, -0x0F39, 0x0F78, 0x0FB6, 0x0FF5, 0x1034, 0x1073, 0x10B2, 0x10F1, -0x1130, 0x116F, 0x11AE, 0x11EE, 0x122D, 0x126C, 0x12AC, 0x12EB, -0x132B, 0x136B, 0x13AA, 0x13EA, 0x142A, 0x146A, 0x14A9, 0x14E9, -0x1529, 0x1569, 0x15AA, 0x15EA, 0x162A, 0x166A, 0x16AB, 0x16EB, -0x172C, 0x176C, 0x17AD, 0x17ED, 0x182E, 0x186F, 0x18B0, 0x18F0, -0x1931, 0x1972, 0x19B3, 0x19F5, 0x1A36, 0x1A77, 0x1AB8, 0x1AFA, -0x1B3B, 0x1B7D, 0x1BBE, 0x1C00, 0x1C41, 0x1C83, 0x1CC5, 0x1D07, -0x1D48, 0x1D8A, 0x1DCC, 0x1E0E, 0x1E51, 0x1E93, 0x1ED5, 0x1F17, -0x1F5A, 0x1F9C, 0x1FDF, 0x2021, 0x2064, 0x20A6, 0x20E9, 0x212C, -0x216F, 0x21B2, 0x21F5, 0x2238, 0x227B, 0x22BE, 0x2301, 0x2344, -0x2388, 0x23CB, 0x240E, 0x2452, 0x2496, 0x24D9, 0x251D, 0x2561, -0x25A4, 0x25E8, 0x262C, 0x2670, 0x26B4, 0x26F8, 0x273D, 0x2781, -0x27C5, 0x280A, 0x284E, 0x2892, 0x28D7, 0x291C, 0x2960, 0x29A5, -0x29EA, 0x2A2F, 0x2A74, 0x2AB9, 0x2AFE, 0x2B43, 0x2B88, 0x2BCD, -0x2C13, 0x2C58, 0x2C9D, 0x2CE3, 0x2D28, 0x2D6E, 0x2DB4, 0x2DF9, -0x2E3F, 0x2E85, 0x2ECB, 0x2F11, 0x2F57, 0x2F9D, 0x2FE3, 0x302A, -0x3070, 0x30B6, 0x30FD, 0x3143, 0x318A, 0x31D0, 0x3217, 0x325E, -0x32A5, 0x32EC, 0x3332, 0x3379, 0x33C1, 0x3408, 0x344F, 0x3496, -0x34DD, 0x3525, 0x356C, 0x35B4, 0x35FB, 0x3643, 0x368B, 0x36D3, -0x371A, 0x3762, 0x37AA, 0x37F2, 0x383A, 0x3883, 0x38CB, 0x3913, -0x395C, 0x39A4, 0x39ED, 0x3A35, 0x3A7E, 0x3AC6, 0x3B0F, 0x3B58, -0x3BA1, 0x3BEA, 0x3C33, 0x3C7C, 0x3CC5, 0x3D0E, 0x3D58, 0x3DA1, -0x3DEA, 0x3E34, 0x3E7D, 0x3EC7, 0x3F11, 0x3F5A, 0x3FA4, 0x3FEE, -0x4038, 0x4082, 0x40CC, 0x4116, 0x4161, 0x41AB, 0x41F5, 0x4240, -0x428A, 0x42D5, 0x431F, 0x436A, 0x43B5, 0x4400, 0x444B, 0x4495, -0x44E1, 0x452C, 0x4577, 0x45C2, 0x460D, 0x4659, 0x46A4, 0x46F0, -0x473B, 0x4787, 0x47D3, 0x481E, 0x486A, 0x48B6, 0x4902, 0x494E, -0x499A, 0x49E6, 0x4A33, 0x4A7F, 0x4ACB, 0x4B18, 0x4B64, 0x4BB1, -0x4BFE, 0x4C4A, 0x4C97, 0x4CE4, 0x4D31, 0x4D7E, 0x4DCB, 0x4E18, -0x4E66, 0x4EB3, 0x4F00, 0x4F4E, 0x4F9B, 0x4FE9, 0x5036, 0x5084, -0x50D2, 0x5120, 0x516E, 0x51BC, 0x520A, 0x5258, 0x52A6, 0x52F4, -0x5343, 0x5391, 0x53E0, 0x542E, 0x547D, 0x54CC, 0x551A, 0x5569, -0x55B8, 0x5607, 0x5656, 0x56A5, 0x56F4, 0x5744, 0x5793, 0x57E2, -0x5832, 0x5882, 0x58D1, 0x5921, 0x5971, 0x59C1, 0x5A10, 0x5A60, -0x5AB0, 0x5B01, 0x5B51, 0x5BA1, 0x5BF1, 0x5C42, 0x5C92, 0x5CE3, -0x5D34, 0x5D84, 0x5DD5, 0x5E26, 0x5E77, 0x5EC8, 0x5F19, 0x5F6A, -0x5FBB, 0x600D, 0x605E, 0x60B0, 0x6101, 0x6153, 0x61A4, 0x61F6, -0x6248, 0x629A, 0x62EC, 0x633E, 0x6390, 0x63E2, 0x6434, 0x6487, -0x64D9, 0x652C, 0x657E, 0x65D1, 0x6624, 0x6676, 0x66C9, 0x671C, -0x676F, 0x67C2, 0x6815, 0x6869, 0x68BC, 0x690F, 0x6963, 0x69B6, -0x6A0A, 0x6A5E, 0x6AB1, 0x6B05, 0x6B59, 0x6BAD, 0x6C01, 0x6C55, -0x6CAA, 0x6CFE, 0x6D52, 0x6DA7, 0x6DFB, 0x6E50, 0x6EA4, 0x6EF9, -0x6F4E, 0x6FA3, 0x6FF8, 0x704D, 0x70A2, 0x70F7, 0x714D, 0x71A2, -0x71F7, 0x724D, 0x72A2, 0x72F8, 0x734E, 0x73A4, 0x73FA, 0x7450, -0x74A6, 0x74FC, 0x7552, 0x75A8, 0x75FF, 0x7655, 0x76AC, 0x7702, -0x7759, 0x77B0, 0x7807, 0x785E, 0x78B4, 0x790C, 0x7963, 0x79BA, -0x7A11, 0x7A69, 0x7AC0, 0x7B18, 0x7B6F, 0x7BC7, 0x7C1F, 0x7C77, -0x7CCF, 0x7D27, 0x7D7F, 0x7DD7, 0x7E2F, 0x7E88, 0x7EE0, 0x7F38, -0x7F91, 0x7FEA, 0x8042, 0x809B, 0x80F4, 0x814D, 0x81A6, 0x81FF, -0x8259, 0x82B2, 0x830B, 0x8365, 0x83BE, 0x8418, 0x8472, 0x84CB, -0x8525, 0x857F, 0x85D9, 0x8633, 0x868E, 0x86E8, 0x8742, 0x879D, -0x87F7, 0x8852, 0x88AC, 0x8907, 0x8962, 0x89BD, 0x8A18, 0x8A73, -0x8ACE, 0x8B2A, 0x8B85, 0x8BE0, 0x8C3C, 0x8C97, 0x8CF3, 0x8D4F, -0x8DAB, 0x8E07, 0x8E63, 0x8EBF, 0x8F1B, 0x8F77, 0x8FD4, 0x9030, -0x908C, 0x90E9, 0x9146, 0x91A2, 0x91FF, 0x925C, 0x92B9, 0x9316, -0x9373, 0x93D1, 0x942E, 0x948C, 0x94E9, 0x9547, 0x95A4, 0x9602, -0x9660, 0x96BE, 0x971C, 0x977A, 0x97D8, 0x9836, 0x9895, 0x98F3, -0x9952, 0x99B0, 0x9A0F, 0x9A6E, 0x9ACD, 0x9B2C, 0x9B8B, 0x9BEA, -0x9C49, 0x9CA8, 0x9D08, 0x9D67, 0x9DC7, 0x9E26, 0x9E86, 0x9EE6, -0x9F46, 0x9FA6, 0xA006, 0xA066, 0xA0C6, 0xA127, 0xA187, 0xA1E8, -0xA248, 0xA2A9, 0xA30A, 0xA36B, 0xA3CC, 0xA42D, 0xA48E, 0xA4EF, -0xA550, 0xA5B2, 0xA613, 0xA675, 0xA6D6, 0xA738, 0xA79A, 0xA7FC, -0xA85E, 0xA8C0, 0xA922, 0xA984, 0xA9E7, 0xAA49, 0xAAAC, 0xAB0E, -0xAB71, 0xABD4, 0xAC37, 0xAC9A, 0xACFD, 0xAD60, 0xADC3, 0xAE27, -0xAE8A, 0xAEED, 0xAF51, 0xAFB5, 0xB019, 0xB07C, 0xB0E0, 0xB145, -0xB1A9, 0xB20D, 0xB271, 0xB2D6, 0xB33A, 0xB39F, 0xB403, 0xB468, -0xB4CD, 0xB532, 0xB597, 0xB5FC, 0xB662, 0xB6C7, 0xB72C, 0xB792, -0xB7F7, 0xB85D, 0xB8C3, 0xB929, 0xB98F, 0xB9F5, 0xBA5B, 0xBAC1, -0xBB28, 0xBB8E, 0xBBF5, 0xBC5B, 0xBCC2, 0xBD29, 0xBD90, 0xBDF7, -0xBE5E, 0xBEC5, 0xBF2C, 0xBF94, 0xBFFB, 0xC063, 0xC0CA, 0xC132, -0xC19A, 0xC202, 0xC26A, 0xC2D2, 0xC33A, 0xC3A2, 0xC40B, 0xC473, -0xC4DC, 0xC544, 0xC5AD, 0xC616, 0xC67F, 0xC6E8, 0xC751, 0xC7BB, -0xC824, 0xC88D, 0xC8F7, 0xC960, 0xC9CA, 0xCA34, 0xCA9E, 0xCB08, -0xCB72, 0xCBDC, 0xCC47, 0xCCB1, 0xCD1B, 0xCD86, 0xCDF1, 0xCE5B, -0xCEC6, 0xCF31, 0xCF9C, 0xD008, 0xD073, 0xD0DE, 0xD14A, 0xD1B5, -0xD221, 0xD28D, 0xD2F8, 0xD364, 0xD3D0, 0xD43D, 0xD4A9, 0xD515, -0xD582, 0xD5EE, 0xD65B, 0xD6C7, 0xD734, 0xD7A1, 0xD80E, 0xD87B, -0xD8E9, 0xD956, 0xD9C3, 0xDA31, 0xDA9E, 0xDB0C, 0xDB7A, 0xDBE8, -0xDC56, 0xDCC4, 0xDD32, 0xDDA0, 0xDE0F, 0xDE7D, 0xDEEC, 0xDF5B, -0xDFC9, 0xE038, 0xE0A7, 0xE116, 0xE186, 0xE1F5, 0xE264, 0xE2D4, -0xE343, 0xE3B3, 0xE423, 0xE493, 0xE503, 0xE573, 0xE5E3, 0xE654, -0xE6C4, 0xE735, 0xE7A5, 0xE816, 0xE887, 0xE8F8, 0xE969, 0xE9DA, -0xEA4B, 0xEABC, 0xEB2E, 0xEB9F, 0xEC11, 0xEC83, 0xECF5, 0xED66, -0xEDD9, 0xEE4B, 0xEEBD, 0xEF2F, 0xEFA2, 0xF014, 0xF087, 0xF0FA, -0xF16D, 0xF1E0, 0xF253, 0xF2C6, 0xF339, 0xF3AD, 0xF420, 0xF494, -0xF507, 0xF57B, 0xF5EF, 0xF663, 0xF6D7, 0xF74C, 0xF7C0, 0xF834, -0xF8A9, 0xF91E, 0xF992, 0xFA07, 0xFA7C, 0xFAF1, 0xFB66, 0xFBDC, -0xFC51, 0xFCC7, 0xFD3C, 0xFDB2, 0xFE28, 0xFE9E, 0xFF14, 0xFF8A -}; - -static u8 getvoltbl[] = { -0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, -0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, -0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, -0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, -0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, -0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, -0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, -0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, -0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x14, -0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x18, -0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, -0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, -0x22, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, 0x28, 0x29, -0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x31, 0x31, -0x32, 0x32, 0x33, 0x33, 0x34, 0x35, 0x35, 0x36, 0x36, 0x37, 0x38, 0x38, 0x39, 0x3A, 0x3A, 0x3B, -0x3C, 0x3C, 0x3D, 0x3E, 0x3F, 0x3F, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x45, 0x46, 0x47, -0x48, 0x49, 0x4A, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x52, 0x53, 0x54, 0x55, -0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x67, -0x68, 0x69, 0x6A, 0x6B, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, 0x7B, -0x7D, 0x7E, 0x7F, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, -0x26, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, -0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x36, -0x36, 0x37, 0x37, 0x38, 0x39, 0x39, 0x3A, 0x3B, 0x3B, 0x3C, 0x3D, 0x3E, 0x3E, 0x3F, 0x40, 0x40, -0x41, 0x42, 0x43, 0x43, 0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4D, -0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, -0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6F, 0x70, -0x71, 0x73, 0x74, 0x75, 0x77, 0x78, 0x79, 0x7B, 0x7C, 0x7E, 0x7E, 0x40, 0x41, 0x42, 0x43, 0x43, -0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, -0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, -0x62, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6B, 0x6C, 0x6D, 0x6E, 0x70, 0x71, 0x72, 0x74, 0x75, -0x76, 0x78, 0x79, 0x7B, 0x7C, 0x7D, 0x7E, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x46, 0x46, -0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, -0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x65, 0x66, -0x67, 0x68, 0x69, 0x6A, 0x6C, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, -0x7C, 0x7D, 0x7E, 0x7F -}; - -u32 bios_nop(armcpu_t * cpu) -{ - if (cpu->proc_ID == ARMCPU_ARM9) - { - LOG("Unimplemented bios function %02X(ARM9) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); - } - else - { - LOG("Unimplemented bios function %02X(ARM7) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); - } - return 3; -} - -u32 delayLoop(armcpu_t * cpu) -{ - return cpu->R[0] * 4; -} - -//u32 oldmode[2]; - -u32 intrWaitARM(armcpu_t * cpu) -{ - u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - u32 intr; - u32 intrFlag = 0; - - //execute = FALSE; - if(cpu->proc_ID) - { - intrFlagAdr = 0x380FFF8; - } else { - intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - } - intr = MMU_read32(cpu->proc_ID, intrFlagAdr); - intrFlag = cpu->R[1] & intr; - - if(intrFlag) - { - // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) - // on efface son(les) occurence(s). - intr ^= intrFlag; - MMU_write32(cpu->proc_ID, intrFlagAdr, intr); - //cpu->switchMode(oldmode[cpu->proc_ID]); - return 1; - } - - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - cpu->waitIRQ = 1; - //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); - - return 1; -} - -u32 waitVBlankARM(armcpu_t * cpu) -{ - u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - u32 intr; - u32 intrFlag = 0; - - //execute = FALSE; - if(cpu->proc_ID) - { - intrFlagAdr = 0x380FFF8; - } else { - intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - } - intr = MMU_read32(cpu->proc_ID, intrFlagAdr); - intrFlag = 1 & intr; - - if(intrFlag) - { - // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) - // on efface son(les) occurence(s). - intr ^= intrFlag; - MMU_write32(cpu->proc_ID, intrFlagAdr, intr); - //cpu->switchMode(oldmode[cpu->proc_ID]); - return 1; - } - - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - cpu->waitIRQ = 1; - //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); - - return 1; -} - -u32 wait4IRQ(armcpu_t* cpu) -{ - //execute= FALSE; - if(cpu->wirq) - { - if(!cpu->waitIRQ) - { - cpu->waitIRQ = 0; - cpu->wirq = 0; - //cpu->switchMode(oldmode[cpu->proc_ID]); - return 1; - } - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - return 1; - } - cpu->waitIRQ = 1; - cpu->wirq = 1; - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); - return 1; -} - -u32 devide(armcpu_t* cpu) -{ - s32 num = (s32)cpu->R[0]; - s32 dnum = (s32)cpu->R[1]; - - if(dnum==0) return 0; - - cpu->R[0] = (u32)(num / dnum); - cpu->R[1] = (u32)(num % dnum); - cpu->R[3] = (u32) (((s32)cpu->R[0])<0 ? -cpu->R[0] : cpu->R[0]); - - return 6; -} - -u32 copy(armcpu_t* cpu) -{ - u32 src = cpu->R[0]; - u32 dst = cpu->R[1]; - u32 cnt = cpu->R[2]; - - switch(BIT26(cnt)) - { - case 0: - src &= 0xFFFFFFFE; - dst &= 0xFFFFFFFE; - switch(BIT24(cnt)) - { - case 0: - cnt &= 0x1FFFFF; - while(cnt) - { - MMU_write16(cpu->proc_ID, dst, MMU_read16(cpu->proc_ID, src)); - cnt--; - dst+=2; - src+=2; - } - break; - case 1: - { - u32 val = MMU_read16(cpu->proc_ID, src); - cnt &= 0x1FFFFF; - while(cnt) - { - MMU_write16(cpu->proc_ID, dst, val); - cnt--; - dst+=2; - } - } - break; - } - break; - case 1: - src &= 0xFFFFFFFC; - dst &= 0xFFFFFFFC; - switch(BIT24(cnt)) - { - case 0: - cnt &= 0x1FFFFF; - while(cnt) - { - MMU_write32(cpu->proc_ID, dst, MMU_read32(cpu->proc_ID, src)); - cnt--; - dst+=4; - src+=4; - } - break; - case 1: - { - u32 val = MMU_read32(cpu->proc_ID, src); - cnt &= 0x1FFFFF; - while(cnt) - { - MMU_write32(cpu->proc_ID, dst, val); - cnt--; - dst+=4; - } - } - break; - } - break; - } - return 1; -} - -u32 fastCopy(armcpu_t* cpu) -{ - u32 src = cpu->R[0] & 0xFFFFFFFC; - u32 dst = cpu->R[1] & 0xFFFFFFFC; - u32 cnt = cpu->R[2]; - - switch(BIT24(cnt)) - { - case 0: - cnt &= 0x1FFFFF; - while(cnt) - { - MMU_write32(cpu->proc_ID, dst, MMU_read32(cpu->proc_ID, src)); - cnt--; - dst+=4; - src+=4; - } - break; - case 1: - { - u32 val = MMU_read32(cpu->proc_ID, src); - cnt &= 0x1FFFFF; - while(cnt) - { - MMU_write32(cpu->proc_ID, dst, val); - cnt--; - dst+=4; - } - } - break; - } - return 1; -} - -u32 LZ77UnCompVram(armcpu_t* cpu) -{ - int i1, i2; - int byteCount; - int byteShift; - u32 writeValue; - int len; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - u32 header = MMU_read32(cpu->proc_ID, source); - source += 4; - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - byteCount = 0; - byteShift = 0; - writeValue = 0; - - len = header >> 8; - - while(len > 0) { - u8 d = MMU_read8(cpu->proc_ID, source++); - - if(d) { - for(i1 = 0; i1 < 8; i1++) { - if(d & 0x80) { - int length; - int offset; - u32 windowOffset; - u16 data = MMU_read8(cpu->proc_ID, source++) << 8; - data |= MMU_read8(cpu->proc_ID, source++); - length = (data >> 12) + 3; - offset = (data & 0x0FFF); - windowOffset = dest + byteCount - offset - 1; - for(i2 = 0; i2 < length; i2++) { - writeValue |= (MMU_read8(cpu->proc_ID, windowOffset++) << byteShift); - byteShift += 8; - byteCount++; - - if(byteCount == 2) { - MMU_write16(cpu->proc_ID, dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } else { - writeValue |= (MMU_read8(cpu->proc_ID, source++) << byteShift); - byteShift += 8; - byteCount++; - if(byteCount == 2) { - MMU_write16(cpu->proc_ID, dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - d <<= 1; - } - } else { - for(i1 = 0; i1 < 8; i1++) { - writeValue |= (MMU_read8(cpu->proc_ID, source++) << byteShift); - byteShift += 8; - byteCount++; - if(byteCount == 2) { - MMU_write16(cpu->proc_ID, dest, writeValue); - dest += 2; - byteShift = 0; - byteCount = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -u32 LZ77UnCompWram(armcpu_t* cpu) -{ - int i1, i2; - int len; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - - u32 header = MMU_read32(cpu->proc_ID, source); - source += 4; - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - - while(len > 0) { - u8 d = MMU_read8(cpu->proc_ID, source++); - - if(d) { - for(i1 = 0; i1 < 8; i1++) { - if(d & 0x80) { - int length; - int offset; - u32 windowOffset; - u16 data = MMU_read8(cpu->proc_ID, source++) << 8; - data |= MMU_read8(cpu->proc_ID, source++); - length = (data >> 12) + 3; - offset = (data & 0x0FFF); - windowOffset = dest - offset - 1; - for(i2 = 0; i2 < length; i2++) { - MMU_write8(cpu->proc_ID, dest++, MMU_read8(cpu->proc_ID, windowOffset++)); - len--; - if(len == 0) - return 0; - } - } else { - MMU_write8(cpu->proc_ID, dest++, MMU_read8(cpu->proc_ID, source++)); - len--; - if(len == 0) - return 0; - } - d <<= 1; - } - } else { - for(i1 = 0; i1 < 8; i1++) { - MMU_write8(cpu->proc_ID, dest++, MMU_read8(cpu->proc_ID, source++)); - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -u32 RLUnCompVram(armcpu_t* cpu) -{ - int i; - int len; - int byteCount; - int byteShift; - u32 writeValue; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - - u32 header = MMU_read32(cpu->proc_ID, source); - source += 4; - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - byteCount = 0; - byteShift = 0; - writeValue = 0; - - while(len > 0) { - u8 d = MMU_read8(cpu->proc_ID, source++); - int l = d & 0x7F; - if(d & 0x80) { - u8 data = MMU_read8(cpu->proc_ID, source++); - l += 3; - for(i = 0;i < l; i++) { - writeValue |= (data << byteShift); - byteShift += 8; - byteCount++; - - if(byteCount == 2) { - MMU_write16(cpu->proc_ID, dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } else { - l++; - for(i = 0; i < l; i++) { - writeValue |= (MMU_read8(cpu->proc_ID, source++) << byteShift); - byteShift += 8; - byteCount++; - if(byteCount == 2) { - MMU_write16(cpu->proc_ID, dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -u32 RLUnCompWram(armcpu_t* cpu) -{ - int i; - int len; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - - u32 header = MMU_read32(cpu->proc_ID, source); - source += 4; - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - - while(len > 0) { - u8 d = MMU_read8(cpu->proc_ID, source++); - int l = d & 0x7F; - if(d & 0x80) { - u8 data = MMU_read8(cpu->proc_ID, source++); - l += 3; - for(i = 0;i < l; i++) { - MMU_write8(cpu->proc_ID, dest++, data); - len--; - if(len == 0) - return 0; - } - } else { - l++; - for(i = 0; i < l; i++) { - MMU_write8(cpu->proc_ID, dest++, MMU_read8(cpu->proc_ID, source++)); - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -u32 UnCompHuffman(armcpu_t* cpu) -{ - u32 source, dest, writeValue, header, treeStart, mask; - u32 data; - u8 treeSize, currentNode, rootNode; - int byteCount, byteShift, len, pos; - int writeData; - - source = cpu->R[0]; - dest = cpu->R[1]; - - header = MMU_read8(cpu->proc_ID, source); - source += 4; - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - treeSize = MMU_read8(cpu->proc_ID, source++); - - treeStart = source; - - source += ((treeSize+1)<<1)-1; // minus because we already skipped one byte - - len = header >> 8; - - mask = 0x80000000; - data = MMU_read8(cpu->proc_ID, source); - source += 4; - - pos = 0; - rootNode = MMU_read8(cpu->proc_ID, treeStart); - currentNode = rootNode; - writeData = 0; - byteShift = 0; - byteCount = 0; - writeValue = 0; - - if((header & 0x0F) == 8) { - while(len > 0) { - // take left - if(pos == 0) - pos++; - else - pos += (((currentNode & 0x3F)+1)<<1); - - if(data & mask) { - // right - if(currentNode & 0x40) - writeData = 1; - currentNode = MMU_read8(cpu->proc_ID, treeStart+pos+1); - } else { - // left - if(currentNode & 0x80) - writeData = 1; - currentNode = MMU_read8(cpu->proc_ID, treeStart+pos); - } - - if(writeData) { - writeValue |= (currentNode << byteShift); - byteCount++; - byteShift += 8; - - pos = 0; - currentNode = rootNode; - writeData = 0; - - if(byteCount == 4) { - byteCount = 0; - byteShift = 0; - MMU_write8(cpu->proc_ID, dest, writeValue); - writeValue = 0; - dest += 4; - len -= 4; - } - } - mask >>= 1; - if(mask == 0) { - mask = 0x80000000; - data = MMU_read8(cpu->proc_ID, source); - source += 4; - } - } - } else { - int halfLen = 0; - int value = 0; - while(len > 0) { - // take left - if(pos == 0) - pos++; - else - pos += (((currentNode & 0x3F)+1)<<1); - - if((data & mask)) { - // right - if(currentNode & 0x40) - writeData = 1; - currentNode = MMU_read8(cpu->proc_ID, treeStart+pos+1); - } else { - // left - if(currentNode & 0x80) - writeData = 1; - currentNode = MMU_read8(cpu->proc_ID, treeStart+pos); - } - - if(writeData) { - if(halfLen == 0) - value |= currentNode; - else - value |= (currentNode<<4); - - halfLen += 4; - if(halfLen == 8) { - writeValue |= (value << byteShift); - byteCount++; - byteShift += 8; - - halfLen = 0; - value = 0; - - if(byteCount == 4) { - byteCount = 0; - byteShift = 0; - MMU_write8(cpu->proc_ID, dest, writeValue); - dest += 4; - writeValue = 0; - len -= 4; - } - } - pos = 0; - currentNode = rootNode; - writeData = 0; - } - mask >>= 1; - if(mask == 0) { - mask = 0x80000000; - data = MMU_read8(cpu->proc_ID, source); - source += 4; - } - } - } - return 1; -} - -u32 BitUnPack(armcpu_t* cpu) -{ - u32 source,dest,header,base,d,temp; - int len,bits,revbits,dataSize,data,bitwritecount,mask,bitcount,addBase; - u8 b; - - source = cpu->R[0]; - dest = cpu->R[1]; - header = cpu->R[2]; - - len = MMU_read16(cpu->proc_ID, header); - // check address - bits = MMU_read8(cpu->proc_ID, header+2); - revbits = 8 - bits; - // u32 value = 0; - base = MMU_read8(cpu->proc_ID, header+4); - addBase = (base & 0x80000000) ? 1 : 0; - base &= 0x7fffffff; - dataSize = MMU_read8(cpu->proc_ID, header+3); - - data = 0; - bitwritecount = 0; - while(1) { - len -= 1; - if(len < 0) - break; - mask = 0xff >> revbits; - b = MMU_read8(cpu->proc_ID, source); - source++; - bitcount = 0; - while(1) { - if(bitcount >= 8) - break; - d = b & mask; - temp = d >> bitcount; - if(!temp && addBase) { - temp += base; - } - data |= temp << bitwritecount; - bitwritecount += dataSize; - if(bitwritecount >= 32) { - MMU_write8(cpu->proc_ID, dest, data); - dest += 4; - data = 0; - bitwritecount = 0; - } - mask <<= bits; - bitcount += bits; - } - } - return 1; -} - -u32 Diff8bitUnFilterWram(armcpu_t* cpu) -{ - u32 source,dest,header; - u8 data,diff; - int len; - - source = cpu->R[0]; - dest = cpu->R[1]; - - header = MMU_read8(cpu->proc_ID, source); - source += 4; - - if(((source & 0xe000000) == 0) || - (( (source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)) - return 0; - - len = header >> 8; - - data = MMU_read8(cpu->proc_ID, source++); - MMU_write8(cpu->proc_ID, dest++, data); - len--; - - while(len > 0) { - diff = MMU_read8(cpu->proc_ID, source++); - data += diff; - MMU_write8(cpu->proc_ID, dest++, data); - len--; - } - return 1; -} - -u32 Diff16bitUnFilter(armcpu_t* cpu) -{ - u32 source,dest,header; - u16 data; - int len; - - source = cpu->R[0]; - dest = cpu->R[1]; - - header = MMU_read8(cpu->proc_ID, source); - source += 4; - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - - data = MMU_read16(cpu->proc_ID, source); - source += 2; - MMU_write16(cpu->proc_ID, dest, data); - dest += 2; - len -= 2; - - while(len >= 2) { - u16 diff = MMU_read16(cpu->proc_ID, source); - source += 2; - data += diff; - MMU_write16(cpu->proc_ID, dest, data); - dest += 2; - len -= 2; - } - return 1; -} - -u32 bios_sqrt(armcpu_t* cpu) -{ - cpu->R[0] = (u32)sqrt((double)(cpu->R[0])); - return 1; -} - -u32 setHaltCR(armcpu_t* cpu) -{ - MMU_write8(cpu->proc_ID, 0x4000300+cpu->proc_ID, cpu->R[0]); - return 1; -} - -u32 getSineTab(armcpu_t* cpu) -{ - cpu->R[0] = getsinetbl[cpu->R[0]]; - return 1; -} - -u32 getPitchTab(armcpu_t* cpu) -{ - cpu->R[0] = getpitchtbl[cpu->R[0]]; - return 1; -} - -u32 getVolumeTab(armcpu_t* cpu) -{ - cpu->R[0] = getvoltbl[cpu->R[0]]; - return 1; -} - -u32 getCRC16(armcpu_t* cpu) -{ - unsigned int i,j; - - u32 crc = cpu->R[0]; - u32 datap = cpu->R[1]; - u32 size = cpu->R[2]; - - static u16 val[] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 }; - for(i = 0; i < size; i++) - { - crc = crc ^ MMU_read8( cpu->proc_ID, datap + i); - - for(j = 0; j < 8; j++) { - int do_bit = 0; - - if ( crc & 0x1) - do_bit = 1; - - crc = crc >> 1; - - if ( do_bit) { - crc = crc ^ (val[j] << (7-j)); - } - } - } - cpu->R[0] = crc; - return 1; -} - -u32 SoundBias(armcpu_t* cpu) -{ - // u32 current = SPU_ReadLong(0x4000504); - // if (cpu->R[0] > current) - //SPU_WriteLong(0x4000504, current + 0x1); - // else - //SPU_WriteLong(0x4000504, current - 0x1); - // return cpu->R[1]; - - u32 curBias = MMU_read32(ARMCPU_ARM7,0x04000504); - u32 newBias = (curBias == 0) ? 0x000:0x200; - u32 delay = (newBias > curBias) ? (newBias-curBias) : (curBias-newBias); - - MMU_write32(ARMCPU_ARM7,0x04000504, newBias); - return cpu->R[1] * delay; -} - -u32 (* ARM9_swi_tab[32])(armcpu_t* cpu)={ - bios_nop, // 0x00 - bios_nop, // 0x01 - bios_nop, // 0x02 - delayLoop, // 0x03 - intrWaitARM, // 0x04 - waitVBlankARM, // 0x05 - wait4IRQ, // 0x06 - bios_nop, // 0x07 - bios_nop, // 0x08 - devide, // 0x09 - bios_nop, // 0x0A - copy, // 0x0B - fastCopy, // 0x0C - bios_sqrt, // 0x0D - getCRC16, // 0x0E - bios_nop, // 0x0F - BitUnPack, // 0x10 - LZ77UnCompWram, // 0x11 - LZ77UnCompVram, // 0x12 - UnCompHuffman, // 0x13 - RLUnCompWram, // 0x14 - RLUnCompVram, // 0x15 - Diff8bitUnFilterWram, // 0x16 - bios_nop, // 0x17 - Diff16bitUnFilter, // 0x18 - bios_nop, // 0x19 - bios_nop, // 0x1A - bios_nop, // 0x1B - bios_nop, // 0x1C - bios_nop, // 0x1D - bios_nop, // 0x1E - setHaltCR, // 0x1F -}; - -u32 (* ARM7_swi_tab[32])(armcpu_t* cpu)={ - bios_nop, // 0x00 - bios_nop, // 0x01 - bios_nop, // 0x02 - delayLoop, // 0x03 - intrWaitARM, // 0x04 - waitVBlankARM, // 0x05 - wait4IRQ, // 0x06 - wait4IRQ, // 0x07 - SoundBias, // 0x08 - devide, // 0x09 - bios_nop, // 0x0A - copy, // 0x0B - fastCopy, // 0x0C - bios_sqrt, // 0x0D - getCRC16, // 0x0E - bios_nop, // 0x0F - BitUnPack, // 0x10 - LZ77UnCompWram, // 0x11 - LZ77UnCompVram, // 0x12 - UnCompHuffman, // 0x13 - RLUnCompWram, // 0x14 - RLUnCompVram, // 0x15 - Diff8bitUnFilterWram, // 0x16 - bios_nop, // 0x17 - bios_nop, // 0x18 - bios_nop, // 0x19 - getSineTab, // 0x1A - getPitchTab, // 0x1B - getVolumeTab, // 0x1C - bios_nop, // 0x1D - bios_nop, // 0x1E - setHaltCR, // 0x1F -}; diff --git a/tools/vio2sf/src/vio2sf/desmume/bios.h b/tools/vio2sf/src/vio2sf/desmume/bios.h deleted file mode 100644 index 7f717cb8c..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/bios.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef BIOS_H -#define BIOS_H - -#include "armcpu.h" - -extern u32 (* ARM9_swi_tab[32])(armcpu_t * cpu); -extern u32 (* ARM7_swi_tab[32])(armcpu_t * cpu); -extern u32 wait4IRQ(armcpu_t * cpu); - -#endif - diff --git a/tools/vio2sf/src/vio2sf/desmume/bits.h b/tools/vio2sf/src/vio2sf/desmume/bits.h deleted file mode 100644 index be64f65d7..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/bits.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BITS_H -#define BITS_H - -#define BIT(n) (1<<(n)) - -#define BIT_N(i,n) (((i)>>(n))&1) -#define BIT0(i) ((i)&1) -#define BIT1(i) BIT_N(i,1) -#define BIT2(i) BIT_N(i,2) -#define BIT3(i) BIT_N(i,3) -#define BIT4(i) BIT_N(i,4) -#define BIT5(i) BIT_N(i,5) -#define BIT6(i) BIT_N(i,6) -#define BIT7(i) BIT_N(i,7) -#define BIT8(i) BIT_N(i,8) -#define BIT9(i) BIT_N(i,9) -#define BIT10(i) BIT_N(i,10) -#define BIT11(i) BIT_N(i,11) -#define BIT12(i) BIT_N(i,12) -#define BIT13(i) BIT_N(i,13) -#define BIT14(i) BIT_N(i,14) -#define BIT15(i) BIT_N(i,15) -#define BIT16(i) BIT_N(i,16) -#define BIT17(i) BIT_N(i,17) -#define BIT18(i) BIT_N(i,18) -#define BIT19(i) BIT_N(i,19) -#define BIT20(i) BIT_N(i,20) -#define BIT21(i) BIT_N(i,21) -#define BIT22(i) BIT_N(i,22) -#define BIT23(i) BIT_N(i,23) -#define BIT24(i) BIT_N(i,24) -#define BIT25(i) BIT_N(i,25) -#define BIT26(i) BIT_N(i,26) -#define BIT27(i) BIT_N(i,27) -#define BIT28(i) BIT_N(i,28) -#define BIT29(i) BIT_N(i,29) -#define BIT30(i) BIT_N(i,30) -#define BIT31(i) ((i)>>31) - -#define CONDITION(i) (i)>>28 - -#define REG_POS(i,n) (((i)>>n)&0xF) - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/config.h b/tools/vio2sf/src/vio2sf/desmume/config.h deleted file mode 100644 index 2f2f707ee..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/config.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2006 thoduv - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#include - -#include "debug.h" - -#endif /*__CONFIG_H__*/ - diff --git a/tools/vio2sf/src/vio2sf/desmume/cp15.c b/tools/vio2sf/src/vio2sf/desmume/cp15.c deleted file mode 100644 index d8ff7b071..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/cp15.c +++ /dev/null @@ -1,590 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -#include "cp15.h" -#include "debug.h" -#include "MMU.h" - -armcp15_t *armcp15_new(armcpu_t * c) -{ - int i; - armcp15_t *armcp15 = (armcp15_t*)malloc(sizeof(armcp15_t)); - if(!armcp15) return NULL; - - armcp15->cpu = c; - armcp15->IDCode = 0x41049460; - armcp15->cacheType = 0x0F0D2112; - armcp15->TCMSize = 0x00140140; - armcp15->ctrl = 0x00000000; - armcp15->DCConfig = 0x0; - armcp15->ICConfig = 0x0; - armcp15->writeBuffCtrl = 0x0; - armcp15->und = 0x0; - armcp15->DaccessPerm = 0x22222222; - armcp15->IaccessPerm = 0x22222222; - armcp15->protectBaseSize0 = 0x0; - armcp15->protectBaseSize1 = 0x0; - armcp15->protectBaseSize2 = 0x0; - armcp15->protectBaseSize3 = 0x0; - armcp15->protectBaseSize4 = 0x0; - armcp15->protectBaseSize5 = 0x0; - armcp15->protectBaseSize6 = 0x0; - armcp15->protectBaseSize7 = 0x0; - armcp15->cacheOp = 0x0; - armcp15->DcacheLock = 0x0; - armcp15->IcacheLock = 0x0; - armcp15->ITCMRegion = 0x0C; - armcp15->DTCMRegion = 0x0080000A; - armcp15->processID = 0; - - /* preset calculated regionmasks */ - for (i=0;i<8;i++) { - armcp15->regionWriteMask_USR[i] = 0 ; - armcp15->regionWriteMask_SYS[i] = 0 ; - armcp15->regionReadMask_USR[i] = 0 ; - armcp15->regionReadMask_SYS[i] = 0 ; - armcp15->regionExecuteMask_USR[i] = 0 ; - armcp15->regionExecuteMask_SYS[i] = 0 ; - armcp15->regionWriteSet_USR[i] = 0 ; - armcp15->regionWriteSet_SYS[i] = 0 ; - armcp15->regionReadSet_USR[i] = 0 ; - armcp15->regionReadSet_SYS[i] = 0 ; - armcp15->regionExecuteSet_USR[i] = 0 ; - armcp15->regionExecuteSet_SYS[i] = 0 ; - } ; - - return armcp15; -} - -#define ACCESSTYPE(val,n) (((val) >> (4*n)) & 0x0F) -#define SIZEIDENTIFIER(val) ((((val) >> 1) & 0x1F)) -#define SIZEBINARY(val) (1 << (SIZEIDENTIFIER(val)+1)) -#define MASKFROMREG(val) (~((SIZEBINARY(val)-1) | 0x3F)) -#define SETFROMREG(val) ((val) & MASKFROMREG(val)) -/* sets the precalculated regions to mask,set for the affected accesstypes */ -void armcp15_setSingleRegionAccess(armcp15_t *armcp15,unsigned long dAccess,unsigned long iAccess,unsigned char num, unsigned long mask,unsigned long set) { - - switch (ACCESSTYPE(dAccess,num)) { - case 4: /* UNP */ - case 7: /* UNP */ - case 8: /* UNP */ - case 9: /* UNP */ - case 10: /* UNP */ - case 11: /* UNP */ - case 12: /* UNP */ - case 13: /* UNP */ - case 14: /* UNP */ - case 15: /* UNP */ - case 0: /* no access at all */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = 0 ; - armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionWriteMask_SYS[num] = 0 ; - armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_SYS[num] = 0 ; - armcp15->regionReadSet_SYS[num] = 0xFFFFFFFF ; - break ; - case 1: /* no access at USR, all to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = 0 ; - armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionWriteMask_SYS[num] = mask ; - armcp15->regionWriteSet_SYS[num] = set ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 2: /* read at USR, all to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = mask ; - armcp15->regionReadSet_USR[num] = set ; - armcp15->regionWriteMask_SYS[num] = mask ; - armcp15->regionWriteSet_SYS[num] = set ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 3: /* all to USR, all to sys */ - armcp15->regionWriteMask_USR[num] = mask ; - armcp15->regionWriteSet_USR[num] = set ; - armcp15->regionReadMask_USR[num] = mask ; - armcp15->regionReadSet_USR[num] = set ; - armcp15->regionWriteMask_SYS[num] = mask ; - armcp15->regionWriteSet_SYS[num] = set ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 5: /* no access at USR, read to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = 0 ; - armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionWriteMask_SYS[num] = 0 ; - armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 6: /* read at USR, read to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = mask ; - armcp15->regionReadSet_USR[num] = set ; - armcp15->regionWriteMask_SYS[num] = 0 ; - armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - } - switch (ACCESSTYPE(iAccess,num)) { - case 4: /* UNP */ - case 7: /* UNP */ - case 8: /* UNP */ - case 9: /* UNP */ - case 10: /* UNP */ - case 11: /* UNP */ - case 12: /* UNP */ - case 13: /* UNP */ - case 14: /* UNP */ - case 15: /* UNP */ - case 0: /* no access at all */ - armcp15->regionExecuteMask_USR[num] = 0 ; - armcp15->regionExecuteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionExecuteMask_SYS[num] = 0 ; - armcp15->regionExecuteSet_SYS[num] = 0xFFFFFFFF ; - break ; - case 1: - armcp15->regionExecuteMask_USR[num] = 0 ; - armcp15->regionExecuteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionExecuteMask_SYS[num] = mask ; - armcp15->regionExecuteSet_SYS[num] = set ; - break ; - case 2: - case 3: - case 6: - armcp15->regionExecuteMask_USR[num] = mask ; - armcp15->regionExecuteSet_USR[num] = set ; - armcp15->regionExecuteMask_SYS[num] = mask ; - armcp15->regionExecuteSet_SYS[num] = set ; - break ; - } -} ; - -/* precalculate region masks/sets from cp15 register */ -void armcp15_maskPrecalc(armcp15_t *armcp15) -{ - #define precalc(num) { \ - u32 mask = 0, set = 0xFFFFFFFF ; /* (x & 0) == 0xFF..FF is allways false (disabled) */ \ - if (BIT_N(armcp15->protectBaseSize##num,0)) /* if region is enabled */ \ - { /* reason for this define: naming includes var */ \ - mask = MASKFROMREG(armcp15->protectBaseSize##num) ; \ - set = SETFROMREG(armcp15->protectBaseSize##num) ; \ - if (SIZEIDENTIFIER(armcp15->protectBaseSize##num)==0x1F) \ - { /* for the 4GB region, u32 suffers wraparound */ \ - mask = 0 ; set = 0 ; /* (x & 0) == 0 is allways true (enabled) */ \ - } \ - } \ - armcp15_setSingleRegionAccess(armcp15,armcp15->DaccessPerm,armcp15->IaccessPerm,num,mask,set) ; \ - } - precalc(0) ; - precalc(1) ; - precalc(2) ; - precalc(3) ; - precalc(4) ; - precalc(5) ; - precalc(6) ; - precalc(7) ; -} - -INLINE BOOL armcp15_isAccessAllowed(armcp15_t *armcp15,u32 address,u32 access) -{ - int i ; - if (!(armcp15->ctrl & 1)) return TRUE ; /* protection checking is not enabled */ - for (i=0;i<8;i++) { - switch (access) { - case CP15_ACCESS_WRITEUSR: - if ((address & armcp15->regionWriteMask_USR[i]) == armcp15->regionWriteSet_USR[i]) return TRUE ; - break ; - case CP15_ACCESS_WRITESYS: - if ((address & armcp15->regionWriteMask_SYS[i]) == armcp15->regionWriteSet_SYS[i]) return TRUE ; - break ; - case CP15_ACCESS_READUSR: - if ((address & armcp15->regionReadMask_USR[i]) == armcp15->regionReadSet_USR[i]) return TRUE ; - break ; - case CP15_ACCESS_READSYS: - if ((address & armcp15->regionReadMask_SYS[i]) == armcp15->regionReadSet_SYS[i]) return TRUE ; - break ; - case CP15_ACCESS_EXECUSR: - if ((address & armcp15->regionExecuteMask_USR[i]) == armcp15->regionExecuteSet_USR[i]) return TRUE ; - break ; - case CP15_ACCESS_EXECSYS: - if ((address & armcp15->regionExecuteMask_SYS[i]) == armcp15->regionExecuteSet_SYS[i]) return TRUE ; - break ; - } - } - /* when protections are enabled, but no region allows access, deny access */ - return FALSE ; -} - -BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) -{ - return FALSE; -} - -BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr) -{ - return FALSE; -} - -BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr) -{ - return FALSE; -} - -BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) -{ - if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE; - - switch(CRn) - { - case 0 : - if((opcode1 == 0)&&(CRm==0)) - { - switch(opcode2) - { - case 1 : - *R = armcp15->cacheType; - return TRUE; - case 2 : - *R = armcp15->TCMSize; - return TRUE; - default : - *R = armcp15->IDCode; - return TRUE; - } - } - return FALSE; - case 1 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - *R = armcp15->ctrl; - return TRUE; - } - return FALSE; - - case 2 : - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 0 : - *R = armcp15->DCConfig; - return TRUE; - case 1 : - *R = armcp15->ICConfig; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 3 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - *R = armcp15->writeBuffCtrl; - return TRUE; - } - return FALSE; - case 5 : - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 2 : - *R = armcp15->DaccessPerm; - return TRUE; - case 3 : - *R = armcp15->IaccessPerm; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 6 : - if((opcode1==0) && (opcode2==0)) - { - switch(CRm) - { - case 0 : - *R = armcp15->protectBaseSize0; - return TRUE; - case 1 : - *R = armcp15->protectBaseSize1; - return TRUE; - case 2 : - *R = armcp15->protectBaseSize2; - return TRUE; - case 3 : - *R = armcp15->protectBaseSize3; - return TRUE; - case 4 : - *R = armcp15->protectBaseSize4; - return TRUE; - case 5 : - *R = armcp15->protectBaseSize5; - return TRUE; - case 6 : - *R = armcp15->protectBaseSize6; - return TRUE; - case 7 : - *R = armcp15->protectBaseSize7; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 9 : - if((opcode1==0)) - { - switch(CRm) - { - case 0 : - switch(opcode2) - { - case 0 : - *R = armcp15->DcacheLock; - return TRUE; - case 1 : - *R = armcp15->IcacheLock; - return TRUE; - default : - return FALSE; - } - case 1 : - switch(opcode2) - { - case 0 : - *R = armcp15->DTCMRegion; - return TRUE; - case 1 : - *R = armcp15->ITCMRegion; - return TRUE; - default : - return FALSE; - } - } - } - return FALSE; - default : - return FALSE; - } -} - - -u32 CP15wait4IRQ(armcpu_t *cpu) -{ - /* on the first call, wirq is not set */ - if(cpu->wirq) - { - /* check wether an irq was issued */ - if(!cpu->waitIRQ) - { - cpu->waitIRQ = 0; - cpu->wirq = 0; - return 1; /* return execution */ - } - /* otherwise, repeat this instruction */ - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - return 1; - } - /* first run, set us into waiting state */ - cpu->waitIRQ = 1; - cpu->wirq = 1; - /* and set next instruction to repeat this */ - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - /* CHECKME: IME shouldn't be modified (?) */ - MMU.reg_IME[0] = 1; - return 1; -} - -BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) -{ - if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE; - - switch(CRn) - { - case 1 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - armcp15->ctrl = val; - MMU.ARM9_RW_MODE = BIT7(val); - armcp15->cpu->intVector = 0x0FFF0000 * (BIT13(val)); - armcp15->cpu->LDTBit = !BIT15(val); //TBit - /*if(BIT17(val)) - { - log::ajouter("outch !!!!!!!"); - } - if(BIT19(val)) - { - log::ajouter("outch !!!!!!!"); - }*/ - return TRUE; - } - return FALSE; - case 2 : - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 0 : - armcp15->DCConfig = val; - return TRUE; - case 1 : - armcp15->ICConfig = val; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 3 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - armcp15->writeBuffCtrl = val; - return TRUE; - } - return FALSE; - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 2 : - armcp15->DaccessPerm = val; - armcp15_maskPrecalc(armcp15); - return TRUE; - case 3 : - armcp15->IaccessPerm = val; - armcp15_maskPrecalc(armcp15); - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 6 : - if((opcode1==0) && (opcode2==0)) - { - switch(CRm) - { - case 0 : - armcp15->protectBaseSize0 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 1 : - armcp15->protectBaseSize1 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 2 : - armcp15->protectBaseSize2 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 3 : - armcp15->protectBaseSize3 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 4 : - armcp15->protectBaseSize4 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 5 : - armcp15->protectBaseSize5 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 6 : - armcp15->protectBaseSize6 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 7 : - armcp15->protectBaseSize7 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 7 : - if((CRm==0)&&(opcode1==0)&&((opcode2==4))) - { - CP15wait4IRQ(armcp15->cpu); - return TRUE; - } - return FALSE; - case 9 : - if((opcode1==0)) - { - switch(CRm) - { - case 0 : - switch(opcode2) - { - case 0 : - armcp15->DcacheLock = val; - return TRUE; - case 1 : - armcp15->IcacheLock = val; - return TRUE; - default : - return FALSE; - } - case 1 : - switch(opcode2) - { - case 0 : - armcp15->DTCMRegion = val; - MMU.DTCMRegion = val & 0x0FFFFFFC0; - /*sprintf(logbuf, "%08X", val); - log::ajouter(logbuf);*/ - return TRUE; - case 1 : - armcp15->ITCMRegion = val; - /* ITCM base is not writeable! */ - MMU.ITCMRegion = 0; - return TRUE; - default : - return FALSE; - } - } - } - return FALSE; - default : - return FALSE; - } -} - - - diff --git a/tools/vio2sf/src/vio2sf/desmume/cp15.h b/tools/vio2sf/src/vio2sf/desmume/cp15.h deleted file mode 100644 index 49496f3e5..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/cp15.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __CP15_H__ -#define __CP15_H__ - -#include "armcpu.h" - -typedef struct -{ - u32 IDCode; - u32 cacheType; - u32 TCMSize; - u32 ctrl; - u32 DCConfig; - u32 ICConfig; - u32 writeBuffCtrl; - u32 und; - u32 DaccessPerm; - u32 IaccessPerm; - u32 protectBaseSize0; - u32 protectBaseSize1; - u32 protectBaseSize2; - u32 protectBaseSize3; - u32 protectBaseSize4; - u32 protectBaseSize5; - u32 protectBaseSize6; - u32 protectBaseSize7; - u32 cacheOp; - u32 DcacheLock; - u32 IcacheLock; - u32 ITCMRegion; - u32 DTCMRegion; - u32 processID; - u32 RAM_TAG; - u32 testState; - u32 cacheDbg; - /* calculated bitmasks for the regions to decide rights uppon */ - /* calculation is done in the MCR instead of on mem access for performance */ - u32 regionWriteMask_USR[8] ; - u32 regionWriteMask_SYS[8] ; - u32 regionReadMask_USR[8] ; - u32 regionReadMask_SYS[8] ; - u32 regionExecuteMask_USR[8] ; - u32 regionExecuteMask_SYS[8] ; - u32 regionWriteSet_USR[8] ; - u32 regionWriteSet_SYS[8] ; - u32 regionReadSet_USR[8] ; - u32 regionReadSet_SYS[8] ; - u32 regionExecuteSet_USR[8] ; - u32 regionExecuteSet_SYS[8] ; - - armcpu_t * cpu; - -} armcp15_t; - -armcp15_t *armcp15_new(armcpu_t *c); -BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); -BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr); -BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr); -BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); -BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); -INLINE BOOL armcp15_isAccessAllowed(armcp15_t *armcp15,u32 address,u32 access) ; - - -#define CP15_ACCESS_WRITE 0 -#define CP15_ACCESS_READ 2 -#define CP15_ACCESS_EXECUTE 4 -#define CP15_ACCESS_WRITEUSR CP15_ACCESS_WRITE -#define CP15_ACCESS_WRITESYS 1 -#define CP15_ACCESS_READUSR CP15_ACCESS_READ -#define CP15_ACCESS_READSYS 3 -#define CP15_ACCESS_EXECUSR CP15_ACCESS_EXECUTE -#define CP15_ACCESS_EXECSYS 5 - -#endif /* __CP15_H__*/ diff --git a/tools/vio2sf/src/vio2sf/desmume/debug.h b/tools/vio2sf/src/vio2sf/desmume/debug.h deleted file mode 100644 index 647eaaacb..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/debug.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef DEBUG_H -#define DEBUG_H - -#define LOG(x) -#define GPULOG(x) -#define DIVLOG(x) -#define SQRTLOG(x) -#define CARDLOG(x) -#define DMALOG(x) - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/dscard.h b/tools/vio2sf/src/vio2sf/desmume/dscard.h deleted file mode 100644 index 9b002e347..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/dscard.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2006 thoduv - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __DSCARD_H__ -#define __DSCARD_H__ - -typedef struct -{ - - u32 adress; - u32 transfer_count; - -} nds_dscard; - -#endif /*__DSCARD_H__*/ - - - diff --git a/tools/vio2sf/src/vio2sf/desmume/instruction_tabdef.inc b/tools/vio2sf/src/vio2sf/desmume/instruction_tabdef.inc deleted file mode 100644 index f63763a73..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/instruction_tabdef.inc +++ /dev/null @@ -1,4400 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -TYPE_RETOUR (*CALLTYPE NOM_TAB[4096])(PARAMETRES)={ - OP_AND_LSL_IMM, // 000 0000 0 0000 - OP_AND_LSL_REG, // 000 0000 0 0001 - OP_AND_LSR_IMM, // 000 0000 0 0010 - OP_AND_LSR_REG, // 000 0000 0 0011 - OP_AND_ASR_IMM, // 000 0000 0 0100 - OP_AND_ASR_REG, // 000 0000 0 0101 - OP_AND_ROR_IMM, // 000 0000 0 0110 - OP_AND_ROR_REG, // 000 0000 0 0111 - - OP_AND_LSL_IMM, // 000 0000 0 1000 - OP_MUL, // 000 0000 0 1001 - OP_AND_LSR_IMM, // OOO OOOO O 1010 - OP_STRH_POS_INDE_M_REG_OFF, // 000 0000 0 1011 - OP_AND_ASR_IMM, // 000 0000 0 1100 - OP_LDRD_STRD_POST_INDEX, - // 000 0000 0 1101 - OP_AND_ROR_IMM, // 000 0000 0 1110 - OP_LDRD_STRD_POST_INDEX, - // 000 0000 0 1111 - - OP_AND_S_LSL_IMM, // 000 0000 1 0000 - OP_AND_S_LSL_REG, // 000 0000 1 0001 - OP_AND_S_LSR_IMM, // 000 0000 1 0010 - OP_AND_S_LSR_REG, // 000 0000 1 0011 - OP_AND_S_ASR_IMM, // 000 0000 1 0100 - OP_AND_S_ASR_REG, // 000 0000 1 0101 - OP_AND_S_ROR_IMM, // 000 0000 1 0110 - OP_AND_S_ROR_REG, // 000 0000 1 0111 - - OP_AND_S_LSL_IMM, // 000 0000 1 1000 - OP_MUL_S, // 000 0000 1 1001 - OP_AND_S_LSR_IMM, // 000 0000 1 1010 - OP_LDRH_POS_INDE_M_REG_OFF, // 000 0000 1 1011 - OP_AND_S_ASR_IMM, // 000 0000 1 1100 - OP_LDRSB_POS_INDE_M_REG_OFF,// 000 0000 1 1101 - OP_AND_S_ROR_IMM, // 000 0000 1 1110 - OP_LDRSH_POS_INDE_M_REG_OFF,// 000 0000 1 1111 - - OP_EOR_LSL_IMM, // 000 0001 0 0000 - OP_EOR_LSL_REG, // 000 0001 0 0001 - OP_EOR_LSR_IMM, // 000 0001 0 0010 - OP_EOR_LSR_REG, // 000 0001 0 0011 - OP_EOR_ASR_IMM, // 000 0001 0 0100 - OP_EOR_ASR_REG, // 000 0001 0 0101 - OP_EOR_ROR_IMM, // 000 0001 0 0110 - OP_EOR_ROR_REG, // 000 0001 0 0111 - - OP_EOR_LSL_IMM, // 000 0001 0 1000 - OP_MLA, // 000 0001 0 1001 - OP_EOR_LSR_IMM, // OOO OOO1 O 1010 - OP_UND, // 000 0001 0 1011 - OP_EOR_ASR_IMM, // 000 0001 0 1100 - OP_UND, // 000 0001 0 1101 - OP_EOR_ROR_IMM, // 000 0001 0 1110 - OP_UND, // 000 0001 0 1111 - - OP_EOR_S_LSL_IMM, // 000 0001 1 0000 - OP_EOR_S_LSL_REG, // 000 0001 1 0001 - OP_EOR_S_LSR_IMM, // 000 0001 1 0010 - OP_EOR_S_LSR_REG, // 000 0001 1 0011 - OP_EOR_S_ASR_IMM, // 000 0001 1 0100 - OP_EOR_S_ASR_REG, // 000 0001 1 0101 - OP_EOR_S_ROR_IMM, // 000 0001 1 0110 - OP_EOR_S_ROR_REG, // 000 0001 1 0111 - - OP_EOR_S_LSL_IMM, // 000 0001 1 1000 - OP_MLA_S, // 000 0001 1 1001 - OP_EOR_S_LSR_IMM, // 000 0001 1 1010 - OP_UND, // 000 0001 1 1011 - OP_EOR_S_ASR_IMM, // 000 0001 1 1100 - OP_UND, // 000 0001 1 1101 - OP_EOR_S_ROR_IMM, // 000 0001 1 1110 - OP_UND, // 000 0001 1 1111 - - OP_SUB_LSL_IMM, // 000 0010 0 0000 - OP_SUB_LSL_REG, // 000 0010 0 0001 - OP_SUB_LSR_IMM, // 000 0010 0 0010 - OP_SUB_LSR_REG, // 000 0010 0 0011 - OP_SUB_ASR_IMM, // 000 0010 0 0100 - OP_SUB_ASR_REG, // 000 0010 0 0101 - OP_SUB_ROR_IMM, // 000 0010 0 0110 - OP_SUB_ROR_REG, // 000 0010 0 0111 - - OP_SUB_LSL_IMM, // 000 0010 0 1000 - OP_UND, // 000 0010 0 1001 - OP_SUB_LSR_IMM, // OOO OO1O O 1010 - OP_STRH_POS_INDE_M_IMM_OFF, // 000 0010 0 1011 - OP_SUB_ASR_IMM, // 000 0010 0 1100 - OP_LDRD_STRD_POST_INDEX, - // 000 0010 0 1101 - OP_SUB_ROR_IMM, // 000 0010 0 1110 - OP_LDRD_STRD_POST_INDEX, - // 000 0010 0 1111 - - OP_SUB_S_LSL_IMM, // 000 0010 1 0000 - OP_SUB_S_LSL_REG, // 000 0010 1 0001 - OP_SUB_S_LSR_IMM, // 000 0010 1 0010 - OP_SUB_S_LSR_REG, // 000 0010 1 0011 - OP_SUB_S_ASR_IMM, // 000 0010 1 0100 - OP_SUB_S_ASR_REG, // 000 0010 1 0101 - OP_SUB_S_ROR_IMM, // 000 0010 1 0110 - OP_SUB_S_ROR_REG, // 000 0010 1 0111 - - OP_SUB_S_LSL_IMM, // 000 0010 1 1000 - OP_UND, // 000 0010 1 1001 - OP_SUB_S_LSR_IMM, // 000 0010 1 1010 - OP_LDRH_POS_INDE_M_IMM_OFF, // 000 0010 1 1011 - OP_SUB_S_ASR_IMM, // 000 0010 1 1100 - OP_LDRSB_POS_INDE_M_IMM_OFF,// 000 0010 1 1101 - OP_SUB_S_ROR_IMM, // 000 0010 1 1110 - OP_LDRSH_POS_INDE_M_IMM_OFF,// 000 0010 1 1111 -//-------------------- - OP_RSB_LSL_IMM, // 000 0011 0 0000 - OP_RSB_LSL_REG, // 000 0011 0 0001 - OP_RSB_LSR_IMM, // 000 0011 0 0010 - OP_RSB_LSR_REG, // 000 0011 0 0011 - OP_RSB_ASR_IMM, // 000 0011 0 0100 - OP_RSB_ASR_REG, // 000 0011 0 0101 - OP_RSB_ROR_IMM, // 000 0011 0 0110 - OP_RSB_ROR_REG, // 000 0011 0 0111 - - OP_RSB_LSL_IMM, // 000 0011 0 1000 - OP_UND, // 000 0011 0 1001 - OP_RSB_LSR_IMM, // OOO OO11 O 1010 - OP_UND, // 000 0011 0 1011 - OP_RSB_ASR_IMM, // 000 0011 0 1100 - OP_UND, // 000 0011 0 1101 - OP_RSB_ROR_IMM, // 000 0011 0 1110 - OP_UND, // 000 0011 0 1111 - - OP_RSB_S_LSL_IMM, // 000 0011 1 0000 - OP_RSB_S_LSL_REG, // 000 0011 1 0001 - OP_RSB_S_LSR_IMM, // 000 0011 1 0010 - OP_RSB_S_LSR_REG, // 000 0011 1 0011 - OP_RSB_S_ASR_IMM, // 000 0011 1 0100 - OP_RSB_S_ASR_REG, // 000 0011 1 0101 - OP_RSB_S_ROR_IMM, // 000 0011 1 0110 - OP_RSB_S_ROR_REG, // 000 0011 1 0111 - - OP_RSB_S_LSL_IMM, // 000 0011 1 1000 - OP_UND, // 000 0011 1 1001 - OP_RSB_S_LSR_IMM, // 000 0011 1 1010 - OP_UND, // 000 0011 1 1011 - OP_RSB_S_ASR_IMM, // 000 0011 1 1100 - OP_UND, // 000 0011 1 1101 - OP_RSB_S_ROR_IMM, // 000 0011 1 1110 - OP_UND, // 000 0011 1 1111 -//-------------------------- - OP_ADD_LSL_IMM, // 000 0100 0 0000 - OP_ADD_LSL_REG, // 000 0100 0 0001 - OP_ADD_LSR_IMM, // 000 0100 0 0010 - OP_ADD_LSR_REG, // 000 0100 0 0011 - OP_ADD_ASR_IMM, // 000 0100 0 0100 - OP_ADD_ASR_REG, // 000 0100 0 0101 - OP_ADD_ROR_IMM, // 000 0100 0 0110 - OP_ADD_ROR_REG, // 000 0100 0 0111 - - OP_ADD_LSL_IMM, // 000 0100 0 1000 - OP_UMULL, // 000 0100 0 1001 - OP_ADD_LSR_IMM, // OOO O10O O 1010 - OP_STRH_POS_INDE_P_REG_OFF, // 000 0100 0 1011 - OP_ADD_ASR_IMM, // 000 0100 0 1100 - OP_LDRD_STRD_POST_INDEX, - // 000 0100 0 1101 - OP_ADD_ROR_IMM, // 000 0100 0 1110 - OP_LDRD_STRD_POST_INDEX, - // 000 0100 0 1111 - - OP_ADD_S_LSL_IMM, // 000 0100 1 0000 - OP_ADD_S_LSL_REG, // 000 0100 1 0001 - OP_ADD_S_LSR_IMM, // 000 0100 1 0010 - OP_ADD_S_LSR_REG, // 000 0100 1 0011 - OP_ADD_S_ASR_IMM, // 000 0100 1 0100 - OP_ADD_S_ASR_REG, // 000 0100 1 0101 - OP_ADD_S_ROR_IMM, // 000 0100 1 0110 - OP_ADD_S_ROR_REG, // 000 0100 1 0111 - - OP_ADD_S_LSL_IMM, // 000 0100 1 1000 - OP_UMULL_S, // 000 0100 1 1001 - OP_ADD_S_LSR_IMM, // 000 0100 1 1010 - OP_LDRH_POS_INDE_P_REG_OFF, // 000 0100 1 1011 - OP_ADD_S_ASR_IMM, // 000 0100 1 1100 - OP_LDRSB_POS_INDE_P_REG_OFF,// 000 0100 1 1101 - OP_ADD_S_ROR_IMM, // 000 0100 1 1110 - OP_LDRSH_POS_INDE_P_REG_OFF,// 000 0100 1 1111 -//----------------------------------------- - OP_ADC_LSL_IMM, // 000 0101 0 0000 - OP_ADC_LSL_REG, // 000 0101 0 0001 - OP_ADC_LSR_IMM, // 000 0101 0 0010 - OP_ADC_LSR_REG, // 000 0101 0 0011 - OP_ADC_ASR_IMM, // 000 0101 0 0100 - OP_ADC_ASR_REG, // 000 0101 0 0101 - OP_ADC_ROR_IMM, // 000 0101 0 0110 - OP_ADC_ROR_REG, // 000 0101 0 0111 - - OP_ADC_LSL_IMM, // 000 0101 0 1000 - OP_UMLAL, // 000 0101 0 1001 - OP_ADC_LSR_IMM, // OOO O101 O 1010 - OP_UND, // 000 0101 0 1011 - OP_ADC_ASR_IMM, // 000 0101 0 1100 - OP_UND, // 000 0101 0 1101 - OP_ADC_ROR_IMM, // 000 0101 0 1110 - OP_UND, // 000 0101 0 1111 - - OP_ADC_S_LSL_IMM, // 000 0101 1 0000 - OP_ADC_S_LSL_REG, // 000 0101 1 0001 - OP_ADC_S_LSR_IMM, // 000 0101 1 0010 - OP_ADC_S_LSR_REG, // 000 0101 1 0011 - OP_ADC_S_ASR_IMM, // 000 0101 1 0100 - OP_ADC_S_ASR_REG, // 000 0101 1 0101 - OP_ADC_S_ROR_IMM, // 000 0101 1 0110 - OP_ADC_S_ROR_REG, // 000 0101 1 0111 - - OP_ADC_S_LSL_IMM, // 000 0101 1 1000 - OP_UMLAL_S, // 000 0101 1 1001 - OP_ADC_S_LSR_IMM, // 000 0101 1 1010 - OP_UND, // 000 0101 1 1011 - OP_ADC_S_ASR_IMM, // 000 0101 1 1100 - OP_UND, // 000 0101 1 1101 - OP_ADC_S_ROR_IMM, // 000 0101 1 1110 - OP_UND, // 000 0101 1 1111 -//------------------------------------------ - OP_SBC_LSL_IMM, // 000 0110 0 0000 - OP_SBC_LSL_REG, // 000 0110 0 0001 - OP_SBC_LSR_IMM, // 000 0110 0 0010 - OP_SBC_LSR_REG, // 000 0110 0 0011 - OP_SBC_ASR_IMM, // 000 0110 0 0100 - OP_SBC_ASR_REG, // 000 0110 0 0101 - OP_SBC_ROR_IMM, // 000 0110 0 0110 - OP_SBC_ROR_REG, // 000 0110 0 0111 - - OP_SBC_LSL_IMM, // 000 0110 0 1000 - OP_SMULL, // 000 0110 0 1001 - OP_SBC_LSR_IMM, // OOO O11O O 1010 - OP_STRH_POS_INDE_P_IMM_OFF, // 000 0110 0 1011 - OP_SBC_ASR_IMM, // 000 0110 0 1100 - OP_LDRD_STRD_POST_INDEX, - // 000 0110 0 1101 - OP_SBC_ROR_IMM, // 000 0110 0 1110 - OP_LDRD_STRD_POST_INDEX, - // 000 0110 0 1111 - - OP_SBC_S_LSL_IMM, // 000 0110 1 0000 - OP_SBC_S_LSL_REG, // 000 0110 1 0001 - OP_SBC_S_LSR_IMM, // 000 0110 1 0010 - OP_SBC_S_LSR_REG, // 000 0110 1 0011 - OP_SBC_S_ASR_IMM, // 000 0110 1 0100 - OP_SBC_S_ASR_REG, // 000 0110 1 0101 - OP_SBC_S_ROR_IMM, // 000 0110 1 0110 - OP_SBC_S_ROR_REG, // 000 0110 1 0111 - - OP_SBC_S_LSL_IMM, // 000 0110 1 1000 - OP_SMULL_S, // 000 0110 1 1001 - OP_SBC_S_LSR_IMM, // 000 0110 1 1010 - OP_LDRH_POS_INDE_P_IMM_OFF, // 000 0110 1 1011 - OP_SBC_S_ASR_IMM, // 000 0110 1 1100 - OP_LDRSB_POS_INDE_P_IMM_OFF,// 000 0110 1 1101 - OP_SBC_S_ROR_IMM, // 000 0110 1 1110 - OP_LDRSH_POS_INDE_P_IMM_OFF,// 000 0110 1 1111 -//------------------------------------------ - OP_RSC_LSL_IMM, // 000 0111 0 0000 - OP_RSC_LSL_REG, // 000 0111 0 0001 - OP_RSC_LSR_IMM, // 000 0111 0 0010 - OP_RSC_LSR_REG, // 000 0111 0 0011 - OP_RSC_ASR_IMM, // 000 0111 0 0100 - OP_RSC_ASR_REG, // 000 0111 0 0101 - OP_RSC_ROR_IMM, // 000 0111 0 0110 - OP_RSC_ROR_REG, // 000 0111 0 0111 - - OP_RSC_LSL_IMM, // 000 0111 0 1000 - OP_SMLAL, // 000 0111 0 1001 - OP_RSC_LSR_IMM, // OOO O111 O 1010 - OP_UND, // 000 0111 0 1011 - OP_RSC_ASR_IMM, // 000 0111 0 1100 - OP_UND, // 000 0111 0 1101 - OP_RSC_ROR_IMM, // 000 0111 0 1110 - OP_UND, // 000 0111 0 1111 - - OP_RSC_S_LSL_IMM, // 000 0111 1 0000 - OP_RSC_S_LSL_REG, // 000 0111 1 0001 - OP_RSC_S_LSR_IMM, // 000 0111 1 0010 - OP_RSC_S_LSR_REG, // 000 0111 1 0011 - OP_RSC_S_ASR_IMM, // 000 0111 1 0100 - OP_RSC_S_ASR_REG, // 000 0111 1 0101 - OP_RSC_S_ROR_IMM, // 000 0111 1 0110 - OP_RSC_S_ROR_REG, // 000 0111 1 0111 - - OP_RSC_S_LSL_IMM, // 000 0111 1 1000 - OP_SMLAL_S, // 000 0111 1 1001 - OP_RSC_S_LSR_IMM, // 000 0111 1 1010 - OP_UND, // 000 0111 1 1011 - OP_RSC_S_ASR_IMM, // 000 0111 1 1100 - OP_UND, // 000 0111 1 1101 - OP_RSC_S_ROR_IMM, // 000 0111 1 1110 - OP_UND, // 000 0111 1 1111 -//------------------------------------------ - OP_MRS_CPSR, // 000 1000 0 0000 - OP_UND, // 000 1000 0 0001 - OP_UND, // 000 1000 0 0010 - OP_UND, // 000 1000 0 0011 - OP_UND, // 000 1000 0 0100 - OP_QADD, // 000 1000 0 0101 - OP_UND, // 000 1000 0 0110 - OP_UND, // 000 1000 0 0111 - - OP_SMLA_B_B, // 000 1000 0 1000 - OP_SWP, // 000 1000 0 1001 - OP_SMLA_T_B, // 000 1000 0 1010 - OP_STRH_M_REG_OFF, // 000 1000 0 1011 - OP_SMLA_B_T, // 000 1000 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1000 0 1101 - OP_SMLA_T_T, // 000 1000 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1000 0 1111 - - OP_TST_LSL_IMM, // 000 1000 1 0000 - OP_TST_LSL_REG, // 000 1000 1 0001 - OP_TST_LSR_IMM, // 000 1000 1 0010 - OP_TST_LSR_REG, // 000 1000 1 0011 - OP_TST_ASR_IMM, // 000 1000 1 0100 - OP_TST_ASR_REG, // 000 1000 1 0101 - OP_TST_ROR_IMM, // 000 1000 1 0110 - OP_TST_ROR_REG, // 000 1000 1 0111 - - OP_TST_LSL_IMM, // 000 1000 1 1000 - OP_UND, // 000 1000 1 1001 - OP_TST_LSR_IMM, // OOO 100O 1 1010 - OP_LDRH_M_REG_OFF, // 000 1000 1 1011 - OP_TST_ASR_IMM, // 000 1000 1 1100 - OP_LDRSB_M_REG_OFF,// 000 1000 1 1101 - OP_TST_ROR_IMM, // 000 1000 1 1110 - OP_LDRSH_M_REG_OFF,// 000 1000 1 1111 -//------------------------------------------ - OP_MSR_CPSR, // 000 1001 0 0000 - OP_BX, // 000 1001 0 0001 - OP_UND, // 000 1001 0 0010 - OP_BLX_REG, // 000 1001 0 0011 - OP_UND, // 000 1001 0 0100 - OP_QSUB, // 000 1001 0 0101 - OP_UND, // 000 1001 0 0110 - OP_BKPT, // 000 1001 0 0111 - - OP_SMLAW_B, // 000 1001 0 1000 - OP_UND, // 000 1001 0 1001 - OP_SMULW_B, // 000 1001 0 1010 - OP_STRH_PRE_INDE_M_REG_OFF, // 000 1001 0 1011 - OP_SMLAW_T, // 000 1001 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1001 0 1101 - OP_SMULW_T, // 000 1001 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1001 0 1111 - - OP_TEQ_LSL_IMM, // 000 1001 1 0000 - OP_TEQ_LSL_REG, // 000 1001 1 0001 - OP_TEQ_LSR_IMM, // 000 1001 1 0010 - OP_TEQ_LSR_REG, // 000 1001 1 0011 - OP_TEQ_ASR_IMM, // 000 1001 1 0100 - OP_TEQ_ASR_REG, // 000 1001 1 0101 - OP_TEQ_ROR_IMM, // 000 1001 1 0110 - OP_TEQ_ROR_REG, // 000 1001 1 0111 - - OP_TEQ_LSL_IMM, // 000 1001 1 1000 - OP_UND, // 000 1001 1 1001 - OP_TEQ_LSR_IMM, // OOO 1001 1 1010 - OP_LDRH_PRE_INDE_M_REG_OFF, // 000 1001 1 1011 - OP_TEQ_ASR_IMM, // 000 1001 1 1100 - OP_LDRSB_PRE_INDE_M_REG_OFF, // 000 1001 1 1101 - OP_TEQ_ROR_IMM, // 000 1001 1 1110 - OP_LDRSH_PRE_INDE_M_REG_OFF, // 000 1001 1 1111 -//------------------------------------------ - OP_MRS_SPSR, // 000 1010 0 0000 - OP_UND, // 000 1010 0 0001 - OP_UND, // 000 1010 0 0010 - OP_UND, // 000 1010 0 0011 - OP_UND, // 000 1010 0 0100 - OP_QDADD, // 000 1010 0 0101 - OP_UND, // 000 1010 0 0110 - OP_UND, // 000 1010 0 0111 - - OP_SMLAL_B_B, // 000 1010 0 1000 - OP_SWPB, // 000 1010 0 1001 - OP_SMLAL_T_B, // 000 1010 0 1010 - OP_STRH_M_IMM_OFF, // 000 1010 0 1011 - OP_SMLAL_B_T, // 000 1010 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1010 0 1101 - OP_SMLAL_T_T, // 000 1010 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1010 0 1111 - - OP_CMP_LSL_IMM, // 000 1010 1 0000 - OP_CMP_LSL_REG, // 000 1010 1 0001 - OP_CMP_LSR_IMM, // 000 1010 1 0010 - OP_CMP_LSR_REG, // 000 1010 1 0011 - OP_CMP_ASR_IMM, // 000 1010 1 0100 - OP_CMP_ASR_REG, // 000 1010 1 0101 - OP_CMP_ROR_IMM, // 000 1010 1 0110 - OP_CMP_ROR_REG, // 000 1010 1 0111 - - OP_CMP_LSL_IMM, // 000 1010 1 1000 - OP_UND, // 000 1010 1 1001 - OP_CMP_LSR_IMM, // OOO 1O1O 1 1010 - OP_LDRH_M_IMM_OFF, // 000 1010 1 1011 - OP_CMP_ASR_IMM, // 000 1010 1 1100 - OP_LDRSB_M_IMM_OFF,// 000 1010 1 1101 - OP_CMP_ROR_IMM, // 000 1010 1 1110 - OP_LDRSH_M_IMM_OFF,// 000 1010 1 1111 -//------------------------------------------ - OP_MSR_SPSR, // 000 1011 0 0000 - OP_CLZ, // 000 1011 0 0001 - OP_UND, // 000 1011 0 0010 - OP_UND, // 000 1011 0 0011 - OP_UND, // 000 1011 0 0100 - OP_QDSUB, // 000 1011 0 0101 - OP_UND, // 000 1011 0 0110 - OP_UND, // 000 1011 0 0111 - - OP_SMUL_B_B, // 000 1011 0 1000 - OP_UND, // 000 1011 0 1001 - OP_SMUL_T_B, // 000 1011 0 1010 - OP_STRH_PRE_INDE_M_IMM_OFF, // 000 1011 0 1011 - OP_SMUL_B_T, // 000 1011 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1011 0 1101 - OP_SMUL_T_T, // 000 1011 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1011 0 1111 - - OP_CMN_LSL_IMM, // 000 1011 1 0000 - OP_CMN_LSL_REG, // 000 1011 1 0001 - OP_CMN_LSR_IMM, // 000 1011 1 0010 - OP_CMN_LSR_REG, // 000 1011 1 0011 - OP_CMN_ASR_IMM, // 000 1011 1 0100 - OP_CMN_ASR_REG, // 000 1011 1 0101 - OP_CMN_ROR_IMM, // 000 1011 1 0110 - OP_CMN_ROR_REG, // 000 1011 1 0111 - - OP_CMN_LSL_IMM, // 000 1011 1 1000 - OP_UND, // 000 1011 1 1001 - OP_CMN_LSR_IMM, // OOO 1O11 1 1010 - OP_LDRH_PRE_INDE_M_IMM_OFF, // 000 1011 1 1011 - OP_CMN_ASR_IMM, // 000 1011 1 1100 - OP_LDRSB_PRE_INDE_M_IMM_OFF, // 000 1011 1 1101 - OP_CMN_ROR_IMM, // 000 1011 1 1110 - OP_LDRSH_PRE_INDE_M_IMM_OFF, // 000 1011 1 1111 -//------------------------------------------ - OP_ORR_LSL_IMM, // 000 1100 0 0000 - OP_ORR_LSL_REG, // 000 1100 0 0001 - OP_ORR_LSR_IMM, // 000 1100 0 0010 - OP_ORR_LSR_REG, // 000 1100 0 0011 - OP_ORR_ASR_IMM, // 000 1100 0 0100 - OP_ORR_ASR_REG, // 000 1100 0 0101 - OP_ORR_ROR_IMM, // 000 1100 0 0110 - OP_ORR_ROR_REG, // 000 1100 0 0111 - - OP_ORR_LSL_IMM, // 000 1100 0 1000 - OP_UND, // 000 1100 0 1001 - OP_ORR_LSR_IMM, // OOO 110O O 1010 - OP_STRH_P_REG_OFF, // 000 1100 0 1011 - OP_ORR_ASR_IMM, // 000 1100 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1100 0 1101 - OP_ORR_ROR_IMM, // 000 1100 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1100 0 1111 - - OP_ORR_S_LSL_IMM, // 000 1100 1 0000 - OP_ORR_S_LSL_REG, // 000 1100 1 0001 - OP_ORR_S_LSR_IMM, // 000 1100 1 0010 - OP_ORR_S_LSR_REG, // 000 1100 1 0011 - OP_ORR_S_ASR_IMM, // 000 1100 1 0100 - OP_ORR_S_ASR_REG, // 000 1100 1 0101 - OP_ORR_S_ROR_IMM, // 000 1100 1 0110 - OP_ORR_S_ROR_REG, // 000 1100 1 0111 - - OP_ORR_S_LSL_IMM, // 000 1100 1 1000 - OP_UND, // 000 1100 1 1001 - OP_ORR_S_LSR_IMM, // 000 1100 1 1010 - OP_LDRH_P_REG_OFF, // 000 1100 1 1011 - OP_ORR_S_ASR_IMM, // 000 1100 1 1100 - OP_LDRSB_P_REG_OFF,// 000 1100 1 1101 - OP_ORR_S_ROR_IMM, // 000 1100 1 1110 - OP_LDRSH_P_REG_OFF,// 000 1100 1 1111 -//------------------------------------------ - OP_MOV_LSL_IMM, // 000 1101 0 0000 - OP_MOV_LSL_REG, // 000 1101 0 0001 - OP_MOV_LSR_IMM, // 000 1101 0 0010 - OP_MOV_LSR_REG, // 000 1101 0 0011 - OP_MOV_ASR_IMM, // 000 1101 0 0100 - OP_MOV_ASR_REG, // 000 1101 0 0101 - OP_MOV_ROR_IMM, // 000 1101 0 0110 - OP_MOV_ROR_REG, // 000 1101 0 0111 - - OP_MOV_LSL_IMM, // 000 1101 0 1000 - OP_UND, // 000 1101 0 1001 - OP_MOV_LSR_IMM, // OOO 1101 O 1010 - OP_STRH_PRE_INDE_P_REG_OFF, // 000 1101 0 1011 - OP_MOV_ASR_IMM, // 000 1101 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1101 0 1101 - OP_MOV_ROR_IMM, // 000 1101 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1101 0 1111 - - OP_MOV_S_LSL_IMM, // 000 1101 1 0000 - OP_MOV_S_LSL_REG, // 000 1101 1 0001 - OP_MOV_S_LSR_IMM, // 000 1101 1 0010 - OP_MOV_S_LSR_REG, // 000 1101 1 0011 - OP_MOV_S_ASR_IMM, // 000 1101 1 0100 - OP_MOV_S_ASR_REG, // 000 1101 1 0101 - OP_MOV_S_ROR_IMM, // 000 1101 1 0110 - OP_MOV_S_ROR_REG, // 000 1101 1 0111 - - OP_MOV_S_LSL_IMM, // 000 1101 1 1000 - OP_UND, // 000 1101 1 1001 - OP_MOV_S_LSR_IMM, // 000 1101 1 1010 - OP_LDRH_PRE_INDE_P_REG_OFF, // 000 1101 1 1011 - OP_MOV_S_ASR_IMM, // 000 1101 1 1100 - OP_LDRSB_PRE_INDE_P_REG_OFF,// 000 1101 1 1101 - OP_MOV_S_ROR_IMM, // 000 1101 1 1110 - OP_LDRSH_PRE_INDE_P_REG_OFF,// 000 1101 1 1111 -//------------------------------------------ - OP_BIC_LSL_IMM, // 000 1110 0 0000 - OP_BIC_LSL_REG, // 000 1110 0 0001 - OP_BIC_LSR_IMM, // 000 1110 0 0010 - OP_BIC_LSR_REG, // 000 1110 0 0011 - OP_BIC_ASR_IMM, // 000 1110 0 0100 - OP_BIC_ASR_REG, // 000 1110 0 0101 - OP_BIC_ROR_IMM, // 000 1110 0 0110 - OP_BIC_ROR_REG, // 000 1110 0 0111 - - OP_BIC_LSL_IMM, // 000 1110 0 1000 - OP_UND, // 000 1110 0 1001 - OP_BIC_LSR_IMM, // OOO 111O O 1010 - OP_STRH_P_IMM_OFF, // 000 1110 0 1011 - OP_BIC_ASR_IMM, // 000 1110 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1110 0 1101 - OP_BIC_ROR_IMM, // 000 1110 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1110 0 1111 - - OP_BIC_S_LSL_IMM, // 000 1110 1 0000 - OP_BIC_S_LSL_REG, // 000 1110 1 0001 - OP_BIC_S_LSR_IMM, // 000 1110 1 0010 - OP_BIC_S_LSR_REG, // 000 1110 1 0011 - OP_BIC_S_ASR_IMM, // 000 1110 1 0100 - OP_BIC_S_ASR_REG, // 000 1110 1 0101 - OP_BIC_S_ROR_IMM, // 000 1110 1 0110 - OP_BIC_S_ROR_REG, // 000 1110 1 0111 - - OP_BIC_S_LSL_IMM, // 000 1110 1 1000 - OP_UND, // 000 1110 1 1001 - OP_BIC_S_LSR_IMM, // 000 1110 1 1010 - OP_LDRH_P_IMM_OFF, // 000 1110 1 1011 - OP_BIC_S_ASR_IMM, // 000 1110 1 1100 - OP_LDRSB_P_IMM_OFF,// 000 1110 1 1101 - OP_BIC_S_ROR_IMM, // 000 1110 1 1110 - OP_LDRSH_P_IMM_OFF,// 000 1110 1 1111 -//------------------------------------------- - OP_MVN_LSL_IMM, // 000 1111 0 0000 - OP_MVN_LSL_REG, // 000 1111 0 0001 - OP_MVN_LSR_IMM, // 000 1111 0 0010 - OP_MVN_LSR_REG, // 000 1111 0 0011 - OP_MVN_ASR_IMM, // 000 1111 0 0100 - OP_MVN_ASR_REG, // 000 1111 0 0101 - OP_MVN_ROR_IMM, // 000 1111 0 0110 - OP_MVN_ROR_REG, // 000 1111 0 0111 - - OP_MVN_LSL_IMM, // 000 1111 0 1000 - OP_UND, // 000 1111 0 1001 - OP_MVN_LSR_IMM, // OOO 1111 O 1010 - OP_STRH_PRE_INDE_P_IMM_OFF, // 000 1111 0 1011 - OP_MVN_ASR_IMM, // 000 1111 0 1100 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1111 0 1101 - OP_MVN_ROR_IMM, // 000 1111 0 1110 - OP_LDRD_STRD_OFFSET_PRE_INDEX, - // 000 1111 0 1111 - - OP_MVN_S_LSL_IMM, // 000 1111 1 0000 - OP_MVN_S_LSL_REG, // 000 1111 1 0001 - OP_MVN_S_LSR_IMM, // 000 1111 1 0010 - OP_MVN_S_LSR_REG, // 000 1111 1 0011 - OP_MVN_S_ASR_IMM, // 000 1111 1 0100 - OP_MVN_S_ASR_REG, // 000 1111 1 0101 - OP_MVN_S_ROR_IMM, // 000 1111 1 0110 - OP_MVN_S_ROR_REG, // 000 1111 1 0111 - - OP_MVN_S_LSL_IMM, // 000 1111 1 1000 - OP_UND, // 000 1111 1 1001 - OP_MVN_S_LSR_IMM, // 000 1111 1 1010 - OP_LDRH_PRE_INDE_P_IMM_OFF, // 000 1111 1 1011 - OP_MVN_S_ASR_IMM, // 000 1111 1 1100 - OP_LDRSB_PRE_INDE_P_IMM_OFF,// 000 1111 1 1101 - OP_MVN_S_ROR_IMM, // 000 1111 1 1110 - OP_LDRSH_PRE_INDE_P_IMM_OFF,// 000 1111 1 1111 -//------------------------------------------- - OP_AND_IMM_VAL, // 001 0000 0 0000 - OP_AND_IMM_VAL, // 001 0000 0 0001 - OP_AND_IMM_VAL, // 001 0000 0 0010 - OP_AND_IMM_VAL, // 001 0000 0 0011 - OP_AND_IMM_VAL, // 001 0000 0 0100 - OP_AND_IMM_VAL, // 001 0000 0 0101 - OP_AND_IMM_VAL, // 001 0000 0 0110 - OP_AND_IMM_VAL, // 001 0000 0 0111 - OP_AND_IMM_VAL, // 001 0000 0 1000 - OP_AND_IMM_VAL, // 001 0000 0 1001 - OP_AND_IMM_VAL, // 001 0000 0 1010 - OP_AND_IMM_VAL, // 001 0000 0 1011 - OP_AND_IMM_VAL, // 001 0000 0 1100 - OP_AND_IMM_VAL, // 001 0000 0 1101 - OP_AND_IMM_VAL, // 001 0000 0 1110 - OP_AND_IMM_VAL, // 001 0000 0 1111 - - OP_AND_S_IMM_VAL, // 001 0000 1 0000 - OP_AND_S_IMM_VAL, // 001 0000 1 0001 - OP_AND_S_IMM_VAL, // 001 0000 1 0010 - OP_AND_S_IMM_VAL, // 001 0000 1 0011 - OP_AND_S_IMM_VAL, // 001 0000 1 0100 - OP_AND_S_IMM_VAL, // 001 0000 1 0101 - OP_AND_S_IMM_VAL, // 001 0000 1 0110 - OP_AND_S_IMM_VAL, // 001 0000 1 0111 - OP_AND_S_IMM_VAL, // 001 0000 1 1000 - OP_AND_S_IMM_VAL, // 001 0000 1 1001 - OP_AND_S_IMM_VAL, // 001 0000 1 1010 - OP_AND_S_IMM_VAL, // 001 0000 1 1011 - OP_AND_S_IMM_VAL, // 001 0000 1 1100 - OP_AND_S_IMM_VAL, // 001 0000 1 1101 - OP_AND_S_IMM_VAL, // 001 0000 1 1110 - OP_AND_S_IMM_VAL, // 001 0000 1 1111 -//------------------------------------------ - OP_EOR_IMM_VAL, // 001 0001 0 0000 - OP_EOR_IMM_VAL, // 001 0001 0 0001 - OP_EOR_IMM_VAL, // 001 0001 0 0010 - OP_EOR_IMM_VAL, // 001 0001 0 0011 - OP_EOR_IMM_VAL, // 001 0001 0 0100 - OP_EOR_IMM_VAL, // 001 0001 0 0101 - OP_EOR_IMM_VAL, // 001 0001 0 0110 - OP_EOR_IMM_VAL, // 001 0001 0 0111 - OP_EOR_IMM_VAL, // 001 0001 0 1000 - OP_EOR_IMM_VAL, // 001 0001 0 1001 - OP_EOR_IMM_VAL, // 001 0001 0 1010 - OP_EOR_IMM_VAL, // 001 0001 0 1011 - OP_EOR_IMM_VAL, // 001 0001 0 1100 - OP_EOR_IMM_VAL, // 001 0001 0 1101 - OP_EOR_IMM_VAL, // 001 0001 0 1110 - OP_EOR_IMM_VAL, // 001 0001 0 1111 - - OP_EOR_S_IMM_VAL, // 001 0001 1 0000 - OP_EOR_S_IMM_VAL, // 001 0001 1 0001 - OP_EOR_S_IMM_VAL, // 001 0001 1 0010 - OP_EOR_S_IMM_VAL, // 001 0001 1 0011 - OP_EOR_S_IMM_VAL, // 001 0001 1 0100 - OP_EOR_S_IMM_VAL, // 001 0001 1 0101 - OP_EOR_S_IMM_VAL, // 001 0001 1 0110 - OP_EOR_S_IMM_VAL, // 001 0001 1 0111 - OP_EOR_S_IMM_VAL, // 001 0001 1 1000 - OP_EOR_S_IMM_VAL, // 001 0001 1 1001 - OP_EOR_S_IMM_VAL, // 001 0001 1 1010 - OP_EOR_S_IMM_VAL, // 001 0001 1 1011 - OP_EOR_S_IMM_VAL, // 001 0001 1 1100 - OP_EOR_S_IMM_VAL, // 001 0001 1 1101 - OP_EOR_S_IMM_VAL, // 001 0001 1 1110 - OP_EOR_S_IMM_VAL, // 001 0001 1 1111 -//------------------------------------------ - OP_SUB_IMM_VAL, // 001 0010 0 0000 - OP_SUB_IMM_VAL, // 001 0010 0 0001 - OP_SUB_IMM_VAL, // 001 0010 0 0010 - OP_SUB_IMM_VAL, // 001 0010 0 0011 - OP_SUB_IMM_VAL, // 001 0010 0 0100 - OP_SUB_IMM_VAL, // 001 0010 0 0101 - OP_SUB_IMM_VAL, // 001 0010 0 0110 - OP_SUB_IMM_VAL, // 001 0010 0 0111 - OP_SUB_IMM_VAL, // 001 0010 0 1000 - OP_SUB_IMM_VAL, // 001 0010 0 1001 - OP_SUB_IMM_VAL, // 001 0010 0 1010 - OP_SUB_IMM_VAL, // 001 0010 0 1011 - OP_SUB_IMM_VAL, // 001 0010 0 1100 - OP_SUB_IMM_VAL, // 001 0010 0 1101 - OP_SUB_IMM_VAL, // 001 0010 0 1110 - OP_SUB_IMM_VAL, // 001 0010 0 1111 - - OP_SUB_S_IMM_VAL, // 001 0010 1 0000 - OP_SUB_S_IMM_VAL, // 001 0010 1 0001 - OP_SUB_S_IMM_VAL, // 001 0010 1 0010 - OP_SUB_S_IMM_VAL, // 001 0010 1 0011 - OP_SUB_S_IMM_VAL, // 001 0010 1 0100 - OP_SUB_S_IMM_VAL, // 001 0010 1 0101 - OP_SUB_S_IMM_VAL, // 001 0010 1 0110 - OP_SUB_S_IMM_VAL, // 001 0010 1 0111 - OP_SUB_S_IMM_VAL, // 001 0010 1 1000 - OP_SUB_S_IMM_VAL, // 001 0010 1 1001 - OP_SUB_S_IMM_VAL, // 001 0010 1 1010 - OP_SUB_S_IMM_VAL, // 001 0010 1 1011 - OP_SUB_S_IMM_VAL, // 001 0010 1 1100 - OP_SUB_S_IMM_VAL, // 001 0010 1 1101 - OP_SUB_S_IMM_VAL, // 001 0010 1 1110 - OP_SUB_S_IMM_VAL, // 001 0010 1 1111 -//------------------------------------------ - OP_RSB_IMM_VAL, // 001 0011 0 0000 - OP_RSB_IMM_VAL, // 001 0011 0 0001 - OP_RSB_IMM_VAL, // 001 0011 0 0010 - OP_RSB_IMM_VAL, // 001 0011 0 0011 - OP_RSB_IMM_VAL, // 001 0011 0 0100 - OP_RSB_IMM_VAL, // 001 0011 0 0101 - OP_RSB_IMM_VAL, // 001 0011 0 0110 - OP_RSB_IMM_VAL, // 001 0011 0 0111 - OP_RSB_IMM_VAL, // 001 0011 0 1000 - OP_RSB_IMM_VAL, // 001 0011 0 1001 - OP_RSB_IMM_VAL, // 001 0011 0 1010 - OP_RSB_IMM_VAL, // 001 0011 0 1011 - OP_RSB_IMM_VAL, // 001 0011 0 1100 - OP_RSB_IMM_VAL, // 001 0011 0 1101 - OP_RSB_IMM_VAL, // 001 0011 0 1110 - OP_RSB_IMM_VAL, // 001 0011 0 1111 - - OP_RSB_S_IMM_VAL, // 001 0011 1 0000 - OP_RSB_S_IMM_VAL, // 001 0011 1 0001 - OP_RSB_S_IMM_VAL, // 001 0011 1 0010 - OP_RSB_S_IMM_VAL, // 001 0011 1 0011 - OP_RSB_S_IMM_VAL, // 001 0011 1 0100 - OP_RSB_S_IMM_VAL, // 001 0011 1 0101 - OP_RSB_S_IMM_VAL, // 001 0011 1 0110 - OP_RSB_S_IMM_VAL, // 001 0011 1 0111 - OP_RSB_S_IMM_VAL, // 001 0011 1 1000 - OP_RSB_S_IMM_VAL, // 001 0011 1 1001 - OP_RSB_S_IMM_VAL, // 001 0011 1 1010 - OP_RSB_S_IMM_VAL, // 001 0011 1 1011 - OP_RSB_S_IMM_VAL, // 001 0011 1 1100 - OP_RSB_S_IMM_VAL, // 001 0011 1 1101 - OP_RSB_S_IMM_VAL, // 001 0011 1 1110 - OP_RSB_S_IMM_VAL, // 001 0011 1 1111 -//------------------------------------------ - OP_ADD_IMM_VAL, // 001 0100 0 0000 - OP_ADD_IMM_VAL, // 001 0100 0 0001 - OP_ADD_IMM_VAL, // 001 0100 0 0010 - OP_ADD_IMM_VAL, // 001 0100 0 0011 - OP_ADD_IMM_VAL, // 001 0100 0 0100 - OP_ADD_IMM_VAL, // 001 0100 0 0101 - OP_ADD_IMM_VAL, // 001 0100 0 0110 - OP_ADD_IMM_VAL, // 001 0100 0 0111 - OP_ADD_IMM_VAL, // 001 0100 0 1000 - OP_ADD_IMM_VAL, // 001 0100 0 1001 - OP_ADD_IMM_VAL, // 001 0100 0 1010 - OP_ADD_IMM_VAL, // 001 0100 0 1011 - OP_ADD_IMM_VAL, // 001 0100 0 1100 - OP_ADD_IMM_VAL, // 001 0100 0 1101 - OP_ADD_IMM_VAL, // 001 0100 0 1110 - OP_ADD_IMM_VAL, // 001 0100 0 1111 - - OP_ADD_S_IMM_VAL, // 001 0100 1 0000 - OP_ADD_S_IMM_VAL, // 001 0100 1 0001 - OP_ADD_S_IMM_VAL, // 001 0100 1 0010 - OP_ADD_S_IMM_VAL, // 001 0100 1 0011 - OP_ADD_S_IMM_VAL, // 001 0100 1 0100 - OP_ADD_S_IMM_VAL, // 001 0100 1 0101 - OP_ADD_S_IMM_VAL, // 001 0100 1 0110 - OP_ADD_S_IMM_VAL, // 001 0100 1 0111 - OP_ADD_S_IMM_VAL, // 001 0100 1 1000 - OP_ADD_S_IMM_VAL, // 001 0100 1 1001 - OP_ADD_S_IMM_VAL, // 001 0100 1 1010 - OP_ADD_S_IMM_VAL, // 001 0100 1 1011 - OP_ADD_S_IMM_VAL, // 001 0100 1 1100 - OP_ADD_S_IMM_VAL, // 001 0100 1 1101 - OP_ADD_S_IMM_VAL, // 001 0100 1 1110 - OP_ADD_S_IMM_VAL, // 001 0100 1 1111 -//------------------------------------------ - OP_ADC_IMM_VAL, // 001 0101 0 0000 - OP_ADC_IMM_VAL, // 001 0101 0 0001 - OP_ADC_IMM_VAL, // 001 0101 0 0010 - OP_ADC_IMM_VAL, // 001 0101 0 0011 - OP_ADC_IMM_VAL, // 001 0101 0 0100 - OP_ADC_IMM_VAL, // 001 0101 0 0101 - OP_ADC_IMM_VAL, // 001 0101 0 0110 - OP_ADC_IMM_VAL, // 001 0101 0 0111 - OP_ADC_IMM_VAL, // 001 0101 0 1000 - OP_ADC_IMM_VAL, // 001 0101 0 1001 - OP_ADC_IMM_VAL, // 001 0101 0 1010 - OP_ADC_IMM_VAL, // 001 0101 0 1011 - OP_ADC_IMM_VAL, // 001 0101 0 1100 - OP_ADC_IMM_VAL, // 001 0101 0 1101 - OP_ADC_IMM_VAL, // 001 0101 0 1110 - OP_ADC_IMM_VAL, // 001 0101 0 1111 - - OP_ADC_S_IMM_VAL, // 001 0101 1 0000 - OP_ADC_S_IMM_VAL, // 001 0101 1 0001 - OP_ADC_S_IMM_VAL, // 001 0101 1 0010 - OP_ADC_S_IMM_VAL, // 001 0101 1 0011 - OP_ADC_S_IMM_VAL, // 001 0101 1 0100 - OP_ADC_S_IMM_VAL, // 001 0101 1 0101 - OP_ADC_S_IMM_VAL, // 001 0101 1 0110 - OP_ADC_S_IMM_VAL, // 001 0101 1 0111 - OP_ADC_S_IMM_VAL, // 001 0101 1 1000 - OP_ADC_S_IMM_VAL, // 001 0101 1 1001 - OP_ADC_S_IMM_VAL, // 001 0101 1 1010 - OP_ADC_S_IMM_VAL, // 001 0101 1 1011 - OP_ADC_S_IMM_VAL, // 001 0101 1 1100 - OP_ADC_S_IMM_VAL, // 001 0101 1 1101 - OP_ADC_S_IMM_VAL, // 001 0101 1 1110 - OP_ADC_S_IMM_VAL, // 001 0101 1 1111 -//------------------------------------------ - OP_SBC_IMM_VAL, // 001 0110 0 0000 - OP_SBC_IMM_VAL, // 001 0110 0 0001 - OP_SBC_IMM_VAL, // 001 0110 0 0010 - OP_SBC_IMM_VAL, // 001 0110 0 0011 - OP_SBC_IMM_VAL, // 001 0110 0 0100 - OP_SBC_IMM_VAL, // 001 0110 0 0101 - OP_SBC_IMM_VAL, // 001 0110 0 0110 - OP_SBC_IMM_VAL, // 001 0110 0 0111 - OP_SBC_IMM_VAL, // 001 0110 0 1000 - OP_SBC_IMM_VAL, // 001 0110 0 1001 - OP_SBC_IMM_VAL, // 001 0110 0 1010 - OP_SBC_IMM_VAL, // 001 0110 0 1011 - OP_SBC_IMM_VAL, // 001 0110 0 1100 - OP_SBC_IMM_VAL, // 001 0110 0 1101 - OP_SBC_IMM_VAL, // 001 0110 0 1110 - OP_SBC_IMM_VAL, // 001 0110 0 1111 - - OP_SBC_S_IMM_VAL, // 001 0110 1 0000 - OP_SBC_S_IMM_VAL, // 001 0110 1 0001 - OP_SBC_S_IMM_VAL, // 001 0110 1 0010 - OP_SBC_S_IMM_VAL, // 001 0110 1 0011 - OP_SBC_S_IMM_VAL, // 001 0110 1 0100 - OP_SBC_S_IMM_VAL, // 001 0110 1 0101 - OP_SBC_S_IMM_VAL, // 001 0110 1 0110 - OP_SBC_S_IMM_VAL, // 001 0110 1 0111 - OP_SBC_S_IMM_VAL, // 001 0110 1 1000 - OP_SBC_S_IMM_VAL, // 001 0110 1 1001 - OP_SBC_S_IMM_VAL, // 001 0110 1 1010 - OP_SBC_S_IMM_VAL, // 001 0110 1 1011 - OP_SBC_S_IMM_VAL, // 001 0110 1 1100 - OP_SBC_S_IMM_VAL, // 001 0110 1 1101 - OP_SBC_S_IMM_VAL, // 001 0110 1 1110 - OP_SBC_S_IMM_VAL, // 001 0110 1 1111 -//------------------------------------------ - OP_RSC_IMM_VAL, // 001 0111 0 0000 - OP_RSC_IMM_VAL, // 001 0111 0 0001 - OP_RSC_IMM_VAL, // 001 0111 0 0010 - OP_RSC_IMM_VAL, // 001 0111 0 0011 - OP_RSC_IMM_VAL, // 001 0111 0 0100 - OP_RSC_IMM_VAL, // 001 0111 0 0101 - OP_RSC_IMM_VAL, // 001 0111 0 0110 - OP_RSC_IMM_VAL, // 001 0111 0 0111 - OP_RSC_IMM_VAL, // 001 0111 0 1000 - OP_RSC_IMM_VAL, // 001 0111 0 1001 - OP_RSC_IMM_VAL, // 001 0111 0 1010 - OP_RSC_IMM_VAL, // 001 0111 0 1011 - OP_RSC_IMM_VAL, // 001 0111 0 1100 - OP_RSC_IMM_VAL, // 001 0111 0 1101 - OP_RSC_IMM_VAL, // 001 0111 0 1110 - OP_RSC_IMM_VAL, // 001 0111 0 1111 - - OP_RSC_S_IMM_VAL, // 001 0111 1 0000 - OP_RSC_S_IMM_VAL, // 001 0111 1 0001 - OP_RSC_S_IMM_VAL, // 001 0111 1 0010 - OP_RSC_S_IMM_VAL, // 001 0111 1 0011 - OP_RSC_S_IMM_VAL, // 001 0111 1 0100 - OP_RSC_S_IMM_VAL, // 001 0111 1 0101 - OP_RSC_S_IMM_VAL, // 001 0111 1 0110 - OP_RSC_S_IMM_VAL, // 001 0111 1 0111 - OP_RSC_S_IMM_VAL, // 001 0111 1 1000 - OP_RSC_S_IMM_VAL, // 001 0111 1 1001 - OP_RSC_S_IMM_VAL, // 001 0111 1 1010 - OP_RSC_S_IMM_VAL, // 001 0111 1 1011 - OP_RSC_S_IMM_VAL, // 001 0111 1 1100 - OP_RSC_S_IMM_VAL, // 001 0111 1 1101 - OP_RSC_S_IMM_VAL, // 001 0111 1 1110 - OP_RSC_S_IMM_VAL, // 001 0111 1 1111 -//------------------------------------------ - OP_UND, // 001 1000 0 0000 - OP_UND, // 001 1000 0 0001 - OP_UND, // 001 1000 0 0010 - OP_UND, // 001 1000 0 0011 - OP_UND, // 001 1000 0 0100 - OP_UND, // 001 1000 0 0101 - OP_UND, // 001 1000 0 0110 - OP_UND, // 001 1000 0 0111 - OP_UND, // 001 1000 0 1000 - OP_UND, // 001 1000 0 1001 - OP_UND, // 001 1000 0 1010 - OP_UND, // 001 1000 0 1011 - OP_UND, // 001 1000 0 1100 - OP_UND, // 001 1000 0 1101 - OP_UND, // 001 1000 0 1110 - OP_UND, // 001 1000 0 1111 - - OP_TST_IMM_VAL, // 001 1000 1 0000 - OP_TST_IMM_VAL, // 001 1000 1 0001 - OP_TST_IMM_VAL, // 001 1000 1 0010 - OP_TST_IMM_VAL, // 001 1000 1 0011 - OP_TST_IMM_VAL, // 001 1000 1 0100 - OP_TST_IMM_VAL, // 001 1000 1 0101 - OP_TST_IMM_VAL, // 001 1000 1 0110 - OP_TST_IMM_VAL, // 001 1000 1 0111 - OP_TST_IMM_VAL, // 001 1000 1 1000 - OP_TST_IMM_VAL, // 001 1000 1 1001 - OP_TST_IMM_VAL, // 001 1000 1 1010 - OP_TST_IMM_VAL, // 001 1000 1 1011 - OP_TST_IMM_VAL, // 001 1000 1 1100 - OP_TST_IMM_VAL, // 001 1000 1 1101 - OP_TST_IMM_VAL, // 001 1000 1 1110 - OP_TST_IMM_VAL, // 001 1000 1 1111 -//------------------------------------------ - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0000 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0001 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0010 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0011 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0100 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0101 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0110 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0111 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1000 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1001 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1010 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1011 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1100 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1101 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1110 - OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1111 - - OP_TEQ_IMM_VAL, // 001 1001 1 0000 - OP_TEQ_IMM_VAL, // 001 1001 1 0001 - OP_TEQ_IMM_VAL, // 001 1001 1 0010 - OP_TEQ_IMM_VAL, // 001 1001 1 0011 - OP_TEQ_IMM_VAL, // 001 1001 1 0100 - OP_TEQ_IMM_VAL, // 001 1001 1 0101 - OP_TEQ_IMM_VAL, // 001 1001 1 0110 - OP_TEQ_IMM_VAL, // 001 1001 1 0111 - OP_TEQ_IMM_VAL, // 001 1001 1 1000 - OP_TEQ_IMM_VAL, // 001 1001 1 1001 - OP_TEQ_IMM_VAL, // 001 1001 1 1010 - OP_TEQ_IMM_VAL, // 001 1001 1 1011 - OP_TEQ_IMM_VAL, // 001 1001 1 1100 - OP_TEQ_IMM_VAL, // 001 1001 1 1101 - OP_TEQ_IMM_VAL, // 001 1001 1 1110 - OP_TEQ_IMM_VAL, // 001 1001 1 1111 -//------------------------------------------ - OP_UND, // 001 1010 0 0000 - OP_UND, // 001 1010 0 0001 - OP_UND, // 001 1010 0 0010 - OP_UND, // 001 1010 0 0011 - OP_UND, // 001 1010 0 0100 - OP_UND, // 001 1010 0 0101 - OP_UND, // 001 1010 0 0110 - OP_UND, // 001 1010 0 0111 - OP_UND, // 001 1010 0 1000 - OP_UND, // 001 1010 0 1001 - OP_UND, // 001 1010 0 1010 - OP_UND, // 001 1010 0 1011 - OP_UND, // 001 1010 0 1100 - OP_UND, // 001 1010 0 1101 - OP_UND, // 001 1010 0 1110 - OP_UND, // 001 1010 0 1111 - - OP_CMP_IMM_VAL, // 001 1010 1 0000 - OP_CMP_IMM_VAL, // 001 1010 1 0001 - OP_CMP_IMM_VAL, // 001 1010 1 0010 - OP_CMP_IMM_VAL, // 001 1010 1 0011 - OP_CMP_IMM_VAL, // 001 1010 1 0100 - OP_CMP_IMM_VAL, // 001 1010 1 0101 - OP_CMP_IMM_VAL, // 001 1010 1 0110 - OP_CMP_IMM_VAL, // 001 1010 1 0111 - OP_CMP_IMM_VAL, // 001 1010 1 1000 - OP_CMP_IMM_VAL, // 001 1010 1 1001 - OP_CMP_IMM_VAL, // 001 1010 1 1010 - OP_CMP_IMM_VAL, // 001 1010 1 1011 - OP_CMP_IMM_VAL, // 001 1010 1 1100 - OP_CMP_IMM_VAL, // 001 1010 1 1101 - OP_CMP_IMM_VAL, // 001 1010 1 1110 - OP_CMP_IMM_VAL, // 001 1010 1 1111 -//------------------------------------------ - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0000 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0001 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0010 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0011 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0100 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0101 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0110 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0111 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1000 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1001 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1010 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1011 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1100 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1101 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1110 - OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1111 - - OP_CMN_IMM_VAL, // 001 1011 1 0000 - OP_CMN_IMM_VAL, // 001 1011 1 0001 - OP_CMN_IMM_VAL, // 001 1011 1 0010 - OP_CMN_IMM_VAL, // 001 1011 1 0011 - OP_CMN_IMM_VAL, // 001 1011 1 0100 - OP_CMN_IMM_VAL, // 001 1011 1 0101 - OP_CMN_IMM_VAL, // 001 1011 1 0110 - OP_CMN_IMM_VAL, // 001 1011 1 0111 - OP_CMN_IMM_VAL, // 001 1011 1 1000 - OP_CMN_IMM_VAL, // 001 1011 1 1001 - OP_CMN_IMM_VAL, // 001 1011 1 1010 - OP_CMN_IMM_VAL, // 001 1011 1 1011 - OP_CMN_IMM_VAL, // 001 1011 1 1100 - OP_CMN_IMM_VAL, // 001 1011 1 1101 - OP_CMN_IMM_VAL, // 001 1011 1 1110 - OP_CMN_IMM_VAL, // 001 1011 1 1111 -//------------------------------------------ - OP_ORR_IMM_VAL, // 001 1100 0 0000 - OP_ORR_IMM_VAL, // 001 1100 0 0001 - OP_ORR_IMM_VAL, // 001 1100 0 0010 - OP_ORR_IMM_VAL, // 001 1100 0 0011 - OP_ORR_IMM_VAL, // 001 1100 0 0100 - OP_ORR_IMM_VAL, // 001 1100 0 0101 - OP_ORR_IMM_VAL, // 001 1100 0 0110 - OP_ORR_IMM_VAL, // 001 1100 0 0111 - OP_ORR_IMM_VAL, // 001 1100 0 1000 - OP_ORR_IMM_VAL, // 001 1100 0 1001 - OP_ORR_IMM_VAL, // 001 1100 0 1010 - OP_ORR_IMM_VAL, // 001 1100 0 1011 - OP_ORR_IMM_VAL, // 001 1100 0 1100 - OP_ORR_IMM_VAL, // 001 1100 0 1101 - OP_ORR_IMM_VAL, // 001 1100 0 1110 - OP_ORR_IMM_VAL, // 001 1100 0 1111 - - OP_ORR_S_IMM_VAL, // 001 1100 1 0000 - OP_ORR_S_IMM_VAL, // 001 1100 1 0001 - OP_ORR_S_IMM_VAL, // 001 1100 1 0010 - OP_ORR_S_IMM_VAL, // 001 1100 1 0011 - OP_ORR_S_IMM_VAL, // 001 1100 1 0100 - OP_ORR_S_IMM_VAL, // 001 1100 1 0101 - OP_ORR_S_IMM_VAL, // 001 1100 1 0110 - OP_ORR_S_IMM_VAL, // 001 1100 1 0111 - OP_ORR_S_IMM_VAL, // 001 1100 1 1000 - OP_ORR_S_IMM_VAL, // 001 1100 1 1001 - OP_ORR_S_IMM_VAL, // 001 1100 1 1010 - OP_ORR_S_IMM_VAL, // 001 1100 1 1011 - OP_ORR_S_IMM_VAL, // 001 1100 1 1100 - OP_ORR_S_IMM_VAL, // 001 1100 1 1101 - OP_ORR_S_IMM_VAL, // 001 1100 1 1110 - OP_ORR_S_IMM_VAL, // 001 1100 1 1111 -//------------------------------------------ - OP_MOV_IMM_VAL, // 001 1101 0 0000 - OP_MOV_IMM_VAL, // 001 1101 0 0001 - OP_MOV_IMM_VAL, // 001 1101 0 0010 - OP_MOV_IMM_VAL, // 001 1101 0 0011 - OP_MOV_IMM_VAL, // 001 1101 0 0100 - OP_MOV_IMM_VAL, // 001 1101 0 0101 - OP_MOV_IMM_VAL, // 001 1101 0 0110 - OP_MOV_IMM_VAL, // 001 1101 0 0111 - OP_MOV_IMM_VAL, // 001 1101 0 1000 - OP_MOV_IMM_VAL, // 001 1101 0 1001 - OP_MOV_IMM_VAL, // 001 1101 0 1010 - OP_MOV_IMM_VAL, // 001 1101 0 1011 - OP_MOV_IMM_VAL, // 001 1101 0 1100 - OP_MOV_IMM_VAL, // 001 1101 0 1101 - OP_MOV_IMM_VAL, // 001 1101 0 1110 - OP_MOV_IMM_VAL, // 001 1101 0 1111 - - OP_MOV_S_IMM_VAL, // 001 1101 1 0000 - OP_MOV_S_IMM_VAL, // 001 1101 1 0001 - OP_MOV_S_IMM_VAL, // 001 1101 1 0010 - OP_MOV_S_IMM_VAL, // 001 1101 1 0011 - OP_MOV_S_IMM_VAL, // 001 1101 1 0100 - OP_MOV_S_IMM_VAL, // 001 1101 1 0101 - OP_MOV_S_IMM_VAL, // 001 1101 1 0110 - OP_MOV_S_IMM_VAL, // 001 1101 1 0111 - OP_MOV_S_IMM_VAL, // 001 1101 1 1000 - OP_MOV_S_IMM_VAL, // 001 1101 1 1001 - OP_MOV_S_IMM_VAL, // 001 1101 1 1010 - OP_MOV_S_IMM_VAL, // 001 1101 1 1011 - OP_MOV_S_IMM_VAL, // 001 1101 1 1100 - OP_MOV_S_IMM_VAL, // 001 1101 1 1101 - OP_MOV_S_IMM_VAL, // 001 1101 1 1110 - OP_MOV_S_IMM_VAL, // 001 1101 1 1111 -//------------------------------------------ - OP_BIC_IMM_VAL, // 001 1110 0 0000 - OP_BIC_IMM_VAL, // 001 1110 0 0001 - OP_BIC_IMM_VAL, // 001 1110 0 0010 - OP_BIC_IMM_VAL, // 001 1110 0 0011 - OP_BIC_IMM_VAL, // 001 1110 0 0100 - OP_BIC_IMM_VAL, // 001 1110 0 0101 - OP_BIC_IMM_VAL, // 001 1110 0 0110 - OP_BIC_IMM_VAL, // 001 1110 0 0111 - OP_BIC_IMM_VAL, // 001 1110 0 1000 - OP_BIC_IMM_VAL, // 001 1110 0 1001 - OP_BIC_IMM_VAL, // 001 1110 0 1010 - OP_BIC_IMM_VAL, // 001 1110 0 1011 - OP_BIC_IMM_VAL, // 001 1110 0 1100 - OP_BIC_IMM_VAL, // 001 1110 0 1101 - OP_BIC_IMM_VAL, // 001 1110 0 1110 - OP_BIC_IMM_VAL, // 001 1110 0 1111 - - OP_BIC_S_IMM_VAL, // 001 1110 1 0000 - OP_BIC_S_IMM_VAL, // 001 1110 1 0001 - OP_BIC_S_IMM_VAL, // 001 1110 1 0010 - OP_BIC_S_IMM_VAL, // 001 1110 1 0011 - OP_BIC_S_IMM_VAL, // 001 1110 1 0100 - OP_BIC_S_IMM_VAL, // 001 1110 1 0101 - OP_BIC_S_IMM_VAL, // 001 1110 1 0110 - OP_BIC_S_IMM_VAL, // 001 1110 1 0111 - OP_BIC_S_IMM_VAL, // 001 1110 1 1000 - OP_BIC_S_IMM_VAL, // 001 1110 1 1001 - OP_BIC_S_IMM_VAL, // 001 1110 1 1010 - OP_BIC_S_IMM_VAL, // 001 1110 1 1011 - OP_BIC_S_IMM_VAL, // 001 1110 1 1100 - OP_BIC_S_IMM_VAL, // 001 1110 1 1101 - OP_BIC_S_IMM_VAL, // 001 1110 1 1110 - OP_BIC_S_IMM_VAL, // 001 1110 1 1111 -//------------------------------------------ - OP_MVN_IMM_VAL, // 001 1111 0 0000 - OP_MVN_IMM_VAL, // 001 1111 0 0001 - OP_MVN_IMM_VAL, // 001 1111 0 0010 - OP_MVN_IMM_VAL, // 001 1111 0 0011 - OP_MVN_IMM_VAL, // 001 1111 0 0100 - OP_MVN_IMM_VAL, // 001 1111 0 0101 - OP_MVN_IMM_VAL, // 001 1111 0 0110 - OP_MVN_IMM_VAL, // 001 1111 0 0111 - OP_MVN_IMM_VAL, // 001 1111 0 1000 - OP_MVN_IMM_VAL, // 001 1111 0 1001 - OP_MVN_IMM_VAL, // 001 1111 0 1010 - OP_MVN_IMM_VAL, // 001 1111 0 1011 - OP_MVN_IMM_VAL, // 001 1111 0 1100 - OP_MVN_IMM_VAL, // 001 1111 0 1101 - OP_MVN_IMM_VAL, // 001 1111 0 1110 - OP_MVN_IMM_VAL, // 001 1111 0 1111 - - OP_MVN_S_IMM_VAL, // 001 1111 1 0000 - OP_MVN_S_IMM_VAL, // 001 1111 1 0001 - OP_MVN_S_IMM_VAL, // 001 1111 1 0010 - OP_MVN_S_IMM_VAL, // 001 1111 1 0011 - OP_MVN_S_IMM_VAL, // 001 1111 1 0100 - OP_MVN_S_IMM_VAL, // 001 1111 1 0101 - OP_MVN_S_IMM_VAL, // 001 1111 1 0110 - OP_MVN_S_IMM_VAL, // 001 1111 1 0111 - OP_MVN_S_IMM_VAL, // 001 1111 1 1000 - OP_MVN_S_IMM_VAL, // 001 1111 1 1001 - OP_MVN_S_IMM_VAL, // 001 1111 1 1010 - OP_MVN_S_IMM_VAL, // 001 1111 1 1011 - OP_MVN_S_IMM_VAL, // 001 1111 1 1100 - OP_MVN_S_IMM_VAL, // 001 1111 1 1101 - OP_MVN_S_IMM_VAL, // 001 1111 1 1110 - OP_MVN_S_IMM_VAL, // 001 1111 1 1111 -//------------------------------------------ - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0000 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0001 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0010 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0011 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0100 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0101 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0110 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0111 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1000 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1001 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1010 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1011 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1100 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1101 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1110 - OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1111 - - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0000 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0001 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0010 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0011 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0100 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0101 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0110 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0111 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1000 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1001 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1010 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1011 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1100 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1101 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1110 - OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1111 -//------------------------------------------ - OP_UND, //010 0001 0 0000 - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, -//------------------------------------------ - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0000 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0001 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0010 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0011 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0100 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0101 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0110 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0111 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1000 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1001 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1010 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1011 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1100 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1101 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1110 - OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1111 - - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0000 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0001 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0010 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0011 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0100 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0101 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0110 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0111 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1000 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1001 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1010 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1011 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1100 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1101 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1110 - OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1111 -//------------------------------------------ - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 - OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 -//------------------------------------------ - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 -//------------------------------------------ - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 - - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 - OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 -//------------------------------------------ - OP_STRB_P_IMM_OFF_POSTIND, //010 0110 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRB_P_IMM_OFF_POSTIND, //010 0110 1 1111 -//------------------------------------------ - OP_STRBT_P_IMM_OFF_POSTIND, //010 0111 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 - OP_LDRBT_P_IMM_OFF_POSTIND, //010 0111 1 1111 -//------------------------------------------ - OP_STR_M_IMM_OFF, //010 1000 0 0000 - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - OP_STR_M_IMM_OFF, - - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, - OP_LDR_M_IMM_OFF, //010 1000 1 1111 -//------------------------------------------ - OP_STR_M_IMM_OFF_PREIND, //010 1001 0 0000 - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - OP_STR_M_IMM_OFF_PREIND, - - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, - OP_LDR_M_IMM_OFF_PREIND, //010 1001 1 1111 -//------------------------------------------ - OP_STRB_M_IMM_OFF, //010 1010 0 0000 - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - OP_STRB_M_IMM_OFF, - - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, - OP_LDRB_M_IMM_OFF, //010 1010 1 1111 -//------------------------------------------ - OP_STRB_M_IMM_OFF_PREIND, //010 1011 0 0000 - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - OP_STRB_M_IMM_OFF_PREIND, - - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, - OP_LDRB_M_IMM_OFF_PREIND, //010 1011 1 1111 -//------------------------------------------ - OP_STR_P_IMM_OFF, //010 1100 0 0000 - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - OP_STR_P_IMM_OFF, - - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, - OP_LDR_P_IMM_OFF, //010 1100 1 1111 -//------------------------------------------ - OP_STR_P_IMM_OFF_PREIND, //010 1101 0 0000 - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - OP_STR_P_IMM_OFF_PREIND, - - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, - OP_LDR_P_IMM_OFF_PREIND, //010 1101 1 1111 -//------------------------------------------ - OP_STRB_P_IMM_OFF, //010 1110 0 0000 - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - OP_STRB_P_IMM_OFF, - - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, - OP_LDRB_P_IMM_OFF, //010 1110 1 1111 -//------------------------------------------ - OP_STRB_P_IMM_OFF_PREIND, //010 1111 0 0000 - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - OP_STRB_P_IMM_OFF_PREIND, - - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, - OP_LDRB_P_IMM_OFF_PREIND, //010 1111 1 1111 -//------------------------------------------ - OP_STR_M_LSL_IMM_OFF_POSTIND, //011 0000 0 0000 - OP_UND, - OP_STR_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_M_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_STR_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_M_ROR_IMM_OFF_POSTIND, - OP_UND, - - OP_LDR_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_M_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_M_ROR_IMM_OFF_POSTIND, - OP_UND, //011 0000 1 1111 -//------------------------------------------ - OP_UND, //011 0001 0 0000 - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, //011 0001 1 1111 -//------------------------------------------ - OP_STRB_M_LSL_IMM_OFF_POSTIND, //011 0010 0 0000 - OP_UND, - OP_STRB_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_M_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_M_ROR_IMM_OFF_POSTIND, - OP_UND, - - OP_LDRB_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_M_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_M_ROR_IMM_OFF_POSTIND, - OP_UND, //011 0010 1 1111 -//------------------------------------------ - OP_STRBT_M_LSL_IMM_OFF_POSTIND, //011 0011 0 0000 - OP_UND, - OP_STRBT_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_M_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_M_ROR_IMM_OFF_POSTIND, - OP_UND, - - OP_LDRBT_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_M_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_M_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_M_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_M_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_M_ROR_IMM_OFF_POSTIND, - OP_UND, //011 0011 1 1111 -//------------------------------------------ - OP_STR_P_LSL_IMM_OFF_POSTIND, //011 0100 0 0000 - OP_UND, - OP_STR_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_P_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_STR_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STR_P_ROR_IMM_OFF_POSTIND, - OP_UND, - - OP_LDR_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_P_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDR_P_ROR_IMM_OFF_POSTIND, - OP_UND, //011 0100 1 1111 -//------------------------------------------ - OP_UND, //011 0101 0 0000 - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, - OP_UND, //011 0101 1 1111 -//------------------------------------------ - OP_STRB_P_LSL_IMM_OFF_POSTIND, //011 0110 0 0000 - OP_UND, - OP_STRB_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_P_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRB_P_ROR_IMM_OFF_POSTIND, - OP_UND, - - OP_LDRB_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_P_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRB_P_ROR_IMM_OFF_POSTIND, - OP_UND, -//------------------------------------------ - OP_STRBT_P_LSL_IMM_OFF_POSTIND, //011 0111 0 0000 - OP_UND, - OP_STRBT_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_P_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_STRBT_P_ROR_IMM_OFF_POSTIND, - OP_UND, - - OP_LDRBT_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_P_ROR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_P_LSL_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_P_LSR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_P_ASR_IMM_OFF_POSTIND, - OP_UND, - OP_LDRBT_P_ROR_IMM_OFF_POSTIND, - OP_UND, -//------------------------------------------ - OP_STR_M_LSL_IMM_OFF, //011 1000 0 0000 - OP_UND, - OP_STR_M_LSR_IMM_OFF, - OP_UND, - OP_STR_M_ASR_IMM_OFF, - OP_UND, - OP_STR_M_ROR_IMM_OFF, - OP_UND, - OP_STR_M_LSL_IMM_OFF, - OP_UND, - OP_STR_M_LSR_IMM_OFF, - OP_UND, - OP_STR_M_ASR_IMM_OFF, - OP_UND, - OP_STR_M_ROR_IMM_OFF, - OP_UND, - - OP_LDR_M_LSL_IMM_OFF, - OP_UND, - OP_LDR_M_LSR_IMM_OFF, - OP_UND, - OP_LDR_M_ASR_IMM_OFF, - OP_UND, - OP_LDR_M_ROR_IMM_OFF, - OP_UND, - OP_LDR_M_LSL_IMM_OFF, - OP_UND, - OP_LDR_M_LSR_IMM_OFF, - OP_UND, - OP_LDR_M_ASR_IMM_OFF, - OP_UND, - OP_LDR_M_ROR_IMM_OFF, - OP_UND, -//------------------------------------------ - OP_STR_M_LSL_IMM_OFF_PREIND, //011 1001 0 0000 - OP_UND, - OP_STR_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STR_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STR_M_ROR_IMM_OFF_PREIND, - OP_UND, - OP_STR_M_LSL_IMM_OFF_PREIND, - OP_UND, - OP_STR_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STR_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STR_M_ROR_IMM_OFF_PREIND, - OP_UND, - - OP_LDR_M_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDR_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_M_ROR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_M_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDR_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_M_ROR_IMM_OFF_PREIND, - OP_UND, -//------------------------------------------ - OP_STRB_M_LSL_IMM_OFF, //011 1010 0 0000 - OP_UND, - OP_STRB_M_LSR_IMM_OFF, - OP_UND, - OP_STRB_M_ASR_IMM_OFF, - OP_UND, - OP_STRB_M_ROR_IMM_OFF, - OP_UND, - OP_STRB_M_LSL_IMM_OFF, - OP_UND, - OP_STRB_M_LSR_IMM_OFF, - OP_UND, - OP_STRB_M_ASR_IMM_OFF, - OP_UND, - OP_STRB_M_ROR_IMM_OFF, - OP_UND, - - OP_LDRB_M_LSL_IMM_OFF, - OP_UND, - OP_LDRB_M_LSR_IMM_OFF, - OP_UND, - OP_LDRB_M_ASR_IMM_OFF, - OP_UND, - OP_LDRB_M_ROR_IMM_OFF, - OP_UND, - OP_LDRB_M_LSL_IMM_OFF, - OP_UND, - OP_LDRB_M_LSR_IMM_OFF, - OP_UND, - OP_LDRB_M_ASR_IMM_OFF, - OP_UND, - OP_LDRB_M_ROR_IMM_OFF, - OP_UND, -//------------------------------------------ - OP_STRB_M_LSL_IMM_OFF_PREIND, //011 1011 0 0000 - OP_UND, - OP_STRB_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_M_ROR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_M_LSL_IMM_OFF_PREIND, - OP_UND, - OP_STRB_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_M_ROR_IMM_OFF_PREIND, - OP_UND, - - OP_LDRB_M_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_M_ROR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_M_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_M_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_M_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_M_ROR_IMM_OFF_PREIND, - OP_UND, -//------------------------------------------ - OP_STR_P_LSL_IMM_OFF, //011 1100 0 0000 - OP_UND, - OP_STR_P_LSR_IMM_OFF, - OP_UND, - OP_STR_P_ASR_IMM_OFF, - OP_UND, - OP_STR_P_ROR_IMM_OFF, - OP_UND, - OP_STR_P_LSL_IMM_OFF, - OP_UND, - OP_STR_P_LSR_IMM_OFF, - OP_UND, - OP_STR_P_ASR_IMM_OFF, - OP_UND, - OP_STR_P_ROR_IMM_OFF, - OP_UND, - - OP_LDR_P_LSL_IMM_OFF, - OP_UND, - OP_LDR_P_LSR_IMM_OFF, - OP_UND, - OP_LDR_P_ASR_IMM_OFF, - OP_UND, - OP_LDR_P_ROR_IMM_OFF, - OP_UND, - OP_LDR_P_LSL_IMM_OFF, - OP_UND, - OP_LDR_P_LSR_IMM_OFF, - OP_UND, - OP_LDR_P_ASR_IMM_OFF, - OP_UND, - OP_LDR_P_ROR_IMM_OFF, - OP_UND, -//------------------------------------------ - OP_STR_P_LSL_IMM_OFF_PREIND, //011 1101 0 0000 - OP_UND, - OP_STR_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STR_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STR_P_ROR_IMM_OFF_PREIND, - OP_UND, - OP_STR_P_LSL_IMM_OFF_PREIND, - OP_UND, - OP_STR_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STR_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STR_P_ROR_IMM_OFF_PREIND, - OP_UND, - - OP_LDR_P_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDR_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_P_ROR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_P_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDR_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDR_P_ROR_IMM_OFF_PREIND, - OP_UND, -//------------------------------------------ - OP_STRB_P_LSL_IMM_OFF, //011 1110 0 0000 - OP_UND, - OP_STRB_P_LSR_IMM_OFF, - OP_UND, - OP_STRB_P_ASR_IMM_OFF, - OP_UND, - OP_STRB_P_ROR_IMM_OFF, - OP_UND, - OP_STRB_P_LSL_IMM_OFF, - OP_UND, - OP_STRB_P_LSR_IMM_OFF, - OP_UND, - OP_STRB_P_ASR_IMM_OFF, - OP_UND, - OP_STRB_P_ROR_IMM_OFF, - OP_UND, - - OP_LDRB_P_LSL_IMM_OFF, - OP_UND, - OP_LDRB_P_LSR_IMM_OFF, - OP_UND, - OP_LDRB_P_ASR_IMM_OFF, - OP_UND, - OP_LDRB_P_ROR_IMM_OFF, - OP_UND, - OP_LDRB_P_LSL_IMM_OFF, - OP_UND, - OP_LDRB_P_LSR_IMM_OFF, - OP_UND, - OP_LDRB_P_ASR_IMM_OFF, - OP_UND, - OP_LDRB_P_ROR_IMM_OFF, - OP_UND, -//------------------------------------------ - OP_STRB_P_LSL_IMM_OFF_PREIND, //011 1111 0 0000 - OP_UND, - OP_STRB_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_P_ROR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_P_LSL_IMM_OFF_PREIND, - OP_UND, - OP_STRB_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_STRB_P_ROR_IMM_OFF_PREIND, - OP_UND, - - OP_LDRB_P_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_P_ROR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_P_LSL_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_P_LSR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_P_ASR_IMM_OFF_PREIND, - OP_UND, - OP_LDRB_P_ROR_IMM_OFF_PREIND, - OP_UND, //011 1111 1 1111 -//------------------------------------------ - OP_STMDA, //100 0000 0 0000 - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - OP_STMDA, - - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, - OP_LDMDA, -//------------------------------------------ - OP_STMDA_W, //100 0001 0 0000 - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - OP_STMDA_W, - - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, - OP_LDMDA_W, -//------------------------------------------ - OP_STMDA2, //100 0010 0 0000 - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - OP_STMDA2, - - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, - OP_LDMDA2, -//------------------------------------------ - OP_STMDA2_W, //100 0011 0 0000 - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - OP_STMDA2_W, - - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, - OP_LDMDA2_W, -//------------------------------------------ - OP_STMIA, //100 0100 0 0000 - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - OP_STMIA, - - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, - OP_LDMIA, -//------------------------------------------ - OP_STMIA_W, //100 0101 0 0000 - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - OP_STMIA_W, - - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, - OP_LDMIA_W, -//------------------------------------------ - OP_STMIA2, //100 0110 0 0000 - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - OP_STMIA2, - - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, - OP_LDMIA2, -//------------------------------------------ - OP_STMIA2_W, //100 0111 0 0000 - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - OP_STMIA2_W, - - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, - OP_LDMIA2_W, -//------------------------------------------ - OP_STMDB, //100 1000 0 0000 - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - OP_STMDB, - - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, - OP_LDMDB, -//------------------------------------------ - OP_STMDB_W, //100 1001 0 0000 - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - OP_STMDB_W, - - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, - OP_LDMDB_W, -//------------------------------------------ - OP_STMDB2, //100 1010 0 0000 - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - OP_STMDB2, - - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, - OP_LDMDB2, -//------------------------------------------ - OP_STMDB2_W, //100 1011 0 0000 - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - OP_STMDB2_W, - - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, - OP_LDMDB2_W, -//------------------------------------------ - - - OP_STMIB, //100 1100 0 0000 - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - OP_STMIB, - - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, - OP_LDMIB, -//------------------------------------------ - OP_STMIB_W, //100 1101 0 0000 - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - OP_STMIB_W, - - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, - OP_LDMIB_W, -//------------------------------------------ - OP_STMIB2, //100 1110 0 0000 - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - OP_STMIB2, - - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, - OP_LDMIB2, -//------------------------------------------ - OP_STMIB2_W, //100 1111 0 0000 - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - OP_STMIB2_W, - - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, - OP_LDMIB2_W, -//------------------------------------------ - OP_B, //101 0000 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_B, //101 0001 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_B, //101 0010 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_B, //101 0011 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_B, //101 0100 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_B, //101 0101 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_B, //101 0110 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_B, //101 0111 0 0000 - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, - OP_B, -//------------------------------------------ - OP_BL, //101 1000 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_BL, //101 1001 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_BL, //101 1010 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_BL, //101 1011 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_BL, //101 1100 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_BL, //101 1101 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_BL, //101 1110 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_BL, //101 1111 0 0000 - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, - OP_BL, -//------------------------------------------ - OP_STC_OPTION, //110 0000 0 0000 - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, -//------------------------------------------ - OP_STC_M_POSTIND, //110 0001 0 0000 - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, -//------------------------------------------ - OP_STC_OPTION, //110 0010 0 0000 - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, -//------------------------------------------ - OP_STC_M_POSTIND, //110 0011 0 0000 - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - OP_STC_M_POSTIND, - - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, - OP_LDC_M_POSTIND, -//------------------------------------------ - OP_STC_OPTION, //110 0100 0 0000 - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, -//------------------------------------------ - OP_STC_P_POSTIND, //110 0101 0 0000 - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, -//------------------------------------------ - OP_STC_OPTION, //110 0110 0 0000 - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - OP_STC_OPTION, - - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, - OP_LDC_OPTION, -//------------------------------------------ - OP_STC_P_POSTIND, //110 0111 0 0000 - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - OP_STC_P_POSTIND, - - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, - OP_LDC_P_POSTIND, -//------------------------------------------ - OP_STC_M_IMM_OFF, //110 1000 0 0000 - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, -//------------------------------------------ - OP_STC_M_PREIND, //110 1001 0 0000 - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, -//------------------------------------------ - OP_STC_M_IMM_OFF, //110 1010 0 0000 - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - OP_STC_M_IMM_OFF, - - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, - OP_LDC_M_IMM_OFF, -//------------------------------------------ - OP_STC_M_PREIND, //110 1011 0 0000 - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - OP_STC_M_PREIND, - - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, - OP_LDC_M_PREIND, -//------------------------------------------ - OP_STC_P_IMM_OFF, //110 1100 0 0000 - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, -//------------------------------------------ - OP_STC_P_PREIND, //110 1101 0 0000 - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, -//------------------------------------------ - OP_STC_P_IMM_OFF, //110 1110 0 0000 - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - OP_STC_P_IMM_OFF, - - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, - OP_LDC_P_IMM_OFF, -//------------------------------------------ - OP_STC_P_PREIND, //110 1111 0 0000 - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - OP_STC_P_PREIND, - - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, - OP_LDC_P_PREIND, -//------------------------------------------ - OP_CDP, //111 0000 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_CDP, //111 0001 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_CDP, //111 0010 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_CDP, //111 0011 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_CDP, //111 0100 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_CDP, //111 0101 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_CDP, //111 0110 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_CDP, //111 0111 0 0000 - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - OP_CDP, - OP_MCR, - - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, - OP_CDP, - OP_MRC, -//--------------------------------------------- - OP_SWI, //111 1000 0 0000 - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, - OP_SWI, -}; - diff --git a/tools/vio2sf/src/vio2sf/desmume/matrix.c b/tools/vio2sf/src/vio2sf/desmume/matrix.c deleted file mode 100644 index 555d62b15..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/matrix.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include "matrix.h" - -void MatrixInit (float *matrix) -{ - memset (matrix, 0, sizeof(float)*16); - - matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f; -} - -void MatrixMultVec4x4 (float *matrix, float *vecPtr) -{ - float x = vecPtr[0]; - float y = vecPtr[1]; - float z = vecPtr[2]; - - vecPtr[0] = x * matrix[0] + y * matrix[4] + z * matrix[ 8] + matrix[12]; - vecPtr[1] = x * matrix[1] + y * matrix[5] + z * matrix[ 9] + matrix[13]; - vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10] + matrix[14]; -} - -void MatrixMultVec3x3 (float *matrix, float *vecPtr) -{ - float x = vecPtr[0]; - float y = vecPtr[1]; - float z = vecPtr[2]; - - vecPtr[0] = x * matrix[0] + y * matrix[4] + z * matrix[ 8]; - vecPtr[1] = x * matrix[1] + y * matrix[5] + z * matrix[ 9]; - vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10]; -} - -void MatrixIdentity (float *matrix) -{ - memset (matrix, 0, sizeof(float)*16); - - matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f; -} - -void MatrixMultiply (float *matrix, float *rightMatrix) -{ - float tmpMatrix[16]; - - tmpMatrix[0] = (matrix[0]*rightMatrix[0])+(matrix[4]*rightMatrix[1])+(matrix[8]*rightMatrix[2])+(matrix[12]*rightMatrix[3]); - tmpMatrix[1] = (matrix[1]*rightMatrix[0])+(matrix[5]*rightMatrix[1])+(matrix[9]*rightMatrix[2])+(matrix[13]*rightMatrix[3]); - tmpMatrix[2] = (matrix[2]*rightMatrix[0])+(matrix[6]*rightMatrix[1])+(matrix[10]*rightMatrix[2])+(matrix[14]*rightMatrix[3]); - tmpMatrix[3] = (matrix[3]*rightMatrix[0])+(matrix[7]*rightMatrix[1])+(matrix[11]*rightMatrix[2])+(matrix[15]*rightMatrix[3]); - - tmpMatrix[4] = (matrix[0]*rightMatrix[4])+(matrix[4]*rightMatrix[5])+(matrix[8]*rightMatrix[6])+(matrix[12]*rightMatrix[7]); - tmpMatrix[5] = (matrix[1]*rightMatrix[4])+(matrix[5]*rightMatrix[5])+(matrix[9]*rightMatrix[6])+(matrix[13]*rightMatrix[7]); - tmpMatrix[6] = (matrix[2]*rightMatrix[4])+(matrix[6]*rightMatrix[5])+(matrix[10]*rightMatrix[6])+(matrix[14]*rightMatrix[7]); - tmpMatrix[7] = (matrix[3]*rightMatrix[4])+(matrix[7]*rightMatrix[5])+(matrix[11]*rightMatrix[6])+(matrix[15]*rightMatrix[7]); - - tmpMatrix[8] = (matrix[0]*rightMatrix[8])+(matrix[4]*rightMatrix[9])+(matrix[8]*rightMatrix[10])+(matrix[12]*rightMatrix[11]); - tmpMatrix[9] = (matrix[1]*rightMatrix[8])+(matrix[5]*rightMatrix[9])+(matrix[9]*rightMatrix[10])+(matrix[13]*rightMatrix[11]); - tmpMatrix[10] = (matrix[2]*rightMatrix[8])+(matrix[6]*rightMatrix[9])+(matrix[10]*rightMatrix[10])+(matrix[14]*rightMatrix[11]); - tmpMatrix[11] = (matrix[3]*rightMatrix[8])+(matrix[7]*rightMatrix[9])+(matrix[11]*rightMatrix[10])+(matrix[15]*rightMatrix[11]); - - tmpMatrix[12] = (matrix[0]*rightMatrix[12])+(matrix[4]*rightMatrix[13])+(matrix[8]*rightMatrix[14])+(matrix[12]*rightMatrix[15]); - tmpMatrix[13] = (matrix[1]*rightMatrix[12])+(matrix[5]*rightMatrix[13])+(matrix[9]*rightMatrix[14])+(matrix[13]*rightMatrix[15]); - tmpMatrix[14] = (matrix[2]*rightMatrix[12])+(matrix[6]*rightMatrix[13])+(matrix[10]*rightMatrix[14])+(matrix[14]*rightMatrix[15]); - tmpMatrix[15] = (matrix[3]*rightMatrix[12])+(matrix[7]*rightMatrix[13])+(matrix[11]*rightMatrix[14])+(matrix[15]*rightMatrix[15]); - - memcpy (matrix, tmpMatrix, sizeof(float)*16); -} -/* -void MatrixMulti (float* right) -{ - float tmpMatrix[16]; - - tmpMatrix[0] = (matrix[0]*right[0])+(matrix[4]*right[1])+(matrix[8]*right[2])+(matrix[12]*right[3]); - tmpMatrix[1] = (matrix[1]*right[0])+(matrix[5]*right[1])+(matrix[9]*right[2])+(matrix[13]*right[3]); - tmpMatrix[2] = (matrix[2]*right[0])+(matrix[6]*right[1])+(matrix[10]*right[2])+(matrix[14]*right[3]); - tmpMatrix[3] = (matrix[3]*right[0])+(matrix[7]*right[1])+(matrix[11]*right[2])+(matrix[15]*right[3]); - - tmpMatrix[4] = (matrix[0]*right[4])+(matrix[4]*right[5])+(matrix[8]*right[6])+(matrix[12]*right[7]); - tmpMatrix[5] = (matrix[1]*right[4])+(matrix[5]*right[5])+(matrix[9]*right[6])+(matrix[13]*right[7]); - tmpMatrix[6] = (matrix[2]*right[4])+(matrix[6]*right[5])+(matrix[10]*right[6])+(matrix[14]*right[7]); - tmpMatrix[7] = (matrix[3]*right[4])+(matrix[7]*right[5])+(matrix[11]*right[6])+(matrix[15]*right[7]); - - tmpMatrix[8] = (matrix[0]*right[8])+(matrix[4]*right[9])+(matrix[8]*right[10])+(matrix[12]*right[11]); - tmpMatrix[9] = (matrix[1]*right[8])+(matrix[5]*right[9])+(matrix[9]*right[10])+(matrix[13]*right[11]); - tmpMatrix[10] = (matrix[2]*right[8])+(matrix[6]*right[9])+(matrix[10]*right[10])+(matrix[14]*right[11]); - tmpMatrix[11] = (matrix[3]*right[8])+(matrix[7]*right[9])+(matrix[11]*right[10])+(matrix[15]*right[11]); - - tmpMatrix[12] = (matrix[0]*right[12])+(matrix[4]*right[13])+(matrix[8]*right[14])+(matrix[12]*right[15]); - tmpMatrix[13] = (matrix[1]*right[12])+(matrix[5]*right[13])+(matrix[9]*right[14])+(matrix[13]*right[15]); - tmpMatrix[14] = (matrix[2]*right[12])+(matrix[6]*right[13])+(matrix[10]*right[14])+(matrix[14]*right[15]); - tmpMatrix[15] = (matrix[3]*right[12])+(matrix[7]*right[13])+(matrix[11]*right[14])+(matrix[15]*right[15]); - - memcpy (matrix, tmpMatrix, sizeof(float)*16); -} - - -float* Matrix::Get (void) -{ - return matrix; -} - -float MatrixGet (float *matrix, int index) -{ - return matrix[index]; -} -*/ - -float MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix) -{ - int iMod = index%4, iDiv = (index>>2)<<2; - - return (matrix[iMod ]*rightMatrix[iDiv ])+(matrix[iMod+ 4]*rightMatrix[iDiv+1])+ - (matrix[iMod+8]*rightMatrix[iDiv+2])+(matrix[iMod+12]*rightMatrix[iDiv+3]); -} - -void MatrixSet (float *matrix, int x, int y, float value) -{ - matrix [x+(y<<2)] = value; -} -/* -void Matrix::Set (int pos, float value) -{ - matrix [pos] = value; -} -*/ -void MatrixCopy (float *matrixDST, float *matrixSRC) -{ - memcpy (matrixDST, matrixSRC, sizeof(float)*16); -} - -void MatrixTranslate (float *matrix, float *ptr) -{ - matrix[12] += (matrix[0]*ptr[0])+(matrix[4]*ptr[1])+(matrix[ 8]*ptr[2]); - matrix[13] += (matrix[1]*ptr[0])+(matrix[5]*ptr[1])+(matrix[ 9]*ptr[2]); - matrix[14] += (matrix[2]*ptr[0])+(matrix[6]*ptr[1])+(matrix[10]*ptr[2]); - matrix[15] += (matrix[3]*ptr[0])+(matrix[7]*ptr[1])+(matrix[11]*ptr[2]); -} - -void MatrixScale (float *matrix, float *ptr) -{ - matrix[0] *= ptr[0]; - matrix[1] *= ptr[0]; - matrix[2] *= ptr[0]; - matrix[3] *= ptr[0]; - - matrix[4] *= ptr[1]; - matrix[5] *= ptr[1]; - matrix[6] *= ptr[1]; - matrix[7] *= ptr[1]; - - matrix[8] *= ptr[2]; - matrix[9] *= ptr[2]; - matrix[10] *= ptr[2]; - matrix[11] *= ptr[2]; -} -/* -void Matrix::Set (float a11, float a21, float a31, float a41, - float a12, float a22, float a32, float a42, - float a13, float a23, float a33, float a43, - float a14, float a24, float a34, float a44) -{ -} -*/ - - -//----------------------------------------- - -void MatrixStackInit (MatrixStack *stack) -{ - stack->matrix = NULL; - stack->position = 0; - stack->size = 0; -} - -void MatrixStackSetMaxSize (MatrixStack *stack, int size) -{ - int i = 0; - - stack->size = size; - - if (stack->matrix == NULL) - { - stack->matrix = (float*) malloc (stack->size*16*sizeof(float)); - } - else - { - free (stack->matrix); - stack->matrix = (float*) malloc (stack->size*16*sizeof(float)); - } - - for (i = 0; i < stack->size; i++) - { - MatrixInit (&stack->matrix[i*16]); - } - - stack->size--; -} - - -void MatrixStackSetStackPosition (MatrixStack *stack, int pos) -{ - stack->position += pos; - - if (stack->position < 0) - stack->position = 0; - else if (stack->position > stack->size) - stack->position = stack->size; -} - -void MatrixStackPushMatrix (MatrixStack *stack, float *ptr) -{ - MatrixCopy (&stack->matrix[stack->position*16], ptr); - - MatrixStackSetStackPosition (stack, 1); -} - -float * MatrixStackPopMatrix (MatrixStack *stack, int size) -{ - MatrixStackSetStackPosition(stack, -size); - - return &stack->matrix[stack->position*16]; -} - -float * MatrixStackGetPos (MatrixStack *stack, int pos) -{ - return &stack->matrix[pos*16]; -} - -float * MatrixStackGet (MatrixStack *stack) -{ - return &stack->matrix[stack->position*16]; -} - -void MatrixStackLoadMatrix (MatrixStack *stack, int pos, float *ptr) -{ - MatrixCopy (&stack->matrix[pos*16], ptr); -} diff --git a/tools/vio2sf/src/vio2sf/desmume/matrix.h b/tools/vio2sf/src/vio2sf/desmume/matrix.h deleted file mode 100644 index 05c0786e2..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/matrix.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MATRIX_H -#define MATRIX_H - -typedef struct MatrixStack -{ - float *matrix; - int position; - int size; -} MatrixStack; - -void MatrixInit (float *matrix); -void MatrixMultVec3x3 (float *matrix, float *vecPtr); -void MatrixMultVec4x4 (float *matrix, float *vecPtr); -void MatrixIdentity (float *matrix); -void MatrixMultiply (float *matrix, float *rightMatrix); -float MatrixGetMultipliedIndex(int index, float *matrix, float *rightMatrix); -void MatrixSet (float *matrix, int x, int y, float value); -void MatrixCopy (float *matrixDST, float *matrixSRC); -void MatrixTranslate (float *matrix, float *ptr); -void MatrixScale (float *matrix, float *ptr); - -void MatrixStackInit (MatrixStack *stack); -void MatrixStackSetMaxSize (MatrixStack *stack, int size); -void MatrixStackSetStackPosition (MatrixStack *stack, int pos); -void MatrixStackPushMatrix (MatrixStack *stack, float *ptr); -float* MatrixStackPopMatrix (MatrixStack *stack, int size); -float* MatrixStackGetPos (MatrixStack *stack, int pos); -float* MatrixStackGet (MatrixStack *stack); -void MatrixStackLoadMatrix (MatrixStack *stack, int pos, float *ptr); - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/mc.c b/tools/vio2sf/src/vio2sf/desmume/mc.c deleted file mode 100644 index 756a92c8d..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/mc.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (C) 2006 thoduv - Copyright (C) 2006-2007 Theo Berkau - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include "debug.h" -#include "types.h" -#include "mc.h" - -#define FW_CMD_READ 0x3 -#define FW_CMD_WRITEDISABLE 0x4 -#define FW_CMD_READSTATUS 0x5 -#define FW_CMD_WRITEENABLE 0x6 -#define FW_CMD_PAGEWRITE 0xA - -#define BM_CMD_AUTODETECT 0xFF -#define BM_CMD_WRITESTATUS 0x1 -#define BM_CMD_WRITELOW 0x2 -#define BM_CMD_READLOW 0x3 -#define BM_CMD_WRITEDISABLE 0x4 -#define BM_CMD_READSTATUS 0x5 -#define BM_CMD_WRITEENABLE 0x6 -#define BM_CMD_WRITEHIGH 0xA -#define BM_CMD_READHIGH 0xB - -/* FLASH*/ -#define COMM_PAGE_WRITE 0x0A -#define COMM_PAGE_ERASE 0xDB -#define COMM_SECTOR_ERASE 0xD8 -#define COMM_CHIP_ERASE 0xC7 -#define CARDFLASH_READ_BYTES_FAST 0x0B /* Not used*/ -#define CARDFLASH_DEEP_POWDOWN 0xB9 /* Not used*/ -#define CARDFLASH_WAKEUP 0xAB /* Not used*/ - -void mc_init(memory_chip_t *mc, int type) -{ - mc->com = 0; - mc->addr = 0; - mc->addr_shift = 0; - mc->data = NULL; - mc->size = 0; - mc->write_enable = FALSE; - mc->writeable_buffer = FALSE; - mc->type = type; - mc->autodetectsize = 0; - - switch(mc->type) - { - case MC_TYPE_EEPROM1: - mc->addr_size = 1; - break; - case MC_TYPE_EEPROM2: - case MC_TYPE_FRAM: - mc->addr_size = 2; - break; - case MC_TYPE_FLASH: - mc->addr_size = 3; - break; - default: break; - } -} - -u8 *mc_alloc(memory_chip_t *mc, u32 size) -{ - u8 *buffer; - buffer = malloc(size); - - mc->data = buffer; - if(!buffer) { return NULL; } - mc->size = size; - mc->writeable_buffer = TRUE; - - return buffer; -} - -void mc_free(memory_chip_t *mc) -{ - if(mc->data) - { - free(mc->data); - mc->data = 0; - } - mc_init(mc, 0); -} - -void mc_realloc(memory_chip_t *mc, int type, u32 size) -{ - mc_free(mc); - mc_init(mc, type); - mc_alloc(mc, size); -} - - -void mc_reset_com(memory_chip_t *mc) -{ -} -u8 fw_transfer(memory_chip_t *mc, u8 data) -{ - return 0; -} -u8 bm_transfer(memory_chip_t *mc, u8 data) -{ - return 0; -} - diff --git a/tools/vio2sf/src/vio2sf/desmume/mc.h b/tools/vio2sf/src/vio2sf/desmume/mc.h deleted file mode 100644 index f78b7c39f..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/mc.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 2006 thoduv - Copyright (C) 2006 Theo Berkau - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __FW_H__ -#define __FW_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "types.h" - -#define MC_TYPE_AUTODETECT 0x0 -#define MC_TYPE_EEPROM1 0x1 -#define MC_TYPE_EEPROM2 0x2 -#define MC_TYPE_FLASH 0x3 -#define MC_TYPE_FRAM 0x4 - -#define MC_SIZE_4KBITS 0x000200 -#define MC_SIZE_64KBITS 0x002000 -#define MC_SIZE_256KBITS 0x008000 -#define MC_SIZE_512KBITS 0x010000 -#define MC_SIZE_1MBITS 0x020000 -#define MC_SIZE_2MBITS 0x040000 -#define MC_SIZE_4MBITS 0x080000 -#define MC_SIZE_8MBITS 0x100000 -#define MC_SIZE_16MBITS 0x200000 -#define MC_SIZE_64MBITS 0x800000 - -static int save_types[6][2] = { - {MC_TYPE_AUTODETECT,1}, - {MC_TYPE_EEPROM1,MC_SIZE_4KBITS}, - {MC_TYPE_EEPROM2,MC_SIZE_64KBITS}, - {MC_TYPE_EEPROM2,MC_SIZE_512KBITS}, - {MC_TYPE_FLASH,MC_SIZE_256KBITS}, - {MC_TYPE_FRAM,MC_SIZE_2MBITS} -}; - -typedef struct -{ - u8 com; /* persistent command actually handled */ - u32 addr; /* current address for reading/writing */ - u8 addr_shift; /* shift for address (since addresses are transfered by 3 bytes units) */ - u8 addr_size; /* size of addr when writing/reading */ - - BOOL write_enable; /* is write enabled ? */ - - u8 *data; /* memory data */ - u32 size; /* memory size */ - BOOL writeable_buffer; /* is "data" writeable ? */ - int type; /* type of Memory */ - char *filename; - FILE *fp; - u8 autodetectbuf[32768]; - int autodetectsize; -} memory_chip_t; - -#define NDS_FW_SIZE_V1 (256 * 1024) /* size of fw memory on nds v1 */ -#define NDS_FW_SIZE_V2 (512 * 1024) /* size of fw memory on nds v2 */ - -void mc_init(memory_chip_t *mc, int type); /* reset and init values for memory struct */ -u8 *mc_alloc(memory_chip_t *mc, u32 size); /* alloc mc memory */ -void mc_realloc(memory_chip_t *mc, int type, u32 size); /* realloc mc memory */ -void mc_load_file(memory_chip_t *mc, const char* filename); /* load save file and setup fp */ -int mc_load_duc(memory_chip_t *mc, const char* filename); /* load Action Replay DS save file */ -void mc_free(memory_chip_t *mc); /* delete mc memory */ -void mc_reset_com(memory_chip_t *mc); /* reset communication with mc */ -u8 fw_transfer(memory_chip_t *mc, u8 data); /* transfer to, then receive data from firmware */ -u8 bm_transfer(memory_chip_t *mc, u8 data); /* transfer to, then receive data from backup memory */ - -#ifdef __cplusplus -} -#endif - -#endif /*__FW_H__*/ - diff --git a/tools/vio2sf/src/vio2sf/desmume/mem.h b/tools/vio2sf/src/vio2sf/desmume/mem.h deleted file mode 100644 index 72060f1f5..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/mem.h +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright 2005-2006 Guillaume Duhamel - Copyright 2005 Theo Berkau - - This file is part of Yabause. - - Yabause is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - Yabause is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Yabause; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MEM_H -#define MEM_H - -#include -#include "types.h" - -/* Type 1 Memory, faster for byte (8 bits) accesses */ - -static INLINE u8 T1ReadByte(u8 * mem, u32 addr) -{ - return mem[addr]; -} - -static INLINE u16 T1ReadWord(u8 * mem, u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return (mem[addr + 1] << 8) | mem[addr]; -#else - return *((u16 *) (mem + addr)); -#endif -} - -static INLINE u32 T1ReadLong(u8 * mem, u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return (mem[addr + 3] << 24 | mem[addr + 2] << 16 | - mem[addr + 1] << 8 | mem[addr]); -#else - return *((u32 *)mem + (addr>>2)); -#endif -} - -static INLINE u64 T1ReadQuad(u8 * mem, u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return (mem[addr + 7] << 56 | mem[addr + 6] << 48 | - mem[addr + 5] << 40 | mem[addr + 4] << 32 | - mem[addr + 3] << 24 | mem[addr + 2] << 16 | - mem[addr + 1] << 8 | mem[addr]); -#else - return *((u64 *) (mem + addr)); -#endif -} - -static INLINE void T1WriteByte(u8 * mem, u32 addr, u8 val) -{ - mem[addr] = val; -} - -static INLINE void T1WriteWord(u8 * mem, u32 addr, u16 val) -{ -#ifdef WORDS_BIGENDIAN - mem[addr + 1] = val >> 8; - mem[addr] = val & 0xFF; -#else - *((u16 *) (mem + addr)) = val; -#endif -} - -static INLINE void T1WriteLong(u8 * mem, u32 addr, u32 val) -{ -#ifdef WORDS_BIGENDIAN - mem[addr + 3] = val >> 24; - mem[addr + 2] = (val >> 16) & 0xFF; - mem[addr + 1] = (val >> 8) & 0xFF; - mem[addr] = val & 0xFF; -#else - *((u32 *) (mem + addr)) = val; -#endif -} - -/* Type 2 Memory, faster for word (16 bits) accesses */ - -static INLINE u8 T2ReadByte(u8 * mem, u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return mem[addr ^ 1]; -#else - return mem[addr]; -#endif -} - -static INLINE u16 T2ReadWord(u8 * mem, u32 addr) -{ - return *((u16 *) (mem + addr)); -} - -static INLINE u32 T2ReadLong(u8 * mem, u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return *((u16 *) (mem + addr + 2)) << 16 | *((u16 *) (mem + addr)); -#else - return *((u32 *) (mem + addr)); -#endif -} - -static INLINE void T2WriteByte(u8 * mem, u32 addr, u8 val) -{ -#ifdef WORDS_BIGENDIAN - mem[addr ^ 1] = val; -#else - mem[addr] = val; -#endif -} - -static INLINE void T2WriteWord(u8 * mem, u32 addr, u16 val) -{ - *((u16 *) (mem + addr)) = val; -} - -static INLINE void T2WriteLong(u8 * mem, u32 addr, u32 val) -{ -#ifdef WORDS_BIGENDIAN - *((u16 *) (mem + addr + 2)) = val >> 16; - *((u16 *) (mem + addr)) = val & 0xFFFF; -#else - *((u32 *) (mem + addr)) = val; -#endif -} - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/registers.h b/tools/vio2sf/src/vio2sf/desmume/registers.h deleted file mode 100644 index f9060214d..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/registers.h +++ /dev/null @@ -1,333 +0,0 @@ -/* Copyright (C) 2006 Theo Berkau - - Ideas borrowed from Stephane Dallongeville's SCSP core - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef REGISTERS_H -#define REGISTERS_H - -#define REG_REGION_MASK 0x0FFFEF80 -#define REG_BASE_DISPx 0x04000000 -#define REG_BASE_DISPA 0x04000000 -#define REG_BASE_DISPB 0x04001000 -#define REG_BASE_DMA 0x04000080 -#define REG_BASE_SIORTCTIMERS 0x04000100 -#define REG_BASE_ROMIPC 0x04000180 -#define REG_BASE_MEMIRQ 0x04000200 -#define REG_BASE_MATH 0x04000280 -#define REG_BASE_OTHER 0x04000300 -#define REG_BASE_RCVPORTS 0x04100000 - -// Display Engine A -#define REG_DISPA_DISPCNT 0x04000000 -#define REG_DISPA_VCOUNT 0x04000006 -#define REG_DISPA_BG0CNT 0x04000008 -#define REG_DISPA_BG1CNT 0x0400000A -#define REG_DISPA_BG2CNT 0x0400000C -#define REG_DISPA_BG3CNT 0x0400000E -#define REG_DISPA_BG0HOFS 0x04000010 -#define REG_DISPA_BG0VOFS 0x04000012 -#define REG_DISPA_BG1HOFS 0x04000014 -#define REG_DISPA_BG1VOFS 0x04000016 -#define REG_DISPA_BG2HOFS 0x04000018 -#define REG_DISPA_BG2VOFS 0x0400001A -#define REG_DISPA_BG3HOFS 0x0400001C -#define REG_DISPA_BG3VOFS 0x0400001E -#define REG_DISPA_BG2PA 0x04000020 -#define REG_DISPA_BG2PB 0x04000022 -#define REG_DISPA_BG2PC 0x04000024 -#define REG_DISPA_BG2PD 0x04000026 -#define REG_DISPA_BG2XL 0x04000028 -#define REG_DISPA_BG2XH 0x0400002A -#define REG_DISPA_BG2YL 0x0400002C -#define REG_DISPA_BG2YH 0x0400002E -#define REG_DISPA_BG3PA 0x04000030 -#define REG_DISPA_BG3PB 0x04000032 -#define REG_DISPA_BG3PC 0x04000034 -#define REG_DISPA_BG3PD 0x04000036 -#define REG_DISPA_BG3XL 0x04000038 -#define REG_DISPA_BG3XH 0x0400003A -#define REG_DISPA_BG3YL 0x0400003C -#define REG_DISPA_BG3YH 0x0400003E -#define REG_DISPA_WIN0H 0x04000040 -#define REG_DISPA_WIN1H 0x04000042 -#define REG_DISPA_WIN0V 0x04000044 -#define REG_DISPA_WIN1V 0x04000046 -#define REG_DISPA_WININ 0x04000048 -#define REG_DISPA_WINOUT 0x0400004A -#define REG_DISPA_MOSAIC 0x0400004C -#define REG_DISPA_BLDCNT 0x04000050 -#define REG_DISPA_BLDALPHA 0x04000052 -#define REG_DISPA_BLDY 0x04000054 -#define REG_DISPA_MASTERBRIGHT 0x0400006C - -// DMA -#define REG_DMA0SAD 0x040000B0 -#define REG_DMA0DAD 0x040000B4 -#define REG_DMA0CNTL 0x040000B8 -#define REG_DMA0CNTH 0x040000BA -#define REG_DMA1SAD 0x040000BC -#define REG_DMA1DAD 0x040000C0 -#define REG_DMA1CNTL 0x040000C4 -#define REG_DMA1CNTH 0x040000C6 -#define REG_DMA2SAD 0x040000C8 -#define REG_DMA2DAD 0x040000CC -#define REG_DMA2CNTL 0x040000D0 -#define REG_DMA2CNTH 0x040000D2 -#define REG_DMA3SAD 0x040000D4 -#define REG_DMA3DAD 0x040000D8 -#define REG_DMA3CNTL 0x040000DC -#define REG_DMA3CNTH 0x040000DE -#define REG_DMA0FILL 0x040000E0 -#define REG_DMA1FILL 0x040000E4 -#define REG_DMA2FILL 0x040000E8 -#define REG_DMA3FILL 0x040000EC - -// Timers -#define REG_TM0CNTL 0x04000100 -#define REG_TM0CNTH 0x04000102 -#define REG_TM1CNTL 0x04000104 -#define REG_TM1CNTH 0x04000106 -#define REG_TM2CNTL 0x04000108 -#define REG_TM2CNTH 0x0400010A -#define REG_TM3CNTL 0x0400010C -#define REG_TM3CNTH 0x0400010E - -// SIO/Keypad Input/RTC -#define REG_SIODATA32 0x04000120 -#define REG_SIOCNT 0x04000128 -#define REG_KEYINPUT 0x04000130 -#define REG_KEYCNT 0x04000132 -#define REG_RCNT 0x04000134 -#define REG_EXTKEYIN 0x04000136 -#define REG_RTC 0x04000138 - -// IPC -#define REG_IPCSYNC 0x04000180 -#define REG_IPCFIFOCNT 0x04000184 -#define REG_IPCFIFOSEND 0x04000188 - -// ROM -#define REG_AUXSPICNT 0x040001A0 -#define REG_AUXSPIDATA 0x040001A2 -#define REG_GCROMCTRL 0x040001A4 -#define REG_GCCMDOUT 0x040001A8 -#define REG_ENCSEED0L 0x040001B0 -#define REG_ENCSEED1L 0x040001B4 -#define REG_ENCSEED0H 0x040001B8 -#define REG_ENCSEED1H 0x040001BC -#define REG_SPICNT 0x040001C0 -#define REG_SPIDATA 0x040001C2 - -// Memory/IRQ -#define REG_EXMEMCNT 0x04000204 -#define REG_WIFIWAITCNT 0x04000206 -#define REG_IME 0x04000208 -#define REG_IE 0x04000210 -#define REG_IF 0x04000214 -#define REG_VRAMCNTA 0x04000240 -#define REG_VRAMSTAT 0x04000240 -#define REG_VRAMCNTB 0x04000241 -#define REG_WRAMSTAT 0x04000241 -#define REG_VRAMCNTC 0x04000242 -#define REG_VRAMCNTD 0x04000243 -#define REG_VRAMCNTE 0x04000244 -#define REG_VRAMCNTF 0x04000245 -#define REG_VRAMCNTG 0x04000246 -#define REG_WRAMCNT 0x04000247 -#define REG_VRAMCNTH 0x04000248 -#define REG_VRAMCNTI 0x04000249 - -// Math -#define REG_DIVCNT 0x04000280 -#define REG_DIVNUMER 0x04000290 -#define REG_DIVDENOM 0x04000298 -#define REG_DIVRESULT 0x040002A0 -#define REG_DIVREMRESULT 0x040002A8 -#define REG_SQRTCNT 0x040002B0 -#define REG_SQRTRESULT 0x040002B4 -#define REG_SQRTPARAM 0x040002B8 - -// Other -#define REG_POSTFLG 0x04000300 -#define REG_HALTCNT 0x04000301 -#define REG_POWCNT1 0x04000304 -#define REG_POWCNT2 0x04000304 -#define REG_BIOSPROT 0x04000308 - -#define REG_DISPB_DISPCNT 0x04001000 -#define REG_DISPB_BG0CNT 0x04001008 -#define REG_DISPB_BG1CNT 0x0400100A -#define REG_DISPB_BG2CNT 0x0400100C -#define REG_DISPB_BG3CNT 0x0400100E -#define REG_DISPB_BG0HOFS 0x04001010 -#define REG_DISPB_BG0VOFS 0x04001012 -#define REG_DISPB_BG1HOFS 0x04001014 -#define REG_DISPB_BG1VOFS 0x04001016 -#define REG_DISPB_BG2HOFS 0x04001018 -#define REG_DISPB_BG2VOFS 0x0400101A -#define REG_DISPB_BG3HOFS 0x0400101C -#define REG_DISPB_BG3VOFS 0x0400101E -#define REG_DISPB_BG2PA 0x04001020 -#define REG_DISPB_BG2PB 0x04001022 -#define REG_DISPB_BG2PC 0x04001024 -#define REG_DISPB_BG2PD 0x04001026 -#define REG_DISPB_BG2XL 0x04001028 -#define REG_DISPB_BG2XH 0x0400102A -#define REG_DISPB_BG2YL 0x0400102C -#define REG_DISPB_BG2YH 0x0400102E -#define REG_DISPB_BG3PA 0x04001030 -#define REG_DISPB_BG3PB 0x04001032 -#define REG_DISPB_BG3PC 0x04001034 -#define REG_DISPB_BG3PD 0x04001036 -#define REG_DISPB_BG3XL 0x04001038 -#define REG_DISPB_BG3XH 0x0400103A -#define REG_DISPB_BG3YL 0x0400103C -#define REG_DISPB_BG3YH 0x0400103E -#define REG_DISPB_WIN0H 0x04001040 -#define REG_DISPB_WIN1H 0x04001042 -#define REG_DISPB_WIN0V 0x04001044 -#define REG_DISPB_WIN1V 0x04001046 -#define REG_DISPB_WININ 0x04001048 -#define REG_DISPB_WINOUT 0x0400104A -#define REG_DISPB_MOSAIC 0x0400104C -#define REG_DISPB_BLDCNT 0x04001050 -#define REG_DISPB_BLDALPHA 0x04001052 -#define REG_DISPB_BLDY 0x04001054 -#define REG_DISPB_MASTERBRIGHT 0x0400106C - -// Receive ports -#define REG_IPCFIFORECV 0x04100000 -#define REG_GCDATAIN 0x04100010 - - - - - -#define REG_DISPB 0x00001000 -// core A and B specific -#define REG_DISPx_DISPCNT 0x04000000 -#define REG_DISPx_VCOUNT 0x04000006 -#define REG_DISPx_BG0CNT 0x04000008 -#define REG_DISPx_BG1CNT 0x0400000A -#define REG_DISPx_BG2CNT 0x0400000C -#define REG_DISPx_BG3CNT 0x0400000E -#define REG_DISPx_BG0HOFS 0x04000010 -#define REG_DISPx_BG0VOFS 0x04000012 -#define REG_DISPx_BG1HOFS 0x04000014 -#define REG_DISPx_BG1VOFS 0x04000016 -#define REG_DISPx_BG2HOFS 0x04000018 -#define REG_DISPx_BG2VOFS 0x0400001A -#define REG_DISPx_BG3HOFS 0x0400001C -#define REG_DISPx_BG3VOFS 0x0400001E -#define REG_DISPx_BG2PA 0x04000020 -#define REG_DISPx_BG2PB 0x04000022 -#define REG_DISPx_BG2PC 0x04000024 -#define REG_DISPx_BG2PD 0x04000026 -#define REG_DISPx_BG2XL 0x04000028 -#define REG_DISPx_BG2XH 0x0400002A -#define REG_DISPx_BG2YL 0x0400002C -#define REG_DISPx_BG2YH 0x0400002E -#define REG_DISPx_BG3PA 0x04000030 -#define REG_DISPx_BG3PB 0x04000032 -#define REG_DISPx_BG3PC 0x04000034 -#define REG_DISPx_BG3PD 0x04000036 -#define REG_DISPx_BG3XL 0x04000038 -#define REG_DISPx_BG3XH 0x0400003A -#define REG_DISPx_BG3YL 0x0400003C -#define REG_DISPx_BG3YH 0x0400003E -#define REG_DISPx_WIN0H 0x04000040 -#define REG_DISPx_WIN1H 0x04000042 -#define REG_DISPx_WIN0V 0x04000044 -#define REG_DISPx_WIN1V 0x04000046 -#define REG_DISPx_WININ 0x04000048 -#define REG_DISPx_WINOUT 0x0400004A -#define REG_DISPx_MOSAIC 0x0400004C -#define REG_DISPx_BLDCNT 0x04000050 -#define REG_DISPx_BLDALPHA 0x04000052 -#define REG_DISPx_BLDY 0x04000054 -#define REG_DISPx_MASTERBRIGHT 0x0400006C -// core A specific -#define REG_DISPA_DISPSTAT 0x04000004 -#define REG_DISPA_DISP3DCNT 0x04000060 -#define REG_DISPA_DISPCAPCNT 0x04000064 -#define REG_DISPA_DISPMMEMFIFO 0x04000068 - - -#define eng_3D_RDLINES_COUNT 0x04000320 -#define eng_3D_EDGE_COLOR 0x04000330 -#define eng_3D_ALPHA_TEST_REF 0x04000340 -#define eng_3D_CLEAR_COLOR 0x04000350 -#define eng_3D_CLEAR_DEPTH 0x04000354 -#define eng_3D_CLRIMAGE_OFFSET 0x04000356 -#define eng_3D_FOG_COLOR 0x04000358 -#define eng_3D_FOG_OFFSET 0x0400035C -#define eng_3D_FOG_TABLE 0x04000360 -#define eng_3D_TOON_TABLE 0x04000380 -#define eng_3D_GXFIFO 0x04000400 - -// 3d commands -#define cmd_3D_MTX_MODE 0x04000440 -#define cmd_3D_MTX_PUSH 0x04000444 -#define cmd_3D_MTX_POP 0x04000448 -#define cmd_3D_MTX_STORE 0x0400044C -#define cmd_3D_MTX_RESTORE 0x04000450 -#define cmd_3D_MTX_IDENTITY 0x04000454 -#define cmd_3D_MTX_LOAD_4x4 0x04000458 -#define cmd_3D_MTX_LOAD_4x3 0x0400045C -#define cmd_3D_MTX_MULT_4x4 0x04000460 -#define cmd_3D_MTX_MULT_4x3 0x04000464 -#define cmd_3D_MTX_MULT_3x3 0x04000468 -#define cmd_3D_MTX_SCALE 0x0400046C -#define cmd_3D_MTX_TRANS 0x04000470 -#define cmd_3D_COLOR 0x04000480 -#define cmd_3D_NORMA 0x04000484 -#define cmd_3D_TEXCOORD 0x04000488 -#define cmd_3D_VTX_16 0x0400048C -#define cmd_3D_VTX_10 0x04000490 -#define cmd_3D_VTX_XY 0x04000494 -#define cmd_3D_VTX_XZ 0x04000498 -#define cmd_3D_VTX_YZ 0x0400049C -#define cmd_3D_VTX_DIFF 0x040004A0 -#define cmd_3D_POLYGON_ATTR 0x040004A4 -#define cmd_3D_TEXIMAGE_PARAM 0x040004A8 -#define cmd_3D_PLTT_BASE 0x040004AC -#define cmd_3D_DIF_AMB 0x040004C0 -#define cmd_3D_SPE_EMI 0x040004C4 -#define cmd_3D_LIGHT_VECTOR 0x040004C8 -#define cmd_3D_LIGHT_COLOR 0x040004CC -#define cmd_3D_SHININESS 0x040004D0 -#define cmd_3D_BEGIN_VTXS 0x04000500 -#define cmd_3D_END_VTXS 0x04000504 -#define cmd_3D_SWAP_BUFFERS 0x04000540 -#define cmd_3D_VIEWPORT 0x04000580 -#define cmd_3D_BOX_TEST 0x040005C0 -#define cmd_3D_POS_TEST 0x040005C4 -#define cmd_3D_VEC_TEST 0x040005C8 - -#define eng_3D_GXSTAT 0x04000600 -#define eng_3D_RAM_COUNT 0x04000604 -#define eng_3D_DISP_1DOT_DEPTH 0x04000610 -#define eng_3D_POS_RESULT 0x04000620 -#define eng_3D_VEC_RESULT 0x04000630 -#define eng_3D_CLIPMTX_RESULT 0x04000640 -#define eng_3D_VECMTX_RESULT 0x04000680 - - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/soundView.cpp b/tools/vio2sf/src/vio2sf/desmume/soundView.cpp deleted file mode 100644 index 2f1847310..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/soundView.cpp +++ /dev/null @@ -1,490 +0,0 @@ -/* soundView.cpp - - Copyright (C) 2009-2010 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#include "SPU.h" -#include "xsfui.rh" -#include "NDSSystem.h" -#include -#include -#include -#include -#include "soundView.h" - -#include - -using namespace std; - -struct TCommonSettings { - TCommonSettings() - : spu_captureMuted(false) - , spu_advanced(false) - { - for(int i=0;i<16;i++) - spu_muteChannels[i] = false; - } - bool spu_muteChannels[16]; - bool spu_advanced, spu_captureMuted; - -} CommonSettings; - - - -////////////////////////////////////////////////////////////////////////////// - -typedef struct SoundView_DataStruct -{ - SoundView_DataStruct() - : viewFirst8Channels(TRUE) - , volModeAlternate(FALSE) - , destroyed(false) - { - } - - volatile bool destroyed; - - HWND hDlg; - - BOOL viewFirst8Channels; - BOOL volModeAlternate; -} SoundView_DataStruct; - -SoundView_DataStruct * SoundView_Data = NULL; - - -bool IsDlgCheckboxChecked(HWND hDlg, int id) -{ - return IsDlgButtonChecked(hDlg,id) == BST_CHECKED; -} - -void CheckDlgItem(HWND hDlg, int id, bool checked) -{ - CheckDlgButton(hDlg, id, checked ? BST_CHECKED : BST_UNCHECKED); -} - - - -////////////////////////////////////////////////////////////////////////////// - -BOOL SoundView_Init() -{ - return 1; -} - -void SoundView_DeInit() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -inline int chanOfs() -{ - return SoundView_Data->viewFirst8Channels ? 0 : 8; -} - -extern "C" int SoundView_DlgOpen(HINSTANCE hAppInst) -{ - HWND hDlg; - - if(SoundView_Data != NULL) - { - SetWindowPos(SoundView_Data->hDlg,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); - return 0; - } - - SoundView_Data = new SoundView_DataStruct(); - if(SoundView_Data == NULL) - return 0; - - hDlg = CreateDialogParamW(hAppInst, MAKEINTRESOURCEW(IDD_SOUND_VIEW), GetDesktopWindow(), SoundView_DlgProc, (LPARAM)SoundView_Data); - if(hDlg == NULL) - { - delete SoundView_Data; - SoundView_Data = NULL; - return 0; - } - - SoundView_Data->hDlg = hDlg; - - ShowWindow(hDlg, SW_SHOW); - UpdateWindow(hDlg); - - return 1; -} - -extern "C" void SoundView_DlgClose() -{ - if(SoundView_Data != NULL ) - { - SendMessage(SoundView_Data->hDlg,WM_APP,0,0); - while(!SoundView_Data->destroyed) - Sleep(1); - delete SoundView_Data; - SoundView_Data = NULL; - } -} - -BOOL SoundView_IsOpened() -{ - return (SoundView_Data != NULL); -} - -HWND SoundView_GetHWnd() -{ - return SoundView_Data ? SoundView_Data->hDlg : NULL; -} - -extern "C" void SoundView_Refresh() -{ - if(SoundView_Data == NULL || SPU_core == NULL) - return; - HWND hDlg = SoundView_Data->hDlg; - - PostMessage(hDlg,WM_APP+1,0,0); -} - -void DoRefresh() -{ - if(SoundView_Data == NULL || SPU_core == NULL) - return; - HWND hDlg = SoundView_Data->hDlg; - - char buf[256]; - static const int format_shift[] = { 2, 1, 3, 0 }; - static const double ARM7_CLOCK = 33513982; - for(int chanId = 0; chanId < 8; chanId++) { - int chan = chanId + chanOfs(); - channel_struct &thischan = SPU_core->channels[chan]; - - SendDlgItemMessage(hDlg, IDC_SOUND0PANBAR+chanId, PBM_SETPOS, (WPARAM)spumuldiv7(128, thischan.pan), (LPARAM)0); - if(thischan.status != CHANSTAT_STOPPED) - { - s32 vol = spumuldiv7(128, thischan.vol) >> thischan.datashift; - SendDlgItemMessage(hDlg, IDC_SOUND0VOLBAR+chanId, PBM_SETPOS, - (WPARAM)vol, (LPARAM)0); - - if(SoundView_Data->volModeAlternate) - sprintf(buf, "%d/%d", thischan.vol, 1 << thischan.datashift); - else - sprintf(buf, "%d", vol); - SetDlgItemText(hDlg, IDC_SOUND0VOL+chanId, buf); - - if (thischan.pan == 0) - strcpy(buf, "L"); - else if (thischan.pan == 64) - strcpy(buf, "C"); - else if (thischan.pan == 127) - strcpy(buf, "R"); - else if (thischan.pan < 64) - sprintf(buf, "L%d", 64 - thischan.pan); - else //if (thischan.pan > 64) - sprintf(buf, "R%d", thischan.pan - 64); - SetDlgItemText(hDlg, IDC_SOUND0PAN+chanId, buf); - - sprintf(buf, "%d", thischan.hold); - SetDlgItemText(hDlg, IDC_SOUND0HOLD+chanId, buf); - - sprintf(buf, "%d", thischan.status); - SetDlgItemText(hDlg, IDC_SOUND0BUSY+chanId, buf); - - const char* modes[] = { "Manual", "Loop Infinite", "One-Shot", "Prohibited" }; - sprintf(buf, "%d (%s)", thischan.repeat, modes[thischan.repeat]); - SetDlgItemText(hDlg, IDC_SOUND0REPEATMODE+chanId, buf); - - if(thischan.format != 3) { - const char* formats[] = { "PCM8", "PCM16", "IMA-ADPCM" }; - sprintf(buf, "%d (%s)", thischan.format, formats[thischan.format]); - SetDlgItemText(hDlg, IDC_SOUND0FORMAT+chanId, buf); - } - else { - if (chan < 8) - sprintf(buf, "%d (PSG/Noise?)", thischan.format); - else if (chan < 14) - sprintf(buf, "%d (%.1f% Square)", thischan.format, (float)thischan.waveduty/8); - else - sprintf(buf, "%d (Noise)", thischan.format); - } - - sprintf(buf, "$%07X", thischan.addr); - SetDlgItemText(hDlg, IDC_SOUND0SAD+chanId, buf); - - sprintf(buf, "samp #%d", thischan.loopstart << format_shift[thischan.format]); - SetDlgItemText(hDlg, IDC_SOUND0PNT+chanId, buf); - - sprintf(buf, "$%04X (%.1f Hz)", thischan.timer, (ARM7_CLOCK/2) / (double)(0x10000 - thischan.timer)); - SetDlgItemText(hDlg, IDC_SOUND0TMR+chanId, buf); - - sprintf(buf, "samp #%d / #%d", sputrunc(thischan.sampcnt), thischan.totlength << format_shift[thischan.format]); - SetDlgItemText(hDlg, IDC_SOUND0POSLEN+chanId, buf); - } - else { - SendDlgItemMessage(hDlg, IDC_SOUND0VOLBAR+chanId, PBM_SETPOS, (WPARAM)0, (LPARAM)0); - strcpy(buf, "---"); - SetDlgItemText(hDlg, IDC_SOUND0VOL+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0PAN+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0HOLD+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0BUSY+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0REPEATMODE+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0FORMAT+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0SAD+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0PNT+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0TMR+chanId, buf); - SetDlgItemText(hDlg, IDC_SOUND0POSLEN+chanId, buf); - } - } //chan loop - - //TODO - CAP REGS - ////ctrl - //{ - // CheckDlgItem(hDlg,IDC_SNDCTRL_ENABLE,SPU_core->regs.masteren!=0); - // CheckDlgItem(hDlg,IDC_SNDCTRL_CH1NOMIX,SPU_core->regs.ctl_ch1bypass!=0); - // CheckDlgItem(hDlg,IDC_SNDCTRL_CH3NOMIX,SPU_core->regs.ctl_ch3bypass!=0); - - // sprintf(buf,"%04X",_MMU_ARM7_read16(0x04000500)); - // SetDlgItemText(hDlg,IDC_SNDCTRL_CTRL,buf); - - // sprintf(buf,"%04X",_MMU_ARM7_read16(0x04000504)); - // SetDlgItemText(hDlg,IDC_SNDCTRL_BIAS,buf); - - // sprintf(buf,"%02X",SPU_core->regs.mastervol); - // SetDlgItemText(hDlg,IDC_SNDCTRL_VOL,buf); - - // sprintf(buf,"%01X",SPU_core->regs.ctl_left); - // SetDlgItemText(hDlg,IDC_SNDCTRL_LEFTOUT,buf); - - // sprintf(buf,"%01X",SPU_core->regs.ctl_right); - // SetDlgItemText(hDlg,IDC_SNDCTRL_RIGHTOUT,buf); - - // static const char* leftouttext[] = {"L-Mix","Ch1","Ch3","Ch1+3"}; - // static const char* rightouttext[] = {"R-Mix","Ch1","Ch3","Ch1+3"}; - - // SetDlgItemText(hDlg,IDC_SNDCTRL_LEFTOUTTEXT,leftouttext[SPU_core->regs.ctl_left]); - - // SetDlgItemText(hDlg,IDC_SNDCTRL_RIGHTOUTTEXT,rightouttext[SPU_core->regs.ctl_right]); - - //} - - ////cap0 - //{ - // SPU_struct::REGS::CAP& cap = SPU_core->regs.cap[0]; - - // CheckDlgItem(hDlg,IDC_CAP0_ADD,cap.add!=0); - // CheckDlgItem(hDlg,IDC_CAP0_SRC,cap.source!=0); - // CheckDlgItem(hDlg,IDC_CAP0_ONESHOT,cap.oneshot!=0); - // CheckDlgItem(hDlg,IDC_CAP0_TYPE,cap.bits8!=0); - // CheckDlgItem(hDlg,IDC_CAP0_ACTIVE,cap.active!=0); - // CheckDlgItem(hDlg,IDC_CAP0_RUNNING,cap.runtime.running!=0); - - // if(cap.source) SetDlgItemText(hDlg,IDC_CAP0_SRCTEXT,"Ch2"); - // else SetDlgItemText(hDlg,IDC_CAP0_SRCTEXT,"L-Mix"); - - // if(cap.bits8) SetDlgItemText(hDlg,IDC_CAP0_TYPETEXT,"Pcm8"); - // else SetDlgItemText(hDlg,IDC_CAP0_TYPETEXT,"Pcm16"); - - // sprintf(buf,"%02X",_MMU_ARM7_read08(0x04000508)); - // SetDlgItemText(hDlg,IDC_CAP0_CTRL,buf); - - // sprintf(buf,"%08X",cap.dad); - // SetDlgItemText(hDlg,IDC_CAP0_DAD,buf); - - // sprintf(buf,"%08X",cap.len); - // SetDlgItemText(hDlg,IDC_CAP0_LEN,buf); - - // sprintf(buf,"%08X",cap.runtime.curdad); - // SetDlgItemText(hDlg,IDC_CAP0_CURDAD,buf); - //} - - ////cap1 - //{ - // SPU_struct::REGS::CAP& cap = SPU_core->regs.cap[1]; - - // CheckDlgItem(hDlg,IDC_CAP1_ADD,cap.add!=0); - // CheckDlgItem(hDlg,IDC_CAP1_SRC,cap.source!=0); - // CheckDlgItem(hDlg,IDC_CAP1_ONESHOT,cap.oneshot!=0); - // CheckDlgItem(hDlg,IDC_CAP1_TYPE,cap.bits8!=0); - // CheckDlgItem(hDlg,IDC_CAP1_ACTIVE,cap.active!=0); - // CheckDlgItem(hDlg,IDC_CAP1_RUNNING,cap.runtime.running!=0); - - // if(cap.source) SetDlgItemText(hDlg,IDC_CAP1_SRCTEXT,"Ch3"); //maybe call it "Ch3(+2)" if it fits - // else SetDlgItemText(hDlg,IDC_CAP1_SRCTEXT,"R-Mix"); - - // if(cap.bits8) SetDlgItemText(hDlg,IDC_CAP1_TYPETEXT,"Pcm8"); - // else SetDlgItemText(hDlg,IDC_CAP1_TYPETEXT,"Pcm16"); - - // sprintf(buf,"%02X",_MMU_ARM7_read08(0x04000509)); - // SetDlgItemText(hDlg,IDC_CAP1_CTRL,buf); - - // sprintf(buf,"%08X",cap.dad); - // SetDlgItemText(hDlg,IDC_CAP1_DAD,buf); - - // sprintf(buf,"%08X",cap.len); - // SetDlgItemText(hDlg,IDC_CAP1_LEN,buf); - - // sprintf(buf,"%08X",cap.runtime.curdad); - // SetDlgItemText(hDlg,IDC_CAP1_CURDAD,buf); - //} -} - -////////////////////////////////////////////////////////////////////////////// - - -static void updateMute_toSettings(HWND hDlg, int chan) -{ - //for(int chanId = 0; chanId < 8; chanId++) - // CommonSettings.spu_muteChannels[chanId+chanOfs()] = IsDlgButtonChecked(hDlg, IDC_SOUND0MUTE+chanId) == BST_CHECKED; -} - -static void updateMute_allFromSettings(HWND hDlg) -{ - //for(int chanId = 0; chanId < 16; chanId++) - // CheckDlgItem(hDlg,IDC_SOUND0MUTE+chanId,CommonSettings.spu_muteChannels[chanId]); -} - -static void updateMute_fromSettings(HWND hDlg) -{ - //for(int chanId = 0; chanId < 8; chanId++) - // CheckDlgItem(hDlg,IDC_SOUND0MUTE+chanId,CommonSettings.spu_muteChannels[chanId+chanOfs()]); -} -static void SoundView_SwitchChanOfs(SoundView_DataStruct *data) -{ - if (data == NULL) - return; - - HWND hDlg = data->hDlg; - data->viewFirst8Channels = !data->viewFirst8Channels; - SetWindowText(GetDlgItem(hDlg, IDC_SOUNDVIEW_CHANSWITCH), - data->viewFirst8Channels ? "V" : "^"); - - char buf[256]; - for(int chanId = 0; chanId < 8; chanId++) { - int chan = chanId + chanOfs(); - sprintf(buf, "#%02d", chan); - SetDlgItemText(hDlg, IDC_SOUND0ID+chanId, buf); - } - - updateMute_fromSettings(hDlg); - CheckDlgItem(hDlg,IDC_SOUND_CAPTURE_MUTED,CommonSettings.spu_captureMuted); - - SoundView_Refresh(); -} - - -static INT_PTR CALLBACK SoundView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - //SoundView_DataStruct *data = (SoundView_DataStruct*)GetWindowLongPtr(hDlg, DWLP_USER); - //if((data == NULL) && (uMsg != WM_INITDIALOG)) - // return 0; - - SoundView_DataStruct *data = SoundView_Data; - - switch(uMsg) - { - case WM_NCDESTROY: - data->destroyed = true; - break; - case WM_APP+0: - DestroyWindow(hDlg); - break; - case WM_APP+1: - DoRefresh(); - break; - case WM_INITDIALOG: - { - //for(int chanId = 0; chanId < 8; chanId++) { - // SendDlgItemMessage(hDlg, IDC_SOUND0VOLBAR+chanId, PBM_SETRANGE, (WPARAM)0, MAKELPARAM(0, 128)); - // SendDlgItemMessage(hDlg, IDC_SOUND0PANBAR+chanId, PBM_SETRANGE, (WPARAM)0, MAKELPARAM(0, 128)); - //} - - //for(int chanId = 0; chanId < 8; chanId++) { - // if(CommonSettings.spu_muteChannels[chanId]) - // SendDlgItemMessage(hDlg, IDC_SOUND0MUTE+chanId, BM_SETCHECK, TRUE, 0); - //} - - //if(data == NULL) - //{ - // data = (SoundView_DataStruct*)lParam; - // SetWindowLongPtr(hDlg, DWLP_USER, (LONG)data); - //} - //data->hDlg = hDlg; - - //data->viewFirst8Channels = !data->viewFirst8Channels; - //SoundView_SwitchChanOfs(data); - ////SoundView_Refresh(); - ////InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg); - } - return 1; - - case WM_CLOSE: - SoundView_DlgClose(); - return 1; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - SoundView_DlgClose(); - return 1; - case IDC_BUTTON_VOLMODE: - data->volModeAlternate = IsDlgButtonChecked(hDlg, IDC_BUTTON_VOLMODE); - return 1; - - case IDC_SOUND0MUTE+0: - case IDC_SOUND0MUTE+1: - case IDC_SOUND0MUTE+2: - case IDC_SOUND0MUTE+3: - case IDC_SOUND0MUTE+4: - case IDC_SOUND0MUTE+5: - case IDC_SOUND0MUTE+6: - case IDC_SOUND0MUTE+7: - updateMute_toSettings(hDlg,LOWORD(wParam)-IDC_SOUND0MUTE); - return 1; - case IDC_SOUND_CAPTURE_MUTED: - CommonSettings.spu_captureMuted = IsDlgButtonChecked(hDlg,IDC_SOUND_CAPTURE_MUTED) != 0; - return 1; - case IDC_SOUND_UNMUTE_ALL: - for(int i=0;i<16;i++) CommonSettings.spu_muteChannels[i] = false; - updateMute_allFromSettings(hDlg); - return 1; - case IDC_SOUND_ANALYZE_CAP: - printf("WTF\n"); - for(int i=0;i<16;i++) CommonSettings.spu_muteChannels[i] = true; - CommonSettings.spu_muteChannels[1] = false; - CommonSettings.spu_muteChannels[3] = false; - CommonSettings.spu_captureMuted = true; - updateMute_allFromSettings(hDlg); - CheckDlgItem(hDlg,IDC_SOUND_CAPTURE_MUTED,CommonSettings.spu_captureMuted); - return 1; - - - case IDC_SOUNDVIEW_CHANSWITCH: - { - SoundView_SwitchChanOfs(data); - } - return 1; - } - return 0; - } - - return 0; -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/tools/vio2sf/src/vio2sf/desmume/soundView.h b/tools/vio2sf/src/vio2sf/desmume/soundView.h deleted file mode 100644 index 2e165ad4b..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/soundView.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef SOUND_VIEW_H -#define SOUND_VIEW_H - -BOOL SoundView_Init(); -void SoundView_DeInit(); - -BOOL SoundView_DlgOpen(HWND hParentWnd); -BOOL SoundView_IsOpened(); -HWND SoundView_GetHWnd(); - -INT_PTR CALLBACK SoundView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - -#endif diff --git a/tools/vio2sf/src/vio2sf/desmume/spu_exports.h b/tools/vio2sf/src/vio2sf/desmume/spu_exports.h deleted file mode 100644 index d1b186e8c..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/spu_exports.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _SPU_EXPORTS_H -#define _SPU_EXPORTS_H - - -#ifndef _SPU_CPP_ - -void SPU_WriteLong(u32 addr, u32 val); -void SPU_WriteByte(u32 addr, u8 val); -void SPU_WriteWord(u32 addr, u16 val); -void SPU_EmulateSamples(int numsamples); -int SPU_ChangeSoundCore(int coreid, int buffersize); -void SPU_Reset(void); -void SPU_DeInit(void); - -typedef struct -{ - int id; - const char *Name; - int (*Init)(int buffersize); - void (*DeInit)(); - void (*UpdateAudio)(s16 *buffer, u32 num_samples); - u32 (*GetAudioSpace)(); - void (*MuteAudio)(); - void (*UnMuteAudio)(); - void (*SetVolume)(int volume); -} SoundInterface_struct; - -#endif _SPU_CPP_ - -#endif //_SPU_EXPORTS_H diff --git a/tools/vio2sf/src/vio2sf/desmume/thumb_instructions.c b/tools/vio2sf/src/vio2sf/desmume/thumb_instructions.c deleted file mode 100644 index fbe5e31c8..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/thumb_instructions.c +++ /dev/null @@ -1,944 +0,0 @@ -/* - Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Code added on 18/08/2006 by shash - - Missing missaligned addresses correction - (reference in http://nocash.emubase.de/gbatek.htm#cpumemoryalignments) - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "bios.h" -#include "debug.h" -#include "MMU.h" - -#define REG_NUM(i, n) (((i)>>n)&0x7) - -extern BOOL execute; - -// Use this macros for reading/writing, so the GDB stub isn't broken -#ifdef GDB_STUB - #define READ32(a,b) cpu->mem_if->read32(a,b) - #define WRITE32(a,b,c) cpu->mem_if->write32(a,b,c) - #define READ16(a,b) cpu->mem_if->read16(a,b) - #define WRITE16(a,b,c) cpu->mem_if->write16(a,b,c) - #define READ8(a,b) cpu->mem_if->read8(a,b) - #define WRITE8(a,b,c) cpu->mem_if->write8(a,b,c) -#else - #define READ32(a,b) MMU_read32(cpu->proc_ID, b) - #define WRITE32(a,b,c) MMU_write32(cpu->proc_ID,b,c) - #define READ16(a,b) MMU_read16(cpu->proc_ID, b) - #define WRITE16(a,b,c) MMU_write16(cpu->proc_ID,b,c) - #define READ8(a,b) MMU_read8(cpu->proc_ID, b) - #define WRITE8(a,b,c) MMU_write8(cpu->proc_ID,b,c) -#endif - -static u32 FASTCALL OP_UND_THUMB(armcpu_t *cpu) -{ - execute = FALSE; - return 1; -} - -static u32 FASTCALL OP_LSL_0(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] = cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -static u32 FASTCALL OP_LSL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = (i>>6) & 0x1F; - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], 32-v); - cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] << v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -static u32 FASTCALL OP_LSR_0(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - // cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]); - cpu->R[REG_NUM(i, 0)] = 0; - cpu->CPSR.bits.N = 0; - cpu->CPSR.bits.Z = 1; - - return 2; -} - -static u32 FASTCALL OP_LSR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = (i>>6) & 0x1F; - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); - cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] >> v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -static u32 FASTCALL OP_ASR_0(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]); - cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 3)])*0xFFFFFFFF; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -static u32 FASTCALL OP_ASR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = (i>>6) & 0x1F; - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], v-1); - cpu->R[REG_NUM(i, 0)] = (((s32)cpu->R[REG_NUM(i, 3)]) >> v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -static u32 FASTCALL OP_ADD_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - u32 b = cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = a + b; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - - return 3; -} - -static u32 FASTCALL OP_SUB_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - u32 b = cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = a - b; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - - return 3; -} - -static u32 FASTCALL OP_ADD_IMM3(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - cpu->R[REG_NUM(i, 0)] = a + REG_NUM(i, 6); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - - return 2; -} - -static u32 FASTCALL OP_SUB_IMM3(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - cpu->R[REG_NUM(i, 0)] = a - REG_NUM(i, 6); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - - return 2; -} - -static u32 FASTCALL OP_MOV_IMM8(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 8)] = i & 0xFF; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 8)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 8)] == 0; - - return 2; -} - -static u32 FASTCALL OP_CMP_IMM8(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - - return 2; -} - -static u32 FASTCALL OP_ADD_IMM8(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 8)] + (i & 0xFF); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->R[REG_NUM(i, 8)] = tmp; - - return 2; -} - -static u32 FASTCALL OP_SUB_IMM8(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->R[REG_NUM(i, 8)] = tmp; - - return 2; -} - -static u32 FASTCALL OP_AND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] &= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_EOR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] ^= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_LSL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(!v) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v<32) - { - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], 32-v); - cpu->R[REG_NUM(i, 0)] <<= v; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v==32) - cpu->CPSR.bits.C = BIT0(cpu->R[REG_NUM(i, 0)]); - else - cpu->CPSR.bits.C = 0; - cpu->R[REG_NUM(i, 0)] = 0; - cpu->CPSR.bits.N = 0; - cpu->CPSR.bits.Z = 1; - - return 3; -} - -static u32 FASTCALL OP_LSR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(!v) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v<32) - { - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); - cpu->R[REG_NUM(i, 0)] >>= v; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v==32) - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - else - cpu->CPSR.bits.C = 0; - cpu->R[REG_NUM(i, 0)] = 0; - cpu->CPSR.bits.N = 0; - cpu->CPSR.bits.Z = 1; - - return 3; -} - -static u32 FASTCALL OP_ASR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(!v) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v<32) - { - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); - cpu->R[REG_NUM(i, 0)] = (u32)(((s32)cpu->R[REG_NUM(i, 0)]) >> v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 0)])*0xFFFFFFFF; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_ADC_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 0)]; - u32 b = cpu->R[REG_NUM(i, 3)]; - u32 tmp = b + cpu->CPSR.bits.C; - u32 res = a + tmp; - - cpu->R[REG_NUM(i, 0)] = res; - - cpu->CPSR.bits.N = BIT31(res); - cpu->CPSR.bits.Z = res == 0; - - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(b, cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(tmp, a, res); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(b, cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(tmp, a, res); - - return 3; -} - -static u32 FASTCALL OP_SBC_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 0)]; - u32 b = cpu->R[REG_NUM(i, 3)]; - u32 tmp = a - (!cpu->CPSR.bits.C); - u32 res = tmp - b; - cpu->R[REG_NUM(i, 0)] = res; - - cpu->CPSR.bits.N = BIT31(res); - cpu->CPSR.bits.Z = res == 0; - - cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(a, !cpu->CPSR.bits.C, tmp)) & (!UNSIGNED_OVERFLOW(tmp, b, res)); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, !cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(tmp, b, res); - - return 3; -} - -static u32 FASTCALL OP_ROR_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(v == 0) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - v &= 0xF; - if(v == 0) - { - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); - cpu->R[REG_NUM(i, 0)] = ROR(cpu->R[REG_NUM(i, 0)], v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_TST(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 0)] & cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - - return 3; -} - -static u32 FASTCALL OP_NEG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - cpu->R[REG_NUM(i, 0)] = -((signed int)a); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(0, a, cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(0, a, cpu->R[REG_NUM(i, 0)]); - - return 3; -} - -static u32 FASTCALL OP_CMP(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 0)] -cpu->R[REG_NUM(i, 3)]; - - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - - return 3; -} - -static u32 FASTCALL OP_CMN(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 0)] + cpu->R[REG_NUM(i, 3)]; - - //execute = FALSE; - //log::ajouter("OP_CMN THUMB"); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - - return 3; -} - -static u32 FASTCALL OP_ORR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] |= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_MUL_REG(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] *= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_BIC(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] &= (~cpu->R[REG_NUM(i, 3)]); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_MVN(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] = (~cpu->R[REG_NUM(i, 3)]); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -static u32 FASTCALL OP_ADD_SPE(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 Rd = (i&7) | ((i>>4)&8); - cpu->R[Rd] += cpu->R[REG_POS(i, 3)]; - - if(Rd==15) - cpu->next_instruction = cpu->R[15]; - - return 2; -} - -static u32 FASTCALL OP_CMP_SPE(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 Rn = (i&7) | ((i>>4)&8); - u32 tmp = cpu->R[Rn] -cpu->R[REG_POS(i, 3)]; - - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp); - - return 3; -} - -static u32 FASTCALL OP_MOV_SPE(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 Rd = (i&7) | ((i>>4)&8); - cpu->R[Rd] = cpu->R[REG_POS(i, 3)]; - - if(Rd==15) - cpu->next_instruction = cpu->R[15]; - - return 2; -} - -static u32 FASTCALL OP_BX_THUMB(armcpu_t *cpu) -{ - u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)]; - - cpu->CPSR.bits.T = BIT0(Rm); - cpu->R[15] = (Rm & 0xFFFFFFFE); - cpu->next_instruction = cpu->R[15]; - - return 3; -} - -static u32 FASTCALL OP_BLX_THUMB(armcpu_t *cpu) -{ - u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)]; - - cpu->CPSR.bits.T = BIT0(Rm); - cpu->R[14] = cpu->next_instruction | 1; - cpu->R[15] = (Rm & 0xFFFFFFFE); - cpu->next_instruction = cpu->R[15]; - - return 3; -} - -static u32 FASTCALL OP_LDR_PCREL(armcpu_t *cpu) -{ - u32 adr = (cpu->R[15]&0xFFFFFFFC) + ((cpu->instruction&0xFF)<<2); - - cpu->R[REG_NUM(cpu->instruction, 8)] = READ32(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 6)] + cpu->R[REG_NUM(i, 3)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - WRITE16(cpu->mem_if->data, adr, ((u16)cpu->R[REG_NUM(i, 0)])); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - WRITE8(cpu->mem_if->data, adr, ((u8)cpu->R[REG_NUM(i, 0)])); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSB_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = (cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]); - u32 tempValue = READ32(cpu->mem_if->data, adr&0xFFFFFFFC); - - adr = (adr&3)*8; - tempValue = (tempValue>>adr) | (tempValue<<(32-adr)); - cpu->R[REG_NUM(i, 0)] = tempValue; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (u32)READ8(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRSH_REG_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C); - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C); - u32 tempValue = READ32(cpu->mem_if->data, adr&0xFFFFFFFC); - adr = (adr&3)*8; - tempValue = (tempValue>>adr) | (tempValue<<(32-adr)); - cpu->R[REG_NUM(i, 0)] = tempValue; - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRB_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F); - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRB_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F); - cpu->R[REG_NUM(i, 0)] = READ8(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STRH_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E); - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDRH_IMM_OFF(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E); - cpu->R[REG_NUM(i, 0)] = READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_STR_SPREL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[13] + ((i&0xFF)<<2); - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 8)]); - - return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_LDR_SPREL(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[13] + ((i&0xFF)<<2); - cpu->R[REG_NUM(i, 8)] = READ32(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; -} - -static u32 FASTCALL OP_ADD_2PC(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 8)] = (cpu->R[15]&0xFFFFFFFC) + ((i&0xFF)<<2); - - return 5; -} - -static u32 FASTCALL OP_ADD_2SP(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[REG_NUM(i, 8)] = cpu->R[13] + ((i&0xFF)<<2); - - return 2; -} - -static u32 FASTCALL OP_ADJUST_P_SP(armcpu_t *cpu) -{ - cpu->R[13] += ((cpu->instruction&0x7F)<<2); - - return 1; -} - -static u32 FASTCALL OP_ADJUST_M_SP(armcpu_t *cpu) -{ - cpu->R[13] -= ((cpu->instruction&0x7F)<<2); - - return 1; -} - -static u32 FASTCALL OP_PUSH(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[13] - 4; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, 7-j)) - { - WRITE32(cpu->mem_if->data, adr, cpu->R[7-j]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - adr -= 4; - } - cpu->R[13] = adr + 4; - - return c + 3; -} - -static u32 FASTCALL OP_PUSH_LR(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[13] - 4; - u32 c = 0, j; - - WRITE32(cpu->mem_if->data, adr, cpu->R[14]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - adr -= 4; - - for(j = 0; j<8; ++j) - if(BIT_N(i, 7-j)) - { - WRITE32(cpu->mem_if->data, adr, cpu->R[7-j]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - adr -= 4; - } - cpu->R[13] = adr + 4; - - return c + 4; -} - -static u32 FASTCALL OP_POP(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[13]; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - cpu->R[j] = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - adr += 4; - } - cpu->R[13] = adr; - - return c + 2; -} - -static u32 FASTCALL OP_POP_PC(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[13]; - u32 c = 0, j; - u32 v; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - cpu->R[j] = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - adr += 4; - } - - v = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - cpu->R[15] = v & 0xFFFFFFFE; - cpu->next_instruction = v & 0xFFFFFFFE; - if(cpu->proc_ID==0) - cpu->CPSR.bits.T = BIT0(v); - adr += 4; - - cpu->R[13] = adr; - return c + 5; -} - -static u32 FASTCALL OP_BKPT_THUMB(armcpu_t *cpu) -{ - return 1; -} - -static u32 FASTCALL OP_STMIA_THUMB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 8)]; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - WRITE32(cpu->mem_if->data, adr, cpu->R[j]); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - adr += 4; - } - cpu->R[REG_NUM(i, 8)] = adr; - return c + 2; -} - -static u32 FASTCALL OP_LDMIA_THUMB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 8)]; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - cpu->R[j] = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; - adr += 4; - } - cpu->R[REG_NUM(i, 8)] = adr; - return c + 3; -} - -static u32 FASTCALL OP_B_COND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - if(!TEST_COND((i>>8)&0xF, 0, cpu->CPSR)) - return 1; - - cpu->R[15] += ((s32)((s8)(i&0xFF)))<<1; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -static u32 FASTCALL OP_SWI_THUMB(armcpu_t *cpu) -{ - if (((cpu->intVector != 0) ^ (cpu->proc_ID == ARMCPU_ARM9))) - { - /* we use an irq thats not in the irq tab, as - it was replaced duie to a changed intVector */ - Status_Reg tmp = cpu->CPSR; - armcpu_switchMode(cpu, SVC); /* enter svc mode */ - cpu->R[14] = cpu->R[15] - 4; /* jump to swi Vector */ - cpu->SPSR = tmp; /* save old CPSR as new SPSR */ - cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ - cpu->CPSR.bits.I = cpu->SPSR.bits.I; /* keep int disable flag */ - cpu->R[15] = cpu->intVector + 0x08; - cpu->next_instruction = cpu->R[15]; - return 3; - } - else - { - u32 swinum = cpu->instruction & 0xFF; - return cpu->swi_tab[swinum](cpu) + 3; - } - //return 3; -} - -#define SIGNEEXT_IMM11(i) (((i)&0x7FF) | (BIT10(i) * 0xFFFFF800)) - -static u32 FASTCALL OP_B_UNCOND(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[15] += (SIGNEEXT_IMM11(i)<<1); - cpu->next_instruction = cpu->R[15]; - return 3; -} - -static u32 FASTCALL OP_BLX(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1))&0xFFFFFFFC; - cpu->R[14] = cpu->next_instruction | 1; - cpu->next_instruction = cpu->R[15]; - cpu->CPSR.bits.T = 0; - return 3; -} - -static u32 FASTCALL OP_BL_10(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[14] = cpu->R[15] + (SIGNEEXT_IMM11(i)<<12); - return 1; -} - -static u32 FASTCALL OP_BL_THUMB(armcpu_t *cpu) -{ - u32 i = cpu->instruction; - cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1)); - cpu->R[14] = cpu->next_instruction | 1; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -#define TYPE_RETOUR u32 -#define CALLTYPE FASTCALL -#define PARAMETRES armcpu_t *cpu -#define NOM_THUMB_TAB thumb_instructions_set - -#include "thumb_tabdef.inc" diff --git a/tools/vio2sf/src/vio2sf/desmume/thumb_instructions.h b/tools/vio2sf/src/vio2sf/desmume/thumb_instructions.h deleted file mode 100644 index 27088a6e3..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/thumb_instructions.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef THUMB_INSTRUCTIONS_H -#define THUMB_INSTRUCTIONS_H - -#include "armcpu.h" - -extern u32 (FASTCALL* thumb_instructions_set[1024])(armcpu_t * cpu); - -#endif - diff --git a/tools/vio2sf/src/vio2sf/desmume/thumb_tabdef.inc b/tools/vio2sf/src/vio2sf/desmume/thumb_tabdef.inc deleted file mode 100644 index 1a9c53b03..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/thumb_tabdef.inc +++ /dev/null @@ -1,1111 +0,0 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -TYPE_RETOUR (* CALLTYPE NOM_THUMB_TAB[1024])(PARAMETRES)={ - OP_LSL_0, //00 0000 0000 - OP_LSL, //00 0000 0001 - OP_LSL, //00 0000 0010 - OP_LSL, //00 0000 0011 - OP_LSL, //00 0000 0100 - OP_LSL, //00 0000 0101 - OP_LSL, //00 0000 0110 - OP_LSL, //00 0000 0111 - OP_LSL, //00 0000 1000 - OP_LSL, //00 0000 1001 - OP_LSL, //00 0000 1010 - OP_LSL, //00 0000 1011 - OP_LSL, //00 0000 1100 - OP_LSL, //00 0000 1101 - OP_LSL, //00 0000 1110 - OP_LSL, //00 0000 1111 - - OP_LSL, //00 0001 0000 - OP_LSL, //00 0001 0001 - OP_LSL, //00 0001 0010 - OP_LSL, //00 0001 0011 - OP_LSL, //00 0001 0100 - OP_LSL, //00 0001 0101 - OP_LSL, //00 0001 0110 - OP_LSL, //00 0001 0111 - OP_LSL, //00 0001 1000 - OP_LSL, //00 0001 1001 - OP_LSL, //00 0001 1010 - OP_LSL, //00 0001 1011 - OP_LSL, //00 0001 1100 - OP_LSL, //00 0001 1101 - OP_LSL, //00 0001 1110 - OP_LSL, //00 0001 1111 - - OP_LSR_0, //00 0010 0000 - OP_LSR, //00 0010 0001 - OP_LSR, //00 0010 0010 - OP_LSR, //00 0010 0011 - OP_LSR, //00 0010 0100 - OP_LSR, //00 0010 0101 - OP_LSR, //00 0010 0110 - OP_LSR, //00 0010 0111 - OP_LSR, //00 0010 1000 - OP_LSR, //00 0010 1001 - OP_LSR, //00 0010 1010 - OP_LSR, //00 0010 1011 - OP_LSR, //00 0010 1100 - OP_LSR, //00 0010 1101 - OP_LSR, //00 0010 1110 - OP_LSR, //00 0010 1111 - - OP_LSR, //00 0011 0000 - OP_LSR, //00 0011 0001 - OP_LSR, //00 0011 0010 - OP_LSR, //00 0011 0011 - OP_LSR, //00 0011 0100 - OP_LSR, //00 0011 0101 - OP_LSR, //00 0011 0110 - OP_LSR, //00 0011 0111 - OP_LSR, //00 0011 1000 - OP_LSR, //00 0011 1001 - OP_LSR, //00 0011 1010 - OP_LSR, //00 0011 1011 - OP_LSR, //00 0011 1100 - OP_LSR, //00 0011 1101 - OP_LSR, //00 0011 1110 - OP_LSR, //00 0011 1111 - - OP_ASR_0, //00 0100 0000 - OP_ASR, //00 0100 0001 - OP_ASR, //00 0100 0010 - OP_ASR, //00 0100 0011 - OP_ASR, //00 0100 0100 - OP_ASR, //00 0100 0101 - OP_ASR, //00 0100 0110 - OP_ASR, //00 0100 0111 - OP_ASR, //00 0100 1000 - OP_ASR, //00 0100 1001 - OP_ASR, //00 0100 1010 - OP_ASR, //00 0100 1011 - OP_ASR, //00 0100 1100 - OP_ASR, //00 0100 1101 - OP_ASR, //00 0100 1110 - OP_ASR, //00 0100 1111 - - OP_ASR, //00 0101 0000 - OP_ASR, //00 0101 0001 - OP_ASR, //00 0101 0010 - OP_ASR, //00 0101 0011 - OP_ASR, //00 0101 0100 - OP_ASR, //00 0101 0101 - OP_ASR, //00 0101 0110 - OP_ASR, //00 0101 0111 - OP_ASR, //00 0101 1000 - OP_ASR, //00 0101 1001 - OP_ASR, //00 0101 1010 - OP_ASR, //00 0101 1011 - OP_ASR, //00 0101 1100 - OP_ASR, //00 0101 1101 - OP_ASR, //00 0101 1110 - OP_ASR, //00 0101 1111 - - OP_ADD_REG, //00 0110 0000 - OP_ADD_REG, //00 0110 0001 - OP_ADD_REG, //00 0110 0010 - OP_ADD_REG, //00 0110 0011 - OP_ADD_REG, //00 0110 0100 - OP_ADD_REG, //00 0110 0101 - OP_ADD_REG, //00 0110 0110 - OP_ADD_REG, //00 0110 0111 - OP_SUB_REG, //00 0110 1000 - OP_SUB_REG, //00 0110 1001 - OP_SUB_REG, //00 0110 1010 - OP_SUB_REG, //00 0110 1011 - OP_SUB_REG, //00 0110 1100 - OP_SUB_REG, //00 0110 1101 - OP_SUB_REG, //00 0110 1110 - OP_SUB_REG, //00 0110 1111 - - OP_ADD_IMM3, //00 0111 0000 - OP_ADD_IMM3, //00 0111 0001 - OP_ADD_IMM3, //00 0111 0010 - OP_ADD_IMM3, //00 0111 0011 - OP_ADD_IMM3, //00 0111 0100 - OP_ADD_IMM3, //00 0111 0101 - OP_ADD_IMM3, //00 0111 0110 - OP_ADD_IMM3, //00 0111 0111 - OP_SUB_IMM3, //00 0111 1000 - OP_SUB_IMM3, //00 0111 1001 - OP_SUB_IMM3, //00 0111 1010 - OP_SUB_IMM3, //00 0111 1011 - OP_SUB_IMM3, //00 0111 1100 - OP_SUB_IMM3, //00 0111 1101 - OP_SUB_IMM3, //00 0111 1110 - OP_SUB_IMM3, //00 0111 1111 - - OP_MOV_IMM8, //00 1000 0000 - OP_MOV_IMM8, //00 1000 0001 - OP_MOV_IMM8, //00 1000 0010 - OP_MOV_IMM8, //00 1000 0011 - OP_MOV_IMM8, //00 1000 0100 - OP_MOV_IMM8, //00 1000 0101 - OP_MOV_IMM8, //00 1000 0110 - OP_MOV_IMM8, //00 1000 0111 - OP_MOV_IMM8, //00 1000 1000 - OP_MOV_IMM8, //00 1000 1001 - OP_MOV_IMM8, //00 1000 1010 - OP_MOV_IMM8, //00 1000 1011 - OP_MOV_IMM8, //00 1000 1100 - OP_MOV_IMM8, //00 1000 1101 - OP_MOV_IMM8, //00 1000 1110 - OP_MOV_IMM8, //00 1000 1111 - - OP_MOV_IMM8, //00 1001 0000 - OP_MOV_IMM8, //00 1001 0001 - OP_MOV_IMM8, //00 1001 0010 - OP_MOV_IMM8, //00 1001 0011 - OP_MOV_IMM8, //00 1001 0100 - OP_MOV_IMM8, //00 1001 0101 - OP_MOV_IMM8, //00 1001 0110 - OP_MOV_IMM8, //00 1001 0111 - OP_MOV_IMM8, //00 1001 1000 - OP_MOV_IMM8, //00 1001 1001 - OP_MOV_IMM8, //00 1001 1010 - OP_MOV_IMM8, //00 1001 1011 - OP_MOV_IMM8, //00 1001 1100 - OP_MOV_IMM8, //00 1001 1101 - OP_MOV_IMM8, //00 1001 1110 - OP_MOV_IMM8, //00 1001 1111 - - OP_CMP_IMM8, //00 1010 0000 - OP_CMP_IMM8, //00 1010 0001 - OP_CMP_IMM8, //00 1010 0010 - OP_CMP_IMM8, //00 1010 0011 - OP_CMP_IMM8, //00 1010 0100 - OP_CMP_IMM8, //00 1010 0101 - OP_CMP_IMM8, //00 1010 0110 - OP_CMP_IMM8, //00 1010 0111 - OP_CMP_IMM8, //00 1010 1000 - OP_CMP_IMM8, //00 1010 1001 - OP_CMP_IMM8, //00 1010 1010 - OP_CMP_IMM8, //00 1010 1011 - OP_CMP_IMM8, //00 1010 1100 - OP_CMP_IMM8, //00 1010 1101 - OP_CMP_IMM8, //00 1010 1110 - OP_CMP_IMM8, //00 1010 1111 - - OP_CMP_IMM8, //00 1011 0000 - OP_CMP_IMM8, //00 1011 0001 - OP_CMP_IMM8, //00 1011 0010 - OP_CMP_IMM8, //00 1011 0011 - OP_CMP_IMM8, //00 1011 0100 - OP_CMP_IMM8, //00 1011 0101 - OP_CMP_IMM8, //00 1011 0110 - OP_CMP_IMM8, //00 1011 0111 - OP_CMP_IMM8, //00 1011 1000 - OP_CMP_IMM8, //00 1011 1001 - OP_CMP_IMM8, //00 1011 1010 - OP_CMP_IMM8, //00 1011 1011 - OP_CMP_IMM8, //00 1011 1100 - OP_CMP_IMM8, //00 1011 1101 - OP_CMP_IMM8, //00 1011 1110 - OP_CMP_IMM8, //00 1011 1111 - - OP_ADD_IMM8, //00 1100 0000 - OP_ADD_IMM8, //00 1100 0001 - OP_ADD_IMM8, //00 1100 0010 - OP_ADD_IMM8, //00 1100 0011 - OP_ADD_IMM8, //00 1100 0100 - OP_ADD_IMM8, //00 1100 0101 - OP_ADD_IMM8, //00 1100 0110 - OP_ADD_IMM8, //00 1100 0111 - OP_ADD_IMM8, //00 1100 1000 - OP_ADD_IMM8, //00 1100 1001 - OP_ADD_IMM8, //00 1100 1010 - OP_ADD_IMM8, //00 1100 1011 - OP_ADD_IMM8, //00 1100 1100 - OP_ADD_IMM8, //00 1100 1101 - OP_ADD_IMM8, //00 1100 1110 - OP_ADD_IMM8, //00 1100 1111 - - OP_ADD_IMM8, //00 1101 0000 - OP_ADD_IMM8, //00 1101 0001 - OP_ADD_IMM8, //00 1101 0010 - OP_ADD_IMM8, //00 1101 0011 - OP_ADD_IMM8, //00 1101 0100 - OP_ADD_IMM8, //00 1101 0101 - OP_ADD_IMM8, //00 1101 0110 - OP_ADD_IMM8, //00 1101 0111 - OP_ADD_IMM8, //00 1101 1000 - OP_ADD_IMM8, //00 1101 1001 - OP_ADD_IMM8, //00 1101 1010 - OP_ADD_IMM8, //00 1101 1011 - OP_ADD_IMM8, //00 1101 1100 - OP_ADD_IMM8, //00 1101 1101 - OP_ADD_IMM8, //00 1101 1110 - OP_ADD_IMM8, //00 1101 1111 - - OP_SUB_IMM8, //00 1110 0000 - OP_SUB_IMM8, //00 1110 0001 - OP_SUB_IMM8, //00 1110 0010 - OP_SUB_IMM8, //00 1110 0011 - OP_SUB_IMM8, //00 1110 0100 - OP_SUB_IMM8, //00 1110 0101 - OP_SUB_IMM8, //00 1110 0110 - OP_SUB_IMM8, //00 1110 0111 - OP_SUB_IMM8, //00 1110 1000 - OP_SUB_IMM8, //00 1110 1001 - OP_SUB_IMM8, //00 1110 1010 - OP_SUB_IMM8, //00 1110 1011 - OP_SUB_IMM8, //00 1110 1100 - OP_SUB_IMM8, //00 1110 1101 - OP_SUB_IMM8, //00 1110 1110 - OP_SUB_IMM8, //00 1110 1111 - - OP_SUB_IMM8, //00 1111 0000 - OP_SUB_IMM8, //00 1111 0001 - OP_SUB_IMM8, //00 1111 0010 - OP_SUB_IMM8, //00 1111 0011 - OP_SUB_IMM8, //00 1111 0100 - OP_SUB_IMM8, //00 1111 0101 - OP_SUB_IMM8, //00 1111 0110 - OP_SUB_IMM8, //00 1111 0111 - OP_SUB_IMM8, //00 1111 1000 - OP_SUB_IMM8, //00 1111 1001 - OP_SUB_IMM8, //00 1111 1010 - OP_SUB_IMM8, //00 1111 1011 - OP_SUB_IMM8, //00 1111 1100 - OP_SUB_IMM8, //00 1111 1101 - OP_SUB_IMM8, //00 1111 1110 - OP_SUB_IMM8, //00 1111 1111 - - OP_AND, //01 0000 0000 - OP_EOR, //01 0000 0001 - OP_LSL_REG, //01 0000 0010 - OP_LSR_REG, //01 0000 0011 - OP_ASR_REG, //01 0000 0100 - OP_ADC_REG, //01 0000 0101 - OP_SBC_REG, //01 0000 0110 - OP_ROR_REG, //01 0000 0111 - OP_TST, //01 0000 1000 - OP_NEG, //01 0000 1001 - OP_CMP, //01 0000 1010 - OP_CMN, //01 0000 1011 - OP_ORR, //01 0000 1100 - OP_MUL_REG, //01 0000 1101 - OP_BIC, //01 0000 1110 - OP_MVN, //01 0000 1111 - - OP_ADD_SPE, //01 0001 0000 - OP_ADD_SPE, //01 0001 0001 - OP_ADD_SPE, //01 0001 0010 - OP_ADD_SPE, //01 0001 0011 - OP_CMP_SPE, //01 0001 0100 - OP_CMP_SPE, //01 0001 0101 - OP_CMP_SPE, //01 0001 0110 - OP_CMP_SPE, //01 0001 0111 - OP_MOV_SPE, //01 0001 1000 - OP_MOV_SPE, //01 0001 1001 - OP_MOV_SPE, //01 0001 1010 - OP_MOV_SPE, //01 0001 1011 - OP_BX_THUMB, //01 0001 1100 - OP_BX_THUMB, //01 0001 1101 - OP_BLX_THUMB, //01 0001 1110 - OP_BLX_THUMB, //01 0001 1111 - - OP_LDR_PCREL, //01 0010 0000 - OP_LDR_PCREL, //01 0010 0001 - OP_LDR_PCREL, //01 0010 0010 - OP_LDR_PCREL, //01 0010 0011 - OP_LDR_PCREL, //01 0010 0100 - OP_LDR_PCREL, //01 0010 0101 - OP_LDR_PCREL, //01 0010 0110 - OP_LDR_PCREL, //01 0010 0111 - OP_LDR_PCREL, //01 0010 1000 - OP_LDR_PCREL, //01 0010 1001 - OP_LDR_PCREL, //01 0010 1010 - OP_LDR_PCREL, //01 0010 1011 - OP_LDR_PCREL, //01 0010 1100 - OP_LDR_PCREL, //01 0010 1101 - OP_LDR_PCREL, //01 0010 1110 - OP_LDR_PCREL, //01 0010 1111 - - OP_LDR_PCREL, //01 0011 0000 - OP_LDR_PCREL, //01 0011 0001 - OP_LDR_PCREL, //01 0011 0010 - OP_LDR_PCREL, //01 0011 0011 - OP_LDR_PCREL, //01 0011 0100 - OP_LDR_PCREL, //01 0011 0101 - OP_LDR_PCREL, //01 0011 0110 - OP_LDR_PCREL, //01 0011 0111 - OP_LDR_PCREL, //01 0011 1000 - OP_LDR_PCREL, //01 0011 1001 - OP_LDR_PCREL, //01 0011 1010 - OP_LDR_PCREL, //01 0011 1011 - OP_LDR_PCREL, //01 0011 1100 - OP_LDR_PCREL, //01 0011 1101 - OP_LDR_PCREL, //01 0011 1110 - OP_LDR_PCREL, //01 0011 1111 - - OP_STR_REG_OFF, //01 0100 0000 - OP_STR_REG_OFF, //01 0100 0001 - OP_STR_REG_OFF, //01 0100 0010 - OP_STR_REG_OFF, //01 0100 0011 - OP_STR_REG_OFF, //01 0100 0100 - OP_STR_REG_OFF, //01 0100 0101 - OP_STR_REG_OFF, //01 0100 0110 - OP_STR_REG_OFF, //01 0100 0111 - OP_STRH_REG_OFF, //01 0100 1000 - OP_STRH_REG_OFF, //01 0100 1001 - OP_STRH_REG_OFF, //01 0100 1010 - OP_STRH_REG_OFF, //01 0100 1011 - OP_STRH_REG_OFF, //01 0100 1100 - OP_STRH_REG_OFF, //01 0100 1101 - OP_STRH_REG_OFF, //01 0100 1110 - OP_STRH_REG_OFF, //01 0100 1111 - - OP_STRB_REG_OFF, //01 0101 0000 - OP_STRB_REG_OFF, //01 0101 0001 - OP_STRB_REG_OFF, //01 0101 0010 - OP_STRB_REG_OFF, //01 0101 0011 - OP_STRB_REG_OFF, //01 0101 0100 - OP_STRB_REG_OFF, //01 0101 0101 - OP_STRB_REG_OFF, //01 0101 0110 - OP_STRB_REG_OFF, //01 0101 0111 - OP_LDRSB_REG_OFF, //01 0101 1000 - OP_LDRSB_REG_OFF, //01 0101 1001 - OP_LDRSB_REG_OFF, //01 0101 1010 - OP_LDRSB_REG_OFF, //01 0101 1011 - OP_LDRSB_REG_OFF, //01 0101 1100 - OP_LDRSB_REG_OFF, //01 0101 1101 - OP_LDRSB_REG_OFF, //01 0101 1110 - OP_LDRSB_REG_OFF, //01 0101 1111 - - OP_LDR_REG_OFF, //01 0110 0000 - OP_LDR_REG_OFF, //01 0110 0001 - OP_LDR_REG_OFF, //01 0110 0010 - OP_LDR_REG_OFF, //01 0110 0011 - OP_LDR_REG_OFF, //01 0110 0100 - OP_LDR_REG_OFF, //01 0110 0101 - OP_LDR_REG_OFF, //01 0110 0110 - OP_LDR_REG_OFF, //01 0110 0111 - OP_LDRH_REG_OFF, //01 0110 1000 - OP_LDRH_REG_OFF, //01 0110 1001 - OP_LDRH_REG_OFF, //01 0110 1010 - OP_LDRH_REG_OFF, //01 0110 1011 - OP_LDRH_REG_OFF, //01 0110 1100 - OP_LDRH_REG_OFF, //01 0110 1101 - OP_LDRH_REG_OFF, //01 0110 1110 - OP_LDRH_REG_OFF, //01 0110 1111 - - OP_LDRB_REG_OFF, //01 0111 0000 - OP_LDRB_REG_OFF, //01 0111 0001 - OP_LDRB_REG_OFF, //01 0111 0010 - OP_LDRB_REG_OFF, //01 0111 0011 - OP_LDRB_REG_OFF, //01 0111 0100 - OP_LDRB_REG_OFF, //01 0111 0101 - OP_LDRB_REG_OFF, //01 0111 0110 - OP_LDRB_REG_OFF, //01 0111 0111 - OP_LDRSH_REG_OFF, //01 0111 1000 - OP_LDRSH_REG_OFF, //01 0111 1001 - OP_LDRSH_REG_OFF, //01 0111 1010 - OP_LDRSH_REG_OFF, //01 0111 1011 - OP_LDRSH_REG_OFF, //01 0111 1100 - OP_LDRSH_REG_OFF, //01 0111 1101 - OP_LDRSH_REG_OFF, //01 0111 1110 - OP_LDRSH_REG_OFF, //01 0111 1111 - - OP_STR_IMM_OFF, //01 1000 0000 - OP_STR_IMM_OFF, //01 1000 0001 - OP_STR_IMM_OFF, //01 1000 0010 - OP_STR_IMM_OFF, //01 1000 0011 - OP_STR_IMM_OFF, //01 1000 0100 - OP_STR_IMM_OFF, //01 1000 0101 - OP_STR_IMM_OFF, //01 1000 0110 - OP_STR_IMM_OFF, //01 1000 0111 - OP_STR_IMM_OFF, //01 1000 1000 - OP_STR_IMM_OFF, //01 1000 1001 - OP_STR_IMM_OFF, //01 1000 1010 - OP_STR_IMM_OFF, //01 1000 1011 - OP_STR_IMM_OFF, //01 1000 1100 - OP_STR_IMM_OFF, //01 1000 1101 - OP_STR_IMM_OFF, //01 1000 1110 - OP_STR_IMM_OFF, //01 1000 1111 - - OP_STR_IMM_OFF, //01 1001 0000 - OP_STR_IMM_OFF, //01 1001 0001 - OP_STR_IMM_OFF, //01 1001 0010 - OP_STR_IMM_OFF, //01 1001 0011 - OP_STR_IMM_OFF, //01 1001 0100 - OP_STR_IMM_OFF, //01 1001 0101 - OP_STR_IMM_OFF, //01 1001 0110 - OP_STR_IMM_OFF, //01 1001 0111 - OP_STR_IMM_OFF, //01 1001 1000 - OP_STR_IMM_OFF, //01 1001 1001 - OP_STR_IMM_OFF, //01 1001 1010 - OP_STR_IMM_OFF, //01 1001 1011 - OP_STR_IMM_OFF, //01 1001 1100 - OP_STR_IMM_OFF, //01 1001 1101 - OP_STR_IMM_OFF, //01 1001 1110 - OP_STR_IMM_OFF, //01 1001 1111 - - OP_LDR_IMM_OFF, //01 1010 0000 - OP_LDR_IMM_OFF, //01 1010 0001 - OP_LDR_IMM_OFF, //01 1010 0010 - OP_LDR_IMM_OFF, //01 1010 0011 - OP_LDR_IMM_OFF, //01 1010 0100 - OP_LDR_IMM_OFF, //01 1010 0101 - OP_LDR_IMM_OFF, //01 1010 0110 - OP_LDR_IMM_OFF, //01 1010 0111 - OP_LDR_IMM_OFF, //01 1010 1000 - OP_LDR_IMM_OFF, //01 1010 1001 - OP_LDR_IMM_OFF, //01 1010 1010 - OP_LDR_IMM_OFF, //01 1010 1011 - OP_LDR_IMM_OFF, //01 1010 1100 - OP_LDR_IMM_OFF, //01 1010 1101 - OP_LDR_IMM_OFF, //01 1010 1110 - OP_LDR_IMM_OFF, //01 1010 1111 - - OP_LDR_IMM_OFF, //01 1011 0000 - OP_LDR_IMM_OFF, //01 1011 0001 - OP_LDR_IMM_OFF, //01 1011 0010 - OP_LDR_IMM_OFF, //01 1011 0011 - OP_LDR_IMM_OFF, //01 1011 0100 - OP_LDR_IMM_OFF, //01 1011 0101 - OP_LDR_IMM_OFF, //01 1011 0110 - OP_LDR_IMM_OFF, //01 1011 0111 - OP_LDR_IMM_OFF, //01 1011 1000 - OP_LDR_IMM_OFF, //01 1011 1001 - OP_LDR_IMM_OFF, //01 1011 1010 - OP_LDR_IMM_OFF, //01 1011 1011 - OP_LDR_IMM_OFF, //01 1011 1100 - OP_LDR_IMM_OFF, //01 1011 1101 - OP_LDR_IMM_OFF, //01 1011 1110 - OP_LDR_IMM_OFF, //01 1011 1111 - - OP_STRB_IMM_OFF, //01 1100 0000 - OP_STRB_IMM_OFF, //01 1100 0001 - OP_STRB_IMM_OFF, //01 1100 0010 - OP_STRB_IMM_OFF, //01 1100 0011 - OP_STRB_IMM_OFF, //01 1100 0100 - OP_STRB_IMM_OFF, //01 1100 0101 - OP_STRB_IMM_OFF, //01 1100 0110 - OP_STRB_IMM_OFF, //01 1100 0111 - OP_STRB_IMM_OFF, //01 1100 1000 - OP_STRB_IMM_OFF, //01 1100 1001 - OP_STRB_IMM_OFF, //01 1100 1010 - OP_STRB_IMM_OFF, //01 1100 1011 - OP_STRB_IMM_OFF, //01 1100 1100 - OP_STRB_IMM_OFF, //01 1100 1101 - OP_STRB_IMM_OFF, //01 1100 1110 - OP_STRB_IMM_OFF, //01 1100 1111 - - OP_STRB_IMM_OFF, //01 1101 0000 - OP_STRB_IMM_OFF, //01 1101 0001 - OP_STRB_IMM_OFF, //01 1101 0010 - OP_STRB_IMM_OFF, //01 1101 0011 - OP_STRB_IMM_OFF, //01 1101 0100 - OP_STRB_IMM_OFF, //01 1101 0101 - OP_STRB_IMM_OFF, //01 1101 0110 - OP_STRB_IMM_OFF, //01 1101 0111 - OP_STRB_IMM_OFF, //01 1101 1000 - OP_STRB_IMM_OFF, //01 1101 1001 - OP_STRB_IMM_OFF, //01 1101 1010 - OP_STRB_IMM_OFF, //01 1101 1011 - OP_STRB_IMM_OFF, //01 1101 1100 - OP_STRB_IMM_OFF, //01 1101 1101 - OP_STRB_IMM_OFF, //01 1101 1110 - OP_STRB_IMM_OFF, //01 1101 1111 - - OP_LDRB_IMM_OFF, //01 1110 0000 - OP_LDRB_IMM_OFF, //01 1110 0001 - OP_LDRB_IMM_OFF, //01 1110 0010 - OP_LDRB_IMM_OFF, //01 1110 0011 - OP_LDRB_IMM_OFF, //01 1110 0100 - OP_LDRB_IMM_OFF, //01 1110 0101 - OP_LDRB_IMM_OFF, //01 1110 0110 - OP_LDRB_IMM_OFF, //01 1110 0111 - OP_LDRB_IMM_OFF, //01 1110 1000 - OP_LDRB_IMM_OFF, //01 1110 1001 - OP_LDRB_IMM_OFF, //01 1110 1010 - OP_LDRB_IMM_OFF, //01 1110 1011 - OP_LDRB_IMM_OFF, //01 1110 1100 - OP_LDRB_IMM_OFF, //01 1110 1101 - OP_LDRB_IMM_OFF, //01 1110 1110 - OP_LDRB_IMM_OFF, //01 1110 1111 - - OP_LDRB_IMM_OFF, //01 1111 0000 - OP_LDRB_IMM_OFF, //01 1111 0001 - OP_LDRB_IMM_OFF, //01 1111 0010 - OP_LDRB_IMM_OFF, //01 1111 0011 - OP_LDRB_IMM_OFF, //01 1111 0100 - OP_LDRB_IMM_OFF, //01 1111 0101 - OP_LDRB_IMM_OFF, //01 1111 0110 - OP_LDRB_IMM_OFF, //01 1111 0111 - OP_LDRB_IMM_OFF, //01 1111 1000 - OP_LDRB_IMM_OFF, //01 1111 1001 - OP_LDRB_IMM_OFF, //01 1111 1010 - OP_LDRB_IMM_OFF, //01 1111 1011 - OP_LDRB_IMM_OFF, //01 1111 1100 - OP_LDRB_IMM_OFF, //01 1111 1101 - OP_LDRB_IMM_OFF, //01 1111 1110 - OP_LDRB_IMM_OFF, //01 1111 1111 - - OP_STRH_IMM_OFF, //10 0000 0000 - OP_STRH_IMM_OFF, //10 0000 0001 - OP_STRH_IMM_OFF, //10 0000 0010 - OP_STRH_IMM_OFF, //10 0000 0011 - OP_STRH_IMM_OFF, //10 0000 0100 - OP_STRH_IMM_OFF, //10 0000 0101 - OP_STRH_IMM_OFF, //10 0000 0110 - OP_STRH_IMM_OFF, //10 0000 0111 - OP_STRH_IMM_OFF, //10 0000 1000 - OP_STRH_IMM_OFF, //10 0000 1001 - OP_STRH_IMM_OFF, //10 0000 1010 - OP_STRH_IMM_OFF, //10 0000 1011 - OP_STRH_IMM_OFF, //10 0000 1100 - OP_STRH_IMM_OFF, //10 0000 1101 - OP_STRH_IMM_OFF, //10 0000 1110 - OP_STRH_IMM_OFF, //10 0000 1111 - - OP_STRH_IMM_OFF, //10 0001 0000 - OP_STRH_IMM_OFF, //10 0001 0001 - OP_STRH_IMM_OFF, //10 0001 0010 - OP_STRH_IMM_OFF, //10 0001 0011 - OP_STRH_IMM_OFF, //10 0001 0100 - OP_STRH_IMM_OFF, //10 0001 0101 - OP_STRH_IMM_OFF, //10 0001 0110 - OP_STRH_IMM_OFF, //10 0001 0111 - OP_STRH_IMM_OFF, //10 0001 1000 - OP_STRH_IMM_OFF, //10 0001 1001 - OP_STRH_IMM_OFF, //10 0001 1010 - OP_STRH_IMM_OFF, //10 0001 1011 - OP_STRH_IMM_OFF, //10 0001 1100 - OP_STRH_IMM_OFF, //10 0001 1101 - OP_STRH_IMM_OFF, //10 0001 1110 - OP_STRH_IMM_OFF, //10 0001 1111 - - OP_LDRH_IMM_OFF, //10 0010 0000 - OP_LDRH_IMM_OFF, //10 0010 0001 - OP_LDRH_IMM_OFF, //10 0010 0010 - OP_LDRH_IMM_OFF, //10 0010 0011 - OP_LDRH_IMM_OFF, //10 0010 0100 - OP_LDRH_IMM_OFF, //10 0010 0101 - OP_LDRH_IMM_OFF, //10 0010 0110 - OP_LDRH_IMM_OFF, //10 0010 0111 - OP_LDRH_IMM_OFF, //10 0010 1000 - OP_LDRH_IMM_OFF, //10 0010 1001 - OP_LDRH_IMM_OFF, //10 0010 1010 - OP_LDRH_IMM_OFF, //10 0010 1011 - OP_LDRH_IMM_OFF, //10 0010 1100 - OP_LDRH_IMM_OFF, //10 0010 1101 - OP_LDRH_IMM_OFF, //10 0010 1110 - OP_LDRH_IMM_OFF, //10 0010 1111 - - OP_LDRH_IMM_OFF, //10 0011 0000 - OP_LDRH_IMM_OFF, //10 0011 0001 - OP_LDRH_IMM_OFF, //10 0011 0010 - OP_LDRH_IMM_OFF, //10 0011 0011 - OP_LDRH_IMM_OFF, //10 0011 0100 - OP_LDRH_IMM_OFF, //10 0011 0101 - OP_LDRH_IMM_OFF, //10 0011 0110 - OP_LDRH_IMM_OFF, //10 0011 0111 - OP_LDRH_IMM_OFF, //10 0011 1000 - OP_LDRH_IMM_OFF, //10 0011 1001 - OP_LDRH_IMM_OFF, //10 0011 1010 - OP_LDRH_IMM_OFF, //10 0011 1011 - OP_LDRH_IMM_OFF, //10 0011 1100 - OP_LDRH_IMM_OFF, //10 0011 1101 - OP_LDRH_IMM_OFF, //10 0011 1110 - OP_LDRH_IMM_OFF, //10 0011 1111 - - OP_STR_SPREL, //10 0100 0000 - OP_STR_SPREL, //10 0100 0001 - OP_STR_SPREL, //10 0100 0010 - OP_STR_SPREL, //10 0100 0011 - OP_STR_SPREL, //10 0100 0100 - OP_STR_SPREL, //10 0100 0101 - OP_STR_SPREL, //10 0100 0110 - OP_STR_SPREL, //10 0100 0111 - OP_STR_SPREL, //10 0100 1000 - OP_STR_SPREL, //10 0100 1001 - OP_STR_SPREL, //10 0100 1010 - OP_STR_SPREL, //10 0100 1011 - OP_STR_SPREL, //10 0100 1100 - OP_STR_SPREL, //10 0100 1101 - OP_STR_SPREL, //10 0100 1110 - OP_STR_SPREL, //10 0100 1111 - - OP_STR_SPREL, //10 0101 0000 - OP_STR_SPREL, //10 0101 0001 - OP_STR_SPREL, //10 0101 0010 - OP_STR_SPREL, //10 0101 0011 - OP_STR_SPREL, //10 0101 0100 - OP_STR_SPREL, //10 0101 0101 - OP_STR_SPREL, //10 0101 0110 - OP_STR_SPREL, //10 0101 0111 - OP_STR_SPREL, //10 0101 1000 - OP_STR_SPREL, //10 0101 1001 - OP_STR_SPREL, //10 0101 1010 - OP_STR_SPREL, //10 0101 1011 - OP_STR_SPREL, //10 0101 1100 - OP_STR_SPREL, //10 0101 1101 - OP_STR_SPREL, //10 0101 1110 - OP_STR_SPREL, //10 0101 1111 - - OP_LDR_SPREL, //10 0110 0000 - OP_LDR_SPREL, //10 0110 0001 - OP_LDR_SPREL, //10 0110 0010 - OP_LDR_SPREL, //10 0110 0011 - OP_LDR_SPREL, //10 0110 0100 - OP_LDR_SPREL, //10 0110 0101 - OP_LDR_SPREL, //10 0110 0110 - OP_LDR_SPREL, //10 0110 0111 - OP_LDR_SPREL, //10 0110 1000 - OP_LDR_SPREL, //10 0110 1001 - OP_LDR_SPREL, //10 0110 1010 - OP_LDR_SPREL, //10 0110 1011 - OP_LDR_SPREL, //10 0110 1100 - OP_LDR_SPREL, //10 0110 1101 - OP_LDR_SPREL, //10 0110 1110 - OP_LDR_SPREL, //10 0110 1111 - - OP_LDR_SPREL, //10 0111 0000 - OP_LDR_SPREL, //10 0111 0001 - OP_LDR_SPREL, //10 0111 0010 - OP_LDR_SPREL, //10 0111 0011 - OP_LDR_SPREL, //10 0111 0100 - OP_LDR_SPREL, //10 0111 0101 - OP_LDR_SPREL, //10 0111 0110 - OP_LDR_SPREL, //10 0111 0111 - OP_LDR_SPREL, //10 0111 1000 - OP_LDR_SPREL, //10 0111 1001 - OP_LDR_SPREL, //10 0111 1010 - OP_LDR_SPREL, //10 0111 1011 - OP_LDR_SPREL, //10 0111 1100 - OP_LDR_SPREL, //10 0111 1101 - OP_LDR_SPREL, //10 0111 1110 - OP_LDR_SPREL, //10 0111 1111 - - OP_ADD_2PC, //10 1000 0000 - OP_ADD_2PC, //10 1000 0001 - OP_ADD_2PC, //10 1000 0010 - OP_ADD_2PC, //10 1000 0011 - OP_ADD_2PC, //10 1000 0100 - OP_ADD_2PC, //10 1000 0101 - OP_ADD_2PC, //10 1000 0110 - OP_ADD_2PC, //10 1000 0111 - OP_ADD_2PC, //10 1000 1000 - OP_ADD_2PC, //10 1000 1001 - OP_ADD_2PC, //10 1000 1010 - OP_ADD_2PC, //10 1000 1011 - OP_ADD_2PC, //10 1000 1100 - OP_ADD_2PC, //10 1000 1101 - OP_ADD_2PC, //10 1000 1110 - OP_ADD_2PC, //10 1000 1111 - - OP_ADD_2PC, //10 1001 0000 - OP_ADD_2PC, //10 1001 0001 - OP_ADD_2PC, //10 1001 0010 - OP_ADD_2PC, //10 1001 0011 - OP_ADD_2PC, //10 1001 0100 - OP_ADD_2PC, //10 1001 0101 - OP_ADD_2PC, //10 1001 0110 - OP_ADD_2PC, //10 1001 0111 - OP_ADD_2PC, //10 1001 1000 - OP_ADD_2PC, //10 1001 1001 - OP_ADD_2PC, //10 1001 1010 - OP_ADD_2PC, //10 1001 1011 - OP_ADD_2PC, //10 1001 1100 - OP_ADD_2PC, //10 1001 1101 - OP_ADD_2PC, //10 1001 1110 - OP_ADD_2PC, //10 1001 1111 - - OP_ADD_2SP, //10 1010 0000 - OP_ADD_2SP, //10 1010 0001 - OP_ADD_2SP, //10 1010 0010 - OP_ADD_2SP, //10 1010 0011 - OP_ADD_2SP, //10 1010 0100 - OP_ADD_2SP, //10 1010 0101 - OP_ADD_2SP, //10 1010 0110 - OP_ADD_2SP, //10 1010 0111 - OP_ADD_2SP, //10 1010 1000 - OP_ADD_2SP, //10 1010 1001 - OP_ADD_2SP, //10 1010 1010 - OP_ADD_2SP, //10 1010 1011 - OP_ADD_2SP, //10 1010 1100 - OP_ADD_2SP, //10 1010 1101 - OP_ADD_2SP, //10 1010 1110 - OP_ADD_2SP, //10 1010 1111 - - OP_ADD_2SP, //10 1011 0000 - OP_ADD_2SP, //10 1011 0001 - OP_ADD_2SP, //10 1011 0010 - OP_ADD_2SP, //10 1011 0011 - OP_ADD_2SP, //10 1011 0100 - OP_ADD_2SP, //10 1011 0101 - OP_ADD_2SP, //10 1011 0110 - OP_ADD_2SP, //10 1011 0111 - OP_ADD_2SP, //10 1011 1000 - OP_ADD_2SP, //10 1011 1001 - OP_ADD_2SP, //10 1011 1010 - OP_ADD_2SP, //10 1011 1011 - OP_ADD_2SP, //10 1011 1100 - OP_ADD_2SP, //10 1011 1101 - OP_ADD_2SP, //10 1011 1110 - OP_ADD_2SP, //10 1011 1111 - - OP_ADJUST_P_SP, //10 1100 0000 - OP_ADJUST_P_SP, //10 1100 0001 - OP_ADJUST_M_SP, //10 1100 0010 - OP_ADJUST_M_SP, //10 1100 0011 - OP_UND_THUMB, //10 1100 0100 - OP_UND_THUMB, //10 1100 0101 - OP_UND_THUMB, //10 1100 0110 - OP_UND_THUMB, //10 1100 0111 - OP_UND_THUMB, //10 1100 1000 - OP_UND_THUMB, //10 1100 1001 - OP_UND_THUMB, //10 1100 1010 - OP_UND_THUMB, //10 1100 1011 - OP_UND_THUMB, //10 1100 1100 - OP_UND_THUMB, //10 1100 1101 - OP_UND_THUMB, //10 1100 1110 - OP_UND_THUMB, //10 1100 1111 - - OP_PUSH, //10 1101 0000 - OP_PUSH, //10 1101 0001 - OP_PUSH, //10 1101 0010 - OP_PUSH, //10 1101 0011 - OP_PUSH_LR, //10 1101 0100 - OP_PUSH_LR, //10 1101 0101 - OP_PUSH_LR, //10 1101 0110 - OP_PUSH_LR, //10 1101 0111 - OP_UND_THUMB, //10 1101 1000 - OP_UND_THUMB, //10 1101 1001 - OP_UND_THUMB, //10 1101 1010 - OP_UND_THUMB, //10 1101 1011 - OP_UND_THUMB, //10 1101 1100 - OP_UND_THUMB, //10 1101 1101 - OP_UND_THUMB, //10 1101 1110 - OP_UND_THUMB, //10 1101 1111 - - OP_UND_THUMB, //10 1110 0000 - OP_UND_THUMB, //10 1110 0001 - OP_UND_THUMB, //10 1110 0010 - OP_UND_THUMB, //10 1110 0011 - OP_UND_THUMB, //10 1110 0100 - OP_UND_THUMB, //10 1110 0101 - OP_UND_THUMB, //10 1110 0110 - OP_UND_THUMB, //10 1110 0111 - OP_UND_THUMB, //10 1110 1000 - OP_UND_THUMB, //10 1110 1001 - OP_UND_THUMB, //10 1110 1010 - OP_UND_THUMB, //10 1110 1011 - OP_UND_THUMB, //10 1110 1100 - OP_UND_THUMB, //10 1110 1101 - OP_UND_THUMB, //10 1110 1110 - OP_UND_THUMB, //10 1110 1111 - - OP_POP, //10 1111 0000 - OP_POP, //10 1111 0001 - OP_POP, //10 1111 0010 - OP_POP, //10 1111 0011 - OP_POP_PC, //10 1111 0100 - OP_POP_PC, //10 1111 0101 - OP_POP_PC, //10 1111 0110 - OP_POP_PC, //10 1111 0111 - OP_BKPT_THUMB, //10 1111 1000 - OP_BKPT_THUMB, //10 1111 1001 - OP_BKPT_THUMB, //10 1111 1010 - OP_BKPT_THUMB, //10 1111 1011 - OP_UND_THUMB, //10 1111 1100 - OP_UND_THUMB, //10 1111 1101 - OP_UND_THUMB, //10 1111 1110 - OP_UND_THUMB, //10 1111 1111 - - OP_STMIA_THUMB, //11 0000 0000 - OP_STMIA_THUMB, //11 0000 0001 - OP_STMIA_THUMB, //11 0000 0010 - OP_STMIA_THUMB, //11 0000 0011 - OP_STMIA_THUMB, //11 0000 0100 - OP_STMIA_THUMB, //11 0000 0101 - OP_STMIA_THUMB, //11 0000 0110 - OP_STMIA_THUMB, //11 0000 0111 - OP_STMIA_THUMB, //11 0000 1000 - OP_STMIA_THUMB, //11 0000 1001 - OP_STMIA_THUMB, //11 0000 1010 - OP_STMIA_THUMB, //11 0000 1011 - OP_STMIA_THUMB, //11 0000 1100 - OP_STMIA_THUMB, //11 0000 1101 - OP_STMIA_THUMB, //11 0000 1110 - OP_STMIA_THUMB, //11 0000 1111 - - OP_STMIA_THUMB, //11 0001 0000 - OP_STMIA_THUMB, //11 0001 0001 - OP_STMIA_THUMB, //11 0001 0010 - OP_STMIA_THUMB, //11 0001 0011 - OP_STMIA_THUMB, //11 0001 0100 - OP_STMIA_THUMB, //11 0001 0101 - OP_STMIA_THUMB, //11 0001 0110 - OP_STMIA_THUMB, //11 0001 0111 - OP_STMIA_THUMB, //11 0001 1000 - OP_STMIA_THUMB, //11 0001 1001 - OP_STMIA_THUMB, //11 0001 1010 - OP_STMIA_THUMB, //11 0001 1011 - OP_STMIA_THUMB, //11 0001 1100 - OP_STMIA_THUMB, //11 0001 1101 - OP_STMIA_THUMB, //11 0001 1110 - OP_STMIA_THUMB, //11 0001 1111 - - OP_LDMIA_THUMB, //11 0010 0000 - OP_LDMIA_THUMB, //11 0010 0001 - OP_LDMIA_THUMB, //11 0010 0010 - OP_LDMIA_THUMB, //11 0010 0011 - OP_LDMIA_THUMB, //11 0010 0100 - OP_LDMIA_THUMB, //11 0010 0101 - OP_LDMIA_THUMB, //11 0010 0110 - OP_LDMIA_THUMB, //11 0010 0111 - OP_LDMIA_THUMB, //11 0010 1000 - OP_LDMIA_THUMB, //11 0010 1001 - OP_LDMIA_THUMB, //11 0010 1010 - OP_LDMIA_THUMB, //11 0010 1011 - OP_LDMIA_THUMB, //11 0010 1100 - OP_LDMIA_THUMB, //11 0010 1101 - OP_LDMIA_THUMB, //11 0010 1110 - OP_LDMIA_THUMB, //11 0010 1111 - - OP_LDMIA_THUMB, //11 0011 0000 - OP_LDMIA_THUMB, //11 0011 0001 - OP_LDMIA_THUMB, //11 0011 0010 - OP_LDMIA_THUMB, //11 0011 0011 - OP_LDMIA_THUMB, //11 0011 0100 - OP_LDMIA_THUMB, //11 0011 0101 - OP_LDMIA_THUMB, //11 0011 0110 - OP_LDMIA_THUMB, //11 0011 0111 - OP_LDMIA_THUMB, //11 0011 1000 - OP_LDMIA_THUMB, //11 0011 1001 - OP_LDMIA_THUMB, //11 0011 1010 - OP_LDMIA_THUMB, //11 0011 1011 - OP_LDMIA_THUMB, //11 0011 1100 - OP_LDMIA_THUMB, //11 0011 1101 - OP_LDMIA_THUMB, //11 0011 1110 - OP_LDMIA_THUMB, //11 0011 1111 - - OP_B_COND, //11 0100 0000 - OP_B_COND, //11 0100 0001 - OP_B_COND, //11 0100 0010 - OP_B_COND, //11 0100 0011 - OP_B_COND, //11 0100 0100 - OP_B_COND, //11 0100 0101 - OP_B_COND, //11 0100 0110 - OP_B_COND, //11 0100 0111 - OP_B_COND, //11 0100 1000 - OP_B_COND, //11 0100 1001 - OP_B_COND, //11 0100 1010 - OP_B_COND, //11 0100 1011 - OP_B_COND, //11 0100 1100 - OP_B_COND, //11 0100 1101 - OP_B_COND, //11 0100 1110 - OP_B_COND, //11 0100 1111 - - OP_B_COND, //11 0101 0000 - OP_B_COND, //11 0101 0001 - OP_B_COND, //11 0101 0010 - OP_B_COND, //11 0101 0011 - OP_B_COND, //11 0101 0100 - OP_B_COND, //11 0101 0101 - OP_B_COND, //11 0101 0110 - OP_B_COND, //11 0101 0111 - OP_B_COND, //11 0101 1000 - OP_B_COND, //11 0101 1001 - OP_B_COND, //11 0101 1010 - OP_B_COND, //11 0101 1011 - OP_B_COND, //11 0101 1100 - OP_B_COND, //11 0101 1101 - OP_B_COND, //11 0101 1110 - OP_B_COND, //11 0101 1111 - - OP_B_COND, //11 0110 0000 - OP_B_COND, //11 0110 0001 - OP_B_COND, //11 0110 0010 - OP_B_COND, //11 0110 0011 - OP_B_COND, //11 0110 0100 - OP_B_COND, //11 0110 0101 - OP_B_COND, //11 0110 0110 - OP_B_COND, //11 0110 0111 - OP_B_COND, //11 0110 1000 - OP_B_COND, //11 0110 1001 - OP_B_COND, //11 0110 1010 - OP_B_COND, //11 0110 1011 - OP_B_COND, //11 0110 1100 - OP_B_COND, //11 0110 1101 - OP_B_COND, //11 0110 1110 - OP_B_COND, //11 0110 1111 - - OP_B_COND, //11 0111 0000 - OP_B_COND, //11 0111 0001 - OP_B_COND, //11 0111 0010 - OP_B_COND, //11 0111 0011 - OP_B_COND, //11 0111 0100 - OP_B_COND, //11 0111 0101 - OP_B_COND, //11 0111 0110 - OP_B_COND, //11 0111 0111 - OP_B_COND, //11 0111 1000 - OP_B_COND, //11 0111 1001 - OP_B_COND, //11 0111 1010 - OP_B_COND, //11 0111 1011 - OP_SWI_THUMB, //11 0111 1100 - OP_SWI_THUMB, //11 0111 1101 - OP_SWI_THUMB, //11 0111 1110 - OP_SWI_THUMB, //11 0111 1111 - - OP_B_UNCOND, //11 1000 0000 - OP_B_UNCOND, //11 1000 0001 - OP_B_UNCOND, //11 1000 0010 - OP_B_UNCOND, //11 1000 0011 - OP_B_UNCOND, //11 1000 0100 - OP_B_UNCOND, //11 1000 0101 - OP_B_UNCOND, //11 1000 0110 - OP_B_UNCOND, //11 1000 0111 - OP_B_UNCOND, //11 1000 1000 - OP_B_UNCOND, //11 1000 1001 - OP_B_UNCOND, //11 1000 1010 - OP_B_UNCOND, //11 1000 1011 - OP_B_UNCOND, //11 1000 1100 - OP_B_UNCOND, //11 1000 1101 - OP_B_UNCOND, //11 1000 1110 - OP_B_UNCOND, //11 1000 1111 - - OP_B_UNCOND, //11 1001 0000 - OP_B_UNCOND, //11 1001 0001 - OP_B_UNCOND, //11 1001 0010 - OP_B_UNCOND, //11 1001 0011 - OP_B_UNCOND, //11 1001 0100 - OP_B_UNCOND, //11 1001 0101 - OP_B_UNCOND, //11 1001 0110 - OP_B_UNCOND, //11 1001 0111 - OP_B_UNCOND, //11 1001 1000 - OP_B_UNCOND, //11 1001 1001 - OP_B_UNCOND, //11 1001 1010 - OP_B_UNCOND, //11 1001 1011 - OP_B_UNCOND, //11 1001 1100 - OP_B_UNCOND, //11 1001 1101 - OP_B_UNCOND, //11 1001 1110 - OP_B_UNCOND, //11 1001 1111 - - OP_BLX, //11 1010 0000 - OP_BLX, //11 1010 0001 - OP_BLX, //11 1010 0010 - OP_BLX, //11 1010 0011 - OP_BLX, //11 1010 0100 - OP_BLX, //11 1010 0101 - OP_BLX, //11 1010 0110 - OP_BLX, //11 1010 0111 - OP_BLX, //11 1010 1000 - OP_BLX, //11 1010 1001 - OP_BLX, //11 1010 1010 - OP_BLX, //11 1010 1011 - OP_BLX, //11 1010 1100 - OP_BLX, //11 1010 1101 - OP_BLX, //11 1010 1110 - OP_BLX, //11 1010 1111 - - OP_BLX, //11 1011 0000 - OP_BLX, //11 1011 0001 - OP_BLX, //11 1011 0010 - OP_BLX, //11 1011 0011 - OP_BLX, //11 1011 0100 - OP_BLX, //11 1011 0101 - OP_BLX, //11 1011 0110 - OP_BLX, //11 1011 0111 - OP_BLX, //11 1011 1000 - OP_BLX, //11 1011 1001 - OP_BLX, //11 1011 1010 - OP_BLX, //11 1011 1011 - OP_BLX, //11 1011 1100 - OP_BLX, //11 1011 1101 - OP_BLX, //11 1011 1110 - OP_BLX, //11 1011 1111 - - OP_BL_10, //11 1100 0000 - OP_BL_10, //11 1100 0001 - OP_BL_10, //11 1100 0010 - OP_BL_10, //11 1100 0011 - OP_BL_10, //11 1100 0100 - OP_BL_10, //11 1100 0101 - OP_BL_10, //11 1100 0110 - OP_BL_10, //11 1100 0111 - OP_BL_10, //11 1100 1000 - OP_BL_10, //11 1100 1001 - OP_BL_10, //11 1100 1010 - OP_BL_10, //11 1100 1011 - OP_BL_10, //11 1100 1100 - OP_BL_10, //11 1100 1101 - OP_BL_10, //11 1100 1110 - OP_BL_10, //11 1100 1111 - - OP_BL_10, //11 1101 0000 - OP_BL_10, //11 1101 0001 - OP_BL_10, //11 1101 0010 - OP_BL_10, //11 1101 0011 - OP_BL_10, //11 1101 0100 - OP_BL_10, //11 1101 0101 - OP_BL_10, //11 1101 0110 - OP_BL_10, //11 1101 0111 - OP_BL_10, //11 1101 1000 - OP_BL_10, //11 1101 1001 - OP_BL_10, //11 1101 1010 - OP_BL_10, //11 1101 1011 - OP_BL_10, //11 1101 1100 - OP_BL_10, //11 1101 1101 - OP_BL_10, //11 1101 1110 - OP_BL_10, //11 1101 1111 - - OP_BL_THUMB, //11 1110 0000 - OP_BL_THUMB, //11 1110 0001 - OP_BL_THUMB, //11 1110 0010 - OP_BL_THUMB, //11 1110 0011 - OP_BL_THUMB, //11 1110 0100 - OP_BL_THUMB, //11 1110 0101 - OP_BL_THUMB, //11 1110 0110 - OP_BL_THUMB, //11 1110 0111 - OP_BL_THUMB, //11 1110 1000 - OP_BL_THUMB, //11 1110 1001 - OP_BL_THUMB, //11 1110 1010 - OP_BL_THUMB, //11 1110 1011 - OP_BL_THUMB, //11 1110 1100 - OP_BL_THUMB, //11 1110 1101 - OP_BL_THUMB, //11 1110 1110 - OP_BL_THUMB, //11 1110 1111 - - OP_BL_THUMB, //11 1111 0000 - OP_BL_THUMB, //11 1111 0001 - OP_BL_THUMB, //11 1111 0010 - OP_BL_THUMB, //11 1111 0011 - OP_BL_THUMB, //11 1111 0100 - OP_BL_THUMB, //11 1111 0101 - OP_BL_THUMB, //11 1111 0110 - OP_BL_THUMB, //11 1111 0111 - OP_BL_THUMB, //11 1111 1000 - OP_BL_THUMB, //11 1111 1001 - OP_BL_THUMB, //11 1111 1010 - OP_BL_THUMB, //11 1111 1011 - OP_BL_THUMB, //11 1111 1100 - OP_BL_THUMB, //11 1111 1101 - OP_BL_THUMB, //11 1111 1110 - OP_BL_THUMB, //11 1111 1111 -}; //1089 - diff --git a/tools/vio2sf/src/vio2sf/desmume/types.h b/tools/vio2sf/src/vio2sf/desmume/types.h deleted file mode 100644 index ed4f21076..000000000 --- a/tools/vio2sf/src/vio2sf/desmume/types.h +++ /dev/null @@ -1,171 +0,0 @@ -/* Copyright (C) 2005 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef TYPES_HPP -#define TYPES_HPP - -#ifndef FASTCALL -#ifdef __MINGW32__ -#define FASTCALL __attribute__((fastcall)) -#elif defined (__i386__) -#define FASTCALL __attribute__((regparm(3))) -#else -#define FASTCALL -#endif -#endif - -#ifndef INLINE -#ifdef _MSC_VER -#define INLINE _inline -#else -#define INLINE inline -#endif -#endif - -#ifdef DESMUME_COCOA -#ifdef __BIG_ENDIAN__ -#define WORDS_BIGENDIAN -#endif -#endif - -#if defined(__LP64__) -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long u64; -typedef unsigned long pointer; - -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; -typedef signed long s64; -#else -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned long u32; -#ifdef _MSC_VER -typedef unsigned __int64 u64; -#else -typedef unsigned long long u64; -#endif -typedef unsigned long pointer; - -typedef signed char s8; -typedef signed short s16; -typedef signed long s32; -#ifdef _MSC_VER -typedef __int64 s64; -#else -typedef signed long long s64; -#endif -#endif - -typedef u8 uint8; -typedef u16 uint16; - -#ifndef OBJ_C -typedef u32 uint32; -#else -#define uint32 u32 //uint32 is defined in Leopard somewhere, avoid conflicts -#endif - -/*---------- GPU3D fixed-points types -----------*/ - -typedef s32 f32; -#define inttof32(n) ((n) << 12) -#define f32toint(n) ((n) >> 12) -#define floattof32(n) ((int32)((n) * (1 << 12))) -#define f32tofloat(n) (((float)(n)) / (float)(1<<12)) - -typedef s16 t16; -#define f32tot16(n) ((t16)(n >> 8)) -#define inttot16(n) ((n) << 4) -#define t16toint(n) ((n) >> 4) -#define floattot16(n) ((t16)((n) * (1 << 4))) -#define t16ofloat(n) (((float)(n)) / (float)(1<<4)) - -typedef s16 v16; -#define inttov16(n) ((n) << 12) -#define f32tov16(n) (n) -#define floattov16(n) ((v16)((n) * (1 << 12))) -#define v16toint(n) ((n) >> 12) -#define v16tofloat(n) (((float)(n)) / (float)(1<<12)) - -typedef s16 v10; -#define inttov10(n) ((n) << 9) -#define f32tov10(n) ((v10)(n >> 3)) -#define v10toint(n) ((n) >> 9) -#define floattov10(n) ((v10)((n) * (1 << 9))) -#define v10tofloat(n) (((float)(n)) / (float)(1<<9)) - -/*----------------------*/ - -#ifndef OBJ_C -typedef int BOOL; -#else -//apple also defines BOOL -typedef int desmume_BOOL; -#define BOOL desmume_BOOL -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifdef __GNUC__ -#define PACKED __attribute__((packed)) -#endif - -#ifdef WORDS_BIGENDIAN -# define LOCAL_BE -#else -# define LOCAL_LE -#endif - -/* little endian (ds' endianess) to local endianess convert macros */ -#ifdef LOCAL_BE /* local arch is big endian */ -# define LE_TO_LOCAL_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) -# define LE_TO_LOCAL_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) -# define LOCAL_TO_LE_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) -# define LOCAL_TO_LE_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) -#else /* local arch is little endian */ -# define LE_TO_LOCAL_16(x) (x) -# define LE_TO_LOCAL_32(x) (x) -# define LOCAL_TO_LE_16(x) (x) -# define LOCAL_TO_LE_32(x) (x) -#endif - -/* kilobytes and megabytes macro */ -#define MB(x) ((x)*1024*1024) -#define KB(x) ((x)*1024) - -#define CPU_STR(c) ((c==ARM9)?"ARM9":"ARM7") -typedef enum -{ - ARM9 = 0, - ARM7 = 1 -} cpu_id_t; - -#define __PACKED __attribute__((__packed__)) - -#endif diff --git a/tools/vio2sf/src/vio2sf/drvimpl.c b/tools/vio2sf/src/vio2sf/drvimpl.c deleted file mode 100644 index e54f26543..000000000 --- a/tools/vio2sf/src/vio2sf/drvimpl.c +++ /dev/null @@ -1,856 +0,0 @@ -#include -#include -#include - -#include "desmume/MMU.h" -#include "desmume/armcpu.h" -#include "desmume/ndssystem.h" -#include "desmume/spu_exports.h" -#include "desmume/cp15.h" - -#include "zlib/zlib.h" -#include "../xsfc/tagget.h" -#include "../xsfc/drvimpl.h" - -volatile BOOL execute = FALSE; - -static struct -{ - unsigned char *rom; - unsigned char *state; - unsigned romsize; - unsigned statesize; - unsigned stateptr; -} loaderwork = { 0, 0, 0, 0, 0 }; - -static void load_term(void) -{ - if (loaderwork.rom) - { - free(loaderwork.rom); - loaderwork.rom = 0; - } - loaderwork.romsize = 0; - if (loaderwork.state) - { - free(loaderwork.state); - loaderwork.state = 0; - } - loaderwork.statesize = 0; -} - -static int load_map(int issave, unsigned char *udata, unsigned usize) -{ - unsigned char *iptr; - unsigned isize; - unsigned char *xptr; - unsigned xsize = getdwordle(udata + 4); - unsigned xofs = getdwordle(udata + 0); - if (issave) - { - iptr = loaderwork.state; - isize = loaderwork.statesize; - loaderwork.state = 0; - loaderwork.statesize = 0; - } - else - { - iptr = loaderwork.rom; - isize = loaderwork.romsize; - loaderwork.rom = 0; - loaderwork.romsize = 0; - } - if (!iptr) - { - unsigned rsize = xofs + xsize; - if (!issave) - { - rsize -= 1; - rsize |= rsize >> 1; - rsize |= rsize >> 2; - rsize |= rsize >> 4; - rsize |= rsize >> 8; - rsize |= rsize >> 16; - rsize += 1; - } - iptr = malloc(rsize + 10); - if (!iptr) - return XSF_FALSE; - memset(iptr, 0, rsize + 10); - isize = rsize; - } - else if (isize < xofs + xsize) - { - unsigned rsize = xofs + xsize; - if (!issave) - { - rsize -= 1; - rsize |= rsize >> 1; - rsize |= rsize >> 2; - rsize |= rsize >> 4; - rsize |= rsize >> 8; - rsize |= rsize >> 16; - rsize += 1; - } - xptr = realloc(iptr, xofs + rsize + 10); - if (!xptr) - { - free(iptr); - return XSF_FALSE; - } - iptr = xptr; - isize = rsize; - } - memcpy(iptr + xofs, udata + 8, xsize); - if (issave) - { - loaderwork.state = iptr; - loaderwork.statesize = isize; - } - else - { - loaderwork.rom = iptr; - loaderwork.romsize = isize; - } - return XSF_TRUE; -} - -static int load_mapz(int issave, unsigned char *zdata, unsigned zsize, unsigned zcrc) -{ - int ret; - int zerr; - uLongf usize = 8; - uLongf rsize = usize; - unsigned char *udata; - unsigned char *rdata; - - udata = malloc(usize); - if (!udata) - return XSF_FALSE; - - while (Z_OK != (zerr = uncompress(udata, &usize, zdata, zsize))) - { - if (Z_MEM_ERROR != zerr && Z_BUF_ERROR != zerr) - { - free(udata); - return XSF_FALSE; - } - if (usize >= 8) - { - usize = getdwordle(udata + 4) + 8; - if (usize < rsize) - { - rsize += rsize; - usize = rsize; - } - else - rsize = usize; - } - else - { - rsize += rsize; - usize = rsize; - } - free(udata); - udata = malloc(usize); - if (!udata) - return XSF_FALSE; - } - - rdata = realloc(udata, usize); - if (!rdata) - { - free(udata); - return XSF_FALSE; - } - - if (0) - { - unsigned ccrc = crc32(crc32(0L, Z_NULL, 0), rdata, usize); - if (ccrc != zcrc) - return XSF_FALSE; - } - - ret = load_map(issave, rdata, usize); - free(rdata); - return ret; -} - -static int load_psf_one(unsigned char *pfile, unsigned bytes) -{ - unsigned char *ptr = pfile; - unsigned code_size; - unsigned resv_size; - unsigned code_crc; - if (bytes < 16 || getdwordle(ptr) != 0x24465350) - return XSF_FALSE; - - resv_size = getdwordle(ptr + 4); - code_size = getdwordle(ptr + 8); - code_crc = getdwordle(ptr + 12); - - if (resv_size) - { - unsigned resv_pos = 0; - ptr = pfile + 16; - if (16+ resv_size > bytes) - return XSF_FALSE; - while (resv_pos + 12 < resv_size) - { - unsigned save_size = getdwordle(ptr + resv_pos + 4); - unsigned save_crc = getdwordle(ptr + resv_pos + 8); - if (getdwordle(ptr + resv_pos + 0) == 0x45564153) - { - if (resv_pos + 12 + save_size > resv_size) - return XSF_FALSE; - if (!load_mapz(1, ptr + resv_pos + 12, save_size, save_crc)) - return XSF_FALSE; - } - resv_pos += 12 + save_size; - } - } - - if (code_size) - { - ptr = pfile + 16 + resv_size; - if (16 + resv_size + code_size > bytes) - return XSF_FALSE; - if (!load_mapz(0, ptr, code_size, code_crc)) - return XSF_FALSE; - } - - return XSF_TRUE; -} - -typedef struct -{ - const char *tag; - int taglen; - int level; - int found; -} loadlibwork_t; - -static int load_psf_and_libs(int level, void *pfile, unsigned bytes); - -static int load_psfcb(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) -{ - loadlibwork_t *pwork = (loadlibwork_t *)pWork; - int ret = xsf_tagenum_callback_returnvaluecontinue; - if (pNameEnd - pNameTop == pwork->taglen && !_strnicmp(pNameTop, pwork->tag , pwork->taglen)) - { - unsigned l = pValueEnd - pValueTop; - char *lib = malloc(l + 1); - if (!lib) - { - ret = xsf_tagenum_callback_returnvaluebreak; - } - else - { - void *libbuf; - unsigned libsize; - memcpy(lib, pValueTop, l); - lib[l] = '\0'; - if (!xsf_get_lib(lib, &libbuf, &libsize)) - { - ret = xsf_tagenum_callback_returnvaluebreak; - } - else - { - if (!load_psf_and_libs(pwork->level + 1, libbuf, libsize)) - ret = xsf_tagenum_callback_returnvaluebreak; - else - pwork->found++; - free(libbuf); - } - free(lib); - } - } - return ret; -} - -static int load_psf_and_libs(int level, void *pfile, unsigned bytes) -{ - int haslib = 0; - loadlibwork_t work; - - work.level = level; - work.tag = "_lib"; - work.taglen = strlen(work.tag); - work.found = 0; - - if (level <= 10 && xsf_tagenum(load_psfcb, &work, pfile, bytes) < 0) - return XSF_FALSE; - - haslib = work.found; - - if (!load_psf_one(pfile, bytes)) - return XSF_FALSE; - -/* if (haslib) */ - { - int n = 2; - do - { - char tbuf[16]; -#ifdef HAVE_SPRINTF_S - sprintf_s(tbuf, sizeof(tbuf), "_lib%d", n++); -#else - sprintf(tbuf, "_lib%d", n++); -#endif - work.tag = tbuf; - work.taglen = strlen(work.tag); - work.found = 0; - if (xsf_tagenum(load_psfcb, &work, pfile, bytes) < 0) - return XSF_FALSE; - } - while (work.found); - } - return XSF_TRUE; -} - -static int load_psf(void *pfile, unsigned bytes) -{ - load_term(); - - return load_psf_and_libs(1, pfile, bytes); -} - -static void load_getstateinit(unsigned ptr) -{ - loaderwork.stateptr = ptr; -} - -static u16 getwordle(const unsigned char *pData) -{ - return pData[0] | (((u16)pData[1]) << 8); -} - -static void load_getsta(Status_Reg *ptr, unsigned l) -{ - unsigned s = l << 2; - unsigned i; - if ((loaderwork.stateptr > loaderwork.statesize) || ((loaderwork.stateptr + s) > loaderwork.statesize)) - return; - for (i = 0; i < l; i++) - { - u32 st = getdwordle(loaderwork.state + loaderwork.stateptr + (i << 2)); - ptr[i].bits.N = (st >> 31) & 1; - ptr[i].bits.Z = (st >> 30) & 1; - ptr[i].bits.C = (st >> 29) & 1; - ptr[i].bits.V = (st >> 28) & 1; - ptr[i].bits.Q = (st >> 27) & 1; - ptr[i].bits.RAZ = (st >> 8) & ((1 << 19) - 1); - ptr[i].bits.I = (st >> 7) & 1; - ptr[i].bits.F = (st >> 6) & 1; - ptr[i].bits.T = (st >> 5) & 1; - ptr[i].bits.mode = (st >> 0) & 0x1f; - } - loaderwork.stateptr += s; -} - -static void load_getbool(BOOL *ptr, unsigned l) -{ - unsigned s = l << 2; - unsigned i; - if ((loaderwork.stateptr > loaderwork.statesize) || ((loaderwork.stateptr + s) > loaderwork.statesize)) - return; - for (i = 0; i < l; i++) - ptr[i] = (BOOL)getdwordle(loaderwork.state + loaderwork.stateptr + (i << 2)); - loaderwork.stateptr += s; -} - -#if defined(SIGNED_IS_NOT_2S_COMPLEMENT) -/* 2's complement */ -#define u32tos32(v) ((s32)((((s64)(v)) ^ 0x80000000) - 0x80000000)) -#else -/* 2's complement */ -#define u32tos32(v) ((s32)v) -#endif - -static void load_gets32(s32 *ptr, unsigned l) -{ - unsigned s = l << 2; - unsigned i; - if ((loaderwork.stateptr > loaderwork.statesize) || ((loaderwork.stateptr + s) > loaderwork.statesize)) - return; - for (i = 0; i < l; i++) - ptr[i] = u32tos32(getdwordle(loaderwork.state + loaderwork.stateptr + (i << 2))); - loaderwork.stateptr += s; -} - -static void load_getu32(u32 *ptr, unsigned l) -{ - unsigned s = l << 2; - unsigned i; - if ((loaderwork.stateptr > loaderwork.statesize) || ((loaderwork.stateptr + s) > loaderwork.statesize)) - return; - for (i = 0; i < l; i++) - ptr[i] = getdwordle(loaderwork.state + loaderwork.stateptr + (i << 2)); - loaderwork.stateptr += s; -} - -static void load_getu16(u16 *ptr, unsigned l) -{ - unsigned s = l << 1; - unsigned i; - if ((loaderwork.stateptr > loaderwork.statesize) || ((loaderwork.stateptr + s) > loaderwork.statesize)) - return; - for (i = 0; i < l; i++) - ptr[i] = getwordle(loaderwork.state + loaderwork.stateptr + (i << 1)); - loaderwork.stateptr += s; -} - -static void load_getu8(u8 *ptr, unsigned l) -{ - unsigned s = l; - unsigned i; - if ((loaderwork.stateptr > loaderwork.statesize) || ((loaderwork.stateptr + s) > loaderwork.statesize)) - return; - for (i = 0; i < l; i++) - ptr[i] = loaderwork.state[loaderwork.stateptr + i]; - loaderwork.stateptr += s; -} - -void gdb_stub_fix(armcpu_t *armcpu) -{ - /* armcpu->R[15] = armcpu->instruct_adr; */ - armcpu->next_instruction = armcpu->instruct_adr; - if(armcpu->CPSR.bits.T == 0) - { - armcpu->instruction = MMU_read32_acl(armcpu->proc_ID, armcpu->next_instruction,CP15_ACCESS_EXECUTE); - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 4; - armcpu->R[15] = armcpu->next_instruction + 4; - } - else - { - armcpu->instruction = MMU_read16_acl(armcpu->proc_ID, armcpu->next_instruction,CP15_ACCESS_EXECUTE); - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 2; - armcpu->R[15] = armcpu->next_instruction + 2; - } -} - -static void load_setstate(void) -{ - if (!loaderwork.statesize) - return; - - /* Skip over "Desmume Save File" crap */ - load_getstateinit(0x17); - - /* Read ARM7 cpu registers */ - load_getu32(&NDS_ARM7.proc_ID, 1); - load_getu32(&NDS_ARM7.instruction, 1); - load_getu32(&NDS_ARM7.instruct_adr, 1); - load_getu32(&NDS_ARM7.next_instruction, 1); - load_getu32(NDS_ARM7.R, 16); - load_getsta(&NDS_ARM7.CPSR, 1); - load_getsta(&NDS_ARM7.SPSR, 1); - load_getu32(&NDS_ARM7.R13_usr, 1); - load_getu32(&NDS_ARM7.R14_usr, 1); - load_getu32(&NDS_ARM7.R13_svc, 1); - load_getu32(&NDS_ARM7.R14_svc, 1); - load_getu32(&NDS_ARM7.R13_abt, 1); - load_getu32(&NDS_ARM7.R14_abt, 1); - load_getu32(&NDS_ARM7.R13_und, 1); - load_getu32(&NDS_ARM7.R14_und, 1); - load_getu32(&NDS_ARM7.R13_irq, 1); - load_getu32(&NDS_ARM7.R14_irq, 1); - load_getu32(&NDS_ARM7.R8_fiq, 1); - load_getu32(&NDS_ARM7.R9_fiq, 1); - load_getu32(&NDS_ARM7.R10_fiq, 1); - load_getu32(&NDS_ARM7.R11_fiq, 1); - load_getu32(&NDS_ARM7.R12_fiq, 1); - load_getu32(&NDS_ARM7.R13_fiq, 1); - load_getu32(&NDS_ARM7.R14_fiq, 1); - load_getsta(&NDS_ARM7.SPSR_svc, 1); - load_getsta(&NDS_ARM7.SPSR_abt, 1); - load_getsta(&NDS_ARM7.SPSR_und, 1); - load_getsta(&NDS_ARM7.SPSR_irq, 1); - load_getsta(&NDS_ARM7.SPSR_fiq, 1); - load_getu32(&NDS_ARM7.intVector, 1); - load_getu8(&NDS_ARM7.LDTBit, 1); - load_getbool(&NDS_ARM7.waitIRQ, 1); - load_getbool(&NDS_ARM7.wIRQ, 1); - load_getbool(&NDS_ARM7.wirq, 1); - - /* Read ARM9 cpu registers */ - load_getu32(&NDS_ARM9.proc_ID, 1); - load_getu32(&NDS_ARM9.instruction, 1); - load_getu32(&NDS_ARM9.instruct_adr, 1); - load_getu32(&NDS_ARM9.next_instruction, 1); - load_getu32(NDS_ARM9.R, 16); - load_getsta(&NDS_ARM9.CPSR, 1); - load_getsta(&NDS_ARM9.SPSR, 1); - load_getu32(&NDS_ARM9.R13_usr, 1); - load_getu32(&NDS_ARM9.R14_usr, 1); - load_getu32(&NDS_ARM9.R13_svc, 1); - load_getu32(&NDS_ARM9.R14_svc, 1); - load_getu32(&NDS_ARM9.R13_abt, 1); - load_getu32(&NDS_ARM9.R14_abt, 1); - load_getu32(&NDS_ARM9.R13_und, 1); - load_getu32(&NDS_ARM9.R14_und, 1); - load_getu32(&NDS_ARM9.R13_irq, 1); - load_getu32(&NDS_ARM9.R14_irq, 1); - load_getu32(&NDS_ARM9.R8_fiq, 1); - load_getu32(&NDS_ARM9.R9_fiq, 1); - load_getu32(&NDS_ARM9.R10_fiq, 1); - load_getu32(&NDS_ARM9.R11_fiq, 1); - load_getu32(&NDS_ARM9.R12_fiq, 1); - load_getu32(&NDS_ARM9.R13_fiq, 1); - load_getu32(&NDS_ARM9.R14_fiq, 1); - load_getsta(&NDS_ARM9.SPSR_svc, 1); - load_getsta(&NDS_ARM9.SPSR_abt, 1); - load_getsta(&NDS_ARM9.SPSR_und, 1); - load_getsta(&NDS_ARM9.SPSR_irq, 1); - load_getsta(&NDS_ARM9.SPSR_fiq, 1); - load_getu32(&NDS_ARM9.intVector, 1); - load_getu8(&NDS_ARM9.LDTBit, 1); - load_getbool(&NDS_ARM9.waitIRQ, 1); - load_getbool(&NDS_ARM9.wIRQ, 1); - load_getbool(&NDS_ARM9.wirq, 1); - - /* Read in other internal variables that are important */ - load_gets32(&nds.ARM9Cycle, 1); - load_gets32(&nds.ARM7Cycle, 1); - load_gets32(&nds.cycles, 1); - load_gets32(nds.timerCycle[0], 4); - load_gets32(nds.timerCycle[1], 4); - load_getbool(nds.timerOver[0], 4); - load_getbool(nds.timerOver[1], 4); - load_gets32(&nds.nextHBlank, 1); - load_getu32(&nds.VCount, 1); - load_getu32(&nds.old, 1); - load_gets32(&nds.diff, 1); - load_getbool(&nds.lignerendu, 1); - load_getu16(&nds.touchX, 1); - load_getu16(&nds.touchY, 1); - - /* Read in memory/registers specific to the ARM9 */ - load_getu8 (ARM9Mem.ARM9_ITCM, 0x8000); - load_getu8 (ARM9Mem.ARM9_DTCM, 0x4000); - load_getu8 (ARM9Mem.ARM9_WRAM, 0x1000000); - load_getu8 (ARM9Mem.MAIN_MEM, 0x400000); - load_getu8 (ARM9Mem.ARM9_REG, 0x10000); - load_getu8 (ARM9Mem.ARM9_VMEM, 0x800); - load_getu8 (ARM9Mem.ARM9_OAM, 0x800); - load_getu8 (ARM9Mem.ARM9_ABG, 0x80000); - load_getu8 (ARM9Mem.ARM9_BBG, 0x20000); - load_getu8 (ARM9Mem.ARM9_AOBJ, 0x40000); - load_getu8 (ARM9Mem.ARM9_BOBJ, 0x20000); - load_getu8 (ARM9Mem.ARM9_LCD, 0xA4000); - - /* Read in memory/registers specific to the ARM7 */ - load_getu8 (MMU.ARM7_ERAM, 0x10000); - load_getu8 (MMU.ARM7_REG, 0x10000); - load_getu8 (MMU.ARM7_WIRAM, 0x10000); - - /* Read in shared memory */ - load_getu8 (MMU.SWIRAM, 0x8000); - -#ifdef GDB_STUB -#else - gdb_stub_fix(&NDS_ARM9); - gdb_stub_fix(&NDS_ARM7); -#endif -} - -static struct -{ - unsigned char *pcmbufalloc; - unsigned char *pcmbuftop; - unsigned filled; - unsigned used; - u32 bufferbytes; - u32 cycles; - int xfs_load; - int sync_type; - int arm7_clockdown_level; - int arm9_clockdown_level; -} sndifwork = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - -static void SNDIFDeInit(void) -{ - if (sndifwork.pcmbufalloc) - { - free(sndifwork.pcmbufalloc); - sndifwork.pcmbufalloc = 0; - sndifwork.pcmbuftop = 0; - sndifwork.bufferbytes = 0; - } -} -static int SNDIFInit(int buffersize) -{ - u32 bufferbytes = buffersize * sizeof(s16); - SNDIFDeInit(); - sndifwork.pcmbufalloc = malloc(bufferbytes + 3); - if (!sndifwork.pcmbufalloc) - return -1; - sndifwork.pcmbuftop = sndifwork.pcmbufalloc + ((4 - (((int)sndifwork.pcmbufalloc) & 3)) & 3); - sndifwork.bufferbytes = bufferbytes; - sndifwork.filled = 0; - sndifwork.used = 0; - sndifwork.cycles = 0; - return 0; -} -static void SNDIFMuteAudio(void) -{ -} -static void SNDIFUnMuteAudio(void) -{ -} -static void SNDIFSetVolume(int volume) -{ -} -static int SNDIFGetAudioSpace(void) -{ - return sndifwork.bufferbytes >> 2; // bytes to samples -} -static void SNDIFUpdateAudio(s16 * buffer, u32 num_samples) -{ - u32 num_bytes = num_samples << 2; - if (num_bytes > sndifwork.bufferbytes) num_bytes = sndifwork.bufferbytes; - memcpy(sndifwork.pcmbuftop, buffer, num_bytes); - sndifwork.filled = num_bytes; - sndifwork.used = 0; -} -#define VIO2SFSNDIFID 0 -static SoundInterface_struct VIO2SFSNDIF = -{ - VIO2SFSNDIFID, - "vio2sf Sound Interface", - SNDIFInit, - SNDIFDeInit, - SNDIFUpdateAudio, - SNDIFGetAudioSpace, - SNDIFMuteAudio, - SNDIFUnMuteAudio, - SNDIFSetVolume -}; - -SoundInterface_struct *SNDCoreList[] = { - &VIO2SFSNDIF, - NULL -}; - -static struct armcpu_ctrl_iface *arm9_ctrl_iface = 0; -static struct armcpu_ctrl_iface *arm7_ctrl_iface = 0; - -int xsf_start(void *pfile, unsigned bytes) -{ - int frames = xsf_tagget_int("_frames", pfile, bytes, -1); - int clockdown = xsf_tagget_int("_clockdown", pfile, bytes, 0); - sndifwork.sync_type = xsf_tagget_int("_vio2sf_sync_type", pfile, bytes, 0); - sndifwork.arm9_clockdown_level = xsf_tagget_int("_vio2sf_arm9_clockdown_level", pfile, bytes, clockdown); - sndifwork.arm7_clockdown_level = xsf_tagget_int("_vio2sf_arm7_clockdown_level", pfile, bytes, clockdown); - - sndifwork.xfs_load = 0; - if (!load_psf(pfile, bytes)) - return XSF_FALSE; - -#ifdef GDB_STUB - if (NDS_Init(&arm9_base_memory_iface, &arm9_ctrl_iface, &arm7_base_memory_iface, &arm7_ctrl_iface)) -#else - if (NDS_Init()) -#endif - return XSF_FALSE; - - SPU_ChangeSoundCore(0, 737); - - execute = FALSE; - - MMU_unsetRom(); - if (loaderwork.rom) - { - NDS_SetROM(loaderwork.rom, loaderwork.romsize - 1); - } - - NDS_Reset(); - - execute = TRUE; - - if (loaderwork.state) - { - armcp15_t *c9 = (armcp15_t *)NDS_ARM9.coproc[15]; - int proc; - if (frames == -1) - { - - /* set initial ARM9 coprocessor state */ - - armcp15_moveARM2CP(c9, 0x00000000, 0x01, 0x00, 0, 0); - armcp15_moveARM2CP(c9, 0x00000000, 0x07, 0x05, 0, 0); - armcp15_moveARM2CP(c9, 0x00000000, 0x07, 0x06, 0, 0); - armcp15_moveARM2CP(c9, 0x00000000, 0x07, 0x0a, 0, 4); - armcp15_moveARM2CP(c9, 0x04000033, 0x06, 0x00, 0, 4); - armcp15_moveARM2CP(c9, 0x0200002d, 0x06, 0x01, 0, 0); - armcp15_moveARM2CP(c9, 0x027e0021, 0x06, 0x02, 0, 0); - armcp15_moveARM2CP(c9, 0x08000035, 0x06, 0x03, 0, 0); - armcp15_moveARM2CP(c9, 0x027e001b, 0x06, 0x04, 0, 0); - armcp15_moveARM2CP(c9, 0x0100002f, 0x06, 0x05, 0, 0); - armcp15_moveARM2CP(c9, 0xffff001d, 0x06, 0x06, 0, 0); - armcp15_moveARM2CP(c9, 0x027ff017, 0x06, 0x07, 0, 0); - armcp15_moveARM2CP(c9, 0x00000020, 0x09, 0x01, 0, 1); - - armcp15_moveARM2CP(c9, 0x027e000a, 0x09, 0x01, 0, 0); - - armcp15_moveARM2CP(c9, 0x00000042, 0x02, 0x00, 0, 1); - armcp15_moveARM2CP(c9, 0x00000042, 0x02, 0x00, 0, 0); - armcp15_moveARM2CP(c9, 0x00000002, 0x03, 0x00, 0, 0); - armcp15_moveARM2CP(c9, 0x05100011, 0x05, 0x00, 0, 3); - armcp15_moveARM2CP(c9, 0x15111011, 0x05, 0x00, 0, 2); - armcp15_moveARM2CP(c9, 0x07dd1e10, 0x01, 0x00, 0, 0); - armcp15_moveARM2CP(c9, 0x0005707d, 0x01, 0x00, 0, 0); - - armcp15_moveARM2CP(c9, 0x00000000, 0x07, 0x0a, 0, 4); - armcp15_moveARM2CP(c9, 0x02004000, 0x07, 0x05, 0, 1); - armcp15_moveARM2CP(c9, 0x02004000, 0x07, 0x0e, 0, 1); - - /* set initial timer state */ - - MMU_write16(0, REG_TM0CNTL, 0x0000); - MMU_write16(0, REG_TM0CNTH, 0x00C1); - MMU_write16(1, REG_TM0CNTL, 0x0000); - MMU_write16(1, REG_TM0CNTH, 0x00C1); - MMU_write16(1, REG_TM1CNTL, 0xf7e7); - MMU_write16(1, REG_TM1CNTH, 0x00C1); - - /* set initial interrupt state */ - - MMU.reg_IME[0] = 0x00000001; - MMU.reg_IE[0] = 0x00042001; - MMU.reg_IME[1] = 0x00000001; - MMU.reg_IE[1] = 0x0104009d; - } - else if (frames > 0) - { - /* execute boot code */ - int i; - for (i=0; i 0) - { - /* skip 1 sec */ - int i; - for (i=0; i 0) - { - if (remainbytes > bytes) - { - memcpy(ptr, sndifwork.pcmbuftop + sndifwork.used, bytes); - sndifwork.used += bytes; - ptr += bytes; - remainbytes -= bytes; /**/ - bytes = 0; /**/ - break; - } - else - { - memcpy(ptr, sndifwork.pcmbuftop + sndifwork.used, remainbytes); - sndifwork.used += remainbytes; - ptr += remainbytes; - bytes -= remainbytes; - remainbytes = 0; - } - } - if (remainbytes == 0) - { - -/* -#define HBASE_CYCLES (16756000*2) -#define HBASE_CYCLES (33512000*1) -#define HBASE_CYCLES (33509300.322234) -*/ -#define HBASE_CYCLES (33509300.322234) -#define HLINE_CYCLES (6 * (99 + 256)) -#define HSAMPLES ((u32)((44100.0 * HLINE_CYCLES) / HBASE_CYCLES)) -#define VDIVISION 100 -#define VLINES 263 -#define VBASE_CYCLES (((double)HBASE_CYCLES) / VDIVISION) -#define VSAMPLES ((u32)((44100.0 * HLINE_CYCLES * VLINES) / HBASE_CYCLES)) - - int numsamples; - if (sndifwork.sync_type == 1) - { - /* vsync */ - sndifwork.cycles += ((44100 / VDIVISION) * HLINE_CYCLES * VLINES); - if (sndifwork.cycles >= (u32)(VBASE_CYCLES * (VSAMPLES + 1))) - { - numsamples = (VSAMPLES + 1); - sndifwork.cycles -= (u32)(VBASE_CYCLES * (VSAMPLES + 1)); - } - else - { - numsamples = (VSAMPLES + 0); - sndifwork.cycles -= (u32)(VBASE_CYCLES * (VSAMPLES + 0)); - } - NDS_exec_frame(sndifwork.arm9_clockdown_level, sndifwork.arm7_clockdown_level); - } - else - { - /* hsync */ - sndifwork.cycles += (44100 * HLINE_CYCLES); - if (sndifwork.cycles >= (u32)(HBASE_CYCLES * (HSAMPLES + 1))) - { - numsamples = (HSAMPLES + 1); - sndifwork.cycles -= (u32)(HBASE_CYCLES * (HSAMPLES + 1)); - } - else - { - numsamples = (HSAMPLES + 0); - sndifwork.cycles -= (u32)(HBASE_CYCLES * (HSAMPLES + 0)); - } - NDS_exec_hframe(sndifwork.arm9_clockdown_level, sndifwork.arm7_clockdown_level); - } - SPU_EmulateSamples(numsamples); - } - } - return ptr - (unsigned char *)pbuffer; -} - -void xsf_term(void) -{ - MMU_unsetRom(); - NDS_DeInit(); - load_term(); -} diff --git a/tools/vio2sf/src/vio2sf/zlib/adler32.c b/tools/vio2sf/src/vio2sf/zlib/adler32.c deleted file mode 100644 index f201d6701..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/adler32.c +++ /dev/null @@ -1,149 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -#define BASE 65521UL /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware */ -#ifdef NO_DIVIDE -# define MOD(a) \ - do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD4(a) \ - do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD4(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 > BASE) sum1 -= BASE; - if (sum1 > BASE) sum1 -= BASE; - if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); - if (sum2 > BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/README.contrib b/tools/vio2sf/src/vio2sf/zlib/contrib/README.contrib deleted file mode 100644 index 1e05c4f18..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/README.contrib +++ /dev/null @@ -1,17 +0,0 @@ -All files under this contrib directory are UNSUPPORTED. There were -provided by users of zlib and were not tested by the authors of zlib. -Use at your own risk. Please contact the authors of the contributions -for help about these, not the zlib authors. Thanks. - - -inflate86/ by Chris Anderson - Tuned x86 gcc asm code to replace inflate_fast() - -masmx64/ by Gilles Vollant - x86 64-bit (AMD64 and Intel EM64t) code for x64 assembler to - replace longest_match() and inflate_fast() - -masmx86/ by Gilles Vollant - x86 asm code to replace longest_match() and inflate_fast(), - for Visual C++ and MASM - diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/inflate86/inffas86.c b/tools/vio2sf/src/vio2sf/zlib/contrib/inflate86/inffas86.c deleted file mode 100644 index 6da76358c..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/inflate86/inffas86.c +++ /dev/null @@ -1,1157 +0,0 @@ -/* inffas86.c is a hand tuned assembler version of - * - * inffast.c -- fast decoding - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Copyright (C) 2003 Chris Anderson - * Please use the copyright conditions above. - * - * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also - * slightly quicker on x86 systems because, instead of using rep movsb to copy - * data, it uses rep movsw, which moves data in 2-byte chunks instead of single - * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates - * from http://fedora.linux.duke.edu/fc1_x86_64 - * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with - * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version, - * when decompressing mozilla-source-1.3.tar.gz. - * - * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from - * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at - * the moment. I have successfully compiled and tested this code with gcc2.96, - * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S - * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX - * enabled. I will attempt to merge the MMX code into this version. Newer - * versions of this and inffast.S can be found at - * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* Mark Adler's comments from inffast.c: */ - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - struct inffast_ar { -/* 64 32 x86 x86_64 */ -/* ar offset register */ -/* 0 0 */ void *esp; /* esp save */ -/* 8 4 */ void *ebp; /* ebp save */ -/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */ -/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */ -/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */ -/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */ -/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */ -/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */ -/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */ -/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */ -/* 80 40 */ unsigned long hold; /* edx rdx local strm->hold */ -/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */ -/* 92 48 */ unsigned wsize; /* window size */ -/* 96 52 */ unsigned write; /* window write index */ -/*100 56 */ unsigned lmask; /* r12 mask for lcode */ -/*104 60 */ unsigned dmask; /* r13 mask for dcode */ -/*108 64 */ unsigned len; /* r14 match length */ -/*112 68 */ unsigned dist; /* r15 match distance */ -/*116 72 */ unsigned status; /* set when state chng*/ - } ar; - -#if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 ) -#define PAD_AVAIL_IN 6 -#define PAD_AVAIL_OUT 258 -#else -#define PAD_AVAIL_IN 5 -#define PAD_AVAIL_OUT 257 -#endif - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - ar.in = strm->next_in; - ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN); - ar.out = strm->next_out; - ar.beg = ar.out - (start - strm->avail_out); - ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT); - ar.wsize = state->wsize; - ar.write = state->write; - ar.window = state->window; - ar.hold = state->hold; - ar.bits = state->bits; - ar.lcode = state->lencode; - ar.dcode = state->distcode; - ar.lmask = (1U << state->lenbits) - 1; - ar.dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - - /* align in on 1/2 hold size boundary */ - while (((unsigned long)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) { - ar.hold += (unsigned long)*ar.in++ << ar.bits; - ar.bits += 8; - } - -#if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 ) - __asm__ __volatile__ ( -" leaq %0, %%rax\n" -" movq %%rbp, 8(%%rax)\n" /* save regs rbp and rsp */ -" movq %%rsp, (%%rax)\n" -" movq %%rax, %%rsp\n" /* make rsp point to &ar */ -" movq 16(%%rsp), %%rsi\n" /* rsi = in */ -" movq 32(%%rsp), %%rdi\n" /* rdi = out */ -" movq 24(%%rsp), %%r9\n" /* r9 = last */ -" movq 48(%%rsp), %%r10\n" /* r10 = end */ -" movq 64(%%rsp), %%rbp\n" /* rbp = lcode */ -" movq 72(%%rsp), %%r11\n" /* r11 = dcode */ -" movq 80(%%rsp), %%rdx\n" /* rdx = hold */ -" movl 88(%%rsp), %%ebx\n" /* ebx = bits */ -" movl 100(%%rsp), %%r12d\n" /* r12d = lmask */ -" movl 104(%%rsp), %%r13d\n" /* r13d = dmask */ - /* r14d = len */ - /* r15d = dist */ -" cld\n" -" cmpq %%rdi, %%r10\n" -" je .L_one_time\n" /* if only one decode left */ -" cmpq %%rsi, %%r9\n" -" je .L_one_time\n" -" jmp .L_do_loop\n" - -".L_one_time:\n" -" movq %%r12, %%r8\n" /* r8 = lmask */ -" cmpb $32, %%bl\n" -" ja .L_get_length_code_one_time\n" - -" lodsl\n" /* eax = *(uint *)in++ */ -" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ -" addb $32, %%bl\n" /* bits += 32 */ -" shlq %%cl, %%rax\n" -" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ -" jmp .L_get_length_code_one_time\n" - -".align 32,0x90\n" -".L_while_test:\n" -" cmpq %%rdi, %%r10\n" -" jbe .L_break_loop\n" -" cmpq %%rsi, %%r9\n" -" jbe .L_break_loop\n" - -".L_do_loop:\n" -" movq %%r12, %%r8\n" /* r8 = lmask */ -" cmpb $32, %%bl\n" -" ja .L_get_length_code\n" /* if (32 < bits) */ - -" lodsl\n" /* eax = *(uint *)in++ */ -" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ -" addb $32, %%bl\n" /* bits += 32 */ -" shlq %%cl, %%rax\n" -" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ - -".L_get_length_code:\n" -" andq %%rdx, %%r8\n" /* r8 &= hold */ -" movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */ - -" movb %%ah, %%cl\n" /* cl = this.bits */ -" subb %%ah, %%bl\n" /* bits -= this.bits */ -" shrq %%cl, %%rdx\n" /* hold >>= this.bits */ - -" testb %%al, %%al\n" -" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ - -" movq %%r12, %%r8\n" /* r8 = lmask */ -" shrl $16, %%eax\n" /* output this.val char */ -" stosb\n" - -".L_get_length_code_one_time:\n" -" andq %%rdx, %%r8\n" /* r8 &= hold */ -" movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */ - -".L_dolen:\n" -" movb %%ah, %%cl\n" /* cl = this.bits */ -" subb %%ah, %%bl\n" /* bits -= this.bits */ -" shrq %%cl, %%rdx\n" /* hold >>= this.bits */ - -" testb %%al, %%al\n" -" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ - -" shrl $16, %%eax\n" /* output this.val char */ -" stosb\n" -" jmp .L_while_test\n" - -".align 32,0x90\n" -".L_test_for_length_base:\n" -" movl %%eax, %%r14d\n" /* len = this */ -" shrl $16, %%r14d\n" /* len = this.val */ -" movb %%al, %%cl\n" - -" testb $16, %%al\n" -" jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */ -" andb $15, %%cl\n" /* op &= 15 */ -" jz .L_decode_distance\n" /* if (!op) */ - -".L_add_bits_to_len:\n" -" subb %%cl, %%bl\n" -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" -" andl %%edx, %%eax\n" /* eax &= hold */ -" shrq %%cl, %%rdx\n" -" addl %%eax, %%r14d\n" /* len += hold & mask[op] */ - -".L_decode_distance:\n" -" movq %%r13, %%r8\n" /* r8 = dmask */ -" cmpb $32, %%bl\n" -" ja .L_get_distance_code\n" /* if (32 < bits) */ - -" lodsl\n" /* eax = *(uint *)in++ */ -" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ -" addb $32, %%bl\n" /* bits += 32 */ -" shlq %%cl, %%rax\n" -" orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ - -".L_get_distance_code:\n" -" andq %%rdx, %%r8\n" /* r8 &= hold */ -" movl (%%r11,%%r8,4), %%eax\n" /* eax = dcode[hold & dmask] */ - -".L_dodist:\n" -" movl %%eax, %%r15d\n" /* dist = this */ -" shrl $16, %%r15d\n" /* dist = this.val */ -" movb %%ah, %%cl\n" -" subb %%ah, %%bl\n" /* bits -= this.bits */ -" shrq %%cl, %%rdx\n" /* hold >>= this.bits */ -" movb %%al, %%cl\n" /* cl = this.op */ - -" testb $16, %%al\n" /* if ((op & 16) == 0) */ -" jz .L_test_for_second_level_dist\n" -" andb $15, %%cl\n" /* op &= 15 */ -" jz .L_check_dist_one\n" - -".L_add_bits_to_dist:\n" -" subb %%cl, %%bl\n" -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" /* (1 << op) - 1 */ -" andl %%edx, %%eax\n" /* eax &= hold */ -" shrq %%cl, %%rdx\n" -" addl %%eax, %%r15d\n" /* dist += hold & ((1 << op) - 1) */ - -".L_check_window:\n" -" movq %%rsi, %%r8\n" /* save in so from can use it's reg */ -" movq %%rdi, %%rax\n" -" subq 40(%%rsp), %%rax\n" /* nbytes = out - beg */ - -" cmpl %%r15d, %%eax\n" -" jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */ - -" movl %%r14d, %%ecx\n" /* ecx = len */ -" movq %%rdi, %%rsi\n" -" subq %%r15, %%rsi\n" /* from = out - dist */ - -" sarl %%ecx\n" -" jnc .L_copy_two\n" /* if len % 2 == 0 */ - -" rep movsw\n" -" movb (%%rsi), %%al\n" -" movb %%al, (%%rdi)\n" -" incq %%rdi\n" - -" movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */ -" jmp .L_while_test\n" - -".L_copy_two:\n" -" rep movsw\n" -" movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */ -" jmp .L_while_test\n" - -".align 32,0x90\n" -".L_check_dist_one:\n" -" cmpl $1, %%r15d\n" /* if dist 1, is a memset */ -" jne .L_check_window\n" -" cmpq %%rdi, 40(%%rsp)\n" /* if out == beg, outside window */ -" je .L_check_window\n" - -" movl %%r14d, %%ecx\n" /* ecx = len */ -" movb -1(%%rdi), %%al\n" -" movb %%al, %%ah\n" - -" sarl %%ecx\n" -" jnc .L_set_two\n" -" movb %%al, (%%rdi)\n" -" incq %%rdi\n" - -".L_set_two:\n" -" rep stosw\n" -" jmp .L_while_test\n" - -".align 32,0x90\n" -".L_test_for_second_level_length:\n" -" testb $64, %%al\n" -" jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */ - -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" -" andl %%edx, %%eax\n" /* eax &= hold */ -" addl %%r14d, %%eax\n" /* eax += len */ -" movl (%%rbp,%%rax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/ -" jmp .L_dolen\n" - -".align 32,0x90\n" -".L_test_for_second_level_dist:\n" -" testb $64, %%al\n" -" jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */ - -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" -" andl %%edx, %%eax\n" /* eax &= hold */ -" addl %%r15d, %%eax\n" /* eax += dist */ -" movl (%%r11,%%rax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/ -" jmp .L_dodist\n" - -".align 32,0x90\n" -".L_clip_window:\n" -" movl %%eax, %%ecx\n" /* ecx = nbytes */ -" movl 92(%%rsp), %%eax\n" /* eax = wsize, prepare for dist cmp */ -" negl %%ecx\n" /* nbytes = -nbytes */ - -" cmpl %%r15d, %%eax\n" -" jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */ - -" addl %%r15d, %%ecx\n" /* nbytes = dist - nbytes */ -" cmpl $0, 96(%%rsp)\n" -" jne .L_wrap_around_window\n" /* if (write != 0) */ - -" movq 56(%%rsp), %%rsi\n" /* from = window */ -" subl %%ecx, %%eax\n" /* eax -= nbytes */ -" addq %%rax, %%rsi\n" /* from += wsize - nbytes */ - -" movl %%r14d, %%eax\n" /* eax = len */ -" cmpl %%ecx, %%r14d\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* eax -= nbytes */ -" rep movsb\n" -" movq %%rdi, %%rsi\n" -" subq %%r15, %%rsi\n" /* from = &out[ -dist ] */ -" jmp .L_do_copy\n" - -".align 32,0x90\n" -".L_wrap_around_window:\n" -" movl 96(%%rsp), %%eax\n" /* eax = write */ -" cmpl %%eax, %%ecx\n" -" jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */ - -" movl 92(%%rsp), %%esi\n" /* from = wsize */ -" addq 56(%%rsp), %%rsi\n" /* from += window */ -" addq %%rax, %%rsi\n" /* from += write */ -" subq %%rcx, %%rsi\n" /* from -= nbytes */ -" subl %%eax, %%ecx\n" /* nbytes -= write */ - -" movl %%r14d, %%eax\n" /* eax = len */ -" cmpl %%ecx, %%eax\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* len -= nbytes */ -" rep movsb\n" -" movq 56(%%rsp), %%rsi\n" /* from = window */ -" movl 96(%%rsp), %%ecx\n" /* nbytes = write */ -" cmpl %%ecx, %%eax\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* len -= nbytes */ -" rep movsb\n" -" movq %%rdi, %%rsi\n" -" subq %%r15, %%rsi\n" /* from = out - dist */ -" jmp .L_do_copy\n" - -".align 32,0x90\n" -".L_contiguous_in_window:\n" -" movq 56(%%rsp), %%rsi\n" /* rsi = window */ -" addq %%rax, %%rsi\n" -" subq %%rcx, %%rsi\n" /* from += write - nbytes */ - -" movl %%r14d, %%eax\n" /* eax = len */ -" cmpl %%ecx, %%eax\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* len -= nbytes */ -" rep movsb\n" -" movq %%rdi, %%rsi\n" -" subq %%r15, %%rsi\n" /* from = out - dist */ -" jmp .L_do_copy\n" /* if (nbytes >= len) */ - -".align 32,0x90\n" -".L_do_copy:\n" -" movl %%eax, %%ecx\n" /* ecx = len */ -" rep movsb\n" - -" movq %%r8, %%rsi\n" /* move in back to %esi, toss from */ -" jmp .L_while_test\n" - -".L_test_for_end_of_block:\n" -" testb $32, %%al\n" -" jz .L_invalid_literal_length_code\n" -" movl $1, 116(%%rsp)\n" -" jmp .L_break_loop_with_status\n" - -".L_invalid_literal_length_code:\n" -" movl $2, 116(%%rsp)\n" -" jmp .L_break_loop_with_status\n" - -".L_invalid_distance_code:\n" -" movl $3, 116(%%rsp)\n" -" jmp .L_break_loop_with_status\n" - -".L_invalid_distance_too_far:\n" -" movl $4, 116(%%rsp)\n" -" jmp .L_break_loop_with_status\n" - -".L_break_loop:\n" -" movl $0, 116(%%rsp)\n" - -".L_break_loop_with_status:\n" -/* put in, out, bits, and hold back into ar and pop esp */ -" movq %%rsi, 16(%%rsp)\n" /* in */ -" movq %%rdi, 32(%%rsp)\n" /* out */ -" movl %%ebx, 88(%%rsp)\n" /* bits */ -" movq %%rdx, 80(%%rsp)\n" /* hold */ -" movq (%%rsp), %%rax\n" /* restore rbp and rsp */ -" movq 8(%%rsp), %%rbp\n" -" movq %%rax, %%rsp\n" - : - : "m" (ar) - : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", - "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" - ); -#elif ( defined( __GNUC__ ) || defined( __ICC ) ) && defined( __i386 ) - __asm__ __volatile__ ( -" leal %0, %%eax\n" -" movl %%esp, (%%eax)\n" /* save esp, ebp */ -" movl %%ebp, 4(%%eax)\n" -" movl %%eax, %%esp\n" -" movl 8(%%esp), %%esi\n" /* esi = in */ -" movl 16(%%esp), %%edi\n" /* edi = out */ -" movl 40(%%esp), %%edx\n" /* edx = hold */ -" movl 44(%%esp), %%ebx\n" /* ebx = bits */ -" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ - -" cld\n" -" jmp .L_do_loop\n" - -".align 32,0x90\n" -".L_while_test:\n" -" cmpl %%edi, 24(%%esp)\n" /* out < end */ -" jbe .L_break_loop\n" -" cmpl %%esi, 12(%%esp)\n" /* in < last */ -" jbe .L_break_loop\n" - -".L_do_loop:\n" -" cmpb $15, %%bl\n" -" ja .L_get_length_code\n" /* if (15 < bits) */ - -" xorl %%eax, %%eax\n" -" lodsw\n" /* al = *(ushort *)in++ */ -" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ -" addb $16, %%bl\n" /* bits += 16 */ -" shll %%cl, %%eax\n" -" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ - -".L_get_length_code:\n" -" movl 56(%%esp), %%eax\n" /* eax = lmask */ -" andl %%edx, %%eax\n" /* eax &= hold */ -" movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[hold & lmask] */ - -".L_dolen:\n" -" movb %%ah, %%cl\n" /* cl = this.bits */ -" subb %%ah, %%bl\n" /* bits -= this.bits */ -" shrl %%cl, %%edx\n" /* hold >>= this.bits */ - -" testb %%al, %%al\n" -" jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ - -" shrl $16, %%eax\n" /* output this.val char */ -" stosb\n" -" jmp .L_while_test\n" - -".align 32,0x90\n" -".L_test_for_length_base:\n" -" movl %%eax, %%ecx\n" /* len = this */ -" shrl $16, %%ecx\n" /* len = this.val */ -" movl %%ecx, 64(%%esp)\n" /* save len */ -" movb %%al, %%cl\n" - -" testb $16, %%al\n" -" jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */ -" andb $15, %%cl\n" /* op &= 15 */ -" jz .L_decode_distance\n" /* if (!op) */ -" cmpb %%cl, %%bl\n" -" jae .L_add_bits_to_len\n" /* if (op <= bits) */ - -" movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ -" xorl %%eax, %%eax\n" -" lodsw\n" /* al = *(ushort *)in++ */ -" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ -" addb $16, %%bl\n" /* bits += 16 */ -" shll %%cl, %%eax\n" -" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ -" movb %%ch, %%cl\n" /* move op back to ecx */ - -".L_add_bits_to_len:\n" -" subb %%cl, %%bl\n" -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" -" andl %%edx, %%eax\n" /* eax &= hold */ -" shrl %%cl, %%edx\n" -" addl %%eax, 64(%%esp)\n" /* len += hold & mask[op] */ - -".L_decode_distance:\n" -" cmpb $15, %%bl\n" -" ja .L_get_distance_code\n" /* if (15 < bits) */ - -" xorl %%eax, %%eax\n" -" lodsw\n" /* al = *(ushort *)in++ */ -" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ -" addb $16, %%bl\n" /* bits += 16 */ -" shll %%cl, %%eax\n" -" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ - -".L_get_distance_code:\n" -" movl 60(%%esp), %%eax\n" /* eax = dmask */ -" movl 36(%%esp), %%ecx\n" /* ecx = dcode */ -" andl %%edx, %%eax\n" /* eax &= hold */ -" movl (%%ecx,%%eax,4), %%eax\n"/* eax = dcode[hold & dmask] */ - -".L_dodist:\n" -" movl %%eax, %%ebp\n" /* dist = this */ -" shrl $16, %%ebp\n" /* dist = this.val */ -" movb %%ah, %%cl\n" -" subb %%ah, %%bl\n" /* bits -= this.bits */ -" shrl %%cl, %%edx\n" /* hold >>= this.bits */ -" movb %%al, %%cl\n" /* cl = this.op */ - -" testb $16, %%al\n" /* if ((op & 16) == 0) */ -" jz .L_test_for_second_level_dist\n" -" andb $15, %%cl\n" /* op &= 15 */ -" jz .L_check_dist_one\n" -" cmpb %%cl, %%bl\n" -" jae .L_add_bits_to_dist\n" /* if (op <= bits) 97.6% */ - -" movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ -" xorl %%eax, %%eax\n" -" lodsw\n" /* al = *(ushort *)in++ */ -" movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ -" addb $16, %%bl\n" /* bits += 16 */ -" shll %%cl, %%eax\n" -" orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ -" movb %%ch, %%cl\n" /* move op back to ecx */ - -".L_add_bits_to_dist:\n" -" subb %%cl, %%bl\n" -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" /* (1 << op) - 1 */ -" andl %%edx, %%eax\n" /* eax &= hold */ -" shrl %%cl, %%edx\n" -" addl %%eax, %%ebp\n" /* dist += hold & ((1 << op) - 1) */ - -".L_check_window:\n" -" movl %%esi, 8(%%esp)\n" /* save in so from can use it's reg */ -" movl %%edi, %%eax\n" -" subl 20(%%esp), %%eax\n" /* nbytes = out - beg */ - -" cmpl %%ebp, %%eax\n" -" jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */ - -" movl 64(%%esp), %%ecx\n" /* ecx = len */ -" movl %%edi, %%esi\n" -" subl %%ebp, %%esi\n" /* from = out - dist */ - -" sarl %%ecx\n" -" jnc .L_copy_two\n" /* if len % 2 == 0 */ - -" rep movsw\n" -" movb (%%esi), %%al\n" -" movb %%al, (%%edi)\n" -" incl %%edi\n" - -" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ -" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ -" jmp .L_while_test\n" - -".L_copy_two:\n" -" rep movsw\n" -" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ -" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ -" jmp .L_while_test\n" - -".align 32,0x90\n" -".L_check_dist_one:\n" -" cmpl $1, %%ebp\n" /* if dist 1, is a memset */ -" jne .L_check_window\n" -" cmpl %%edi, 20(%%esp)\n" -" je .L_check_window\n" /* out == beg, if outside window */ - -" movl 64(%%esp), %%ecx\n" /* ecx = len */ -" movb -1(%%edi), %%al\n" -" movb %%al, %%ah\n" - -" sarl %%ecx\n" -" jnc .L_set_two\n" -" movb %%al, (%%edi)\n" -" incl %%edi\n" - -".L_set_two:\n" -" rep stosw\n" -" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ -" jmp .L_while_test\n" - -".align 32,0x90\n" -".L_test_for_second_level_length:\n" -" testb $64, %%al\n" -" jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */ - -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" -" andl %%edx, %%eax\n" /* eax &= hold */ -" addl 64(%%esp), %%eax\n" /* eax += len */ -" movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/ -" jmp .L_dolen\n" - -".align 32,0x90\n" -".L_test_for_second_level_dist:\n" -" testb $64, %%al\n" -" jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */ - -" xorl %%eax, %%eax\n" -" incl %%eax\n" -" shll %%cl, %%eax\n" -" decl %%eax\n" -" andl %%edx, %%eax\n" /* eax &= hold */ -" addl %%ebp, %%eax\n" /* eax += dist */ -" movl 36(%%esp), %%ecx\n" /* ecx = dcode */ -" movl (%%ecx,%%eax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/ -" jmp .L_dodist\n" - -".align 32,0x90\n" -".L_clip_window:\n" -" movl %%eax, %%ecx\n" -" movl 48(%%esp), %%eax\n" /* eax = wsize */ -" negl %%ecx\n" /* nbytes = -nbytes */ -" movl 28(%%esp), %%esi\n" /* from = window */ - -" cmpl %%ebp, %%eax\n" -" jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */ - -" addl %%ebp, %%ecx\n" /* nbytes = dist - nbytes */ -" cmpl $0, 52(%%esp)\n" -" jne .L_wrap_around_window\n" /* if (write != 0) */ - -" subl %%ecx, %%eax\n" -" addl %%eax, %%esi\n" /* from += wsize - nbytes */ - -" movl 64(%%esp), %%eax\n" /* eax = len */ -" cmpl %%ecx, %%eax\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* len -= nbytes */ -" rep movsb\n" -" movl %%edi, %%esi\n" -" subl %%ebp, %%esi\n" /* from = out - dist */ -" jmp .L_do_copy\n" - -".align 32,0x90\n" -".L_wrap_around_window:\n" -" movl 52(%%esp), %%eax\n" /* eax = write */ -" cmpl %%eax, %%ecx\n" -" jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */ - -" addl 48(%%esp), %%esi\n" /* from += wsize */ -" addl %%eax, %%esi\n" /* from += write */ -" subl %%ecx, %%esi\n" /* from -= nbytes */ -" subl %%eax, %%ecx\n" /* nbytes -= write */ - -" movl 64(%%esp), %%eax\n" /* eax = len */ -" cmpl %%ecx, %%eax\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* len -= nbytes */ -" rep movsb\n" -" movl 28(%%esp), %%esi\n" /* from = window */ -" movl 52(%%esp), %%ecx\n" /* nbytes = write */ -" cmpl %%ecx, %%eax\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* len -= nbytes */ -" rep movsb\n" -" movl %%edi, %%esi\n" -" subl %%ebp, %%esi\n" /* from = out - dist */ -" jmp .L_do_copy\n" - -".align 32,0x90\n" -".L_contiguous_in_window:\n" -" addl %%eax, %%esi\n" -" subl %%ecx, %%esi\n" /* from += write - nbytes */ - -" movl 64(%%esp), %%eax\n" /* eax = len */ -" cmpl %%ecx, %%eax\n" -" jbe .L_do_copy\n" /* if (nbytes >= len) */ - -" subl %%ecx, %%eax\n" /* len -= nbytes */ -" rep movsb\n" -" movl %%edi, %%esi\n" -" subl %%ebp, %%esi\n" /* from = out - dist */ -" jmp .L_do_copy\n" /* if (nbytes >= len) */ - -".align 32,0x90\n" -".L_do_copy:\n" -" movl %%eax, %%ecx\n" -" rep movsb\n" - -" movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ -" movl 32(%%esp), %%ebp\n" /* ebp = lcode */ -" jmp .L_while_test\n" - -".L_test_for_end_of_block:\n" -" testb $32, %%al\n" -" jz .L_invalid_literal_length_code\n" -" movl $1, 72(%%esp)\n" -" jmp .L_break_loop_with_status\n" - -".L_invalid_literal_length_code:\n" -" movl $2, 72(%%esp)\n" -" jmp .L_break_loop_with_status\n" - -".L_invalid_distance_code:\n" -" movl $3, 72(%%esp)\n" -" jmp .L_break_loop_with_status\n" - -".L_invalid_distance_too_far:\n" -" movl 8(%%esp), %%esi\n" -" movl $4, 72(%%esp)\n" -" jmp .L_break_loop_with_status\n" - -".L_break_loop:\n" -" movl $0, 72(%%esp)\n" - -".L_break_loop_with_status:\n" -/* put in, out, bits, and hold back into ar and pop esp */ -" movl %%esi, 8(%%esp)\n" /* save in */ -" movl %%edi, 16(%%esp)\n" /* save out */ -" movl %%ebx, 44(%%esp)\n" /* save bits */ -" movl %%edx, 40(%%esp)\n" /* save hold */ -" movl 4(%%esp), %%ebp\n" /* restore esp, ebp */ -" movl (%%esp), %%esp\n" - : - : "m" (ar) - : "memory", "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" - ); -#elif defined( _MSC_VER ) && ! defined( _M_AMD64 ) - __asm { - lea eax, ar - mov [eax], esp /* save esp, ebp */ - mov [eax+4], ebp - mov esp, eax - mov esi, [esp+8] /* esi = in */ - mov edi, [esp+16] /* edi = out */ - mov edx, [esp+40] /* edx = hold */ - mov ebx, [esp+44] /* ebx = bits */ - mov ebp, [esp+32] /* ebp = lcode */ - - cld - jmp L_do_loop - -ALIGN 4 -L_while_test: - cmp [esp+24], edi - jbe L_break_loop - cmp [esp+12], esi - jbe L_break_loop - -L_do_loop: - cmp bl, 15 - ja L_get_length_code /* if (15 < bits) */ - - xor eax, eax - lodsw /* al = *(ushort *)in++ */ - mov cl, bl /* cl = bits, needs it for shifting */ - add bl, 16 /* bits += 16 */ - shl eax, cl - or edx, eax /* hold |= *((ushort *)in)++ << bits */ - -L_get_length_code: - mov eax, [esp+56] /* eax = lmask */ - and eax, edx /* eax &= hold */ - mov eax, [ebp+eax*4] /* eax = lcode[hold & lmask] */ - -L_dolen: - mov cl, ah /* cl = this.bits */ - sub bl, ah /* bits -= this.bits */ - shr edx, cl /* hold >>= this.bits */ - - test al, al - jnz L_test_for_length_base /* if (op != 0) 45.7% */ - - shr eax, 16 /* output this.val char */ - stosb - jmp L_while_test - -ALIGN 4 -L_test_for_length_base: - mov ecx, eax /* len = this */ - shr ecx, 16 /* len = this.val */ - mov [esp+64], ecx /* save len */ - mov cl, al - - test al, 16 - jz L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ - and cl, 15 /* op &= 15 */ - jz L_decode_distance /* if (!op) */ - cmp bl, cl - jae L_add_bits_to_len /* if (op <= bits) */ - - mov ch, cl /* stash op in ch, freeing cl */ - xor eax, eax - lodsw /* al = *(ushort *)in++ */ - mov cl, bl /* cl = bits, needs it for shifting */ - add bl, 16 /* bits += 16 */ - shl eax, cl - or edx, eax /* hold |= *((ushort *)in)++ << bits */ - mov cl, ch /* move op back to ecx */ - -L_add_bits_to_len: - sub bl, cl - xor eax, eax - inc eax - shl eax, cl - dec eax - and eax, edx /* eax &= hold */ - shr edx, cl - add [esp+64], eax /* len += hold & mask[op] */ - -L_decode_distance: - cmp bl, 15 - ja L_get_distance_code /* if (15 < bits) */ - - xor eax, eax - lodsw /* al = *(ushort *)in++ */ - mov cl, bl /* cl = bits, needs it for shifting */ - add bl, 16 /* bits += 16 */ - shl eax, cl - or edx, eax /* hold |= *((ushort *)in)++ << bits */ - -L_get_distance_code: - mov eax, [esp+60] /* eax = dmask */ - mov ecx, [esp+36] /* ecx = dcode */ - and eax, edx /* eax &= hold */ - mov eax, [ecx+eax*4]/* eax = dcode[hold & dmask] */ - -L_dodist: - mov ebp, eax /* dist = this */ - shr ebp, 16 /* dist = this.val */ - mov cl, ah - sub bl, ah /* bits -= this.bits */ - shr edx, cl /* hold >>= this.bits */ - mov cl, al /* cl = this.op */ - - test al, 16 /* if ((op & 16) == 0) */ - jz L_test_for_second_level_dist - and cl, 15 /* op &= 15 */ - jz L_check_dist_one - cmp bl, cl - jae L_add_bits_to_dist /* if (op <= bits) 97.6% */ - - mov ch, cl /* stash op in ch, freeing cl */ - xor eax, eax - lodsw /* al = *(ushort *)in++ */ - mov cl, bl /* cl = bits, needs it for shifting */ - add bl, 16 /* bits += 16 */ - shl eax, cl - or edx, eax /* hold |= *((ushort *)in)++ << bits */ - mov cl, ch /* move op back to ecx */ - -L_add_bits_to_dist: - sub bl, cl - xor eax, eax - inc eax - shl eax, cl - dec eax /* (1 << op) - 1 */ - and eax, edx /* eax &= hold */ - shr edx, cl - add ebp, eax /* dist += hold & ((1 << op) - 1) */ - -L_check_window: - mov [esp+8], esi /* save in so from can use it's reg */ - mov eax, edi - sub eax, [esp+20] /* nbytes = out - beg */ - - cmp eax, ebp - jb L_clip_window /* if (dist > nbytes) 4.2% */ - - mov ecx, [esp+64] /* ecx = len */ - mov esi, edi - sub esi, ebp /* from = out - dist */ - - sar ecx, 1 - jnc L_copy_two - - rep movsw - mov al, [esi] - mov [edi], al - inc edi - - mov esi, [esp+8] /* move in back to %esi, toss from */ - mov ebp, [esp+32] /* ebp = lcode */ - jmp L_while_test - -L_copy_two: - rep movsw - mov esi, [esp+8] /* move in back to %esi, toss from */ - mov ebp, [esp+32] /* ebp = lcode */ - jmp L_while_test - -ALIGN 4 -L_check_dist_one: - cmp ebp, 1 /* if dist 1, is a memset */ - jne L_check_window - cmp [esp+20], edi - je L_check_window /* out == beg, if outside window */ - - mov ecx, [esp+64] /* ecx = len */ - mov al, [edi-1] - mov ah, al - - sar ecx, 1 - jnc L_set_two - mov [edi], al /* memset out with from[-1] */ - inc edi - -L_set_two: - rep stosw - mov ebp, [esp+32] /* ebp = lcode */ - jmp L_while_test - -ALIGN 4 -L_test_for_second_level_length: - test al, 64 - jnz L_test_for_end_of_block /* if ((op & 64) != 0) */ - - xor eax, eax - inc eax - shl eax, cl - dec eax - and eax, edx /* eax &= hold */ - add eax, [esp+64] /* eax += len */ - mov eax, [ebp+eax*4] /* eax = lcode[val+(hold&mask[op])]*/ - jmp L_dolen - -ALIGN 4 -L_test_for_second_level_dist: - test al, 64 - jnz L_invalid_distance_code /* if ((op & 64) != 0) */ - - xor eax, eax - inc eax - shl eax, cl - dec eax - and eax, edx /* eax &= hold */ - add eax, ebp /* eax += dist */ - mov ecx, [esp+36] /* ecx = dcode */ - mov eax, [ecx+eax*4] /* eax = dcode[val+(hold&mask[op])]*/ - jmp L_dodist - -ALIGN 4 -L_clip_window: - mov ecx, eax - mov eax, [esp+48] /* eax = wsize */ - neg ecx /* nbytes = -nbytes */ - mov esi, [esp+28] /* from = window */ - - cmp eax, ebp - jb L_invalid_distance_too_far /* if (dist > wsize) */ - - add ecx, ebp /* nbytes = dist - nbytes */ - cmp dword ptr [esp+52], 0 - jne L_wrap_around_window /* if (write != 0) */ - - sub eax, ecx - add esi, eax /* from += wsize - nbytes */ - - mov eax, [esp+64] /* eax = len */ - cmp eax, ecx - jbe L_do_copy /* if (nbytes >= len) */ - - sub eax, ecx /* len -= nbytes */ - rep movsb - mov esi, edi - sub esi, ebp /* from = out - dist */ - jmp L_do_copy - -ALIGN 4 -L_wrap_around_window: - mov eax, [esp+52] /* eax = write */ - cmp ecx, eax - jbe L_contiguous_in_window /* if (write >= nbytes) */ - - add esi, [esp+48] /* from += wsize */ - add esi, eax /* from += write */ - sub esi, ecx /* from -= nbytes */ - sub ecx, eax /* nbytes -= write */ - - mov eax, [esp+64] /* eax = len */ - cmp eax, ecx - jbe L_do_copy /* if (nbytes >= len) */ - - sub eax, ecx /* len -= nbytes */ - rep movsb - mov esi, [esp+28] /* from = window */ - mov ecx, [esp+52] /* nbytes = write */ - cmp eax, ecx - jbe L_do_copy /* if (nbytes >= len) */ - - sub eax, ecx /* len -= nbytes */ - rep movsb - mov esi, edi - sub esi, ebp /* from = out - dist */ - jmp L_do_copy - -ALIGN 4 -L_contiguous_in_window: - add esi, eax - sub esi, ecx /* from += write - nbytes */ - - mov eax, [esp+64] /* eax = len */ - cmp eax, ecx - jbe L_do_copy /* if (nbytes >= len) */ - - sub eax, ecx /* len -= nbytes */ - rep movsb - mov esi, edi - sub esi, ebp /* from = out - dist */ - jmp L_do_copy - -ALIGN 4 -L_do_copy: - mov ecx, eax - rep movsb - - mov esi, [esp+8] /* move in back to %esi, toss from */ - mov ebp, [esp+32] /* ebp = lcode */ - jmp L_while_test - -L_test_for_end_of_block: - test al, 32 - jz L_invalid_literal_length_code - mov dword ptr [esp+72], 1 - jmp L_break_loop_with_status - -L_invalid_literal_length_code: - mov dword ptr [esp+72], 2 - jmp L_break_loop_with_status - -L_invalid_distance_code: - mov dword ptr [esp+72], 3 - jmp L_break_loop_with_status - -L_invalid_distance_too_far: - mov esi, [esp+4] - mov dword ptr [esp+72], 4 - jmp L_break_loop_with_status - -L_break_loop: - mov dword ptr [esp+72], 0 - -L_break_loop_with_status: -/* put in, out, bits, and hold back into ar and pop esp */ - mov [esp+8], esi /* save in */ - mov [esp+16], edi /* save out */ - mov [esp+44], ebx /* save bits */ - mov [esp+40], edx /* save hold */ - mov ebp, [esp+4] /* restore esp, ebp */ - mov esp, [esp] - } -#else -#error "x86 architecture not defined" -#endif - - if (ar.status > 1) { - if (ar.status == 2) - strm->msg = "invalid literal/length code"; - else if (ar.status == 3) - strm->msg = "invalid distance code"; - else - strm->msg = "invalid distance too far back"; - state->mode = BAD; - } - else if ( ar.status == 1 ) { - state->mode = TYPE; - } - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - ar.len = ar.bits >> 3; - ar.in -= ar.len; - ar.bits -= ar.len << 3; - ar.hold &= (1U << ar.bits) - 1; - - /* update state and return */ - strm->next_in = ar.in; - strm->next_out = ar.out; - strm->avail_in = (unsigned)(ar.in < ar.last ? - PAD_AVAIL_IN + (ar.last - ar.in) : - PAD_AVAIL_IN - (ar.in - ar.last)); - strm->avail_out = (unsigned)(ar.out < ar.end ? - PAD_AVAIL_OUT + (ar.end - ar.out) : - PAD_AVAIL_OUT - (ar.out - ar.end)); - state->hold = ar.hold; - state->bits = ar.bits; - return; -} - diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/inflate86/inffast.S b/tools/vio2sf/src/vio2sf/zlib/contrib/inflate86/inffast.S deleted file mode 100644 index 2245a2905..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/inflate86/inffast.S +++ /dev/null @@ -1,1368 +0,0 @@ -/* - * inffast.S is a hand tuned assembler version of: - * - * inffast.c -- fast decoding - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Copyright (C) 2003 Chris Anderson - * Please use the copyright conditions above. - * - * This version (Jan-23-2003) of inflate_fast was coded and tested under - * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution. On that - * machine, I found that gzip style archives decompressed about 20% faster than - * the gcc-3.2 -O3 -fomit-frame-pointer compiled version. Your results will - * depend on how large of a buffer is used for z_stream.next_in & next_out - * (8K-32K worked best for my 256K cpu cache) and how much overhead there is in - * stream processing I/O and crc32/addler32. In my case, this routine used - * 70% of the cpu time and crc32 used 20%. - * - * I am confident that this version will work in the general case, but I have - * not tested a wide variety of datasets or a wide variety of platforms. - * - * Jan-24-2003 -- Added -DUSE_MMX define for slightly faster inflating. - * It should be a runtime flag instead of compile time flag... - * - * Jan-26-2003 -- Added runtime check for MMX support with cpuid instruction. - * With -DUSE_MMX, only MMX code is compiled. With -DNO_MMX, only non-MMX code - * is compiled. Without either option, runtime detection is enabled. Runtime - * detection should work on all modern cpus and the recomended algorithm (flip - * ID bit on eflags and then use the cpuid instruction) is used in many - * multimedia applications. Tested under win2k with gcc-2.95 and gas-2.12 - * distributed with cygwin3. Compiling with gcc-2.95 -c inffast.S -o - * inffast.obj generates a COFF object which can then be linked with MSVC++ - * compiled code. Tested under FreeBSD 4.7 with gcc-2.95. - * - * Jan-28-2003 -- Tested Athlon XP... MMX mode is slower than no MMX (and - * slower than compiler generated code). Adjusted cpuid check to use the MMX - * code only for Pentiums < P4 until I have more data on the P4. Speed - * improvment is only about 15% on the Athlon when compared with code generated - * with MSVC++. Not sure yet, but I think the P4 will also be slower using the - * MMX mode because many of it's x86 ALU instructions execute in .5 cycles and - * have less latency than MMX ops. Added code to buffer the last 11 bytes of - * the input stream since the MMX code grabs bits in chunks of 32, which - * differs from the inffast.c algorithm. I don't think there would have been - * read overruns where a page boundary was crossed (a segfault), but there - * could have been overruns when next_in ends on unaligned memory (unintialized - * memory read). - * - * Mar-13-2003 -- P4 MMX is slightly slower than P4 NO_MMX. I created a C - * version of the non-MMX code so that it doesn't depend on zstrm and zstate - * structure offsets which are hard coded in this file. This was last tested - * with zlib-1.2.0 which is currently in beta testing, newer versions of this - * and inffas86.c can be found at http://www.eetbeetee.com/zlib/ and - * http://www.charm.net/~christop/zlib/ - */ - - -/* - * if you have underscore linking problems (_inflate_fast undefined), try - * using -DGAS_COFF - */ -#if ! defined( GAS_COFF ) && ! defined( GAS_ELF ) - -#if defined( WIN32 ) || defined( __CYGWIN__ ) -#define GAS_COFF /* windows object format */ -#else -#define GAS_ELF -#endif - -#endif /* ! GAS_COFF && ! GAS_ELF */ - - -#if defined( GAS_COFF ) - -/* coff externals have underscores */ -#define inflate_fast _inflate_fast -#define inflate_fast_use_mmx _inflate_fast_use_mmx - -#endif /* GAS_COFF */ - - -.file "inffast.S" - -.globl inflate_fast - -.text -.align 4,0 -.L_invalid_literal_length_code_msg: -.string "invalid literal/length code" - -.align 4,0 -.L_invalid_distance_code_msg: -.string "invalid distance code" - -.align 4,0 -.L_invalid_distance_too_far_msg: -.string "invalid distance too far back" - -#if ! defined( NO_MMX ) -.align 4,0 -.L_mask: /* mask[N] = ( 1 << N ) - 1 */ -.long 0 -.long 1 -.long 3 -.long 7 -.long 15 -.long 31 -.long 63 -.long 127 -.long 255 -.long 511 -.long 1023 -.long 2047 -.long 4095 -.long 8191 -.long 16383 -.long 32767 -.long 65535 -.long 131071 -.long 262143 -.long 524287 -.long 1048575 -.long 2097151 -.long 4194303 -.long 8388607 -.long 16777215 -.long 33554431 -.long 67108863 -.long 134217727 -.long 268435455 -.long 536870911 -.long 1073741823 -.long 2147483647 -.long 4294967295 -#endif /* NO_MMX */ - -.text - -/* - * struct z_stream offsets, in zlib.h - */ -#define next_in_strm 0 /* strm->next_in */ -#define avail_in_strm 4 /* strm->avail_in */ -#define next_out_strm 12 /* strm->next_out */ -#define avail_out_strm 16 /* strm->avail_out */ -#define msg_strm 24 /* strm->msg */ -#define state_strm 28 /* strm->state */ - -/* - * struct inflate_state offsets, in inflate.h - */ -#define mode_state 0 /* state->mode */ -#define wsize_state 32 /* state->wsize */ -#define write_state 40 /* state->write */ -#define window_state 44 /* state->window */ -#define hold_state 48 /* state->hold */ -#define bits_state 52 /* state->bits */ -#define lencode_state 68 /* state->lencode */ -#define distcode_state 72 /* state->distcode */ -#define lenbits_state 76 /* state->lenbits */ -#define distbits_state 80 /* state->distbits */ - -/* - * inflate_fast's activation record - */ -#define local_var_size 64 /* how much local space for vars */ -#define strm_sp 88 /* first arg: z_stream * (local_var_size + 24) */ -#define start_sp 92 /* second arg: unsigned int (local_var_size + 28) */ - -/* - * offsets for local vars on stack - */ -#define out 60 /* unsigned char* */ -#define window 56 /* unsigned char* */ -#define wsize 52 /* unsigned int */ -#define write 48 /* unsigned int */ -#define in 44 /* unsigned char* */ -#define beg 40 /* unsigned char* */ -#define buf 28 /* char[ 12 ] */ -#define len 24 /* unsigned int */ -#define last 20 /* unsigned char* */ -#define end 16 /* unsigned char* */ -#define dcode 12 /* code* */ -#define lcode 8 /* code* */ -#define dmask 4 /* unsigned int */ -#define lmask 0 /* unsigned int */ - -/* - * typedef enum inflate_mode consts, in inflate.h - */ -#define INFLATE_MODE_TYPE 11 /* state->mode flags enum-ed in inflate.h */ -#define INFLATE_MODE_BAD 26 - - -#if ! defined( USE_MMX ) && ! defined( NO_MMX ) - -#define RUN_TIME_MMX - -#define CHECK_MMX 1 -#define DO_USE_MMX 2 -#define DONT_USE_MMX 3 - -.globl inflate_fast_use_mmx - -.data - -.align 4,0 -inflate_fast_use_mmx: /* integer flag for run time control 1=check,2=mmx,3=no */ -.long CHECK_MMX - -#if defined( GAS_ELF ) -/* elf info */ -.type inflate_fast_use_mmx,@object -.size inflate_fast_use_mmx,4 -#endif - -#endif /* RUN_TIME_MMX */ - -#if defined( GAS_COFF ) -/* coff info: scl 2 = extern, type 32 = function */ -.def inflate_fast; .scl 2; .type 32; .endef -#endif - -.text - -.align 32,0x90 -inflate_fast: - pushl %edi - pushl %esi - pushl %ebp - pushl %ebx - pushf /* save eflags (strm_sp, state_sp assumes this is 32 bits) */ - subl $local_var_size, %esp - cld - -#define strm_r %esi -#define state_r %edi - - movl strm_sp(%esp), strm_r - movl state_strm(strm_r), state_r - - /* in = strm->next_in; - * out = strm->next_out; - * last = in + strm->avail_in - 11; - * beg = out - (start - strm->avail_out); - * end = out + (strm->avail_out - 257); - */ - movl avail_in_strm(strm_r), %edx - movl next_in_strm(strm_r), %eax - - addl %eax, %edx /* avail_in += next_in */ - subl $11, %edx /* avail_in -= 11 */ - - movl %eax, in(%esp) - movl %edx, last(%esp) - - movl start_sp(%esp), %ebp - movl avail_out_strm(strm_r), %ecx - movl next_out_strm(strm_r), %ebx - - subl %ecx, %ebp /* start -= avail_out */ - negl %ebp /* start = -start */ - addl %ebx, %ebp /* start += next_out */ - - subl $257, %ecx /* avail_out -= 257 */ - addl %ebx, %ecx /* avail_out += out */ - - movl %ebx, out(%esp) - movl %ebp, beg(%esp) - movl %ecx, end(%esp) - - /* wsize = state->wsize; - * write = state->write; - * window = state->window; - * hold = state->hold; - * bits = state->bits; - * lcode = state->lencode; - * dcode = state->distcode; - * lmask = ( 1 << state->lenbits ) - 1; - * dmask = ( 1 << state->distbits ) - 1; - */ - - movl lencode_state(state_r), %eax - movl distcode_state(state_r), %ecx - - movl %eax, lcode(%esp) - movl %ecx, dcode(%esp) - - movl $1, %eax - movl lenbits_state(state_r), %ecx - shll %cl, %eax - decl %eax - movl %eax, lmask(%esp) - - movl $1, %eax - movl distbits_state(state_r), %ecx - shll %cl, %eax - decl %eax - movl %eax, dmask(%esp) - - movl wsize_state(state_r), %eax - movl write_state(state_r), %ecx - movl window_state(state_r), %edx - - movl %eax, wsize(%esp) - movl %ecx, write(%esp) - movl %edx, window(%esp) - - movl hold_state(state_r), %ebp - movl bits_state(state_r), %ebx - -#undef strm_r -#undef state_r - -#define in_r %esi -#define from_r %esi -#define out_r %edi - - movl in(%esp), in_r - movl last(%esp), %ecx - cmpl in_r, %ecx - ja .L_align_long /* if in < last */ - - addl $11, %ecx /* ecx = &in[ avail_in ] */ - subl in_r, %ecx /* ecx = avail_in */ - movl $12, %eax - subl %ecx, %eax /* eax = 12 - avail_in */ - leal buf(%esp), %edi - rep movsb /* memcpy( buf, in, avail_in ) */ - movl %eax, %ecx - xorl %eax, %eax - rep stosb /* memset( &buf[ avail_in ], 0, 12 - avail_in ) */ - leal buf(%esp), in_r /* in = buf */ - movl in_r, last(%esp) /* last = in, do just one iteration */ - jmp .L_is_aligned - - /* align in_r on long boundary */ -.L_align_long: - testl $3, in_r - jz .L_is_aligned - xorl %eax, %eax - movb (in_r), %al - incl in_r - movl %ebx, %ecx - addl $8, %ebx - shll %cl, %eax - orl %eax, %ebp - jmp .L_align_long - -.L_is_aligned: - movl out(%esp), out_r - -#if defined( NO_MMX ) - jmp .L_do_loop -#endif - -#if defined( USE_MMX ) - jmp .L_init_mmx -#endif - -/*** Runtime MMX check ***/ - -#if defined( RUN_TIME_MMX ) -.L_check_mmx: - cmpl $DO_USE_MMX, inflate_fast_use_mmx - je .L_init_mmx - ja .L_do_loop /* > 2 */ - - pushl %eax - pushl %ebx - pushl %ecx - pushl %edx - pushf - movl (%esp), %eax /* copy eflags to eax */ - xorl $0x200000, (%esp) /* try toggling ID bit of eflags (bit 21) - * to see if cpu supports cpuid... - * ID bit method not supported by NexGen but - * bios may load a cpuid instruction and - * cpuid may be disabled on Cyrix 5-6x86 */ - popf - pushf - popl %edx /* copy new eflags to edx */ - xorl %eax, %edx /* test if ID bit is flipped */ - jz .L_dont_use_mmx /* not flipped if zero */ - xorl %eax, %eax - cpuid - cmpl $0x756e6547, %ebx /* check for GenuineIntel in ebx,ecx,edx */ - jne .L_dont_use_mmx - cmpl $0x6c65746e, %ecx - jne .L_dont_use_mmx - cmpl $0x49656e69, %edx - jne .L_dont_use_mmx - movl $1, %eax - cpuid /* get cpu features */ - shrl $8, %eax - andl $15, %eax - cmpl $6, %eax /* check for Pentium family, is 0xf for P4 */ - jne .L_dont_use_mmx - testl $0x800000, %edx /* test if MMX feature is set (bit 23) */ - jnz .L_use_mmx - jmp .L_dont_use_mmx -.L_use_mmx: - movl $DO_USE_MMX, inflate_fast_use_mmx - jmp .L_check_mmx_pop -.L_dont_use_mmx: - movl $DONT_USE_MMX, inflate_fast_use_mmx -.L_check_mmx_pop: - popl %edx - popl %ecx - popl %ebx - popl %eax - jmp .L_check_mmx -#endif - - -/*** Non-MMX code ***/ - -#if defined ( NO_MMX ) || defined( RUN_TIME_MMX ) - -#define hold_r %ebp -#define bits_r %bl -#define bitslong_r %ebx - -.align 32,0x90 -.L_while_test: - /* while (in < last && out < end) - */ - cmpl out_r, end(%esp) - jbe .L_break_loop /* if (out >= end) */ - - cmpl in_r, last(%esp) - jbe .L_break_loop - -.L_do_loop: - /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out - * - * do { - * if (bits < 15) { - * hold |= *((unsigned short *)in)++ << bits; - * bits += 16 - * } - * this = lcode[hold & lmask] - */ - cmpb $15, bits_r - ja .L_get_length_code /* if (15 < bits) */ - - xorl %eax, %eax - lodsw /* al = *(ushort *)in++ */ - movb bits_r, %cl /* cl = bits, needs it for shifting */ - addb $16, bits_r /* bits += 16 */ - shll %cl, %eax - orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ - -.L_get_length_code: - movl lmask(%esp), %edx /* edx = lmask */ - movl lcode(%esp), %ecx /* ecx = lcode */ - andl hold_r, %edx /* edx &= hold */ - movl (%ecx,%edx,4), %eax /* eax = lcode[hold & lmask] */ - -.L_dolen: - /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out - * - * dolen: - * bits -= this.bits; - * hold >>= this.bits - */ - movb %ah, %cl /* cl = this.bits */ - subb %ah, bits_r /* bits -= this.bits */ - shrl %cl, hold_r /* hold >>= this.bits */ - - /* check if op is a literal - * if (op == 0) { - * PUP(out) = this.val; - * } - */ - testb %al, %al - jnz .L_test_for_length_base /* if (op != 0) 45.7% */ - - shrl $16, %eax /* output this.val char */ - stosb - jmp .L_while_test - -.L_test_for_length_base: - /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = len - * - * else if (op & 16) { - * len = this.val - * op &= 15 - * if (op) { - * if (op > bits) { - * hold |= *((unsigned short *)in)++ << bits; - * bits += 16 - * } - * len += hold & mask[op]; - * bits -= op; - * hold >>= op; - * } - */ -#define len_r %edx - movl %eax, len_r /* len = this */ - shrl $16, len_r /* len = this.val */ - movb %al, %cl - - testb $16, %al - jz .L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ - andb $15, %cl /* op &= 15 */ - jz .L_save_len /* if (!op) */ - cmpb %cl, bits_r - jae .L_add_bits_to_len /* if (op <= bits) */ - - movb %cl, %ch /* stash op in ch, freeing cl */ - xorl %eax, %eax - lodsw /* al = *(ushort *)in++ */ - movb bits_r, %cl /* cl = bits, needs it for shifting */ - addb $16, bits_r /* bits += 16 */ - shll %cl, %eax - orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ - movb %ch, %cl /* move op back to ecx */ - -.L_add_bits_to_len: - movl $1, %eax - shll %cl, %eax - decl %eax - subb %cl, bits_r - andl hold_r, %eax /* eax &= hold */ - shrl %cl, hold_r - addl %eax, len_r /* len += hold & mask[op] */ - -.L_save_len: - movl len_r, len(%esp) /* save len */ -#undef len_r - -.L_decode_distance: - /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = dist - * - * if (bits < 15) { - * hold |= *((unsigned short *)in)++ << bits; - * bits += 16 - * } - * this = dcode[hold & dmask]; - * dodist: - * bits -= this.bits; - * hold >>= this.bits; - * op = this.op; - */ - - cmpb $15, bits_r - ja .L_get_distance_code /* if (15 < bits) */ - - xorl %eax, %eax - lodsw /* al = *(ushort *)in++ */ - movb bits_r, %cl /* cl = bits, needs it for shifting */ - addb $16, bits_r /* bits += 16 */ - shll %cl, %eax - orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ - -.L_get_distance_code: - movl dmask(%esp), %edx /* edx = dmask */ - movl dcode(%esp), %ecx /* ecx = dcode */ - andl hold_r, %edx /* edx &= hold */ - movl (%ecx,%edx,4), %eax /* eax = dcode[hold & dmask] */ - -#define dist_r %edx -.L_dodist: - movl %eax, dist_r /* dist = this */ - shrl $16, dist_r /* dist = this.val */ - movb %ah, %cl - subb %ah, bits_r /* bits -= this.bits */ - shrl %cl, hold_r /* hold >>= this.bits */ - - /* if (op & 16) { - * dist = this.val - * op &= 15 - * if (op > bits) { - * hold |= *((unsigned short *)in)++ << bits; - * bits += 16 - * } - * dist += hold & mask[op]; - * bits -= op; - * hold >>= op; - */ - movb %al, %cl /* cl = this.op */ - - testb $16, %al /* if ((op & 16) == 0) */ - jz .L_test_for_second_level_dist - andb $15, %cl /* op &= 15 */ - jz .L_check_dist_one - cmpb %cl, bits_r - jae .L_add_bits_to_dist /* if (op <= bits) 97.6% */ - - movb %cl, %ch /* stash op in ch, freeing cl */ - xorl %eax, %eax - lodsw /* al = *(ushort *)in++ */ - movb bits_r, %cl /* cl = bits, needs it for shifting */ - addb $16, bits_r /* bits += 16 */ - shll %cl, %eax - orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ - movb %ch, %cl /* move op back to ecx */ - -.L_add_bits_to_dist: - movl $1, %eax - shll %cl, %eax - decl %eax /* (1 << op) - 1 */ - subb %cl, bits_r - andl hold_r, %eax /* eax &= hold */ - shrl %cl, hold_r - addl %eax, dist_r /* dist += hold & ((1 << op) - 1) */ - jmp .L_check_window - -.L_check_window: - /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist - * %ecx = nbytes - * - * nbytes = out - beg; - * if (dist <= nbytes) { - * from = out - dist; - * do { - * PUP(out) = PUP(from); - * } while (--len > 0) { - * } - */ - - movl in_r, in(%esp) /* save in so from can use it's reg */ - movl out_r, %eax - subl beg(%esp), %eax /* nbytes = out - beg */ - - cmpl dist_r, %eax - jb .L_clip_window /* if (dist > nbytes) 4.2% */ - - movl len(%esp), %ecx - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - - subl $3, %ecx - movb (from_r), %al - movb %al, (out_r) - movb 1(from_r), %al - movb 2(from_r), %dl - addl $3, from_r - movb %al, 1(out_r) - movb %dl, 2(out_r) - addl $3, out_r - rep movsb - - movl in(%esp), in_r /* move in back to %esi, toss from */ - jmp .L_while_test - -.align 16,0x90 -.L_check_dist_one: - cmpl $1, dist_r - jne .L_check_window - cmpl out_r, beg(%esp) - je .L_check_window - - decl out_r - movl len(%esp), %ecx - movb (out_r), %al - subl $3, %ecx - - movb %al, 1(out_r) - movb %al, 2(out_r) - movb %al, 3(out_r) - addl $4, out_r - rep stosb - - jmp .L_while_test - -.align 16,0x90 -.L_test_for_second_level_length: - /* else if ((op & 64) == 0) { - * this = lcode[this.val + (hold & mask[op])]; - * } - */ - testb $64, %al - jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ - - movl $1, %eax - shll %cl, %eax - decl %eax - andl hold_r, %eax /* eax &= hold */ - addl %edx, %eax /* eax += this.val */ - movl lcode(%esp), %edx /* edx = lcode */ - movl (%edx,%eax,4), %eax /* eax = lcode[val + (hold&mask[op])] */ - jmp .L_dolen - -.align 16,0x90 -.L_test_for_second_level_dist: - /* else if ((op & 64) == 0) { - * this = dcode[this.val + (hold & mask[op])]; - * } - */ - testb $64, %al - jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ - - movl $1, %eax - shll %cl, %eax - decl %eax - andl hold_r, %eax /* eax &= hold */ - addl %edx, %eax /* eax += this.val */ - movl dcode(%esp), %edx /* edx = dcode */ - movl (%edx,%eax,4), %eax /* eax = dcode[val + (hold&mask[op])] */ - jmp .L_dodist - -.align 16,0x90 -.L_clip_window: - /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist - * %ecx = nbytes - * - * else { - * if (dist > wsize) { - * invalid distance - * } - * from = window; - * nbytes = dist - nbytes; - * if (write == 0) { - * from += wsize - nbytes; - */ -#define nbytes_r %ecx - movl %eax, nbytes_r - movl wsize(%esp), %eax /* prepare for dist compare */ - negl nbytes_r /* nbytes = -nbytes */ - movl window(%esp), from_r /* from = window */ - - cmpl dist_r, %eax - jb .L_invalid_distance_too_far /* if (dist > wsize) */ - - addl dist_r, nbytes_r /* nbytes = dist - nbytes */ - cmpl $0, write(%esp) - jne .L_wrap_around_window /* if (write != 0) */ - - subl nbytes_r, %eax - addl %eax, from_r /* from += wsize - nbytes */ - - /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist - * %ecx = nbytes, %eax = len - * - * if (nbytes < len) { - * len -= nbytes; - * do { - * PUP(out) = PUP(from); - * } while (--nbytes); - * from = out - dist; - * } - * } - */ -#define len_r %eax - movl len(%esp), len_r - cmpl nbytes_r, len_r - jbe .L_do_copy1 /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - jmp .L_do_copy1 - - cmpl nbytes_r, len_r - jbe .L_do_copy1 /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - jmp .L_do_copy1 - -.L_wrap_around_window: - /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist - * %ecx = nbytes, %eax = write, %eax = len - * - * else if (write < nbytes) { - * from += wsize + write - nbytes; - * nbytes -= write; - * if (nbytes < len) { - * len -= nbytes; - * do { - * PUP(out) = PUP(from); - * } while (--nbytes); - * from = window; - * nbytes = write; - * if (nbytes < len) { - * len -= nbytes; - * do { - * PUP(out) = PUP(from); - * } while(--nbytes); - * from = out - dist; - * } - * } - * } - */ -#define write_r %eax - movl write(%esp), write_r - cmpl write_r, nbytes_r - jbe .L_contiguous_in_window /* if (write >= nbytes) */ - - addl wsize(%esp), from_r - addl write_r, from_r - subl nbytes_r, from_r /* from += wsize + write - nbytes */ - subl write_r, nbytes_r /* nbytes -= write */ -#undef write_r - - movl len(%esp), len_r - cmpl nbytes_r, len_r - jbe .L_do_copy1 /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl window(%esp), from_r /* from = window */ - movl write(%esp), nbytes_r /* nbytes = write */ - cmpl nbytes_r, len_r - jbe .L_do_copy1 /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - jmp .L_do_copy1 - -.L_contiguous_in_window: - /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist - * %ecx = nbytes, %eax = write, %eax = len - * - * else { - * from += write - nbytes; - * if (nbytes < len) { - * len -= nbytes; - * do { - * PUP(out) = PUP(from); - * } while (--nbytes); - * from = out - dist; - * } - * } - */ -#define write_r %eax - addl write_r, from_r - subl nbytes_r, from_r /* from += write - nbytes */ -#undef write_r - - movl len(%esp), len_r - cmpl nbytes_r, len_r - jbe .L_do_copy1 /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - -.L_do_copy1: - /* regs: %esi = from, %esi = in, %ebp = hold, %bl = bits, %edi = out - * %eax = len - * - * while (len > 0) { - * PUP(out) = PUP(from); - * len--; - * } - * } - * } while (in < last && out < end); - */ -#undef nbytes_r -#define in_r %esi - movl len_r, %ecx - rep movsb - - movl in(%esp), in_r /* move in back to %esi, toss from */ - jmp .L_while_test - -#undef len_r -#undef dist_r - -#endif /* NO_MMX || RUN_TIME_MMX */ - - -/*** MMX code ***/ - -#if defined( USE_MMX ) || defined( RUN_TIME_MMX ) - -.align 32,0x90 -.L_init_mmx: - emms - -#undef bits_r -#undef bitslong_r -#define bitslong_r %ebp -#define hold_mm %mm0 - movd %ebp, hold_mm - movl %ebx, bitslong_r - -#define used_mm %mm1 -#define dmask2_mm %mm2 -#define lmask2_mm %mm3 -#define lmask_mm %mm4 -#define dmask_mm %mm5 -#define tmp_mm %mm6 - - movd lmask(%esp), lmask_mm - movq lmask_mm, lmask2_mm - movd dmask(%esp), dmask_mm - movq dmask_mm, dmask2_mm - pxor used_mm, used_mm - movl lcode(%esp), %ebx /* ebx = lcode */ - jmp .L_do_loop_mmx - -.align 32,0x90 -.L_while_test_mmx: - /* while (in < last && out < end) - */ - cmpl out_r, end(%esp) - jbe .L_break_loop /* if (out >= end) */ - - cmpl in_r, last(%esp) - jbe .L_break_loop - -.L_do_loop_mmx: - psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ - - cmpl $32, bitslong_r - ja .L_get_length_code_mmx /* if (32 < bits) */ - - movd bitslong_r, tmp_mm - movd (in_r), %mm7 - addl $4, in_r - psllq tmp_mm, %mm7 - addl $32, bitslong_r - por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ - -.L_get_length_code_mmx: - pand hold_mm, lmask_mm - movd lmask_mm, %eax - movq lmask2_mm, lmask_mm - movl (%ebx,%eax,4), %eax /* eax = lcode[hold & lmask] */ - -.L_dolen_mmx: - movzbl %ah, %ecx /* ecx = this.bits */ - movd %ecx, used_mm - subl %ecx, bitslong_r /* bits -= this.bits */ - - testb %al, %al - jnz .L_test_for_length_base_mmx /* if (op != 0) 45.7% */ - - shrl $16, %eax /* output this.val char */ - stosb - jmp .L_while_test_mmx - -.L_test_for_length_base_mmx: -#define len_r %edx - movl %eax, len_r /* len = this */ - shrl $16, len_r /* len = this.val */ - - testb $16, %al - jz .L_test_for_second_level_length_mmx /* if ((op & 16) == 0) 8% */ - andl $15, %eax /* op &= 15 */ - jz .L_decode_distance_mmx /* if (!op) */ - - psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ - movd %eax, used_mm - movd hold_mm, %ecx - subl %eax, bitslong_r - andl .L_mask(,%eax,4), %ecx - addl %ecx, len_r /* len += hold & mask[op] */ - -.L_decode_distance_mmx: - psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ - - cmpl $32, bitslong_r - ja .L_get_dist_code_mmx /* if (32 < bits) */ - - movd bitslong_r, tmp_mm - movd (in_r), %mm7 - addl $4, in_r - psllq tmp_mm, %mm7 - addl $32, bitslong_r - por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ - -.L_get_dist_code_mmx: - movl dcode(%esp), %ebx /* ebx = dcode */ - pand hold_mm, dmask_mm - movd dmask_mm, %eax - movq dmask2_mm, dmask_mm - movl (%ebx,%eax,4), %eax /* eax = dcode[hold & lmask] */ - -.L_dodist_mmx: -#define dist_r %ebx - movzbl %ah, %ecx /* ecx = this.bits */ - movl %eax, dist_r - shrl $16, dist_r /* dist = this.val */ - subl %ecx, bitslong_r /* bits -= this.bits */ - movd %ecx, used_mm - - testb $16, %al /* if ((op & 16) == 0) */ - jz .L_test_for_second_level_dist_mmx - andl $15, %eax /* op &= 15 */ - jz .L_check_dist_one_mmx - -.L_add_bits_to_dist_mmx: - psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ - movd %eax, used_mm /* save bit length of current op */ - movd hold_mm, %ecx /* get the next bits on input stream */ - subl %eax, bitslong_r /* bits -= op bits */ - andl .L_mask(,%eax,4), %ecx /* ecx = hold & mask[op] */ - addl %ecx, dist_r /* dist += hold & mask[op] */ - -.L_check_window_mmx: - movl in_r, in(%esp) /* save in so from can use it's reg */ - movl out_r, %eax - subl beg(%esp), %eax /* nbytes = out - beg */ - - cmpl dist_r, %eax - jb .L_clip_window_mmx /* if (dist > nbytes) 4.2% */ - - movl len_r, %ecx - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - - subl $3, %ecx - movb (from_r), %al - movb %al, (out_r) - movb 1(from_r), %al - movb 2(from_r), %dl - addl $3, from_r - movb %al, 1(out_r) - movb %dl, 2(out_r) - addl $3, out_r - rep movsb - - movl in(%esp), in_r /* move in back to %esi, toss from */ - movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ - jmp .L_while_test_mmx - -.align 16,0x90 -.L_check_dist_one_mmx: - cmpl $1, dist_r - jne .L_check_window_mmx - cmpl out_r, beg(%esp) - je .L_check_window_mmx - - decl out_r - movl len_r, %ecx - movb (out_r), %al - subl $3, %ecx - - movb %al, 1(out_r) - movb %al, 2(out_r) - movb %al, 3(out_r) - addl $4, out_r - rep stosb - - movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ - jmp .L_while_test_mmx - -.align 16,0x90 -.L_test_for_second_level_length_mmx: - testb $64, %al - jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ - - andl $15, %eax - psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ - movd hold_mm, %ecx - andl .L_mask(,%eax,4), %ecx - addl len_r, %ecx - movl (%ebx,%ecx,4), %eax /* eax = lcode[hold & lmask] */ - jmp .L_dolen_mmx - -.align 16,0x90 -.L_test_for_second_level_dist_mmx: - testb $64, %al - jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ - - andl $15, %eax - psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ - movd hold_mm, %ecx - andl .L_mask(,%eax,4), %ecx - movl dcode(%esp), %eax /* ecx = dcode */ - addl dist_r, %ecx - movl (%eax,%ecx,4), %eax /* eax = lcode[hold & lmask] */ - jmp .L_dodist_mmx - -.align 16,0x90 -.L_clip_window_mmx: -#define nbytes_r %ecx - movl %eax, nbytes_r - movl wsize(%esp), %eax /* prepare for dist compare */ - negl nbytes_r /* nbytes = -nbytes */ - movl window(%esp), from_r /* from = window */ - - cmpl dist_r, %eax - jb .L_invalid_distance_too_far /* if (dist > wsize) */ - - addl dist_r, nbytes_r /* nbytes = dist - nbytes */ - cmpl $0, write(%esp) - jne .L_wrap_around_window_mmx /* if (write != 0) */ - - subl nbytes_r, %eax - addl %eax, from_r /* from += wsize - nbytes */ - - cmpl nbytes_r, len_r - jbe .L_do_copy1_mmx /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - jmp .L_do_copy1_mmx - - cmpl nbytes_r, len_r - jbe .L_do_copy1_mmx /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - jmp .L_do_copy1_mmx - -.L_wrap_around_window_mmx: -#define write_r %eax - movl write(%esp), write_r - cmpl write_r, nbytes_r - jbe .L_contiguous_in_window_mmx /* if (write >= nbytes) */ - - addl wsize(%esp), from_r - addl write_r, from_r - subl nbytes_r, from_r /* from += wsize + write - nbytes */ - subl write_r, nbytes_r /* nbytes -= write */ -#undef write_r - - cmpl nbytes_r, len_r - jbe .L_do_copy1_mmx /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl window(%esp), from_r /* from = window */ - movl write(%esp), nbytes_r /* nbytes = write */ - cmpl nbytes_r, len_r - jbe .L_do_copy1_mmx /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - jmp .L_do_copy1_mmx - -.L_contiguous_in_window_mmx: -#define write_r %eax - addl write_r, from_r - subl nbytes_r, from_r /* from += write - nbytes */ -#undef write_r - - cmpl nbytes_r, len_r - jbe .L_do_copy1_mmx /* if (nbytes >= len) */ - - subl nbytes_r, len_r /* len -= nbytes */ - rep movsb - movl out_r, from_r - subl dist_r, from_r /* from = out - dist */ - -.L_do_copy1_mmx: -#undef nbytes_r -#define in_r %esi - movl len_r, %ecx - rep movsb - - movl in(%esp), in_r /* move in back to %esi, toss from */ - movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ - jmp .L_while_test_mmx - -#undef hold_r -#undef bitslong_r - -#endif /* USE_MMX || RUN_TIME_MMX */ - - -/*** USE_MMX, NO_MMX, and RUNTIME_MMX from here on ***/ - -.L_invalid_distance_code: - /* else { - * strm->msg = "invalid distance code"; - * state->mode = BAD; - * } - */ - movl $.L_invalid_distance_code_msg, %ecx - movl $INFLATE_MODE_BAD, %edx - jmp .L_update_stream_state - -.L_test_for_end_of_block: - /* else if (op & 32) { - * state->mode = TYPE; - * break; - * } - */ - testb $32, %al - jz .L_invalid_literal_length_code /* if ((op & 32) == 0) */ - - movl $0, %ecx - movl $INFLATE_MODE_TYPE, %edx - jmp .L_update_stream_state - -.L_invalid_literal_length_code: - /* else { - * strm->msg = "invalid literal/length code"; - * state->mode = BAD; - * } - */ - movl $.L_invalid_literal_length_code_msg, %ecx - movl $INFLATE_MODE_BAD, %edx - jmp .L_update_stream_state - -.L_invalid_distance_too_far: - /* strm->msg = "invalid distance too far back"; - * state->mode = BAD; - */ - movl in(%esp), in_r /* from_r has in's reg, put in back */ - movl $.L_invalid_distance_too_far_msg, %ecx - movl $INFLATE_MODE_BAD, %edx - jmp .L_update_stream_state - -.L_update_stream_state: - /* set strm->msg = %ecx, strm->state->mode = %edx */ - movl strm_sp(%esp), %eax - testl %ecx, %ecx /* if (msg != NULL) */ - jz .L_skip_msg - movl %ecx, msg_strm(%eax) /* strm->msg = msg */ -.L_skip_msg: - movl state_strm(%eax), %eax /* state = strm->state */ - movl %edx, mode_state(%eax) /* state->mode = edx (BAD | TYPE) */ - jmp .L_break_loop - -.align 32,0x90 -.L_break_loop: - -/* - * Regs: - * - * bits = %ebp when mmx, and in %ebx when non-mmx - * hold = %hold_mm when mmx, and in %ebp when non-mmx - * in = %esi - * out = %edi - */ - -#if defined( USE_MMX ) || defined( RUN_TIME_MMX ) - -#if defined( RUN_TIME_MMX ) - - cmpl $DO_USE_MMX, inflate_fast_use_mmx - jne .L_update_next_in - -#endif /* RUN_TIME_MMX */ - - movl %ebp, %ebx - -.L_update_next_in: - -#endif - -#define strm_r %eax -#define state_r %edx - - /* len = bits >> 3; - * in -= len; - * bits -= len << 3; - * hold &= (1U << bits) - 1; - * state->hold = hold; - * state->bits = bits; - * strm->next_in = in; - * strm->next_out = out; - */ - movl strm_sp(%esp), strm_r - movl %ebx, %ecx - movl state_strm(strm_r), state_r - shrl $3, %ecx - subl %ecx, in_r - shll $3, %ecx - subl %ecx, %ebx - movl out_r, next_out_strm(strm_r) - movl %ebx, bits_state(state_r) - movl %ebx, %ecx - - leal buf(%esp), %ebx - cmpl %ebx, last(%esp) - jne .L_buf_not_used /* if buf != last */ - - subl %ebx, in_r /* in -= buf */ - movl next_in_strm(strm_r), %ebx - movl %ebx, last(%esp) /* last = strm->next_in */ - addl %ebx, in_r /* in += strm->next_in */ - movl avail_in_strm(strm_r), %ebx - subl $11, %ebx - addl %ebx, last(%esp) /* last = &strm->next_in[ avail_in - 11 ] */ - -.L_buf_not_used: - movl in_r, next_in_strm(strm_r) - - movl $1, %ebx - shll %cl, %ebx - decl %ebx - -#if defined( USE_MMX ) || defined( RUN_TIME_MMX ) - -#if defined( RUN_TIME_MMX ) - - cmpl $DO_USE_MMX, inflate_fast_use_mmx - jne .L_update_hold - -#endif /* RUN_TIME_MMX */ - - psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ - movd hold_mm, %ebp - - emms - -.L_update_hold: - -#endif /* USE_MMX || RUN_TIME_MMX */ - - andl %ebx, %ebp - movl %ebp, hold_state(state_r) - -#define last_r %ebx - - /* strm->avail_in = in < last ? 11 + (last - in) : 11 - (in - last) */ - movl last(%esp), last_r - cmpl in_r, last_r - jbe .L_last_is_smaller /* if (in >= last) */ - - subl in_r, last_r /* last -= in */ - addl $11, last_r /* last += 11 */ - movl last_r, avail_in_strm(strm_r) - jmp .L_fixup_out -.L_last_is_smaller: - subl last_r, in_r /* in -= last */ - negl in_r /* in = -in */ - addl $11, in_r /* in += 11 */ - movl in_r, avail_in_strm(strm_r) - -#undef last_r -#define end_r %ebx - -.L_fixup_out: - /* strm->avail_out = out < end ? 257 + (end - out) : 257 - (out - end)*/ - movl end(%esp), end_r - cmpl out_r, end_r - jbe .L_end_is_smaller /* if (out >= end) */ - - subl out_r, end_r /* end -= out */ - addl $257, end_r /* end += 257 */ - movl end_r, avail_out_strm(strm_r) - jmp .L_done -.L_end_is_smaller: - subl end_r, out_r /* out -= end */ - negl out_r /* out = -out */ - addl $257, out_r /* out += 257 */ - movl out_r, avail_out_strm(strm_r) - -#undef end_r -#undef strm_r -#undef state_r - -.L_done: - addl $local_var_size, %esp - popf - popl %ebx - popl %ebp - popl %esi - popl %edi - ret - -#if defined( GAS_ELF ) -/* elf info */ -.type inflate_fast,@function -.size inflate_fast,.-inflate_fast -#endif diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/bld_ml64.bat b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/bld_ml64.bat deleted file mode 100644 index 8f9343d0a..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/bld_ml64.bat +++ /dev/null @@ -1,2 +0,0 @@ -ml64.exe /Flinffasx64 /c /Zi inffasx64.asm -ml64.exe /Flgvmat64 /c /Zi gvmat64.asm diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/gvmat64.asm b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/gvmat64.asm deleted file mode 100644 index 790d65554..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/gvmat64.asm +++ /dev/null @@ -1,513 +0,0 @@ -;uInt longest_match_x64( -; deflate_state *s, -; IPos cur_match); /* current match */ - -; gvmat64.asm -- Asm portion of the optimized longest_match for 32 bits x86 -; Copyright (C) 1995-2005 Jean-loup Gailly, Brian Raiter and Gilles Vollant. -; -; File written by Gilles Vollant, by converting to assembly the longest_match -; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. -; -; and by taking inspiration on asm686 with masm, optimised assembly code -; from Brian Raiter, written 1998 -; -; http://www.zlib.net -; http://www.winimage.com/zLibDll -; http://www.muppetlabs.com/~breadbox/software/assembly.html -; -; to compile this file for infozip Zip, I use option: -; ml64.exe /Flgvmat64 /c /Zi /DINFOZIP gvmat64.asm -; -; to compile this file for zLib, I use option: -; ml64.exe /Flgvmat64 /c /Zi gvmat64.asm -; Be carrefull to adapt zlib1222add below to your version of zLib -; (if you use a version of zLib before 1.0.4 or after 1.2.2.2, change -; value of zlib1222add later) -; -; This file compile with Microsoft Macro Assembler (x64) for AMD64 -; -; ml64.exe is given with Visual Studio 2005 and Windows 2003 server DDK -; -; (you can get Windows 2003 server DDK with ml64 and cl for AMD64 from -; http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) -; - - -;uInt longest_match(s, cur_match) -; deflate_state *s; -; IPos cur_match; /* current match */ -.code -longest_match PROC - - -;LocalVarsSize equ 88 - LocalVarsSize equ 72 - -; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 -; free register : r14,r15 -; register can be saved : rsp - - chainlenwmask equ rsp + 8 - LocalVarsSize ; high word: current chain len - ; low word: s->wmask -;window equ rsp + xx - LocalVarsSize ; local copy of s->window ; stored in r10 -;windowbestlen equ rsp + xx - LocalVarsSize ; s->window + bestlen , use r10+r11 -;scanstart equ rsp + xx - LocalVarsSize ; first two bytes of string ; stored in r12w -;scanend equ rsp + xx - LocalVarsSize ; last two bytes of string use ebx -;scanalign equ rsp + xx - LocalVarsSize ; dword-misalignment of string r13 -;bestlen equ rsp + xx - LocalVarsSize ; size of best match so far -> r11d -;scan equ rsp + xx - LocalVarsSize ; ptr to string wanting match -> r9 -IFDEF INFOZIP -ELSE - nicematch equ (rsp + 16 - LocalVarsSize) ; a good enough match size -ENDIF - -save_rdi equ rsp + 24 - LocalVarsSize -save_rsi equ rsp + 32 - LocalVarsSize -save_rbx equ rsp + 40 - LocalVarsSize -save_rbp equ rsp + 48 - LocalVarsSize -save_r12 equ rsp + 56 - LocalVarsSize -save_r13 equ rsp + 64 - LocalVarsSize -;save_r14 equ rsp + 72 - LocalVarsSize -;save_r15 equ rsp + 80 - LocalVarsSize - - - -; all the +4 offsets are due to the addition of pending_buf_size (in zlib -; in the deflate_state structure since the asm code was first written -; (if you compile with zlib 1.0.4 or older, remove the +4). -; Note : these value are good with a 8 bytes boundary pack structure - - - MAX_MATCH equ 258 - MIN_MATCH equ 3 - MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) - - -;;; Offsets for fields in the deflate_state structure. These numbers -;;; are calculated from the definition of deflate_state, with the -;;; assumption that the compiler will dword-align the fields. (Thus, -;;; changing the definition of deflate_state could easily cause this -;;; program to crash horribly, without so much as a warning at -;;; compile time. Sigh.) - -; all the +zlib1222add offsets are due to the addition of fields -; in zlib in the deflate_state structure since the asm code was first written -; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). -; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). -; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). - - -IFDEF INFOZIP - -_DATA SEGMENT -COMM window_size:DWORD -; WMask ; 7fff -COMM window:BYTE:010040H -COMM prev:WORD:08000H -; MatchLen : unused -; PrevMatch : unused -COMM strstart:DWORD -COMM match_start:DWORD -; Lookahead : ignore -COMM prev_length:DWORD ; PrevLen -COMM max_chain_length:DWORD -COMM good_match:DWORD -COMM nice_match:DWORD -prev_ad equ OFFSET prev -window_ad equ OFFSET window -nicematch equ nice_match -_DATA ENDS -WMask equ 07fffh - -ELSE - - IFNDEF zlib1222add - zlib1222add equ 8 - ENDIF -dsWSize equ 56+zlib1222add+(zlib1222add/2) -dsWMask equ 64+zlib1222add+(zlib1222add/2) -dsWindow equ 72+zlib1222add -dsPrev equ 88+zlib1222add -dsMatchLen equ 128+zlib1222add -dsPrevMatch equ 132+zlib1222add -dsStrStart equ 140+zlib1222add -dsMatchStart equ 144+zlib1222add -dsLookahead equ 148+zlib1222add -dsPrevLen equ 152+zlib1222add -dsMaxChainLen equ 156+zlib1222add -dsGoodMatch equ 172+zlib1222add -dsNiceMatch equ 176+zlib1222add - -window_size equ [ rcx + dsWSize] -WMask equ [ rcx + dsWMask] -window_ad equ [ rcx + dsWindow] -prev_ad equ [ rcx + dsPrev] -strstart equ [ rcx + dsStrStart] -match_start equ [ rcx + dsMatchStart] -Lookahead equ [ rcx + dsLookahead] ; 0ffffffffh on infozip -prev_length equ [ rcx + dsPrevLen] -max_chain_length equ [ rcx + dsMaxChainLen] -good_match equ [ rcx + dsGoodMatch] -nice_match equ [ rcx + dsNiceMatch] -ENDIF - -; parameter 1 in r8(deflate state s), param 2 in rdx (cur match) - -; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and -; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp -; -; All registers must be preserved across the call, except for -; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. - - - -;;; Save registers that the compiler may be using, and adjust esp to -;;; make room for our stack frame. - - -;;; Retrieve the function arguments. r8d will hold cur_match -;;; throughout the entire function. edx will hold the pointer to the -;;; deflate_state structure during the function's setup (before -;;; entering the main loop. - -; parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) - -; this clear high 32 bits of r8, which can be garbage in both r8 and rdx - - mov [save_rdi],rdi - mov [save_rsi],rsi - mov [save_rbx],rbx - mov [save_rbp],rbp -IFDEF INFOZIP - mov r8d,ecx -ELSE - mov r8d,edx -ENDIF - mov [save_r12],r12 - mov [save_r13],r13 -; mov [save_r14],r14 -; mov [save_r15],r15 - - -;;; uInt wmask = s->w_mask; -;;; unsigned chain_length = s->max_chain_length; -;;; if (s->prev_length >= s->good_match) { -;;; chain_length >>= 2; -;;; } - - mov edi, prev_length - mov esi, good_match - mov eax, WMask - mov ebx, max_chain_length - cmp edi, esi - jl LastMatchGood - shr ebx, 2 -LastMatchGood: - -;;; chainlen is decremented once beforehand so that the function can -;;; use the sign flag instead of the zero flag for the exit test. -;;; It is then shifted into the high word, to make room for the wmask -;;; value, which it will always accompany. - - dec ebx - shl ebx, 16 - or ebx, eax - -;;; on zlib only -;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - -IFDEF INFOZIP - mov [chainlenwmask], ebx -; on infozip nice_match = [nice_match] -ELSE - mov eax, nice_match - mov [chainlenwmask], ebx - mov r10d, Lookahead - cmp r10d, eax - cmovnl r10d, eax - mov [nicematch],r10d -ENDIF - -;;; register Bytef *scan = s->window + s->strstart; - mov r10, window_ad - mov ebp, strstart - lea r13, [r10 + rbp] - -;;; Determine how many bytes the scan ptr is off from being -;;; dword-aligned. - - mov r9,r13 - neg r13 - and r13,3 - -;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? -;;; s->strstart - (IPos)MAX_DIST(s) : NIL; -IFDEF INFOZIP - mov eax,07efah ; MAX_DIST = (WSIZE-MIN_LOOKAHEAD) (0x8000-(3+8+1)) -ELSE - mov eax, window_size - sub eax, MIN_LOOKAHEAD -ENDIF - xor edi,edi - sub ebp, eax - - mov r11d, prev_length - - cmovng ebp,edi - -;;; int best_len = s->prev_length; - - -;;; Store the sum of s->window + best_len in esi locally, and in esi. - - lea rsi,[r10+r11] - -;;; register ush scan_start = *(ushf*)scan; -;;; register ush scan_end = *(ushf*)(scan+best_len-1); -;;; Posf *prev = s->prev; - - movzx r12d,word ptr [r9] - movzx ebx, word ptr [r9 + r11 - 1] - - mov rdi, prev_ad - -;;; Jump into the main loop. - - mov edx, [chainlenwmask] - - cmp bx,word ptr [rsi + r8 - 1] - jz LookupLoopIsZero - -LookupLoop1: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - jbe LeaveNow - sub edx, 00010000h - js LeaveNow - -LoopEntry1: - cmp bx,word ptr [rsi + r8 - 1] - jz LookupLoopIsZero - -LookupLoop2: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - jbe LeaveNow - sub edx, 00010000h - js LeaveNow - -LoopEntry2: - cmp bx,word ptr [rsi + r8 - 1] - jz LookupLoopIsZero - -LookupLoop4: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - jbe LeaveNow - sub edx, 00010000h - js LeaveNow - -LoopEntry4: - - cmp bx,word ptr [rsi + r8 - 1] - jnz LookupLoop1 - jmp LookupLoopIsZero - - -;;; do { -;;; match = s->window + cur_match; -;;; if (*(ushf*)(match+best_len-1) != scan_end || -;;; *(ushf*)match != scan_start) continue; -;;; [...] -;;; } while ((cur_match = prev[cur_match & wmask]) > limit -;;; && --chain_length != 0); -;;; -;;; Here is the inner loop of the function. The function will spend the -;;; majority of its time in this loop, and majority of that time will -;;; be spent in the first ten instructions. -;;; -;;; Within this loop: -;;; ebx = scanend -;;; r8d = curmatch -;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) -;;; esi = windowbestlen - i.e., (window + bestlen) -;;; edi = prev -;;; ebp = limit - -LookupLoop: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - jbe LeaveNow - sub edx, 00010000h - js LeaveNow - -LoopEntry: - - cmp bx,word ptr [rsi + r8 - 1] - jnz LookupLoop1 -LookupLoopIsZero: - cmp r12w, word ptr [r10 + r8] - jnz LookupLoop1 - - -;;; Store the current value of chainlen. - mov [chainlenwmask], edx - -;;; Point edi to the string under scrutiny, and esi to the string we -;;; are hoping to match it up with. In actuality, esi and edi are -;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is -;;; initialized to -(MAX_MATCH_8 - scanalign). - - lea rsi,[r8+r10] - mov rdx, 0fffffffffffffef8h; -(MAX_MATCH_8) - lea rsi, [rsi + r13 + 0108h] ;MAX_MATCH_8] - lea rdi, [r9 + r13 + 0108h] ;MAX_MATCH_8] - - prefetcht1 [rsi+rdx] - prefetcht1 [rdi+rdx] - - -;;; Test the strings for equality, 8 bytes at a time. At the end, -;;; adjust rdx so that it is offset to the exact byte that mismatched. -;;; -;;; We already know at this point that the first three bytes of the -;;; strings match each other, and they can be safely passed over before -;;; starting the compare loop. So what this code does is skip over 0-3 -;;; bytes, as much as necessary in order to dword-align the edi -;;; pointer. (rsi will still be misaligned three times out of four.) -;;; -;;; It should be confessed that this loop usually does not represent -;;; much of the total running time. Replacing it with a more -;;; straightforward "rep cmpsb" would not drastically degrade -;;; performance. - - -LoopCmps: - mov rax, [rsi + rdx] - xor rax, [rdi + rdx] - jnz LeaveLoopCmps - - mov rax, [rsi + rdx + 8] - xor rax, [rdi + rdx + 8] - jnz LeaveLoopCmps8 - - - mov rax, [rsi + rdx + 8+8] - xor rax, [rdi + rdx + 8+8] - jnz LeaveLoopCmps16 - - add rdx,8+8+8 - - jmp short LoopCmps -LeaveLoopCmps16: add rdx,8 -LeaveLoopCmps8: add rdx,8 -LeaveLoopCmps: - - test eax, 0000FFFFh - jnz LenLower - - test eax,0ffffffffh - - jnz LenLower32 - - add rdx,4 - shr rax,32 - or ax,ax - jnz LenLower - -LenLower32: - shr eax,16 - add rdx,2 -LenLower: sub al, 1 - adc rdx, 0 -;;; Calculate the length of the match. If it is longer than MAX_MATCH, -;;; then automatically accept it as the best possible match and leave. - - lea rax, [rdi + rdx] - sub rax, r9 - cmp eax, MAX_MATCH - jge LenMaximum - -;;; If the length of the match is not longer than the best match we -;;; have so far, then forget it and return to the lookup loop. -;/////////////////////////////////// - - cmp eax, r11d - jg LongerMatch - - lea rsi,[r10+r11] - - mov rdi, prev_ad - mov edx, [chainlenwmask] - jmp LookupLoop - -;;; s->match_start = cur_match; -;;; best_len = len; -;;; if (len >= nice_match) break; -;;; scan_end = *(ushf*)(scan+best_len-1); - -LongerMatch: - mov r11d, eax - mov match_start, r8d - cmp eax, [nicematch] - jge LeaveNow - - lea rsi,[r10+rax] - - movzx ebx, word ptr [r9 + rax - 1] - mov rdi, prev_ad - mov edx, [chainlenwmask] - jmp LookupLoop - -;;; Accept the current string, with the maximum possible length. - -LenMaximum: - mov r11d,MAX_MATCH - mov match_start, r8d - -;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; -;;; return s->lookahead; - -LeaveNow: -IFDEF INFOZIP - mov eax,r11d -ELSE - mov eax, Lookahead - cmp r11d, eax - cmovng eax, r11d -ENDIF - -;;; Restore the stack and return from whence we came. - - - mov rsi,[save_rsi] - mov rdi,[save_rdi] - mov rbx,[save_rbx] - mov rbp,[save_rbp] - mov r12,[save_r12] - mov r13,[save_r13] -; mov r14,[save_r14] -; mov r15,[save_r15] - - - ret 0 -; please don't remove this string ! -; Your can freely use gvmat64 in any free or commercial app -; but it is far better don't remove the string in the binary! - db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 -longest_match ENDP - -match_init PROC - ret 0 -match_init ENDP - - -END diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/gvmat64.obj b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/gvmat64.obj deleted file mode 100644 index a49ca029c..000000000 Binary files a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/gvmat64.obj and /dev/null differ diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffas8664.c b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffas8664.c deleted file mode 100644 index 3af764de9..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffas8664.c +++ /dev/null @@ -1,186 +0,0 @@ -/* inffas8664.c is a hand tuned assembler version of inffast.c - fast decoding - * version for AMD64 on Windows using Microsoft C compiler - * - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Copyright (C) 2003 Chris Anderson - * Please use the copyright conditions above. - * - * 2005 - Adaptation to Microsoft C Compiler for AMD64 by Gilles Vollant - * - * inffas8664.c call function inffas8664fnc in inffasx64.asm - * inffasx64.asm is automatically convert from AMD64 portion of inffas86.c - * - * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also - * slightly quicker on x86 systems because, instead of using rep movsb to copy - * data, it uses rep movsw, which moves data in 2-byte chunks instead of single - * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates - * from http://fedora.linux.duke.edu/fc1_x86_64 - * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with - * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version, - * when decompressing mozilla-source-1.3.tar.gz. - * - * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from - * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at - * the moment. I have successfully compiled and tested this code with gcc2.96, - * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S - * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX - * enabled. I will attempt to merge the MMX code into this version. Newer - * versions of this and inffast.S can be found at - * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ - * - */ - -#include -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* Mark Adler's comments from inffast.c: */ - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ - - - - typedef struct inffast_ar { -/* 64 32 x86 x86_64 */ -/* ar offset register */ -/* 0 0 */ void *esp; /* esp save */ -/* 8 4 */ void *ebp; /* ebp save */ -/* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */ -/* 24 12 */ unsigned char FAR *last; /* r9 while in < last */ -/* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */ -/* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */ -/* 48 24 */ unsigned char FAR *end; /* r10 while out < end */ -/* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */ -/* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */ -/* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */ -/* 80 40 */ size_t /*unsigned long */hold; /* edx rdx local strm->hold */ -/* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */ -/* 92 48 */ unsigned wsize; /* window size */ -/* 96 52 */ unsigned write; /* window write index */ -/*100 56 */ unsigned lmask; /* r12 mask for lcode */ -/*104 60 */ unsigned dmask; /* r13 mask for dcode */ -/*108 64 */ unsigned len; /* r14 match length */ -/*112 68 */ unsigned dist; /* r15 match distance */ -/*116 72 */ unsigned status; /* set when state chng*/ - } type_ar; -#ifdef ASMINF - -void inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - type_ar ar; - void inffas8664fnc(struct inffast_ar * par); - - - -#if (defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )) || (defined(_MSC_VER) && defined(_M_AMD64)) -#define PAD_AVAIL_IN 6 -#define PAD_AVAIL_OUT 258 -#else -#define PAD_AVAIL_IN 5 -#define PAD_AVAIL_OUT 257 -#endif - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - - ar.in = strm->next_in; - ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN); - ar.out = strm->next_out; - ar.beg = ar.out - (start - strm->avail_out); - ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT); - ar.wsize = state->wsize; - ar.write = state->write; - ar.window = state->window; - ar.hold = state->hold; - ar.bits = state->bits; - ar.lcode = state->lencode; - ar.dcode = state->distcode; - ar.lmask = (1U << state->lenbits) - 1; - ar.dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - - /* align in on 1/2 hold size boundary */ - while (((size_t)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) { - ar.hold += (unsigned long)*ar.in++ << ar.bits; - ar.bits += 8; - } - - inffas8664fnc(&ar); - - if (ar.status > 1) { - if (ar.status == 2) - strm->msg = "invalid literal/length code"; - else if (ar.status == 3) - strm->msg = "invalid distance code"; - else - strm->msg = "invalid distance too far back"; - state->mode = BAD; - } - else if ( ar.status == 1 ) { - state->mode = TYPE; - } - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - ar.len = ar.bits >> 3; - ar.in -= ar.len; - ar.bits -= ar.len << 3; - ar.hold &= (1U << ar.bits) - 1; - - /* update state and return */ - strm->next_in = ar.in; - strm->next_out = ar.out; - strm->avail_in = (unsigned)(ar.in < ar.last ? - PAD_AVAIL_IN + (ar.last - ar.in) : - PAD_AVAIL_IN - (ar.in - ar.last)); - strm->avail_out = (unsigned)(ar.out < ar.end ? - PAD_AVAIL_OUT + (ar.end - ar.out) : - PAD_AVAIL_OUT - (ar.out - ar.end)); - state->hold = (unsigned long)ar.hold; - state->bits = ar.bits; - return; -} - -#endif diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffasx64.asm b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffasx64.asm deleted file mode 100644 index b5d93a272..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffasx64.asm +++ /dev/null @@ -1,392 +0,0 @@ -; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding -; version for AMD64 on Windows using Microsoft C compiler -; -; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c -; inffasx64.asm is called by inffas8664.c, which contain more info. - - -; to compile this file, I use option -; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm -; with Microsoft Macro Assembler (x64) for AMD64 -; -; ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK -; -; (you can get Windows 2003 server DDK with ml64 and cl.exe for AMD64 from -; http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) -; - -.code -inffas8664fnc PROC - -; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and -; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp -; -; All registers must be preserved across the call, except for -; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch. - - - mov [rsp-8],rsi - mov [rsp-16],rdi - mov [rsp-24],r12 - mov [rsp-32],r13 - mov [rsp-40],r14 - mov [rsp-48],r15 - mov [rsp-56],rbx - - mov rax,rcx - - mov [rax+8], rbp ; /* save regs rbp and rsp */ - mov [rax], rsp - - mov rsp, rax ; /* make rsp point to &ar */ - - mov rsi, [rsp+16] ; /* rsi = in */ - mov rdi, [rsp+32] ; /* rdi = out */ - mov r9, [rsp+24] ; /* r9 = last */ - mov r10, [rsp+48] ; /* r10 = end */ - mov rbp, [rsp+64] ; /* rbp = lcode */ - mov r11, [rsp+72] ; /* r11 = dcode */ - mov rdx, [rsp+80] ; /* rdx = hold */ - mov ebx, [rsp+88] ; /* ebx = bits */ - mov r12d, [rsp+100] ; /* r12d = lmask */ - mov r13d, [rsp+104] ; /* r13d = dmask */ - ; /* r14d = len */ - ; /* r15d = dist */ - - - cld - cmp r10, rdi - je L_one_time ; /* if only one decode left */ - cmp r9, rsi - - jne L_do_loop - - -L_one_time: - mov r8, r12 ; /* r8 = lmask */ - cmp bl, 32 - ja L_get_length_code_one_time - - lodsd ; /* eax = *(uint *)in++ */ - mov cl, bl ; /* cl = bits, needs it for shifting */ - add bl, 32 ; /* bits += 32 */ - shl rax, cl - or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ - jmp L_get_length_code_one_time - -ALIGN 4 -L_while_test: - cmp r10, rdi - jbe L_break_loop - cmp r9, rsi - jbe L_break_loop - -L_do_loop: - mov r8, r12 ; /* r8 = lmask */ - cmp bl, 32 - ja L_get_length_code ; /* if (32 < bits) */ - - lodsd ; /* eax = *(uint *)in++ */ - mov cl, bl ; /* cl = bits, needs it for shifting */ - add bl, 32 ; /* bits += 32 */ - shl rax, cl - or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ - -L_get_length_code: - and r8, rdx ; /* r8 &= hold */ - mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ - - mov cl, ah ; /* cl = this.bits */ - sub bl, ah ; /* bits -= this.bits */ - shr rdx, cl ; /* hold >>= this.bits */ - - test al, al - jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ - - mov r8, r12 ; /* r8 = lmask */ - shr eax, 16 ; /* output this.val char */ - stosb - -L_get_length_code_one_time: - and r8, rdx ; /* r8 &= hold */ - mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ - -L_dolen: - mov cl, ah ; /* cl = this.bits */ - sub bl, ah ; /* bits -= this.bits */ - shr rdx, cl ; /* hold >>= this.bits */ - - test al, al - jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ - - shr eax, 16 ; /* output this.val char */ - stosb - jmp L_while_test - -ALIGN 4 -L_test_for_length_base: - mov r14d, eax ; /* len = this */ - shr r14d, 16 ; /* len = this.val */ - mov cl, al - - test al, 16 - jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */ - and cl, 15 ; /* op &= 15 */ - jz L_decode_distance ; /* if (!op) */ - -L_add_bits_to_len: - sub bl, cl - xor eax, eax - inc eax - shl eax, cl - dec eax - and eax, edx ; /* eax &= hold */ - shr rdx, cl - add r14d, eax ; /* len += hold & mask[op] */ - -L_decode_distance: - mov r8, r13 ; /* r8 = dmask */ - cmp bl, 32 - ja L_get_distance_code ; /* if (32 < bits) */ - - lodsd ; /* eax = *(uint *)in++ */ - mov cl, bl ; /* cl = bits, needs it for shifting */ - add bl, 32 ; /* bits += 32 */ - shl rax, cl - or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ - -L_get_distance_code: - and r8, rdx ; /* r8 &= hold */ - mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */ - -L_dodist: - mov r15d, eax ; /* dist = this */ - shr r15d, 16 ; /* dist = this.val */ - mov cl, ah - sub bl, ah ; /* bits -= this.bits */ - shr rdx, cl ; /* hold >>= this.bits */ - mov cl, al ; /* cl = this.op */ - - test al, 16 ; /* if ((op & 16) == 0) */ - jz L_test_for_second_level_dist - and cl, 15 ; /* op &= 15 */ - jz L_check_dist_one - -L_add_bits_to_dist: - sub bl, cl - xor eax, eax - inc eax - shl eax, cl - dec eax ; /* (1 << op) - 1 */ - and eax, edx ; /* eax &= hold */ - shr rdx, cl - add r15d, eax ; /* dist += hold & ((1 << op) - 1) */ - -L_check_window: - mov r8, rsi ; /* save in so from can use it's reg */ - mov rax, rdi - sub rax, [rsp+40] ; /* nbytes = out - beg */ - - cmp eax, r15d - jb L_clip_window ; /* if (dist > nbytes) 4.2% */ - - mov ecx, r14d ; /* ecx = len */ - mov rsi, rdi - sub rsi, r15 ; /* from = out - dist */ - - sar ecx, 1 - jnc L_copy_two ; /* if len % 2 == 0 */ - - rep movsw - mov al, [rsi] - mov [rdi], al - inc rdi - - mov rsi, r8 ; /* move in back to %rsi, toss from */ - jmp L_while_test - -L_copy_two: - rep movsw - mov rsi, r8 ; /* move in back to %rsi, toss from */ - jmp L_while_test - -ALIGN 4 -L_check_dist_one: - cmp r15d, 1 ; /* if dist 1, is a memset */ - jne L_check_window - cmp [rsp+40], rdi ; /* if out == beg, outside window */ - je L_check_window - - mov ecx, r14d ; /* ecx = len */ - mov al, [rdi-1] - mov ah, al - - sar ecx, 1 - jnc L_set_two - mov [rdi], al - inc rdi - -L_set_two: - rep stosw - jmp L_while_test - -ALIGN 4 -L_test_for_second_level_length: - test al, 64 - jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */ - - xor eax, eax - inc eax - shl eax, cl - dec eax - and eax, edx ; /* eax &= hold */ - add eax, r14d ; /* eax += len */ - mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/ - jmp L_dolen - -ALIGN 4 -L_test_for_second_level_dist: - test al, 64 - jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */ - - xor eax, eax - inc eax - shl eax, cl - dec eax - and eax, edx ; /* eax &= hold */ - add eax, r15d ; /* eax += dist */ - mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/ - jmp L_dodist - -ALIGN 4 -L_clip_window: - mov ecx, eax ; /* ecx = nbytes */ - mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */ - neg ecx ; /* nbytes = -nbytes */ - - cmp eax, r15d - jb L_invalid_distance_too_far ; /* if (dist > wsize) */ - - add ecx, r15d ; /* nbytes = dist - nbytes */ - cmp dword ptr [rsp+96], 0 - jne L_wrap_around_window ; /* if (write != 0) */ - - mov rsi, [rsp+56] ; /* from = window */ - sub eax, ecx ; /* eax -= nbytes */ - add rsi, rax ; /* from += wsize - nbytes */ - - mov eax, r14d ; /* eax = len */ - cmp r14d, ecx - jbe L_do_copy ; /* if (nbytes >= len) */ - - sub eax, ecx ; /* eax -= nbytes */ - rep movsb - mov rsi, rdi - sub rsi, r15 ; /* from = &out[ -dist ] */ - jmp L_do_copy - -ALIGN 4 -L_wrap_around_window: - mov eax, [rsp+96] ; /* eax = write */ - cmp ecx, eax - jbe L_contiguous_in_window ; /* if (write >= nbytes) */ - - mov esi, [rsp+92] ; /* from = wsize */ - add rsi, [rsp+56] ; /* from += window */ - add rsi, rax ; /* from += write */ - sub rsi, rcx ; /* from -= nbytes */ - sub ecx, eax ; /* nbytes -= write */ - - mov eax, r14d ; /* eax = len */ - cmp eax, ecx - jbe L_do_copy ; /* if (nbytes >= len) */ - - sub eax, ecx ; /* len -= nbytes */ - rep movsb - mov rsi, [rsp+56] ; /* from = window */ - mov ecx, [rsp+96] ; /* nbytes = write */ - cmp eax, ecx - jbe L_do_copy ; /* if (nbytes >= len) */ - - sub eax, ecx ; /* len -= nbytes */ - rep movsb - mov rsi, rdi - sub rsi, r15 ; /* from = out - dist */ - jmp L_do_copy - -ALIGN 4 -L_contiguous_in_window: - mov rsi, [rsp+56] ; /* rsi = window */ - add rsi, rax - sub rsi, rcx ; /* from += write - nbytes */ - - mov eax, r14d ; /* eax = len */ - cmp eax, ecx - jbe L_do_copy ; /* if (nbytes >= len) */ - - sub eax, ecx ; /* len -= nbytes */ - rep movsb - mov rsi, rdi - sub rsi, r15 ; /* from = out - dist */ - jmp L_do_copy ; /* if (nbytes >= len) */ - -ALIGN 4 -L_do_copy: - mov ecx, eax ; /* ecx = len */ - rep movsb - - mov rsi, r8 ; /* move in back to %esi, toss from */ - jmp L_while_test - -L_test_for_end_of_block: - test al, 32 - jz L_invalid_literal_length_code - mov dword ptr [rsp+116], 1 - jmp L_break_loop_with_status - -L_invalid_literal_length_code: - mov dword ptr [rsp+116], 2 - jmp L_break_loop_with_status - -L_invalid_distance_code: - mov dword ptr [rsp+116], 3 - jmp L_break_loop_with_status - -L_invalid_distance_too_far: - mov dword ptr [rsp+116], 4 - jmp L_break_loop_with_status - -L_break_loop: - mov dword ptr [rsp+116], 0 - -L_break_loop_with_status: -; /* put in, out, bits, and hold back into ar and pop esp */ - mov [rsp+16], rsi ; /* in */ - mov [rsp+32], rdi ; /* out */ - mov [rsp+88], ebx ; /* bits */ - mov [rsp+80], rdx ; /* hold */ - - mov rax, [rsp] ; /* restore rbp and rsp */ - mov rbp, [rsp+8] - mov rsp, rax - - - - mov rsi,[rsp-8] - mov rdi,[rsp-16] - mov r12,[rsp-24] - mov r13,[rsp-32] - mov r14,[rsp-40] - mov r15,[rsp-48] - mov rbx,[rsp-56] - - ret 0 -; : -; : "m" (ar) -; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", -; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" -; ); - -inffas8664fnc ENDP -;_TEXT ENDS -END diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffasx64.obj b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffasx64.obj deleted file mode 100644 index 8df5d8261..000000000 Binary files a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/inffasx64.obj and /dev/null differ diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/readme.txt b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/readme.txt deleted file mode 100644 index ee03115c5..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx64/readme.txt +++ /dev/null @@ -1,28 +0,0 @@ -Summary -------- -This directory contains ASM implementations of the functions -longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t), -for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits. - -gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits - assembly optimized version from Jean-loup Gailly original longest_match function - -inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing - original function from Mark Adler - -Use instructions ----------------- -Copy these files into the zlib source directory. - -define ASMV and ASMINF in your project. Include inffas8664.c in your source tree, -and inffasx64.obj and gvmat64.obj as object to link. - - -Build instructions ------------------- -run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe) - -ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK - -You can get Windows 2003 server DDK with ml64 and cl for AMD64 from - http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/bld_ml32.bat b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/bld_ml32.bat deleted file mode 100644 index 99144d07a..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/bld_ml32.bat +++ /dev/null @@ -1,2 +0,0 @@ -ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm -ml /coff /Zi /c /Flinffas32.lst inffas32.asm diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32.asm b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32.asm deleted file mode 100644 index 874bb2d48..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32.asm +++ /dev/null @@ -1,972 +0,0 @@ -; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 -; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. -; File written by Gilles Vollant, by modifiying the longest_match -; from Jean-loup Gailly in deflate.c -; -; http://www.zlib.net -; http://www.winimage.com/zLibDll -; http://www.muppetlabs.com/~breadbox/software/assembly.html -; -; For Visual C++ 4.x and higher and ML 6.x and higher -; ml.exe is in directory \MASM611C of Win95 DDK -; ml.exe is also distributed in http://www.masm32.com/masmdl.htm -; and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/ -; -; this file contain two implementation of longest_match -; -; longest_match_7fff : written 1996 by Gilles Vollant optimized for -; first Pentium. Assume s->w_mask == 0x7fff -; longest_match_686 : written by Brian raiter (1998), optimized for Pentium Pro -; -; for using an seembly version of longest_match, you need define ASMV in project -; There is two way in using gvmat32.asm -; -; A) Suggested method -; if you want include both longest_match_7fff and longest_match_686 -; compile the asm file running -; ml /coff /Zi /Flgvmat32.lst /c gvmat32.asm -; and include gvmat32c.c in your project -; if you have an old cpu (386,486 or first Pentium) and s->w_mask==0x7fff, -; longest_match_7fff will be used -; if you have a more modern CPU (Pentium Pro, II and higher) -; longest_match_686 will be used -; on old cpu with s->w_mask!=0x7fff, longest_match_686 will be used, -; but this is not a sitation you'll find often -; -; B) Alternative -; if you are not interresed in old cpu performance and want the smaller -; binaries possible -; -; compile the asm file running -; ml /coff /Zi /c /Flgvmat32.lst /DNOOLDPENTIUMCODE gvmat32.asm -; and do not include gvmat32c.c in your project (ou define also -; NOOLDPENTIUMCODE) -; -; note : as I known, longest_match_686 is very faster than longest_match_7fff -; on pentium Pro/II/III, faster (but less) in P4, but it seem -; longest_match_7fff can be faster (very very litte) on AMD Athlon64/K8 -; -; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2 - -;uInt longest_match_7fff(s, cur_match) -; deflate_state *s; -; IPos cur_match; /* current match */ - - NbStack equ 76 - cur_match equ dword ptr[esp+NbStack-0] - str_s equ dword ptr[esp+NbStack-4] -; 5 dword on top (ret,ebp,esi,edi,ebx) - adrret equ dword ptr[esp+NbStack-8] - pushebp equ dword ptr[esp+NbStack-12] - pushedi equ dword ptr[esp+NbStack-16] - pushesi equ dword ptr[esp+NbStack-20] - pushebx equ dword ptr[esp+NbStack-24] - - chain_length equ dword ptr [esp+NbStack-28] - limit equ dword ptr [esp+NbStack-32] - best_len equ dword ptr [esp+NbStack-36] - window equ dword ptr [esp+NbStack-40] - prev equ dword ptr [esp+NbStack-44] - scan_start equ word ptr [esp+NbStack-48] - wmask equ dword ptr [esp+NbStack-52] - match_start_ptr equ dword ptr [esp+NbStack-56] - nice_match equ dword ptr [esp+NbStack-60] - scan equ dword ptr [esp+NbStack-64] - - windowlen equ dword ptr [esp+NbStack-68] - match_start equ dword ptr [esp+NbStack-72] - strend equ dword ptr [esp+NbStack-76] - NbStackAdd equ (NbStack-24) - - .386p - - name gvmatch - .MODEL FLAT - - - -; all the +zlib1222add offsets are due to the addition of fields -; in zlib in the deflate_state structure since the asm code was first written -; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). -; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). -; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). - - zlib1222add equ 8 - -; Note : these value are good with a 8 bytes boundary pack structure - dep_chain_length equ 74h+zlib1222add - dep_window equ 30h+zlib1222add - dep_strstart equ 64h+zlib1222add - dep_prev_length equ 70h+zlib1222add - dep_nice_match equ 88h+zlib1222add - dep_w_size equ 24h+zlib1222add - dep_prev equ 38h+zlib1222add - dep_w_mask equ 2ch+zlib1222add - dep_good_match equ 84h+zlib1222add - dep_match_start equ 68h+zlib1222add - dep_lookahead equ 6ch+zlib1222add - - -_TEXT segment - -IFDEF NOUNDERLINE - IFDEF NOOLDPENTIUMCODE - public longest_match - public match_init - ELSE - public longest_match_7fff - public cpudetect32 - public longest_match_686 - ENDIF -ELSE - IFDEF NOOLDPENTIUMCODE - public _longest_match - public _match_init - ELSE - public _longest_match_7fff - public _cpudetect32 - public _longest_match_686 - ENDIF -ENDIF - - MAX_MATCH equ 258 - MIN_MATCH equ 3 - MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) - - - -IFNDEF NOOLDPENTIUMCODE -IFDEF NOUNDERLINE -longest_match_7fff proc near -ELSE -_longest_match_7fff proc near -ENDIF - - mov edx,[esp+4] - - - - push ebp - push edi - push esi - push ebx - - sub esp,NbStackAdd - -; initialize or check the variables used in match.asm. - mov ebp,edx - -; chain_length = s->max_chain_length -; if (prev_length>=good_match) chain_length >>= 2 - mov edx,[ebp+dep_chain_length] - mov ebx,[ebp+dep_prev_length] - cmp [ebp+dep_good_match],ebx - ja noshr - shr edx,2 -noshr: -; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop - inc edx - mov edi,[ebp+dep_nice_match] - mov chain_length,edx - mov eax,[ebp+dep_lookahead] - cmp eax,edi -; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - jae nolookaheadnicematch - mov edi,eax -nolookaheadnicematch: -; best_len = s->prev_length - mov best_len,ebx - -; window = s->window - mov esi,[ebp+dep_window] - mov ecx,[ebp+dep_strstart] - mov window,esi - - mov nice_match,edi -; scan = window + strstart - add esi,ecx - mov scan,esi -; dx = *window - mov dx,word ptr [esi] -; bx = *(window+best_len-1) - mov bx,word ptr [esi+ebx-1] - add esi,MAX_MATCH-1 -; scan_start = *scan - mov scan_start,dx -; strend = scan + MAX_MATCH-1 - mov strend,esi -; bx = scan_end = *(window+best_len-1) - -; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? -; s->strstart - (IPos)MAX_DIST(s) : NIL; - - mov esi,[ebp+dep_w_size] - sub esi,MIN_LOOKAHEAD -; here esi = MAX_DIST(s) - sub ecx,esi - ja nodist - xor ecx,ecx -nodist: - mov limit,ecx - -; prev = s->prev - mov edx,[ebp+dep_prev] - mov prev,edx - -; - mov edx,dword ptr [ebp+dep_match_start] - mov bp,scan_start - mov eax,cur_match - mov match_start,edx - - mov edx,window - mov edi,edx - add edi,best_len - mov esi,prev - dec edi -; windowlen = window + best_len -1 - mov windowlen,edi - - jmp beginloop2 - align 4 - -; here, in the loop -; eax = ax = cur_match -; ecx = limit -; bx = scan_end -; bp = scan_start -; edi = windowlen (window + best_len -1) -; esi = prev - - -;// here; chain_length <=16 -normalbeg0add16: - add chain_length,16 - jz exitloop -normalbeg0: - cmp word ptr[edi+eax],bx - je normalbeg2noroll -rcontlabnoroll: -; cur_match = prev[cur_match & wmask] - and eax,7fffh - mov ax,word ptr[esi+eax*2] -; if cur_match > limit, go to exitloop - cmp ecx,eax - jnb exitloop -; if --chain_length != 0, go to exitloop - dec chain_length - jnz normalbeg0 - jmp exitloop - -normalbeg2noroll: -; if (scan_start==*(cur_match+window)) goto normalbeg2 - cmp bp,word ptr[edx+eax] - jne rcontlabnoroll - jmp normalbeg2 - -contloop3: - mov edi,windowlen - -; cur_match = prev[cur_match & wmask] - and eax,7fffh - mov ax,word ptr[esi+eax*2] -; if cur_match > limit, go to exitloop - cmp ecx,eax -jnbexitloopshort1: - jnb exitloop -; if --chain_length != 0, go to exitloop - - -; begin the main loop -beginloop2: - sub chain_length,16+1 -; if chain_length <=16, don't use the unrolled loop - jna normalbeg0add16 - -do16: - cmp word ptr[edi+eax],bx - je normalbeg2dc0 - -maccn MACRO lab - and eax,7fffh - mov ax,word ptr[esi+eax*2] - cmp ecx,eax - jnb exitloop - cmp word ptr[edi+eax],bx - je lab - ENDM - -rcontloop0: - maccn normalbeg2dc1 - -rcontloop1: - maccn normalbeg2dc2 - -rcontloop2: - maccn normalbeg2dc3 - -rcontloop3: - maccn normalbeg2dc4 - -rcontloop4: - maccn normalbeg2dc5 - -rcontloop5: - maccn normalbeg2dc6 - -rcontloop6: - maccn normalbeg2dc7 - -rcontloop7: - maccn normalbeg2dc8 - -rcontloop8: - maccn normalbeg2dc9 - -rcontloop9: - maccn normalbeg2dc10 - -rcontloop10: - maccn short normalbeg2dc11 - -rcontloop11: - maccn short normalbeg2dc12 - -rcontloop12: - maccn short normalbeg2dc13 - -rcontloop13: - maccn short normalbeg2dc14 - -rcontloop14: - maccn short normalbeg2dc15 - -rcontloop15: - and eax,7fffh - mov ax,word ptr[esi+eax*2] - cmp ecx,eax - jnb exitloop - - sub chain_length,16 - ja do16 - jmp normalbeg0add16 - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -normbeg MACRO rcontlab,valsub -; if we are here, we know that *(match+best_len-1) == scan_end - cmp bp,word ptr[edx+eax] -; if (match != scan_start) goto rcontlab - jne rcontlab -; calculate the good chain_length, and we'll compare scan and match string - add chain_length,16-valsub - jmp iseq - ENDM - - -normalbeg2dc11: - normbeg rcontloop11,11 - -normalbeg2dc12: - normbeg short rcontloop12,12 - -normalbeg2dc13: - normbeg short rcontloop13,13 - -normalbeg2dc14: - normbeg short rcontloop14,14 - -normalbeg2dc15: - normbeg short rcontloop15,15 - -normalbeg2dc10: - normbeg rcontloop10,10 - -normalbeg2dc9: - normbeg rcontloop9,9 - -normalbeg2dc8: - normbeg rcontloop8,8 - -normalbeg2dc7: - normbeg rcontloop7,7 - -normalbeg2dc6: - normbeg rcontloop6,6 - -normalbeg2dc5: - normbeg rcontloop5,5 - -normalbeg2dc4: - normbeg rcontloop4,4 - -normalbeg2dc3: - normbeg rcontloop3,3 - -normalbeg2dc2: - normbeg rcontloop2,2 - -normalbeg2dc1: - normbeg rcontloop1,1 - -normalbeg2dc0: - normbeg rcontloop0,0 - - -; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end - -normalbeg2: - mov edi,window - - cmp bp,word ptr[edi+eax] - jne contloop3 ; if *(ushf*)match != scan_start, continue - -iseq: -; if we are here, we know that *(match+best_len-1) == scan_end -; and (match == scan_start) - - mov edi,edx - mov esi,scan ; esi = scan - add edi,eax ; edi = window + cur_match = match - - mov edx,[esi+3] ; compare manually dword at match+3 - xor edx,[edi+3] ; and scan +3 - - jz begincompare ; if equal, go to long compare - -; we will determine the unmatch byte and calculate len (in esi) - or dl,dl - je eq1rr - mov esi,3 - jmp trfinval -eq1rr: - or dx,dx - je eq1 - - mov esi,4 - jmp trfinval -eq1: - and edx,0ffffffh - jz eq11 - mov esi,5 - jmp trfinval -eq11: - mov esi,6 - jmp trfinval - -begincompare: - ; here we now scan and match begin same - add edi,6 - add esi,6 - mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes - repe cmpsd ; loop until mismatch - - je trfin ; go to trfin if not unmatch -; we determine the unmatch byte - sub esi,4 - mov edx,[edi-4] - xor edx,[esi] - - or dl,dl - jnz trfin - inc esi - - or dx,dx - jnz trfin - inc esi - - and edx,0ffffffh - jnz trfin - inc esi - -trfin: - sub esi,scan ; esi = len -trfinval: -; here we have finised compare, and esi contain len of equal string - cmp esi,best_len ; if len > best_len, go newbestlen - ja short newbestlen -; now we restore edx, ecx and esi, for the big loop - mov esi,prev - mov ecx,limit - mov edx,window - jmp contloop3 - -newbestlen: - mov best_len,esi ; len become best_len - - mov match_start,eax ; save new position as match_start - cmp esi,nice_match ; if best_len >= nice_match, exit - jae exitloop - mov ecx,scan - mov edx,window ; restore edx=window - add ecx,esi - add esi,edx - - dec esi - mov windowlen,esi ; windowlen = window + best_len-1 - mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end - -; now we restore ecx and esi, for the big loop : - mov esi,prev - mov ecx,limit - jmp contloop3 - -exitloop: -; exit : s->match_start=match_start - mov ebx,match_start - mov ebp,str_s - mov ecx,best_len - mov dword ptr [ebp+dep_match_start],ebx - mov eax,dword ptr [ebp+dep_lookahead] - cmp ecx,eax - ja minexlo - mov eax,ecx -minexlo: -; return min(best_len,s->lookahead) - -; restore stack and register ebx,esi,edi,ebp - add esp,NbStackAdd - - pop ebx - pop esi - pop edi - pop ebp - ret -InfoAuthor: -; please don't remove this string ! -; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! - db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah - - - -IFDEF NOUNDERLINE -longest_match_7fff endp -ELSE -_longest_match_7fff endp -ENDIF - - -IFDEF NOUNDERLINE -cpudetect32 proc near -ELSE -_cpudetect32 proc near -ENDIF - - push ebx - - pushfd ; push original EFLAGS - pop eax ; get original EFLAGS - mov ecx, eax ; save original EFLAGS - xor eax, 40000h ; flip AC bit in EFLAGS - push eax ; save new EFLAGS value on stack - popfd ; replace current EFLAGS value - pushfd ; get new EFLAGS - pop eax ; store new EFLAGS in EAX - xor eax, ecx ; can稚 toggle AC bit, processor=80386 - jz end_cpu_is_386 ; jump if 80386 processor - push ecx - popfd ; restore AC bit in EFLAGS first - - pushfd - pushfd - pop ecx - - mov eax, ecx ; get original EFLAGS - xor eax, 200000h ; flip ID bit in EFLAGS - push eax ; save new EFLAGS value on stack - popfd ; replace current EFLAGS value - pushfd ; get new EFLAGS - pop eax ; store new EFLAGS in EAX - popfd ; restore original EFLAGS - xor eax, ecx ; can稚 toggle ID bit, - je is_old_486 ; processor=old - - mov eax,1 - db 0fh,0a2h ;CPUID - -exitcpudetect: - pop ebx - ret - -end_cpu_is_386: - mov eax,0300h - jmp exitcpudetect - -is_old_486: - mov eax,0400h - jmp exitcpudetect - -IFDEF NOUNDERLINE -cpudetect32 endp -ELSE -_cpudetect32 endp -ENDIF -ENDIF - -MAX_MATCH equ 258 -MIN_MATCH equ 3 -MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1) -MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h) - - -;;; stack frame offsets - -chainlenwmask equ esp + 0 ; high word: current chain len - ; low word: s->wmask -window equ esp + 4 ; local copy of s->window -windowbestlen equ esp + 8 ; s->window + bestlen -scanstart equ esp + 16 ; first two bytes of string -scanend equ esp + 12 ; last two bytes of string -scanalign equ esp + 20 ; dword-misalignment of string -nicematch equ esp + 24 ; a good enough match size -bestlen equ esp + 28 ; size of best match so far -scan equ esp + 32 ; ptr to string wanting match - -LocalVarsSize equ 36 -; saved ebx byte esp + 36 -; saved edi byte esp + 40 -; saved esi byte esp + 44 -; saved ebp byte esp + 48 -; return address byte esp + 52 -deflatestate equ esp + 56 ; the function arguments -curmatch equ esp + 60 - -;;; Offsets for fields in the deflate_state structure. These numbers -;;; are calculated from the definition of deflate_state, with the -;;; assumption that the compiler will dword-align the fields. (Thus, -;;; changing the definition of deflate_state could easily cause this -;;; program to crash horribly, without so much as a warning at -;;; compile time. Sigh.) - -dsWSize equ 36+zlib1222add -dsWMask equ 44+zlib1222add -dsWindow equ 48+zlib1222add -dsPrev equ 56+zlib1222add -dsMatchLen equ 88+zlib1222add -dsPrevMatch equ 92+zlib1222add -dsStrStart equ 100+zlib1222add -dsMatchStart equ 104+zlib1222add -dsLookahead equ 108+zlib1222add -dsPrevLen equ 112+zlib1222add -dsMaxChainLen equ 116+zlib1222add -dsGoodMatch equ 132+zlib1222add -dsNiceMatch equ 136+zlib1222add - - -;;; match.asm -- Pentium-Pro-optimized version of longest_match() -;;; Written for zlib 1.1.2 -;;; Copyright (C) 1998 Brian Raiter -;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html -;;; -;;; This is free software; you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License. - -;GLOBAL _longest_match, _match_init - - -;SECTION .text - -;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch) - -;_longest_match: -IFDEF NOOLDPENTIUMCODE - IFDEF NOUNDERLINE - longest_match proc near - ELSE - _longest_match proc near - ENDIF -ELSE - IFDEF NOUNDERLINE - longest_match_686 proc near - ELSE - _longest_match_686 proc near - ENDIF -ENDIF - -;;; Save registers that the compiler may be using, and adjust esp to -;;; make room for our stack frame. - - push ebp - push edi - push esi - push ebx - sub esp, LocalVarsSize - -;;; Retrieve the function arguments. ecx will hold cur_match -;;; throughout the entire function. edx will hold the pointer to the -;;; deflate_state structure during the function's setup (before -;;; entering the main loop. - - mov edx, [deflatestate] - mov ecx, [curmatch] - -;;; uInt wmask = s->w_mask; -;;; unsigned chain_length = s->max_chain_length; -;;; if (s->prev_length >= s->good_match) { -;;; chain_length >>= 2; -;;; } - - mov eax, [edx + dsPrevLen] - mov ebx, [edx + dsGoodMatch] - cmp eax, ebx - mov eax, [edx + dsWMask] - mov ebx, [edx + dsMaxChainLen] - jl LastMatchGood - shr ebx, 2 -LastMatchGood: - -;;; chainlen is decremented once beforehand so that the function can -;;; use the sign flag instead of the zero flag for the exit test. -;;; It is then shifted into the high word, to make room for the wmask -;;; value, which it will always accompany. - - dec ebx - shl ebx, 16 - or ebx, eax - mov [chainlenwmask], ebx - -;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - mov eax, [edx + dsNiceMatch] - mov ebx, [edx + dsLookahead] - cmp ebx, eax - jl LookaheadLess - mov ebx, eax -LookaheadLess: mov [nicematch], ebx - -;;; register Bytef *scan = s->window + s->strstart; - - mov esi, [edx + dsWindow] - mov [window], esi - mov ebp, [edx + dsStrStart] - lea edi, [esi + ebp] - mov [scan], edi - -;;; Determine how many bytes the scan ptr is off from being -;;; dword-aligned. - - mov eax, edi - neg eax - and eax, 3 - mov [scanalign], eax - -;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? -;;; s->strstart - (IPos)MAX_DIST(s) : NIL; - - mov eax, [edx + dsWSize] - sub eax, MIN_LOOKAHEAD - sub ebp, eax - jg LimitPositive - xor ebp, ebp -LimitPositive: - -;;; int best_len = s->prev_length; - - mov eax, [edx + dsPrevLen] - mov [bestlen], eax - -;;; Store the sum of s->window + best_len in esi locally, and in esi. - - add esi, eax - mov [windowbestlen], esi - -;;; register ush scan_start = *(ushf*)scan; -;;; register ush scan_end = *(ushf*)(scan+best_len-1); -;;; Posf *prev = s->prev; - - movzx ebx, word ptr [edi] - mov [scanstart], ebx - movzx ebx, word ptr [edi + eax - 1] - mov [scanend], ebx - mov edi, [edx + dsPrev] - -;;; Jump into the main loop. - - mov edx, [chainlenwmask] - jmp short LoopEntry - -align 4 - -;;; do { -;;; match = s->window + cur_match; -;;; if (*(ushf*)(match+best_len-1) != scan_end || -;;; *(ushf*)match != scan_start) continue; -;;; [...] -;;; } while ((cur_match = prev[cur_match & wmask]) > limit -;;; && --chain_length != 0); -;;; -;;; Here is the inner loop of the function. The function will spend the -;;; majority of its time in this loop, and majority of that time will -;;; be spent in the first ten instructions. -;;; -;;; Within this loop: -;;; ebx = scanend -;;; ecx = curmatch -;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) -;;; esi = windowbestlen - i.e., (window + bestlen) -;;; edi = prev -;;; ebp = limit - -LookupLoop: - and ecx, edx - movzx ecx, word ptr [edi + ecx*2] - cmp ecx, ebp - jbe LeaveNow - sub edx, 00010000h - js LeaveNow -LoopEntry: movzx eax, word ptr [esi + ecx - 1] - cmp eax, ebx - jnz LookupLoop - mov eax, [window] - movzx eax, word ptr [eax + ecx] - cmp eax, [scanstart] - jnz LookupLoop - -;;; Store the current value of chainlen. - - mov [chainlenwmask], edx - -;;; Point edi to the string under scrutiny, and esi to the string we -;;; are hoping to match it up with. In actuality, esi and edi are -;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is -;;; initialized to -(MAX_MATCH_8 - scanalign). - - mov esi, [window] - mov edi, [scan] - add esi, ecx - mov eax, [scanalign] - mov edx, 0fffffef8h; -(MAX_MATCH_8) - lea edi, [edi + eax + 0108h] ;MAX_MATCH_8] - lea esi, [esi + eax + 0108h] ;MAX_MATCH_8] - -;;; Test the strings for equality, 8 bytes at a time. At the end, -;;; adjust edx so that it is offset to the exact byte that mismatched. -;;; -;;; We already know at this point that the first three bytes of the -;;; strings match each other, and they can be safely passed over before -;;; starting the compare loop. So what this code does is skip over 0-3 -;;; bytes, as much as necessary in order to dword-align the edi -;;; pointer. (esi will still be misaligned three times out of four.) -;;; -;;; It should be confessed that this loop usually does not represent -;;; much of the total running time. Replacing it with a more -;;; straightforward "rep cmpsb" would not drastically degrade -;;; performance. - -LoopCmps: - mov eax, [esi + edx] - xor eax, [edi + edx] - jnz LeaveLoopCmps - mov eax, [esi + edx + 4] - xor eax, [edi + edx + 4] - jnz LeaveLoopCmps4 - add edx, 8 - jnz LoopCmps - jmp short LenMaximum -LeaveLoopCmps4: add edx, 4 -LeaveLoopCmps: test eax, 0000FFFFh - jnz LenLower - add edx, 2 - shr eax, 16 -LenLower: sub al, 1 - adc edx, 0 - -;;; Calculate the length of the match. If it is longer than MAX_MATCH, -;;; then automatically accept it as the best possible match and leave. - - lea eax, [edi + edx] - mov edi, [scan] - sub eax, edi - cmp eax, MAX_MATCH - jge LenMaximum - -;;; If the length of the match is not longer than the best match we -;;; have so far, then forget it and return to the lookup loop. - - mov edx, [deflatestate] - mov ebx, [bestlen] - cmp eax, ebx - jg LongerMatch - mov esi, [windowbestlen] - mov edi, [edx + dsPrev] - mov ebx, [scanend] - mov edx, [chainlenwmask] - jmp LookupLoop - -;;; s->match_start = cur_match; -;;; best_len = len; -;;; if (len >= nice_match) break; -;;; scan_end = *(ushf*)(scan+best_len-1); - -LongerMatch: mov ebx, [nicematch] - mov [bestlen], eax - mov [edx + dsMatchStart], ecx - cmp eax, ebx - jge LeaveNow - mov esi, [window] - add esi, eax - mov [windowbestlen], esi - movzx ebx, word ptr [edi + eax - 1] - mov edi, [edx + dsPrev] - mov [scanend], ebx - mov edx, [chainlenwmask] - jmp LookupLoop - -;;; Accept the current string, with the maximum possible length. - -LenMaximum: mov edx, [deflatestate] - mov dword ptr [bestlen], MAX_MATCH - mov [edx + dsMatchStart], ecx - -;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; -;;; return s->lookahead; - -LeaveNow: - mov edx, [deflatestate] - mov ebx, [bestlen] - mov eax, [edx + dsLookahead] - cmp ebx, eax - jg LookaheadRet - mov eax, ebx -LookaheadRet: - -;;; Restore the stack and return from whence we came. - - add esp, LocalVarsSize - pop ebx - pop esi - pop edi - pop ebp - - ret -; please don't remove this string ! -; Your can freely use gvmat32 in any free or commercial app if you don't remove the string in the binary! - db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah - - -IFDEF NOOLDPENTIUMCODE - IFDEF NOUNDERLINE - longest_match endp - ELSE - _longest_match endp - ENDIF - - IFDEF NOUNDERLINE - match_init proc near - ret - match_init endp - ELSE - _match_init proc near - ret - _match_init endp - ENDIF -ELSE - IFDEF NOUNDERLINE - longest_match_686 endp - ELSE - _longest_match_686 endp - ENDIF -ENDIF - -_TEXT ends -end diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32.obj b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32.obj deleted file mode 100644 index ebb326238..000000000 Binary files a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32.obj and /dev/null differ diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32c.c b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32c.c deleted file mode 100644 index 7ad2b2794..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/gvmat32c.c +++ /dev/null @@ -1,62 +0,0 @@ -/* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 - * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. - * File written by Gilles Vollant, by modifiying the longest_match - * from Jean-loup Gailly in deflate.c - * it prepare all parameters and call the assembly longest_match_gvasm - * longest_match execute standard C code is wmask != 0x7fff - * (assembly code is faster with a fixed wmask) - * - * Read comment at beginning of gvmat32.asm for more information - */ - -#if defined(ASMV) && (!defined(NOOLDPENTIUMCODE)) -#include "deflate.h" - -/* if your C compiler don't add underline before function name, - define ADD_UNDERLINE_ASMFUNC */ -#ifdef ADD_UNDERLINE_ASMFUNC -#define longest_match_7fff _longest_match_7fff -#define longest_match_686 _longest_match_686 -#define cpudetect32 _cpudetect32 -#endif - - -unsigned long cpudetect32(); - -uInt longest_match_c( - deflate_state *s, - IPos cur_match); /* current match */ - - -uInt longest_match_7fff( - deflate_state *s, - IPos cur_match); /* current match */ - -uInt longest_match_686( - deflate_state *s, - IPos cur_match); /* current match */ - - -static uInt iIsPPro=2; - -void match_init () -{ - iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; -} - -uInt longest_match( - deflate_state *s, - IPos cur_match) /* current match */ -{ - if (iIsPPro!=0) - return longest_match_686(s,cur_match); - - if (s->w_mask != 0x7fff) - return longest_match_686(s,cur_match); - - /* now ((s->w_mask == 0x7fff) && (iIsPPro==0)) */ - return longest_match_7fff(s,cur_match); -} - - -#endif /* defined(ASMV) && (!defined(NOOLDPENTIUMCODE)) */ diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/inffas32.asm b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/inffas32.asm deleted file mode 100644 index 4a205125e..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/inffas32.asm +++ /dev/null @@ -1,1083 +0,0 @@ -;/* inffas32.asm is a hand tuned assembler version of inffast.c -- fast decoding -; * -; * inffas32.asm is derivated from inffas86.c, with translation of assembly code -; * -; * Copyright (C) 1995-2003 Mark Adler -; * For conditions of distribution and use, see copyright notice in zlib.h -; * -; * Copyright (C) 2003 Chris Anderson -; * Please use the copyright conditions above. -; * -; * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from -; * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at -; * the moment. I have successfully compiled and tested this code with gcc2.96, -; * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S -; * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX -; * enabled. I will attempt to merge the MMX code into this version. Newer -; * versions of this and inffast.S can be found at -; * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ -; * -; * 2005 : modification by Gilles Vollant -; */ -; For Visual C++ 4.x and higher and ML 6.x and higher -; ml.exe is in directory \MASM611C of Win95 DDK -; ml.exe is also distributed in http://www.masm32.com/masmdl.htm -; and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/ -; -; -; compile with command line option -; ml /coff /Zi /c /Flinffas32.lst inffas32.asm - -; if you define NO_GZIP (see inflate.h), compile with -; ml /coff /Zi /c /Flinffas32.lst /DNO_GUNZIP inffas32.asm - - -; zlib122sup is 0 fort zlib 1.2.2.1 and lower -; zlib122sup is 8 fort zlib 1.2.2.2 and more (with addition of dmax and head -; in inflate_state in inflate.h) -zlib1222sup equ 8 - - -IFDEF GUNZIP - INFLATE_MODE_TYPE equ 11 - INFLATE_MODE_BAD equ 26 -ELSE - IFNDEF NO_GUNZIP - INFLATE_MODE_TYPE equ 11 - INFLATE_MODE_BAD equ 26 - ELSE - INFLATE_MODE_TYPE equ 3 - INFLATE_MODE_BAD equ 17 - ENDIF -ENDIF - - -; 75 "inffast.S" -;FILE "inffast.S" - -;;;GLOBAL _inflate_fast - -;;;SECTION .text - - - - .586p - .mmx - - name inflate_fast_x86 - .MODEL FLAT - -_DATA segment -inflate_fast_use_mmx: - dd 1 - - -_TEXT segment -PUBLIC _inflate_fast - -ALIGN 4 -_inflate_fast: - jmp inflate_fast_entry - - - -ALIGN 4 - db 'Fast decoding Code from Chris Anderson' - db 0 - -ALIGN 4 -invalid_literal_length_code_msg: - db 'invalid literal/length code' - db 0 - -ALIGN 4 -invalid_distance_code_msg: - db 'invalid distance code' - db 0 - -ALIGN 4 -invalid_distance_too_far_msg: - db 'invalid distance too far back' - db 0 - - -ALIGN 4 -inflate_fast_mask: -dd 0 -dd 1 -dd 3 -dd 7 -dd 15 -dd 31 -dd 63 -dd 127 -dd 255 -dd 511 -dd 1023 -dd 2047 -dd 4095 -dd 8191 -dd 16383 -dd 32767 -dd 65535 -dd 131071 -dd 262143 -dd 524287 -dd 1048575 -dd 2097151 -dd 4194303 -dd 8388607 -dd 16777215 -dd 33554431 -dd 67108863 -dd 134217727 -dd 268435455 -dd 536870911 -dd 1073741823 -dd 2147483647 -dd 4294967295 - - -mode_state equ 0 ;/* state->mode */ -wsize_state equ (32+zlib1222sup) ;/* state->wsize */ -write_state equ (36+4+zlib1222sup) ;/* state->write */ -window_state equ (40+4+zlib1222sup) ;/* state->window */ -hold_state equ (44+4+zlib1222sup) ;/* state->hold */ -bits_state equ (48+4+zlib1222sup) ;/* state->bits */ -lencode_state equ (64+4+zlib1222sup) ;/* state->lencode */ -distcode_state equ (68+4+zlib1222sup) ;/* state->distcode */ -lenbits_state equ (72+4+zlib1222sup) ;/* state->lenbits */ -distbits_state equ (76+4+zlib1222sup) ;/* state->distbits */ - - -;;SECTION .text -; 205 "inffast.S" -;GLOBAL inflate_fast_use_mmx - -;SECTION .data - - -; GLOBAL inflate_fast_use_mmx:object -;.size inflate_fast_use_mmx, 4 -; 226 "inffast.S" -;SECTION .text - -ALIGN 4 -inflate_fast_entry: - push edi - push esi - push ebp - push ebx - pushfd - sub esp,64 - cld - - - - - mov esi, [esp+88] - mov edi, [esi+28] - - - - - - - - mov edx, [esi+4] - mov eax, [esi+0] - - add edx,eax - sub edx,11 - - mov [esp+44],eax - mov [esp+20],edx - - mov ebp, [esp+92] - mov ecx, [esi+16] - mov ebx, [esi+12] - - sub ebp,ecx - neg ebp - add ebp,ebx - - sub ecx,257 - add ecx,ebx - - mov [esp+60],ebx - mov [esp+40],ebp - mov [esp+16],ecx -; 285 "inffast.S" - mov eax, [edi+lencode_state] - mov ecx, [edi+distcode_state] - - mov [esp+8],eax - mov [esp+12],ecx - - mov eax,1 - mov ecx, [edi+lenbits_state] - shl eax,cl - dec eax - mov [esp+0],eax - - mov eax,1 - mov ecx, [edi+distbits_state] - shl eax,cl - dec eax - mov [esp+4],eax - - mov eax, [edi+wsize_state] - mov ecx, [edi+write_state] - mov edx, [edi+window_state] - - mov [esp+52],eax - mov [esp+48],ecx - mov [esp+56],edx - - mov ebp, [edi+hold_state] - mov ebx, [edi+bits_state] -; 321 "inffast.S" - mov esi, [esp+44] - mov ecx, [esp+20] - cmp ecx,esi - ja L_align_long - - add ecx,11 - sub ecx,esi - mov eax,12 - sub eax,ecx - lea edi, [esp+28] - rep movsb - mov ecx,eax - xor eax,eax - rep stosb - lea esi, [esp+28] - mov [esp+20],esi - jmp L_is_aligned - - -L_align_long: - test esi,3 - jz L_is_aligned - xor eax,eax - mov al, [esi] - inc esi - mov ecx,ebx - add ebx,8 - shl eax,cl - or ebp,eax - jmp L_align_long - -L_is_aligned: - mov edi, [esp+60] -; 366 "inffast.S" -L_check_mmx: - cmp dword ptr [inflate_fast_use_mmx],2 - je L_init_mmx - ja L_do_loop - - push eax - push ebx - push ecx - push edx - pushfd - mov eax, [esp] - xor dword ptr [esp],0200000h - - - - - popfd - pushfd - pop edx - xor edx,eax - jz L_dont_use_mmx - xor eax,eax - cpuid - cmp ebx,0756e6547h - jne L_dont_use_mmx - cmp ecx,06c65746eh - jne L_dont_use_mmx - cmp edx,049656e69h - jne L_dont_use_mmx - mov eax,1 - cpuid - shr eax,8 - and eax,15 - cmp eax,6 - jne L_dont_use_mmx - test edx,0800000h - jnz L_use_mmx - jmp L_dont_use_mmx -L_use_mmx: - mov dword ptr [inflate_fast_use_mmx],2 - jmp L_check_mmx_pop -L_dont_use_mmx: - mov dword ptr [inflate_fast_use_mmx],3 -L_check_mmx_pop: - pop edx - pop ecx - pop ebx - pop eax - jmp L_check_mmx -; 426 "inffast.S" -ALIGN 4 -L_do_loop: -; 437 "inffast.S" - cmp bl,15 - ja L_get_length_code - - xor eax,eax - lodsw - mov cl,bl - add bl,16 - shl eax,cl - or ebp,eax - -L_get_length_code: - mov edx, [esp+0] - mov ecx, [esp+8] - and edx,ebp - mov eax, [ecx+edx*4] - -L_dolen: - - - - - - - mov cl,ah - sub bl,ah - shr ebp,cl - - - - - - - test al,al - jnz L_test_for_length_base - - shr eax,16 - stosb - -L_while_test: - - - cmp [esp+16],edi - jbe L_break_loop - - cmp [esp+20],esi - ja L_do_loop - jmp L_break_loop - -L_test_for_length_base: -; 502 "inffast.S" - mov edx,eax - shr edx,16 - mov cl,al - - test al,16 - jz L_test_for_second_level_length - and cl,15 - jz L_save_len - cmp bl,cl - jae L_add_bits_to_len - - mov ch,cl - xor eax,eax - lodsw - mov cl,bl - add bl,16 - shl eax,cl - or ebp,eax - mov cl,ch - -L_add_bits_to_len: - mov eax,1 - shl eax,cl - dec eax - sub bl,cl - and eax,ebp - shr ebp,cl - add edx,eax - -L_save_len: - mov [esp+24],edx - - -L_decode_distance: -; 549 "inffast.S" - cmp bl,15 - ja L_get_distance_code - - xor eax,eax - lodsw - mov cl,bl - add bl,16 - shl eax,cl - or ebp,eax - -L_get_distance_code: - mov edx, [esp+4] - mov ecx, [esp+12] - and edx,ebp - mov eax, [ecx+edx*4] - - -L_dodist: - mov edx,eax - shr edx,16 - mov cl,ah - sub bl,ah - shr ebp,cl -; 584 "inffast.S" - mov cl,al - - test al,16 - jz L_test_for_second_level_dist - and cl,15 - jz L_check_dist_one - cmp bl,cl - jae L_add_bits_to_dist - - mov ch,cl - xor eax,eax - lodsw - mov cl,bl - add bl,16 - shl eax,cl - or ebp,eax - mov cl,ch - -L_add_bits_to_dist: - mov eax,1 - shl eax,cl - dec eax - sub bl,cl - and eax,ebp - shr ebp,cl - add edx,eax - jmp L_check_window - -L_check_window: -; 625 "inffast.S" - mov [esp+44],esi - mov eax,edi - sub eax, [esp+40] - - cmp eax,edx - jb L_clip_window - - mov ecx, [esp+24] - mov esi,edi - sub esi,edx - - sub ecx,3 - mov al, [esi] - mov [edi],al - mov al, [esi+1] - mov dl, [esi+2] - add esi,3 - mov [edi+1],al - mov [edi+2],dl - add edi,3 - rep movsb - - mov esi, [esp+44] - jmp L_while_test - -ALIGN 4 -L_check_dist_one: - cmp edx,1 - jne L_check_window - cmp [esp+40],edi - je L_check_window - - dec edi - mov ecx, [esp+24] - mov al, [edi] - sub ecx,3 - - mov [edi+1],al - mov [edi+2],al - mov [edi+3],al - add edi,4 - rep stosb - - jmp L_while_test - -ALIGN 4 -L_test_for_second_level_length: - - - - - test al,64 - jnz L_test_for_end_of_block - - mov eax,1 - shl eax,cl - dec eax - and eax,ebp - add eax,edx - mov edx, [esp+8] - mov eax, [edx+eax*4] - jmp L_dolen - -ALIGN 4 -L_test_for_second_level_dist: - - - - - test al,64 - jnz L_invalid_distance_code - - mov eax,1 - shl eax,cl - dec eax - and eax,ebp - add eax,edx - mov edx, [esp+12] - mov eax, [edx+eax*4] - jmp L_dodist - -ALIGN 4 -L_clip_window: -; 721 "inffast.S" - mov ecx,eax - mov eax, [esp+52] - neg ecx - mov esi, [esp+56] - - cmp eax,edx - jb L_invalid_distance_too_far - - add ecx,edx - cmp dword ptr [esp+48],0 - jne L_wrap_around_window - - sub eax,ecx - add esi,eax -; 749 "inffast.S" - mov eax, [esp+24] - cmp eax,ecx - jbe L_do_copy1 - - sub eax,ecx - rep movsb - mov esi,edi - sub esi,edx - jmp L_do_copy1 - - cmp eax,ecx - jbe L_do_copy1 - - sub eax,ecx - rep movsb - mov esi,edi - sub esi,edx - jmp L_do_copy1 - -L_wrap_around_window: -; 793 "inffast.S" - mov eax, [esp+48] - cmp ecx,eax - jbe L_contiguous_in_window - - add esi, [esp+52] - add esi,eax - sub esi,ecx - sub ecx,eax - - - mov eax, [esp+24] - cmp eax,ecx - jbe L_do_copy1 - - sub eax,ecx - rep movsb - mov esi, [esp+56] - mov ecx, [esp+48] - cmp eax,ecx - jbe L_do_copy1 - - sub eax,ecx - rep movsb - mov esi,edi - sub esi,edx - jmp L_do_copy1 - -L_contiguous_in_window: -; 836 "inffast.S" - add esi,eax - sub esi,ecx - - - mov eax, [esp+24] - cmp eax,ecx - jbe L_do_copy1 - - sub eax,ecx - rep movsb - mov esi,edi - sub esi,edx - -L_do_copy1: -; 862 "inffast.S" - mov ecx,eax - rep movsb - - mov esi, [esp+44] - jmp L_while_test -; 878 "inffast.S" -ALIGN 4 -L_init_mmx: - emms - - - - - - movd mm0,ebp - mov ebp,ebx -; 896 "inffast.S" - movd mm4,[esp+0] - movq mm3,mm4 - movd mm5,[esp+4] - movq mm2,mm5 - pxor mm1,mm1 - mov ebx, [esp+8] - jmp L_do_loop_mmx - -ALIGN 4 -L_do_loop_mmx: - psrlq mm0,mm1 - - cmp ebp,32 - ja L_get_length_code_mmx - - movd mm6,ebp - movd mm7,[esi] - add esi,4 - psllq mm7,mm6 - add ebp,32 - por mm0,mm7 - -L_get_length_code_mmx: - pand mm4,mm0 - movd eax,mm4 - movq mm4,mm3 - mov eax, [ebx+eax*4] - -L_dolen_mmx: - movzx ecx,ah - movd mm1,ecx - sub ebp,ecx - - test al,al - jnz L_test_for_length_base_mmx - - shr eax,16 - stosb - -L_while_test_mmx: - - - cmp [esp+16],edi - jbe L_break_loop - - cmp [esp+20],esi - ja L_do_loop_mmx - jmp L_break_loop - -L_test_for_length_base_mmx: - - mov edx,eax - shr edx,16 - - test al,16 - jz L_test_for_second_level_length_mmx - and eax,15 - jz L_decode_distance_mmx - - psrlq mm0,mm1 - movd mm1,eax - movd ecx,mm0 - sub ebp,eax - and ecx, [inflate_fast_mask+eax*4] - add edx,ecx - -L_decode_distance_mmx: - psrlq mm0,mm1 - - cmp ebp,32 - ja L_get_dist_code_mmx - - movd mm6,ebp - movd mm7,[esi] - add esi,4 - psllq mm7,mm6 - add ebp,32 - por mm0,mm7 - -L_get_dist_code_mmx: - mov ebx, [esp+12] - pand mm5,mm0 - movd eax,mm5 - movq mm5,mm2 - mov eax, [ebx+eax*4] - -L_dodist_mmx: - - movzx ecx,ah - mov ebx,eax - shr ebx,16 - sub ebp,ecx - movd mm1,ecx - - test al,16 - jz L_test_for_second_level_dist_mmx - and eax,15 - jz L_check_dist_one_mmx - -L_add_bits_to_dist_mmx: - psrlq mm0,mm1 - movd mm1,eax - movd ecx,mm0 - sub ebp,eax - and ecx, [inflate_fast_mask+eax*4] - add ebx,ecx - -L_check_window_mmx: - mov [esp+44],esi - mov eax,edi - sub eax, [esp+40] - - cmp eax,ebx - jb L_clip_window_mmx - - mov ecx,edx - mov esi,edi - sub esi,ebx - - sub ecx,3 - mov al, [esi] - mov [edi],al - mov al, [esi+1] - mov dl, [esi+2] - add esi,3 - mov [edi+1],al - mov [edi+2],dl - add edi,3 - rep movsb - - mov esi, [esp+44] - mov ebx, [esp+8] - jmp L_while_test_mmx - -ALIGN 4 -L_check_dist_one_mmx: - cmp ebx,1 - jne L_check_window_mmx - cmp [esp+40],edi - je L_check_window_mmx - - dec edi - mov ecx,edx - mov al, [edi] - sub ecx,3 - - mov [edi+1],al - mov [edi+2],al - mov [edi+3],al - add edi,4 - rep stosb - - mov ebx, [esp+8] - jmp L_while_test_mmx - -ALIGN 4 -L_test_for_second_level_length_mmx: - test al,64 - jnz L_test_for_end_of_block - - and eax,15 - psrlq mm0,mm1 - movd ecx,mm0 - and ecx, [inflate_fast_mask+eax*4] - add ecx,edx - mov eax, [ebx+ecx*4] - jmp L_dolen_mmx - -ALIGN 4 -L_test_for_second_level_dist_mmx: - test al,64 - jnz L_invalid_distance_code - - and eax,15 - psrlq mm0,mm1 - movd ecx,mm0 - and ecx, [inflate_fast_mask+eax*4] - mov eax, [esp+12] - add ecx,ebx - mov eax, [eax+ecx*4] - jmp L_dodist_mmx - -ALIGN 4 -L_clip_window_mmx: - - mov ecx,eax - mov eax, [esp+52] - neg ecx - mov esi, [esp+56] - - cmp eax,ebx - jb L_invalid_distance_too_far - - add ecx,ebx - cmp dword ptr [esp+48],0 - jne L_wrap_around_window_mmx - - sub eax,ecx - add esi,eax - - cmp edx,ecx - jbe L_do_copy1_mmx - - sub edx,ecx - rep movsb - mov esi,edi - sub esi,ebx - jmp L_do_copy1_mmx - - cmp edx,ecx - jbe L_do_copy1_mmx - - sub edx,ecx - rep movsb - mov esi,edi - sub esi,ebx - jmp L_do_copy1_mmx - -L_wrap_around_window_mmx: - - mov eax, [esp+48] - cmp ecx,eax - jbe L_contiguous_in_window_mmx - - add esi, [esp+52] - add esi,eax - sub esi,ecx - sub ecx,eax - - - cmp edx,ecx - jbe L_do_copy1_mmx - - sub edx,ecx - rep movsb - mov esi, [esp+56] - mov ecx, [esp+48] - cmp edx,ecx - jbe L_do_copy1_mmx - - sub edx,ecx - rep movsb - mov esi,edi - sub esi,ebx - jmp L_do_copy1_mmx - -L_contiguous_in_window_mmx: - - add esi,eax - sub esi,ecx - - - cmp edx,ecx - jbe L_do_copy1_mmx - - sub edx,ecx - rep movsb - mov esi,edi - sub esi,ebx - -L_do_copy1_mmx: - - - mov ecx,edx - rep movsb - - mov esi, [esp+44] - mov ebx, [esp+8] - jmp L_while_test_mmx -; 1174 "inffast.S" -L_invalid_distance_code: - - - - - - mov ecx, invalid_distance_code_msg - mov edx,INFLATE_MODE_BAD - jmp L_update_stream_state - -L_test_for_end_of_block: - - - - - - test al,32 - jz L_invalid_literal_length_code - - mov ecx,0 - mov edx,INFLATE_MODE_TYPE - jmp L_update_stream_state - -L_invalid_literal_length_code: - - - - - - mov ecx, invalid_literal_length_code_msg - mov edx,INFLATE_MODE_BAD - jmp L_update_stream_state - -L_invalid_distance_too_far: - - - - mov esi, [esp+44] - mov ecx, invalid_distance_too_far_msg - mov edx,INFLATE_MODE_BAD - jmp L_update_stream_state - -L_update_stream_state: - - mov eax, [esp+88] - test ecx,ecx - jz L_skip_msg - mov [eax+24],ecx -L_skip_msg: - mov eax, [eax+28] - mov [eax+mode_state],edx - jmp L_break_loop - -ALIGN 4 -L_break_loop: -; 1243 "inffast.S" - cmp dword ptr [inflate_fast_use_mmx],2 - jne L_update_next_in - - - - mov ebx,ebp - -L_update_next_in: -; 1266 "inffast.S" - mov eax, [esp+88] - mov ecx,ebx - mov edx, [eax+28] - shr ecx,3 - sub esi,ecx - shl ecx,3 - sub ebx,ecx - mov [eax+12],edi - mov [edx+bits_state],ebx - mov ecx,ebx - - lea ebx, [esp+28] - cmp [esp+20],ebx - jne L_buf_not_used - - sub esi,ebx - mov ebx, [eax+0] - mov [esp+20],ebx - add esi,ebx - mov ebx, [eax+4] - sub ebx,11 - add [esp+20],ebx - -L_buf_not_used: - mov [eax+0],esi - - mov ebx,1 - shl ebx,cl - dec ebx - - - - - - cmp dword ptr [inflate_fast_use_mmx],2 - jne L_update_hold - - - - psrlq mm0,mm1 - movd ebp,mm0 - - emms - -L_update_hold: - - - - and ebp,ebx - mov [edx+hold_state],ebp - - - - - mov ebx, [esp+20] - cmp ebx,esi - jbe L_last_is_smaller - - sub ebx,esi - add ebx,11 - mov [eax+4],ebx - jmp L_fixup_out -L_last_is_smaller: - sub esi,ebx - neg esi - add esi,11 - mov [eax+4],esi - - - - -L_fixup_out: - - mov ebx, [esp+16] - cmp ebx,edi - jbe L_end_is_smaller - - sub ebx,edi - add ebx,257 - mov [eax+16],ebx - jmp L_done -L_end_is_smaller: - sub edi,ebx - neg edi - add edi,257 - mov [eax+16],edi - - - - - -L_done: - add esp,64 - popfd - pop ebx - pop ebp - pop esi - pop edi - ret - -_TEXT ends -end diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/inffas32.obj b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/inffas32.obj deleted file mode 100644 index bd6664d11..000000000 Binary files a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/inffas32.obj and /dev/null differ diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/mkasm.bat b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/mkasm.bat deleted file mode 100644 index 70a51f837..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/mkasm.bat +++ /dev/null @@ -1,3 +0,0 @@ -cl /DASMV /I..\.. /O2 /c gvmat32c.c -ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm -ml /coff /Zi /c /Flinffas32.lst inffas32.asm diff --git a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/readme.txt b/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/readme.txt deleted file mode 100644 index 7b57167b7..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/contrib/masmx86/readme.txt +++ /dev/null @@ -1,21 +0,0 @@ - -Summary -------- -This directory contains ASM implementations of the functions -longest_match() and inflate_fast(). - - -Use instructions ----------------- -Copy these files into the zlib source directory, then run the -appropriate makefile, as suggested below. - - -Build instructions ------------------- -* With Microsoft C and MASM: -nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" - -* With Borland C and TASM: -make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" OBJPA="+gvmat32c.obj+gvmat32.obj+inffas32.obj" - diff --git a/tools/vio2sf/src/vio2sf/zlib/crc32.c b/tools/vio2sf/src/vio2sf/zlib/crc32.c deleted file mode 100644 index 32814c20c..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/crc32.c +++ /dev/null @@ -1,423 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -/* @(#) $Id$ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - */ - -#ifdef MAKECRCH -# include -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for STDC and FAR definitions */ - -#define local static - -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - -/* Definitions for doing the crc four data bytes at a time. */ -#ifdef BYFOUR -# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); -# define TBLS 8 -#else -# define TBLS 1 -#endif /* BYFOUR */ - -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); - -#ifdef DYNAMIC_CRC_TABLE - -local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); -#ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); -#endif /* MAKECRCH */ -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - unsigned long c; - int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (unsigned long)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = REV(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); - } - } -#endif /* BYFOUR */ - - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; - } - -#ifdef MAKECRCH - /* write out CRC tables to crc32.h */ - { - FILE *out; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); - } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const unsigned long FAR *table; -{ - int n; - - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} -#endif /* MAKECRCH */ - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const unsigned long FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; -} - -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - if (buf == Z_NULL) return 0UL; - -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; - - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); - } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; - } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} - -#ifdef BYFOUR - -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 - -/* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = (u4)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} - -/* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 - -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = REV((u4)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - buf4--; - while (len >= 32) { - DOBIG32; - len -= 32; - } - while (len >= 4) { - DOBIG4; - len -= 4; - } - buf4++; - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(REV(c)); -} - -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - -/* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - -/* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case */ - if (len2 == 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320L; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } - - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; -} diff --git a/tools/vio2sf/src/vio2sf/zlib/crc32.h b/tools/vio2sf/src/vio2sf/zlib/crc32.h deleted file mode 100644 index 5de49bc97..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const unsigned long FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL -#endif - } -}; diff --git a/tools/vio2sf/src/vio2sf/zlib/crypt.h b/tools/vio2sf/src/vio2sf/zlib/crypt.h deleted file mode 100644 index 9c7a89cbe..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/crypt.h +++ /dev/null @@ -1,132 +0,0 @@ -/* crypt.h -- base code for crypt/uncrypt ZIPfile - - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - This code is a modified version of crypting code in Infozip distribution - - The encryption/decryption parts of this source code (as opposed to the - non-echoing password parts) were originally written in Europe. The - whole source package can be freely distributed, including from the USA. - (Prior to January 2000, re-export from the US was a violation of US law.) - - This encryption code is a direct transcription of the algorithm from - Roger Schlafly, described by Phil Katz in the file appnote.txt. This - file (appnote.txt) is distributed with the PKZIP program (even in the - version without encryption capabilities). - - If you don't need crypting in your application, just define symbols - NOCRYPT and NOUNCRYPT. - - This code support the "Traditional PKWARE Encryption". - - The new AES encryption added on Zip format by Winzip (see the page - http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong - Encryption is not supported. -*/ - -#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) - -/*********************************************************************** - * Return the next byte in the pseudo-random sequence - */ -static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) -{ - unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an - * unpredictable manner on 16-bit systems; not a problem - * with any known compiler so far, though */ - - temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; - return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); -} - -/*********************************************************************** - * Update the encryption keys with the next byte of plain text - */ -static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) -{ - (*(pkeys+0)) = CRC32((*(pkeys+0)), c); - (*(pkeys+1)) += (*(pkeys+0)) & 0xff; - (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; - { - register int keyshift = (int)((*(pkeys+1)) >> 24); - (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); - } - return c; -} - - -/*********************************************************************** - * Initialize the encryption keys and the random header according to - * the given password. - */ -static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) -{ - *(pkeys+0) = 305419896L; - *(pkeys+1) = 591751049L; - *(pkeys+2) = 878082192L; - while (*passwd != '\0') { - update_keys(pkeys,pcrc_32_tab,(int)*passwd); - passwd++; - } -} - -#define zdecode(pkeys,pcrc_32_tab,c) \ - (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) - -#define zencode(pkeys,pcrc_32_tab,c,t) \ - (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) - -#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED - -#define RAND_HEAD_LEN 12 - /* "last resort" source for second part of crypt seed pattern */ -# ifndef ZCR_SEED2 -# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ -# endif - -static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) - const char *passwd; /* password string */ - unsigned char *buf; /* where to write header */ - int bufSize; - unsigned long* pkeys; - const unsigned long* pcrc_32_tab; - unsigned long crcForCrypting; -{ - int n; /* index in random header */ - int t; /* temporary */ - int c; /* random byte */ - unsigned char header[RAND_HEAD_LEN-2]; /* random header */ - static unsigned calls = 0; /* ensure different random header each time */ - - if (bufSize> 7) & 0xff; - header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); - } - /* Encrypt random header (last two bytes is high word of crc) */ - init_keys(passwd, pkeys, pcrc_32_tab); - for (n = 0; n < RAND_HEAD_LEN-2; n++) - { - buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); - } - buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); - buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); - return n; -} - -#endif diff --git a/tools/vio2sf/src/vio2sf/zlib/infback.c b/tools/vio2sf/src/vio2sf/zlib/infback.c deleted file mode 100644 index 1e03e1bab..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/infback.c +++ /dev/null @@ -1,623 +0,0 @@ -/* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - This code is largely copied from inflate.c. Normally either infback.o or - inflate.o would be linked into an application--not both. The interface - with inffast.c is retained so that optimized assembler-coded versions of - inflate_fast() can be used with either inflate.c or infback.c. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - windowBits is in the range 8..15, and window is a user-supplied - window and output buffer that is 2**windowBits bytes. - */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL || - windowBits < 8 || windowBits > 15) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->dmax = 32768U; - state->wbits = windowBits; - state->wsize = 1U << windowBits; - state->window = window; - state->write = 0; - state->whave = 0; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -/* Macros for inflateBack(): */ - -/* Load returned state from inflate_fast() */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Set state from registers for inflate_fast() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = state->window; \ - left = state->wsize; \ - state->whave = left; \ - if (out(out_desc, put, left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - state->mode = TYPE; - state->last = 0; - state->whave = 0; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = state->window; - left = state->wsize; - - /* Inflate until end of block marked as last */ - for (;;) - switch (state->mode) { - case TYPE: - /* determine and dispatch block type */ - if (state->last) { - BYTEBITS(); - state->mode = DONE; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - - /* copy stored block from input to output */ - while (state->length != 0) { - copy = state->length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= 6 && left >= 258) { - RESTORE(); - if (state->whave < state->wsize) - state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); - LOAD(); - break; - } - - /* get a literal, length, or end-of-block code */ - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - - /* process literal */ - if (this.op == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - ROOM(); - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - } - - /* process end of block */ - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - - /* invalid code */ - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - - /* get distance code */ - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - - /* get distance extra bits, if any */ - state->extra = (unsigned)(this.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->wsize - (state->whave < state->wsize ? - left : 0)) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = state->wsize - state->offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - state->offset; - copy = left; - } - if (copy > state->length) copy = state->length; - state->length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (state->length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/tools/vio2sf/src/vio2sf/zlib/inffast.c b/tools/vio2sf/src/vio2sf/zlib/inffast.c deleted file mode 100644 index fa31cad90..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/inffast.c +++ /dev/null @@ -1,318 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ -#else -# define OFF 1 -# define PUP(a) *++(a) -#endif - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - unsigned char FAR *in; /* local strm->next_in */ - unsigned char FAR *last; /* while in < last, enough input available */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code this; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; - last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - write = state->write; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = lcode[hold & lmask]; - dolen: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op == 0) { /* literal */ - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - PUP(out) = (unsigned char)(this.val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = dcode[hold & dmask]; - dodist: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op & 16) { /* distance base */ - dist = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - from = window - OFF; - if (write == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (write < op) { /* wrap around window */ - from += wsize + write - op; - op -= write; - if (op < len) { /* some from end of window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = window - OFF; - if (write < len) { /* some from start of window */ - op = write; - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += write - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } while (len > 2); - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - this = dcode[this.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - this = lcode[this.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and write == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/tools/vio2sf/src/vio2sf/zlib/inffast.h b/tools/vio2sf/src/vio2sf/zlib/inffast.h deleted file mode 100644 index 614fa7877..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/tools/vio2sf/src/vio2sf/zlib/inffixed.h b/tools/vio2sf/src/vio2sf/zlib/inffixed.h deleted file mode 100644 index 423d5c5b5..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. It - is part of the implementation of the compression library and - is subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/tools/vio2sf/src/vio2sf/zlib/inflate.c b/tools/vio2sf/src/vio2sf/zlib/inflate.c deleted file mode 100644 index 33ea90292..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/inflate.c +++ /dev/null @@ -1,1368 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common write == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, unsigned out)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, - unsigned len)); - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - strm->adler = 1; /* to support ill-conceived Java test suite */ - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = Z_NULL; - state->wsize = 0; - state->whave = 0; - state->write = 0; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; - return Z_OK; -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - if (windowBits < 0) { - state->wrap = 0; - windowBits = -windowBits; - } - else { - state->wrap = (windowBits >> 4) + 1; -#ifdef GUNZIP - if (windowBits < 48) windowBits &= 15; -#endif - } - if (windowBits < 8 || windowBits > 15) { - ZFREE(strm, state); - strm->state = Z_NULL; - return Z_STREAM_ERROR; - } - state->wbits = (unsigned)windowBits; - state->window = Z_NULL; - return inflateReset(strm); -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, - state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, out) -z_streamp strm; -unsigned out; -{ - struct inflate_state FAR *state; - unsigned copy, dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->write = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; - if (copy >= state->wsize) { - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); - state->write = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->write; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->write, strm->next_out - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, strm->next_out - copy, copy); - state->write = copy; - state->whave = state->wsize; - } - else { - state->write += dist; - if (state->write == state->wsize) state->write = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Reverse the bytes in a 32-bit value */ -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - state->flags = 0; /* expect zlib header */ - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if (hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK) goto inf_leave; - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else { - if (this.val == 16) { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - break; - } - for (;;) { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - if ((int)(this.op) == 0) { - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", this.val)); - state->mode = LIT; - break; - } - if (this.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - if (this.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(this.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->mode = DIST; - case DIST: - for (;;) { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) { - last = this; - for (;;) { - this = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - state->extra = (unsigned)(this.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - if (state->offset > state->whave + out - left) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->write) { - copy -= state->write; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->write - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if (out) - strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if (( -#ifdef GUNZIP - state->flags ? hold : -#endif - REVERSE(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) - if (updatewindow(strm, out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if (state->wrap && out) - strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long id; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary id */ - if (state->mode == DICT) { - id = adler32(0L, Z_NULL, 0); - id = adler32(id, dictionary, dictLength); - if (id != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window */ - if (updatewindow(strm, strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - if (dictLength > state->wsize) { - zmemcpy(state->window, dictionary + dictLength - state->wsize, - state->wsize); - state->whave = state->wsize; - } - else { - zmemcpy(state->window + state->wsize - dictLength, dictionary, - dictLength); - state->whave = dictLength; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy(dest, source, sizeof(z_stream)); - zmemcpy(copy, state, sizeof(struct inflate_state)); - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} diff --git a/tools/vio2sf/src/vio2sf/zlib/inflate.h b/tools/vio2sf/src/vio2sf/zlib/inflate.h deleted file mode 100644 index fbbc87143..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/inflate.h +++ /dev/null @@ -1,115 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2004 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN, /* i: waiting for length/lit code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to the BAD or MEM mode -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME - NAME -> COMMENT -> HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - Read deflate blocks: - TYPE -> STORED or TABLE or LEN or CHECK - STORED -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN - Read deflate codes: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* state maintained between inflate() calls. Approximately 7K bytes. */ -struct inflate_state { - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ -}; diff --git a/tools/vio2sf/src/vio2sf/zlib/inftrees.c b/tools/vio2sf/src/vio2sf/zlib/inftrees.c deleted file mode 100644 index 38ded81c3..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/inftrees.c +++ /dev/null @@ -1,329 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code this; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)1; - this.val = (unsigned short)0; - *(*table)++ = this; /* make a table to force an error */ - *(*table)++ = this; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min <= MAXBITS; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked when a LENS table is being made - against the space in *table, ENOUGH, minus the maximum space needed by - the worst case distance code, MAXD. This should never happen, but the - sufficiency of ENOUGH has not been proven exhaustively, hence the check. - This assumes that when type == LENS, bits == 9. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - this.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { - this.op = (unsigned char)0; - this.val = work[sym]; - } - else if ((int)(work[sym]) > end) { - this.op = (unsigned char)(extra[work[sym]]); - this.val = base[work[sym]]; - } - else { - this.op = (unsigned char)(32 + 64); /* end of block */ - this.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = this; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if (type == LENS && used >= ENOUGH - MAXD) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* - Fill in rest of table for incomplete codes. This loop is similar to the - loop above in incrementing huff for table indices. It is assumed that - len is equal to curr + drop, so there is no loop needed to increment - through high index bits. When the current sub-table is filled, the loop - drops back to the root table to fill in any remaining entries there. - */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)(len - drop); - this.val = (unsigned short)0; - while (huff != 0) { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) { - drop = 0; - len = root; - next = *table; - this.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = this; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/tools/vio2sf/src/vio2sf/zlib/inftrees.h b/tools/vio2sf/src/vio2sf/zlib/inftrees.h deleted file mode 100644 index dc0fd567e..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/inftrees.h +++ /dev/null @@ -1,55 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1444 code structures (852 for length/literals - and 592 for distances, the latter actually the result of an - exhaustive search). The true maximum is not known, but the value - below is more than safe. */ -#define ENOUGH 2048 -#define MAXD 592 - -/* Type of code to build for inftable() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -extern int inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/tools/vio2sf/src/vio2sf/zlib/uncompr.c b/tools/vio2sf/src/vio2sf/zlib/uncompr.c deleted file mode 100644 index ad6db0a67..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/uncompr.c +++ /dev/null @@ -1,61 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) - return Z_DATA_ERROR; - return err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/tools/vio2sf/src/vio2sf/zlib/zconf.h b/tools/vio2sf/src/vio2sf/zlib/zconf.h deleted file mode 100644 index e3b0c962e..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/zconf.h +++ /dev/null @@ -1,332 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define deflateBound z_deflateBound -# define deflatePrime z_deflatePrime -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateCopy z_inflateCopy -# define inflateReset z_inflateReset -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table -# define zError z_zError - -# define alloc_func z_alloc_func -# define free_func z_free_func -# define in_func z_in_func -# define out_func z_out_func -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/tools/vio2sf/src/vio2sf/zlib/zlib.h b/tools/vio2sf/src/vio2sf/zlib/zlib.h deleted file mode 100644 index 62d0e4675..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/zlib.h +++ /dev/null @@ -1,1357 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns 1 if file is being read directly without decompression, otherwise - zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); -/* - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - -/* - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/tools/vio2sf/src/vio2sf/zlib/zutil.c b/tools/vio2sf/src/vio2sf/zlib/zutil.c deleted file mode 100644 index 0f4bd7871..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/zutil.c +++ /dev/null @@ -1,318 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch (sizeof(uInt)) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch (sizeof(uLong)) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch (sizeof(voidpf)) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch (sizeof(z_off_t)) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#ifdef STDC -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int z_verbose = verbose; - -void z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ diff --git a/tools/vio2sf/src/vio2sf/zlib/zutil.h b/tools/vio2sf/src/vio2sf/zlib/zutil.h deleted file mode 100644 index 0ba6e0208..000000000 --- a/tools/vio2sf/src/vio2sf/zlib/zutil.h +++ /dev/null @@ -1,269 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#define ZLIB_INTERNAL -#include "zlib.h" - -#ifdef STDC -# ifndef _WIN32_WCE -# include -# endif -# include -# include -#endif -#ifdef NO_ERRNO_H -# ifdef _WIN32_WCE - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. We rename it to - * avoid conflict with other libraries that use the same workaround. - */ -# define errno z_errno -# endif - extern int errno; -#else -# ifndef _WIN32_WCE -# include -# endif -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# ifdef M_I86 - #include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# define vsnprintf _vsnprintf -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ diff --git a/tools/vio2sf/src/xsfc/drvimpl.h b/tools/vio2sf/src/xsfc/drvimpl.h deleted file mode 100644 index 680d8e898..000000000 --- a/tools/vio2sf/src/xsfc/drvimpl.h +++ /dev/null @@ -1,18 +0,0 @@ -#define XSF_FALSE (0) -#define XSF_TRUE (!XSF_FALSE) - -#ifdef __cplusplus -extern "C" { -#endif - -int xsf_start(void *pfile, unsigned bytes); -int xsf_gen(void *pbuffer, unsigned samples); -int xsf_get_lib(char *pfilename, void **ppbuffer, unsigned *plength); -void xsf_term(void); -void xsf_set_extend_param(unsigned dwId, const wchar_t *lpPtr); -extern unsigned long dwChannelMute; -extern unsigned long dwChannelMute; - -#ifdef __cplusplus -} -#endif diff --git a/tools/vio2sf/src/xsfc/foo_input_xsf.cpp b/tools/vio2sf/src/xsfc/foo_input_xsf.cpp deleted file mode 100644 index 192c7fe53..000000000 --- a/tools/vio2sf/src/xsfc/foo_input_xsf.cpp +++ /dev/null @@ -1,732 +0,0 @@ -extern unsigned long dwInterpolation; - -#include "leakchk.h" - -#include "foobar2000/SDK/foobar2000.h" - -#include "../pversion.h" - -#include "../loadpe/loadpe.h" -#include "xsfdrv.h" - -#include "tagget.h" -#include "xsfcfg.h" - -enum -{ - xsf_bits_per_sample = 16, - xsf_channels = 2, -#ifndef XSFDRIVER_SAMPLERATE - xsf_sample_rate = 44100, -#else - xsf_sample_rate = XSFDRIVER_SAMPLERATE, -#endif - - xsf_bytes_per_sample = xsf_bits_per_sample / 8, - xsf_total_sample_width = xsf_bytes_per_sample * xsf_channels, -}; - -#define DEFAULT_BUFFER_SIZE (1024) - -#define CHECK_SILENCE_BIAS 0x8000000 -#ifndef CHECK_SILENCE_LEVEL -#define CHECK_SILENCE_LEVEL 7 -#endif - -typedef signed short xsfsample_t; - -static HMODULE hDLL; - -class xsf_drv -{ -protected: - void *lpDrv; - IXSFDRV *lpif; - pfc::string8 m_libpath; - bool m_genok; - - unsigned detectedSilenceSec; - unsigned detectedSilenceSample; - unsigned skipSilenceOnStartSec; - unsigned long prevSampleL; - unsigned long prevSampleR; - -public: - bool isUTF8; - - xsf_drv() - { - m_genok = false; - isUTF8 = false; - lpDrv = 0; - lpif = 0; - } - - ~xsf_drv() - { - freeDrv(); - } - void setlibpath(pfc::string8 &p_libpath) - { - m_libpath.set_string(p_libpath.get_ptr()); - } - - void start(void *p, DWORD l) - { - if (loadDrv()) - { - if (lpif->dwInterfaceVersion >= 3) - { - lpif->SetExtendParam(1, CFGGetExtendParam1()); - lpif->SetExtendParam(2, CFGGetExtendParam2()); - } - m_genok = !lpif->Start(p, l); - } - - skipSilenceOnStartSec = CFGGetSkipSilenceOnStartSec(); - - detectedSilenceSec = 0; - detectedSilenceSample = 0; - - prevSampleL = CHECK_SILENCE_BIAS; - prevSampleR = CHECK_SILENCE_BIAS; - } - - unsigned long get_detect_silence() - { - return detectedSilenceSec; - } - - int gen(void *pbuf, unsigned bufsize) - { - if (!lpif) return 0; - if (!m_genok) return 0; - - xsfsample_t *ptop = static_cast(pbuf); - unsigned detectSilence = CFGGetDetectSilenceSec(); - unsigned pos = 0; - - if (lpif->dwInterfaceVersion >= 2) - { - bool output = false; - for (int i = 0; i < 4; i++) - { - unsigned long mute = CFGGetChannelMute(i); - output |= (mute != ~unsigned long(0)); - lpif->SetChannelMute(i, mute); - } - if (!output) detectSilence = 0; - } - if (lpif->dwInterfaceVersion >= 4) - { - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_INTERPOLATION,&dwInterpolation); - } - - while (pos < bufsize) - { - unsigned ofs; - xsfsample_t *pblk = ptop + (pos << 1); - unsigned remain = bufsize - pos; - lpif->Gen(pblk, remain); - if (detectSilence || skipSilenceOnStartSec) - { - xsfsample_t *pskp = 0; - xsfsample_t *pcur = pblk; - for (ofs = 0; ofs < remain; ofs++) - { - long smpl = pcur[0]; - long smpr = pcur[1]; - bool silence = (((unsigned long)(smpl + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL)) - prevSampleL <= (CHECK_SILENCE_LEVEL) * 2) && (((unsigned long)(smpr + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL)) - prevSampleR <= (CHECK_SILENCE_LEVEL) * 2); - - if (silence) - { - if (++detectedSilenceSample >= xsf_sample_rate) - { - detectedSilenceSample -= xsf_sample_rate; - detectedSilenceSec++; - if (skipSilenceOnStartSec && detectedSilenceSec >= skipSilenceOnStartSec) - { - skipSilenceOnStartSec = 0; - detectedSilenceSec = 0; - if (pblk != pcur) pskp = pcur; - } - } - } - else - { - detectedSilenceSample = 0; - detectedSilenceSec = 0; - if (skipSilenceOnStartSec) - { - skipSilenceOnStartSec = 0; - if (pblk != pcur) pskp = pcur; - } - } - prevSampleL = smpl + CHECK_SILENCE_BIAS; - prevSampleR = smpr + CHECK_SILENCE_BIAS; - pcur += 2; - } - if (skipSilenceOnStartSec) - { - } - else if (pskp) - { - while (pskp < pcur) - { - *(pblk++)= *(pskp++); - *(pblk++)= *(pskp++); - pos++; - } - } - else - { - pos += remain; - } - } - else - { - pos += remain; - } - } - return bufsize; - } - - - void stop() - { - if (!lpif) return; - lpif->Term(); - m_genok = false; - } - -protected: - bool aogetlib(pfc::string8 &filename, void **ppBuffer, DWORD *pdwSize) - { - try - { - if (!lpif) return false; - service_ptr_t xsflib; - abort_callback_impl abort_cb; - xsfc::TStringM path(true, xsfc::TWin32::CanonicalizePath(xsfc::TString(true, m_libpath.get_ptr()) + xsfc::TString(true, filename.get_ptr()))); - pfc::string8 xsfpath(path.GetM()); - filesystem::g_open_read(xsflib, xsfpath, abort_cb); - DWORD dwfilesize = DWORD(xsflib->get_size_ex(abort_cb)); - void *ret = lpif->LibAlloc(dwfilesize); - if (!ret) return false; - xsflib->read(ret, dwfilesize, abort_cb); - *ppBuffer = ret; - *pdwSize = dwfilesize; - return true; - } catch (xsfc::EShortOfMemory e) { - } catch (exception_io e) { - } - return false; - } - static int PASCAL XSFGETLIBCALLBACK(void *lpWork, LPSTR lpszFilename, void **ppBuffer, DWORD *pdwSize) - { - xsf_drv *pthis = static_cast(lpWork); - pfc::string8 filename; - if (pthis->isUTF8) - { - filename.set_string(static_cast(lpszFilename)); - } - else - { - pfc::stringcvt::string_utf8_from_ansi valuea(static_cast(lpszFilename)); - filename.set_string(valuea.get_ptr()); - } - return pthis->aogetlib(filename, ppBuffer, pdwSize) ? 0 : 1; - } - bool loadDrv(void) - { - if (lpif) return true; - pfc::string8 dllpath; - uGetModuleFileName(hDLL, dllpath); - pfc::string8 binpath(dllpath, pfc::scan_filename(dllpath)); - binpath.add_string(XSFDRIVER_MODULENAME); - - if (xsfc::TWin32::IsUnicodeSupportedOS()) - { - pfc::stringcvt::string_wide_from_utf8 dllpathw(binpath); - lpDrv = XLoadLibraryW(dllpathw.get_ptr()); - } - else - { - pfc::stringcvt::string_ansi_from_utf8 dllpatha(binpath); - lpDrv = XLoadLibraryA(dllpatha.get_ptr()); - } - if (!lpDrv) return false; - - LPFNXSFDRVSETUP xsfsetup = (LPFNXSFDRVSETUP)XGetProcAddress(lpDrv, XSFDRIVER_ENTRYNAME); - if (!xsfsetup) - { - XFreeLibrary(lpDrv); - lpDrv = 0; - return false; - } - - lpif = xsfsetup(XSFGETLIBCALLBACK, this); - return true; - } - - void freeDrv(void) - { - if (lpif) - { - lpif->Term(); - lpif = 0; - } - if (lpDrv) - { - XFreeLibrary(lpDrv); - lpDrv = 0; - } - } -}; - -class input_xsf -{ -protected: - xsf_drv drv; - pfc::array_t m_filebuffer; - foobar2000_io::t_filesize m_filesize; - t_uint64 cur_smp; - t_uint64 len_smp; - t_uint64 fad_smp; - t_uint64 end_smp; - - service_ptr_t m_file; - pfc::array_t m_buffer; - - double m_volume; - bool m_hasvolume; - bool m_haslength; - - bool m_write_UTF8; - unsigned m_flags; - - typedef struct - { - class input_xsf *pThis; - file_info * p_info; - bool isUTF8; - } tagloadcbwork; - - void tagloadsub(file_info & p_info, pfc::string8 &name, pfc::string8 &value) - { - if (!stricmp_utf8(name.get_ptr(), "game")) - p_info.meta_add("album", value.get_ptr()); - else if (!stricmp_utf8(name.get_ptr(), "year")) - p_info.meta_add("date", value.get_ptr()); - else if (!_strnicmp(name.get_ptr(), "_lib", 4) || !stricmp_utf8(name.get_ptr(), "fade") || !stricmp_utf8(name.get_ptr(), "length") || !stricmp_utf8(name.get_ptr(), "volume")) - p_info.info_set(name.get_ptr(), value.get_ptr()); - else if (!stricmp_utf8(name.get_ptr(), "replaygain_track_gain")) - { - replaygain_info rg = p_info.get_replaygain(); - rg.set_track_gain_text(value.get_ptr()); - p_info.set_replaygain(rg); - } - else if (!stricmp_utf8(name.get_ptr(), "replaygain_track_peak")) - { - replaygain_info rg = p_info.get_replaygain(); - rg.set_track_peak_text(value.get_ptr()); - p_info.set_replaygain(rg); - } - else if (!stricmp_utf8(name.get_ptr(), "replaygain_album_gain")) - { - replaygain_info rg = p_info.get_replaygain(); - rg.set_album_gain_text(value.get_ptr()); - p_info.set_replaygain(rg); - } - else if (!stricmp_utf8(name.get_ptr(), "replaygain_album_peak")) - { - replaygain_info rg = p_info.get_replaygain(); - rg.set_album_peak_text(value.get_ptr()); - p_info.set_replaygain(rg); - } - else - p_info.meta_add(name.get_ptr(), value.get_ptr()); - } - - static enum XSFTag::enum_callback_returnvalue tagloadcb(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - if (pNameTop == pNameEnd) return XSFTag::enum_continue; - - tagloadcbwork *pcbwork = static_cast(pWork); - - pfc::string8 name; - name.set_string(pNameTop, pNameEnd - pNameTop); - - pfc::string8 value; - if (pcbwork->isUTF8) - { - value.set_string(pValueTop, pValueEnd - pValueTop); - } - else - { - pfc::stringcvt::string_utf8_from_ansi valuea(pValueTop, pValueEnd - pValueTop); - value.set_string(valuea.get_ptr()); - } - - pcbwork->pThis->tagloadsub(*pcbwork->p_info, name, value); - return XSFTag::enum_continue; - } - - void tagload(file_info & p_info) - { - BYTE *pData = m_filebuffer.get_ptr(); - DWORD dwSize = DWORD(m_filesize); - bool isUTF8 = XSFTag::Exists("utf8", pData, dwSize); - drv.isUTF8 = isUTF8; - - tagloadcbwork cbwork; - cbwork.isUTF8 = isUTF8; - cbwork.pThis = this; - cbwork.p_info= &p_info; - XSFTag::Enum(tagloadcb, &cbwork, pData, dwSize); - return; - } - - void tagsave(const file_info & p_info, abort_callback & p_abort) - { - BYTE *pData = m_filebuffer.get_ptr(); - DWORD dwSize = DWORD(m_filesize); - - DWORD dwPos = XSFTag::SearchRaw(pData, dwSize); - if (!dwPos || dwPos >= dwSize) return; - - m_file->truncate(dwPos, p_abort); - m_file->seek(dwPos, p_abort); - - m_write_UTF8 = p_info.meta_exists("utf8"); - - tag_write("[TAG]", p_abort); - if (m_write_UTF8) - tag_writel("utf8=1\x0a", p_abort); - - /* write play info */ - t_size icnt = p_info.info_get_count(); - for (t_size i = 0; i < icnt; i++) - { - const char *name = p_info.info_enum_name(i); - if (!_strnicmp(name, "_lib", 4) || !stricmp_utf8(name, "fade") || !stricmp_utf8(name, "length") || !stricmp_utf8(name, "volume")) - { - const char *value = p_info.info_enum_value(i); - if (*value) - { - tag_writel(name, p_abort); - tag_writel("=", p_abort); - tag_write(value, p_abort); - tag_writel("\x0a", p_abort); - } - } - } - - /* write meta data */ - t_size mcnt = p_info.meta_get_count(); - for (t_size m = 0; m < mcnt; m++) - { - const char *name = p_info.meta_enum_name(m); - if (!stricmp_utf8(name, "utf8")) - continue; - else if (!stricmp_utf8(name, "album")) - name = "game"; - else if (!stricmp_utf8(name, "date")) - name = "year"; - t_size ncnt = p_info.meta_enum_value_count(m); - for (t_size n = 0; n < ncnt; n++) - { - const char *value = p_info.meta_enum_value(m, n); - if (*value) - { - tag_writel(name, p_abort); - tag_writel("=", p_abort); - tag_write(value, p_abort); - tag_writel("\x0a", p_abort); - } - } - } - - /* write replay gain */ - pfc::array_t rgbuf; - replaygain_info rg = p_info.get_replaygain(); - rgbuf.set_size(rg.text_buffer_size); - - if (rg.m_album_gain > rg.gain_invalid) - { - rg.format_album_gain(rgbuf.get_ptr()); - tag_writel("replaygain_album_gain", p_abort); - tag_writel("=", p_abort); - tag_write(rgbuf.get_ptr(), p_abort); - tag_writel("\x0a", p_abort); - } - if (rg.m_album_peak > rg.peak_invalid) - { - rg.format_album_peak(rgbuf.get_ptr()); - tag_writel("replaygain_album_peak", p_abort); - tag_writel("=", p_abort); - tag_write(rgbuf.get_ptr(), p_abort); - tag_writel("\x0a", p_abort); - } - if (rg.m_track_gain > rg.gain_invalid) - { - rg.format_track_gain(rgbuf.get_ptr()); - tag_writel("replaygain_track_gain", p_abort); - tag_writel("=", p_abort); - tag_write(rgbuf.get_ptr(), p_abort); - tag_writel("\x0a", p_abort); - } - if (rg.m_track_peak > rg.peak_invalid) - { - rg.format_track_peak(rgbuf.get_ptr()); - tag_writel("replaygain_track_peak", p_abort); - tag_writel("=", p_abort); - tag_write(rgbuf.get_ptr(), p_abort); - tag_writel("\x0a", p_abort); - } - m_file->set_eof(p_abort); - } - - void tag_writel(const char *p, abort_callback & p_abort) - { - t_size l = strlen(p); - pfc::array_t lbuf; - lbuf.set_size(l); - char *d = lbuf.get_ptr(); - for (t_size i = 0; i < l; i++) - d[i] = pfc::ascii_tolower(p[i]); - m_file->write(d, l, p_abort); - } - - void tag_writeA(const char *p, t_size l, abort_callback & p_abort) - { - pfc::stringcvt::string_ansi_from_utf8 valuea(p, l); - m_file->write(valuea.get_ptr(), valuea.length(), p_abort); - } - - void tag_write(const char *p, abort_callback & p_abort) - { - t_size l = strlen(p); - pfc::array_t lbuf; - lbuf.set_size(l); - char *d = lbuf.get_ptr(); - for (t_size i = 0; i < l; i++) - { - if (p[i] == 0x0a) - d[i] = ';'; - else if (p[i] > 0x00 && p[i] < 0x20) - d[i] = ' '; - else - d[i] = p[i]; - } - if (m_write_UTF8) - m_file->write(d, l, p_abort); - else - tag_writeA(d, l, p_abort); - } - - void xsf_restart() - { - drv.start(m_filebuffer.get_ptr(), DWORD(m_filebuffer.get_size())); - cur_smp = 0; - } - - void xsf_reopen(service_ptr_t & p_file, abort_callback & p_abort) - { - m_filesize = p_file->get_size_ex(p_abort); - m_filebuffer.set_size(t_size(m_filesize)); - p_file->read(m_filebuffer.get_ptr(), t_size(m_filesize), p_abort); - xsf_reload(); - } - - void xsf_reload(void) - { - xsfc::TString tagvolume = XSFTag::Get("volume", m_filebuffer.get_ptr(), size_t(m_filesize)); - - t_uint32 length = XSFTag::GetLengthMS(m_filebuffer.get_ptr(), size_t(m_filesize), CFGGetDefaultLength()); - t_uint32 fade = XSFTag::GetFadeMS(m_filebuffer.get_ptr(), size_t(m_filesize), CFGGetDefaultFade()); - - m_haslength = XSFTag::Exists("length", m_filebuffer.get_ptr(), size_t(m_filesize)); - - m_volume = 1.0; - m_hasvolume = false; - if (tagvolume[0]) - { - m_volume = tagvolume.GetFloat(); - m_hasvolume = (m_volume != 1.0); - } - - len_smp = t_uint64(length) * xsf_sample_rate / 1000; - fad_smp = t_uint64(fade) * xsf_sample_rate / 1000; - end_smp = len_smp + fad_smp; - } - - void xsf_seek(t_uint64 &seek_smp, abort_callback & p_abort) - { - t_size bufsize = m_buffer.get_size() / xsf_total_sample_width; - if (bufsize < xsf_total_sample_width) - { - bufsize = DEFAULT_BUFFER_SIZE; - m_buffer.set_size(bufsize * xsf_total_sample_width); - } - if (seek_smp < cur_smp) - { - xsf_restart(); - } - while (seek_smp - cur_smp > bufsize) - { - if (p_abort.is_aborting()) - return; - drv.gen(m_buffer.get_ptr(), DWORD(bufsize)); - cur_smp += bufsize; - } - if (seek_smp - cur_smp > 0) - { - drv.gen(m_buffer.get_ptr(), DWORD(seek_smp - cur_smp)); - cur_smp = seek_smp; - } - } - -public: - void open(service_ptr_t p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) - { - - m_file = p_filehint;//p_filehint may be null, hence next line - input_open_file_helper(m_file,p_path,p_reason,p_abort);//if m_file is null, opens file with appropriate privileges for our operation (read/write for writing tags, read-only otherwise). - - pfc::string8 libpath(p_path, pfc::scan_filename(p_path)); - drv.setlibpath(libpath); - - xsf_reopen(m_file, p_abort); - - if (p_reason == input_open_decode) - xsf_restart(); - } - - void get_info(file_info & p_info,abort_callback & p_abort) - { - (void)p_abort; - p_info.set_length(audio_math::samples_to_time( end_smp, xsf_sample_rate)); - - p_info.info_set_int("samplerate",xsf_sample_rate); - p_info.info_set_int("channels",xsf_channels); - p_info.info_set_int("bitspersample",xsf_bits_per_sample); - p_info.info_set("encoding",FOOBAR2000COMPONENT_ENCODING); - p_info.info_set_bitrate((xsf_bits_per_sample * xsf_channels * xsf_sample_rate + 500 /* rounding for bps to kbps*/ ) / 1000 /* bps to kbps */); - - tagload(p_info); - } - t_filestats get_file_stats(abort_callback & p_abort) {return m_file->get_stats(p_abort);} - - void decode_initialize(unsigned p_flags,abort_callback & p_abort) - { - (void)p_abort; - m_flags = p_flags; - } - - bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) - { - (void)p_abort; - bool fPlayInfinitely = CFGGetPlayInfinitely() && !(m_flags & input_flag_no_looping) && (m_flags & input_flag_playback); - - if ((cur_smp >= end_smp && !fPlayInfinitely) || (!m_haslength && CFGGetDetectSilenceSec() && CFGGetDetectSilenceSec() <= drv.get_detect_silence())) - { - return false; - } - m_buffer.set_size(DEFAULT_BUFFER_SIZE * xsf_total_sample_width); - t_size bufsize = m_buffer.get_size() / xsf_total_sample_width; - drv.gen(m_buffer.get_ptr(), DWORD(bufsize)); - - if (!fPlayInfinitely && cur_smp + bufsize > end_smp) - bufsize = t_size(end_smp - cur_smp); - - cur_smp += bufsize; - - p_chunk.set_data_fixedpoint(m_buffer.get_ptr(),bufsize * xsf_total_sample_width,xsf_sample_rate,xsf_channels,xsf_bits_per_sample,audio_chunk::g_guess_channel_config(xsf_channels)); - - double cfgvolume = 1; - bool hascfgvolume = (m_flags & input_flag_playback) && CFGGetVolume(cfgvolume); - if (hascfgvolume || m_hasvolume || (!fPlayInfinitely && (fad_smp && cur_smp + bufsize >= len_smp))) - { - audio_sample *psmp = p_chunk.get_data(); - t_uint64 i; - double volume = m_volume * cfgvolume; - for (i = cur_smp; i < cur_smp + bufsize; i++) - { - if (fPlayInfinitely || i < len_smp) - { - psmp[0] = float(psmp[0] * volume); - psmp[1] = float(psmp[1] * volume); - } - else if (i < end_smp) - { - double scale = volume * double(len_smp + fad_smp - i) / double(fad_smp); - psmp[0] = float(psmp[0] * scale); - psmp[1] = float(psmp[1] * scale); - } - else - { - psmp[0] = 0; - psmp[1] = 0; - } - psmp += 2; - } - } - - return true; - } - void decode_seek(double p_seconds,abort_callback & p_abort) - { - if (!decode_can_seek()) - { - throw exception_io_object_not_seekable(); - } - else - { - t_uint64 seek_pos(t_uint64(p_seconds * xsf_sample_rate)); - xsf_seek(seek_pos, p_abort); - } - } - bool decode_can_seek() {return true;} - bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) { (void)p_out, p_timestamp_delta; return false; } - bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) { (void)p_out, p_timestamp_delta; return false; } - void decode_on_idle(abort_callback & p_abort) { m_file->on_idle(p_abort); } - - void retag(const file_info & p_info,abort_callback & p_abort) - { - tagsave(p_info, p_abort); - - m_file->reopen(p_abort); - xsf_reopen(m_file, p_abort); - } - - static bool g_is_our_content_type(const char * p_content_type) { (void)p_content_type; return false;} - static bool g_is_our_path(const char * p_path,const char * p_extension) { (void)p_path, p_extension; return FOOBAR2000COMPONENT_EXT_CHECK; } -}; - - -static input_singletrack_factory_t g_input_xsf_factory; - -DECLARE_COMPONENT_VERSION(FOOBAR2000COMPONENT_NAME,FOOBAR2000COMPONENT_VERSION,FOOBAR2000COMPONENT_ABOUT); -DECLARE_FILE_TYPE(FOOBAR2000COMPONENT_TYPE,FOOBAR2000COMPONENT_EXTS); - -extern "C" void fb2k_config_init(HINSTANCE hinstDLL); - -BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - if (ul_reason_for_call == DLL_PROCESS_ATTACH) - { -#if defined(_MSC_VER) && defined(_DEBUG) - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF); -#endif - hDLL = hModule; - fb2k_config_init(hDLL); - } - else if (ul_reason_for_call == DLL_PROCESS_DETACH) - { - } - return TRUE; -} - - - diff --git a/tools/vio2sf/src/xsfc/foo_input_xsf8.cpp b/tools/vio2sf/src/xsfc/foo_input_xsf8.cpp deleted file mode 100644 index dc6c6982b..000000000 --- a/tools/vio2sf/src/xsfc/foo_input_xsf8.cpp +++ /dev/null @@ -1,715 +0,0 @@ -extern unsigned long dwInterpolation; - -#include "foobar2000/SDK/foobar2000.h" - -#include "../pversion.h" - -#include "../loadpe/loadpe.h" -#include "xsfdrv.h" - -#include "tagget.h" -#include "xsfcfg.h" - -enum -{ - xsf_bits_per_sample = 16, - xsf_channels = 2, -#ifndef XSFDRIVER_SAMPLERATE - xsf_sample_rate = 44100, -#else - xsf_sample_rate = XSFDRIVER_SAMPLERATE, -#endif - - xsf_bytes_per_sample = xsf_bits_per_sample / 8, - xsf_total_sample_width = xsf_bytes_per_sample * xsf_channels -}; - -#define DEFAULT_BUFFER_SIZE (1024) - -#define CHECK_SILENCE_BIAS 0x8000000 -#ifndef CHECK_SILENCE_LEVEL -#define CHECK_SILENCE_LEVEL 7 -#endif - -typedef signed short xsfsample_t; - -static HMODULE hDLL; - -class ReaderHolder -{ - void Free() - { - if (ptr) - { - ptr->reader_release(); - ptr = 0; - } - } -public: - reader *ptr; - ReaderHolder(reader *p = 0) - : ptr(p) - { - } - ~ReaderHolder() - { - Free(); - } - reader *GetReader() - { - return ptr; - } - void SetReader(reader * p) - { - Free(); - ptr = p; - } - bool Open(const xsfc::TString &fn) - { - SetReader(file::g_open(xsfc::TStringM(true, fn), reader::MODE_READ)); - return ptr != 0; - } -}; - -class xsf_drv -{ -protected: - void *lpDrv; - IXSFDRV *lpif; - xsfc::TString m_libpath; - bool m_genok; - - unsigned detectedSilenceSec; - unsigned detectedSilenceSample; - unsigned skipSilenceOnStartSec; - unsigned long prevSampleL; - unsigned long prevSampleR; - -public: - bool isUTF8; - - xsf_drv() - { - m_genok = false; - isUTF8 = false; - lpDrv = 0; - lpif = 0; - } - - ~xsf_drv() - { - freeDrv(); - } - void setlibpath(const xsfc::TString &p_libpath) - { - m_libpath = p_libpath; - } - - void start(void *p, DWORD l) - { - if (loadDrv()) - { - if (lpif->dwInterfaceVersion >= 3) - { - lpif->SetExtendParam(1, CFGGetExtendParam1()); - lpif->SetExtendParam(2, CFGGetExtendParam2()); - } - m_genok = !lpif->Start(p, l); - } - - skipSilenceOnStartSec = CFGGetSkipSilenceOnStartSec(); - - detectedSilenceSec = 0; - detectedSilenceSample = 0; - - prevSampleL = CHECK_SILENCE_BIAS; - prevSampleR = CHECK_SILENCE_BIAS; - } - - unsigned long get_detect_silence() - { - return detectedSilenceSec; - } - - int gen(void *pbuf, unsigned bufsize) - { - if (!lpif) return 0; - if (!m_genok) return 0; - - xsfsample_t *ptop = static_cast(pbuf); - unsigned detectSilence = CFGGetDetectSilenceSec(); - unsigned pos = 0; - - if (lpif->dwInterfaceVersion >= 2) - { - bool output = false; - for (int i = 0; i < 4; i++) - { - unsigned long mute = CFGGetChannelMute(i); - output |= (mute != ~unsigned long(0)); - lpif->SetChannelMute(i, mute); - } - if (!output) detectSilence = 0; - } - if (lpif->dwInterfaceVersion >= 4) - { - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_INTERPOLATION,&dwInterpolation); - } - - while (pos < bufsize) - { - unsigned ofs; - xsfsample_t *pblk = ptop + (pos << 1); - unsigned remain = bufsize - pos; - lpif->Gen(pblk, remain); - if (detectSilence || skipSilenceOnStartSec) - { - xsfsample_t *pskp = 0; - xsfsample_t *pcur = pblk; - for (ofs = 0; ofs < remain; ofs++) - { - long smpl = pcur[0]; - long smpr = pcur[1]; - bool silence = (((unsigned long)(smpl + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL)) - prevSampleL <= (CHECK_SILENCE_LEVEL) * 2) && (((unsigned long)(smpr + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL)) - prevSampleR <= (CHECK_SILENCE_LEVEL) * 2); - - if (silence) - { - if (++detectedSilenceSample >= xsf_sample_rate) - { - detectedSilenceSample -= xsf_sample_rate; - detectedSilenceSec++; - if (skipSilenceOnStartSec && detectedSilenceSec >= skipSilenceOnStartSec) - { - skipSilenceOnStartSec = 0; - detectedSilenceSec = 0; - if (pblk != pcur) pskp = pcur; - } - } - } - else - { - detectedSilenceSample = 0; - detectedSilenceSec = 0; - if (skipSilenceOnStartSec) - { - skipSilenceOnStartSec = 0; - if (pblk != pcur) pskp = pcur; - } - } - prevSampleL = smpl + CHECK_SILENCE_BIAS; - prevSampleR = smpr + CHECK_SILENCE_BIAS; - pcur += 2; - } - if (skipSilenceOnStartSec) - { - } - else if (pskp) - { - while (pskp < pcur) - { - *(pblk++)= *(pskp++); - *(pblk++)= *(pskp++); - pos++; - } - } - else - { - pos += remain; - } - } - else - { - pos += remain; - } - } - return bufsize; - } - - - void stop() - { - if (!lpif) return; - lpif->Term(); - m_genok = false; - } - - -protected: - bool aogetlib(xsfc::TString filename, void **ppBuffer, DWORD *pdwSize) - { - if (!lpif) return false; - ReaderHolder xsflib; - xsfc::TString path = xsfc::TWin32::CanonicalizePath(m_libpath + filename); - if (!xsflib.Open(path)) return false; - __int64 filesize64 = xsflib.GetReader()->get_length(); - DWORD dwfilesize = DWORD(filesize64); - if (filesize64 == -1 || filesize64 != dwfilesize) return false; - void *ret = lpif->LibAlloc(dwfilesize); - if (!ret) return false; - xsflib.GetReader()->read(ret, dwfilesize); - *ppBuffer = ret; - *pdwSize = dwfilesize; - return true; - } - static int PASCAL XSFGETLIBCALLBACK(void *lpWork, LPSTR lpszFilename, void **ppBuffer, DWORD *pdwSize) - { - xsf_drv *pthis = static_cast(lpWork); - xsfc::TString filename; - if (pthis->isUTF8) - { - filename = xsfc::TString(true, lpszFilename); - } - else - { - filename = xsfc::TString(false, lpszFilename); - } - return pthis->aogetlib(filename, ppBuffer, pdwSize) ? 0 : 1; - } - bool loadDrv(void) - { - if (lpif) return true; - xsfc::TString binpath = xsfc::TWin32::ExtractPath(xsfc::TWin32::ModulePath(hDLL)) + XSFDRIVER_MODULENAME; - - if (xsfc::TWin32::IsUnicodeSupportedOS()) - { - lpDrv = XLoadLibraryW(binpath); - } - else - { - lpDrv = XLoadLibraryA(xsfc::TStringM(binpath)); - } - if (!lpDrv) return false; - - LPFNXSFDRVSETUP xsfsetup = (LPFNXSFDRVSETUP)XGetProcAddress(lpDrv, XSFDRIVER_ENTRYNAME); - if (!xsfsetup) - { - XFreeLibrary(lpDrv); - lpDrv = 0; - return false; - } - - lpif = xsfsetup(XSFGETLIBCALLBACK, this); - return true; - } - - void freeDrv(void) - { - if (lpif) - { - lpif->Term(); - lpif = 0; - } - if (lpDrv) - { - XFreeLibrary(lpDrv); - lpDrv = 0; - } - } -}; - -class input_xsf : public input_pcm -{ -protected: - typedef signed short audio_sample_t; - typedef __int64 t_size; - typedef unsigned __int64 t_uint64; - xsf_drv drv; - array_t m_filebuffer; - t_size m_filesize; - t_uint64 cur_smp; - t_uint64 len_smp; - t_uint64 fad_smp; - t_uint64 end_smp; - - array_t m_buffer; - - double m_volume; - bool m_hasvolume; - bool m_haslength; - - bool m_write_UTF8; - unsigned m_flags; - - typedef struct - { - class input_xsf *pThis; - file_info * p_info; - bool isUTF8; - } tagloadcbwork; - - void tagloadsub(file_info & p_info, const char *name, const xsfc::TStringM &value) - { - if (!stricmp_utf8(name, "game")) - p_info.meta_add("album", value); - else if (!stricmp_utf8(name, "year")) - p_info.meta_add("date", value); - else if (!_strnicmp(name, "_lib", 4) || !stricmp_utf8(name, "fade") || !stricmp_utf8(name, "length") || !stricmp_utf8(name, "volume")) - p_info.info_set(name, value); - else if (!stricmp_utf8(name, "replaygain_track_gain")) - { - p_info.info_set_replaygain_track_gain(pfc_string_to_float(value)); - } - else if (!stricmp_utf8(name, "replaygain_track_peak")) - { - p_info.info_set_replaygain_track_peak(pfc_string_to_float(value)); - } - else if (!stricmp_utf8(name, "replaygain_album_gain")) - { - p_info.info_set_replaygain_album_gain(pfc_string_to_float(value)); - } - else if (!stricmp_utf8(name, "replaygain_album_peak")) - { - p_info.info_set_replaygain_album_peak(pfc_string_to_float(value)); - } - else - p_info.meta_add(name, value); - } - - static enum XSFTag::enum_callback_returnvalue tagloadcb(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - if (pNameTop == pNameEnd) return XSFTag::enum_continue; - - tagloadcbwork *pcbwork = static_cast(pWork); - - xsfc::TString name; - xsfc::TString value; - - if (pcbwork->isUTF8) - { - name = xsfc::TString(true, pNameTop, pNameEnd - pNameTop); - value = xsfc::TString(true, pValueTop, pValueEnd - pValueTop); - } - else - { - name = xsfc::TString(false, pNameTop, pNameEnd - pNameTop); - value = xsfc::TString(false, pValueTop, pValueEnd - pValueTop); - } - - pcbwork->pThis->tagloadsub(*pcbwork->p_info, xsfc::TStringM(true, name), xsfc::TStringM(true, value)); - return XSFTag::enum_continue; - } - - void tagload(file_info & p_info) - { - BYTE *pData = &m_filebuffer[0]; - DWORD dwSize = DWORD(m_filesize); - bool isUTF8 = XSFTag::Exists("utf8", pData, dwSize); - drv.isUTF8 = isUTF8; - - tagloadcbwork cbwork; - cbwork.isUTF8 = isUTF8; - cbwork.pThis = this; - cbwork.p_info= &p_info; - XSFTag::Enum(tagloadcb, &cbwork, pData, dwSize); - return; - } - - bool tag_writel(const char *p, reader *r) - { - string8 value; - value.convert_to_lower_ascii(p); - const char *pL = value.get_ptr(); - t_size lL = strlen(p); - return r->write(pL, lL) == lL; - } - - bool tag_writeA(const char *p, t_size l, reader *r) - { - xsfc::TString value(true, p, l); - xsfc::TStringM valueA(false, value); - const char *pA = valueA; - t_size lA = strlen(pA); - return r->write(pA, lA) == lA; - } - - bool tag_writeU(const char *p, t_size l, reader *r) - { - return r->write(p, l) == l; - } - - bool tag_write(const char *p, reader *r) - { - t_size l = strlen(p); - array_t lbuf; - if (!lbuf.resize(l)) return false; - char *d = &lbuf[0]; - for (t_size i = 0; i < l; i++) - { - if (p[i] == 0x0a) - d[i] = ';'; - else if (p[i] > 0x00 && p[i] < 0x20) - d[i] = ' '; - else - d[i] = p[i]; - } - return (m_write_UTF8) ? tag_writeU(d, l, r) : tag_writeA(d, l, r); - } - - bool tagsave(reader *r, const file_info & p_info) - { - BYTE *pData = &m_filebuffer[0]; - DWORD dwSize = DWORD(m_filesize); - - DWORD dwPos = XSFTag::SearchRaw(pData, dwSize); - if (!dwPos || dwPos >= dwSize) return false; - - if (!r->seek(dwPos)) return false; - - m_write_UTF8 = p_info.meta_get_count_by_name("utf8") > 0; - - tag_write("[TAG]", r); - if (m_write_UTF8) - tag_writel("utf8=1\x0a", r); - - /* write play info */ - t_size icnt = p_info.info_get_count(); - for (t_size i = 0; i < icnt; i++) - { - const char *name = p_info.info_enum_name(i); - if (!_strnicmp(name, "_lib", 4) || !stricmp_utf8(name, "fade") || !stricmp_utf8(name, "length") || !stricmp_utf8(name, "volume") || !stricmp_utf8(name, "replaygain_album_gain") || !stricmp_utf8(name, "replaygain_album_peak") || !stricmp_utf8(name, "replaygain_track_gain") || !stricmp_utf8(name, "replaygain_track_peak")) - { - const char *value = p_info.info_enum_value(i); - if (*value) - { - tag_writel(name, r); - tag_writel("=", r); - tag_write(value, r); - tag_writel("\x0a", r); - } - } - } - - /* write meta data */ - t_size mcnt = p_info.meta_get_count(); - for (t_size m = 0; m < mcnt; m++) - { - const char *name = p_info.meta_enum_name(m); - if (!stricmp_utf8(name, "utf8")) - continue; - else if (!stricmp_utf8(name, "album")) - name = "game"; - else if (!stricmp_utf8(name, "date")) - name = "year"; - const char *value = p_info.meta_enum_value(m); - if (*value) - { - tag_writel(name, r); - tag_writel("=", r); - tag_write(value, r); - tag_writel("\x0a", r); - } - } - - r->set_eof(); - return true; - } - - void xsf_restart() - { - drv.start(&m_filebuffer[0], DWORD(m_filebuffer.size())); - cur_smp = 0; - } - - bool xsf_reopen(reader *r) - { - m_filesize = r->get_length(); - t_size l = t_size(m_filesize); - if (!m_filebuffer.resize(t_size(m_filesize))) return false; - return r->read(&m_filebuffer[0], l) == l; - } - - void xsf_reload(void) - { - xsfc::TString tagvolume = XSFTag::Get("volume", &m_filebuffer[0], size_t(m_filesize)) ; - - unsigned length = XSFTag::GetLengthMS(&m_filebuffer[0], size_t(m_filesize), CFGGetDefaultLength()); - unsigned fade = XSFTag::GetFadeMS(&m_filebuffer[0], size_t(m_filesize), CFGGetDefaultFade()); - - m_haslength = XSFTag::Exists("length", &m_filebuffer[0], size_t(m_filesize)); - - m_volume = 1.0; - m_hasvolume = false; - if (tagvolume[0]) - { - m_volume = tagvolume.GetFloat(); - m_hasvolume = (m_volume != 1.0); - } - - len_smp = t_uint64(length) * xsf_sample_rate / 1000; - fad_smp = t_uint64(fade) * xsf_sample_rate / 1000; - end_smp = len_smp + fad_smp; - } - - void xsf_seek(t_uint64 &seek_smp) - { - t_size bufsize = m_buffer.size() / xsf_total_sample_width; - if (bufsize < xsf_total_sample_width) - { - bufsize = DEFAULT_BUFFER_SIZE; - m_buffer.resize(bufsize * xsf_total_sample_width); - } - if (seek_smp < cur_smp) - { - xsf_restart(); - } - while (seek_smp - cur_smp > bufsize) - { - drv.gen(&m_buffer[0], DWORD(bufsize)); - cur_smp += bufsize; - } - if (seek_smp - cur_smp > 0) - { - drv.gen(&m_buffer[0], DWORD(seek_smp - cur_smp)); - cur_smp = seek_smp; - } - } - -public: - void get_info(file_info & p_info) - { - p_info.set_length(::MulDiv(end_smp, 1, xsf_sample_rate)); - - p_info.info_set_int("samplerate",xsf_sample_rate); - p_info.info_set_int("channels",xsf_channels); - p_info.info_set_int("bitspersample",xsf_bits_per_sample); - p_info.info_set("encoding",FOOBAR2000COMPONENT_ENCODING); - p_info.info_set_bitrate((xsf_bits_per_sample * xsf_channels * xsf_sample_rate + 500 /* rounding for bps to kbps*/ ) / 1000 /* bps to kbps */); - - tagload(p_info); - } - - bool open(reader * r,file_info * info,unsigned flags) - { - m_flags = flags; - xsf_reopen(r); - xsf_reload(); - - if( flags & input::OPEN_FLAG_GET_INFO) - get_info(*info); - - if (flags & input::OPEN_FLAG_DECODE) - { - const char *playpathutf8 = info->get_file_path(); - xsfc::TString playpath(true, playpathutf8); - xsfc::TString libpath = xsfc::TWin32::ExtractPath(playpath); - drv.setlibpath(libpath); - xsf_restart(); - } - return true; - } - - inline audio_sample_t clip_mul(signed s1, double s2) - { - double r = s1 * s2; - if (r > 0x7fff) - r = 0x7fff; - else if (r < -0x8000) - r = -0x8000; - return audio_sample_t(r); - } - - int get_samples_pcm(void ** out_buffer,int * out_size, int * srate, int * bps, int * nch) - { - bool fPlayInfinitely = CFGGetPlayInfinitely() && !(m_flags & OPEN_FLAG_NO_LOOPING); - - if ((cur_smp >= end_smp && !fPlayInfinitely) || (!m_haslength && CFGGetDetectSilenceSec() && CFGGetDetectSilenceSec() <= drv.get_detect_silence())) - { - return false; - } - unsigned reqssize = DEFAULT_BUFFER_SIZE * xsf_total_sample_width; - if (m_buffer.size() < reqssize && !m_buffer.resize(reqssize)) - return false; - - t_size bufsize = m_buffer.size() / xsf_total_sample_width; - drv.gen(&m_buffer[0], DWORD(bufsize)); - - if (!fPlayInfinitely && cur_smp + bufsize > end_smp) - bufsize = t_size(end_smp - cur_smp); - - *out_buffer = &m_buffer[0]; - *out_size = bufsize * xsf_total_sample_width; - *srate = xsf_sample_rate; - *bps = xsf_bits_per_sample; - *nch = xsf_channels; - - cur_smp += bufsize; - - double cfgvolume = 1; - bool hascfgvolume = CFGGetVolume(cfgvolume); - if (hascfgvolume || m_hasvolume || (!fPlayInfinitely && (fad_smp && cur_smp + bufsize >= len_smp))) - { - audio_sample_t *psmp = (audio_sample_t *)&m_buffer[0]; - t_uint64 i; - double volume = m_volume * cfgvolume; - for (i = cur_smp; i < cur_smp + bufsize; i++) - { - if (fPlayInfinitely || i < len_smp) - { - psmp[0] = clip_mul(psmp[0] , volume); - psmp[1] = clip_mul(psmp[1] , volume); - } - else if (i < end_smp) - { - double scale = volume * double(__int64(len_smp + fad_smp - i)) / double(__int64(fad_smp)); - psmp[0] = clip_mul(psmp[0] , scale); - psmp[1] = clip_mul(psmp[1] , scale); - } - else - { - psmp[0] = 0; - psmp[1] = 0; - } - psmp += 2; - } - } - - return true; - } - - bool can_seek() {return true;} - - bool seek(double p_seconds) - { - if (can_seek()) - { - t_uint64 seek_pos(t_uint64(p_seconds * xsf_sample_rate)); - xsf_seek(seek_pos); - return true; - } - return false; - } - - bool is_our_content_type(const char * url,const char * type) { (void)url, type; return false;} - bool test_filename(const char * p_path,const char * p_extension) { (void)p_path, p_extension; return FOOBAR2000COMPONENT_EXT_CHECK; } - - set_info_t set_info(reader *r, const file_info * info) - { - xsf_reopen(r); - return tagsave(r, *info) ? SET_INFO_SUCCESS : SET_INFO_FAILURE; - } - -}; - - -static input_factory g_input_xsf_factory; - -DECLARE_COMPONENT_VERSION(FOOBAR2000COMPONENT_NAME,FOOBAR2000COMPONENT_VERSION,FOOBAR2000COMPONENT_ABOUT); -DECLARE_FILE_TYPE(FOOBAR2000COMPONENT_TYPE,FOOBAR2000COMPONENT_EXTS); - -extern "C" void fb2k_config_init(HINSTANCE hinstDLL); - -BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - if (ul_reason_for_call == DLL_PROCESS_ATTACH) - { - hDLL = hModule; - fb2k_config_init(hDLL); - } - else if (ul_reason_for_call == DLL_PROCESS_DETACH) - { - } - return TRUE; -} - - - diff --git a/tools/vio2sf/src/xsfc/foo_input_xsfcfg.cpp b/tools/vio2sf/src/xsfc/foo_input_xsfcfg.cpp deleted file mode 100644 index 5fd0af821..000000000 --- a/tools/vio2sf/src/xsfc/foo_input_xsfcfg.cpp +++ /dev/null @@ -1,278 +0,0 @@ -#include "leakchk.h" - -#include "foobar2000/SDK/foobar2000.h" - -#include "../pversion.h" - -#include "tagget.h" -#include "xsfcfg.h" - -#include "xsfui.rh" - -namespace -{ - -HMODULE hDLL; - -const GUID cfgguid1 = XSFDRIVER_GUID1; -const GUID cfgguid2 = XSFDRIVER_GUID2; -cfg_string cfg_fooxsf(cfgguid2, ""); - -class foo_config : public IConfigIO -{ -protected: - typedef struct - { - xsfc::TString output; - xsfc::TString newvalue; - xsfc::TStringM newname; - size_t newnamelen; - bool exist; - } - cbw_t; - - static enum XSFTag::enum_callback_returnvalue scv_cb(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - cbw_t *pcbw = static_cast(pWork); - xsfc::TString name(true, pNameTop, pNameEnd - pNameTop); - if (pcbw->newnamelen == pNameEnd - pNameTop && !_strnicmp(pNameTop, pcbw->newname, pcbw->newnamelen)) - { - pcbw->exist = true; - pcbw->output = pcbw->output + name + xsfc::TString(L"=") + pcbw->newvalue + xsfc::TString(L"\n"); - } - else - { - xsfc::TString value(true, pValueTop, pValueEnd - pValueTop); - pcbw->output = pcbw->output + name + xsfc::TString(L"=") + value + xsfc::TString(L"\n"); - } - return XSFTag::enum_continue; - } - - void SetConfigValue(const wchar_t *name, xsfc::TString value) - { - const char *idata = cfg_fooxsf.get_ptr(); - size_t isize = xsfc::StrNLen(idata); - cbw_t cbw; - cbw.newvalue = value; - cbw.newname = xsfc::TStringM(true, name); - cbw.newnamelen = xsfc::StrNLen(cbw.newname); - cbw.exist = false; - XSFTag::EnumRaw(scv_cb, &cbw, idata, isize); - if (!cbw.exist) - { - cbw.output = cbw.output + name + xsfc::TString(L"=") + value + xsfc::TString(L"\n"); - } - xsfc::TStringM oututf8(true, cbw.output); - cfg_fooxsf = oututf8; - } - - xsfc::TString GetConfigValue(const wchar_t *name) - { - xsfc::TStringM tag(true, name); - const char *idata = cfg_fooxsf.get_ptr(); - size_t isize = xsfc::StrNLen(idata); - return XSFTag::GetRaw(true, tag, idata, isize); - } - -public: - foo_config() - { - } - ~foo_config() - { - } - - void SetULong(const wchar_t *name, const unsigned long value) throw() - { - try - { - xsfc::TString sValue(value); - SetConfigValue(name, sValue); - } - catch (xsfc::EShortOfMemory e) - { - } - } - unsigned long GetULong(const wchar_t *name, const unsigned long defaultvalue = 0) throw() - { - try - { - xsfc::TString value = GetConfigValue(name); - if (value[0]) - return value.GetULong(); - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } - void SetFloat(const wchar_t *name, const double value) throw() - { - try - { - xsfc::TString sValue(value); - SetConfigValue(name, sValue); - } - catch (xsfc::EShortOfMemory e) - { - } - } - double GetFloat(const wchar_t *name, const double defaultvalue = 0) throw() - { - try - { - xsfc::TString value = GetConfigValue(name); - if (value[0]) - return value.GetFloat(); - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } - void SetString(const wchar_t *name, const wchar_t *value) throw() - { - try - { - xsfc::TString sValue(value); - SetConfigValue(name, sValue); - } - catch (xsfc::EShortOfMemory e) - { - } - } - xsfc::TString GetString(const wchar_t *name, const wchar_t *defaultvalue = 0) throw() - { - try - { - xsfc::TString value = GetConfigValue(name); - if (value[0]) - return value; - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } -}; - -static foo_config icfg; - -class foo_input_xsfcfg : public preferences_page_v2 -{ -protected: - bool initialized; - foo_config *pcfg; - HWND hwnd; - - bool OnCommand(HWND hwndDlg, DWORD id, DWORD cmd) - { - switch (id) - { - case IDC_COMBO_INTERPOLATION: - if (cmd == CBN_SELCHANGE) - { - CFGUpdate(pcfg, hwndDlg); - CFGSave(pcfg); - } - break; - case 0x200: case 0x201: case 0x202: - case 0x203: case 0x204: case 0x205: - if (initialized) - { - CFGUpdate(pcfg, hwndDlg); - CFGSave(pcfg); - } - break; - case 0x206: - if (cmd == LBN_SELCHANGE) - { - CFGMuteChange(hwndDlg, 0x206); - } - break; - default: - break; - } - return FALSE; - } - - bool OnInit(HWND hwndDlg) - { - hwnd = hwndDlg; - pcfg = &icfg; - xsfc::TWin32::WndSetLongPtr(hwndDlg, DWLP_USER, this); - - initialized = false; - CFGReset(pcfg, hwndDlg); - initialized = true; - return TRUE; - } - - static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) - { - switch (uMsg) - { - case WM_COMMAND: - { - foo_input_xsfcfg *pthis = static_cast(xsfc::TWin32::WndGetLongPtr(hwndDlg, DWLP_USER)); - return pthis->OnCommand(hwndDlg, LOWORD(wParam), HIWORD(wParam)); - } - - case WM_INITDIALOG: - { - foo_input_xsfcfg *pthis = static_cast((void *)lParam); - return pthis->OnInit(hwndDlg) ? TRUE : FALSE; - } - } - return FALSE; - } - -public: - HWND create(HWND p_parent) - { - return static_cast(xsfc::TWin32::DlgCreate(hDLL, 1, p_parent, DialogProc, this)); - } - const char * get_name() { return XSFDRIVER_SIMPLENAME; } - GUID get_guid() { return cfgguid1; } - GUID get_parent_guid() { return guid_input; } - bool reset_query() { return true; } - void reset() - { - CFGDefault(); - CFGReset(pcfg, hwnd); - CFGSave(pcfg); - } - bool get_help_url(pfc::string_base & p_out) { return false; } - double get_sort_priority() { return 0; } - - foo_input_xsfcfg() - : initialized(false) - { - } - ~foo_input_xsfcfg() - { - } -}; - -class foo_initquit : public initquit -{ - void on_init() - { - CFGLoad(&icfg); - } - void on_quit() - { - } -}; - -static preferences_page_factory_t g_input_xsfcfg_factory; - -static initquit_factory_t g_input_xsfiq_factory; - -} - - -extern "C" void fb2k_config_init(HINSTANCE hinstDLL) -{ - hDLL = (HMODULE)hinstDLL; -} diff --git a/tools/vio2sf/src/xsfc/foo_input_xsfcfg8.cpp b/tools/vio2sf/src/xsfc/foo_input_xsfcfg8.cpp deleted file mode 100644 index 67459ddd5..000000000 --- a/tools/vio2sf/src/xsfc/foo_input_xsfcfg8.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include "foobar2000/SDK/foobar2000.h" - -#include "../pversion.h" - -#include "tagget.h" -#include "xsfcfg.h" - -#include "xsfui.rh" - -extern unsigned long dwInterpolation; - -namespace -{ - -HMODULE hDLL; - -cfg_string cfg_fooxsf(XSFDRIVER_SIMPLENAME "/config", ""); - -class foo_config : public IConfigIO -{ -protected: - typedef struct - { - xsfc::TString output; - xsfc::TString newvalue; - xsfc::TStringM newname; - size_t newnamelen; - bool exist; - } - cbw_t; - - static enum XSFTag::enum_callback_returnvalue scv_cb(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - cbw_t *pcbw = static_cast(pWork); - xsfc::TString name(true, pNameTop, pNameEnd - pNameTop); - if (pcbw->newnamelen == unsigned(pNameEnd - pNameTop) && !_strnicmp(pNameTop, pcbw->newname, pcbw->newnamelen)) - { - pcbw->exist = true; - pcbw->output = pcbw->output + name + xsfc::TString(L"=") + pcbw->newvalue + xsfc::TString(L"\n"); - } - else - { - xsfc::TString value(true, pValueTop, pValueEnd - pValueTop); - pcbw->output = pcbw->output + name + xsfc::TString(L"=") + value + xsfc::TString(L"\n"); - } - return XSFTag::enum_continue; - } - - void SetConfigValue(const wchar_t *name, xsfc::TString value) - { - const char *idata = cfg_fooxsf.get_val(); - size_t isize = xsfc::StrNLen(idata); - cbw_t cbw; - cbw.newvalue = value; - cbw.newname = xsfc::TStringM(true, name); - cbw.newnamelen = xsfc::StrNLen(cbw.newname); - cbw.exist = false; - XSFTag::EnumRaw(scv_cb, &cbw, idata, isize); - if (!cbw.exist) - { - cbw.output = cbw.output + name + xsfc::TString(L"=") + value + xsfc::TString(L"\n"); - } - xsfc::TStringM oututf8(true, cbw.output); - cfg_fooxsf = oututf8; - } - - xsfc::TString GetConfigValue(const wchar_t *name) - { - xsfc::TStringM tag(true, name); - const char *idata = cfg_fooxsf.get_val(); - size_t isize = xsfc::StrNLen(idata); - return XSFTag::GetRaw(true, tag, idata, isize); - } - -public: - foo_config() - { - } - ~foo_config() - { - } - - void SetULong(const wchar_t *name, const unsigned long value) throw() - { - try - { - xsfc::TString sValue(value); - SetConfigValue(name, sValue); - } - catch (xsfc::EShortOfMemory e) - { - } - } - unsigned long GetULong(const wchar_t *name, const unsigned long defaultvalue = 0) throw() - { - try - { - xsfc::TString value = GetConfigValue(name); - if (value[0]) - return value.GetULong(); - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } - void SetFloat(const wchar_t *name, const double value) throw() - { - try - { - xsfc::TString sValue(value); - SetConfigValue(name, sValue); - } - catch (xsfc::EShortOfMemory e) - { - } - } - double GetFloat(const wchar_t *name, const double defaultvalue = 0) throw() - { - try - { - xsfc::TString value = GetConfigValue(name); - if (value[0]) - return value.GetFloat(); - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } - void SetString(const wchar_t *name, const wchar_t *value) throw() - { - try - { - xsfc::TString sValue(value); - SetConfigValue(name, sValue); - } - catch (xsfc::EShortOfMemory e) - { - } - } - xsfc::TString GetString(const wchar_t *name, const wchar_t *defaultvalue = 0) - { - try - { - xsfc::TString value = GetConfigValue(name); - if (value[0]) - return value; - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } -}; - -static foo_config icfg; - -class foo_input_xsfcfg : public config -{ -protected: - bool initialized; - foo_config *pcfg; - HWND hwnd; - - bool OnCommand(HWND hwndDlg, DWORD id, DWORD cmd) - { - switch (id) - { - case IDC_COMBO_INTERPOLATION: - if (cmd == CBN_SELCHANGE) - { - CFGUpdate(pcfg, hwndDlg); - CFGSave(pcfg); - } - break; - - case 0x200: case 0x201: case 0x202: - case 0x203: case 0x204: case 0x205: - if (initialized) - { - CFGUpdate(pcfg, hwndDlg); - CFGSave(pcfg); - } - break; - case 0x206: - if (cmd == LBN_SELCHANGE) - { - CFGMuteChange(hwndDlg, 0x206); - } - break; - default: - break; - } - return FALSE; - } - - bool OnInit(HWND hwndDlg) - { - hwnd = hwndDlg; - pcfg = &icfg; - xsfc::TWin32::WndSetLongPtr(hwndDlg, DWL_USER, this); - - initialized = false; - CFGReset(pcfg, hwndDlg); - initialized = true; - return TRUE; - } - - static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) - { - switch (uMsg) - { - case WM_COMMAND: - { - foo_input_xsfcfg *pthis = static_cast(xsfc::TWin32::WndGetLongPtr(hwndDlg, DWL_USER)); - return pthis->OnCommand(hwndDlg, LOWORD(wParam), HIWORD(wParam)); - } - - case WM_INITDIALOG: - { - foo_input_xsfcfg *pthis = static_cast((void *)lParam); - return pthis->OnInit(hwndDlg) ? TRUE : FALSE; - } - } - return FALSE; - } - -public: - HWND create(HWND p_parent) - { - return (HWND)xsfc::TWin32::DlgCreate(hDLL, 1, p_parent, DialogProc, this); - } - const char * get_name() { return XSFDRIVER_SIMPLENAME; } - const char * get_parent_name() {return "Input";} - - foo_input_xsfcfg() - : initialized(false) - { - } - ~foo_input_xsfcfg() - { - } -}; - -class foo_initquit : public initquit -{ - void on_init() - { - CFGLoad(&icfg); - } - void on_quit() - { - } -}; - -static config_factory g_input_xsfcfg_factory; - -static initquit_factory g_input_xsfiq_factory; - -} - - -extern "C" void fb2k_config_init(HINSTANCE hinstDLL) -{ - hDLL = (HMODULE)hinstDLL; -} diff --git a/tools/vio2sf/src/xsfc/in_xsf.cpp b/tools/vio2sf/src/xsfc/in_xsf.cpp deleted file mode 100644 index b62923b04..000000000 --- a/tools/vio2sf/src/xsfc/in_xsf.cpp +++ /dev/null @@ -1,1984 +0,0 @@ -extern unsigned long dwInterpolation; - -#ifndef ENABLE_UNICODE_PLUGIN -#define ENABLE_UNICODE_PLUGIN 0 -#endif -#ifndef ENABLE_GETEXTENDINFO -#define ENABLE_GETEXTENDINFO 1 -#endif -#ifndef ENABLE_GETEXTENDINFOW -#define ENABLE_GETEXTENDINFOW 1 -#endif -#ifndef ENABLE_TAGWRITER -#define ENABLE_TAGWRITER 1 -#endif -#ifndef ENABLE_EXTENDREADER -#define ENABLE_EXTENDREADER 1 -#endif - -#define WIN32_LEAN_AND_MEAN -#define NOGDI -#include "leakchk.h" - -#include -#include -#include -#include - -#if _MSC_VER >= 1400 -#include -#endif - -#if ENABLE_UNICODE_PLUGIN -#define UNICODE_INPUT_PLUGIN -#else -#undef UNICODE_INPUT_PLUGIN -#endif - -/* Winamp SDK headers */ -#include -#include - -#if !defined(_DEBUG) -#include "../loadpe/loadpe.h" -#else -#define XLoadLibraryW LoadLibraryW -#define XLoadLibraryA LoadLibraryA -#define XGetProcAddress(h,n) GetProcAddress((HMODULE)h,n) -#define XFreeLibrary(h) FreeLibrary((HMODULE)h) -#endif - -#include "xsfdrv.h" - -#include "../pversion.h" -#include "tagget.h" - -#include "in_xsfcfg.h" - -#if _MSC_VER >= 1200 -#pragma comment(linker, "/EXPORT:winampGetInModule2=_winampGetInModule2") - -#if ENABLE_GETEXTENDINFO -#pragma comment(linker, "/EXPORT:winampGetExtendedFileInfo=_winampGetExtendedFileInfo") -#endif - -#if ENABLE_GETEXTENDINFOW -#pragma comment(linker, "/EXPORT:winampGetExtendedFileInfoW=_winampGetExtendedFileInfoW") -#endif - -#if ENABLE_TAGWRITER -#pragma comment(linker, "/EXPORT:winampSetExtendedFileInfo=_winampSetExtendedFileInfo") -#pragma comment(linker, "/EXPORT:winampSetExtendedFileInfoW=_winampSetExtendedFileInfoW") -#pragma comment(linker, "/EXPORT:winampWriteExtendedFileInfo=_winampWriteExtendedFileInfo") -#endif - -#if ENABLE_GETEXTENDINFO || ENABLE_GETEXTENDINFOW || ENABLE_TAGWRITER -#pragma comment(linker, "/EXPORT:winampUseUnifiedFileInfoDlg=_winampUseUnifiedFileInfoDlg") -#pragma comment(linker, "/EXPORT:winampAddUnifiedFileInfoPane=_winampAddUnifiedFileInfoPane") -#endif - -#if ENABLE_EXTENDREADER -#ifdef UNICODE_INPUT_PLUGIN -#pragma comment(linker, "/EXPORT:winampGetExtendedRead_openW=_winampGetExtendedRead_openW") -#else -#pragma comment(linker, "/EXPORT:winampGetExtendedRead_open=_winampGetExtendedRead_open") -#endif -#pragma comment(linker, "/EXPORT:winampGetExtendedRead_getData=_winampGetExtendedRead_getData") -#pragma comment(linker, "/EXPORT:winampGetExtendedRead_setTime=_winampGetExtendedRead_setTime") -#pragma comment(linker, "/EXPORT:winampGetExtendedRead_close=_winampGetExtendedRead_close") -#endif - -#endif - -#if defined(_MSC_VER) && !defined(_DEBUG) -#pragma comment(linker,"/MERGE:.rdata=.text") -#endif - -namespace -{ - -#define CHECK_SILENCE_BIAS 0x8000000 -#ifndef CHECK_SILENCE_LEVEL -#define CHECK_SILENCE_LEVEL 7 -#endif - -#define SIZE_OF_BUFFER (576 * 4) - -typedef signed short xsfsample_t; - -static void wstrncpychk(wchar_t *d, const wchar_t *s, size_t m) -{ - size_t l = wcslen(s) + 1; - wcsncpy(d, s, (l > m) ? m : l); -} - -static void mstrncpychk(char *d, const char *s, size_t m) -{ - size_t l = strlen(s) + 1; - strncpy(d, s, (l > m) ? m : l); -} - -static void icsncpy(in_char *d, const in_char *s, size_t m) -{ -#if _MSC_VER >= 1200 -#ifndef STATUS_ACCESS_VIOLATION -#define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L) -#endif - __try - { -#endif -#ifdef UNICODE_INPUT_PLUGIN - wstrncpychk(d, s, m); -#else - mstrncpychk(d, s, m); -#endif -#if _MSC_VER >= 1200 - } - __except(GetExceptionCode() == STATUS_ACCESS_VIOLATION) - { - } -#endif -} - -class XSFDriver -{ -public: - - IXSFDRV *lpif; - - xsfc::TAutoBuffer xsfdata; - - unsigned cur_smp; - unsigned len_smp; - unsigned fad_smp; - - int hasvolume; - bool haslength; - float volume; - enum - { -#ifndef XSFDRIVER_SAMPLERATE - samplerate = 44100, -#else - samplerate = XSFDRIVER_SAMPLERATE, -#endif - samplebits = 16, - ch = 2, - blockshift = 2, - }; - int length_in_ms; int fade_in_ms; - - volatile unsigned seek_pos; - volatile int seek_req; - volatile int seek_kil; - -protected: - unsigned detectedSilenceSec; - unsigned detectedSilenceSample; - unsigned skipSilenceOnStartSec; - unsigned long prevSampleL; - unsigned long prevSampleR; - - void *hDriver; - xsfc::TString sLibBasePath; - bool fUTF8; - - static void *liballoc_cb(void *pwork, size_t s) - { - IXSFDRV *lpif = static_cast(pwork); - return lpif->LibAlloc(DWORD(s)); - } - static void libfree_cb(void *pwork, void *p) - { - IXSFDRV *lpif = static_cast(pwork); - lpif->LibFree(p); - } - - static int PASCAL XSFGETLIBCALLBACK(void *lpWork, LPSTR lpszFilename, void **ppBuffer, DWORD *pdwSize) - { - XSFDriver *lpDrv = static_cast(lpWork); - - size_t libsize; - xsfc::TString sLibName = xsfc::TString(lpDrv->fUTF8, lpszFilename); - - void *libdata = xsfc::TWin32::LoadEx(xsfc::TWin32::CanonicalizePath(lpDrv->sLibBasePath + sLibName), libsize, lpDrv->lpif, liballoc_cb, libfree_cb); - if (!libdata) - { - /* in_zip.dll */ - libdata = xsfc::TWin32::LoadEx(lpDrv->sLibBasePath + xsfc::TWin32::ExtractFileName(sLibName), libsize, lpDrv->lpif, liballoc_cb, libfree_cb); - } - if (!libdata) - return 1; - - *ppBuffer = libdata; - *pdwSize = DWORD(libsize); - - return 0; - } - - void SeekTop() - { - cur_smp = 0; - - skipSilenceOnStartSec = CFGGetSkipSilenceOnStartSec(); - - detectedSilenceSec = 0; - detectedSilenceSample = 0; - - prevSampleL = CHECK_SILENCE_BIAS; - prevSampleR = CHECK_SILENCE_BIAS; - } - -public: - - XSFDriver() throw() - : hDriver(0), lpif(0) - { - } - ~XSFDriver() - { - } - - void Free() - { - if (lpif) - { - lpif->Term(); - lpif = 0; - } - if (hDriver) - { - XFreeLibrary(hDriver); - hDriver = 0; - } - xsfdata.Free(); - } - - bool Init(HINSTANCE hDll) - { - xsfc::TString sDrvPath = xsfc::TWin32::ExtractPath(xsfc::TWin32::ModulePath(hDll)) + XSFDRIVER_MODULENAME; - hDriver = xsfc::TWin32::IsUnicodeSupportedOS() ? XLoadLibraryW(sDrvPath) : XLoadLibraryA(xsfc::TStringM(sDrvPath)); - if (!hDriver) - return false; - LPFNXSFDRVSETUP lpfnXSFSetup = (LPFNXSFDRVSETUP)XGetProcAddress(hDriver, XSFDRIVER_ENTRYNAME); - lpif = lpfnXSFSetup ? lpfnXSFSetup(XSFGETLIBCALLBACK ,this) : 0; - if (!lpif) - { - Free(); - return false; - } - - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT, addInstrument); - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED, isInstrumentMuted); - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME, getInstrumentVolume); - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE, isInstrumentSelectionActive); - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_OPENSOUNDVIEW, openSoundView); - - - return true; - } - - bool Load(xsfc::TString fn) - { - - length_in_ms = CFGGetDefaultLength(); - fade_in_ms = CFGGetDefaultFade(); - hasvolume = 0; - volume = 1; - - sLibBasePath = xsfc::TWin32::ExtractPath(fn); - - xsfdata = xsfc::TWin32::Map(fn); - if (!xsfdata.Ptr()) - return false; - - fUTF8 = XSFTag::Exists("utf8", xsfdata.Ptr(), xsfdata.Len()) != 0; - if (lpif->dwInterfaceVersion >= 3) - { - lpif->SetExtendParam(1, CFGGetExtendParam1()); - lpif->SetExtendParam(2, CFGGetExtendParam2()); - } - if (lpif->Start(xsfdata.Ptr(), xsfdata.Len())) - { - return false; - } - - if (!XSFTag::GetVolume(&volume, "volume", xsfdata, 0)) - hasvolume = 1; - length_in_ms = XSFTag::GetLengthMS(xsfdata, CFGGetDefaultLength()); - fade_in_ms = XSFTag::GetFadeMS(xsfdata, CFGGetDefaultFade()); - - haslength = XSFTag::Exists("length", xsfdata.Ptr(), xsfdata.Len()) != 0; - - return true; - } - - void Start() - { - len_smp = MulDiv(length_in_ms, samplerate, 1000); - fad_smp = MulDiv(fade_in_ms, samplerate, 1000); - seek_pos = 0; - seek_kil = 0; - seek_req = 0; - SeekTop(); - } - - int Gen(void *pbuf, unsigned bufsize) - { - xsfsample_t *ptop = static_cast(pbuf); - unsigned detectSilence = CFGGetDetectSilenceSec(); - unsigned pos = 0; - if (lpif->dwInterfaceVersion >= 2) - { - bool output = false; - for (int i = 0; i < 4; i++) - { - unsigned long mute = CFGGetChannelMute(i); - output |= (mute != ~unsigned long(0)); - lpif->SetChannelMute(i, mute); - } - if (!output) detectSilence = 0; - } - if (lpif->dwInterfaceVersion >= 4) - { - lpif->SetExtendParamImmediate(EXTEND_PARAM_IMMEDIATE_INTERPOLATION, &dwInterpolation); - } - while (pos < bufsize) - { - unsigned ofs; - xsfsample_t *pblk = ptop + (pos << 1); - unsigned remain = bufsize - pos; - lpif->Gen(pblk, remain); - if (detectSilence || skipSilenceOnStartSec) - { - xsfsample_t *pskp = 0; - xsfsample_t *pcur = pblk; - for (ofs = 0; ofs < remain; ofs++) - { - long smpl = pcur[0]; - long smpr = pcur[1]; - bool silence = (((unsigned long)(smpl + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL)) - prevSampleL <= (CHECK_SILENCE_LEVEL) * 2) && (((unsigned long)(smpr + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL)) - prevSampleR <= (CHECK_SILENCE_LEVEL) * 2); - - if (silence) - { - if (++detectedSilenceSample >= samplerate) - { - detectedSilenceSample -= samplerate; - detectedSilenceSec++; - if (skipSilenceOnStartSec && detectedSilenceSec >= skipSilenceOnStartSec) - { - skipSilenceOnStartSec = 0; - detectedSilenceSec = 0; - if (pblk != pcur) pskp = pcur; - } - } - } - else - { - detectedSilenceSample = 0; - detectedSilenceSec = 0; - if (skipSilenceOnStartSec) - { - skipSilenceOnStartSec = 0; - if (pblk != pcur) pskp = pcur; - } - } - prevSampleL = smpl + CHECK_SILENCE_BIAS; - prevSampleR = smpr + CHECK_SILENCE_BIAS; - pcur += 2; - } - if (skipSilenceOnStartSec) - { - } - else if (pskp) - { - while (pskp < pcur) - { - *(pblk++)= *(pskp++); - *(pblk++)= *(pskp++); - pos++; - } - } - else - { - pos += remain; - } - } - else - { - pos += remain; - } - } - return bufsize; - } - unsigned DetectedSilenceSec() - { - return detectedSilenceSec; - } - - int FillBuffer(void *pbuf, unsigned bufbytes, unsigned *writebytes, unsigned isdecoder) - { - int end_flag = 0; - unsigned bufsize = bufbytes >> blockshift; - unsigned cur = MulDiv(cur_smp, 1000, samplerate); - int len = bufsize; - Gen(pbuf, bufsize); - - /* detect end */ - if (!CFGGetPlayInfinitely() || isdecoder) - { - if (cur_smp >= len_smp + fad_smp) - { - end_flag = 1; - *writebytes = 0; - return 1; - } - if (cur_smp + len >= len_smp + fad_smp) - { - len = len_smp + fad_smp - cur_smp; - end_flag = 1; - } - } - - double cfgvolume = 1; - bool hascfgvolume = !isdecoder && CFGGetVolume(cfgvolume); - /* volume */ - if (hasvolume || hascfgvolume) - { - float scale = float(volume * cfgvolume); - xsfsample_t *p = static_cast(pbuf); - unsigned i; - for (i = cur_smp; i < cur_smp + len; i++) - { - float s1, s2; - s1 = float(p[0]); - s2 = float(p[1]); - s1 *= scale; - if (s1 > float(0x7fff)) - s1 = float(0x7fff); - else if (s1 < float(-0x8000)) - s1 = float(-0x8000); - s2 *= scale; - if (s2 > float(0x7fff)) - s2 = float(0x7fff); - else if (s2 < float(-0x8000)) - s2 = float(-0x8000); - p[0] = xsfsample_t(s1); - p[1] = xsfsample_t(s2); - p += 2; - } - } - - /* fader */ - if ((!CFGGetPlayInfinitely() || isdecoder) && fad_smp && cur_smp + len >= len_smp) - { - xsfsample_t *p = static_cast(pbuf); - unsigned i; - for (i = cur_smp; i < cur_smp + len; i++) - { - if (i < len_smp) - ; - else if (i < len_smp + fad_smp) - { - int scale = MulDiv(len_smp + fad_smp - i, 0x10000, fad_smp); - p[0] = (p[0] * scale) >> 16; - p[1] = (p[1] * scale) >> 16; - } - else - { - p[0] = 0; - p[1] = 0; - } - p += 2; - } - } - - cur_smp += len ; - *writebytes = len << blockshift; - return end_flag; - } - - int Seek(unsigned seek_pos, volatile int *killswitch, void *pbuf, unsigned bufbytes, Out_Module *outMod) - { - unsigned bufsize = bufbytes >> blockshift; - unsigned seek_smp = MulDiv(seek_pos, samplerate, 1000); - DWORD prevTimer = outMod ? GetTickCount() : 0; - if (seek_smp < cur_smp) - { - lpif->Start(xsfdata.Ptr(), xsfdata.Len()); - SeekTop(); - } - while (seek_smp - cur_smp > bufsize) - { - unsigned cur = MulDiv(cur_smp, 1000, samplerate); - if (killswitch && *killswitch) - return 1; - if (outMod) - { - DWORD curTimer = GetTickCount(); - if (DWORD(curTimer - prevTimer) >= 500) - { - prevTimer = curTimer; - outMod->Flush(cur); - } - } - - Gen(pbuf, bufsize); - cur_smp += bufsize; - } - if (seek_smp - cur_smp > 0) - { - Gen(pbuf, seek_smp - cur_smp); - cur_smp = seek_smp; - } - if (outMod) outMod->Flush(seek_pos); - return 0; - } - - void Reinit() - { - Free(); - seek_pos = 0; - } -}; - -enum REQUEST -{ - REQUEST_STOP, - REQUEST_SEEK, - REQUEST_RESTART -}; - -#if ENABLE_GETEXTENDINFO || ENABLE_GETEXTENDINFOW || ENABLE_TAGWRITER - -static const char * const tag_table[] = -{ - "title","title", - "artist","artist", - "album","game", - "albumartist","copyright", - "year","year", - "genre","genre", - "composer","composer", - "publisher",WINAMPPLUGIN_TAG_XSFBY, - "disc","disc", - "track","track", - "replaygain_album_gain","replaygain_album_gain", - "replaygain_album_peak","replaygain_album_peak", - "replaygain_track_gain","replaygain_track_gain", - "replaygain_track_peak","replaygain_track_peak", - - "GracenoteFileID",0, - "GracenoteExtData",0, - "streamtype",0, - "bpm",0, - - "type","\x01", - "streamname","\x02", - "length","\x03", - "comment","\x04", - "formatinformation","\x05", - - 0,0 -}; - -enum EXINFO -{ - EXINFO_NOT_SUPPORTED = 0, - EXINFO_SUPPORTED = 1 -}; - -enum XSF_TAG_TYPE -{ - XSF_TAG_TYPE_DIRECTSUPPORT = 0, - XSF_TAG_TYPE_EXTENDSUPPORT = 1, - XSF_TAG_TYPE_SYSTEM = 2, - XSF_TAG_TYPE_UNKNOWN = -1, - XSF_TAG_TYPE_ALL = -2 -}; - -class TagReader -{ -protected: - typedef struct - { - char *ptr; - const char *tag; - int taglen; - int count; - unsigned need; - enum XSF_TAG_TYPE mode; - } xsf_multitagget_work_t; - - static enum XSF_TAG_TYPE xsf_multitagget_type(const char *tag, int taglen) - { - const char * const *ptbl; - if (!taglen) - return XSF_TAG_TYPE_UNKNOWN; - if (XSFDRIVER_ISSYSTEMTAG(taglen, tag)) - return XSF_TAG_TYPE_SYSTEM; - for (ptbl = tag_table; ptbl[0]; ptbl += 2) - { - if (!ptbl[1]) - continue; - if ('\x00' < ptbl[1][0] && ptbl[1][0] <= '\x05') - continue; - if (!_strnicmp(tag, ptbl[1], taglen)) - return XSF_TAG_TYPE_DIRECTSUPPORT; - } - return XSF_TAG_TYPE_EXTENDSUPPORT; - } - - static enum XSFTag::enum_callback_returnvalue getmultitaqg_cb(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - xsf_multitagget_work_t *pwork = static_cast(pWork); - enum XSF_TAG_TYPE tagtype = xsf_multitagget_type(pNameTop, pNameEnd - pNameTop); - if (pwork->mode != XSF_TAG_TYPE_ALL && pwork->mode != tagtype) - return XSFTag::enum_continue; - if (pwork->mode != XSF_TAG_TYPE_ALL && tagtype == XSF_TAG_TYPE_DIRECTSUPPORT) - { - if (pNameEnd - pNameTop != pwork->taglen || _strnicmp(pNameTop, pwork->tag, pwork->taglen)) - return XSFTag::enum_continue; - if (pwork->ptr) - { - if (0 != pwork->count++) - { - pwork->ptr[0] = ' '; - pwork->ptr[1] = ';'; - pwork->ptr[2] = ' '; - pwork->ptr += 3; - } - if (pValueEnd-pValueTop > 0) - memcpy(pwork->ptr, pValueTop, pValueEnd-pValueTop); - pwork->ptr += pValueEnd-pValueTop; - } - else - { - if (0 != pwork->count++) - pwork->need += 3; - pwork->need += pValueEnd-pValueTop; - } - } - else - { - if (pwork->ptr) - { - if (0 != pwork->count++) - { - pwork->ptr[0] = '\x0d'; - pwork->ptr[1] = '\x0a'; - pwork->ptr += 2; - } - if (pNameEnd-pNameTop > 0) - memcpy(pwork->ptr, pNameTop, pNameEnd-pNameTop); - pwork->ptr += pNameEnd-pNameTop; - pwork->ptr[0] = '='; - pwork->ptr += 1; - if (pValueEnd-pValueTop > 0) - memcpy(pwork->ptr, pValueTop, pValueEnd-pValueTop); - pwork->ptr += pValueEnd-pValueTop; - } - else - { - if (0 != pwork->count++) - { - pwork->need += 2; - } - pwork->need += pNameEnd-pNameTop + 1 + pValueEnd-pValueTop; - } - } - return XSFTag::enum_continue; - } - - static wchar_t *TagFunc(const wchar_t * tag, void * p) - { - return 0; - } - - static void TagFree(wchar_t *tag, void *p) - { - } - - static int get_tag_formattitleW(HWND hwndWinamp, const wchar_t *fn, wchar_t *title, unsigned l) - { - waFormatTitleExtended fmt; - fmt.filename = fn; - fmt.useExtendedInfo = 1; - fmt.spec = NULL; - fmt.p = NULL; - fmt.out = title; - fmt.out_len = l; - fmt.TAGFUNC = TagFunc; - fmt.TAGFREEFUNC = TagFree; - if (l > 0) - { - title[0] = 0; - xsfc::TWin32::WndMsgSend(hwndWinamp, WM_WA_IPC, &fmt, IPC_FORMAT_TITLE_EXTENDED); - if (title[0]) - return 1; - } - return 0; - } - -#ifdef UNICODE_INPUT_PLUGIN -#else - static int get_tag_formattitleA(HWND hwndWinamp, const char *fn, char *title, unsigned l) - { - int r = 0; - wchar_t wbuf[GETFILEINFO_TITLE_LENGTH]; - r = get_tag_formattitleW(hwndWinamp, xsfc::TString(fn), wbuf, GETFILEINFO_TITLE_LENGTH); - xsfc::TStringM mbuf(wbuf, GETFILEINFO_TITLE_LENGTH); - icsncpy(title, mbuf, l); - return r; - } -#endif - -public: - - static xsfc::TString XSFTagGetMulti(xsfc::TAutoBuffer idata, const char *metadata, enum XSF_TAG_TYPE mode) - { - xsfc::TString ret; - xsfc::TSimpleArray tag; - xsf_multitagget_work_t cbw; - cbw.mode = mode; - cbw.tag = metadata; - cbw.taglen = metadata ? strlen(metadata) : 0; - cbw.count = 0; - cbw.need = 0; - cbw.ptr = 0; - XSFTag::Enum(getmultitaqg_cb, &cbw, idata.Ptr(), idata.Len()); - if (cbw.need && tag.Resize(cbw.need + 1)) - { - bool futf8 = XSFTag::Exists("utf8", idata.Ptr(), idata.Len()); - char *ptr = tag.Ptr(); - ptr[cbw.need] = '\x00'; - cbw.count = 0; - cbw.ptr = ptr; - XSFTag::Enum(getmultitaqg_cb, &cbw, idata.Ptr(), idata.Len()); - ret = xsfc::TString(futf8, ptr); - } - return ret; - } -#endif - - static void get_tag_title(in_char *title, unsigned l, xsfc::TAutoBuffer idata) - { - xsfc::TString tagtitle; -#if ENABLE_GETEXTENDINFO || ENABLE_GETEXTENDINFOW || ENABLE_TAGWRITER - tagtitle = XSFTagGetMulti(idata, "title", XSF_TAG_TYPE_DIRECTSUPPORT); -#else - tagtitle = XSFTag::Get("title", idata.Ptr(), idata.Len()); -#endif - if (l > 0) title[0] = 0; - if (tagtitle[0]) - { -#ifdef UNICODE_INPUT_PLUGIN - icsncpy(title, tagtitle, l); -#else - icsncpy(title, xsfc::TStringM(tagtitle), l); -#endif - } - } - - static void get_tag_formattitle(HWND hwndWinamp, const in_char *fn, in_char *title, unsigned l, xsfc::TAutoBuffer idata) - { - if (l > 0) title[0] = 0; -#ifdef UNICODE_INPUT_PLUGIN - get_tag_formattitleW(hwndWinamp, fn, title, l); -#else - get_tag_formattitleA(hwndWinamp, fn, title, l); -#endif - if (l > 0 && !title[0]) - { - get_tag_title(title, l, idata); - } - if (l > 0 && !title[0]) - { - icsncpy(title, xsfc::TWin32T::ExtractFilename(fn), l); - } - } - -#if ENABLE_GETEXTENDINFO || ENABLE_GETEXTENDINFOW || ENABLE_TAGWRITER - class TagReturn - { - protected: - xsfc::TString ret; - size_t l; - wchar_t *wbuf; - char *mbuf; - public: - TagReturn() - : l(0), wbuf(0), mbuf(0) - { - } - TagReturn(char *buf, size_t buflen) - : l(buflen), wbuf(0), mbuf(buf) - { - } - TagReturn(wchar_t *buf, size_t buflen) - : l(buflen), wbuf(buf), mbuf(0) - { - } - ~TagReturn() - { - } - void Set(const xsfc::TString &value) - { - ret = value; - if (l && wbuf) - wstrncpychk(wbuf, ret, l); - if (l && mbuf) - mstrncpychk(mbuf, xsfc::TStringM(ret), l); - } - void Set(bool futf8, const char *tag) - { - Set(xsfc::TString(futf8, tag)); - } - xsfc::TString Get() - { - return ret; - } - }; - - static int getfinfo(xsfc::TAutoBuffer idata, const char *metadata, TagReturn &result) - { - bool futf8 = XSFTag::Exists("utf8", idata.Ptr(), idata.Len()); - int taglen = strlen(metadata); - const char * const *ptbl; - for (ptbl = tag_table; ptbl[0]; ptbl += 2) - { - if (!_strnicmp(metadata, ptbl[0], taglen)) - { - if (!ptbl[1]) - break; - else if (ptbl[1][0] == '\x01') - { - result.Set(futf8, "0"); - } - else if (ptbl[1][0] == '\x02') - { - result.Set(futf8, ""); - } - else if (ptbl[1][0] == '\x03') - { - char tbuf[16]; - unsigned length = XSFTag::GetLengthMS(idata, CFGGetDefaultLength()); - unsigned fade = XSFTag::GetFadeMS(idata, CFGGetDefaultFade()); -#if defined(HAVE_SPRINTF_S) - sprintf_s(tbuf, sizeof(tbuf), "%10d", (length + fade)); -#elif defined(HAVE_SNPRINTF) - snprintf(tbuf, sizeof(tbuf), "%10d", (length + fade)); -#elif defined(HAVE_SNPRINTF_) - _snprintf(tbuf, sizeof(tbuf), "%10d", (length + fade)); -#else - sprintf(tbuf, "%10d", (length + fade)); -#endif - result.Set(futf8, tbuf); - } - else if (ptbl[1][0] == '\x04') - { - xsfc::TString tag = XSFTagGetMulti(idata, 0, XSF_TAG_TYPE_EXTENDSUPPORT); - result.Set(futf8, xsfc::TStringM(futf8, tag)); - } - else if (ptbl[1][0] == '\x05') - { - xsfc::TString tag = XSFTagGetMulti(idata, 0, XSF_TAG_TYPE_SYSTEM); - result.Set(futf8, xsfc::TStringM(futf8, tag)); - } - else - { - xsfc::TString tag = XSFTagGetMulti(idata, ptbl[1], XSF_TAG_TYPE_DIRECTSUPPORT); - result.Set(futf8, xsfc::TStringM(futf8, tag)); - } - return EXINFO_SUPPORTED; - } - } - return EXINFO_NOT_SUPPORTED; - } -#endif - -#if ENABLE_GETEXTENDINFO || ENABLE_GETEXTENDINFOW - static bool getfinfo_map(xsfc::TAutoBuffer &idata, const wchar_t *fn) - { - idata = xsfc::TWin32::Map(fn); - return idata.Ptr() != 0; - } -#endif - -}; - -class WinampPlugin -{ -protected: - static XSFDriver xsfdrv; - static HMODULE m_hDLL; - static HANDLE m_hThread; - static HANDLE m_hEvent; - static HANDLE m_hEvent2; - static volatile LONG m_lRequest; - static int m_paused; - static in_char m_title[GETFILEINFO_TITLE_LENGTH]; - static HANDLE m_hFindWindowThread; - -public: - static In_Module mod; - - static void Init(HINSTANCE hinstDLL) - { - m_hDLL = (HMODULE)hinstDLL; - } - - static HMODULE ConfigInit() - { - winamp_config_load(mod.hMainWindow); - return m_hDLL; - } - -protected: - static DWORD __stdcall PlayWorkerThread(LPVOID argp) - { - try - { - unsigned char buffer[SIZE_OF_BUFFER * 2]; - unsigned seek_pos; - unsigned end_flag; - - int request1; - - xsfdrv.Start(); - - m_paused = 0; - request1 = 0; - ::ResetEvent(m_hEvent); - - end_flag = 0; - do - { - unsigned timeout; - unsigned writebytes; - int len; - unsigned detectsilencesec = CFGGetDetectSilenceSec(); - unsigned playinfinitely = CFGGetPlayInfinitely(); - unsigned cur = MulDiv(xsfdrv.cur_smp, 1000, xsfdrv.samplerate); - bool haslength = xsfdrv.haslength; - end_flag = xsfdrv.FillBuffer(buffer, SIZE_OF_BUFFER, &writebytes, 0); - - if (!playinfinitely && !haslength && detectsilencesec && detectsilencesec <= xsfdrv.DetectedSilenceSec()) - end_flag = 1; - - len = writebytes >> xsfdrv.blockshift; - if (len == 0) - { - end_flag = 1; - continue; - } - - if (len >= 576) - { - mod.SAAddPCMData(buffer, xsfdrv.ch, xsfdrv.samplebits, cur); - mod.VSAAddPCMData(buffer, xsfdrv.ch, xsfdrv.samplebits, cur); - } - if(mod.dsp_isactive()) - len = mod.dsp_dosamples((xsfsample_t *)(buffer), len, xsfdrv.samplebits, xsfdrv.ch, xsfdrv.samplerate); - len <<= xsfdrv.blockshift; - timeout = 0; - request1 = 0; - do - { - if (::WaitForSingleObject(m_hEvent, timeout) != WAIT_TIMEOUT) - { - request1 = ::InterlockedExchange((LPLONG)&m_lRequest, 0); - break; - } - timeout = 10; - } while (mod.outMod->CanWrite() < len); - if (request1 & (1 << REQUEST_STOP)) - break; - if (request1 & (1 << REQUEST_RESTART)) - { - seek_pos = 0; - request1 |= (1 << REQUEST_SEEK); - } - else if (request1 & (1 << REQUEST_SEEK)) - { - seek_pos = xsfdrv.seek_pos; - if (!seek_pos) - request1 &= ~(1 << REQUEST_SEEK); - } - if (request1 & (1 << REQUEST_SEEK)) - { - xsfdrv.seek_kil = 0; - xsfdrv.Seek(seek_pos, &xsfdrv.seek_kil, buffer, SIZE_OF_BUFFER, mod.outMod); - xsfdrv.seek_pos = 0; - continue; - } - if (mod.outMod->CanWrite() >= len) - mod.outMod->Write((char *)(buffer), len); - } while (!end_flag); - - if (end_flag) - { - unsigned timeout = 0; - do - { - if (::WaitForSingleObject(m_hEvent, timeout) != WAIT_TIMEOUT) - { - int request2 = ::InterlockedExchange((LPLONG)&m_lRequest, 0); - if (request2 & (1 << REQUEST_STOP)) - { - request1 |= (1 << REQUEST_STOP); - break; - } - } - timeout = 10; - } while (mod.outMod->IsPlaying()); - } - - void killSoundView(); - killSoundView(); - xsfdrv.Free(); - - if (!(request1 & (1 << REQUEST_STOP))) - { - xsfc::TWin32::WndMsgPost(mod.hMainWindow, WM_WA_MPEG_EOF); - } - } - catch (xsfc::EShortOfMemory ex) - { - } - return 0; - } - - static int __cdecl play(const in_char *fn) - { - try - { - DWORD dwThreadId; - int maxlatency; - - if (m_hThread) - return 1; - - if (!m_hEvent) - return 1; - - xsfdrv.Free(); - - ConfigInit(); - - if (!xsfdrv.Init(m_hDLL) || !xsfdrv.Load(xsfc::TString(fn))) - { - xsfdrv.Free(); - return 1; - } - - if (!XSFTag::GetVolume(&xsfdrv.volume, "replaygain_album_gain", xsfdrv.xsfdata, 1)) - xsfdrv.hasvolume = 1; - else if (!XSFTag::GetVolume(&xsfdrv.volume, "replaygain_track_gain", xsfdrv.xsfdata, 1)) - xsfdrv.hasvolume = 1; - - TagReader::get_tag_formattitle(mod.hMainWindow, fn, m_title, GETFILEINFO_TITLE_LENGTH, xsfdrv.xsfdata); - - maxlatency = mod.outMod->Open(xsfdrv.samplerate, xsfdrv.ch, xsfdrv.samplebits, 0, 0); - if (maxlatency < 0) - { - xsfdrv.Free(); - return 1; - } - - xsfc::TWin32::WndMsgSend(mod.hMainWindow, WM_WA_IPC, 0, IPC_UPDTITLE); - - mod.SetInfo(xsfdrv.samplerate * xsfdrv.samplebits * xsfdrv.ch / 1000, xsfdrv.samplerate / 1000, xsfdrv.ch, 0); - mod.SAVSAInit(maxlatency, xsfdrv.samplerate); - mod.VSASetInfo(xsfdrv.samplerate, xsfdrv.ch); - mod.outMod->SetVolume(-666); - m_hThread = ::CreateThread(NULL, 0, PlayWorkerThread, NULL, 0, &dwThreadId); - if (!m_hThread) - { - mod.SAVSADeInit(); - mod.outMod->Close(); - xsfdrv.Free(); - return 1; - } - return 0; - } - catch (xsfc::EShortOfMemory ex) - { - } - return 1; - } - - static void Request(enum REQUEST request_code) - { - if (m_hEvent) - { - m_lRequest |= 1 << request_code; - ::SetEvent(m_hEvent); - } - } - - static void __cdecl stop(void) - { - if (m_hThread) - { - do - { - xsfdrv.seek_kil = 1; - Request(REQUEST_STOP); - - MSG msg; - while( PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ) ) - if( GetMessage( &msg, 0, 0, 0)>0 ) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - - } while (::WaitForSingleObject(m_hThread, 20) == WAIT_TIMEOUT); - ::CloseHandle(m_hThread); - m_hThread = NULL; - mod.SAVSADeInit(); - mod.outMod->Close(); - } - } - - typedef struct - { - bool found; - HWND hwnd; - } ftw_work_t; - - static BOOL CALLBACK ftw_cb(HWND hwnd, LPARAM lParam) - { - ftw_work_t *pftww = (ftw_work_t *)lParam; - char buf[32]; - if (::GetClassNameA(hwnd, buf, sizeof(buf))) - { - if (!::lstrcmpA(buf, "Winamp v1.x")) - { - pftww->found = true; - pftww->hwnd = hwnd; - return FALSE; - } - } - return TRUE; - } - - static DWORD CALLBACK FindThreadWindow(LPVOID argp) - { - ftw_work_t ftww = { false, 0 }; - DWORD dwThreadId = (DWORD)argp; - do - { - Sleep(500); - ::EnumThreadWindows(dwThreadId, ftw_cb, (LPARAM)&ftww); - } - while (!ftww.found && (*(volatile HANDLE *)&m_hEvent) != 0); - if (ftww.found) - winamp_config_add_prefs(ftww.hwnd); - return 0; - } - - static void closeevent(void) - { - if (m_hEvent) - { - ::CloseHandle(m_hEvent); - m_hEvent = 0; - } - } - static void termfindwindowthread(void) - { - if (m_hFindWindowThread) - { - TerminateThread(m_hFindWindowThread, 1); - ::CloseHandle(m_hFindWindowThread); - m_hFindWindowThread = 0; - } - } - - static void __cdecl init(void) - { - try - { - m_lRequest = 0; - m_hThread = 0; - m_title[0] = '\0'; - closeevent(); - m_hEvent = ::CreateEventA(NULL, FALSE, FALSE, NULL); - xsfdrv.Reinit(); - ConfigInit(); - if (mod.hMainWindow) - winamp_config_add_prefs(mod.hMainWindow); - else - { - DWORD dwThreadId; - termfindwindowthread(); - m_hFindWindowThread = ::CreateThread(NULL, 0, FindThreadWindow, (LPVOID)::GetCurrentThreadId(), 0, &dwThreadId); - } - } - catch (xsfc::EShortOfMemory ex) - { - } - } - - static void __cdecl quit(void) - { - try - { - termfindwindowthread(); - winamp_config_remove_prefs(mod.hMainWindow); - xsfdrv.Free(); - closeevent(); - } - catch (xsfc::EShortOfMemory ex) - { - } - } - - static void __cdecl getfileinfo(const in_char *fn, in_char *title, int *length_in_ms) - { - try - { - if (title) *title = '\0'; - if (length_in_ms) *length_in_ms = CFGGetDefaultLength() + CFGGetDefaultFade(); - if (!fn || !*fn) - { - if (title) - icsncpy(title, m_title, GETFILEINFO_TITLE_LENGTH); - if (length_in_ms) - *length_in_ms = xsfdrv.length_in_ms + xsfdrv.fade_in_ms; - return; - } - xsfc::TAutoBuffer idata = xsfc::TWin32::Map(xsfc::TString(fn)); - if (idata.Ptr()) - { - if (title) - { - TagReader::get_tag_formattitle(mod.hMainWindow, fn, title, GETFILEINFO_TITLE_LENGTH, idata); - } - - if (length_in_ms) - { - unsigned length = XSFTag::GetLengthMS(idata, CFGGetDefaultLength()); - unsigned fade = XSFTag::GetFadeMS(idata, CFGGetDefaultFade()); - *length_in_ms = length + fade; - } - } - } - catch (xsfc::EShortOfMemory ex) - { - } - } - - static void __cdecl pause(void) { m_paused = 1; mod.outMod->Pause(1); } - static void __cdecl unpause(void) { m_paused = 0; mod.outMod->Pause(0); } - static int __cdecl getoutputtime(void) { return mod.outMod->GetOutputTime(); } - static void __cdecl setvolume(int volume) { mod.outMod->SetVolume(volume); } - static void __cdecl setpan(int pan) { mod.outMod->SetPan(pan); } - static void __cdecl config(HWND hwnd) - { - winamp_config_dialog(mod.hMainWindow, hwnd); - } - static void __cdecl about(HWND hwnd) { MessageBoxA(hwnd, WINAMPPLUGIN_COPYRIGHT , WINAMPPLUGIN_NAME, MB_OK); } - static int __cdecl infobox(const in_char *fn, HWND hwnd) - { - try - { - /* This function is obsolete in Winamp5. */ - /* Current version of 'in_zip.dll' and XMPlay cannot handle 'winampUseUnifiedFileInfoDlg' function. */ - xsfc::TAutoBuffer idata = xsfc::TWin32::Map(xsfc::TString(fn)); - if (idata.Ptr()) - { - int futf8 = XSFTag::Exists("utf8", idata.Ptr(), idata.Len()); - xsfc::TString tag = TagReader::XSFTagGetMulti(idata, 0, XSF_TAG_TYPE_ALL); - if (tag[0]) - { -#ifdef UNICODE_INPUT_PLUGIN - MessageBoxW(hwnd, tag, xsfc::TWin32T::ExtractFilename(fn), MB_OK); -#else - MessageBoxA(hwnd, xsfc::TStringM(tag), xsfc::TWin32T::ExtractFilename(fn), MB_OK); -#endif - return 1; - } - } - } - catch (xsfc::EShortOfMemory ex) - { - } - return 0; - } - static int __cdecl isourfile(const in_char *fn) { return 0; } - static void __cdecl eq_set(int on, char data[10], int preamp) {} - static int __cdecl ispaused(void) { return m_paused; } - static int __cdecl getlength(void) { return xsfdrv.length_in_ms + xsfdrv.fade_in_ms; } - static void __cdecl setoutputtime(int time_in_ms) - { - xsfdrv.seek_kil = 1; - if (time_in_ms) - { - xsfdrv.seek_pos = time_in_ms; - Request(REQUEST_SEEK); - } - else - { - Request(REQUEST_RESTART); - } - } - -}; - -XSFDriver WinampPlugin::xsfdrv; -HMODULE WinampPlugin::m_hDLL = 0; -HANDLE WinampPlugin::m_hThread = 0; -HANDLE WinampPlugin::m_hEvent = 0; -volatile LONG WinampPlugin::m_lRequest = 0; -int WinampPlugin::m_paused = 0; -in_char WinampPlugin::m_title[GETFILEINFO_TITLE_LENGTH]; -HANDLE WinampPlugin::m_hFindWindowThread = 0; - -In_Module WinampPlugin::mod = -{ - IN_VER, - WINAMPPLUGIN_NAME, - 0, /* hMainWindow */ - 0, /* hDllInstance */ - WINAMPPLUGIN_EXTS, - 1, /* is_seekable */ - 1, /* UsesOutputPlug */ - WinampPlugin::config, - WinampPlugin::about, - WinampPlugin::init, - WinampPlugin::quit, - WinampPlugin::getfileinfo, - WinampPlugin::infobox, - WinampPlugin::isourfile, - WinampPlugin::play, - WinampPlugin::pause, - WinampPlugin::unpause, - WinampPlugin::ispaused, - WinampPlugin::stop, - - WinampPlugin::getlength, - WinampPlugin::getoutputtime, - WinampPlugin::setoutputtime, - WinampPlugin::setvolume, - WinampPlugin::setpan, - - /* pointers filled in by winamp */ - 0,0,0,0,0,0,0,0,0, /* vis stuff */ - 0,0, /* dsp */ - - WinampPlugin::eq_set, /* EQ, not used */ - NULL, /* setinfo */ - 0 /* out_mod */ -}; - - -extern "C" In_Module * __cdecl winampGetInModule2(void) -{ - return &WinampPlugin::mod; -} - -#if ENABLE_GETEXTENDINFO -extern "C" int __cdecl winampGetExtendedFileInfo(char *filename, char *metadata, char *ret, int retlen) -{ - int e = EXINFO_NOT_SUPPORTED; - try - { - xsfc::TAutoBuffer idata; - WinampPlugin::ConfigInit(); - if (filename && *filename && TagReader::getfinfo_map(idata, xsfc::TString(filename))) - { - TagReader::TagReturn result(ret, retlen); - e = TagReader::getfinfo(idata, metadata, result); -// if (ret && retlen > 0 && !ret[0] && !strcmp(metadata, "title")) -// { -// mstrncpychk(ret, xsfc::TWin32T::ExtractFilename(filename), retlen); -// e = EXINFO_SUPPORTED; -// } - } - else if (!strcmp(metadata, "type")) - { - if (retlen > 0) ret[0] = '0'; - if (retlen > 1) ret[1] = 0; - e = EXINFO_SUPPORTED; - } - } - catch (xsfc::EShortOfMemory ex) - { - } - return e; -} -#endif - -#if ENABLE_GETEXTENDINFOW -extern "C" int __cdecl winampGetExtendedFileInfoW(WCHAR *filename, char *metadata, WCHAR *ret, int retlen) -{ - int e = EXINFO_NOT_SUPPORTED; - try - { - xsfc::TAutoBuffer idata; - WinampPlugin::ConfigInit(); - if (filename && *filename && TagReader::getfinfo_map(idata, filename)) - { - TagReader::TagReturn result(ret, retlen); - e = TagReader::getfinfo(idata, metadata, result); -// if (ret && retlen > 0 && !ret[0] && !strcmp(metadata, "title")) -// { -// wstrncpychk(ret, xsfc::TWin32T::ExtractFilename(filename), retlen); -// e = EXINFO_SUPPORTED; -// } - } - else if (!strcmp(metadata, "type")) - { - if (retlen > 0) ret[0] = L'0'; - if (retlen > 1) ret[1] = 0; - e = EXINFO_SUPPORTED; - } - } - catch (xsfc::EShortOfMemory ex) - { - } - return e; -} -#endif - -#if ENABLE_TAGWRITER - -class TagWriter -{ -protected: - - class tagwriternode - { - public: - class tagwriternode *pnext; - xsfc::TStringM tag; - xsfc::TStringM valueu8; - - tagwriternode() throw() - : pnext(0) - { - } - ~tagwriternode() - { - } - - static tagwriternode *get_node(tagwriternode *ptop, const char *tag) - { - tagwriternode *pcur = ptop; - while (pcur) - { - tagwriternode *pnext = pcur->pnext; - if (pcur->tag && !strcmp(pcur->tag, tag)) - break; - pcur = pnext; - } - return pcur; - } - }; - - class tagwriterfile - { - public: - xsfc::TStringM filenameu8; - tagwriternode *ptop; - tagwriterfile() throw() - : ptop(0) - { - } - ~tagwriterfile() - { - tagwriternode *pcur = ptop; - while (pcur) - { - tagwriternode *pnext = pcur->pnext; - delete pcur; - pcur = pnext; - } - } - }; - - static tagwriterfile * volatile ptarget; - static CRITICAL_SECTION cs; - - static tagwriterfile *GetTarget(tagwriterfile *pnewtarget) - { - tagwriterfile *poldtarget; - ::EnterCriticalSection(&cs); - poldtarget = ptarget; - ptarget = pnewtarget; - ::LeaveCriticalSection(&cs); - return poldtarget; - } - - static void FreeFile(tagwriterfile *pfile) - { - if (pfile) - { - delete pfile; - } - } - TagWriter() - { - } - ~TagWriter() - { - } - - static xsfc::TStringM Get(tagwriternode *ptop, xsfc::TAutoBuffer idata, const char *tag) - { - tagwriternode *pnode = tagwriternode::get_node(ptop, tag); - xsfc::TStringM valueu8; - if (pnode) - valueu8 = pnode->valueu8; - else - { - TagReader::TagReturn result; - TagReader::getfinfo(idata, tag, result); - valueu8 = xsfc::TStringM(true, result.Get()); - } - return valueu8; - } - - static void WriteSingle(HANDLE h, bool futf8, const char *pname, unsigned uname, const char *pvalue, unsigned uvalue) - { - if (uname && uvalue) - { - DWORD dwNumberOfByteWritten; - if (futf8) - { - WriteFile(h, pname, uname, &dwNumberOfByteWritten, NULL); - WriteFile(h, "=", 1, &dwNumberOfByteWritten, NULL); - WriteFile(h, pvalue, uvalue, &dwNumberOfByteWritten, NULL); - WriteFile(h, "\x0a", 1, &dwNumberOfByteWritten, NULL); - } - else - { - xsfc::TStringM name(xsfc::TString(true, pname, uname)); - xsfc::TStringM value(xsfc::TString(true, pvalue, uvalue)); - WriteFile(h, name, strlen(name), &dwNumberOfByteWritten, NULL); - WriteFile(h, "=", 1, &dwNumberOfByteWritten, NULL); - WriteFile(h, value, strlen(value), &dwNumberOfByteWritten, NULL); - WriteFile(h, "\x0a", 1, &dwNumberOfByteWritten, NULL); - } - } - } - - static const char *Split(const char *p) - { - int l; - for (l = 0; p[l]; l++) - { - if (p[l + 0] == ' ' && p[l + 1] == ';' && p[l + 2] == ' ') - break; - } - return p + l; - } - - static void WriteMulti(HANDLE h, bool futf8, const char *tag, const char *value) - { - int taglen = strlen(tag); - if (!value) return; - do - { - const char *top = value; - value = Split(value); - WriteSingle(h, futf8, tag, taglen, top, value-top); - if (*value) value += 3; - } while (*value); - } - - typedef struct - { - HANDLE h; - bool futf8; - char ignoresystemtag; - } writetagmultiline_work_t; - - static XSFTag::enum_callback_returnvalue tagwriter_wmlcb(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - writetagmultiline_work_t *pwork = static_cast(pWork); - if (pwork->ignoresystemtag && XSFDRIVER_ISSYSTEMTAG(pNameEnd - pNameTop, pNameTop)) - return XSFTag::enum_continue; - WriteSingle(pwork->h, pwork->futf8, pNameTop, pNameEnd-pNameTop, pValueTop, pValueEnd-pValueTop); - return XSFTag::enum_continue; - } - - static void WriteMultiLine(HANDLE h, bool futf8, const char *value) - { - writetagmultiline_work_t cbw; - cbw.h = h; - cbw.futf8 = futf8; - cbw.ignoresystemtag = 1; - if (!value) return; - XSFTag::EnumRaw(tagwriter_wmlcb, &cbw, value, strlen(value)); - } - - static void WriteSysMultiLine(HANDLE h, bool futf8, const char *value) - { - writetagmultiline_work_t cbw; - cbw.h = h; - cbw.futf8 = futf8; - cbw.ignoresystemtag = 0; - if (!value) return; - XSFTag::EnumRaw(tagwriter_wmlcb, &cbw, value, strlen(value)); - } - - static int WriteAll(HANDLE h, tagwriternode *ptop, xsfc::TAutoBuffer idata) - { - const char * const *ptbl; - bool futf8 = false; - xsfc::TStringM comment = Get(ptop, idata, "comment"); - xsfc::TStringM formatinformation = Get(0, idata, "formatinformation"); - xsfc::TString utf8 = XSFTag::GetRaw("utf8", comment.GetM(), strlen(comment)); - if (utf8[0]) futf8 = true; - if (formatinformation[0]) - WriteSysMultiLine(h, futf8, formatinformation); - if (comment[0]) - WriteMultiLine(h, futf8, comment); - for (ptbl = tag_table; ptbl[0]; ptbl += 2) - { - if (!ptbl[1]) - continue; - if ('\x00' < ptbl[1][0] && ptbl[1][0] <= '\x05') - continue; - WriteMulti(h, futf8, ptbl[1], Get(ptop, idata, ptbl[0])); - } - return EXINFO_SUPPORTED; - } - - static xsfc::TString fnextend(const wchar_t *fn) - { - if (fn && fn[0] == L'\\' && fn[1] == L'\\' && fn[2] != L'?') - return xsfc::TString("\\\\?\\UNC") + (fn + 1); - if (fn && fn[0] && fn[1] == L':' && fn[2] == L'\\') - return xsfc::TString("\\\\?\\") + fn; - return xsfc::TString(); - } - - static HANDLE createfileW(const WCHAR *fn) - { - HANDLE h = INVALID_HANDLE_VALUE; - if (xsfc::TWin32::IsUnicodeSupportedOS()) - { - xsfc::TString fnw = fnextend(fn); - h = CreateFileW(fnw[0] ? fnw : fn, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - } - else - { - h = CreateFileA(xsfc::TStringM(fn), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - } - return h; - } - - static int WriteTarget(tagwriterfile *pfile) - { - int e = EXINFO_NOT_SUPPORTED; - if (pfile && pfile->filenameu8 && pfile->ptop) - { - xsfc::TString fnw(true, pfile->filenameu8); - xsfc::TAutoBuffer idata = xsfc::TWin32::Map(fnw); - if (idata.Ptr()) - { - DWORD dwTagOffset = XSFTag::SearchRaw(idata.Ptr(), idata.Len()); - if (dwTagOffset) - { - HANDLE h = createfileW(fnw); - if (h != INVALID_HANDLE_VALUE) - { - DWORD dwNumberOfByteWritten; - WriteFile(h, idata.Ptr(), dwTagOffset, &dwNumberOfByteWritten, NULL); - WriteFile(h, "[TAG]", 5, &dwNumberOfByteWritten, NULL); - e = WriteAll(h, pfile->ptop, idata); - ::CloseHandle(h); - } - } - } - } - return e; - } - -public: - static int Write() - { - int e = EXINFO_NOT_SUPPORTED; - tagwriterfile *ptarget = GetTarget(0); - if (ptarget) - { - e = WriteTarget(ptarget); - FreeFile(ptarget); - } - return e; - } - - static int SetFInfo(xsfc::TStringM filenameu8, xsfc::TStringM tag, xsfc::TStringM valueu8) - { - tagwriterfile *pfile = GetTarget(0); - if (pfile) - { - if (strcmp(pfile->filenameu8, filenameu8)) - { - FreeFile(pfile); - pfile = 0; - } - } - if (!pfile) - { - pfile = new(xsfc::nothrow) tagwriterfile; - if (pfile) - { - pfile->filenameu8 = filenameu8; - pfile->ptop = 0; - } - } - - if (pfile) - { - tagwriternode *pnode = tagwriternode::get_node(pfile->ptop, tag); - if (!pnode) - { - pnode = new(xsfc::nothrow) tagwriternode; - if (pnode) - { - pnode->pnext = pfile->ptop; - pnode->tag = tag; - pfile->ptop = pnode; - } - } - if (pnode) - { - if (strcmp(pnode->valueu8, valueu8)) - pnode->valueu8 = valueu8; - } - } - - pfile = GetTarget(pfile); - FreeFile(pfile); - return EXINFO_SUPPORTED; - } - - static void Init() - { - ptarget = 0; - ::InitializeCriticalSection(&cs); - } - static void Term() - { - FreeFile(GetTarget(0)); - ::DeleteCriticalSection(&cs); - } -}; - -TagWriter::tagwriterfile * volatile TagWriter::ptarget = 0; -CRITICAL_SECTION TagWriter::cs; - -extern "C" int __cdecl winampSetExtendedFileInfo(char *filename,char *metadata,char *ret,int retlen) -{ - try - { - xsfc::TStringM fnu8(true, xsfc::TString(filename)); - xsfc::TStringM tgu8(true, xsfc::TString(metadata)); - xsfc::TStringM tvu8(true, xsfc::TString(ret)); - return TagWriter::SetFInfo(fnu8, tgu8, tvu8); - } - catch (xsfc::EShortOfMemory ex) - { - } - return EXINFO_NOT_SUPPORTED; -} -extern "C" int __cdecl winampSetExtendedFileInfoW(WCHAR *filename,char *metadata,WCHAR *ret,int retlen) -{ - try - { - xsfc::TStringM fnu8(true, filename); - xsfc::TStringM tgu8(true, xsfc::TString(metadata)); - xsfc::TStringM tvu8(true, ret); - return TagWriter::SetFInfo(fnu8, tgu8, tvu8); - } - catch (xsfc::EShortOfMemory ex) - { - } - return EXINFO_NOT_SUPPORTED; -} -extern "C" int __cdecl winampWriteExtendedFileInfo(void) -{ - try - { - return TagWriter::Write(); - } - catch (xsfc::EShortOfMemory ex) - { - } - return EXINFO_NOT_SUPPORTED; -} -#endif - -#if ENABLE_GETEXTENDINFO || ENABLE_GETEXTENDINFOW || ENABLE_TAGWRITER -/* - return 1 if you want winamp to show it's own file info dialogue, 0 if you want to show your own (via In_Module.InfoBox) - if returning 1, remember to implement winampGetExtendedFileInfo("formatinformation")! -*/ -extern "C" int __cdecl winampUseUnifiedFileInfoDlg(const wchar_t * fn) -{ - return EXINFO_SUPPORTED; -} -/* - should return a child window of 513x271 pixels (341x164 in msvc dlg units), or return NULL for no tab. - Fill in name (a buffer of namelen characters), this is the title of the tab (defaults to "Advanced"). - filename will be valid for the life of your window. n is the tab number. This function will first be - called with n == 0, then n == 1 and so on until you return NULL (so you can add as many tabs as you like). - The window you return will recieve WM_COMMAND, IDOK/IDCANCEL messages when the user clicks OK or Cancel. - when the user edits a field which is duplicated in another pane, do a SendMessage(GetParent(hwnd),WM_USER,(WPARAM)L"fieldname",(LPARAM)L"newvalue"); - this will be broadcast to all panes (including yours) as a WM_USER. -*/ -extern "C" HWND __cdecl winampAddUnifiedFileInfoPane(int n, const wchar_t * filename, HWND parent, wchar_t *name, size_t namelen) -{ - return NULL; -} -#endif - -#if ENABLE_EXTENDREADER -static void * __cdecl winampGetExtendedRead_opensub(xsfc::TString fn, int *size, int *bps, int *nch, int *srate) -{ - try - { - xsfc::TAutoPtr pDrv(new(xsfc::nothrow) XSFDriver); - if (!pDrv) - return NULL; - if (!pDrv->Init(WinampPlugin::ConfigInit()) || !pDrv->Load(fn)) - { - pDrv->Free(); - return NULL; - } - pDrv->Start(); - if (size) *size = (pDrv->len_smp + pDrv->fad_smp) << pDrv->blockshift; - if (bps) *bps = pDrv->samplebits; - if (nch) *nch = pDrv->ch; - if (srate) *srate = pDrv->samplerate; - return pDrv.Detach(); - } - catch (xsfc::EShortOfMemory ex) - { - } - return NULL; -} -extern "C" void * __cdecl winampGetExtendedRead_openW(const wchar_t *fn, int *size, int *bps, int *nch, int *srate) -{ - return winampGetExtendedRead_opensub(xsfc::TString(fn), size, bps, nch, srate); -} -extern "C" void * __cdecl winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate) -{ - return winampGetExtendedRead_opensub(xsfc::TString(fn), size, bps, nch, srate); -} -static int winampGetExtendedRead_getData_seeksub(XSFDriver *pDrv, unsigned seek_pos, volatile int *killswitch) -{ - char buf[576 * 4]; - return pDrv->Seek(seek_pos, killswitch, buf, sizeof(buf), 0); -} - -extern "C" int __cdecl winampGetExtendedRead_getData(void *handle, char *dest, int len, volatile int *killswitch) -{ - try - { - XSFDriver *pDrv = static_cast(handle); - const int block = 576 * 4; - int genlen = 0; - int endflag = 0; - if (!pDrv) - return 0; - if (pDrv->seek_req) - { - unsigned seek_pos = pDrv->seek_pos; - pDrv->seek_req = 0; - if (winampGetExtendedRead_getData_seeksub(pDrv, seek_pos, killswitch)) - return genlen; - } - while (genlen < len && !endflag) - { - unsigned writebytes; - endflag = pDrv->FillBuffer(dest + genlen, ((len - genlen) > block) ? block : (len - genlen), &writebytes, 1); - genlen += writebytes; - if (killswitch && *killswitch) - break; - } - return genlen; - } - catch (xsfc::EShortOfMemory ex) - { - } - return 0; -} -extern "C" int __cdecl winampGetExtendedRead_setTime(void *handle, int millisecs) -{ - try - { - XSFDriver *pDrv = static_cast(handle); - if (pDrv) - { - pDrv->seek_pos = millisecs; - pDrv->seek_req = 1; - return 1; - } - } - catch (xsfc::EShortOfMemory ex) - { - } - return 0; -} -extern "C" void __cdecl winampGetExtendedRead_close(void *handle) -{ - try - { - XSFDriver *pDrv = static_cast(handle); - if (pDrv) - { - pDrv->Free(); - delete pDrv; - } - } - catch (xsfc::EShortOfMemory ex) - { - } -} -#endif - -} - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { - try - { -#if defined(_MSC_VER) && defined(_DEBUG) - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF); -#endif - WinampPlugin::Init(hinstDLL); - winamp_config_init(hinstDLL); -#if ENABLE_TAGWRITER - TagWriter::Init(); -#endif - DisableThreadLibraryCalls(hinstDLL); - } - catch (xsfc::EShortOfMemory ex) - { - return FALSE; - } - } - else if (fdwReason == DLL_PROCESS_DETACH) - { -#if ENABLE_TAGWRITER - try - { - TagWriter::Term(); - } - catch (xsfc::EShortOfMemory ex) - { - } -#endif - } - return TRUE; -} - diff --git a/tools/vio2sf/src/xsfc/in_xsfcfg.cpp b/tools/vio2sf/src/xsfc/in_xsfcfg.cpp deleted file mode 100644 index 3c51a24f1..000000000 --- a/tools/vio2sf/src/xsfc/in_xsfcfg.cpp +++ /dev/null @@ -1,712 +0,0 @@ -#define WIN32_LEAN_AND_MEAN -#include "leakchk.h" - -#include -#include -#include -#include - -/* Winamp SDK headers */ -#include - -#include "../pversion.h" -#include "in_xsfcfg.h" -#include "xsfui.rh" - -#if _MSC_VER >= 1200 -#pragma warning(disable:4290) -#endif - -extern unsigned long dwInterpolation; - -namespace -{ - -xsfc::TAutoPtr pcfg; -prefsDlgRec prefwork; -int prefreg = 0; -HMODULE hDLL = 0; - -} - -class IniConfig : public IConfigIO -{ - xsfc::TString sIniPath; -protected: - IniConfig() throw() - { - } - - bool Initialize(HWND hwndWinamp) throw(xsfc::EShortOfMemory) - { - char *ini = (char *)(::SendMessageA(hwndWinamp, WM_WA_IPC, 0, IPC_GETINIFILE)); - if (ini && int(ini) != 1 && !IsBadStringPtrA(ini, MAX_PATH)) - sIniPath = xsfc::TString(ini); - else - sIniPath = xsfc::TWin32::ExtractPath(xsfc::TWin32::ModulePath(NULL)) + "winamp.ini"; - return true; - } - -public: - ~IniConfig() throw() - { - } - - void SetULong(const wchar_t *name, const unsigned long value) throw() - { - try - { - xsfc::TWin32::SetPrivateProfile(sIniPath, xsfc::TString(XSFDRIVER_SIMPLENAME), name, xsfc::TString(value)); - } - catch (xsfc::EShortOfMemory e) - { - } - } - unsigned long GetULong(const wchar_t *name, const unsigned long defaultvalue = 0) throw() - { - try - { - xsfc::TString value = xsfc::TWin32::GetPrivateProfile(sIniPath, xsfc::TString(XSFDRIVER_SIMPLENAME), name, xsfc::TString(defaultvalue)); - if (value[0]) return value.GetULong(); - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } - void SetFloat(const wchar_t *name, const double value) throw() - { - try - { - xsfc::TWin32::SetPrivateProfile(sIniPath, xsfc::TString(XSFDRIVER_SIMPLENAME), name, xsfc::TString(value)); - } - catch (xsfc::EShortOfMemory e) - { - } - } - double GetFloat(const wchar_t *name, const double defaultvalue = 0) throw() - { - try - { - xsfc::TString value = xsfc::TWin32::GetPrivateProfile(sIniPath, xsfc::TString(XSFDRIVER_SIMPLENAME), name, xsfc::TString(defaultvalue)); - if (value[0]) return value.GetFloat(); - } - catch (xsfc::EShortOfMemory e) - { - } - return defaultvalue; - } - void SetString(const wchar_t *name, const wchar_t *value) throw() - { - try - { - xsfc::TWin32::SetPrivateProfile(sIniPath, xsfc::TString(XSFDRIVER_SIMPLENAME), name, value); - } - catch (xsfc::EShortOfMemory e) - { - } - } - xsfc::TString GetString(const wchar_t *name, const wchar_t *defaultvalue = 0) throw(xsfc::EShortOfMemory) - { - return xsfc::TWin32::GetPrivateProfile(sIniPath, xsfc::TString(XSFDRIVER_SIMPLENAME), name, defaultvalue); - } - - static LPIConfigIO Create(HWND hwndWinamp) throw(xsfc::EShortOfMemory) - { - xsfc::TAutoPtr cfg(new(xsfc::nothrow) IniConfig); - return (cfg && cfg->Initialize(hwndWinamp)) ? cfg.Detach() : 0; - } -}; - -static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDC_COMBO_INTERPOLATION: - if (GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE) - { - dwInterpolation = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_COMBO_INTERPOLATION)); - } - break; - case IDOK: - CFGUpdate(pcfg, hwndDlg); - CFGSave(pcfg); - ::EndDialog(hwndDlg, IDOK); - break; - case IDCANCEL: - ::EndDialog(hwndDlg, IDCANCEL); - break; - case 0x206: - if (GET_WM_COMMAND_CMD(wParam, lParam) == LBN_SELCHANGE) - { - CFGMuteChange(hwndDlg, 0x206); - } - break; - default: - return FALSE; - } - break; - case WM_INITDIALOG: - ::SetWindowTextA(hwndDlg, WINAMPPLUGIN_NAME); - ::ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_SHOWNA); - ::ShowWindow(GetDlgItem(hwndDlg, IDCANCEL), SW_SHOWNA); - CFGLoad(pcfg); - CFGReset(pcfg, hwndDlg); - return TRUE; - } - return FALSE; -} - - -int msgBox(TCHAR* stringFormat, ...) -{ - va_list valist; - va_start( valist, stringFormat); - TCHAR msgPassed[2000]; - StringCbVPrintf(msgPassed, sizeof(msgPassed), stringFormat, valist); - return MessageBox(NULL, msgPassed, "msgBox", MB_OK | MB_SYSTEMMODAL); -} -BOOL vsSetDlgItemText(HWND hDlg, int nIDDlgItem, TCHAR* stringFormat, ...) -{ - va_list valist; - va_start( valist, stringFormat); - TCHAR msgPassed[2000]; - StringCbVPrintf(msgPassed, sizeof(msgPassed), stringFormat, valist); - return SetDlgItemText(hDlg, nIDDlgItem, msgPassed); -} -unsigned long GetDlgItemHex(HWND wnd, UINT wndMsg) -{ - TCHAR read[20]; unsigned long res; - GetDlgItemText(wnd, wndMsg, read, sizeof(read)/sizeof(TCHAR)); - size_t len; StringCbLength(read, sizeof(read), &len); - if (len>=1) sscanf_s(read, "%X", &res); else res=0; - return res; -} - -HWND dlgInstrumentSelection=0; -HWND dlgMixerInstrument[50]; - -BOOL isInstrumentSelectionActive() -{ - return (dlgInstrumentSelection != 0); -} - -class Instrument -{ -public: - unsigned long addr; - int type; - BOOL selectedStatus; - BOOL muteStatus; - unsigned long volume; - TCHAR name[100]; -}; -Instrument instrument[50]; -int nbInstruments=0; - -TCHAR* getInstrumentName(unsigned long addr) -{ - for (int i=0; i= 50) return; - - while (semaphore != 0) Sleep(0); /* thread safety (exchangeInstruments) */ - - for (int i=0; i= SendDlgItemMessage(dlg, IDC_LISTINSTRUMENTS, LB_GETCOUNT , 0, 0)-1) break; - unsigned long addr1 = SendDlgItemMessage(dlg, IDC_LISTINSTRUMENTS, LB_GETITEMDATA, currentInstrumentIndex, 0); - unsigned long addr2 = SendDlgItemMessage(dlg, IDC_LISTINSTRUMENTS, LB_GETITEMDATA, currentInstrumentIndex+1, 0); - exchangeInstruments(addr1, addr2); - updateInstrumentListbox(dlg); - SendDlgItemMessage(dlg, IDC_LISTINSTRUMENTS, LB_SETCARETINDEX, currentInstrumentIndex+1, TRUE); - } - break; - - case IDOK: - { - updateInstrumentListbox(dlg); - int index = searchInstrument(dlg, GetDlgItemHex(dlg, IDC_EDIT_ADDRESSSEARCH)); - if (index != -1) - { - SendDlgItemMessage(dlg, IDC_LISTINSTRUMENTS, LB_SETCARETINDEX, index, TRUE); - SendMessage(dlg, WM_COMMAND, MAKEWPARAM(IDC_LISTINSTRUMENTS, LBN_DBLCLK), (LPARAM)GetDlgItem(dlg, IDC_LISTINSTRUMENTS)); - } - else MessageBeep(MB_ICONEXCLAMATION); - } - break; - - default: return FALSE; - } - break; - - case WM_CLOSE: DestroyWindow(dlg); - return TRUE; - case WM_DESTROY: dlgInstrumentSelection = 0; - return TRUE; - } - return FALSE; -} - -static BOOL CALLBACK DialogProcPref(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static bool initialized = false; - switch (uMsg) - { - case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) - { - case IDC_BUTTON_VIEWSPU: - if(soundViewCallbacks.doOpenSoundView) soundViewCallbacks.doOpenSoundView(hDLL); - break; - - case IDC_BUTTON_INSTRUMENTSELECTION: - if (HIWORD(wParam)==BN_CLICKED) - { - if (dlgInstrumentSelection == 0) - { - dlgInstrumentSelection=CreateDialog(hDLL, MAKEINTRESOURCE(IDD_INSTRUMENTDLG), hwndDlg, (DLGPROC)dlgProcInstrumentSelection); - if (dlgInstrumentSelection==0) MessageBeep(MB_ICONEXCLAMATION); - ShowWindow(dlgInstrumentSelection, SW_SHOW); - } - else - { - HWND tmp=dlgInstrumentSelection; /* thread safety (PostMessage in addInstrument) */ - dlgInstrumentSelection=0; - DestroyWindow(tmp); - } - } - break; - - case IDC_COMBO_INTERPOLATION: - if (GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE) - { - dwInterpolation = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_COMBO_INTERPOLATION)); - CFGSave(pcfg); - } - break; - - case 0x200: case 0x201: case 0x202: - case 0x203: case 0x204: case 0x205: - if (initialized) - { - CFGUpdate(pcfg, hwndDlg); - CFGSave(pcfg); - } - break; - case 0x206: - if (GET_WM_COMMAND_CMD(wParam, lParam) == LBN_SELCHANGE) - { - CFGMuteChange(hwndDlg, 0x206); - } - break; - default: - return FALSE; - } - break; - case WM_INITDIALOG: - initialized = false; - CFGLoad(pcfg); - CFGReset(pcfg, hwndDlg); - initialized = true; - return TRUE; - } - return FALSE; -} - -void winamp_config_init(HINSTANCE hinstDLL) -{ - hDLL = hinstDLL; -} -void winamp_config_load(HWND hwndWinamp) -{ - if (!pcfg) - { - pcfg = IniConfig::Create(hwndWinamp); - if (!pcfg) pcfg = NullConfig::Create(); - CFGLoad(pcfg); - } -} - - -void winamp_config_add_prefs(HWND hwndWinamp) -{ - if (prefreg) return; - - if (((LONG)xsfc::TWin32::WndMsgSend(hwndWinamp, WM_WA_IPC, 0, IPC_GETVERSION) & 0xffffU) >= 0x2090) - { - /* 2.9+ */ - prefwork.hInst = hDLL; - prefwork.dlgID = 1; - prefwork.proc = (void *)DialogProcPref; - prefwork.name = XSFDRIVER_SIMPLENAME; - prefwork.where = 0; - prefwork._id = 0; - prefwork.next = 0; - prefreg = !(LONG)xsfc::TWin32::WndMsgSend(hwndWinamp, WM_WA_IPC, &prefwork, IPC_ADD_PREFS_DLG); - } -} - -void winamp_config_remove_prefs(HWND hwndWinamp) -{ - - if (pcfg) pcfg.Release(); - if (prefreg) - { - xsfc::TWin32::WndMsgSend(hwndWinamp, WM_WA_IPC, &prefwork, IPC_REMOVE_PREFS_DLG); - prefreg = 0; - } -} - -void winamp_config_dialog(HWND hwndWinamp, HWND hwndParent) -{ - HRSRC hrsrc; - DWORD dwSize; - HGLOBAL hGlobal; - xsfc::TSimpleArray resbuf; - if (prefreg) - { - if (((LONG)xsfc::TWin32::WndMsgSend(hwndWinamp, WM_WA_IPC, 0, IPC_GETVERSION) & 0xffffU) >= 0x5000) - { - xsfc::TWin32::WndMsgSend(hwndWinamp, WM_WA_IPC, &prefwork, IPC_OPENPREFSTOPAGE); - return; - } - } - - hrsrc = ::FindResourceA(hDLL, MAKEINTRESOURCE(1), RT_DIALOG); - if (!hrsrc) return; - - dwSize = ::SizeofResource(hDLL, hrsrc); - hGlobal = ::LoadResource(hDLL, hrsrc); - - if (dwSize < 4 || !hGlobal) return; - - if (!resbuf.Resize(dwSize)) return; - - LPBYTE lpResource = resbuf.Ptr(); - - ::CopyMemory(lpResource, hGlobal, dwSize); - - lpResource[0] = '\xc0'; - lpResource[1] = '\x08'; - lpResource[2] = '\xc8'; - lpResource[3] = '\x80'; - - xsfc::TWin32::DlgInvoke(::GetModuleHandleA(NULL), lpResource, NULL, DialogProc, NULL); -} \ No newline at end of file diff --git a/tools/vio2sf/src/xsfc/in_xsfcfg.h b/tools/vio2sf/src/xsfc/in_xsfcfg.h deleted file mode 100644 index 1ca08a3bc..000000000 --- a/tools/vio2sf/src/xsfc/in_xsfcfg.h +++ /dev/null @@ -1,23 +0,0 @@ -#include "xsfcfg.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -void winamp_config_init(HINSTANCE hinstDLL); -void winamp_config_load(HWND hwndWinamp); -void winamp_config_add_prefs(HWND hwndWinamp); -void winamp_config_remove_prefs(HWND hwndWinamp); -void winamp_config_dialog(HWND hwndWinamp, HWND hwndParent); - -void addInstrument(unsigned long addr, int type); -BOOL isInstrumentMuted(unsigned long addr); -unsigned long getInstrumentVolume(unsigned long addr); -BOOL isInstrumentSelectionActive(); -void openSoundView(void* callback); - -#ifdef __cplusplus -} -#endif - diff --git a/tools/vio2sf/src/xsfc/kpixsf.c b/tools/vio2sf/src/xsfc/kpixsf.c deleted file mode 100644 index 6f9bbdb2d..000000000 --- a/tools/vio2sf/src/xsfc/kpixsf.c +++ /dev/null @@ -1,353 +0,0 @@ -#define STRICT -#define WIN32_LEAN_AND_MEAN -#include "leakchk.h" - -#include -#include -#include -#include - -#include "../kobarin/kmp_pi.h" - -#include "xsfdrv.h" - -#include "../pversion.h" -#include "tagget.h" - -#ifndef ENABLE_LOADPE -#if !defined(_DEBUG) -#define ENABLE_LOADPE 1 -#else -#define ENABLE_LOADPE 0 -#endif -#endif - -#if ENABLE_LOADPE -#include "../loadpe/loadpe.h" -#else -#define XLoadLibraryA LoadLibraryA -#define XLoadLibraryW LoadLibraryW -#define XGetProcAddress GetProcAddress -#define XFreeLibrary FreeLibrary -#endif - -#if _MSC_VER >= 1200 -#pragma comment(linker, "/EXPORT:kmp_GetTestModule=_kmp_GetTestModule@0") -#endif - -#if defined(_MSC_VER) && !defined(_DEBUG) -#pragma comment(linker,"/MERGE:.rdata=.text") -#endif - -static HMODULE hDLL = 0; -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - (void)lpvReserved; - if (fdwReason == DLL_PROCESS_ATTACH) - { -#if defined(_MSC_VER) && defined(_DEBUG) - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF); -#endif - hDLL = hinstDLL; - DisableThreadLibraryCalls(hinstDLL); - } - return TRUE; -} - -typedef struct { - char sBasepath[MAX_PATH]; - HMODULE hDrv; - IXSFDRV *lpif; - int bTop; - int bVolume; - float fVolume; - DWORD dwFileLen; - BYTE bFileBuf[4]; -} KMP; - - -static void *loadfileA(const char *fn, unsigned *plength) -{ - void *ret = NULL; - HANDLE h = CreateFileA(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (h != INVALID_HANDLE_VALUE) - { - unsigned length; - void *buf; - length = GetFileSize(h, NULL); - buf = malloc(length); - if (buf) - { - DWORD dwNumberOfBytesRead; - ReadFile(h, buf, length, &dwNumberOfBytesRead, NULL); - ret = buf; - if (plength) *plength = length; - } - CloseHandle(h); - } - return ret; -} - - -static int PASCAL XSFGETLIBCALLBACK(void *lpWork, LPSTR lpszFilename, void **ppBuffer, DWORD *pdwSize) -{ - DWORD dwNumberOfBytesRead; - void *filebuf; - DWORD size; - KMP *p = lpWork; - - HANDLE h = CreateFileA(lpszFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (h == INVALID_HANDLE_VALUE) - { - char sCanPath[MAX_PATH]; - char sExtPath[MAX_PATH]; - if (lstrlenA(p->sBasepath) + lstrlenA(lpszFilename) + 1 >= MAX_PATH) - { - return 1; - } - lstrcpyA(sExtPath, p->sBasepath); - lstrcatA(sExtPath, lpszFilename); - if (!PathCanonicalizeA(sCanPath, sExtPath)) - lstrcpyA(sCanPath, sExtPath); - h = CreateFileA(sCanPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (h == INVALID_HANDLE_VALUE) - { - lstrcpyA(sExtPath, p->sBasepath); - lstrcatA(sExtPath, PathFindFileNameA(lpszFilename)); - if (!PathCanonicalizeA(sCanPath, sExtPath)) - lstrcpyA(sCanPath, sExtPath); - h = CreateFileA(sCanPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (h == INVALID_HANDLE_VALUE) - { - return 1; - } - } - } - - size = GetFileSize(h, NULL); - - filebuf = p->lpif->LibAlloc(size); - - if (!filebuf) - { - CloseHandle(h); - return 1; - } - - ReadFile(h, filebuf, size, &dwNumberOfBytesRead, NULL); - CloseHandle(h); - - *ppBuffer = filebuf; - *pdwSize = size; - - return 0; -} - - -static HKMP WINAPI OpenFromBufferSub(const char *cszFileName, const BYTE *Buffer, DWORD dwSize, SOUNDINFO *pInfo) -{ - HKMP ret = NULL; - KMP *p; - LPFNXSFDRVSETUP lpfnXSFSetup; - LPSTR lpFilePart; - char *taglength; - char *tagvolume; - DWORD dwLength; - - CHAR dllpath[MAX_PATH]; - CHAR binpath[MAX_PATH]; - - if (!pInfo) return ret; - p = (KMP *)malloc(sizeof(KMP) + dwSize - 4); - if (!p) return ret; - - if (cszFileName) - { - LPSTR lpscut = 0; - GetFullPathNameA(cszFileName, MAX_PATH, p->sBasepath, &lpscut); - if (lpscut) *lpscut = 0; - } - else - { - p->sBasepath[0] = 0; - } - - p->lpif = 0; - p->dwFileLen = dwSize; - - GetModuleFileNameA(hDLL, dllpath, MAX_PATH); - GetFullPathNameA(dllpath, MAX_PATH, binpath, &lpFilePart); - lstrcpyA(lpFilePart, XSFDRIVER_MODULENAME); - - p->hDrv = XLoadLibraryA(binpath); - if (!p->hDrv) - { - free(p); - return ret; - } - - lpfnXSFSetup = (LPFNXSFDRVSETUP)XGetProcAddress(p->hDrv, XSFDRIVER_ENTRYNAME); - if (!lpfnXSFSetup) - { - XFreeLibrary(p->hDrv); - p->hDrv = 0; - free(p); - return ret; - } - - CopyMemory(p->bFileBuf, Buffer, dwSize); - - p->lpif = lpfnXSFSetup(XSFGETLIBCALLBACK ,p); - if (!p->lpif || p->lpif->Start(p->bFileBuf, p->dwFileLen)) - { - if (p->lpif) - p->lpif->Term(); - XFreeLibrary(p->hDrv); - p->lpif = 0; - p->hDrv = 0; - free(p); - return ret; - } - p->bTop = 1; - - ret = (HKMP)p; -#ifndef XSFDRIVER_SAMPLERATE - pInfo->dwSamplesPerSec = 44100; -#else - pInfo->dwSamplesPerSec = XSFDRIVER_SAMPLERATE; -#endif - pInfo->dwChannels = 2; - pInfo->dwBitsPerSample = 16; - pInfo->dwLength = 0xFFFFFFFF; - pInfo->dwSeekable = 0; - pInfo->dwUnitRender = 0x100; - pInfo->dwReserved1 = 1; - pInfo->dwReserved2 = 0; - taglength = xsf_tagget("length", p->bFileBuf,p->dwFileLen); - if (taglength) - { - dwLength = tag2ms(taglength); - if (dwLength) - { - pInfo->dwLength = dwLength; - } - free(taglength); - } - p->bVolume = 0; - p->fVolume = 1.0; - tagvolume = xsf_tagget("volume", p->bFileBuf,p->dwFileLen); - if (tagvolume) - { - float volume = (float)atof(tagvolume); - p->fVolume = volume; - p->bVolume = (p->fVolume != 1.0); - free(tagvolume); - } - return ret; -} - -static HKMP WINAPI Open(const char *cszFileName, SOUNDINFO *pInfo) -{ - HKMP ret = NULL; - void *buffer; - DWORD size; - if (!pInfo) return ret; - buffer = loadfileA(cszFileName, &size); - if (buffer) - { - ret = OpenFromBufferSub(cszFileName, (const BYTE *)buffer, size, pInfo); - free(buffer); - } - return ret; -} - - -static void WINAPI Close(HKMP hKMP) -{ - KMP *p = (KMP *)hKMP; - if (p) - { - if (p->lpif) - { - p->lpif->Term(); - p->lpif = 0; - } - if (p->hDrv) - { - XFreeLibrary(p->hDrv); - p->hDrv = 0; - } - free(p); - } -} - -static DWORD WINAPI Render(HKMP hKMP, BYTE* Buffer, DWORD dwSize) -{ - KMP *p = (KMP *)hKMP; - p->bTop = 0; - p->lpif->Gen(Buffer, (dwSize >> 2)); - if (p->bVolume) - { - DWORD i; - for (i = 0; i < dwSize; i += 4) - { - float s1 = ((short *)(Buffer + i))[0]; - float s2 = ((short *)(Buffer + i))[1]; - s1 *= p->fVolume; - if (s1 > (float)0x7fff) - s1 = (float)0x7fff; - else if (s1 < (float)-0x8000) - s1 = (float)-0x8000; - s2 *= p->fVolume; - if (s2 > (float)0x7fff) - s2 = (float)0x7fff; - else if (s2 < (float)-0x8000) - s2 = (float)-0x8000; - ((short *)(Buffer + i))[0] = (short)s1; - ((short *)(Buffer + i))[1] = (short)s2; - } - } - return dwSize; -} - -static DWORD WINAPI SetPosition(HKMP hKMP, DWORD dwPos) -{ - KMP *p = (KMP *)hKMP; - if (p->bTop && dwPos == 0) - { - } - else - { - p->lpif->Start(p->bFileBuf, p->dwFileLen); - p->bTop = 1; - } - return 0; -} - -KBMEDIAPLUGIN_EXTS(exts) - -static const KMPMODULE mod = -{ - KMPMODULE_VERSION, - KBMEDIAPLUGIN_VERSION, - KBMEDIAPLUGIN_COPYRIGHT, - KBMEDIAPLUGIN_NAME, - (const char **)exts, -#if ENABLE_LOADPE - 1, -#else - 0, -#endif - NULL, - NULL, - Open, - NULL, - Close, - Render, - SetPosition -}; - -KMPMODULE* WINAPI KMP_GETMODULE(void) -{ - return (KMPMODULE*)&mod; -} \ No newline at end of file diff --git a/tools/vio2sf/src/xsfc/leakchk.h b/tools/vio2sf/src/xsfc/leakchk.h deleted file mode 100644 index 23a9e887e..000000000 --- a/tools/vio2sf/src/xsfc/leakchk.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LEAKCHK_H -#define LEAKCHK_H - -#if defined(_MSC_VER) && defined(_DEBUG) -#define _CRTDBG_MAP_ALLOC -#include -#include -/* -#define new ::new(_CLIENT_BLOCK, __FILE__, __LINE__) -*/ -#endif - -#endif diff --git a/tools/vio2sf/src/xsfc/tagget.h b/tools/vio2sf/src/xsfc/tagget.h deleted file mode 100644 index bdc7e48e3..000000000 --- a/tools/vio2sf/src/xsfc/tagget.h +++ /dev/null @@ -1,525 +0,0 @@ -#ifdef __cplusplus - -#include "xsfc.h" -class XSFTag -{ -protected: - XSFTag() - { - } - - ~XSFTag() - { - } - - static unsigned long GetWordLE(const void *pData) - { - const unsigned char *pdata = static_cast(pData); - return pdata[0] | (unsigned long(pdata[1]) << 8) | (unsigned long(pdata[2]) << 16) | (unsigned long(pdata[3]) << 24); - } - -public: - - static unsigned long SearchRaw(const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - unsigned long dwPos; - unsigned long dwReservedAreaSize; - unsigned long dwProgramLength; - unsigned long dwProgramCRC; - if (dwSize < 16 + 5 + 1) return 0; - if (pdata[0] != 'P') return 0; - if (pdata[1] != 'S') return 0; - if (pdata[2] != 'F') return 0; - dwReservedAreaSize = GetWordLE(pdata + 4); - dwProgramLength = GetWordLE(pdata + 8); - dwProgramCRC = GetWordLE(pdata + 12); - dwPos = 16 + dwReservedAreaSize + dwProgramLength; - if (dwPos >= dwSize) return 0; - return dwPos; - } - - static int Search(unsigned long *pdwRet, const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - unsigned long dwPos = SearchRaw(pdata, dwSize); - if (dwSize < dwPos + 5) return 0; - if (memcmp(pdata + dwPos, "[TAG]", 5)) return 0; - *pdwRet = dwPos + 5; - return 1; - } - - enum enum_callback_returnvalue - { - enum_continue = 0, - enum_break = 1 - }; - - typedef enum enum_callback_returnvalue (*pfnenum_callback_t)(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd); - static int EnumRaw(pfnenum_callback_t pCallBack, void *pWork, const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - unsigned long dwPos = 0; - while (dwPos < dwSize) - { - unsigned long dwNameTop; - unsigned long dwNameEnd; - unsigned long dwValueTop; - unsigned long dwValueEnd; - if (dwPos < dwSize && pdata[dwPos] == 0x0a) dwPos++; - while (dwPos < dwSize && pdata[dwPos] != 0x0a && 0x00 <= pdata[dwPos] && pdata[dwPos] <= 0x20) - dwPos++; - if (dwPos >= dwSize || pdata[dwPos] == 0x0a) continue; - dwNameTop = dwPos; - while (dwPos < dwSize && pdata[dwPos] != 0x0a && pdata[dwPos] != '=') - dwPos++; - if (dwPos >= dwSize || pdata[dwPos] == 0x0a) continue; - dwNameEnd = dwPos; - while (dwNameTop < dwNameEnd && 0x00 <= pdata[dwNameEnd - 1] && pdata[dwNameEnd - 1] <= 0x20) - dwNameEnd--; - if (dwPos < dwSize && pdata[dwPos] == '=') dwPos++; - while (dwPos < dwSize && pdata[dwPos] != 0x0a && 0x00 <= pdata[dwPos] && pdata[dwPos] <= 0x20) - dwPos++; - dwValueTop = dwPos; - while (dwPos < dwSize && pdata[dwPos] != 0x0a) - dwPos++; - dwValueEnd = dwPos; - while (dwValueTop < dwValueEnd && 0x00 <= pdata[dwValueEnd - 1] && pdata[dwValueEnd - 1] <= 0x20) - dwValueEnd--; - - if (pCallBack) - { - if (enum_continue != pCallBack(pWork, pdata + dwNameTop, pdata + dwNameEnd, pdata + dwValueTop, pdata + dwValueEnd)) - return -1; - } - } - return 1; - } - - static int Enum(pfnenum_callback_t pCallBack, void *pWork, const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - unsigned long dwPos = 0; - if (!Search(&dwPos, pdata, dwSize)) - return 0; - return EnumRaw(pCallBack, pWork, pdata + dwPos, dwSize - dwPos); - } - -protected: - - typedef struct - { - int taglen; - const char *tag; - bool ret; - } xsf_tagexists_work_t; - - static enum enum_callback_returnvalue enum_callback_tagexists(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - xsf_tagexists_work_t *pwork = static_cast(pWork); - (void)pValueTop, pValueEnd; - if (pwork->taglen == pNameEnd - pNameTop && !_strnicmp(pNameTop, pwork->tag, pwork->taglen)) - { - pwork->ret = true; - return enum_break; - } - return enum_continue; - } - -public: - - static bool ExistsRaw(const char *tag, const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - xsf_tagexists_work_t work; - work.ret = false; - work.tag = tag; - work.taglen = (unsigned long)strlen(tag); - EnumRaw(enum_callback_tagexists, &work, pdata, dwSize); - return work.ret; - } - - static bool Exists(const char *tag, const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - xsf_tagexists_work_t work; - work.ret = false; - work.tag = tag; - work.taglen = (unsigned long)strlen(tag); - Enum(enum_callback_tagexists, &work, pdata, dwSize); - return work.ret; - } - -protected: - - typedef struct - { - int taglen; - const char *tag; - xsfc::TString ret; - bool futf8; - } xsf_tagget_work_t; - - static enum enum_callback_returnvalue enum_callback_tagget(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) - { - xsf_tagget_work_t *pwork = static_cast(pWork); - if (pwork->taglen == pNameEnd - pNameTop && !_strnicmp(pNameTop, pwork->tag, pwork->taglen)) - { - pwork->ret = xsfc::TString(pwork->futf8, pValueTop, pValueEnd - pValueTop); - return enum_break; - } - return enum_continue; - } - -public: - - static xsfc::TString GetRaw(bool fUTF8, const char *tag, const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - xsf_tagget_work_t work; - xsfc::TString ret; - work.futf8 = fUTF8; - work.tag = tag; - work.taglen = (unsigned long)strlen(tag); - EnumRaw(enum_callback_tagget, &work, pdata, dwSize); - ret = work.ret; - return ret; - } - static xsfc::TString GetRaw(const char *tag, const void *pData, size_t dwSize) - { - return GetRaw(ExistsRaw("utf8", pData, dwSize), tag, pData, dwSize); - } - - static xsfc::TString Get(bool fUTF8, const char *tag, const void *pData, size_t dwSize) - { - const char *pdata = static_cast(pData); - xsf_tagget_work_t work; - xsfc::TString ret; - work.futf8 = fUTF8; - work.tag = tag; - work.taglen = (unsigned long)strlen(tag); - Enum(enum_callback_tagget, &work, pdata, dwSize); - ret = work.ret; - return ret; - } - static xsfc::TString Get(const char *tag, const void *pData, size_t dwSize) - { - return Get(Exists("utf8", pData, dwSize), tag, pData, dwSize); - } - - - static int GetInt(const char *tag, const void *pData, size_t dwSize, int value_default) - { - const char *pdata = static_cast(pData); - int ret = value_default; - xsfc::TString value = Get(tag, pdata, dwSize); - if (value[0]) ret = atoi(xsfc::TStringM(value)); - return ret; - } - - static double GetFloat(const char *tag, const void *pData, size_t dwSize, double value_default) - { - const char *pdata = static_cast(pData); - double ret = value_default; - xsfc::TString value = Get(tag, pdata, dwSize); - if (value[0]) ret = atof(xsfc::TStringM(value)); - return ret; - } - - static unsigned long ToMS(const wchar_t *p) - { - int f = 0; - unsigned long b = 0; - unsigned long r = 0; - for (;*p; p++) - { - if (*p >= L'0' && *p <= L'9') - { - if (f < 1000) - { - r = r * 10 + *p - L'0'; - if (f) f *= 10; - continue; - } - break; - } - if (*p == L'.') - { - f = 1; - continue; - } - if (*p == L':') - { - b = (b + r) * 60; - r = 0; - continue; - } - break; - } - if (f < 10) - r *= 1000; - else if (f == 10) - r *= 100; - else if (f == 100) - r *= 10; - r += b * 1000; - return r; - } - - static unsigned GetLengthMS(const void *idata, size_t isize, unsigned defaultlength) - { - unsigned length = 0; - xsfc::TString taglength = XSFTag::Get("length", idata, isize); - if (taglength[0]) length = XSFTag::ToMS(taglength); - if (!length) length = defaultlength; - return length; - } - static unsigned GetLengthMS(xsfc::TAutoBuffer idata, unsigned defaultlength) - { - return GetLengthMS(idata.Ptr(), idata.Len(), defaultlength); - } - - static unsigned GetFadeMS(const void *idata, size_t isize, unsigned defaultfade) - { - unsigned fade = defaultfade; - xsfc::TString tagfade = XSFTag::Get("fade", idata, isize); - if (tagfade[0]) fade = XSFTag::ToMS(tagfade); - return fade; - } - static unsigned GetFadeMS(xsfc::TAutoBuffer idata, unsigned defaultfade) - { - return GetFadeMS(idata.Ptr(), idata.Len(), defaultfade); - } - - static bool GetVolume(float *pvolume, const char *tag, xsfc::TAutoBuffer idata, int isgain) - { - bool hasvolume = false; - xsfc::TString tagvolume = XSFTag::Get(tag, idata.Ptr(), idata.Len()); - if (tagvolume[0]) - { - float value = float(tagvolume.GetFloat()); - if (isgain) - *pvolume *= float(pow(2.0, value / 6.0)); - else - *pvolume = value; - hasvolume = (*pvolume != 1.0); - } - return !hasvolume; - } - -}; -#else - -static DWORD getdwordle(const BYTE *pData) -{ - return pData[0] | (((DWORD)pData[1]) << 8) | (((DWORD)pData[2]) << 16) | (((DWORD)pData[3]) << 24); -} - -static DWORD xsf_tagsearchraw(const void *pData, DWORD dwSize) -{ - const BYTE *pdata = (const BYTE *)pData; - DWORD dwPos; - DWORD dwReservedAreaSize; - DWORD dwProgramLength; - DWORD dwProgramCRC; - if (dwSize < 16 + 5 + 1) return 0; - if (pdata[0] != 'P') return 0; - if (pdata[1] != 'S') return 0; - if (pdata[2] != 'F') return 0; - dwReservedAreaSize = getdwordle(pdata + 4); - dwProgramLength = getdwordle(pdata + 8); - dwProgramCRC = getdwordle(pdata + 12); - dwPos = 16 + dwReservedAreaSize + dwProgramLength; - if (dwPos >= dwSize) return 0; - return dwPos; -} -static int xsf_tagsearch(DWORD *pdwRet, const BYTE *pData, DWORD dwSize) -{ - DWORD dwPos = xsf_tagsearchraw(pData, dwSize); - if (dwSize < dwPos + 5) return 0; - if (memcmp(pData + dwPos, "[TAG]", 5)) return 0; - *pdwRet = dwPos + 5; - return 1; -} - -enum xsf_tagenum_callback_returnvalue -{ - xsf_tagenum_callback_returnvaluecontinue = 0, - xsf_tagenum_callback_returnvaluebreak = 1 -}; -typedef int (*pfnxsf_tagenum_callback_t)(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd); -static int xsf_tagenumraw(pfnxsf_tagenum_callback_t pCallBack, void *pWork, const void *pData, DWORD dwSize) -{ - const char *pdata = (const char *)pData; - DWORD dwPos = 0; - while (dwPos < dwSize) - { - DWORD dwNameTop; - DWORD dwNameEnd; - DWORD dwValueTop; - DWORD dwValueEnd; - if (dwPos < dwSize && pdata[dwPos] == 0x0a) dwPos++; - while (dwPos < dwSize && pdata[dwPos] != 0x0a && 0x00 <= pdata[dwPos] && pdata[dwPos] <= 0x20) - dwPos++; - if (dwPos >= dwSize || pdata[dwPos] == 0x0a) continue; - dwNameTop = dwPos; - while (dwPos < dwSize && pdata[dwPos] != 0x0a && pdata[dwPos] != '=') - dwPos++; - if (dwPos >= dwSize || pdata[dwPos] == 0x0a) continue; - dwNameEnd = dwPos; - while (dwNameTop < dwNameEnd && 0x00 <= pdata[dwNameEnd - 1] && pdata[dwNameEnd - 1] <= 0x20) - dwNameEnd--; - if (dwPos < dwSize && pdata[dwPos] == '=') dwPos++; - while (dwPos < dwSize && pdata[dwPos] != 0x0a && 0x00 <= pdata[dwPos] && pdata[dwPos] <= 0x20) - dwPos++; - dwValueTop = dwPos; - while (dwPos < dwSize && pdata[dwPos] != 0x0a) - dwPos++; - dwValueEnd = dwPos; - while (dwValueTop < dwValueEnd && 0x00 <= pdata[dwValueEnd - 1] && pdata[dwValueEnd - 1] <= 0x20) - dwValueEnd--; - - if (pCallBack) - { - if (xsf_tagenum_callback_returnvaluecontinue != pCallBack(pWork, (const char *)pdata + dwNameTop, (const char *)pdata + dwNameEnd, (const char *)pdata + dwValueTop, (const char *)pdata + dwValueEnd)) - return -1; - } - } - return 1; -} - -static int xsf_tagenum(pfnxsf_tagenum_callback_t pCallBack, void *pWork, const void *pData, DWORD dwSize) -{ - const BYTE *pdata = (const BYTE *)pData; - DWORD dwPos = 0; - if (!xsf_tagsearch(&dwPos, pdata, dwSize)) - return 0; - return xsf_tagenumraw(pCallBack, pWork, pdata + dwPos, dwSize - dwPos); -} - -typedef struct -{ - int taglen; - const char *tag; - char *ret; -} xsf_tagget_work_t; - -static int xsf_tagenum_callback_tagget(void *pWork, const char *pNameTop, const char *pNameEnd, const char *pValueTop, const char *pValueEnd) -{ - xsf_tagget_work_t *pwork = (xsf_tagget_work_t *)pWork; - if (pwork->taglen == pNameEnd - pNameTop && !_strnicmp(pNameTop, pwork->tag, pwork->taglen)) - { - char *ret = (char *)malloc(pValueEnd - pValueTop + 1); - if (!ret) return xsf_tagenum_callback_returnvaluecontinue; - memcpy(ret, pValueTop, pValueEnd - pValueTop); - ret[pValueEnd - pValueTop] = 0; - pwork->ret = ret; - return xsf_tagenum_callback_returnvaluebreak; - } - return xsf_tagenum_callback_returnvaluecontinue; -} - -static char *xsf_taggetraw(const char *tag, const void *pData, DWORD dwSize) -{ - const BYTE *pdata = (const BYTE *)pData; - xsf_tagget_work_t work; - work.ret = 0; - work.tag = tag; - work.taglen = (DWORD)strlen(tag); - xsf_tagenumraw(xsf_tagenum_callback_tagget, &work, pdata, dwSize); - return work.ret; -} - -static char *xsf_tagget(const char *tag, const void *pData, DWORD dwSize) -{ - const BYTE *pdata = (const BYTE *)pData; - xsf_tagget_work_t work; - work.ret = 0; - work.tag = tag; - work.taglen = (DWORD)strlen(tag); - xsf_tagenum(xsf_tagenum_callback_tagget, &work, pdata, dwSize); - return work.ret; -} - -static int xsf_tagget_exist(const char *tag, const void *pData, DWORD dwSize) -{ - const BYTE *pdata = (const BYTE *)pData; - int exists; - char *value = xsf_tagget(tag, pdata, dwSize); - if (value) - { - exists = 1; - free(value); - } - else - { - exists = 0; - } - return exists; -} - -static int xsf_tagget_int(const char *tag, const BYTE *pData, DWORD dwSize, int value_default) -{ - int ret = value_default; - char *value = xsf_tagget(tag, pData, dwSize); - if (value) - { - if (*value) ret = atoi(value); - free(value); - } - return ret; -} - -static double xsf_tagget_float(const char *tag, const BYTE *pData, DWORD dwSize, double value_default) -{ - double ret = value_default; - char *value = xsf_tagget(tag, pData, dwSize); - if (value) - { - if (*value) ret = atof(value); - free(value); - } - return ret; -} - -static DWORD tag2ms(const char *p) -{ - int f = 0; - DWORD b = 0; - DWORD r = 0; - for (;*p; p++) - { - if (*p >= '0' && *p <= '9') - { - if (f < 1000) - { - r = r * 10 + *p - '0'; - if (f) f *= 10; - continue; - } - break; - } - if (*p == '.') - { - f = 1; - continue; - } - if (*p == ':') - { - b = (b + r) * 60; - r = 0; - continue; - } - break; - } - if (f < 10) - r *= 1000; - else if (f == 10) - r *= 100; - else if (f == 100) - r *= 10; - r += b * 1000; - return r; -} - -#endif diff --git a/tools/vio2sf/src/xsfc/winresx.h b/tools/vio2sf/src/xsfc/winresx.h deleted file mode 100644 index 724086da3..000000000 --- a/tools/vio2sf/src/xsfc/winresx.h +++ /dev/null @@ -1,8 +0,0 @@ -#if defined(_MSC_VER) && (_MSC_VER < 1400) -# include -#else -# include -#endif -#ifndef IDC_STATIC -# define IDC_STATIC -1 -#endif diff --git a/tools/vio2sf/src/xsfc/xsfc.cpp b/tools/vio2sf/src/xsfc/xsfc.cpp deleted file mode 100644 index 1d7318e2c..000000000 --- a/tools/vio2sf/src/xsfc/xsfc.cpp +++ /dev/null @@ -1,553 +0,0 @@ -#ifdef HAVE_STDINT_H -#include -#elif (defined(_MSC_VER) && (_MSC_VER >= 1200)) -#define int64_t signed __int64 -#define uint64_t unsigned __int64 -#elif (defined(__BORLANDC__ ) && (__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__)) -#define int64_t signed __int64 -#define uint64_t unsigned __int64 -#elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100)) -#define int64_t signed __int64 -#define uint64_t unsigned __int64 -#else -#error "64 bit integer variables are required." -#endif - -#define WIN32_LEAN_AND_MEAN -#include "leakchk.h" - -#include -#include - -#include "xsfc.h" - - -#if _MSC_VER >= 1200 -#pragma warning(disable:4290) -#endif - -namespace -{ - -class FileHandle -{ -protected: - HANDLE h; - - inline HANDLE Handle() - { - return h; - } - - static xsfc::TString FNExtend(const wchar_t *fn) throw(xsfc::EShortOfMemory) - { - if (fn && fn[0] == L'\\' && fn[1] == L'\\' && fn[2] != L'?') - return xsfc::TString("\\\\?\\UNC") + (fn + 1); - if (fn && fn[0] && fn[1] == L':' && fn[2] == L'\\') - return xsfc::TString("\\\\?\\") + fn; - return xsfc::TString(); - } - - static HANDLE ReadOpen(const WCHAR *fn) throw() - { - HANDLE h = INVALID_HANDLE_VALUE; - try - { - if (xsfc::TWin32::IsUnicodeSupportedOS()) - { - xsfc::TString fnw = FNExtend(fn); - h = CreateFileW(fnw ? fnw : fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); -/* - if (h == INVALID_HANDLE_VALUE) - { - h = CreateFileW(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (h == INVALID_HANDLE_VALUE) - { - DWORD dw = GetLastError(); - OutputDebugStringA(""); - (void)dw; - } - } -*/ - } - else - { - h = CreateFileA(xsfc::TStringM(fn), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - } - } - catch (xsfc::EShortOfMemory e) - { - } - return h; - } - -public: - inline bool Opened() - { - return Handle() != INVALID_HANDLE_VALUE; - } - - FileHandle(HANDLE hfile = INVALID_HANDLE_VALUE) - : h(hfile) - { - } - - FileHandle(const wchar_t *path) - : h(ReadOpen(path)) - { - } - - ~FileHandle() - { - if (Opened()) - { - CloseHandle(Handle()); - } - } - - size_t Length() - { - if (Opened()) - { - DWORD dwH = 0; - DWORD dwL = GetFileSize(Handle(), &dwH); - if (dwL != DWORD(0xFFFFFFFF) || GetLastError() == NO_ERROR) - { - if (dwH) - { - uint64_t s64 = ((((uint64_t)dwH) << 32) | dwL); - size_t s = size_t(s64); - if (s == s64) return s; - } - else - { - size_t s = size_t(dwL); - if (s == dwL) return s; - } - } - } - return 0; - } - size_t Read(void *p, size_t l) - { - if (Opened()) - { - DWORD nNumberOfBytesToRead = DWORD(l); - DWORD dwNumberOfBytesRead = 0; - if (l == nNumberOfBytesToRead) - { - if (!ReadFile(Handle(), p, nNumberOfBytesToRead, &dwNumberOfBytesRead, 0)) - dwNumberOfBytesRead = 0; - } - size_t s = size_t(dwNumberOfBytesRead); - if (s == dwNumberOfBytesRead) - return s; - } - return 0; - } -}; - -} - -namespace xsfc -{ - -static UINT GetFileCP(void) throw() -{ - return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; -} - -size_t TIConv::ToWide(bool isUTF8, const char *s, size_t sl, wchar_t *d, size_t dl) throw() -{ - UINT cp = isUTF8 ? CP_UTF8 : GetFileCP(); - DWORD flag = 0; - return ::MultiByteToWideChar(cp, flag, s, (int)sl, d, (int)dl); -} - -size_t TIConv::ToMulti(bool isUTF8, const wchar_t *s, size_t sl, char *d, size_t dl) throw() -{ - UINT cp = isUTF8 ? CP_UTF8 : GetFileCP(); - DWORD flag = 0; - return ::WideCharToMultiByte(cp, flag, s, (int)sl, d, (int)dl, 0, 0); -} - -bool TWin32::IsUnicodeSupportedOS(void) throw() -{ - return !(::GetVersion() & 0x80000000); -} - -bool TWin32::IsPathSeparator(char c) throw() -{ - return c == ':' || c == '\\' || c == '/' || c == '|'; -} - -bool TWin32::IsPathSeparator(wchar_t c) throw() -{ - return c == L':' || c == L'\\' || c == L'/' || c == L'|'; -} - -const char *TWin32::NextChar(const char *p) -{ - return ::IsDBCSLeadByte(*p) ? p + 2 : p + 1; -} - -const wchar_t *TWin32::NextChar(const wchar_t *p) -{ - return p + 1; -} - -template class WndMsgSendHelper -{ -public: - static void *Invoke(void *hwnd, unsigned msg, T1 wp, T2 lp) throw() - { - return (void *)(TWin32::IsUnicodeSupportedOS() ? ::SendMessageW : ::SendMessageA) (static_cast(hwnd), msg, WPARAM(wp), LPARAM(lp)); - } -}; - -void *TWin32::WndMsgSend(void *hwnd, unsigned msg, const void *wp, const void *lp) -{ - return WndMsgSendHelper::Invoke(hwnd, msg, wp, lp); -} -void *TWin32::WndMsgSend(void *hwnd, unsigned msg, const void *wp, int lp) -{ - return WndMsgSendHelper::Invoke(hwnd, msg, wp, lp); -} -void *TWin32::WndMsgSend(void *hwnd, unsigned msg, int wp, const void *lp) -{ - return WndMsgSendHelper::Invoke(hwnd, msg, wp, lp); -} -void *TWin32::WndMsgSend(void *hwnd, unsigned msg, int wp, int lp) -{ - return WndMsgSendHelper::Invoke(hwnd, msg, wp, lp); -} - -void TWin32::WndMsgPost(void *hwnd, unsigned msg, const void *wp, const void *lp) -{ - (IsUnicodeSupportedOS() ? ::PostMessageW : ::PostMessageA) (static_cast(hwnd), msg, WPARAM(wp), LPARAM(lp)); -} - -void *TWin32::WndGetLongPtr(void *hwnd, int idx) -{ -#ifdef GetWindowLongPtr - return (void *)(LONG_PTR)(IsUnicodeSupportedOS() ? ::GetWindowLongPtrW : ::GetWindowLongPtrA) (static_cast(hwnd), idx); -#else - return (void *)(IsUnicodeSupportedOS() ? ::GetWindowLongW : ::GetWindowLongA) (static_cast(hwnd), idx); -#endif -} -void *TWin32::WndSetLongPtr(void *hwnd, int idx, void *ptr) -{ -#ifdef SetWindowLongPtr -#ifdef _WIN64 - if (IsUnicodeSupportedOS()) - return (void *)(LONG_PTR) ::SetWindowLongPtrW(static_cast(hwnd), idx, (LONG_PTR)ptr); - else - return (void *)(LONG_PTR) ::SetWindowLongPtrA(static_cast(hwnd), idx, (LONG_PTR)ptr); -#else - if (IsUnicodeSupportedOS()) - return (void *)(LONG_PTR) ::SetWindowLongW(static_cast(hwnd), idx, (LONG)(LONG_PTR)ptr); - else - return (void *)(LONG_PTR) ::SetWindowLongA(static_cast(hwnd), idx, (LONG)(LONG_PTR)ptr); -#endif -#else - return (void *)(IsUnicodeSupportedOS() ? ::SetWindowLongW : ::SetWindowLongA) (static_cast(hwnd), idx, (LONG)ptr); -#endif -} - -TString TWin32::ModulePath(void *hmod) throw(EShortOfMemory) -{ - TString ret; - if (IsUnicodeSupportedOS()) - { - WCHAR wbuf[MAX_PATH]; - wbuf[0] = 0; - ::GetModuleFileNameW((HINSTANCE)hmod, wbuf, MAX_PATH); - ret.SetW(wbuf, MAX_PATH); - } - else - { - char mbuf[MAX_PATH]; - mbuf[0] = 0; - ::GetModuleFileNameA((HINSTANCE)hmod, mbuf, MAX_PATH); - ret.SetM(mbuf, MAX_PATH); - } - return ret; -} - -TString TWin32::ExtractPath(const wchar_t *p) throw(EShortOfMemory) -{ - int i, s; - for (s = i = 0; p[i]; i++) - { - if (IsPathSeparator(p[i])) - s = i + 1; - } - - return TString(p, s); -} - -TString TWin32::ExtractFileName(const wchar_t *p) throw(EShortOfMemory) -{ - return TString(TWin32T::ExtractFilename(p)); -} - -TString TWin32::CanonicalizePath(const wchar_t *p) throw(EShortOfMemory) -{ - size_t wl = StrNLen(p); - TAutoBuffer buf; - buf.Resize(wl + 1); - wchar_t *b = buf.Ptr(); - ::lstrcpyW(b, p); - bool e; - do - { - e = false; - wchar_t *f = 0; - for (wchar_t *c = b; *c; c++) - { - if (TWin32::IsPathSeparator(*c)) - { - if (f && c[1] == L'.' && c[2] == L'.') - { - f += 1; - c += 4; - while (0 != (*(f++) = *(c++))); - e = true; - break; - } - else - { - f = c; - } - } - } - } while (e); - TString ret(b); - buf.Free(); - return ret; -} - - -TString TWin32::GetPrivateProfile(const wchar_t *ininame, const wchar_t *appname, const wchar_t *keyname, const wchar_t *defaultvalue) throw(EShortOfMemory) -{ - if (IsUnicodeSupportedOS()) - { - size_t ret = 0; - size_t prevret = 0; - size_t bufsize = MAX_PATH; - TAutoBuffer buf; - do - { - prevret = ret; - bufsize += bufsize; - if (!buf.Resize(bufsize)) - throw EShortOfMemory(); - ret = ::GetPrivateProfileStringW(appname, keyname, defaultvalue, buf.Ptr(), DWORD(bufsize), ininame); - } - while (ret + 1== bufsize && ret != prevret); - return TString(buf.Ptr(), buf.Len()); - } - else - { - size_t ret = 0; - size_t prevret = 0; - size_t bufsize = MAX_PATH; - TAutoBuffer buf; - TStringM ininameM(ininame), appnameM(appname), keynameM(keyname), defaultvalueM(defaultvalue); - do - { - prevret = ret; - bufsize += bufsize; - if (!buf.Resize(bufsize)) - throw EShortOfMemory(); - ret = ::GetPrivateProfileStringA(appnameM, keynameM, defaultvalueM, buf.Ptr(), DWORD(bufsize), ininameM); - } - while (ret + 1 == bufsize && ret != prevret); - return TString(buf.Ptr(), buf.Len()); - } -} - -void TWin32::SetPrivateProfile(const wchar_t *ininame, const wchar_t *appname, const wchar_t *keyname, const wchar_t *value) throw() -{ - try - { - if (IsUnicodeSupportedOS()) - { - ::WritePrivateProfileStringW(appname, keyname, value, ininame); - } - else - { - TStringM ininameM(ininame), appnameM(appname), keynameM(keyname), valueM(value); - ::WritePrivateProfileStringA(appnameM, keynameM, valueM, ininameM); - } - } - catch (xsfc::EShortOfMemory e) - { - } -} - -void *TWin32::DlgCreate(void *hinst, int id, void *hwndParent, DLGPROC pProc, void *param) -{ - if (IsUnicodeSupportedOS()) - return (void *)::CreateDialogParamW(static_cast(hinst), MAKEINTRESOURCEW(id), static_cast(hwndParent), pProc, LPARAM(param)); - else - return (void *)::CreateDialogParamA(static_cast(hinst), MAKEINTRESOURCEA(id), static_cast(hwndParent), pProc, LPARAM(param)); -} -void *TWin32::DlgInvoke(void *hinst, const void *ptemp, void *hwndParent, DLGPROC pProc, void *param) -{ - if (IsUnicodeSupportedOS()) - return (void *)::DialogBoxIndirectParamW(static_cast(hinst), static_cast(ptemp), static_cast(hwndParent), pProc, LPARAM(param)); - else - return (void *)::DialogBoxIndirectParamA(static_cast(hinst), static_cast(ptemp), static_cast(hwndParent), pProc, LPARAM(param)); -} - - -void TWin32::DlgSetText(void *hwndDlg, int itm, TString text) throw() -{ - try - { - if (IsUnicodeSupportedOS()) - ::SetDlgItemTextW(static_cast(hwndDlg), itm, text); - else - ::SetDlgItemTextA(static_cast(hwndDlg), itm, TStringM(text)); - } - catch (xsfc::EShortOfMemory e) - { - } -} - -TString TWin32::DlgGetText(void *hwndDlg, int itm) throw(EShortOfMemory) -{ - TString ret; - if (IsUnicodeSupportedOS()) - { - WCHAR buf[32]; - ::GetDlgItemTextW(static_cast(hwndDlg), itm, buf, 32); - ret.SetW(buf, 32); - } - else - { - char buf[32]; - ::GetDlgItemTextA(static_cast(hwndDlg), itm, buf, 32); - ret.SetM(buf, 32); - } - return ret; -} - -static void *DlgItem(void *hwndDlg, int itm) -{ - return ::GetDlgItem(static_cast(hwndDlg), itm); -} - -void TWin32::DlgSetEnabled(void *hwndDlg, int itm, bool chk) -{ - ::EnableWindow(::GetDlgItem(static_cast(hwndDlg), itm), chk ? TRUE : FALSE); -} - - -void TWin32::DlgSetCheck(void *hwndDlg, int itm, bool chk) -{ - WndMsgSend(DlgItem(hwndDlg, itm), BM_SETCHECK, chk ? BST_CHECKED : BST_UNCHECKED, 0); -} - -bool TWin32::DlgGetCheck(void *hwndDlg, int itm) -{ - return (INT_PTR)WndMsgSend(DlgItem(hwndDlg, itm), BM_GETCHECK, 0, 0) == BST_CHECKED; -} - -void TWin32::DlgAddList(void *hwndDlg, int itm, TString item) -{ - try - { - if (IsUnicodeSupportedOS()) - WndMsgSend(DlgItem(hwndDlg, itm), LB_ADDSTRING, 0, item.GetW()); - else - WndMsgSend(DlgItem(hwndDlg, itm), LB_ADDSTRING, 0, TStringM(item).GetM()); - } - catch (xsfc::EShortOfMemory e) - { - } -} - -void TWin32::DlgAddCombo(void *hwndDlg, int itm, TString item) -{ - try - { - if (IsUnicodeSupportedOS()) - WndMsgSend(DlgItem(hwndDlg, itm), CB_ADDSTRING, 0, item.GetW()); - else - WndMsgSend(DlgItem(hwndDlg, itm), CB_ADDSTRING, 0, TStringM(item).GetM()); - } - catch (xsfc::EShortOfMemory e) - { - } -} - -int TWin32::DlgCntList(void *hwndDlg, int itm) -{ - return (int)(INT_PTR)WndMsgSend(DlgItem(hwndDlg, itm), LB_GETCOUNT, 0, 0); -} - -int TWin32::DlgCurList(void *hwndDlg, int itm) -{ - return (int)(INT_PTR)WndMsgSend(DlgItem(hwndDlg, itm), LB_GETCURSEL, 0, 0); -} - -int TWin32::DlgCurCombo(void *hwndDlg, int itm) -{ - return (int)(INT_PTR)WndMsgSend(DlgItem(hwndDlg, itm), CB_GETCURSEL, 0, 0); -} - -bool TWin32::DlgGetList(void *hwndDlg, int itm, int cur) -{ - return (INT_PTR)WndMsgSend(DlgItem(hwndDlg, itm), LB_GETSEL, cur, 0) > 0; -} - -void *TWin32::LoadEx(const wchar_t *path, size_t &loadsize, void *pwork, lpfnalloc palloc, lpfnfree pfree) -{ - void *p = 0; - void *ret = 0; - try - { - FileHandle h(path); - size_t s = h.Length(); - if (s && palloc) - { - p = palloc(pwork, s); - if (p && s == h.Read(p, s)) - { - loadsize = s; - ret = p; - p = 0; - } - } - } - catch (EShortOfMemory e) - { - } - if (p && pfree) pfree(pwork, p); - return ret; -} - -TAutoBuffer TWin32::Map(const wchar_t *path) -{ - TAutoBuffer ret; - try - { - FileHandle h(path); - size_t s = h.Length(); - if (s && ret.Resize(s)) - { - if (s != h.Read(ret.Ptr(), s)) - { - ret.Free(); - } - } - } - catch (EShortOfMemory e) - { - } - return ret; -} - -} diff --git a/tools/vio2sf/src/xsfc/xsfc.h b/tools/vio2sf/src/xsfc/xsfc.h deleted file mode 100644 index fbc7eabde..000000000 --- a/tools/vio2sf/src/xsfc/xsfc.h +++ /dev/null @@ -1,673 +0,0 @@ -#if _MSC_VER >= 1200 -# pragma once -#endif - -#ifndef XSFC_H__ -#define XSFC_H__ - -#if _MSC_VER >= 1200 -#pragma warning(push) -#pragma warning(disable:4290) -#endif - -#ifdef __cplusplus - -#include -#include -#include -#include - -#if !defined(HAVE_SPRINTF_S) && !defined(HAVE_SNPRINTF_) && defined(_MSC_VER) -# if _MSC_VER >= 1400 -# define HAVE_SPRINTF_S -# elif _MSC_VER >= 1200 -# define HAVE_SNPRINTF_ -# endif -#endif - -namespace xsfc -{ - -const std::nothrow_t nothrow; - -class EBaseException -{ -protected: - EBaseException(int c) throw() - : Code(c) - { - } -public: - int Code; - EBaseException(const EBaseException &e) throw() - : Code(e.Code) - { - } - ~EBaseException() throw() {} -}; - -class EShortOfMemory : public EBaseException -{ -public: - EShortOfMemory() throw() - : EBaseException(1) - { - } - EShortOfMemory(const EShortOfMemory &e) throw() - : EBaseException(e) - { - } - ~EShortOfMemory() throw() {} -}; - -template class TAutoPtr -{ -protected: - T *ptr; - -public: - void Release() throw() - { - if (ptr) - { - delete ptr; - ptr = 0; - } - } - T *Ptr() const throw() - { - return ptr; - } - T *Detach() throw() - { - T *ret = ptr; - ptr = 0; - return ret; - } - TAutoPtr(T *p = 0) throw() - : ptr(p) - { - } - ~TAutoPtr() throw() - { - Release(); - } - T * operator->() const throw() - { - return ptr; - } - operator T *() const throw() - { - return ptr; - } - TAutoPtr &operator =(T *p) throw() - { - Release(); - ptr = p; - return *this; - } -}; - -template class TSimpleArray -{ -protected: - T *ptr; - size_t length; - - void Free() throw() - { - if (ptr) - { - delete [] ptr; - ptr = 0; - } - length = 0; - } - -public: - - ~TSimpleArray() throw() - { - Free(); - } - - TSimpleArray() throw() - : ptr(0), length(0) - { - } - - bool Resize(size_t l) throw() - { - Free(); - if (l > 0) - { - ptr = new(nothrow) T[l]; - if (ptr) length = l; - } - return ptr != 0 || l == 0; - } - - bool ResizeE(size_t l) - { - Free(); - if (l > 0) - { - ptr = new(nothrow) T[l]; - if (ptr) length = l; - } - return ptr != 0 || l == 0; - } - - inline T* Ptr() const throw() - { - return ptr; - } - - inline size_t Len() const throw() - { - return length; - } -}; - -template class TRefCnt -{ -protected: - T target; - unsigned count; - - ~TRefCnt() throw() - { - } - - TRefCnt() throw() - : count(0) - { - } - -public: - - void Release() throw() - { - if (--count == 0) - { - delete this; - } - } - - TRefCnt *AddRef() throw() - { - ++count; - return this; - } - - inline T &Target() throw() - { - return target; - } - - static TRefCnt *Create() throw() - { - TRefCnt *ret = new(nothrow) TRefCnt(); - return ret ? ret->AddRef() : 0; - } -}; - -template class TReference -{ -protected: - TRefCnt *refbuf; -public: - void Free() throw() - { - if (refbuf) - { - refbuf->Release(); - refbuf = 0; - } - } - - ~TReference() throw() - { - Free(); - } - - TReference(const bool fInitialze = true) throw() - : refbuf(fInitialze ? TRefCnt::Create() : 0) - { - } - - TReference(const TReference &s) throw() - : refbuf(s.refbuf ? s.refbuf->AddRef() : 0) - { - } - - TReference &operator =(const TReference &s) throw() - { - // AddRef must be called before than Free because refbuf may be equal to s.refbuf. - TRefCnt *newbuf = s.refbuf ? s.refbuf->AddRef() : 0; - Free(); - refbuf = newbuf; - return *this; - } - - inline T *Ptr() const throw() - { - return refbuf ? &refbuf->Target() : 0; - } -}; - -template class TAutoBuffer -{ -protected: - typedef TSimpleArray array_t; - TReference ref; - -public: - inline void Free() throw() - { - ref.Free(); - } - - bool Resize(size_t l) throw() - { - ref = TReference(true); - if (ref.Ptr() && !ref.Ptr()->Resize(l)) - { - ref.Free(); - } - return ref.Ptr()->Ptr() != 0; - } - - ~TAutoBuffer() throw() - { - } - - TAutoBuffer() throw() - : ref(false) - { - } - - TAutoBuffer(const TAutoBuffer &s) throw() - : ref(s.ref) - { - } - - TAutoBuffer &operator =(const TAutoBuffer &s) throw() - { - ref = s.ref; - return *this; - } - - T * Ptr() const throw() - { - array_t *ptr = ref.Ptr(); - return ptr ? ptr->Ptr() : 0; - } - - size_t Len() const throw() - { - array_t *ptr = ref.Ptr(); - return ptr ? ptr->Len() : 0; - } -}; - -class TIConv -{ -public: - static size_t ToWide(bool isUTF8, const char *s, size_t sl, wchar_t *d, size_t dl) throw(); - static size_t ToMulti(bool isUTF8, const wchar_t *s, size_t sl, char *d, size_t dl) throw(); -}; - -template size_t StrNLen(const T *s, size_t n = -1) throw() -{ - size_t l; - for (l = 0; s && ((n == (size_t)-1) || (l < n)) && s[l]; l++) - ; - return l; -} - -class TStringM -{ -protected: - TAutoBuffer buf; - bool isutf8; - - void SetWU(bool isUTF8, const wchar_t *p, size_t n = -1) throw(EShortOfMemory) - { - isutf8 = isUTF8; - size_t sl = StrNLen(p, n); - size_t l = TIConv::ToMulti(isutf8, p, sl, 0, 0); - if (!buf.Resize(l + 1)) - throw EShortOfMemory(); - else - { - char *ptr = buf.Ptr(); - ptr[l] = '\0'; - if (l > 0) - TIConv::ToMulti(isutf8, p, sl, ptr, l); - } - } - - - void SetMU(bool isUTF8, const char *p, size_t n = -1) throw(EShortOfMemory) - { - isutf8 = isUTF8; - size_t l = StrNLen(p, n); - if (!buf.Resize(l + 1)) - throw EShortOfMemory(); - else - { - char *ptr = buf.Ptr(); - ptr[l] = L'\0'; - memcpy(ptr, p, l * sizeof(char)); - } - } - -public: - TStringM(bool utf8, const char *p, size_t n = -1) throw(EShortOfMemory) - { - SetMU(utf8, p, n); - } - - TStringM(const TStringM &p) throw() - : buf(p.buf), isutf8(p.isutf8) - { - } - - TStringM &operator =(const TStringM &s) throw() - { - buf = s.buf; - isutf8 = s.isutf8; - return *this; - } - - void SetW(const wchar_t *p, size_t n = -1) throw(EShortOfMemory) - { - SetWU(false, p, n); - } - - void SetW(bool utf8, const wchar_t *p, size_t n = -1) throw(EShortOfMemory) - { - SetWU(utf8, p, n); - } - - const char *GetM(void) const throw() - { - return buf.Len() ? buf.Ptr() : ""; - } - - operator const char *(void) const throw() - { - return GetM(); - } - - TStringM() throw() - : isutf8(false) - { - } - - TStringM(const wchar_t *p, size_t n = -1) throw(EShortOfMemory) - { - SetWU(false, p, n); - } - - TStringM(bool utf8, const wchar_t *p, size_t n = -1) throw(EShortOfMemory) - { - SetWU(utf8, p, n); - } - - ~TStringM() throw() - { - } - - inline bool IsUTF8(void) const throw() - { - return isutf8; - } -}; - -class TString -{ -protected: - TAutoBuffer buf; - - void SetMU(bool isUTF8, const char *p, size_t n = -1) throw(EShortOfMemory) - { - size_t sl = StrNLen(p, n); - size_t l = TIConv::ToWide(isUTF8, p, sl, 0, 0); - if (!buf.Resize(l + 1)) - throw EShortOfMemory(); - else - { - wchar_t *ptr = buf.Ptr(); - if (ptr) ptr[l] = L'\0'; - if (l > 0) - TIConv::ToWide(isUTF8, p, sl, ptr, l); - } - } - - void SetFloat(const double &s) throw(EShortOfMemory) - { - char buf[32]; -#if defined(HAVE_SPRINTF_S) - sprintf_s(buf, sizeof(buf), "%g", s); -#elif defined(HAVE_SNPRINTF) - snprintf(buf, sizeof(buf), "%g", s); -#elif defined(HAVE_SNPRINTF_) - _snprintf(buf, sizeof(buf), "%g", s); -#else - sprintf(buf, "%g", s); -#endif - SetMU(false, buf, sizeof(buf)); - } - - void SetULong(const unsigned long &s) throw(EShortOfMemory) - { - char buf[32]; -#if defined(HAVE_SPRINTF_S) - sprintf_s(buf, sizeof(buf), "%lu", s); -#elif defined(HAVE_SNPRINTF) - snprintf(buf, sizeof(buf), "%lu", s); -#elif defined(HAVE_SNPRINTF_) - _snprintf(buf, sizeof(buf), "%lu", s); -#else - sprintf(buf, "%lu", s); -#endif - SetMU(false, buf, sizeof(buf)); - } - -public: - - void SetW(const wchar_t *p, size_t n = -1) throw(EShortOfMemory) - { - size_t l = StrNLen(p, n); - if (!buf.Resize(l + 1)) - throw EShortOfMemory(); - else - { - wchar_t *ptr = buf.Ptr(); - ptr[l] = L'\0'; - memcpy(ptr, p, l * sizeof(wchar_t)); - } - } - - void SetM(const char *p, size_t n = -1) throw(EShortOfMemory) - { - SetMU(false, p, n); - } - - void SetUTF8(const char *p, size_t n = -1) throw(EShortOfMemory) - { - SetMU(true, p, n); - } - - const wchar_t *GetW(void) const throw() - { - return buf.Len() ? buf.Ptr() : L""; - } - - operator const wchar_t *(void) const throw() - { - return GetW(); - } - - TString() throw() - { - } - - TString(const TString &p) throw() - : buf(p.buf) - { - } - - TString(const TStringM & p) throw(EShortOfMemory) - { - SetMU(p.IsUTF8(), p); - } - - TString(const wchar_t *p, size_t n = -1) throw(EShortOfMemory) - { - SetW(p, n); - } - - TString(const char *p, size_t n = -1) throw(EShortOfMemory) - { - SetM(p, n); - } - - TString(bool isUTF8, const char *p, size_t n = -1) throw(EShortOfMemory) - { - SetMU(isUTF8, p, n); - } - - TString(unsigned long s) throw(EShortOfMemory) - { - SetULong(s); - } - - TString(double s) throw(EShortOfMemory) - { - SetFloat(s); - } - - ~TString() throw() - { - } - - TString &operator =(const TString &s) throw() - { - buf = s.buf; - return *this; - } - - TString &operator =(const TStringM &s) throw() - { - SetMU(s.IsUTF8(), s); - return *this; - } - - static friend TString operator+(const wchar_t *p, const TString &s) throw(EShortOfMemory) - { - TString r; - const wchar_t *p2 = s.GetW(); - size_t l1 = StrNLen(p); - size_t l2 = StrNLen(p2); - if (!r.buf.Resize(l1 + l2 + 1)) - throw EShortOfMemory(); - else - { - wchar_t *des = r.buf.Ptr(); - des[l1 + l2] = L'\0'; - if (l1) - memcpy(des, p, l1 * sizeof(wchar_t)); - if (l2) - memcpy(des + l1, p2, l2 * sizeof(wchar_t)); - } - return r; - } - - double GetFloat() const throw(EShortOfMemory) - { - return atof(TStringM(GetW())); - } - unsigned long GetULong() const throw(EShortOfMemory) - { - return unsigned long(atol(TStringM(GetW()))); - } -}; - -class TWin32 -{ -public: - // System - static bool IsUnicodeSupportedOS(void) throw(); - static bool IsPathSeparator(char c) throw(); - static bool IsPathSeparator(wchar_t c) throw(); - static const char *NextChar(const char *p) throw(); - static const wchar_t *NextChar(const wchar_t *p) throw(); - static TString ModulePath(void *hmod) throw(EShortOfMemory); - static TString ExtractPath(const wchar_t *p) throw(EShortOfMemory); - static TString ExtractFileName(const wchar_t *p) throw(EShortOfMemory); - static TString CanonicalizePath(const wchar_t *p) throw(EShortOfMemory); - // Setting - static TString GetPrivateProfile(const wchar_t *ininame, const wchar_t *appname, const wchar_t *keyname, const wchar_t *defaultvalue) throw(EShortOfMemory); - static void SetPrivateProfile(const wchar_t *ininame, const wchar_t *appname, const wchar_t *keyname, const wchar_t *value) throw(); - // Window - static void *WndMsgSend(void *hwnd, unsigned msg, const void *wp, const void *lp) throw(); - static void *WndMsgSend(void *hwnd, unsigned msg, const void *wp, int lp) throw(); - static void *WndMsgSend(void *hwnd, unsigned msg, int wp, const void *lp) throw(); - static void *WndMsgSend(void *hwnd, unsigned msg, int wp, int lp) throw(); - static void WndMsgPost(void *hwnd, unsigned msg, const void *wp = 0, const void *lp = 0) throw(); - static void *WndGetLongPtr(void *hwnd, int idx) throw(); - static void *WndSetLongPtr(void *hwnd, int idx, void *ptr) throw(); - // Dialog - static void *DlgCreate(void *hinst, int id, void *hwndParent, DLGPROC pProc, void *param) throw(); - static void *DlgInvoke(void *hinst, const void *ptemp, void *hwndParent, DLGPROC pProc, void *param) throw(); - static void DlgSetText(void *hwndDlg, int itm, TString text) throw(); - static TString DlgGetText(void *hwndDlg, int itm) throw(EShortOfMemory); - static void DlgSetEnabled(void *hwndDlg, int itm, bool chk) throw(); - static void DlgSetCheck(void *hwndDlg, int itm, bool chk) throw(); - static bool DlgGetCheck(void *hwndDlg, int itm) throw(); - static void DlgAddList(void *hwndDlg, int itm, TString item) throw(); - static void DlgAddCombo(void *hwndDlg, int itm, TString item) throw(); - static int DlgCntList(void *hwndDlg, int itm) throw(); - static int DlgCurList(void *hwndDlg, int itm) throw(); - static int DlgCurCombo(void *hwndDlg, int itm) throw(); - static bool DlgGetList(void *hwndDlg, int itm, int cur) throw(); - // File - typedef void *(*lpfnalloc)(void *pwork, size_t s); - typedef void (*lpfnfree)(void *pwork, void *p); - static void *LoadEx(const wchar_t *path, size_t &loadsize, void *pwork, lpfnalloc palloc, lpfnfree pfree) throw(); - static TAutoBuffer Map(const wchar_t *path) throw(EShortOfMemory); -// TReference Create(const wchar_t *path); -}; - -template class TWin32T -{ -public: - static const T *ExtractFilename(const T * fn) throw() - { - const T *fname = fn; - const T *p = fn; - while (*p) - { - if (TWin32::IsPathSeparator(*p)) - fname = p + 1; - p = TWin32::NextChar(p); - } - if (!*fname) - fname = fn; - return fname; - } -}; - - -} - -#endif - -#if _MSC_VER >= 1200 -#pragma warning(pop) -#endif - -#endif diff --git a/tools/vio2sf/src/xsfc/xsfcfg.cpp b/tools/vio2sf/src/xsfc/xsfcfg.cpp deleted file mode 100644 index 0cf3db981..000000000 --- a/tools/vio2sf/src/xsfc/xsfcfg.cpp +++ /dev/null @@ -1,290 +0,0 @@ -#define WIN32_LEAN_AND_MEAN -#include "leakchk.h" - -#include -#include - -#include "xsfcfg.h" -#include "tagget.h" -#include "../pversion.h" -#include "xsfui.rh" - -#include "vio2sf/desmume/spu.h" - -unsigned long dwChannelMute[4] = { 0, 0, 0, 0 }; - -unsigned long dwInterpolation; - -namespace -{ - -const int VolumeBase = 16; - -unsigned long dwPlayInfinitely; -unsigned long dwSkipSilenceOnStartSec; -unsigned long dwDetectSilenceSec; -unsigned long dwDefaultLength; -unsigned long dwDefaultFade; -double dVolume; - -xsfc::TString sDefaultLengthC(L"1:55"); -xsfc::TString sDefaultFadeC(L"5"); -xsfc::TString sDefaultLength; -xsfc::TString sDefaultFade; - -typedef struct -{ - int devch; - const char *devname; -} CHANNELMAP; - -const CHANNELMAP chmap[] = XSFDRIVER_CHANNELMAP; - -#ifdef XSFDRIVER_EXTENDPARAM1NAME -xsfc::TString sExtendParam1C(XSFDRIVER_EXTENDPARAM1DEFAULT); -xsfc::TString sExtendParam1; -#endif - -#ifdef XSFDRIVER_EXTENDPARAM2NAME -xsfc::TString sExtendParam2C(XSFDRIVER_EXTENDPARAM2DEFAULT); -xsfc::TString sExtendParam2; -#endif - -} - -unsigned long CFGGetChannelMute(int page) -{ - return (page < 4) ? dwChannelMute[page] : ~unsigned long(0); -} - -void CFGSetChannelMute(int ch, bool mute) -{ - int page = ch >> 5; - if (page < 4) - { - if (mute) - dwChannelMute[page] |= ((unsigned long(1)) << (ch & 0x1f)); - else - dwChannelMute[page] &= ~((unsigned long(1)) << (ch & 0x1f)); - } -} - - -unsigned CFGGetPlayInfinitely(void) -{ - return dwPlayInfinitely; -} -unsigned CFGGetSkipSilenceOnStartSec(void) -{ - return dwSkipSilenceOnStartSec; -} -unsigned CFGGetDetectSilenceSec(void) -{ - return dwDetectSilenceSec; -} -unsigned CFGGetDefaultLength(void) -{ - return dwDefaultLength; -} -unsigned CFGGetDefaultFade(void) -{ - return dwDefaultFade; -} -bool CFGGetVolume(double &vol) -{ - int iVolume = int(dVolume); - if (iVolume == 0 || iVolume == VolumeBase) - { - vol = 1; - return false; - } - vol = dVolume / VolumeBase; - return true; -} - -const wchar_t *CFGGetExtendParam1(void) -{ -#ifdef XSFDRIVER_EXTENDPARAM1NAME - return sExtendParam1; -#else - return 0; -#endif -} -const wchar_t *CFGGetExtendParam2(void) -{ -#ifdef XSFDRIVER_EXTENDPARAM2NAME - return sExtendParam2; -#else - return 0; -#endif -} - -void CFGDefault(void) -{ - dwPlayInfinitely = 0; - dwInterpolation = (unsigned long)SPUInterpolation_Linear; - dwSkipSilenceOnStartSec = 5; - dwDetectSilenceSec = 5; - dwDefaultLength = (1 * 60 + 55) * 1000; - dwDefaultFade = 5 * 1000; - dVolume = VolumeBase; - - sDefaultLength = sDefaultLengthC; - sDefaultFade = sDefaultFadeC; - -#ifdef XSFDRIVER_EXTENDPARAM1NAME - sExtendParam1 = sExtendParam1C; -#endif -#ifdef XSFDRIVER_EXTENDPARAM2NAME - sExtendParam2 = sExtendParam2C; -#endif - - int tch = 0; - for (const CHANNELMAP *pchmap = &chmap[0]; pchmap->devch; pchmap++) - { - for (int ch = 1; ch <= pchmap->devch; ch++) - { - CFGSetChannelMute(tch++, false); - } - } - while (tch < 32 * 4) - CFGSetChannelMute(tch++, true); -} - -void CFGLoad(LPIConfigIO pcfg) -{ - try - { - - CFGDefault(); - dwInterpolation = pcfg->GetULong(L"Interpolation", dwInterpolation); - dwPlayInfinitely = pcfg->GetULong(L"PlayInfinitely", dwPlayInfinitely); - dwSkipSilenceOnStartSec = pcfg->GetULong(L"SkipSilenceOnStartSec", dwSkipSilenceOnStartSec); - dwDetectSilenceSec = pcfg->GetULong(L"DetectSilenceSec", dwDetectSilenceSec); - dVolume = pcfg->GetFloat(L"Volume", dVolume / dVolume) * VolumeBase; - sDefaultLength = pcfg->GetString(L"DefaultLength", sDefaultLength); - sDefaultFade = pcfg->GetString(L"DefaultFade", sDefaultFade); -#ifdef XSFDRIVER_EXTENDPARAM1NAME - sExtendParam1 = pcfg->GetString(XSFDRIVER_EXTENDPARAM1NAME, sExtendParam1); -#endif -#ifdef XSFDRIVER_EXTENDPARAM2NAME - sExtendParam2 = pcfg->GetString(XSFDRIVER_EXTENDPARAM2NAME, sExtendParam2); -#endif - - dwDefaultLength = XSFTag::ToMS(sDefaultLength); - dwDefaultFade = XSFTag::ToMS(sDefaultFade); - } - catch (xsfc::EShortOfMemory e) - { - } -} - -void CFGSave(LPIConfigIO pcfg) -{ - try - { - pcfg->SetULong(L"PlayInfinitely", dwPlayInfinitely); - pcfg->SetULong(L"Interpolation", dwInterpolation); - pcfg->SetULong(L"SkipSilenceOnStartSec", dwSkipSilenceOnStartSec); - pcfg->SetULong(L"DetectSilenceSec", dwDetectSilenceSec); - pcfg->SetFloat(L"Volume", dVolume / VolumeBase); - pcfg->SetString(L"DefaultLength", sDefaultLength); - pcfg->SetString(L"DefaultFade", sDefaultFade); -#ifdef XSFDRIVER_EXTENDPARAM1NAME - pcfg->SetString(XSFDRIVER_EXTENDPARAM1NAME, sExtendParam1); -#endif -#ifdef XSFDRIVER_EXTENDPARAM2NAME - pcfg->SetString(XSFDRIVER_EXTENDPARAM2NAME, sExtendParam2); -#endif - } - catch (xsfc::EShortOfMemory e) - { - } -} - -void CFGReset(LPIConfigIO pcfg, void *hwndDlg) -{ - (void)pcfg; - try - { - char buf[128]; - xsfc::TWin32::DlgSetCheck(hwndDlg, 0x200, dwPlayInfinitely == 1); - xsfc::TWin32::DlgAddCombo(hwndDlg, IDC_COMBO_INTERPOLATION, xsfc::TString("No interpolation")); - xsfc::TWin32::DlgAddCombo(hwndDlg, IDC_COMBO_INTERPOLATION, xsfc::TString("Linear interpolation")); - xsfc::TWin32::DlgAddCombo(hwndDlg, IDC_COMBO_INTERPOLATION, xsfc::TString("Cosine interpolation")); - ComboBox_SetCurSel(GetDlgItem((HWND)hwndDlg, IDC_COMBO_INTERPOLATION), dwInterpolation); - xsfc::TWin32::DlgSetText(hwndDlg, 0x201, sDefaultLength); - xsfc::TWin32::DlgSetText(hwndDlg, 0x202, sDefaultFade); - xsfc::TWin32::DlgSetText(hwndDlg, 0x203, xsfc::TString(dwSkipSilenceOnStartSec)); - xsfc::TWin32::DlgSetText(hwndDlg, 0x204, xsfc::TString(dwDetectSilenceSec)); - xsfc::TWin32::DlgSetText(hwndDlg, 0x205, xsfc::TString(dVolume / VolumeBase)); -#ifdef XSFDRIVER_EXTENDPARAM1NAME - xsfc::TWin32::DlgSetText(hwndDlg, 0x207, xsfc::TString(XSFDRIVER_EXTENDPARAM1LABEL)); - xsfc::TWin32::DlgSetText(hwndDlg, 0x208, sExtendParam1); - xsfc::TWin32::DlgSetEnabled(hwndDlg, 0x208, true); -#endif -#ifdef XSFDRIVER_EXTENDPARAM2NAME - xsfc::TWin32::DlgSetText(hwndDlg, 0x209, xsfc::TString(XSFDRIVER_EXTENDPARAM2LABEL)); - xsfc::TWin32::DlgSetText(hwndDlg, 0x20a, sExtendParam2); - xsfc::TWin32::DlgSetEnabled(hwndDlg, 0x20a, true); -#endif - for (const CHANNELMAP *pchmap = &chmap[0]; pchmap->devch; pchmap++) - { - for (int ch = 1; ch <= pchmap->devch; ch++) - { -#if defined(HAVE_SPRINTF_S) - sprintf_s(buf, sizeof(buf), pchmap->devname, ch); -#elif defined(HAVE_SNPRINTF) - snprintf(buf, sizeof(buf), pchmap->devname, ch); - buf[sizeof(buf) - 1] = 0; -#elif defined(HAVE_SNPRINTF_) - _snprintf(buf, sizeof(buf), pchmap->devname, ch); -#else - sprintf(buf, pchmap->devname, ch); -#endif - xsfc::TWin32::DlgAddList(hwndDlg, 0x206, buf); - } - } - } - catch (xsfc::EShortOfMemory e) - { - } -} - -void CFGUpdate(LPIConfigIO pcfg, void *hwndDlg) -{ - (void)pcfg; - try - { - dwPlayInfinitely = xsfc::TWin32::DlgGetCheck(hwndDlg, 0x200) ? 1 : 0; - dwInterpolation = xsfc::TWin32::DlgCurCombo(hwndDlg, IDC_COMBO_INTERPOLATION); - sDefaultLength = xsfc::TWin32::DlgGetText(hwndDlg, 0x201); - sDefaultFade = xsfc::TWin32::DlgGetText(hwndDlg, 0x202); - dwSkipSilenceOnStartSec = xsfc::TWin32::DlgGetText(hwndDlg, 0x203).GetULong(); - dwDetectSilenceSec = xsfc::TWin32::DlgGetText(hwndDlg, 0x204).GetULong(); - dVolume = xsfc::TWin32::DlgGetText(hwndDlg, 0x205).GetFloat() * VolumeBase; -#ifdef XSFDRIVER_EXTENDPARAM1NAME - sExtendParam1 = xsfc::TWin32::DlgGetText(hwndDlg, 0x208); -#endif -#ifdef XSFDRIVER_EXTENDPARAM2NAME - sExtendParam2 = xsfc::TWin32::DlgGetText(hwndDlg, 0x20a); -#endif - - dwDefaultLength = XSFTag::ToMS(sDefaultLength); - dwDefaultFade = XSFTag::ToMS(sDefaultFade); - } - catch (xsfc::EShortOfMemory e) - { - } -} - -void CFGMuteChange(void *hwndDlg, int itm) -{ - int cnt = xsfc::TWin32::DlgCntList(hwndDlg, itm); - for (int ch = 0; ch < cnt; ch++) - { - bool mute = xsfc::TWin32::DlgGetList(hwndDlg, itm, ch); - CFGSetChannelMute(ch, mute); - } -} - diff --git a/tools/vio2sf/src/xsfc/xsfcfg.h b/tools/vio2sf/src/xsfc/xsfcfg.h deleted file mode 100644 index 7b6538f0b..000000000 --- a/tools/vio2sf/src/xsfc/xsfcfg.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - -unsigned CFGGetPlayInfinitely(void); -unsigned CFGGetSkipSilenceOnStartSec(void); -unsigned CFGGetDetectSilenceSec(void); -unsigned CFGGetDefaultLength(void); -unsigned CFGGetDefaultFade(void); -bool CFGGetVolume(double &vol); -unsigned long CFGGetChannelMute(int page); -void CFGSetChannelMute(int ch, bool mute); -const wchar_t *CFGGetExtendParam1(void); -const wchar_t *CFGGetExtendParam2(void); - -#ifdef __cplusplus -} - -#include "xsfc.h" - -#if _MSC_VER >= 1200 -#pragma warning(push) -#pragma warning(disable:4290) -#endif - -class IConfigIO -{ -protected: - IConfigIO() {} -public: - virtual ~IConfigIO() {} - - virtual void SetULong(const wchar_t *name, const unsigned long value) throw() = 0; - virtual unsigned long GetULong(const wchar_t *name, const unsigned long defaultvalue = 0) throw() = 0; - virtual void SetFloat(const wchar_t *name, const double value) throw() = 0; - virtual double GetFloat(const wchar_t *name, const double defaultvalue = 0) throw() = 0; - virtual void SetString(const wchar_t *name, const wchar_t *value) throw() = 0; - virtual xsfc::TString GetString(const wchar_t *name, const wchar_t *defaultvalue = 0) throw(xsfc::EShortOfMemory) = 0; -}; -typedef IConfigIO *LPIConfigIO; - -class NullConfig : public IConfigIO -{ -protected: - NullConfig() throw() {} -public: - ~NullConfig() throw() {} - - void SetULong(const wchar_t *name, const unsigned long value) throw() { (void)name, value; } - unsigned long GetULong(const wchar_t *name, const unsigned long defaultvalue = 0) throw() { (void)name; return defaultvalue; } - void SetFloat(const wchar_t *name, const double value) throw() { (void)name, value; } - double GetFloat(const wchar_t *name, const double defaultvalue = 0) throw() { (void)name; return defaultvalue; } - void SetString(const wchar_t *name, const wchar_t *value) throw() { (void)name, value; } - xsfc::TString GetString(const wchar_t *name, const wchar_t *defaultvalue = 0) throw(xsfc::EShortOfMemory) { (void)name; return xsfc::TString(defaultvalue); } - - static LPIConfigIO Create() throw() - { - static NullConfig singleton; - return &singleton; - } -}; - -void CFGDefault(void); -void CFGLoad(LPIConfigIO pcfg); -void CFGReset(LPIConfigIO pcfg, void *hwndDlg); -void CFGUpdate(LPIConfigIO pcfg, void *hwndDlg); -void CFGSave(LPIConfigIO pcfg); -void CFGMuteChange(void *hwndDlg, int itm); - -#if _MSC_VER >= 1200 -#pragma warning(pop) -#endif - -#endif \ No newline at end of file diff --git a/tools/vio2sf/src/xsfc/xsfdrv.c b/tools/vio2sf/src/xsfc/xsfdrv.c deleted file mode 100644 index 98525071e..000000000 --- a/tools/vio2sf/src/xsfc/xsfdrv.c +++ /dev/null @@ -1,148 +0,0 @@ -#define STRICT -#define WIN32_LEAN_AND_MEAN -#include "leakchk.h" - -#include -#include -#include - -#include "../pversion.h" - -#include "drvimpl.h" -#include "xsfdrv.h" - -long dwInterpolation = 0; - -#if _MSC_VER >= 1200 -#pragma comment(linker, "/EXPORT:XSFSetup=_XSFSetup@8") -#endif - -#if defined(_MSC_VER) && !defined(_DEBUG) -#pragma comment(linker,"/MERGE:.rdata=.text") -#endif - -static void * PASCAL XSFLibAlloc(DWORD dwSize) -{ - return malloc(dwSize); -} -static void PASCAL XSFLibFree(void *lpPtr) -{ - free(lpPtr); -} -static int PASCAL XSFStart(void *lpPtr, DWORD dwSize) -{ - return !xsf_start(lpPtr, dwSize); -} -static void PASCAL XSFGen(void *lpPtr, DWORD dwSamples) -{ - xsf_gen(lpPtr, dwSamples); -} -static void PASCAL XSFTerm(void) -{ - xsf_term(); -} - -unsigned long dwChannelMute = 0; - -static void PASCAL XSFSetChannelMute(DWORD dwPage, DWORD dwMute) -{ - if (dwPage == 0) - dwChannelMute = dwMute; -} - -#ifdef XSFDRIVER_EXTENDPARAM1NAME -static void PASCAL XSFSetExtendParam(DWORD dwId, LPCWSTR lpPtr) -{ - //xsf_set_extend_param(dwId, lpPtr); -} -#endif - -TYPE_EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT addInstrument=0; -TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED isInstrumentMuted=0; -TYPE_EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME getInstrumentVolume=0; -TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE isInstrumentSelectionActive=0; -TYPE_EXTEND_PARAM_IMMEDIATE_OPENSOUNDVIEW openSoundView=0; - - -int SoundView_DlgOpen(HINSTANCE hAppIndst); -void SoundView_DlgClose(); - -void doOpenSoundView(void* hinst) -{ - SoundView_DlgOpen(hinst); -} - -void killSoundView(void* hinst) -{ - SoundView_DlgClose(); -} - -typedef void (*TOpenSoundView)(void* hinst); -typedef struct CallbackSet -{ - TOpenSoundView doOpenSoundView; - TOpenSoundView killSoundView; -}; -struct CallbackSet soundViewCallbacks = { &doOpenSoundView, &killSoundView }; - - -static void PASCAL XSFSetExtendParamImmediate(DWORD dwId, LPVOID lpPtr) -{ - switch(dwId) - { - case EXTEND_PARAM_IMMEDIATE_INTERPOLATION: - dwInterpolation = *(unsigned long*)lpPtr; - break; - - case EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT: addInstrument = (TYPE_EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT) lpPtr; break; - case EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED: isInstrumentMuted = (TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED) lpPtr; break; - case EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME: getInstrumentVolume = (TYPE_EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME) lpPtr; break; - case EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE: isInstrumentSelectionActive = (TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE) lpPtr; break; - case EXTEND_PARAM_IMMEDIATE_OPENSOUNDVIEW: - openSoundView = (TYPE_EXTEND_PARAM_IMMEDIATE_OPENSOUNDVIEW) lpPtr; - openSoundView(&soundViewCallbacks); - break; - } -} - -static void *lpUserWrok = 0; -static LPFNGETLIB_XSFDRV lpfnGetLib = 0; -static IXSFDRV ifaossf = -{ - XSFLibAlloc, - XSFLibFree, - XSFStart, - XSFGen, - XSFTerm, - 4, - XSFSetChannelMute, - XSFSetExtendParam, - XSFSetExtendParamImmediate -}; - -IXSFDRV * PASCAL XSFSetup(LPFNGETLIB_XSFDRV lpfn, void *lpWork) -{ - lpfnGetLib = lpfn; - lpUserWrok = lpWork; - return &ifaossf; -} - -int xsf_get_lib(char *pfilename, void **ppbuffer, unsigned *plength) -{ - DWORD length32; - if (!lpfnGetLib || lpfnGetLib(lpUserWrok, pfilename, ppbuffer, &length32)) return 0; - if (plength) *plength = length32; - return 1; -} - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - if (fdwReason == DLL_PROCESS_ATTACH) - { -#if defined(_MSC_VER) && defined(_DEBUG) - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF); -#endif - DisableThreadLibraryCalls(hinstDLL); - } - return TRUE; -} diff --git a/tools/vio2sf/src/xsfc/xsfdrv.h b/tools/vio2sf/src/xsfc/xsfdrv.h deleted file mode 100644 index d0f0c02f6..000000000 --- a/tools/vio2sf/src/xsfc/xsfdrv.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -typedef int (PASCAL * LPFNGETLIB_XSFDRV)(void *lpWork, LPSTR lpszFilename, void **ppBuffer, DWORD *pdwSize); -typedef struct -{ - /* V1 */ - void * (PASCAL * LibAlloc)(DWORD dwSize); - void (PASCAL * LibFree)(void *lpPtr); - int (PASCAL * Start)(void *lpPtr, DWORD dwSize); - void (PASCAL * Gen)(void *lpPtr, DWORD dwSamples); - void (PASCAL * Term)(void); - - /* V2 */ - DWORD dwInterfaceVersion; - void (PASCAL * SetChannelMute)(DWORD dwPage, DWORD dwMute); - - /* V3 */ - void (PASCAL * SetExtendParam)(DWORD dwId, LPCWSTR lpPtr); - - /* V4 */ - void (PASCAL * SetExtendParamImmediate)(DWORD dwId, LPVOID lpPtr); -} IXSFDRV; - -#define EXTEND_PARAM_IMMEDIATE_INTERPOLATION 0 -#define EXTEND_PARAM_IMMEDIATE_INTERPOLATION_NONE 0 -#define EXTEND_PARAM_IMMEDIATE_INTERPOLATION_LINEAR 1 -#define EXTEND_PARAM_IMMEDIATE_INTERPOLATION_COSINE 2 - -#define EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT 1 -#define EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED 2 -#define EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME 3 -#define EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE 4 -#define EXTEND_PARAM_IMMEDIATE_OPENSOUNDVIEW 5 - -typedef void (*TYPE_EXTEND_PARAM_IMMEDIATE_ADDINSTRUMENT)(unsigned long addr, int type); -typedef BOOL (*TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTMUTED)(unsigned long addr); -typedef unsigned long (*TYPE_EXTEND_PARAM_IMMEDIATE_GETINSTRUMENTVOLUME)(unsigned long addr); -typedef BOOL (*TYPE_EXTEND_PARAM_IMMEDIATE_ISINSTRUMENTSELECTIONACTIVE)(); -typedef unsigned long (*TYPE_EXTEND_PARAM_IMMEDIATE_OPENSOUNDVIEW)(void* callback); - -typedef IXSFDRV * (PASCAL * LPFNXSFDRVSETUP)(LPFNGETLIB_XSFDRV lpfn, void *lpWork); -/* IXSFDRV * PASCAL XSFDRVSetup(LPFNGETLIB_XSFDRV lpfn, void *lpWork); */ - -#ifdef __cplusplus -} -#endif - diff --git a/tools/vio2sf/src/xsfc/xsfui.rc b/tools/vio2sf/src/xsfc/xsfui.rc deleted file mode 100644 index 09ac23243..000000000 --- a/tools/vio2sf/src/xsfc/xsfui.rc +++ /dev/null @@ -1,413 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "xsfui.rh" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winresx.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Japanese resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) -#ifdef _WIN32 -LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT -#pragma code_page(932) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "xsfui.rh\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winresx.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Japanese resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -1 DIALOGEX 0, 0, 172, 202 -STYLE DS_SETFONT | WS_CHILD -FONT 9, "MS UI Gothic", 0, 0, 0x0 -BEGIN - GROUPBOX "General",IDC_STATIC,5,5,160,90 - CONTROL "Play infinitely",512,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,15,60,10 - EDITTEXT 513,100,30,25,12,ES_RIGHT | ES_AUTOHSCROLL - LTEXT "Default play length (m:s)",IDC_STATIC,10,30,85,9 - EDITTEXT 514,100,45,25,12,ES_RIGHT | ES_AUTOHSCROLL - LTEXT "Default fadeout length (m:s)",IDC_STATIC,10,45,85,9 - LTEXT "Skip silence on start(sec)",IDC_STATIC,10,60,80,9 - EDITTEXT 515,100,60,25,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Detect silence(sec)",IDC_STATIC,10,75,80,9 - EDITTEXT 516,100,75,25,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - GROUPBOX "Output",IDC_STATIC,5,100,160,75 - LTEXT "Volume",IDC_STATIC,10,110,30,9 - EDITTEXT 517,45,110,25,12,ES_RIGHT | ES_AUTOHSCROLL - LTEXT "",519,10,125,50,9 - EDITTEXT 520,65,125,25,12,ES_RIGHT | ES_AUTOHSCROLL | WS_DISABLED - LTEXT "",521,10,140,50,9 - EDITTEXT 522,65,140,25,12,ES_RIGHT | ES_AUTOHSCROLL | WS_DISABLED - LISTBOX 518,100,105,60,45,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - LTEXT "Mute",IDC_STATIC,80,110,20,9 - DEFPUSHBUTTON "OK",IDOK,84,181,35,15,NOT WS_VISIBLE - PUSHBUTTON "Cancel",IDCANCEL,129,181,35,15,NOT WS_VISIBLE - COMBOBOX IDC_COMBO_INTERPOLATION,10,156,78,55,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Instruments",IDC_BUTTON_INSTRUMENTSELECTION,70,12,50,14 - PUSHBUTTON "View SPU",IDC_BUTTON_VIEWSPU,123,12,37,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - 1, DIALOG - BEGIN - BOTTOMMARGIN, 192 - END -END -#endif // APSTUDIO_INVOKED - -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_INSTRUMENTDLG DIALOGEX 0, 0, 352, 215 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOOLWINDOW -CAPTION "Instrument Selection" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LISTBOX IDC_LISTINSTRUMENTS,144,24,204,186,LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Clear List",IDC_BUTTONCLEARLIST,6,6,72,14 - LTEXT "0 instruments displayed",IDC_STATICNBINSTRUMENTSDISPLAYED,6,196,84,8 - PUSHBUTTON "All",IDC_BUTTONSELECTALL,300,6,24,14 - PUSHBUTTON "None",IDC_BUTTONSELECTNONE,324,6,24,14 - LTEXT "Volume of selected instruments (0% - 100%):",IDC_STATICHELP,6,138,90,18 - PUSHBUTTON "Up",IDC_BUTTONMOVEINSTRUMENTUP,114,78,24,14 - PUSHBUTTON "Down",IDC_BUTTONMOVEINSTRUMENTDOWN,114,96,24,14 - LTEXT "Search Address:",IDC_STATICNBINSTRUMENTSDISPLAYED3,145,8,56,12 - EDITTEXT IDC_EDIT_ADDRESSSEARCH,200,6,58,12,ES_AUTOHSCROLL | ES_WANTRETURN - CONTROL "",IDC_SLIDER_VOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_TOOLTIPS | WS_TABSTOP,0,156,138,30 - LTEXT "Select to mute (or reduce volume).\n\nDouble click to change instrument name.\n\nInstruments are added to the list as they are played.",IDC_STATICHELP2,6,36,90,72 -END - -IDD_DIALOGENTERINSTRUMENTNAME DIALOGEX 0, 0, 280, 87 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Enter Instrument Name" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,84,60,50,14 - PUSHBUTTON "Cancel",IDCANCEL,144,60,50,14 - EDITTEXT IDC_EDIT_ENTERINSTRUMENTNAME,12,12,252,14,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_ENTERINSTRUMENTNAMEADDRESS,12,36,252,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY -END - -IDD_DIALOG_MIXERINSTRUMENT DIALOGEX 0, 0, 452, 17 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_TRANSPARENT -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - CONTROL "",IDC_SLIDER_INSTRUMENTVOLUME,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,185,0,192,17 - CONTROL "Mute",IDC_CHECK_INSTRUMENTMUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,379,2,32,11 - CONTROL "",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,0,3,12,10 - LTEXT "Instrument Name",IDC_STATIC_INSTRUMENTNAME,12,4,131,8,SS_ENDELLIPSIS - CONTROL "Low Level",IDC_CHECK_INSTRUMENTLOWLEVEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,131,3,47,11 -END - -IDD_SOUND_VIEW DIALOGEX 0, 0, 550, 268 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Sound View" -FONT 8, "Ms Shell Dlg 2", 0, 0, 0x0 -BEGIN - CTEXT "Volume",IDC_STATIC,30,22,100,11,0,WS_EX_STATICEDGE - CTEXT "Pan",IDC_STATIC,30,34,100,11,0,WS_EX_STATICEDGE - CTEXT "Hold",IDC_STATIC,131,22,22,11,0,WS_EX_STATICEDGE - CTEXT "Busy",IDC_STATIC,131,34,22,11,0,WS_EX_STATICEDGE - CTEXT "Repeat Mode",IDC_STATIC,154,22,72,11,0,WS_EX_STATICEDGE - CTEXT "Format",IDC_STATIC,154,34,72,11,0,WS_EX_STATICEDGE - CTEXT "Source Addr",IDC_STATIC,227,22,60,11,0,WS_EX_STATICEDGE - CTEXT "Loop Start",IDC_STATIC,227,34,60,11,0,WS_EX_STATICEDGE - CTEXT "Timer Value",IDC_STATIC,288,22,88,11,0,WS_EX_STATICEDGE - CTEXT "Sound Pos / Len",IDC_STATIC,288,34,88,11,0,WS_EX_STATICEDGE - RTEXT "#00",IDC_SOUND0ID,4,50,23,10 - CONTROL "",IDC_SOUND0VOLBAR,"msctls_progress32",PBS_SMOOTH,30,49,68,11 - CTEXT "",IDC_SOUND0VOL,100,49,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND0PANBAR,"msctls_progress32",PBS_SMOOTH,30,62,68,10 - CTEXT "",IDC_SOUND0PAN,100,61,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0HOLD,131,49,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0BUSY,131,61,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0REPEATMODE,154,49,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0FORMAT,154,61,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0SAD,227,49,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0PNT,227,61,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0TMR,288,49,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND0POSLEN,288,61,88,11,0,WS_EX_STATICEDGE - RTEXT "#01",IDC_SOUND1ID,4,75,23,10 - CONTROL "",IDC_SOUND1VOLBAR,"msctls_progress32",PBS_SMOOTH,30,74,68,11 - CTEXT "",IDC_SOUND1VOL,100,74,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND1PANBAR,"msctls_progress32",PBS_SMOOTH,30,87,68,11 - CTEXT "",IDC_SOUND1PAN,100,87,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1HOLD,131,74,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1BUSY,131,87,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1REPEATMODE,154,74,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1FORMAT,154,87,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1SAD,227,74,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1PNT,227,87,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1TMR,288,74,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND1POSLEN,288,87,88,11,0,WS_EX_STATICEDGE - RTEXT "#02",IDC_SOUND2ID,4,101,23,10 - CONTROL "",IDC_SOUND2VOLBAR,"msctls_progress32",PBS_SMOOTH,30,100,68,11 - CTEXT "",IDC_SOUND2VOL,100,100,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND2PANBAR,"msctls_progress32",PBS_SMOOTH,30,113,68,11 - CTEXT "",IDC_SOUND2PAN,100,113,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2HOLD,131,100,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2BUSY,131,113,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2REPEATMODE,154,100,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2FORMAT,154,113,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2SAD,227,100,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2PNT,227,113,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2TMR,288,100,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND2POSLEN,288,113,88,11,0,WS_EX_STATICEDGE - RTEXT "#03",IDC_SOUND3ID,4,127,23,10 - CONTROL "",IDC_SOUND3VOLBAR,"msctls_progress32",PBS_SMOOTH,30,126,68,11 - CTEXT "",IDC_SOUND3VOL,100,126,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND3PANBAR,"msctls_progress32",PBS_SMOOTH,30,139,68,11 - CTEXT "",IDC_SOUND3PAN,100,139,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3HOLD,131,126,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3BUSY,131,139,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3REPEATMODE,154,126,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3FORMAT,154,139,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3SAD,227,126,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3PNT,227,139,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3TMR,288,126,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND3POSLEN,288,139,88,11,0,WS_EX_STATICEDGE - RTEXT "#04",IDC_SOUND4ID,4,153,23,10 - CONTROL "",IDC_SOUND4VOLBAR,"msctls_progress32",PBS_SMOOTH,30,152,68,11 - CTEXT "",IDC_SOUND4VOL,100,152,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND4PANBAR,"msctls_progress32",PBS_SMOOTH,30,165,68,11 - CTEXT "",IDC_SOUND4PAN,100,165,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4HOLD,131,152,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4BUSY,131,165,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4REPEATMODE,154,152,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4FORMAT,154,165,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4SAD,227,152,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4PNT,227,165,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4TMR,288,152,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND4POSLEN,288,165,88,11,0,WS_EX_STATICEDGE - RTEXT "#05",IDC_SOUND5ID,4,179,23,10 - CONTROL "",IDC_SOUND5VOLBAR,"msctls_progress32",PBS_SMOOTH,30,178,68,11 - CTEXT "",IDC_SOUND5VOL,100,178,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND5PANBAR,"msctls_progress32",PBS_SMOOTH,30,191,68,11 - CTEXT "",IDC_SOUND5PAN,100,191,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5HOLD,131,178,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5BUSY,131,191,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5REPEATMODE,154,178,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5FORMAT,154,191,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5SAD,227,178,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5PNT,227,191,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5TMR,288,178,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND5POSLEN,288,191,88,11,0,WS_EX_STATICEDGE - RTEXT "#06",IDC_SOUND6ID,4,205,23,10 - CONTROL "",IDC_SOUND6VOLBAR,"msctls_progress32",PBS_SMOOTH,30,204,68,11 - CTEXT "",IDC_SOUND6VOL,100,204,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND6PANBAR,"msctls_progress32",PBS_SMOOTH,30,217,68,11 - CTEXT "",IDC_SOUND6PAN,100,217,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6HOLD,131,204,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6BUSY,131,217,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6REPEATMODE,154,204,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6FORMAT,154,217,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6SAD,227,204,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6PNT,227,217,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6TMR,288,204,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND6POSLEN,288,217,88,11,0,WS_EX_STATICEDGE - RTEXT "#07",IDC_SOUND7ID,4,231,23,10 - CONTROL "",IDC_SOUND7VOLBAR,"msctls_progress32",PBS_SMOOTH,30,230,68,11 - CTEXT "",IDC_SOUND7VOL,100,230,30,11,0,WS_EX_STATICEDGE - CONTROL "",IDC_SOUND7PANBAR,"msctls_progress32",PBS_SMOOTH,30,243,68,11 - CTEXT "",IDC_SOUND7PAN,100,243,30,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7HOLD,131,230,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7BUSY,131,243,22,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7REPEATMODE,154,230,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7FORMAT,154,243,72,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7SAD,227,230,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7PNT,227,243,60,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7TMR,288,230,88,11,0,WS_EX_STATICEDGE - CTEXT "",IDC_SOUND7POSLEN,288,243,88,11,0,WS_EX_STATICEDGE - PUSHBUTTON "V",IDC_SOUNDVIEW_CHANSWITCH,16,33,12,12 - CONTROL "Vol.Mode",IDC_BUTTON_VOLMODE,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,13,7,45,10 - CONTROL "Check1",IDC_SOUND0MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,62,10,10 - CONTROL "Check1",IDC_SOUND1MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,87,10,10 - CONTROL "Check1",IDC_SOUND2MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,114,10,10 - CONTROL "Check1",IDC_SOUND3MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,140,10,10 - CONTROL "Check1",IDC_SOUND4MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,164,10,10 - CONTROL "Check1",IDC_SOUND5MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,192,10,10 - CONTROL "Check1",IDC_SOUND6MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,217,10,10 - CONTROL "Check1",IDC_SOUND7MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,243,10,10 - GROUPBOX "Capture 0",IDC_STATIC,379,90,157,80 - LTEXT "508 ctrl",IDC_STATIC,403,103,25,8 - CHECKBOX "b0 AddCh1toCh0",IDC_CAP0_ADD,433,103,68,10 - CHECKBOX "b1 Src",IDC_CAP0_SRC,383,116,36,10 - CHECKBOX "b2 One-Shot",IDC_CAP0_ONESHOT,450,116,54,10 - CHECKBOX "b3 Typ",IDC_CAP0_TYPE,383,127,36,10 - CHECKBOX "b7 Active",IDC_CAP0_ACTIVE,450,127,49,10 - LTEXT "",IDC_CAP0_DAD,383,141,37,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP0_CTRL,383,103,16,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP0_SRCTEXT,419,116,25,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP0_TYPETEXT,419,127,25,11,0,WS_EX_STATICEDGE - LTEXT "510 DAD",IDC_STATIC,423,143,29,8 - LTEXT "514 LEN",IDC_STATIC,492,143,27,8 - LTEXT "",IDC_CAP0_LEN,453,141,37,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP0_CURDAD,384,156,37,11,0,WS_EX_STATICEDGE - LTEXT "DAD CUR",IDC_STATIC,423,156,32,8 - CHECKBOX "Running",IDC_CAP0_RUNNING,457,156,49,10 - GROUPBOX "Capture 1",IDC_STATIC,379,174,157,80 - LTEXT "509 ctrl",IDC_STATIC,403,187,25,8 - CHECKBOX "b0 AddCh3toCh2",IDC_CAP1_ADD,433,187,68,10 - CHECKBOX "b1 Src",IDC_CAP1_SRC,383,200,36,10 - CHECKBOX "b2 One-Shot",IDC_CAP1_ONESHOT,449,200,54,10 - CHECKBOX "b3 Typ",IDC_CAP1_TYPE,383,211,36,10 - CHECKBOX "b7 Active",IDC_CAP1_ACTIVE,449,211,49,10 - LTEXT "",IDC_CAP1_DAD,383,226,37,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP1_CTRL,383,187,16,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP1_SRCTEXT,419,200,25,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP1_TYPETEXT,419,211,25,11,0,WS_EX_STATICEDGE - LTEXT "518 DAD",IDC_STATIC,423,227,29,8 - LTEXT "51C LEN",IDC_STATIC,492,227,28,8 - LTEXT "",IDC_CAP1_LEN,453,226,37,11,0,WS_EX_STATICEDGE - LTEXT "",IDC_CAP1_CURDAD,383,240,37,11,0,WS_EX_STATICEDGE - LTEXT "DAD CUR",IDC_STATIC,423,240,32,8 - CHECKBOX "Running",IDC_CAP1_RUNNING,457,240,49,10 - GROUPBOX "Sound Control",IDC_STATIC,378,18,158,69 - LTEXT "",IDC_SNDCTRL_CTRL,385,29,26,11,0,WS_EX_STATICEDGE - LTEXT "500 Ctrl",IDC_STATIC,416,31,26,8 - LTEXT "",IDC_SNDCTRL_VOL,385,42,26,11,0,WS_EX_STATICEDGE - LTEXT "b0-6 Vol",IDC_STATIC,415,44,27,8 - LTEXT "",IDC_SNDCTRL_BIAS,456,30,26,11,0,WS_EX_STATICEDGE - LTEXT "504 Bias",IDC_STATIC,485,32,28,8 - CHECKBOX "b15 Enable",IDC_SNDCTRL_ENABLE,473,44,49,10 - LTEXT "",IDC_SNDCTRL_LEFTOUT,385,57,12,11,0,WS_EX_STATICEDGE - LTEXT "b8-9 L-Out",IDC_STATIC,400,59,36,8 - LTEXT "",IDC_SNDCTRL_LEFTOUTTEXT,445,57,25,11,0,WS_EX_STATICEDGE - CHECKBOX "b12 ch1 nomix",IDC_SNDCTRL_CH1NOMIX,473,57,59,10 - LTEXT "",IDC_SNDCTRL_RIGHTOUT,385,70,12,11,0,WS_EX_STATICEDGE - LTEXT "b10-11 R-Out",IDC_STATIC,400,72,45,8 - LTEXT "",IDC_SNDCTRL_RIGHTOUTTEXT,445,71,25,11,0,WS_EX_STATICEDGE - CHECKBOX "b13 ch3 nomix",IDC_SNDCTRL_CH3NOMIX,473,71,59,10 - CONTROL "Capture muted channels",IDC_SOUND_CAPTURE_MUTED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,435,5,94,10 - PUSHBUTTON "Analyze Cap",IDC_SOUND_ANALYZE_CAP,379,3,50,14 - PUSHBUTTON "Unmute All",IDC_SOUND_UNMUTE_ALL,325,3,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_INSTRUMENTDLG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 345 - TOPMARGIN, 7 - BOTTOMMARGIN, 208 - END - - IDD_DIALOGENTERINSTRUMENTNAME, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 273 - TOPMARGIN, 7 - BOTTOMMARGIN, 80 - END - - IDD_DIALOG_MIXERINSTRUMENT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 445 - TOPMARGIN, 7 - BOTTOMMARGIN, 10 - END - - IDD_SOUND_VIEW, DIALOG - BEGIN - LEFTMARGIN, 7 - TOPMARGIN, 7 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/tools/vio2sf/src/xsfc/xsfui.rh b/tools/vio2sf/src/xsfc/xsfui.rh deleted file mode 100644 index 8541388aa..000000000 --- a/tools/vio2sf/src/xsfc/xsfui.rh +++ /dev/null @@ -1,199 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by xsfui.rc -// -#define IDD_INSTRUMENTDLG 101 -#define IDD_DIALOGENTERINSTRUMENTNAME 102 -#define IDD_DIALOG_MIXERINSTRUMENT 104 -#define IDD_DIALOG1 105 -#define IDD_SOUND_VIEW 105 -#define IDC_COMBO_INTERPOLATION 1000 -#define IDC_SOUNDVIEW_CHANSWITCH 1001 -#define IDC_BUTTON_INSTRUMENTSELECTION 1001 -#define IDC_LISTINSTRUMENTS 1002 -#define IDC_BUTTON_SPU 1002 -#define IDC_BUTTON_VIEWSPU 1002 -#define IDC_BUTTONDISPLAYLIST 1003 -#define IDC_BUTTON_VOLMODE 1004 -#define IDC_BUTTONCLEARLIST 1004 -#define IDC_STATICNBINSTRUMENTSDISPLAYED 1005 -#define IDC_BUTTONSELECTALL 1006 -#define IDC_EDIT_ENTERINSTRUMENTNAME 1006 -#define IDC_BUTTONSELECTNONE 1007 -#define IDC_EDIT_ENTERINSTRUMENTNAMEADDRESS 1007 -#define IDC_STATICNBINSTRUMENTSDISPLAYED2 1008 -#define IDC_STATICHELP 1008 -#define IDC_BUTTONMOVEINSTRUMENTUP 1009 -#define IDC_STATICNBINSTRUMENTSDISPLAYED3 1010 -#define IDC_BUTTONMOVEINSTRUMENTDOWN 1011 -#define IDC_STATICHELP2 1012 -#define IDC_EDIT_ADDRESSSEARCH 1013 -#define IDC_SLIDER_VOLUME 1016 -#define IDC_SLIDER_INSTRUMENTVOLUME 1020 -#define IDC_CHECK_INSTRUMENTMUTE 1021 -#define IDC_CHECK_INSTRUMENTMUTE2 1022 -#define IDC_CHECK_INSTRUMENTLOWLEVEL 1022 -#define IDC_CAP0_ADD 1023 -#define IDC_CAP0_CURDAD 1024 -#define IDC_CAP1_ADD 1025 -#define IDC_SPU_ADVANCED 1025 -#define IDC_CAP1_CURDAD 1026 -#define IDC_RADIO1 1027 -#define IDC_SNDCTRL_ENABLE 1028 -#define IDC_STATIC_INSTRUMENTNAME 1028 -#define IDC_SNDCTRL_CH1NOMIX 1029 -#define IDC_SNDCTRL_CH3NOMIX 1030 -#define IDC_SOUND_CAPTURE_MUTED 1031 -#define IDC_SOUND_ANALYZE_CAP 1032 -#define IDC_SOUND_UNMUTE_ALL 1033 -#define IDC_CAP0_SRC 1075 -#define IDC_CAP0_ONESHOT 1076 -#define IDC_CAP0_TYPE 1077 -#define IDC_CAP0_ACTIVE 1078 -#define IDC_CAP0_RUNNING 1079 -#define IDC_CAP1_SRC 1080 -#define IDC_CAP1_ONESHOT 1081 -#define IDC_CAP1_TYPE 1082 -#define IDC_CAP1_ACTIVE 1083 -#define IDC_CAP1_RUNNING 1084 -#define IDC_SOUND0ID 21350 -#define IDC_SOUND1ID 21351 -#define IDC_SOUND2ID 21352 -#define IDC_SOUND3ID 21353 -#define IDC_SOUND4ID 21354 -#define IDC_SOUND5ID 21355 -#define IDC_SOUND6ID 21356 -#define IDC_SOUND7ID 21357 -#define IDC_SOUND0VOL 21358 -#define IDC_SOUND1VOL 21359 -#define IDC_SOUND2VOL 21360 -#define IDC_SOUND3VOL 21361 -#define IDC_SOUND4VOL 21362 -#define IDC_SOUND5VOL 21363 -#define IDC_SOUND6VOL 21364 -#define IDC_SOUND7VOL 21365 -#define IDC_SOUND0VOLBAR 21366 -#define IDC_SOUND1VOLBAR 21367 -#define IDC_SOUND2VOLBAR 21368 -#define IDC_SOUND3VOLBAR 21369 -#define IDC_SOUND4VOLBAR 21370 -#define IDC_SOUND5VOLBAR 21371 -#define IDC_SOUND6VOLBAR 21372 -#define IDC_SOUND7VOLBAR 21373 -#define IDC_SOUND0PAN 21374 -#define IDC_SOUND1PAN 21375 -#define IDC_SOUND2PAN 21376 -#define IDC_SOUND3PAN 21377 -#define IDC_SOUND4PAN 21378 -#define IDC_SOUND5PAN 21379 -#define IDC_SOUND6PAN 21380 -#define IDC_SOUND7PAN 21381 -#define IDC_SOUND0PANBAR 21382 -#define IDC_SOUND1PANBAR 21383 -#define IDC_SOUND2PANBAR 21384 -#define IDC_SOUND3PANBAR 21385 -#define IDC_SOUND4PANBAR 21386 -#define IDC_SOUND5PANBAR 21387 -#define IDC_SOUND6PANBAR 21388 -#define IDC_SOUND7PANBAR 21389 -#define IDC_SOUND0HOLD 21390 -#define IDC_SOUND1HOLD 21391 -#define IDC_SOUND2HOLD 21392 -#define IDC_SOUND3HOLD 21393 -#define IDC_SOUND4HOLD 21394 -#define IDC_SOUND5HOLD 21395 -#define IDC_SOUND6HOLD 21396 -#define IDC_SOUND7HOLD 21397 -#define IDC_SOUND0BUSY 21398 -#define IDC_SOUND1BUSY 21399 -#define IDC_SOUND2BUSY 21400 -#define IDC_SOUND3BUSY 21401 -#define IDC_SOUND4BUSY 21402 -#define IDC_SOUND5BUSY 21403 -#define IDC_SOUND6BUSY 21404 -#define IDC_SOUND7BUSY 21405 -#define IDC_SOUND0REPEATMODE 21406 -#define IDC_SOUND1REPEATMODE 21407 -#define IDC_SOUND2REPEATMODE 21408 -#define IDC_SOUND3REPEATMODE 21409 -#define IDC_SOUND4REPEATMODE 21410 -#define IDC_SOUND5REPEATMODE 21411 -#define IDC_SOUND6REPEATMODE 21412 -#define IDC_SOUND7REPEATMODE 21413 -#define IDC_SOUND0FORMAT 21414 -#define IDC_SOUND1FORMAT 21415 -#define IDC_SOUND2FORMAT 21416 -#define IDC_SOUND3FORMAT 21417 -#define IDC_SOUND4FORMAT 21418 -#define IDC_SOUND5FORMAT 21419 -#define IDC_SOUND6FORMAT 21420 -#define IDC_SOUND7FORMAT 21421 -#define IDC_SOUND0SAD 21422 -#define IDC_SOUND1SAD 21423 -#define IDC_SOUND2SAD 21424 -#define IDC_SOUND3SAD 21425 -#define IDC_SOUND4SAD 21426 -#define IDC_SOUND5SAD 21427 -#define IDC_SOUND6SAD 21428 -#define IDC_SOUND7SAD 21429 -#define IDC_SOUND0PNT 21430 -#define IDC_SOUND1PNT 21431 -#define IDC_SOUND2PNT 21432 -#define IDC_SOUND3PNT 21433 -#define IDC_SOUND4PNT 21434 -#define IDC_SOUND5PNT 21435 -#define IDC_SOUND6PNT 21436 -#define IDC_SOUND7PNT 21437 -#define IDC_SOUND0TMR 21438 -#define IDC_SOUND1TMR 21439 -#define IDC_SOUND2TMR 21440 -#define IDC_SOUND3TMR 21441 -#define IDC_SOUND4TMR 21442 -#define IDC_SOUND5TMR 21443 -#define IDC_SOUND6TMR 21444 -#define IDC_SOUND7TMR 21445 -#define IDC_SOUND0POSLEN 21446 -#define IDC_SOUND1POSLEN 21447 -#define IDC_SOUND2POSLEN 21448 -#define IDC_SOUND3POSLEN 21449 -#define IDC_SOUND4POSLEN 21450 -#define IDC_SOUND5POSLEN 21451 -#define IDC_SOUND6POSLEN 21452 -#define IDC_SOUND7POSLEN 21453 -#define IDC_CAP0_DAD 21454 -#define IDC_CAP0_CTRL 21455 -#define IDC_CAP0_SRCTEXT 21456 -#define IDC_CAP0_TYPETEXT 21457 -#define IDC_CAP0_LEN 21458 -#define IDC_SOUND0POSLEN7 21459 -#define IDC_CAP1_DAD 21459 -#define IDC_CAP1_CTRL 21460 -#define IDC_CAP1_SRCTEXT 21461 -#define IDC_CAP1_TYPETEXT 21462 -#define IDC_CAP1_LEN 21463 -#define IDC_SNDCTRL_CTRL 21464 -#define IDC_SNDCTRL_VOL 21465 -#define IDC_SNDCTRL_BIAS 21466 -#define IDC_SNDCTRL_LEFTOUT 21467 -#define IDC_SNDCTRL_LEFTOUTTEXT 21468 -#define IDC_SNDCTRL_RIGHTOUT 21469 -#define IDC_SNDCTRL_RIGHTOUTTEXT 21470 -#define IDC_SOUND0MUTE 22001 -#define IDC_SOUND1MUTE 22002 -#define IDC_SOUND2MUTE 22003 -#define IDC_SOUND3MUTE 22004 -#define IDC_SOUND4MUTE 22005 -#define IDC_SOUND5MUTE 22006 -#define IDC_SOUND6MUTE 22007 -#define IDC_SOUND7MUTE 22008 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 106 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1029 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/tools/vio2sf/vio2sf.dsp b/tools/vio2sf/vio2sf.dsp deleted file mode 100644 index 6f5e77e4f..000000000 --- a/tools/vio2sf/vio2sf.dsp +++ /dev/null @@ -1,348 +0,0 @@ -# Microsoft Developer Studio Project File - Name="vio2sf" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=vio2sf - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "vio2sf.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "vio2sf.mak" CFG="vio2sf - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "vio2sf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "vio2sf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "vio2sf - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_vio2sf" -# PROP Intermediate_Dir "Release_vio2sf" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AOSSFDRV_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /O2 /I "src/vio2sf/desmume" /I "src/vio2sf/zlib" /I "." /D "LSB_FIRST" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AOSSFDRV_EXPORTS" /D "XSFDRIVER_EXTENDPARAM1NAME" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "NDEBUG" -# ADD RSC /l 0x411 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /pdb:none /machine:I386 /out:"vio2sf.bin" -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=copy /y vio2sf.bin OUTPUT\winamp5\plugins copy /y vio2sf.bin OUTPUT\winamp2\plugins copy /y vio2sf.bin OUTPUT\kbmed\plugins copy /y vio2sf.bin OUTPUT\fb8 copy /y vio2sf.bin OUTPUT\fb9\components -# End Special Build Tool - -!ELSEIF "$(CFG)" == "vio2sf - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_vio2sf" -# PROP Intermediate_Dir "Debug_vio2sf" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AOSSFDRV_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "src/vio2sf/desmume" /I "src/vio2sf/zlib" /I "." /D "LSB_FIRST" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "AOSSFDRV_EXPORTS" /D "XSFDRIVER_EXTENDPARAM1NAME" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x411 /d "_DEBUG" -# ADD RSC /l 0x411 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"vio2sf.bin" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "vio2sf - Win32 Release" -# Name "vio2sf - Win32 Debug" -# Begin Group "vio2sf" - -# PROP Default_Filter "" -# Begin Group "zlib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\adler32.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\crc32.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\crc32.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\crypt.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\infback.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\inffast.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\inffixed.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\inflate.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\inflate.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\inftrees.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\inftrees.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\uncompr.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\zconf.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\zlib.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\zutil.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\zutil.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\zlib\contrib\masmx86\inffas32.obj -# End Source File -# End Group -# Begin Group "desmume" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\ARM9.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\arm_instructions.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\arm_instructions.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\armcpu.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\armcpu.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\bios.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\bios.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\bits.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\cflash.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\config.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\cp15.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\cp15.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\debug.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\Disassembler.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\dscard.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\FIFO.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\FIFO.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\GPU.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\GPU.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\instruction_tabdef.inc -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\matrix.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\matrix.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\mc.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\mc.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\mem.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\MMU.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\MMU.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\NDSSystem.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\NDSSystem.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\registers.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\SPU.cpp -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\SPU.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\thumb_instructions.c -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\thumb_instructions.h -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\thumb_tabdef.inc -# End Source File -# Begin Source File - -SOURCE=.\src\vio2sf\desmume\types.h -# End Source File -# End Group -# End Group -# Begin Group "xsfc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\xsfc\tagget.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfdrv.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\src\vio2sf\drvimpl.c -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\drvimpl.h -# End Source File -# Begin Source File - -SOURCE=.\src\pversion.h -# End Source File -# Begin Source File - -SOURCE=.\src\xsfc\xsfdrv.c -# End Source File -# End Target -# End Project diff --git a/tools/vio2sf/vio2sf.dsw b/tools/vio2sf/vio2sf.dsw deleted file mode 100644 index fb45c9d94..000000000 --- a/tools/vio2sf/vio2sf.dsw +++ /dev/null @@ -1,155 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "foo_xsf8"=.\foo_xsf8.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name foobar2000_SDK - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_sdk_helpers - End Project Dependency - Begin Project Dependency - Project_Dep_Name pfc - End Project Dependency - Begin Project Dependency - Project_Dep_Name foobar2000_component_client - End Project Dependency -}}} - -############################################################################### - -Project: "foobar2000_SDK"=.\src\foobar8\foobar2000\SDK\foobar2000_SDK.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name utf8api - End Project Dependency -}}} - -############################################################################### - -Project: "foobar2000_component_client"=.\src\foobar8\foobar2000\foobar2000_component_client\foobar2000_component_client.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "foobar2000_sdk_helpers"=.\src\foobar8\foobar2000\helpers\foobar2000_sdk_helpers.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "in_xsf"=.\in_xsf.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "in_xsfu"=.\in_xsfu.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "kpixsf"=.\kpixsf.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "pfc"=.\src\foobar8\pfc\pfc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "utf8api"=.\src\foobar8\foobar2000\utf8api\utf8api.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name pfc - End Project Dependency -}}} - -############################################################################### - -Project: "vio2sf"=.\vio2sf.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/tools/vio2sf/vio2sf.sln b/tools/vio2sf/vio2sf.sln deleted file mode 100644 index 0ec362544..000000000 --- a/tools/vio2sf/vio2sf.sln +++ /dev/null @@ -1,117 +0,0 @@ -サソ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foo_xsf8", "foo_xsf8.vcproj", "{02361C60-7E8A-4002-890A-E2B0AC2C91D8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "in_xsf", "in_xsf.vcproj", "{035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "in_xsfu", "in_xsfu.vcproj", "{226CE519-0842-4808-B6F9-C02DE14BB3DC}" - ProjectSection(ProjectDependencies) = postProject - {1BEA83DD-D533-446B-B470-490A1604B594} = {1BEA83DD-D533-446B-B470-490A1604B594} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kpixsf", "kpixsf.vcproj", "{45AEABD2-996B-4C43-947C-E43D3A3DF79A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vio2sf", "vio2sf.vcproj", "{1BEA83DD-D533-446B-B470-490A1604B594}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foo_input_vio2sf", "foo_input_vio2sf.vcproj", "{22752D82-8F89-4F87-B07E-D254D7BF675A}" - ProjectSection(ProjectDependencies) = postProject - {E8091321-D79D-4575-86EF-064EA1A4A20D} = {E8091321-D79D-4575-86EF-064EA1A4A20D} - {EE47764E-A202-4F85-A767-ABDAB4AFF35F} = {EE47764E-A202-4F85-A767-ABDAB4AFF35F} - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C} = {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C} - {71AD2674-065B-48F5-B8B0-E1F9D3892081} = {71AD2674-065B-48F5-B8B0-E1F9D3892081} - {1BEA83DD-D533-446B-B470-490A1604B594} = {1BEA83DD-D533-446B-B470-490A1604B594} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_component_client", "src\foobar\foobar2000\foobar2000_component_client\foobar2000_component_client.vcproj", "{71AD2674-065B-48F5-B8B0-E1F9D3892081}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_SDK", "src\foobar\foobar2000\SDK\foobar2000_SDK.vcproj", "{E8091321-D79D-4575-86EF-064EA1A4A20D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_sdk_helpers", "src\foobar\foobar2000\helpers\foobar2000_sdk_helpers.vcproj", "{EE47764E-A202-4F85-A767-ABDAB4AFF35F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pfc", "src\foobar\pfc\pfc.vcproj", "{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {02361C60-7E8A-4002-890A-E2B0AC2C91D8}.Debug|Win32.ActiveCfg = Debug|Win32 - {02361C60-7E8A-4002-890A-E2B0AC2C91D8}.Debug|Win32.Build.0 = Debug|Win32 - {02361C60-7E8A-4002-890A-E2B0AC2C91D8}.Debug|x64.ActiveCfg = Debug|Win32 - {02361C60-7E8A-4002-890A-E2B0AC2C91D8}.Release|Win32.ActiveCfg = Release|Win32 - {02361C60-7E8A-4002-890A-E2B0AC2C91D8}.Release|Win32.Build.0 = Release|Win32 - {02361C60-7E8A-4002-890A-E2B0AC2C91D8}.Release|x64.ActiveCfg = Release|Win32 - {035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}.Debug|Win32.ActiveCfg = Debug|Win32 - {035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}.Debug|Win32.Build.0 = Debug|Win32 - {035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}.Debug|x64.ActiveCfg = Debug|Win32 - {035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}.Release|Win32.ActiveCfg = Release|Win32 - {035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}.Release|Win32.Build.0 = Release|Win32 - {035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}.Release|x64.ActiveCfg = Release|Win32 - {226CE519-0842-4808-B6F9-C02DE14BB3DC}.Debug|Win32.ActiveCfg = Debug|Win32 - {226CE519-0842-4808-B6F9-C02DE14BB3DC}.Debug|Win32.Build.0 = Debug|Win32 - {226CE519-0842-4808-B6F9-C02DE14BB3DC}.Debug|x64.ActiveCfg = Debug|Win32 - {226CE519-0842-4808-B6F9-C02DE14BB3DC}.Release|Win32.ActiveCfg = Release|Win32 - {226CE519-0842-4808-B6F9-C02DE14BB3DC}.Release|Win32.Build.0 = Release|Win32 - {226CE519-0842-4808-B6F9-C02DE14BB3DC}.Release|x64.ActiveCfg = Release|Win32 - {45AEABD2-996B-4C43-947C-E43D3A3DF79A}.Debug|Win32.ActiveCfg = Debug|Win32 - {45AEABD2-996B-4C43-947C-E43D3A3DF79A}.Debug|Win32.Build.0 = Debug|Win32 - {45AEABD2-996B-4C43-947C-E43D3A3DF79A}.Debug|x64.ActiveCfg = Debug|Win32 - {45AEABD2-996B-4C43-947C-E43D3A3DF79A}.Release|Win32.ActiveCfg = Release|Win32 - {45AEABD2-996B-4C43-947C-E43D3A3DF79A}.Release|Win32.Build.0 = Release|Win32 - {45AEABD2-996B-4C43-947C-E43D3A3DF79A}.Release|x64.ActiveCfg = Release|Win32 - {1BEA83DD-D533-446B-B470-490A1604B594}.Debug|Win32.ActiveCfg = Debug|Win32 - {1BEA83DD-D533-446B-B470-490A1604B594}.Debug|Win32.Build.0 = Debug|Win32 - {1BEA83DD-D533-446B-B470-490A1604B594}.Debug|x64.ActiveCfg = Debug|Win32 - {1BEA83DD-D533-446B-B470-490A1604B594}.Release|Win32.ActiveCfg = Release|Win32 - {1BEA83DD-D533-446B-B470-490A1604B594}.Release|Win32.Build.0 = Release|Win32 - {1BEA83DD-D533-446B-B470-490A1604B594}.Release|x64.ActiveCfg = Release|Win32 - {22752D82-8F89-4F87-B07E-D254D7BF675A}.Debug|Win32.ActiveCfg = Debug|Win32 - {22752D82-8F89-4F87-B07E-D254D7BF675A}.Debug|Win32.Build.0 = Debug|Win32 - {22752D82-8F89-4F87-B07E-D254D7BF675A}.Debug|x64.ActiveCfg = Debug|Win32 - {22752D82-8F89-4F87-B07E-D254D7BF675A}.Release|Win32.ActiveCfg = Release|Win32 - {22752D82-8F89-4F87-B07E-D254D7BF675A}.Release|Win32.Build.0 = Release|Win32 - {22752D82-8F89-4F87-B07E-D254D7BF675A}.Release|x64.ActiveCfg = Release|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.ActiveCfg = Debug|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.Build.0 = Debug|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.ActiveCfg = Debug|x64 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.Build.0 = Debug|x64 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.ActiveCfg = Release|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.Build.0 = Release|Win32 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.ActiveCfg = Release|x64 - {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.Build.0 = Release|x64 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.ActiveCfg = Debug|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.Build.0 = Debug|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.ActiveCfg = Debug|x64 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.Build.0 = Debug|x64 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.ActiveCfg = Release|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.Build.0 = Release|Win32 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.ActiveCfg = Release|x64 - {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.Build.0 = Release|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.ActiveCfg = Debug|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.Build.0 = Debug|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.ActiveCfg = Debug|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.Build.0 = Debug|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.ActiveCfg = Release|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.Build.0 = Release|Win32 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.ActiveCfg = Release|x64 - {EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.Build.0 = Release|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.ActiveCfg = Debug|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.Build.0 = Debug|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.ActiveCfg = Debug|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.Build.0 = Debug|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.ActiveCfg = Release|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.Build.0 = Release|Win32 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.ActiveCfg = Release|x64 - {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - AMDCaProjectFile = D:\svn\desmume\trunk\tools\vio2sf\CodeAnalyst\vio2sf.caw - EndGlobalSection -EndGlobal diff --git a/tools/vio2sf/vio2sf.vcproj b/tools/vio2sf/vio2sf.vcproj deleted file mode 100644 index 2442dbc24..000000000 --- a/tools/vio2sf/vio2sf.vcproj +++ /dev/null @@ -1,853 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -