├── README.md ├── AziAudio ├── ABI3.cpp ├── HLEMain.cpp ├── tests │ ├── testmain.h │ ├── tests.h │ └── testmain.cpp ├── Settings.h ├── SoundDriverInterface.cpp ├── SoundDriverFactory.h ├── SoundDriverInterface.h ├── WaveOut.h ├── NoSoundDriver.h ├── resource.h ├── WASAPISoundDriver.h ├── ABI2.cpp ├── WaveOutSoundDriver.h ├── SoundDriverLegacy.h ├── SoundDriverLegacy.cpp ├── WaveOut.cpp ├── Mupen64plusHLE │ ├── Mupen64Support.c │ ├── common.h │ ├── hle_external.h │ ├── audio.h │ ├── hle.h │ ├── arithmetics.h │ ├── hle_internal.h │ ├── memory.c │ ├── ucodes.h │ ├── memory.h │ ├── alist.h │ └── audio.c ├── DirectSoundDriver.h ├── NoSoundDriver.cpp ├── DirectSoundDriverLegacy.h ├── SoundDriver.h ├── ABI1.cpp ├── XAudio2SoundDriver.h ├── XAudio2SoundDriverLegacy.h ├── common.h ├── SoundDriverFactory.cpp ├── ABI_MixerInterleave.cpp ├── Configuration.h ├── ABI_Buffers.cpp ├── AziAudio2010.vcxproj ├── AziAudio.vcxproj ├── WaveOutSoundDriver.cpp ├── ABI_Resample.cpp └── AziAudio.vcxproj.filters ├── Scripts ├── mingw-build.cmd ├── make_wdk.cmd ├── AziAudio.Xbx.sln └── make.sh ├── 3rd Party ├── directx │ ├── lib │ │ ├── x64 │ │ │ └── dsound.lib │ │ └── x86 │ │ │ └── dsound.lib │ └── include │ │ └── comdecl.h ├── sal.h └── XBox │ ├── xbox_depp.cpp │ └── xbox_depp.h ├── .gitmodules ├── PropertySheets ├── Win32.Debug.vsprops ├── Win32.Release.vsprops ├── root.vsprops ├── Win32.vsprops ├── Win32.props ├── x64.props ├── Release.vsprops ├── Debug.vsprops ├── Release.props ├── Debug.props └── Default.vsprops ├── .gitattributes ├── AziAudio.vs2008.sln ├── AziAudio.vs2005.sln ├── AziAudio.sln ├── AziAudio.vs2010.sln ├── .gitignore └── Makefile /README.md: -------------------------------------------------------------------------------- 1 | # AziAudio 2 | ## Azimer's Audio Plugin for N64 emulators 3 | -------------------------------------------------------------------------------- /AziAudio/ABI3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azimer/AziAudio/HEAD/AziAudio/ABI3.cpp -------------------------------------------------------------------------------- /AziAudio/HLEMain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azimer/AziAudio/HEAD/AziAudio/HLEMain.cpp -------------------------------------------------------------------------------- /Scripts/mingw-build.cmd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azimer/AziAudio/HEAD/Scripts/mingw-build.cmd -------------------------------------------------------------------------------- /3rd Party/directx/lib/x64/dsound.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azimer/AziAudio/HEAD/3rd Party/directx/lib/x64/dsound.lib -------------------------------------------------------------------------------- /3rd Party/directx/lib/x86/dsound.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azimer/AziAudio/HEAD/3rd Party/directx/lib/x86/dsound.lib -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "3rd Party/simpleini"] 2 | path = 3rd Party/simpleini 3 | url = https://github.com/Azimer/simpleini.git 4 | -------------------------------------------------------------------------------- /PropertySheets/Win32.Debug.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /PropertySheets/Win32.Release.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /PropertySheets/root.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /AziAudio/tests/testmain.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTMAIN_DOT_H__ 2 | #define __TESTMAIN_DOT_H__ 3 | #include 4 | 5 | inline bool TestTrue(bool test, std::string testString, std::string &statusBuffer) 6 | { 7 | if (!test) 8 | { 9 | statusBuffer += "ERROR: " + testString + "\n"; 10 | } 11 | return test == true ? 0 : 1; 12 | } 13 | 14 | 15 | #endif // __TESTMAIN_DOT_H__ -------------------------------------------------------------------------------- /PropertySheets/Win32.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /AziAudio/Settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | 4 | class Settings 5 | { 6 | public: 7 | unsigned long configFrequency; 8 | unsigned long configBufferLevel; 9 | unsigned long configBufferFPS; 10 | unsigned long configBackendFPS; 11 | bool configAIEmulation; 12 | bool configSyncAudio; 13 | bool configForceSync; 14 | bool configDisallowSleepXA2; 15 | bool configDisallowSleepDS8; 16 | unsigned long configBitRate; 17 | bool configResTimer; 18 | 19 | u16 CartID; 20 | char CartName[21]; 21 | }; 22 | -------------------------------------------------------------------------------- /AziAudio/tests/tests.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTS_DOT_H__ 2 | #define __TESTS_DOT_H__ 3 | 4 | #include 5 | #include 6 | 7 | // Arg[0] = failureResult string to hold a list of fail results 8 | // Return : 0 on success, non-zero on failure 9 | typedef int TestRunFunc(std::string&); 10 | 11 | TestRunFunc ConfigTestDefaults; 12 | TestRunFunc ConfigTestSave; 13 | TestRunFunc ConfigTestSaveModified; 14 | TestRunFunc ConfigTestLoad, ConfigTestLoadRomMissing, ConfigTestLoadRomPresent, ConfigTestLoadRomPartial; 15 | 16 | #endif //__TESTS_DOT_H__ -------------------------------------------------------------------------------- /AziAudio/SoundDriverInterface.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | #include "SoundDriverInterface.h" 12 | 13 | -------------------------------------------------------------------------------- /PropertySheets/Win32.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | $(SolutionDir)bin\$(Configuration)\ 10 | $(SolutionDir)build\$(Configuration)\$(ProjectName)\ 11 | 12 | 13 | 14 | $(SolutionDir)bin\$(Configuration)\lib\ 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | MachineX86 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PropertySheets/x64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | $(SolutionDir)bin\$(Configuration)64\ 10 | $(SolutionDir)build\$(Configuration)64\$(ProjectName)\ 11 | 12 | 13 | 14 | $(SolutionDir)bin\$(Configuration)64\lib\ 15 | 16 | 17 | 18 | 19 | NotSet 20 | 21 | 22 | MachineX64 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PropertySheets/Release.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 8 | 21 | 25 | 29 | 33 | 34 | -------------------------------------------------------------------------------- /PropertySheets/Debug.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 8 | 22 | 26 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /AziAudio.vs2008.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AziAudio", "AziAudio\AziAudio.vcproj", "{835979AC-BC6A-45B7-A513-8EEE79B443DE}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.Build.0 = Debug|Win32 14 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.ActiveCfg = Release|Win32 15 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /AziAudio.vs2005.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AziAudio", "AziAudio\AziAudio.2005.vcproj", "{835979AC-BC6A-45B7-A513-8EEE79B443DE}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.Build.0 = Debug|Win32 14 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.ActiveCfg = Release|Win32 15 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /PropertySheets/Release.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NDEBUG;%(PreprocessorDefinitions) 6 | Full 7 | AnySuitable 8 | true 9 | Neither 10 | false 11 | false 12 | true 13 | false 14 | MultiThreaded 15 | StreamingSIMDExtensions2 16 | 17 | 18 | NDEBUG;%(PreprocessorDefinitions) 19 | 20 | 21 | NDEBUG;%(PreprocessorDefinitions) 22 | 23 | 24 | -------------------------------------------------------------------------------- /PropertySheets/Debug.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | _DEBUG;DEBUG;%(PreprocessorDefinitions) 7 | Disabled 8 | Default 9 | false 10 | Neither 11 | false 12 | false 13 | false 14 | EnableFastChecks 15 | true 16 | MultiThreadedDebug 17 | 18 | 19 | _DEBUG;DEBUG;%(PreprocessorDefinitions) 20 | 21 | 22 | _DEBUG;DEBUG;%(PreprocessorDefinitions) 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Scripts/make_wdk.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | TITLE Windows Driver Kit 7.1.0 3 | 4 | set src=%CD%\..\AziAudio 5 | set obj=%CD% 6 | 7 | REM set target=i386 8 | set target=amd64 9 | 10 | set DDK=C:\WinDDK\7600.16385.1 11 | set MSVC=%DDK%\bin\x86\%target% 12 | set incl=/I"%DDK%\inc\crt" /I"%DDK%\inc\api" /I"%DDK%\inc\api\crt\stl60" /I"%src%\..\3rd Party\directx\include" 13 | set libs=/LIBPATH:"%DDK%\lib\crt\%target%" /LIBPATH:"%DDK%\lib\wnet\%target%" 14 | 15 | set C_FLAGS=/W4 /Ox /Ob2 /Gm /Zi /Oi /GS- /EHa /MD 16 | set LINK_FLAGS=%libs% kernel32.lib user32.lib ole32.lib %obj%\resource.res /DLL 17 | 18 | set files=%src%\main.cpp^ 19 | %src%\ABI_Adpcm.cpp^ 20 | %src%\ABI_Buffers.cpp^ 21 | %src%\ABI_Envmixer.cpp^ 22 | %src%\ABI_Filters.cpp^ 23 | %src%\ABI_MixerInterleave.cpp^ 24 | %src%\ABI_Resample.cpp^ 25 | %src%\ABI1.cpp^ 26 | %src%\ABI2.cpp^ 27 | %src%\ABI3.cpp^ 28 | %src%\ABI3mp3.cpp^ 29 | %src%\Configuration.cpp^ 30 | %src%\DirectSoundDriver.cpp^ 31 | %src%\HLEMain.cpp^ 32 | %src%\SoundDriver.cpp^ 33 | %src%\SoundDriverFactory.cpp^ 34 | %src%\SoundDriverInterface.cpp^ 35 | %src%\NoSoundDriver.cpp^ 36 | %src%\WaveOut.cpp^ 37 | %src%\XAudio2SoundDriver.cpp^ 38 | %src%\Mupen64plusHLE\audio.c^ 39 | %src%\Mupen64plusHLE\memory.c^ 40 | %src%\Mupen64plusHLE\Mupen64Support.c^ 41 | %src%\Mupen64plusHLE\musyx.c 42 | 43 | %DDK%\bin\x86\rc.exe %incl% /fo %obj%\resource.res %src%\resource.rc 44 | %MSVC%\cl.exe %files% %incl% %C_FLAGS% /link /OUT:AziAudio.dll %LINK_FLAGS% 45 | 46 | pause 47 | -------------------------------------------------------------------------------- /Scripts/AziAudio.Xbx.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AziAudio.Xbx", "..\AziAudio\AziAudio.xbx.vcproj", "{B0A432FE-0718-47CA-8621-FF9D16FCE3E7}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfiguration) = preSolution 8 | Debug = Debug 9 | Profile = Profile 10 | Profile_FastCap = Profile_FastCap 11 | Release = Release 12 | Release_LTCG = Release_LTCG 13 | EndGlobalSection 14 | GlobalSection(ProjectConfiguration) = postSolution 15 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Debug.ActiveCfg = Debug|Xbox 16 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Debug.Build.0 = Debug|Xbox 17 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Profile.ActiveCfg = Profile|Xbox 18 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Profile.Build.0 = Profile|Xbox 19 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox 20 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox 21 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Release.ActiveCfg = Release|Xbox 22 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Release.Build.0 = Release|Xbox 23 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox 24 | {B0A432FE-0718-47CA-8621-FF9D16FCE3E7}.Release_LTCG.Build.0 = Release_LTCG|Xbox 25 | EndGlobalSection 26 | GlobalSection(ExtensibilityGlobals) = postSolution 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityAddIns) = postSolution 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /AziAudio/tests/testmain.cpp: -------------------------------------------------------------------------------- 1 | #include "testmain.h" 2 | #include "tests.h" 3 | 4 | typedef std::map TestContainer; 5 | 6 | TestContainer tests = { 7 | {"Configuration Default Test", ConfigTestDefaults}, 8 | {"Configuration Save Test" , ConfigTestSave}, 9 | {"Configuration Save Test Modified" , ConfigTestSaveModified}, 10 | {"Configuration Load Test" , ConfigTestLoad}, 11 | {"Configuration Load with no Rom Section while Running", ConfigTestLoadRomMissing}, 12 | {"Configuration Load with Rom Section while Running", ConfigTestLoadRomPresent}, 13 | {"Configuration Load with Partial Rom Section while Running", ConfigTestLoadRomPartial} 14 | }; 15 | 16 | int main () 17 | { 18 | std::string testFailureReason; 19 | int ctr = 0; 20 | int successCnt = 0, failCnt = 0; 21 | int result = 0; 22 | std::cout << "Starting Tests for AziAudio..." << std::endl; 23 | 24 | for ( TestContainer::iterator itr = tests.begin(); itr != tests.end(); itr++ ) 25 | { 26 | std::cout << "Beginning Test " << ++ctr << " of " << tests.size() << " : " << itr->first << "... "; 27 | result = itr->second(testFailureReason); 28 | if (result == 0) 29 | { 30 | std::cout << "success" << std::endl; 31 | successCnt++; 32 | } 33 | else 34 | { 35 | std::cout << "failed" << std::endl; 36 | std::cout << testFailureReason << std::endl; 37 | failCnt++; 38 | testFailureReason = ""; 39 | } 40 | } 41 | return failCnt > 0 ? -1 : 0; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /3rd Party/sal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * minimalist needed to get XAudio2 compiling with MinGW 3 | * If your local compiler package includes a system , just use that. 4 | */ 5 | 6 | #ifndef _SAL_H_ 7 | #define _SAL_H_ 8 | 9 | /* 10 | * 2015.05.06 cxd4 11 | * taken straight from Visual Studio's , required for upcoming defs 12 | */ 13 | #ifdef _USE_SAL2_ONLY 14 | #define _SAL2_STRICT 15 | #define _SAL_VERSION_CHECK(_A) _SAL_VERSION_SAL2(_A) 16 | #else 17 | #define _SAL_VERSION_CHECK(_A) 18 | #endif 19 | 20 | /* 21 | * 2015.05.06 cxd4 22 | * 23 | * needs these from Visual Studio 2013's . 24 | * 25 | * These macros are not in the same order as presented in official ; I 26 | * just added them one-by-one in the order that the pre-processor complained. 27 | */ 28 | #define __in_bcount(size) _SAL_VERSION_CHECK(__in_bcount) 29 | #define __in_ecount(size) _SAL_VERSION_CHECK(__in_ecount) 30 | #define __out _SAL_VERSION_CHECK(__out) 31 | #define __in _SAL_VERSION_CHECK(__in) 32 | #define __inout _SAL_VERSION_CHECK(__inout) 33 | 34 | /* 35 | * 2015.05.06 cxd4 36 | * 37 | * needs these from Visual Studio 2013's . 38 | * Again, I've not added these macros in the same order as given in . 39 | */ 40 | #define __deref_out _SAL_VERSION_CHECK(__deref_out) 41 | #define __in_opt _SAL_VERSION_CHECK(__in_opt) 42 | #define __reserved _SAL_VERSION_CHECK(__reserved) 43 | #define __out_bcount(size) _SAL_VERSION_CHECK(__out_bcount) 44 | #define __out_ecount(size) _SAL_VERSION_CHECK(__out_ecount) 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /AziAudio.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2010 and later 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AziAudio", "AziAudio\AziAudio.vcxproj", "{835979AC-BC6A-45B7-A513-8EEE79B443DE}" 6 | EndProject 7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PropertySheets", "PropertySheets", "{CC1EBB98-29E0-40BA-AF5D-299B6E03B756}" 8 | ProjectSection(SolutionItems) = preProject 9 | PropertySheets\Debug.props = PropertySheets\Debug.props 10 | PropertySheets\PlatformBase.props = PropertySheets\PlatformBase.props 11 | PropertySheets\Release.props = PropertySheets\Release.props 12 | PropertySheets\Win32.props = PropertySheets\Win32.props 13 | PropertySheets\x64.props = PropertySheets\x64.props 14 | EndProjectSection 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Win32 = Debug|Win32 19 | Debug|x64 = Debug|x64 20 | Release|Win32 = Release|Win32 21 | Release|x64 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.Build.0 = Debug|Win32 26 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|x64.ActiveCfg = Debug|x64 27 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|x64.Build.0 = Debug|x64 28 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.ActiveCfg = Release|Win32 29 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.Build.0 = Release|Win32 30 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|x64.ActiveCfg = Release|x64 31 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|x64.Build.0 = Release|x64 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /AziAudio.vs2010.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 and later 4 | #MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AziAudio", "AziAudio\AziAudio2010.vcxproj", "{835979AC-BC6A-45B7-A513-8EEE79B443DE}" 6 | EndProject 7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PropertySheets", "PropertySheets", "{CC1EBB98-29E0-40BA-AF5D-299B6E03B756}" 8 | ProjectSection(SolutionItems) = preProject 9 | PropertySheets\Debug.props = PropertySheets\Debug.props 10 | PropertySheets\PlatformBase.props = PropertySheets\PlatformBase.props 11 | PropertySheets\Release.props = PropertySheets\Release.props 12 | PropertySheets\Win32.props = PropertySheets\Win32.props 13 | PropertySheets\x64.props = PropertySheets\x64.props 14 | EndProjectSection 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Win32 = Debug|Win32 19 | Debug|x64 = Debug|x64 20 | Release|Win32 = Release|Win32 21 | Release|x64 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.Build.0 = Debug|Win32 26 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|x64.ActiveCfg = Debug|x64 27 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|x64.Build.0 = Debug|x64 28 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.ActiveCfg = Release|Win32 29 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.Build.0 = Release|Win32 30 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|x64.ActiveCfg = Release|x64 31 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|x64.Build.0 = Release|x64 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /AziAudio/SoundDriverFactory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | #pragma once 12 | #include "common.h" 13 | #include "SoundDriverInterface.h" 14 | 15 | class SoundDriverFactory 16 | { 17 | private: 18 | typedef SoundDriverInterface* (*SoundDriverCreationFunction)(); 19 | struct FactoryDriversStruct 20 | { 21 | SoundDriverType DriverType; 22 | SoundDriverCreationFunction CreateFunction; 23 | int Priority; 24 | char Description[100]; 25 | }; 26 | 27 | private: 28 | SoundDriverFactory() {}; 29 | static int FactoryNextSlot; 30 | static const int MAX_FACTORY_DRIVERS = 20; 31 | static FactoryDriversStruct FactoryDrivers[MAX_FACTORY_DRIVERS]; 32 | public: 33 | ~SoundDriverFactory() {}; 34 | 35 | static SoundDriverInterface* CreateSoundDriver(SoundDriverType DriverID); 36 | static bool RegisterSoundDriver(SoundDriverType DriverType, SoundDriverCreationFunction CreateFunction, const char *Description, int Priority); 37 | static SoundDriverType DefaultDriver(); 38 | static int EnumDrivers(SoundDriverType *drivers, int max_entries); 39 | static const char* GetDriverDescription(SoundDriverType driver); 40 | static bool DriverExists(SoundDriverType driver); 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /AziAudio/SoundDriverInterface.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | #pragma once 12 | 13 | #include "common.h" 14 | #include "Configuration.h" 15 | 16 | 17 | class SoundDriverInterface 18 | { 19 | private: 20 | 21 | public: 22 | virtual ~SoundDriverInterface() {}; 23 | // Setup and Teardown Functions 24 | virtual Boolean Initialize() = 0; 25 | virtual void DeInitialize() = 0; 26 | 27 | // Management functions 28 | virtual void AiUpdate(Boolean Wait) { UNREFERENCED_PARAMETER(Wait); }; // Optional 29 | virtual void StopAudio() = 0; // Stops the Audio PlayBack (as if paused) 30 | virtual void StartAudio() = 0; // Starts the Audio PlayBack (as if unpaused) 31 | virtual void SetFrequency(u32 Frequency) = 0; // Sets the Nintendo64 Game Audio Frequency 32 | 33 | // Audio Spec interface methods (new) 34 | virtual void AI_SetFrequency(u32 Frequency) = 0; 35 | virtual void AI_LenChanged(u8 *start, u32 length) = 0; 36 | virtual u32 AI_ReadLength() = 0; 37 | virtual void AI_Startup() = 0; 38 | virtual void AI_Shutdown() = 0; 39 | virtual void AI_ResetAudio() = 0; 40 | virtual void AI_Update(Boolean Wait) = 0; 41 | 42 | virtual void SetVolume(u32 volume) = 0; 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /AziAudio/WaveOut.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | #include 14 | #if defined(_WIN32) 15 | #include 16 | #endif 17 | 18 | typedef struct 19 | { 20 | // RIFF Header 21 | char ChunkID[4]; // "RIFF" 22 | unsigned long ChunkSize; // FileSize - 8 23 | char format[4]; // "WAVE" 24 | // fmt Header 25 | char Subchunk1ID[4]; // "fmt " 26 | unsigned long Subchunk1Size; // 16 for PCM 27 | unsigned short AudioFormat; // PCM=1 28 | unsigned short NumChannels; // Mono=1, Stereo=2 29 | unsigned long SampleRate; // 8000, 44100, etc. 30 | unsigned long ByteRate; // SampleRate*NumChannels*BitsPerSample/8 31 | unsigned short BlockAlign; // NumChannels * BitsPerSample/8 32 | unsigned short BitsPerSample; // 8bits = 8, 16 bits = 16 33 | // Data Header 34 | char Subchunk2ID[4]; // "data" 35 | unsigned long Subchunk2Size; // NumSamples * NumChannels * BitsPerSample/8 36 | 37 | // Everything after is Data 38 | 39 | } WaveHeader; 40 | 41 | class WaveOut 42 | { 43 | protected: 44 | WaveHeader header; 45 | FILE *waveoutput; 46 | unsigned long datasize; 47 | public: 48 | WaveOut(); 49 | void BeginWaveOut(char *filename, unsigned short channels, unsigned short bitsPerSample, unsigned long sampleRate); 50 | void EndWaveOut(); 51 | void WriteData (unsigned char*data, unsigned long size); 52 | }; 53 | -------------------------------------------------------------------------------- /AziAudio/NoSoundDriver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | /* 12 | NoSound Driver to demonstrate how to use the SoundDriver interface 13 | */ 14 | 15 | #pragma once 16 | #include "common.h" 17 | #include "SoundDriver.h" 18 | 19 | #if !defined(_WIN32) && !defined(_XBOX) 20 | typedef union _LARGE_INTEGER { 21 | #if defined(ANONYMOUS_STRUCTS_ARE_NOT_ALLOWED) 22 | struct { 23 | u32 LowPart; 24 | s32 HighPart; 25 | }; /* ...but Microsoft uses them anyway. */ 26 | #endif 27 | struct { 28 | u32 LowPart; 29 | s32 HighPart; 30 | } u; 31 | s64 QuadPart; 32 | } LARGE_INTEGER; 33 | #endif 34 | 35 | class NoSoundDriver : 36 | public SoundDriver 37 | { 38 | public: 39 | NoSoundDriver() {}; 40 | ~NoSoundDriver() {}; 41 | 42 | // Setup and Teardown Functions 43 | Boolean Initialize(); 44 | void DeInitialize(); 45 | 46 | // Management functions 47 | void AiUpdate(Boolean Wait); 48 | void StopAudio(); 49 | void StartAudio(); 50 | void SetFrequency(u32 Frequency); 51 | 52 | static SoundDriverInterface* CreateSoundDriver() { return new NoSoundDriver(); } 53 | static bool ValidateDriver(); 54 | 55 | protected: 56 | bool dllInitialized; 57 | /* 58 | LARGE_INTEGER perfTimer; 59 | LARGE_INTEGER perfFreq; 60 | LARGE_INTEGER perfLast; 61 | LARGE_INTEGER countsPerSample; 62 | */ 63 | bool isPlaying; 64 | u32 lastTick; 65 | 66 | private: 67 | static bool ClassRegistered; 68 | }; 69 | -------------------------------------------------------------------------------- /AziAudio/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by resource.rc 4 | // 5 | #define IDD_CONFIG 101 6 | #define IDD_PROPPAGE_GENERAL 107 7 | #define IDD_PROPPAGE_ADVANCED 108 8 | #define IDD_PROPPAGE_LOGGING 109 9 | #define IDC_AUDIOSYNC 1000 10 | #define IDC_AI 1001 11 | #define IDC_OLDSYNC 1002 12 | #define IDC_VOLUME 1003 13 | #define IDC_DISALLOWDS8 1003 14 | #define IDC_MUTE 1004 15 | #define IDC_AI3 1004 16 | #define IDC_DISALLOWXA2 1004 17 | #define IDC_EDIT1 1005 18 | #define IDC_EDIT2 1006 19 | #define IDC_EDIT3 1007 20 | #define IDC_DIRECTORY 1008 21 | #define IDC_BROWSE 1009 22 | #define IDC_START 1010 23 | #define IDC_STOP 1011 24 | #define IDC_EDIT5 1012 25 | #define IDC_EDIT6 1013 26 | #define IDC_DEVICE 1014 27 | #define IDC_DEVICE2 1015 28 | #define IDC_BACKEND 1015 29 | #define IDC_COMBO2 1016 30 | #define IDC_DEVICE3 1016 31 | #define IDC_SLIDER_BUFFERFPS 1017 32 | #define IDC_SLIDER_BACKFPS 1018 33 | #define IDC_SLIDER_BUFFERFPS2 1019 34 | #define IDC_BUFFERS 1019 35 | #define IDC_BUFFERS_TEXT 1020 36 | #define IDC_SLIDER_BACKFPS_TEXT 1021 37 | #define IDC_SLIDER_BUFFERFPS_TEXT 1022 38 | #define IDC_PROFILE_NEW 1023 39 | #define IDC_PROFILE_DELETE 1024 40 | #define IDC_PROFILE 1025 41 | 42 | // Next default values for new objects 43 | // 44 | #ifdef APSTUDIO_INVOKED 45 | #ifndef APSTUDIO_READONLY_SYMBOLS 46 | #define _APS_NEXT_RESOURCE_VALUE 104 47 | #define _APS_NEXT_COMMAND_VALUE 40001 48 | #define _APS_NEXT_CONTROL_VALUE 1026 49 | #define _APS_NEXT_SYMED_VALUE 101 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /AziAudio/WASAPISoundDriver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | //#define _WIN32_WINNT 0x0601 14 | #ifdef _WIN32 15 | #include 16 | #endif 17 | 18 | #include "SoundDriver.h" 19 | 20 | class WASAPISoundDriver : 21 | public SoundDriver 22 | { 23 | public: 24 | WASAPISoundDriver(); 25 | ~WASAPISoundDriver(); 26 | 27 | // Setup and Teardown Functions 28 | BOOL Initialize(); 29 | void DeInitialize(); 30 | 31 | // Buffer Functions for the Audio Code 32 | void SetFrequency(u32 Frequency); // Sets the Nintendo64 Game Audio Frequency 33 | 34 | // Management functions 35 | void AiUpdate(BOOL Wait) { if (Wait) WaitMessage(); }; 36 | void StopAudio(); // Stops the Audio PlayBack (as if paused) 37 | void StartAudio(); // Starts the Audio PlayBack (as if unpaused) 38 | 39 | void SetVolume(u32 volume); 40 | 41 | static SoundDriverInterface* CreateSoundDriver() { return new WASAPISoundDriver(); } 42 | 43 | u32 LoadAiBufferResample(u8 *start, u32 length, float ratio); 44 | 45 | // Override the default in SoundDriver 46 | //u32 WASAPISoundDriver::LoadAiBuffer(u8 *start, u32 length); 47 | 48 | static bool ValidateDriver(); 49 | 50 | protected: 51 | static DWORD WINAPI AudioThreadProc(LPVOID lpParameter); 52 | 53 | //bool dllInitialized; 54 | bool bInitialized; 55 | float m_Volume; 56 | 57 | private: 58 | HANDLE hAudioThread; 59 | bool bStopAudioThread; 60 | bool m_CoUninit; 61 | static bool ClassRegistered; 62 | }; 63 | 64 | #if !defined(_MSC_VER) 65 | #undef __in 66 | #undef __out 67 | #endif 68 | -------------------------------------------------------------------------------- /AziAudio/ABI2.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include "audiohle.h" 13 | 14 | void UNKNOWN () { 15 | } 16 | /* 17 | p_func ABI2[NUM_ABI_COMMANDS] = { 18 | SPNOOP, ADPCM2, CLEARBUFF2, SPNOOP, SPNOOP, RESAMPLE2, SPNOOP, SEGMENT2, 19 | SETBUFF2, SPNOOP, DMEMMOVE2, LOADADPCM2, MIXER2, INTERLEAVE2, HILOGAIN, SETLOOP2, 20 | SPNOOP, INTERL2, ENVSETUP1, ENVMIXER2, LOADBUFF2, SAVEBUFF2, ENVSETUP2, SPNOOP, 21 | SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP, SPNOOP 22 | };*/ 23 | 24 | p_func ABI2[NUM_ABI_COMMANDS] = { 25 | SPNOOP ,ADPCM2 ,CLEARBUFF2,UNKNOWN , 26 | ADDMIXER ,RESAMPLE2 ,UNKNOWN ,SEGMENT2 , 27 | SETBUFF2 ,DUPLICATE2,DMEMMOVE2 ,LOADADPCM2, 28 | MIXER2 ,INTERLEAVE2,HILOGAIN ,SETLOOP2 , 29 | SPNOOP ,INTERL2 ,ENVSETUP1 ,ENVMIXER2 , 30 | LOADBUFF2 ,SAVEBUFF2 ,ENVSETUP2 ,SPNOOP , 31 | HILOGAIN ,SPNOOP ,DUPLICATE2,UNKNOWN , 32 | SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP , 33 | }; 34 | 35 | #if 0 36 | p_func ABI2[NUM_ABI_COMMANDS] = { 37 | SPNOOP , ADPCM2, CLEARBUFF2, SPNOOP, SPNOOP, RESAMPLE2 , SPNOOP , SEGMENT2, 38 | SETBUFF2 , DUPLICATE2, DMEMMOVE2, LOADADPCM2, MIXER2, INTERLEAVE2, SPNOOP, SETLOOP2, 39 | SPNOOP, INTERL2 , ENVSETUP1, ENVMIXER2, LOADBUFF2, SAVEBUFF2, ENVSETUP2, SPNOOP, 40 | SPNOOP , SPNOOP, SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP 41 | }; 42 | #endif 43 | 44 | /* NOTES: 45 | 46 | FILTER/SEGMENT - Still needs to be finished up... add FILTER? 47 | UNKNOWWN #27 - Is this worth doing? Looks like a pain in the ass just for WaveRace64 48 | */ 49 | -------------------------------------------------------------------------------- /AziAudio/WaveOutSoundDriver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | //#define _WIN32_WINNT 0x0601 14 | #ifdef _WIN32 15 | #include 16 | #include 17 | #include 18 | #endif 19 | 20 | #include "SoundDriver.h" 21 | 22 | class WaveOutSoundDriver : 23 | public SoundDriver 24 | { 25 | public: 26 | WaveOutSoundDriver(); 27 | ~WaveOutSoundDriver(); 28 | 29 | // Setup and Teardown Functions 30 | BOOL Initialize(); 31 | void DeInitialize(); 32 | void Setup(); 33 | void Teardown(); 34 | 35 | // Buffer Functions for the Audio Code 36 | void SetFrequency(u32 Frequency); // Sets the Nintendo64 Game Audio Frequency 37 | 38 | // Management functions 39 | void AiUpdate(BOOL Wait) { if (Wait) WaitMessage(); }; 40 | void StopAudio(); // Stops the Audio PlayBack (as if paused) 41 | void StartAudio(); // Starts the Audio PlayBack (as if unpaused) 42 | 43 | void SetVolume(u32 volume); 44 | 45 | static SoundDriverInterface* CreateSoundDriver() { return new WaveOutSoundDriver(); } 46 | static bool ValidateDriver(); 47 | 48 | protected: 49 | 50 | static void CALLBACK waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2); 51 | 52 | static WaveOutSoundDriver* m_Instance; 53 | HWAVEOUT m_hWave; 54 | 55 | int m_numOutputBuffers; 56 | u32 m_OutputBuffersSize; 57 | WAVEHDR *m_OutputBuffers; 58 | u8 *m_BufferMemory; 59 | bool bIsDone; 60 | u32 SampleRate; 61 | 62 | private: 63 | static bool ClassRegistered; 64 | }; 65 | 66 | #if !defined(_MSC_VER) 67 | #undef __in 68 | #undef __out 69 | #endif 70 | -------------------------------------------------------------------------------- /AziAudio/SoundDriverLegacy.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | 14 | #if defined(_WIN32) 15 | #include 16 | #else 17 | #include 18 | #include 19 | #include 20 | #endif 21 | 22 | /* strcpy() */ 23 | #include 24 | 25 | #include "common.h" 26 | #include "AudioSpec.h" 27 | #include "SoundDriverInterface.h" 28 | 29 | #define SND_IS_NOT_EMPTY 0x4000000 30 | #define SND_IS_FULL 0x8000000 31 | 32 | class SoundDriverLegacy : 33 | public SoundDriverInterface 34 | { 35 | public: 36 | 37 | // Deprecated 38 | virtual u32 GetReadStatus() = 0; // Returns the status on the read pointer 39 | virtual u32 AddBuffer(u8 *start, u32 length) = 0; // Uploads a new buffer and returns status 40 | 41 | // Sound Driver Factory method 42 | static SoundDriverLegacy* SoundDriverFactory(); 43 | 44 | virtual void SetVolume(u32 volume) { UNREFERENCED_PARAMETER(volume); }; // We could potentially do this ourselves within the buffer copy method 45 | virtual ~SoundDriverLegacy() {}; 46 | 47 | void AI_SetFrequency(u32 Frequency); 48 | void AI_LenChanged(u8 *start, u32 length); 49 | u32 AI_ReadLength(); 50 | void AI_Startup(); 51 | void AI_Shutdown(); 52 | void AI_ResetAudio(); 53 | void AI_Update(Boolean Wait); 54 | 55 | protected: 56 | // Temporary (to allow for incremental development) 57 | bool m_audioIsInitialized; 58 | 59 | // Mutex Handle 60 | #ifdef _WIN32 61 | HANDLE m_hMutex; 62 | #else 63 | pthread_mutex_t m_Mutex; 64 | #endif 65 | 66 | u32 m_SamplesPerSecond; 67 | 68 | SoundDriverLegacy(){ 69 | m_audioIsInitialized = false; 70 | #ifdef _WIN32 71 | m_hMutex = NULL; 72 | #else 73 | m_Mutex = NULL; 74 | #endif 75 | } 76 | }; 77 | -------------------------------------------------------------------------------- /AziAudio/SoundDriverLegacy.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include "common.h" 13 | #if defined(ENABLE_BACKEND_DIRECTSOUND8_LEGACY) || defined(ENABLE_BACKEND_XAUDIO2_LEGACY) 14 | #include "SoundDriverLegacy.h" 15 | // Load the buffer from the AI interface to our emulated buffer 16 | void SoundDriverLegacy::AI_LenChanged(u8 *start, u32 length) 17 | { 18 | if (m_audioIsInitialized == false) 19 | { 20 | *AudioInfo.AI_STATUS_REG = AI_STATUS_DMA_BUSY; 21 | *AudioInfo.MI_INTR_REG |= MI_INTR_AI; 22 | } 23 | else 24 | { 25 | AddBuffer(start, length); 26 | } 27 | } 28 | 29 | void SoundDriverLegacy::AI_SetFrequency(u32 Frequency) 30 | { 31 | m_SamplesPerSecond = Frequency; 32 | if (m_audioIsInitialized == true) SetFrequency(Frequency); 33 | } 34 | 35 | u32 SoundDriverLegacy::AI_ReadLength() 36 | { 37 | if (m_audioIsInitialized == false) return 0; 38 | return GetReadStatus(); 39 | } 40 | 41 | void SoundDriverLegacy::AI_Startup() 42 | { 43 | if (m_audioIsInitialized == true) DeInitialize(); 44 | m_audioIsInitialized = false; 45 | m_audioIsInitialized = (Initialize() == FALSE); 46 | if (m_audioIsInitialized == true) SetVolume(Configuration::getVolume()); 47 | StartAudio(); 48 | } 49 | 50 | void SoundDriverLegacy::AI_Shutdown() 51 | { 52 | StopAudio(); 53 | if (m_audioIsInitialized == true) DeInitialize(); 54 | m_audioIsInitialized = false; 55 | //DeInitialize(); 56 | } 57 | 58 | void SoundDriverLegacy::AI_ResetAudio() 59 | { 60 | if (m_audioIsInitialized == true) AI_Shutdown(); 61 | DeInitialize(); 62 | m_audioIsInitialized = false; 63 | AI_Startup(); 64 | m_audioIsInitialized = (Initialize() == FALSE); 65 | StartAudio(); 66 | } 67 | 68 | void SoundDriverLegacy::AI_Update(Boolean Wait) 69 | { 70 | AiUpdate(Wait); 71 | } 72 | #endif 73 | -------------------------------------------------------------------------------- /3rd Party/XBox/xbox_depp.cpp: -------------------------------------------------------------------------------- 1 | #include "xbox_depp.h" 2 | 3 | // Functions in Windows that don't exist on the Xbox 4 | 5 | BOOL PathFileExists(const char *pszPath) 6 | { 7 | return GetFileAttributes(pszPath) != INVALID_FILE_ATTRIBUTES; 8 | } 9 | 10 | int MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) 11 | { 12 | OutputDebugString(lpText); 13 | OutputDebugString("\n"); 14 | return FALSE; 15 | } 16 | 17 | int MessageBoxA(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) 18 | { 19 | return MessageBox(hWnd, lpText, lpCaption, uType); 20 | } 21 | 22 | BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode) 23 | { 24 | ExitThread(dwExitCode); 25 | return TRUE; 26 | } 27 | 28 | BOOL IsWindow(HWND hWnd) 29 | { 30 | return FALSE; 31 | } 32 | 33 | BOOL ShowWindow(HWND hWnd, int CmdShow) 34 | { 35 | return FALSE; 36 | } 37 | 38 | BOOL SetWindowText(HWND hWnd, LPCTSTR lpString) 39 | { 40 | OutputDebugString(lpString); 41 | OutputDebugString("\n"); 42 | return FALSE; 43 | } 44 | 45 | LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong) 46 | { 47 | return 0; 48 | } 49 | 50 | BOOL GetClientRect(HWND hWnd, LPRECT lpRect) 51 | { 52 | return FALSE; 53 | } 54 | 55 | int ShowCursor(BOOL bShow) 56 | { 57 | return 0; 58 | } 59 | 60 | int GetDlgCtrlID(HWND hWnd) 61 | { 62 | return 0; 63 | } 64 | 65 | HWND GetDlgItem(HWND hDlg, int nIDDlgItem) 66 | { 67 | return NULL; 68 | } 69 | 70 | DWORD GetModuleFileName(HMODULE hModule, LPSTR lpFilename, DWORD nSize) 71 | { 72 | return 0; 73 | } 74 | 75 | // We could have this return a string if we ever want to use it 76 | BOOL StrTrim(LPSTR psz, LPCSTR pszTrimChars) 77 | { 78 | // needs work 79 | /*char szBuf[256]; 80 | memset(szBuf, 0, sizeof(szBuf)); 81 | 82 | char szString[256]; 83 | sprintf(szString, psz); 84 | 85 | char szTrim[256]; 86 | sprintf(szTrim, pszTrimChars); 87 | 88 | for (int i=0; i 15 | #include 16 | #include "WaveOut.h" 17 | 18 | WaveOut::WaveOut() : waveoutput(NULL) { 19 | waveoutput = NULL; 20 | }; 21 | void WaveOut::BeginWaveOut(char *filename, WORD channels, WORD bitsPerSample, DWORD sampleRate) 22 | { 23 | if (waveoutput != NULL) return; 24 | // Clear header 25 | memset(&header, 0, sizeof(WaveHeader)); 26 | header.AudioFormat = 1; 27 | header.BitsPerSample = bitsPerSample; 28 | header.NumChannels = channels; 29 | header.SampleRate = sampleRate; 30 | header.BlockAlign = header.NumChannels * (header.BitsPerSample/8); 31 | header.ByteRate = header.SampleRate * header.BlockAlign; 32 | memcpy (header.ChunkID, "RIFF", 4); 33 | header.ChunkSize=0; // TODO at EndWaveOut 34 | memcpy (header.format, "WAVE", 4); 35 | memcpy (header.Subchunk1ID, "fmt ", 4); 36 | header.Subchunk1Size = 16; 37 | memcpy(header.Subchunk2ID,"data",4); 38 | header.Subchunk2Size=0; // TODO at EndWaveOut 39 | 40 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) 41 | fopen_s(&waveoutput, filename, "wb"); 42 | #else 43 | waveoutput = fopen(filename, "wb"); 44 | #endif 45 | fwrite(&header, sizeof(WaveHeader), 1, waveoutput); 46 | datasize = 0; 47 | } 48 | 49 | void WaveOut::WriteData (unsigned char*data, DWORD size) 50 | { 51 | if (waveoutput == NULL) return; 52 | datasize += size; 53 | fwrite(data, size, 1, waveoutput); 54 | } 55 | 56 | void WaveOut::EndWaveOut() 57 | { 58 | if (waveoutput == NULL) return; 59 | header.ChunkSize = ftell(waveoutput)-8; 60 | header.Subchunk2Size = datasize; 61 | fseek(waveoutput, 0, SEEK_SET); 62 | fwrite(&header, sizeof(WaveHeader), 1, waveoutput); 63 | fclose(waveoutput); 64 | waveoutput = NULL; 65 | } 66 | #endif -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/Mupen64Support.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | *****************************************************************************/ 12 | #include 13 | #include 14 | 15 | #include "common.h" 16 | 17 | #include "hle_external.h" 18 | #include "hle_internal.h" 19 | #include "../AudioSpec.h" 20 | 21 | void HleWarnMessage(void* user_defined, const char *message, ...) 22 | { 23 | va_list args; 24 | va_start(args, message); 25 | #if 0 26 | DebugMessage(M64MSG_WARNING, message, args); 27 | #endif 28 | va_end(args); 29 | 30 | if (user_defined == NULL) 31 | return; 32 | /* user_defined possibly as a HWND, FILE pointer, window ID, ... ? */ 33 | } 34 | 35 | 36 | void HleVerboseMessage(void* user_defined, const char *message, ...) 37 | { 38 | va_list args; 39 | va_start(args, message); 40 | #if 0 41 | DebugMessage(M64MSG_VERBOSE, message, args); 42 | #endif 43 | va_end(args); 44 | 45 | if (user_defined == NULL) 46 | return; 47 | /* user_defined possibly as a HWND, FILE pointer, window ID, ... ? */ 48 | } 49 | 50 | 51 | static struct hle_t _hle; 52 | 53 | void SetupMusyX() 54 | { 55 | struct hle_t *hle = &_hle; 56 | 57 | hle->dram = AudioInfo.RDRAM; 58 | hle->dmem = AudioInfo.DMEM; 59 | hle->imem = AudioInfo.IMEM; 60 | /*hle->mi_intr = NULL; 61 | hle->sp_mem_addr = NULL; 62 | hle->sp_dram_addr = NULL; 63 | hle->sp_rd_length = NULL; 64 | hle->sp_wr_length = NULL; 65 | hle->sp_status = NULL; 66 | hle->sp_dma_full = NULL; 67 | hle->sp_dma_busy = NULL; 68 | hle->sp_pc = NULL; 69 | hle->sp_semaphore = NULL; 70 | hle->dpc_start = NULL; 71 | hle->dpc_end = NULL; 72 | hle->dpc_current = NULL; 73 | hle->dpc_status = NULL; 74 | hle->dpc_clock = NULL; 75 | hle->dpc_bufbusy = NULL; 76 | hle->dpc_pipebusy = NULL; 77 | hle->dpc_tmem = NULL; 78 | hle->user_defined = NULL;*/ 79 | } 80 | 81 | void ProcessMusyX_v1() 82 | { 83 | SetupMusyX(); 84 | musyx_v1_task(&_hle); 85 | } 86 | 87 | void ProcessMusyX_v2() 88 | { 89 | SetupMusyX(); 90 | musyx_v2_task(&_hle); 91 | } 92 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/common.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - common.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef COMMON_H 32 | #define COMMON_H 33 | 34 | #include "../my_types.h" 35 | 36 | /* macro for unused variable warning suppression */ 37 | #ifdef __GNUC__ 38 | # define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) 39 | #else 40 | # define UNUSED(x) UNUSED_ ## x 41 | #endif 42 | 43 | /* macro for inline keyword */ 44 | #ifdef _MSC_VER 45 | #define inline __inline 46 | #elif defined(__GNUC_GNU_INLINE__) 47 | #define inline 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/hle_external.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - hle_external.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef HLE_EXTERNAL_H 32 | #define HLE_EXTERNAL_H 33 | 34 | /* users of the hle core are expected to define these functions */ 35 | 36 | void HleVerboseMessage(void* user_defined, const char *message, ...); 37 | void HleErrorMessage(void* user_defined, const char *message, ...); 38 | void HleWarnMessage(void* user_defined, const char *message, ...); 39 | 40 | void HleCheckInterrupts(void* user_defined); 41 | void HleProcessDlistList(void* user_defined); 42 | void HleProcessAlistList(void* user_defined); 43 | void HleProcessRdpList(void* user_defined); 44 | void HleShowCFB(void* user_defined); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/audio.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - audio.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef AUDIO_H 32 | #define AUDIO_H 33 | 34 | #include 35 | 36 | #include "common.h" 37 | 38 | extern const int16_t RESAMPLE_LUT[64 * 4]; 39 | 40 | int32_t rdot(size_t n, const int16_t *x, const int16_t *y); 41 | 42 | static inline int16_t adpcm_predict_sample(uint8_t byte, uint8_t mask, 43 | unsigned lshift, unsigned rshift) 44 | { 45 | int16_t sample = (uint16_t)(byte & mask) << lshift; 46 | sample >>= rshift; /* signed */ 47 | return sample; 48 | } 49 | 50 | void adpcm_compute_residuals(int16_t* dst, const int16_t* src, 51 | const int16_t* cb_entry, const int16_t* last_samples, size_t count); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /AziAudio/DirectSoundDriver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | 14 | #include "common.h" 15 | #if defined(_WIN32) && !defined(_XBOX) 16 | #include 17 | #endif 18 | #include 19 | #include "SoundDriver.h" 20 | #include "SoundDriverInterface.h" 21 | 22 | #define DS_SEGMENTS 4 23 | #define LOCK_SIZE sLOCK_SIZE 24 | // 0x600 25 | //sLOCK_SIZE 26 | //0x700 27 | 28 | #define TOTAL_SIZE (LOCK_SIZE*DS_SEGMENTS) 29 | 30 | #define MAXBUFFER 27000 31 | //27000 32 | //(LOCK_SIZE*DS_SEGMENTS+LOCK_SIZE) 33 | // LOCKSIZE must not be fractional 34 | //#define LOCK_SIZE (ac->SegmentSize) 35 | 36 | #define BUFFSIZE (writeLoc-readLoc) 37 | 38 | class DirectSoundDriver : 39 | public SoundDriver 40 | { 41 | protected: 42 | DWORD dwFreqTarget; // Frequency of the Nintendo64 Game Audio 43 | void(*CallBack)(DWORD); 44 | BOOL audioIsPlaying; 45 | bool threadRunning; 46 | HANDLE handleAudioThread; 47 | DWORD dwAudioThreadId; 48 | HANDLE hMutex; 49 | LPDIRECTSOUNDBUFFER lpdsbuf; 50 | LPDIRECTSOUND8 lpds; 51 | bool audioIsDone; 52 | // Buffer Variables 53 | BYTE SoundBuffer[500000];//[MAXBUFFER]; 54 | DWORD readLoc; 55 | DWORD writeLoc; 56 | volatile DWORD remainingBytes; 57 | DWORD SampleRate; 58 | DWORD SegmentSize; 59 | 60 | public: 61 | 62 | friend DWORD WINAPI AudioThreadProc(DirectSoundDriver *ac); 63 | 64 | DirectSoundDriver() { lpdsbuf = NULL; lpds = NULL; audioIsDone = false; hMutex = NULL; handleAudioThread = NULL; audioIsPlaying = FALSE; readLoc = writeLoc = remainingBytes = 0; SampleRate = 0; }; 65 | //DirectSoundDriver() {}; 66 | ~DirectSoundDriver() { }; 67 | 68 | // Setup and Teardown Functions 69 | BOOL Initialize(); 70 | void DeInitialize(); 71 | 72 | // Buffer Functions for the Audio Code 73 | void SetFrequency(u32 Frequency); // Sets the Nintendo64 Game Audio Frequency 74 | void SetSegmentSize(DWORD length); 75 | 76 | // Management functions 77 | void AiUpdate(BOOL Wait); 78 | void StopAudio(); // Stops the Audio PlayBack (as if paused) 79 | void StartAudio(); // Starts the Audio PlayBack (as if unpaused) 80 | 81 | void SetVolume(u32 volume); 82 | 83 | static SoundDriverInterface* CreateSoundDriver() { return new DirectSoundDriver(); } 84 | static bool ValidateDriver(); 85 | private: 86 | static bool ClassRegistered; 87 | }; 88 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/hle.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - hle.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef HLE_H 32 | #define HLE_H 33 | 34 | #include "hle_internal.h" 35 | 36 | void hle_init(struct hle_t* hle, 37 | unsigned char* dram, 38 | unsigned char* dmem, 39 | unsigned char* imem, 40 | unsigned int* mi_intr, 41 | unsigned int* sp_mem_addr, 42 | unsigned int* sp_dram_addr, 43 | unsigned int* sp_rd_length, 44 | unsigned int* sp_wr_length, 45 | unsigned int* sp_status, 46 | unsigned int* sp_dma_full, 47 | unsigned int* sp_dma_busy, 48 | unsigned int* sp_pc, 49 | unsigned int* sp_semaphore, 50 | unsigned int* dpc_start, 51 | unsigned int* dpc_end, 52 | unsigned int* dpc_current, 53 | unsigned int* dpc_status, 54 | unsigned int* dpc_clock, 55 | unsigned int* dpc_bufbusy, 56 | unsigned int* dpc_pipebusy, 57 | unsigned int* dpc_tmem, 58 | void* user_defined); 59 | 60 | void hle_execute(struct hle_t* hle); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /AziAudio/NoSoundDriver.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | /* 12 | NoSound Driver to demonstrate how to use the SoundDriver interface 13 | */ 14 | #include "NoSoundDriver.h" 15 | #include "SoundDriverFactory.h" 16 | #if !defined(_WIN32) && !defined(_XBOX) 17 | #include 18 | #endif 19 | 20 | bool NoSoundDriver::ClassRegistered = NoSoundDriver::ValidateDriver() ? 21 | SoundDriverFactory::RegisterSoundDriver(SND_DRIVER_NOSOUND, NoSoundDriver::CreateSoundDriver, "No Sound Driver", 0) : 22 | false; 23 | 24 | bool NoSoundDriver::ValidateDriver() 25 | { 26 | // No Sound should always be an option. The only issue is if GetTickCount isn't supported or something similar 27 | return true; 28 | } 29 | 30 | Boolean NoSoundDriver::Initialize() 31 | { 32 | dllInitialized = true; 33 | isPlaying = false; 34 | m_SamplesPerSecond = false; 35 | lastTick = 0; 36 | return true; 37 | } 38 | 39 | void NoSoundDriver::DeInitialize() 40 | { 41 | isPlaying = false; 42 | dllInitialized = false; 43 | lastTick = 0; 44 | } 45 | 46 | // Management functions 47 | void NoSoundDriver::AiUpdate(Boolean Wait) 48 | { 49 | u32 bytes; 50 | u32 tick, tickdiff; 51 | Wait = Wait; // Avoids unreferences parameter warning. Required as part of the Project64 API 52 | 53 | while (Wait) 54 | { 55 | 56 | // GetTickCount - Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days. 57 | #if defined(_WIN32) || defined(_XBOX) 58 | if (lastTick == 0) 59 | lastTick = GetTickCount(); 60 | #endif 61 | 62 | if (isPlaying == true) 63 | { 64 | #if defined(_WIN32) || defined(_XBOX) 65 | Sleep(5); 66 | tick = GetTickCount(); 67 | tickdiff = tick - lastTick; 68 | lastTick = tick; 69 | #else 70 | usleep(5); 71 | tickdiff = 50; 72 | #endif 73 | if (tickdiff > 50) 74 | { 75 | tickdiff = 50; 76 | } 77 | bytes = (m_SamplesPerSecond / 1000) * 4 * tickdiff; // Play tickdiff ms of audio 78 | if (bytes > 0) LoadAiBuffer(NULL, bytes); 79 | } 80 | else 81 | { 82 | #if defined(_WIN32) || defined(_XBOX) 83 | Sleep(1); 84 | #else 85 | usleep(1); 86 | #endif 87 | } 88 | } 89 | } 90 | 91 | void NoSoundDriver::StopAudio() 92 | { 93 | isPlaying = false; 94 | } 95 | 96 | void NoSoundDriver::StartAudio() 97 | { 98 | isPlaying = true; 99 | } 100 | 101 | void NoSoundDriver::SetFrequency(u32 Frequency) 102 | { 103 | #ifdef _WIN32 104 | UNREFERENCED_PARAMETER(Frequency); 105 | #else 106 | #endif 107 | } 108 | -------------------------------------------------------------------------------- /AziAudio/DirectSoundDriverLegacy.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | 14 | #include "common.h" 15 | #if defined(_WIN32) && !defined(_XBOX) 16 | #include 17 | #endif 18 | #include 19 | #include "SoundDriverLegacy.h" 20 | #include "SoundDriverInterface.h" 21 | 22 | #define DS_SEGMENTS 4 23 | #define LOCK_SIZE sLOCK_SIZE 24 | // 0x600 25 | //sLOCK_SIZE 26 | //0x700 27 | 28 | #define TOTAL_SIZE (LOCK_SIZE*DS_SEGMENTS) 29 | 30 | #define MAXBUFFER 27000 31 | //27000 32 | //(LOCK_SIZE*DS_SEGMENTS+LOCK_SIZE) 33 | // LOCKSIZE must not be fractional 34 | //#define LOCK_SIZE (ac->SegmentSize) 35 | 36 | #define BUFFSIZE (writeLoc-readLoc) 37 | 38 | class DirectSoundDriverLegacy : 39 | public SoundDriverLegacy 40 | { 41 | protected: 42 | DWORD dwFreqTarget; // Frequency of the Nintendo64 Game Audio 43 | void(*CallBack)(DWORD); 44 | BOOL audioIsPlaying; 45 | HANDLE handleAudioThread; 46 | DWORD dwAudioThreadId; 47 | HANDLE hMutex; 48 | LPDIRECTSOUNDBUFFER lpdsbuf; 49 | LPDIRECTSOUND8 lpds; 50 | bool audioIsDone; 51 | // Buffer Variables 52 | BYTE SoundBuffer[500000];//[MAXBUFFER]; 53 | DWORD readLoc; 54 | DWORD writeLoc; 55 | volatile DWORD remainingBytes; 56 | DWORD SampleRate; 57 | DWORD SegmentSize; 58 | 59 | public: 60 | 61 | friend DWORD WINAPI AudioThreadProc(DirectSoundDriverLegacy *ac); 62 | 63 | DirectSoundDriverLegacy() { lpdsbuf = NULL; lpds = NULL; audioIsDone = false; hMutex = NULL; handleAudioThread = NULL; audioIsPlaying = FALSE; readLoc = writeLoc = remainingBytes = 0; SampleRate = 0; }; 64 | //DirectSoundDriverLegacy() {}; 65 | ~DirectSoundDriverLegacy() { }; 66 | 67 | // Setup and Teardown Functions 68 | BOOL Initialize(); 69 | void DeInitialize(); 70 | 71 | // Buffer Functions for the Audio Code 72 | void SetFrequency(u32 Frequency); // Sets the Nintendo64 Game Audio Frequency 73 | u32 AddBuffer(u8 *start, u32 length); // Uploads a new buffer and returns status 74 | void FillBuffer(BYTE *buff, DWORD len); 75 | void SetSegmentSize(DWORD length); 76 | 77 | // Management functions 78 | void AiUpdate(BOOL Wait); 79 | void StopAudio(); // Stops the Audio PlayBack (as if paused) 80 | void StartAudio(); // Starts the Audio PlayBack (as if unpaused) 81 | 82 | u32 GetReadStatus(); // Returns the status on the read pointer 83 | 84 | void SetVolume(u32 volume); 85 | 86 | static SoundDriverInterface* CreateSoundDriver() { return new DirectSoundDriverLegacy(); } 87 | static bool ValidateDriver(); 88 | private: 89 | static bool ClassRegistered; 90 | 91 | }; 92 | -------------------------------------------------------------------------------- /AziAudio/SoundDriver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | 14 | #if defined(_WIN32) 15 | #include 16 | #else 17 | //#include 18 | #include 19 | #include 20 | #endif 21 | 22 | /* strcpy() */ 23 | #include 24 | 25 | #include "common.h" 26 | #include "AudioSpec.h" 27 | #include "SoundDriverInterface.h" 28 | 29 | #define SND_IS_NOT_EMPTY 0x4000000 30 | #define SND_IS_FULL 0x8000000 31 | 32 | class SoundDriver : 33 | public SoundDriverInterface 34 | { 35 | public: 36 | 37 | // Buffer Management methods 38 | u32 LoadAiBuffer(u8 *start, u32 length); // Reads in length amount of audio bytes 39 | void BufferAudio(); 40 | 41 | // Sound Driver Factory method 42 | static SoundDriver* SoundDriverFactory(); 43 | 44 | virtual void SetVolume(u32 volume) { UNREFERENCED_PARAMETER(volume); }; // We could potentially do this ourselves within the buffer copy method 45 | virtual ~SoundDriver() {}; 46 | 47 | void AI_SetFrequency(u32 Frequency); 48 | void AI_LenChanged(u8 *start, u32 length); 49 | u32 AI_ReadLength(); 50 | void AI_Startup(); 51 | void AI_Shutdown(); 52 | void AI_ResetAudio(); 53 | void AI_Update(Boolean Wait); 54 | 55 | protected: 56 | // Temporary (to allow for incremental development) 57 | bool m_audioIsInitialized; 58 | bool m_isValid; 59 | 60 | // Mutex Handle 61 | #ifdef _WIN32 62 | HANDLE m_hMutex; 63 | #else 64 | pthread_mutex_t m_Mutex; 65 | #endif 66 | 67 | // Variables for AI DMA emulation 68 | //int m_AI_CurrentDMABuffer; // Currently playing AI Buffer 69 | //int m_AI_WriteDMABuffer; // Which set of registers will be written to 70 | u8 *m_AI_DMAPrimaryBuffer, *m_AI_DMASecondaryBuffer; 71 | u32 m_AI_DMAPrimaryBytes, m_AI_DMASecondaryBytes; 72 | 73 | // Variables for Buffering audio samples from AI DMA 74 | static const int MAX_SIZE = 44100 * 2 * 2; // Max Buffer Size (44100Hz * 16bit * Stereo) 75 | //static const int NUM_BUFFERS = 4; // Number of emulated buffers 76 | u32 m_MaxBufferSize; // Variable size determined by Playback rate 77 | u32 m_CurrentReadLoc; // Currently playing Buffer 78 | u32 m_CurrentWriteLoc; // Currently writing Buffer 79 | u8 m_Buffer[MAX_SIZE]; // Emulated buffers 80 | u32 m_BufferRemaining; // Buffer remaining 81 | bool m_DMAEnabled; // Sets to true when DMA is enabled 82 | u32 m_SamplesPerSecond; 83 | 84 | // Needed to smooth out the ReadLength 85 | u32 lastReadLength; 86 | u32 lastReadCount; 87 | u32 lastLength; 88 | 89 | SoundDriver(){ 90 | m_audioIsInitialized = false; 91 | #ifdef _WIN32 92 | m_hMutex = NULL; 93 | #else 94 | m_Mutex = PTHREAD_MUTEX_INITIALIZER; 95 | #endif 96 | } 97 | }; 98 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/arithmetics.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - arithmetics.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef ARITHMETICS_H 32 | #define ARITHMETICS_H 33 | 34 | #include "common.h" 35 | 36 | /* 37 | * 2015.05.05 modified by cxd4 38 | * The `INT16_MIN' macro is a dependency of this RSP HLE code. 39 | * In practice, there are two problems with this: 40 | * 1. can (rather, must) define `INT16_MIN' as -32767 instead 41 | * of the necessary -32768, as is irrelevant to RSP 42 | * hardware limitations and is really more about the host's CPU. 43 | * http://www.open-std.org/jtc1/sc22/wg14/www/docs/n761.htm 44 | * 2. Not everybody has a working , nor should they need to, 45 | * as its existence is based on the opinion that the C language 46 | * itself should arbitrate traditional-size types for the programmer. 47 | * As none of the types are scientifically essential to 48 | * valid CPU hardware, such C impl. requirements are for laziness. 49 | */ 50 | #if !defined(INT16_MIN) && !defined(INT16_MAX) 51 | #define INT16_MIN -32768 52 | #define INT16_MAX +32767 53 | #endif 54 | 55 | static inline int16_t clamp_s16(int32_t x) 56 | { 57 | x = (x < INT16_MIN) ? INT16_MIN: x; 58 | x = (x > INT16_MAX) ? INT16_MAX: x; 59 | 60 | return (int16_t)x; 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /3rd Party/directx/include/comdecl.h: -------------------------------------------------------------------------------- 1 | // comdecl.h: Macros to facilitate COM interface and GUID declarations. 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | 4 | #ifndef _COMDECL_H_ 5 | #define _COMDECL_H_ 6 | 7 | #ifndef _XBOX 8 | #include // For standard COM interface macros 9 | #else 10 | #pragma warning(push) 11 | #pragma warning(disable:4061) 12 | #include // Required by xobjbase.h 13 | #include // Special definitions for Xbox build 14 | #pragma warning(pop) 15 | #endif 16 | 17 | #if 1 18 | 19 | #ifndef GUID_SECT 20 | #define GUID_SECT 21 | #endif 22 | #define __DEFINE_CLSID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const CLSID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} 23 | #define __DEFINE_IID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const IID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} 24 | 25 | #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 26 | __DEFINE_CLSID(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) 27 | 28 | #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 29 | __DEFINE_IID(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) 30 | 31 | #else 32 | 33 | // The DEFINE_CLSID() and DEFINE_IID() macros defined below allow COM GUIDs to 34 | // be declared and defined in such a way that clients can obtain the GUIDs using 35 | // either the __uuidof() extension or the old-style CLSID_Foo / IID_IFoo names. 36 | // If using the latter approach, the client can also choose whether to get the 37 | // GUID definitions by defining the INITGUID preprocessor constant or by linking 38 | // to a GUID library. This works in either C or C++. 39 | 40 | #ifdef __cplusplus 41 | 42 | #define DECLSPEC_UUID_WRAPPER(x) __declspec(uuid(#x)) 43 | #ifdef INITGUID 44 | 45 | #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 46 | class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \ 47 | EXTERN_C const GUID DECLSPEC_SELECTANY CLSID_##className = __uuidof(className) 48 | 49 | #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 50 | interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \ 51 | EXTERN_C const GUID DECLSPEC_SELECTANY IID_##interfaceName = __uuidof(interfaceName) 52 | 53 | #else // INITGUID 54 | 55 | #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 56 | class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \ 57 | EXTERN_C const GUID CLSID_##className 58 | 59 | #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 60 | interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \ 61 | EXTERN_C const GUID IID_##interfaceName 62 | 63 | #endif // INITGUID 64 | 65 | #else // __cplusplus 66 | 67 | #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 68 | DEFINE_GUID(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) 69 | 70 | #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 71 | DEFINE_GUID(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) 72 | 73 | #endif // __cplusplus 74 | 75 | #endif 76 | 77 | #endif // #ifndef _COMDECL_H_ 78 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/hle_internal.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - hle_internal.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef HLE_INTERNAL_H 32 | #define HLE_INTERNAL_H 33 | 34 | #include "ucodes.h" 35 | 36 | /* rsp hle internal state - internal usage only */ 37 | struct hle_t 38 | { 39 | unsigned char* dram; 40 | unsigned char* dmem; 41 | unsigned char* imem; 42 | 43 | unsigned int* mi_intr; 44 | 45 | unsigned int* sp_mem_addr; 46 | unsigned int* sp_dram_addr; 47 | unsigned int* sp_rd_length; 48 | unsigned int* sp_wr_length; 49 | unsigned int* sp_status; 50 | unsigned int* sp_dma_full; 51 | unsigned int* sp_dma_busy; 52 | unsigned int* sp_pc; 53 | unsigned int* sp_semaphore; 54 | 55 | unsigned int* dpc_start; 56 | unsigned int* dpc_end; 57 | unsigned int* dpc_current; 58 | unsigned int* dpc_status; 59 | unsigned int* dpc_clock; 60 | unsigned int* dpc_bufbusy; 61 | unsigned int* dpc_pipebusy; 62 | unsigned int* dpc_tmem; 63 | 64 | /* for user convenience, this will be passed to "external" functions */ 65 | void* user_defined; 66 | 67 | 68 | /* alist.c */ 69 | uint8_t alist_buffer[0x1000]; 70 | 71 | /* alist_audio.c */ 72 | struct alist_audio_t alist_audio; 73 | 74 | /* alist_naudio.c */ 75 | struct alist_naudio_t alist_naudio; 76 | 77 | /* alist_nead.c */ 78 | struct alist_nead_t alist_nead; 79 | 80 | /* mp3.c */ 81 | uint8_t mp3_buffer[0x1000]; 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /AziAudio/ABI1.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include "audiohle.h" 13 | //#include "rsp.h" 14 | //#define SAFE_MEMORY 15 | /* 16 | #ifndef SAFE_MEMORY 17 | # define wr8 (src , address); 18 | # define rd8 (dest, address); 19 | # define wr16 (src, address); 20 | # define rd16 (dest, address); 21 | # define wr32 (src, address); 22 | # define rd32 (dest, address); 23 | # define wr64 (src, address); 24 | # define rd64 (dest, address); 25 | # define dmamem (dest, src, size) memcpy (dest, src, size); 26 | # define clrmem (dest, size) memset (dest, 0, size); 27 | #else 28 | void wr8 (u8 src, void *address); 29 | void rd8 (u8 dest, void *address); 30 | void wr16 (u16 src, void *address); 31 | void rd16 (u16 dest, void *address); 32 | void wr32 (u16 src, void *address); 33 | void rd32 (u16 dest, void *address); 34 | void wr64 (u16 src, void *address); 35 | void rd64 (u16 dest, void *address); 36 | void dmamem (void *dest, void *src, int size); 37 | void clrmem (void *dest, int size); 38 | #endif 39 | */ 40 | /******** DMEM Memory Map for ABI 1 *************** 41 | Address/Range Description 42 | ------------- ------------------------------- 43 | 0x000..0x2BF UCodeData 44 | 0x000-0x00F Constants - 0000 0001 0002 FFFF 0020 0800 7FFF 4000 45 | 0x010-0x02F Function Jump Table (16 Functions * 2 bytes each = 32) 0x20 46 | 0x030-0x03F Constants - F000 0F00 00F0 000F 0001 0010 0100 1000 47 | 0x040-0x03F Used by the Envelope Mixer (But what for?) 48 | 0x070-0x07F Used by the Envelope Mixer (But what for?) 49 | 0x2C0..0x31F 50 | 0x320..0x35F Segments 51 | 0x360 Audio In Buffer (Location) 52 | 0x362 Audio Out Buffer (Location) 53 | 0x364 Audio Buffer Size (Location) 54 | 0x366 Initial Volume for Left Channel 55 | 0x368 Initial Volume for Right Channel 56 | 0x36A Auxillary Buffer #1 (Location) 57 | 0x36C Auxillary Buffer #2 (Location) 58 | 0x36E Auxillary Buffer #3 (Location) 59 | 0x370 Loop Value (shared location) 60 | 0x370 Target Volume (Left) 61 | 0x372 Ramp?? (Left) 62 | 0x374 Rate?? (Left) 63 | 0x376 Target Volume (Right) 64 | 0x378 Ramp?? (Right) 65 | 0x37A Rate?? (Right) 66 | 0x37C Dry?? 67 | 0x37E Wet?? 68 | 0x380..0x4BF Alist data 69 | 0x4C0..0x4FF ADPCM CodeBook 70 | 0x500..0x5BF 71 | 0x5C0..0xF7F Buffers... 72 | 0xF80..0xFFF 73 | ***************************************************/ 74 | 75 | 76 | 77 | // T8 = 0x360 78 | 79 | p_func ABI1[NUM_ABI_COMMANDS] = { 80 | SPNOOP ,ADPCM ,CLEARBUFF ,ENVMIXER ,LOADBUFF ,RESAMPLE ,SAVEBUFF ,UNKNOWN , 81 | SETBUFF ,SETVOL ,DMEMMOVE ,LOADADPCM ,MIXER ,INTERLEAVE,POLEF ,SETLOOP , 82 | SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP , 83 | SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP , 84 | }; 85 | 86 | p_func ABI1GE[NUM_ABI_COMMANDS] = { 87 | SPNOOP ,ADPCM ,CLEARBUFF,ENVMIXER_GE,LOADBUFF ,RESAMPLE ,SAVEBUFF ,UNKNOWN , 88 | SETBUFF ,SETVOL ,DMEMMOVE ,LOADADPCM ,MIXER ,INTERLEAVE,POLEF ,SETLOOP , 89 | SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP , 90 | SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP ,SPNOOP , 91 | }; 92 | -------------------------------------------------------------------------------- /AziAudio/XAudio2SoundDriver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | //#define _WIN32_WINNT 0x0601 14 | #ifdef _WIN32 15 | #include 16 | #endif 17 | 18 | #include "SoundDriver.h" 19 | #include 20 | 21 | class VoiceCallback : public IXAudio2VoiceCallback 22 | { 23 | public: 24 | //HANDLE hBufferEndEvent; 25 | VoiceCallback() /*: hBufferEndEvent(CreateEvent(NULL, FALSE, FALSE, NULL))*/{} 26 | ~VoiceCallback(){/* CloseHandle(hBufferEndEvent); */} 27 | 28 | //Called when the voice has just finished playing a contiguous audio stream. 29 | void __stdcall OnStreamEnd() {/* SetEvent(hBufferEndEvent); */} 30 | 31 | //Unused methods are stubs 32 | 33 | void __stdcall OnVoiceProcessingPassEnd() { } 34 | void __stdcall OnVoiceProcessingPassStart(UINT32 SamplesRequired);// {} 35 | void __stdcall OnBufferEnd(void * pBufferContext);// {} 36 | void __stdcall OnBufferStart(void * pBufferContext) { UNREFERENCED_PARAMETER(pBufferContext); } 37 | void __stdcall OnLoopEnd(void * pBufferContext) { UNREFERENCED_PARAMETER(pBufferContext); } 38 | void __stdcall OnVoiceError(void * pBufferContext, HRESULT Error) { UNREFERENCED_PARAMETER(pBufferContext); UNREFERENCED_PARAMETER(Error); } 39 | 40 | /* 41 | STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired); 42 | STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS); 43 | STDMETHOD_(void, OnStreamEnd) (THIS); 44 | STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext); 45 | STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext); 46 | STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext); 47 | STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error); 48 | */ 49 | }; 50 | 51 | class XAudio2SoundDriver : 52 | public SoundDriver 53 | { 54 | public: 55 | XAudio2SoundDriver(); 56 | ~XAudio2SoundDriver(); 57 | 58 | // Setup and Teardown Functions 59 | BOOL Initialize(); 60 | void DeInitialize(); 61 | 62 | BOOL Setup(); 63 | void Teardown(); 64 | 65 | // Buffer Functions for the Audio Code 66 | void SetFrequency(u32 Frequency); // Sets the Nintendo64 Game Audio Frequency 67 | void PlayBuffer(u8* data, int bufferSize); 68 | 69 | // Management functions 70 | void AiUpdate(BOOL Wait); 71 | void StopAudio(); // Stops the Audio PlayBack (as if paused) 72 | void StartAudio(); // Starts the Audio PlayBack (as if unpaused) 73 | void StopAudioThread(); 74 | void StartAudioThread(); 75 | 76 | void SetVolume(u32 volume); 77 | 78 | static SoundDriverInterface* CreateSoundDriver() { return new XAudio2SoundDriver(); } 79 | static bool ValidateDriver(); 80 | 81 | protected: 82 | 83 | bool dllInitialized; 84 | static DWORD WINAPI AudioThreadProc(LPVOID lpParameter); 85 | 86 | private: 87 | HANDLE hAudioThread; 88 | bool bStopAudioThread; 89 | static bool ClassRegistered; 90 | }; 91 | 92 | /* 93 | * The GNU C++ compiler (ported to Windows through MinGW, for example) 94 | * references system C++ headers that use `__in` and `__out` for things 95 | * related to C++, which conflicts with Microsoft's driver macros for 96 | * the XAudio2 API. Perhaps either side could be blamed for this, but I 97 | * think that it shouldn't hurt to un-define the __in and __out stuff after 98 | * we have finished prototyping everything relevant to XAudio2. -- cxd4 99 | */ 100 | #if !defined(_MSC_VER) 101 | #undef __in 102 | #undef __out 103 | #endif 104 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Compilation results: GNU C/C++ 14 | *.asm 15 | *.o 16 | *.s 17 | 18 | # Build results 19 | *.dll 20 | *.so 21 | 22 | # Build result directories: Visual Studio 23 | [Dd]ebug/ 24 | [Dd]ebugPublic/ 25 | [Rr]elease/ 26 | [Rr]eleases/ 27 | /x64/ 28 | /x86/ 29 | build/ 30 | bld/ 31 | [Bb]in/ 32 | [Oo]bj/ 33 | 34 | # Subversion 35 | .svn 36 | 37 | # Visual Studo 2015 cache/options directory 38 | .vs/ 39 | .vscode/ 40 | 41 | # MSTest test Results 42 | [Tt]est[Rr]esult*/ 43 | [Bb]uild[Ll]og.* 44 | 45 | # NUNIT 46 | *.VisualState.xml 47 | TestResult.xml 48 | 49 | # Build Results of an ATL Project 50 | [Dd]ebugPS/ 51 | [Rr]eleasePS/ 52 | dlldata.c 53 | *_i.c 54 | *_p.c 55 | *_i.h 56 | *.idb 57 | *.ilk 58 | *.meta 59 | *.obj 60 | *.pch 61 | *.pdb 62 | *.pgc 63 | *.pgd 64 | *.res 65 | *.rsp 66 | *.sbr 67 | *.tlb 68 | *.tli 69 | *.tlh 70 | *.tmp 71 | *.tmp_proj 72 | *.log 73 | *.vspscc 74 | *.vssscc 75 | .builds 76 | *.pidb 77 | *.svclog 78 | *.scc 79 | 80 | # Chutzpah Test files 81 | _Chutzpah* 82 | 83 | # Visual C++ cache files 84 | ipch/ 85 | *.aps 86 | *.ncb 87 | *.opensdf 88 | *.opendb 89 | *.sdf 90 | *.cachefile 91 | *.VC.db 92 | 93 | # Visual Studio profiler 94 | *.psess 95 | *.vsp 96 | *.vspx 97 | 98 | # TFS 2012 Local Workspace 99 | $tf/ 100 | 101 | # Guidance Automation Toolkit 102 | *.gpState 103 | 104 | # ReSharper is a .NET coding add-in 105 | _ReSharper*/ 106 | *.[Rr]e[Ss]harper 107 | *.DotSettings.user 108 | 109 | # JustCode is a .NET coding addin-in 110 | .JustCode 111 | 112 | # TeamCity is a build add-in 113 | _TeamCity* 114 | 115 | # DotCover is a Code Coverage Tool 116 | *.dotCover 117 | 118 | # NCrunch 119 | _NCrunch_* 120 | .*crunch*.local.xml 121 | 122 | # MightyMoose 123 | *.mm.* 124 | AutoTest.Net/ 125 | 126 | # Web workbench (sass) 127 | .sass-cache/ 128 | 129 | # Installshield output folder 130 | [Ee]xpress/ 131 | 132 | # DocProject is a documentation generator add-in 133 | DocProject/buildhelp/ 134 | DocProject/Help/*.HxT 135 | DocProject/Help/*.HxC 136 | DocProject/Help/*.hhc 137 | DocProject/Help/*.hhk 138 | DocProject/Help/*.hhp 139 | DocProject/Help/Html2 140 | DocProject/Help/html 141 | 142 | # Click-Once directory 143 | publish/ 144 | 145 | # Publish Web Output 146 | *.[Pp]ublish.xml 147 | *.azurePubxml 148 | 149 | # TODO: Comment the next line if you want to checkin your web deploy settings 150 | # but database connection strings (with potential passwords) will be unencrypted 151 | *.pubxml 152 | *.publishproj 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | 157 | # The packages folder can be ignored because of Package Restore 158 | **/packages/* 159 | 160 | # except build/, which is used as an MSBuild target. 161 | !**/packages/build/ 162 | 163 | # Uncomment if necessary however generally it will be regenerated when needed 164 | #!**/packages/repositories.config 165 | # Windows Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | 172 | # Others 173 | *.[Cc]ache 174 | ClientBin/ 175 | [Ss]tyle[Cc]op.* 176 | ~$* 177 | *~ 178 | *.dbmdl 179 | *.dbproj.schemaview 180 | *.pfx 181 | *.publishsettings 182 | node_modules/ 183 | bower_components/ 184 | 185 | # RIA/Silverlight projects 186 | Generated_Code/ 187 | 188 | # Backup & report files from converting an old project file 189 | # to a newer Visual Studio version. Backup files are not needed, 190 | # because we have git ;-) 191 | _UpgradeReport_Files/ 192 | Backup*/ 193 | UpgradeLog*.XML 194 | UpgradeLog*.htm 195 | 196 | # SQL Server files 197 | *.mdf 198 | *.ldf 199 | 200 | # Business Intelligence projects 201 | *.rdl.data 202 | *.bim.layout 203 | *.bim_*.settings 204 | 205 | # Microsoft Fakes 206 | FakesAssemblies/ 207 | 208 | # Node.js Tools for Visual Studio 209 | .ntvs_analysis.dat 210 | 211 | # Visual Studio 6 build log 212 | *.plg 213 | 214 | # Visual Studio 6 workspace options file 215 | *.opt 216 | *.tlog 217 | 218 | # Remove unnecessary folders and files 219 | AziAudio/Todo.txt 220 | [Tt]arget/ 221 | [Cc]onfig/ 222 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## -*- Makefile -*- 2 | ## mingw Makefile for AziAudio Project64 Audio Plugin 3 | ## 4 | ## Build can be configured to a small amount with environment variables. 5 | ## Set BUILD_ARCH to x86 for a 32 bit build or x86_64 for a 64 bit build. 6 | ## If BUILD_ARCH is not set, we will attempt to detect the architecture. 7 | ## Set BUILD_DEBUG to 1 for a debug build. Anything else for a release build. 8 | 9 | #### Debug location #### 10 | PJ64LDIR=$(HOME)/emu/Project64 11 | PJ64LEXE=run.sh 12 | TEST_CASE_EXE=tests.exe 13 | 14 | #### Compiler and tool definitions shared by all build targets ##### 15 | # Cfg 16 | ifeq ($(BUILD_ARCH),) 17 | GCC_ARCH = $(shell gcc -dumpmachine | sed s/-.*//) 18 | ifeq ($(GCC_ARCH),x86_64) 19 | BUILD_ARCH = x86_64 20 | else 21 | BUILD_ARCH = x86 22 | endif 23 | endif 24 | 25 | ifneq ($(BUILD_DEBUG),1) 26 | PLUGIN_FILE = AziAudio_m.dll 27 | RESFLAGS = 28 | BASICOPTS = -O3 29 | BUILD_TYPE = Release 30 | else 31 | PLUGIN_FILE = AziAudio_md.dll 32 | RESFLAGS = -D_DEBUG 33 | BASICOPTS = -g -D_DEBUG 34 | BUILD_TYPE = Debug 35 | endif 36 | 37 | BUILD_PREFIX = i686-w64-mingw32- 38 | CC = $(BUILD_PREFIX)gcc 39 | CXX = $(BUILD_PREFIX)g++ 40 | WINDRES = $(BUILD_PREFIX)windres 41 | COMMON_FLAGS = -msse2 -DSSE2_SUPPORT -mstackrealign -I"3rd Party/directx/include" -I"3rd Party" -Wall -Wno-attributes -Wno-unknown-pragmas # -D_WIN32_WINNT=0x0501 -DWINVER=0x0501 42 | CFLAGS = $(BASICOPTS) $(COMMON_FLAGS) 43 | CXXFLAGS = $(BASICOPTS) $(COMMON_FLAGS) $(CPPFLAGS) 44 | LDFLAGS = -static-libstdc++ -static-libgcc -static -lole32 -lcomctl32 -lwinmm -ldsound -lksuser 45 | 46 | # Define the target directories. 47 | BINDIR=bin 48 | SRCDIR=AziAudio 49 | OBJDIR=$(BINDIR)/$(BUILD_TYPE)_$(BUILD_ARCH) 50 | 51 | all: $(BINDIR)/$(PLUGIN_FILE) 52 | cp "$(BINDIR)/$(PLUGIN_FILE)" "$(PJ64LDIR)/Plugin/$(PLUGIN_FILE)" 53 | 54 | test: $(BINDIR)/$(TEST_CASE_EXE) 55 | cd $(BINDIR) && wine $(TEST_CASE_EXE) 56 | 57 | run: all 58 | cd $(PJ64LDIR) && $(PJ64LDIR)/$(PJ64LEXE) 59 | 60 | TEST_OBJS = \ 61 | $(OBJDIR)/tests/testmain.o \ 62 | $(OBJDIR)/tests/configtests.o 63 | 64 | 65 | COMMON_OBJS = \ 66 | $(OBJDIR)/WaveOut.o \ 67 | $(OBJDIR)/ABI_Resample.o \ 68 | $(OBJDIR)/ABI_MixerInterleave.o \ 69 | $(OBJDIR)/ABI_Filters.o \ 70 | $(OBJDIR)/ABI_Envmixer.o \ 71 | $(OBJDIR)/ABI_Buffers.o \ 72 | $(OBJDIR)/ABI_Adpcm.o \ 73 | $(OBJDIR)/ABI3mp3.o \ 74 | $(OBJDIR)/ABI3.o \ 75 | $(OBJDIR)/ABI2.o \ 76 | $(OBJDIR)/ABI1.o \ 77 | $(OBJDIR)/Configuration.o \ 78 | $(OBJDIR)/Mupen64plusHLE/musyx.o \ 79 | $(OBJDIR)/Mupen64plusHLE/Mupen64Support.o \ 80 | $(OBJDIR)/Mupen64plusHLE/memory.o \ 81 | $(OBJDIR)/Mupen64plusHLE/audio.o \ 82 | $(OBJDIR)/SoundDriverFactory.o \ 83 | $(OBJDIR)/SoundDriverInterface.o \ 84 | $(OBJDIR)/SoundDriver.o \ 85 | $(OBJDIR)/SoundDriverLegacy.o \ 86 | $(OBJDIR)/WaveOutSoundDriver.o \ 87 | $(OBJDIR)/XAudio2SoundDriver.o \ 88 | $(OBJDIR)/XAudio2SoundDriverLegacy.o \ 89 | $(OBJDIR)/DirectSoundDriver.o \ 90 | $(OBJDIR)/DirectSoundDriverLegacy.o \ 91 | $(OBJDIR)/WASAPISoundDriver.o \ 92 | $(OBJDIR)/NoSoundDriver.o \ 93 | $(OBJDIR)/HLEMain.o \ 94 | $(OBJDIR)/main.o \ 95 | $(OBJDIR)/resource.o 96 | 97 | # Link or archive 98 | $(BINDIR)/$(TEST_CASE_EXE): ALL_DIRS $(XA_OBJS) $(COMMON_OBJS) $(TEST_OBJS) 99 | $(CXX) -mconsole $(CXXFLAGS) $(CPPFLAGS) -o $@ $(COMMON_OBJS) $(TEST_OBJS) $(LDFLAGS) 100 | 101 | # Link or archive 102 | $(BINDIR)/$(PLUGIN_FILE): ALL_DIRS $(XA_OBJS) $(COMMON_OBJS) 103 | $(CXX) -shared $(CXXFLAGS) $(CPPFLAGS) -o $@ $(COMMON_OBJS) $(LDFLAGS) 104 | 105 | 106 | # Compile source files into .o files 107 | 108 | $(OBJDIR)/Mupen64plusHLE/%.o: AziAudio/Mupen64plusHLE/%.c 109 | $(CC) -c $(CFLAGS) $< -o $@ 110 | 111 | $(OBJDIR)/%.o: AziAudio/%.c 112 | $(CC) -c $(CFLAGS) $< -o $@ 113 | 114 | $(OBJDIR)/%.o: AziAudio/%.cpp 115 | $(CXX) -c $(CXXFLAGS) $< -o $@ 116 | 117 | $(OBJDIR)/%.o: AziAudio/%.rc 118 | $(WINDRES) $(RESFLAGS) $< $@ 119 | 120 | .PHONY: ALL_DIRS 121 | 122 | ALL_DIRS: $(BINDIR) $(OBJDIR) $(OBJDIR)/Mupen64plusHLE $(OBJDIR)/tests 123 | 124 | $(OBJDIR)/tests: 125 | mkdir -p $@ 126 | 127 | $(OBJDIR)/Mupen64plusHLE: 128 | mkdir -p $@ 129 | 130 | $(OBJDIR): 131 | mkdir -p $@ 132 | 133 | $(BINDIR): 134 | mkdir -p $@ 135 | 136 | #### Clean target deletes all generated files #### 137 | clean: 138 | rm -rf $(BINDIR) 139 | rm -f $(COMMON_OBJS) 140 | rm -f $(TEST_OBJS) 141 | -------------------------------------------------------------------------------- /AziAudio/XAudio2SoundDriverLegacy.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #pragma once 13 | //#define _WIN32_WINNT 0x0601 14 | #ifdef _WIN32 15 | #include 16 | #endif 17 | 18 | #include "SoundDriverLegacy.h" 19 | #include 20 | 21 | class VoiceCallbackLegacy : public IXAudio2VoiceCallback 22 | { 23 | public: 24 | //HANDLE hBufferEndEvent; 25 | VoiceCallbackLegacy() /*: hBufferEndEvent(CreateEvent(NULL, FALSE, FALSE, NULL))*/{} 26 | ~VoiceCallbackLegacy(){/* CloseHandle(hBufferEndEvent); */} 27 | 28 | //Called when the voice has just finished playing a contiguous audio stream. 29 | void __stdcall OnStreamEnd() {/* SetEvent(hBufferEndEvent); */} 30 | 31 | //Unused methods are stubs 32 | 33 | void __stdcall OnVoiceProcessingPassEnd() { } 34 | void __stdcall OnVoiceProcessingPassStart(UINT32 SamplesRequired);// {} 35 | void __stdcall OnBufferEnd(void * pBufferContext);// {} 36 | void __stdcall OnBufferStart(void * pBufferContext) { UNREFERENCED_PARAMETER(pBufferContext); } 37 | void __stdcall OnLoopEnd(void * pBufferContext) { UNREFERENCED_PARAMETER(pBufferContext); } 38 | void __stdcall OnVoiceError(void * pBufferContext, HRESULT Error) { UNREFERENCED_PARAMETER(pBufferContext); UNREFERENCED_PARAMETER(Error); } 39 | 40 | /* 41 | STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired); 42 | STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS); 43 | STDMETHOD_(void, OnStreamEnd) (THIS); 44 | STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext); 45 | STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext); 46 | STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext); 47 | STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error); 48 | */ 49 | }; 50 | 51 | class XAudio2SoundDriverLegacy : 52 | public SoundDriverLegacy 53 | { 54 | public: 55 | XAudio2SoundDriverLegacy(); 56 | ~XAudio2SoundDriverLegacy(); 57 | 58 | // Setup and Teardown Functions 59 | BOOL Initialize(); 60 | void DeInitialize(); 61 | 62 | BOOL Setup(); 63 | void Teardown(); 64 | 65 | // Buffer Functions for the Audio Code 66 | void SetFrequency(u32 Frequency); // Sets the Nintendo64 Game Audio Frequency 67 | u32 AddBuffer(u8 *start, u32 length); // Uploads a new buffer and returns status 68 | 69 | // Management functions 70 | void AiUpdate(BOOL Wait); 71 | void StopAudio(); // Stops the Audio PlayBack (as if paused) 72 | void StartAudio(); // Starts the Audio PlayBack (as if unpaused) 73 | u32 GetReadStatus(); // Returns the status on the read pointer 74 | 75 | void SetVolume(u32 volume); 76 | 77 | //void PlayBuffer(int bufferNumber, u8* bufferData, int bufferSize); 78 | 79 | static SoundDriverInterface* CreateSoundDriver() { return new XAudio2SoundDriverLegacy(); } 80 | static bool ValidateDriver(); 81 | 82 | protected: 83 | 84 | bool dllInitialized; 85 | static DWORD WINAPI AudioThreadProc(LPVOID lpParameter); 86 | 87 | private: 88 | HANDLE hAudioThread; 89 | bool bStopAudioThread; 90 | static bool ClassRegistered; 91 | }; 92 | 93 | /* 94 | * The GNU C++ compiler (ported to Windows through MinGW, for example) 95 | * references system C++ headers that use `__in` and `__out` for things 96 | * related to C++, which conflicts with Microsoft's driver macros for 97 | * the XAudio2 API. Perhaps either side could be blamed for this, but I 98 | * think that it shouldn't hurt to un-define the __in and __out stuff after 99 | * we have finished prototyping everything relevant to XAudio2. -- cxd4 100 | */ 101 | #if !defined(_MSC_VER) 102 | #undef __in 103 | #undef __out 104 | #endif 105 | -------------------------------------------------------------------------------- /Scripts/make.sh: -------------------------------------------------------------------------------- 1 | mkdir -p gccbuild 2 | mkdir -p gccbuild/Mupen64plusHLE 3 | 4 | src="./../AziAudio" 5 | obj="./gccbuild" 6 | 7 | FLAGS_x86="\ 8 | -fPIC\ 9 | -DSSE2_SUPPORT\ 10 | -masm=intel\ 11 | -msse2\ 12 | -mstackrealign\ 13 | -ansi\ 14 | -pedantic\ 15 | -Wall\ 16 | " 17 | C_FLAGS=$FLAGS_x86 18 | 19 | echo Compiling sources... 20 | cc -o $obj/Mupen64plusHLE/audio.asm $src/Mupen64plusHLE/audio.c -S $C_FLAGS -O2 21 | cc -o $obj/Mupen64plusHLE/memory.asm $src/Mupen64plusHLE/memory.c -S $C_FLAGS -O2 22 | cc -o $obj/Mupen64plusHLE/Mupen64Support.asm $src/Mupen64plusHLE/Mupen64Support.c -S $C_FLAGS -Os 23 | cc -o $obj/Mupen64plusHLE/musyx.asm $src/Mupen64plusHLE/musyx.c -S $C_FLAGS -O2 24 | g++ -o $obj/ABI1.asm -x c++ $src/ABI1.cpp -S $C_FLAGS -O2 25 | g++ -o $obj/ABI2.asm -x c++ $src/ABI2.cpp -S $C_FLAGS -O2 26 | g++ -o $obj/ABI3.asm -x c++ $src/ABI3.cpp -S $C_FLAGS -O2 27 | g++ -o $obj/ABI3mp3.asm -x c++ $src/ABI3mp3.cpp -S $C_FLAGS -O2 28 | g++ -o $obj/ABI_Adpcm.asm -x c++ $src/ABI_Adpcm.cpp -S $C_FLAGS -O2 29 | g++ -o $obj/ABI_Buffers.asm -x c++ $src/ABI_Buffers.cpp -S $C_FLAGS -O2 30 | g++ -o $obj/ABI_Envmixer.asm -x c++ $src/ABI_Envmixer.cpp -S $C_FLAGS -O2 31 | g++ -o $obj/ABI_Filters.asm -x c++ $src/ABI_Filters.cpp -S $C_FLAGS -O2 32 | g++ -o $obj/ABI_MixerInterleave.asm -x c++ $src/ABI_MixerInterleave.cpp -S $C_FLAGS -O2 33 | g++ -o $obj/ABI_Resample.asm -x c++ $src/ABI_Resample.cpp -S $C_FLAGS -O2 34 | g++ -o $obj/HLEMain.asm -x c++ $src/HLEMain.cpp -S $C_FLAGS -Os 35 | 36 | g++ -o $obj/main.asm -x c++ $src/main.cpp -S $C_FLAGS -Os 37 | g++ -o $obj/Configuration.asm -x c++ $src/Configuration.cpp -S $C_FLAGS -Os 38 | g++ -o $obj/SoundDriver.asm -x c++ $src/SoundDriver.cpp -S $C_FLAGS -Os 39 | g++ -o $obj/SoundDriverFactory.asm -x c++ $src/SoundDriverFactory.cpp -S $C_FLAGS -Os 40 | g++ -o $obj/SoundDriverInterface.asm -x c++ $src/SoundDriverInterface.cpp -S $C_FLAGS -Os 41 | g++ -o $obj/NoSoundDriver.asm -x c++ $src/NoSoundDriver.cpp -S $C_FLAGS -Os 42 | # To do: We currently don't have any sound-playing drivers for this plugin on Linux. 43 | 44 | echo Assembling compiled sources... 45 | as -o $obj/ABI1.o $obj/ABI1.asm 46 | as -o $obj/ABI2.o $obj/ABI2.asm 47 | as -o $obj/ABI3.o $obj/ABI3.asm 48 | as -o $obj/ABI3mp3.o $obj/ABI3mp3.asm 49 | as -o $obj/ABI_Adpcm.o $obj/ABI_Adpcm.asm 50 | as -o $obj/ABI_Buffers.o $obj/ABI_Buffers.asm 51 | as -o $obj/ABI_Envmixer.o $obj/ABI_Envmixer.asm 52 | as -o $obj/ABI_Filters.o $obj/ABI_Filters.asm 53 | as -o $obj/ABI_MixerInterleave.o $obj/ABI_MixerInterleave.asm 54 | as -o $obj/ABI_Resample.o $obj/ABI_Resample.asm 55 | as -o $obj/HLEMain.o $obj/HLEMain.asm 56 | as -o $obj/Configuration.o $obj/Configuration.asm 57 | as -o $obj/main.o $obj/main.asm 58 | 59 | as -o $obj/Mupen64plusHLE/audio.o $obj/Mupen64plusHLE/audio.asm 60 | as -o $obj/Mupen64plusHLE/memory.o $obj/Mupen64plusHLE/memory.asm 61 | as -o $obj/Mupen64plusHLE/Mupen64Support.o $obj/Mupen64plusHLE/Mupen64Support.asm 62 | as -o $obj/Mupen64plusHLE/musyx.o $obj/Mupen64plusHLE/musyx.asm 63 | 64 | as -o $obj/SoundDriver.o $obj/SoundDriver.asm 65 | as -o $obj/SoundDriverFactory.o $obj/SoundDriverFactory.asm 66 | as -o $obj/SoundDriverInterface.o $obj/SoundDriverInterface.asm 67 | as -o $obj/NoSoundDriver.o $obj/NoSoundDriver.asm 68 | 69 | OBJ_LIST="\ 70 | $obj/ABI1.o \ 71 | $obj/ABI2.o \ 72 | $obj/ABI3.o \ 73 | $obj/ABI3mp3.o \ 74 | $obj/ABI_Adpcm.o \ 75 | $obj/ABI_Buffers.o \ 76 | $obj/ABI_Envmixer.o \ 77 | $obj/ABI_Filters.o \ 78 | $obj/ABI_MixerInterleave.o \ 79 | $obj/ABI_Resample.o \ 80 | $obj/HLEMain.o \ 81 | $obj/Configuration.o \ 82 | $obj/main.o \ 83 | $obj/Mupen64plusHLE/audio.o \ 84 | $obj/Mupen64plusHLE/memory.o \ 85 | $obj/Mupen64plusHLE/Mupen64Support.o \ 86 | $obj/Mupen64plusHLE/musyx.o \ 87 | $obj/NoSoundDriver.o \ 88 | $obj/SoundDriver.o \ 89 | $obj/SoundDriverFactory.o \ 90 | $obj/SoundDriverInterface.o" 91 | 92 | echo Linking assembled objects... 93 | g++ -o $obj/AziAudio.so $OBJ_LIST -s -shared 94 | -------------------------------------------------------------------------------- /3rd Party/XBox/xbox_depp.h: -------------------------------------------------------------------------------- 1 | #ifndef _XBOX_DEPP_H__COMMON_ 2 | #define _XBOX_DEPP_H__COMMON_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif //_MSC_VER > 1000 7 | 8 | #pragma warning(disable:4018) // signed/unsigned mismatch 9 | #pragma warning(disable:4101) // unreferenced local variable 10 | #pragma warning(disable:4244) // conversion, possible loss of data 11 | #pragma warning(disable:4731) // frame pointer register modified by inline assembly code 12 | 13 | /* 14 | * name-mangling needed to statically link the zilmar-spec plugin within 15 | * Surreal64, which requires unique function names per each "plugin" 16 | */ 17 | #if 1 18 | #define AiDacrateChanged _AUDIO_AZIAUD_##AiDacrateChanged 19 | #define AiLenChanged _AUDIO_AZIAUD_##AiLenChanged 20 | #define AiReadLength _AUDIO_AZIAUD_##AiReadLength 21 | #define AiUpdate _AUDIO_AZIAUD_##AiUpdate 22 | #define CloseDLL _AUDIO_AZIAUD_##CloseDLL 23 | #define DllAbout _AUDIO_AZIAUD_##DllAbout 24 | #define DllConfig _AUDIO_AZIAUD_##DllConfig 25 | #define DllTest _AUDIO_AZIAUD_##DllTest 26 | #define GetDllInfo _AUDIO_AZIAUD_##GetDllInfo 27 | #define InitiateAudio _AUDIO_AZIAUD_##InitiateAudio 28 | #define ProcessAList _AUDIO_AZIAUD_##ProcessAList 29 | #define RomClosed _AUDIO_AZIAUD_##RomClosed 30 | #define RomOpened _AUDIO_AZIAUD_##RomOpened 31 | 32 | #define PluginLoaded _AUDIO_AZIAUD_##PluginLoaded 33 | #define AiCallBack _AUDIO_AZIAUD_##AiCallBack 34 | #endif 35 | 36 | /* 37 | * more name-mangling for Windows stubs needed to prevent collisions with 38 | * stubs in the emulator or in another statically linked plugin 39 | */ 40 | #if 1 41 | #define PathFileExists _WIN32_AZIAUD_##PathFileExists 42 | #define MessageBox _WIN32_AZIAUD_##MessageBox 43 | #define MessageBoxA _WIN32_AZIAUD_##MessageBoxA 44 | #define TerminateThread _WIN32_AZIAUD_##TerminateThread 45 | #define IsWindow _WIN32_AZIAUD_##IsWindow 46 | #define ShowWindow _WIN32_AZIAUD_##ShowWindow 47 | #define SetWindowText _WIN32_AZIAUD_##SetWindowText 48 | #define SetWindowLong _WIN32_AZIAUD_##SetWindowLong 49 | #define GetClientRect _WIN32_AZIAUD_##GetClientRect 50 | #define ShowCursor _WIN32_AZIAUD_##ShowCursor 51 | #define GetDlgCtrlID _WIN32_AZIAUD_##GetDlgCtrlID 52 | #define GetDlgItem _WIN32_AZIAUD_##GetDlgItem 53 | #define GetModuleFileName _WIN32_AZIAUD_##GetModuleFileName 54 | #define StrTrim _WIN32_AZIAUD_##StrTrim 55 | #define WaitMessage _WIN32_AZIAUD_##WaitMessage 56 | #define DllMain _WIN32_AZIAUD_##DllMain 57 | #endif 58 | 59 | #ifndef _XBOX_ICC 60 | #include 61 | #else 62 | #include "my_types.h" 63 | #endif 64 | 65 | #if defined(__cplusplus) 66 | extern "C" { 67 | #endif 68 | 69 | #define XAUDIO_LIBRARIES_UNAVAILABLE 70 | 71 | #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) 72 | 73 | // Message Box arg's, unused on XBOX 74 | #define MB_ABORTRETRYIGNORE 0x00000002L 75 | #define MB_CANCELTRYCONTINUE 0x00000006L 76 | #define MB_HELP 0x00004000L 77 | #define MB_OK 0x00000000L 78 | #define MB_OKCANCEL 0x00000001L 79 | #define MB_RETRYCANCEL 0x00000005L 80 | #define MB_YESNO 0x00000004L 81 | #define MB_YESNOCANCEL 0x00000003L 82 | #define MB_ICONASTERISK 0x00000040L 83 | #define MB_ICONERROR 0x00000010L 84 | #define MB_ICONEXCLAMATION 0x00000030L 85 | #define MB_ICONHAND 0x00000010L 86 | #define MB_ICONINFORMATION 0x00000040L 87 | #define MB_ICONQUESTION 0x00000020L 88 | #define MB_ICONSTOP 0x00000010L 89 | #define MB_ICONWARNING 0x00000030L 90 | 91 | // ShowWindow arg's. unused on XBOX 92 | #define SW_HIDE 0 93 | #define SW_SHOW 5 94 | 95 | BOOL PathFileExists(const char *pszPath); 96 | int MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType); 97 | int MessageBoxA(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType); 98 | BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode); 99 | BOOL IsWindow(HWND hWnd); 100 | BOOL ShowWindow(HWND hWnd, int CmdShow); 101 | BOOL SetWindowText(HWND hWnd, LPCTSTR lpString); 102 | LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong); 103 | BOOL GetClientRect(HWND hWnd, LPRECT lpRect); 104 | int ShowCursor(BOOL bShow); 105 | int GetDlgCtrlID(HWND hWnd); 106 | HWND GetDlgItem(HWND hDlg, int nIDDlgItem); 107 | DWORD GetModuleFileName(HMODULE hModule, LPSTR lpFilename, DWORD nSize); 108 | BOOL StrTrim(LPSTR psz, LPCSTR pszTrimChars); 109 | BOOL WaitMessage(void); 110 | 111 | #if defined(__cplusplus) 112 | } 113 | #endif 114 | 115 | #endif //_XBOX_DEPP_H__COMMON_ 116 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/memory.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - memory.c * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2013 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | #include "common.h" 35 | 36 | /* 37 | * 2017.02.09: helpers taken from "memory.h" 38 | * 39 | * We're not including "memory.h" itself because it's full of static function 40 | * definitions--all but 3 of which are never used here--which causes tens of 41 | * unused function warnings from unclean practice. We could try for a more 42 | * modular design, but the below 3 functions are straightforward to paste in. 43 | */ 44 | 45 | static uint8_t* pt_u8(const unsigned char* buffer, unsigned address) 46 | { 47 | return (uint8_t *)(buffer + (address ^ ENDIAN_SWAP_BYTE)); 48 | } 49 | 50 | static uint16_t* pt_u16(const unsigned char* buffer, unsigned address) 51 | { 52 | assert((address & 1) == 0); 53 | return (uint16_t *)(buffer + (address ^ ENDIAN_SWAP_HALF)); 54 | } 55 | 56 | static uint32_t* pt_u32(const unsigned char* buffer, unsigned address) 57 | { 58 | assert((address & 3) == 0); 59 | return (uint32_t *)(buffer + address); 60 | } 61 | 62 | 63 | /* Global functions */ 64 | void load_u8(uint8_t* dst, const unsigned char* buffer, unsigned address, size_t count) 65 | { 66 | while (count != 0) { 67 | *(dst++) = *pt_u8(buffer, address); 68 | address += 1; 69 | --count; 70 | } 71 | } 72 | 73 | void load_u16(uint16_t* dst, const unsigned char* buffer, unsigned address, size_t count) 74 | { 75 | while (count != 0) { 76 | *(dst++) = *pt_u16(buffer, address); 77 | address += 2; 78 | --count; 79 | } 80 | } 81 | 82 | void load_u32(uint32_t* dst, const unsigned char* buffer, unsigned address, size_t count) 83 | { 84 | /* Optimization for uint32_t */ 85 | memcpy(dst, pt_u32(buffer, address), count * sizeof(uint32_t)); 86 | } 87 | 88 | void store_u8(unsigned char* buffer, unsigned address, const uint8_t* src, size_t count) 89 | { 90 | while (count != 0) { 91 | *pt_u8(buffer, address) = *(src++); 92 | address += 1; 93 | --count; 94 | } 95 | } 96 | 97 | void store_u16(unsigned char* buffer, unsigned address, const uint16_t* src, size_t count) 98 | { 99 | while (count != 0) { 100 | *pt_u16(buffer, address) = *(src++); 101 | address += 2; 102 | --count; 103 | } 104 | } 105 | 106 | void store_u32(unsigned char* buffer, unsigned address, const uint32_t* src, size_t count) 107 | { 108 | /* Optimization for uint32_t */ 109 | memcpy(pt_u32(buffer, address), src, count * sizeof(uint32_t)); 110 | } 111 | -------------------------------------------------------------------------------- /AziAudio/common.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | //************ Configuration Section ************** (to be moved to compile time defines) 13 | 14 | // Configure the plugin to have a console window for informational output -- should be used for debugging only 15 | //#define USE_PRINTF 16 | 17 | #ifdef _WIN32 18 | #define ENABLE_BACKEND_DIRECTSOUND8_LEGACY 19 | #define ENABLE_BACKEND_XAUDIO2_LEGACY 20 | #define ENABLE_BACKEND_DIRECTSOUND8 21 | #define ENABLE_BACKEND_XAUDIO2 22 | #define ENABLE_BACKEND_COMMON 23 | #define ENABLE_BACKEND_WASAPI 24 | #define ENABLE_BACKEND_WAVEOUT 25 | #endif 26 | //#define ENABLE_BACKEND_PORTAUDIO // NYI 27 | 28 | #ifndef _COMMON_DOT_H_ 29 | #define _COMMON_DOT_H_ 30 | 31 | #include // size_t definition 32 | 33 | #if defined (_XBOX) 34 | #include 35 | #include "../3rd Party/XBox/xbox_depp.h" 36 | #elif defined(_WIN32) 37 | #include 38 | #include 39 | extern OSVERSIONINFOEX OSInfo; 40 | #endif 41 | 42 | #ifdef USE_PRINTF 43 | #include 44 | #endif 45 | #include 46 | 47 | #if 0 48 | #define ENABLEPROFILING 49 | #endif 50 | 51 | #if defined(_MSC_VER) 52 | #define SEH_SUPPORTED 53 | #endif 54 | 55 | #ifdef USE_PRINTF 56 | #define DEBUG_OUTPUT printf 57 | #else 58 | #define DEBUG_OUTPUT // 59 | #endif 60 | 61 | 62 | 63 | 64 | #include "my_types.h" 65 | 66 | enum SoundDriverType 67 | { 68 | SND_DRIVER_NOSOUND = 0x0000, 69 | // Windows-only 70 | SND_DRIVER_DS8L = 0x1000, 71 | SND_DRIVER_DS8 = 0x1001, 72 | SND_DRIVER_XA2L = 0x1002, 73 | SND_DRIVER_XA2 = 0x1003, 74 | SND_DRIVER_WASAPI = 0x1004, 75 | SND_DRIVER_WAVEOUT = 0x1005, 76 | // Cross Platform 77 | SND_DRIVER_PORTAUDIO = 0x1100 // NYI 78 | }; 79 | 80 | 81 | typedef struct { 82 | u16 Version; 83 | u32 BufferSize; 84 | Boolean doAIHACK; 85 | Boolean syncAudio; 86 | Boolean fillAudio; 87 | Boolean oldStyle; 88 | Boolean Reserved2; 89 | Boolean Reserved3; 90 | u32 Reserved4; 91 | u32 Reserved5; 92 | u32 Reserved6; 93 | } rSettings; 94 | extern rSettings RegSettings; 95 | #endif 96 | 97 | #define AUDIOCODE 0 98 | #define HLECODE 1 99 | #define CPUCODE 2 100 | 101 | #define PLUGIN_NAME "Audio" 102 | 103 | #ifdef DEVBUILD 104 | #ifdef __GNUC__ 105 | #define PLUGIN_BUILDSYS "Mingw" 106 | #else 107 | #define PLUGIN_BUILDSYS "MSVC" 108 | #endif 109 | #ifdef _DEBUG 110 | #define PLUGIN_DEBUG " (" PLUGIN_BUILDSYS " Debug)" 111 | #else 112 | #define PLUGIN_DEBUG " (" PLUGIN_BUILDSYS ")" 113 | #endif 114 | #else 115 | #ifdef _DEBUG 116 | #define PLUGIN_DEBUG " (Debug r59)" 117 | #else 118 | #define PLUGIN_DEBUG "" 119 | #endif 120 | #endif 121 | 122 | #define PLUGIN_RELEASE " v0.70" 123 | #define PLUGIN_BUILD " WIP 11" \ 124 | PLUGIN_DEBUG 125 | 126 | #define PLUGIN_VERSION \ 127 | "Azimer's " \ 128 | PLUGIN_NAME \ 129 | PLUGIN_RELEASE \ 130 | PLUGIN_BUILD 131 | 132 | 133 | #ifdef ENABLEPROFILING 134 | 135 | extern u64 ProfileStartTimes[30]; 136 | extern u64 ProfileTimes[30]; 137 | 138 | inline void StartProfile (int profile) { 139 | u64 start; 140 | __asm { 141 | rdtsc; 142 | mov dword ptr [start+0], eax; 143 | mov dword ptr [start+4], edx; 144 | } 145 | ProfileStartTimes[profile] = start; 146 | } 147 | 148 | inline void EndProfile (int profile) { 149 | u64 end; 150 | __asm { 151 | rdtsc; 152 | mov dword ptr [end+0], eax; 153 | mov dword ptr [end+4], edx; 154 | } 155 | ProfileTimes[profile] = ProfileTimes[profile] + (end - ProfileStartTimes[profile]); 156 | } 157 | inline void PrintProfiles () { 158 | FILE *dfile = fopen ("d:\\profile.txt", "wt"); 159 | u64 totalTimes = 0; 160 | for (int x = 0; x < 30; x++) { 161 | if (ProfileTimes[x] != 0) { 162 | fprintf (dfile, "Times for %i is: %08X %08X\n", x, (u32)(ProfileTimes[x] >> 32), (u32)ProfileTimes[x]); 163 | totalTimes += ProfileTimes[x]; 164 | } 165 | } 166 | for (x = 0; x < 30; x++) { 167 | if (ProfileTimes[x] != 0) { 168 | fprintf (dfile, "Percent Time for %i is: %i%%\n", x, (u32)((ProfileTimes[x]*100) / totalTimes)); 169 | } 170 | } 171 | fclose (dfile); 172 | } 173 | inline void ClearProfiles () { 174 | for (int x = 0; x < 30; x++) { 175 | ProfileTimes[x] = 0; 176 | } 177 | } 178 | #else 179 | # define StartProfile(profile) // 180 | # define EndProfile(profile) // 181 | # define PrintProfiles() // 182 | # define ClearProfiles()// 183 | #endif 184 | 185 | /* 186 | * `strcpy` with bounds checking 187 | * This basically is a portable variation of Microsoft's `strcpy_s`. 188 | */ 189 | extern int safe_strcpy(char* dst, size_t limit, const char* src); 190 | -------------------------------------------------------------------------------- /AziAudio/SoundDriverFactory.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | #include "SoundDriverFactory.h" 12 | #include "NoSoundDriver.h" 13 | 14 | int SoundDriverFactory::FactoryNextSlot = 0; 15 | SoundDriverFactory::FactoryDriversStruct SoundDriverFactory::FactoryDrivers[MAX_FACTORY_DRIVERS]; 16 | 17 | SoundDriverInterface* SoundDriverFactory::CreateSoundDriver(SoundDriverType DriverID) 18 | { 19 | SoundDriverInterface *result = NULL; 20 | 21 | // Look for our driver 22 | for (int x = 0; x < FactoryNextSlot; x++) 23 | { 24 | if (FactoryDrivers[x].DriverType == DriverID) 25 | { 26 | result = FactoryDrivers[x].CreateFunction(); 27 | if (result != NULL) 28 | break; 29 | } 30 | } 31 | 32 | /* 33 | We have two options here. See if the Validate is enough to prevent a "NoSound" situation or we need to rework AI_Startup and Initialize. 34 | Pros for Validate - We remove the need to do an API overhaul for something that should happen seldomly. 35 | Cons for Validate - It doesn't exactly fix a scenario where the API is available but fails to initialize. 36 | 37 | I think for now I am happy where things are unless we see issues. I have a lot of other things to do so it will stay disabled for now. 38 | */ 39 | #if 0 40 | SoundDriverType drivers[MAX_FACTORY_DRIVERS]; 41 | int index[MAX_FACTORY_DRIVERS]; 42 | bool sorted = false; 43 | 44 | if (result == NULL) 45 | { 46 | // *** Start failover *** 47 | // Copy the drivers 48 | for (int x = 0; x < FactoryNextSlot; x++) 49 | { 50 | drivers[x] = FactoryDrivers[x].DriverType; 51 | index[x] = x; 52 | } 53 | 54 | // Sort on priority -- Highest priority is likely best API for the system 55 | while (sorted == false) 56 | { 57 | sorted = true; 58 | for (int x = 0; x < FactoryNextSlot - 1; x++) 59 | { 60 | if (FactoryDrivers[index[x]].Priority < 61 | FactoryDrivers[index[x + 1]].Priority) 62 | { 63 | int i; 64 | i = index[x]; 65 | index[x] = index[x + 1]; 66 | index[x + 1] = i; 67 | sorted = false; 68 | } 69 | } 70 | } 71 | 72 | // Return the first one that doesn't fail to initialize 73 | for (int x = 0; x < FactoryNextSlot; x++) 74 | { 75 | result = FactoryDrivers[index[x]].CreateFunction(); 76 | if (result != NULL) 77 | break; 78 | } 79 | } 80 | #endif 81 | if (result == NULL) 82 | result = new NoSoundDriver(); 83 | 84 | return result; 85 | } 86 | 87 | // Priority denotes which driver to consider the default. 88 | // Currently priority highest to lowest: XA2L(11), XA2(10), DS8(6), DS8L(5), NoAudio(0) 89 | // Priority setting can be changed per build... for example... XBox should be DS8 or DS8L since it doesn't support XA2. 90 | // However, since these two implementations shouldn't be included in the project, DS8 and DS8L will be default. 91 | bool SoundDriverFactory::RegisterSoundDriver(SoundDriverType DriverType, SoundDriverCreationFunction CreateFunction, const char *Description, int Priority) 92 | { 93 | if (FactoryNextSlot < MAX_FACTORY_DRIVERS) 94 | { 95 | FactoryDrivers[FactoryNextSlot].DriverType = DriverType; 96 | FactoryDrivers[FactoryNextSlot].CreateFunction = CreateFunction; 97 | FactoryDrivers[FactoryNextSlot].Priority = Priority; 98 | safe_strcpy(FactoryDrivers[FactoryNextSlot].Description, 99, Description); 99 | FactoryNextSlot++; 100 | return true; 101 | } 102 | return false; 103 | } 104 | 105 | // Traverse the FactoryDrivers array and find the best default driver 106 | SoundDriverType SoundDriverFactory::DefaultDriver() 107 | { 108 | int highestPriority = -1; 109 | SoundDriverType retVal = SoundDriverType::SND_DRIVER_NOSOUND; 110 | for (int x = 0; x < FactoryNextSlot; x++) 111 | { 112 | if (FactoryDrivers[x].Priority > highestPriority) 113 | { 114 | retVal = FactoryDrivers[x].DriverType; 115 | highestPriority = FactoryDrivers[x].Priority; 116 | } 117 | } 118 | return retVal; 119 | } 120 | 121 | int SoundDriverFactory::EnumDrivers(SoundDriverType *drivers, int max_entries) 122 | { 123 | int retVal = 0; 124 | for (int x = 0; x < FactoryNextSlot; x++) 125 | { 126 | if (x >= max_entries) break; 127 | drivers[x] = FactoryDrivers[x].DriverType; 128 | retVal++; 129 | } 130 | return retVal; 131 | } 132 | 133 | const char* SoundDriverFactory::GetDriverDescription(SoundDriverType driver) 134 | { 135 | for (int x = 0; x < FactoryNextSlot; x++) 136 | { 137 | if (driver == FactoryDrivers[x].DriverType) 138 | return FactoryDrivers[x].Description; 139 | } 140 | return "Error"; 141 | } 142 | 143 | bool SoundDriverFactory::DriverExists(SoundDriverType driver) 144 | { 145 | for (int x = 0; x < FactoryNextSlot; x++) 146 | { 147 | if (driver == FactoryDrivers[x].DriverType) 148 | return true; 149 | } 150 | return false; 151 | } -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/ucodes.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - ucodes.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef UCODES_H 32 | #define UCODES_H 33 | 34 | struct hle_t; 35 | 36 | 37 | /* cic_x105 ucode */ 38 | void cicx105_ucode(struct hle_t* hle); 39 | 40 | 41 | /* audio list ucodes - audio */ 42 | enum { N_SEGMENTS = 16 }; 43 | struct alist_audio_t { 44 | /* segments */ 45 | uint32_t segments[N_SEGMENTS]; 46 | 47 | /* main buffers */ 48 | uint16_t in; 49 | uint16_t out; 50 | uint16_t count; 51 | 52 | /* auxiliary buffers */ 53 | uint16_t dry_right; 54 | uint16_t wet_left; 55 | uint16_t wet_right; 56 | 57 | /* gains */ 58 | int16_t dry; 59 | int16_t wet; 60 | 61 | /* envelopes (0:left, 1:right) */ 62 | int16_t vol[2]; 63 | int16_t target[2]; 64 | int32_t rate[2]; 65 | 66 | /* ADPCM loop point address */ 67 | uint32_t loop; 68 | 69 | /* storage for ADPCM table and polef coefficients */ 70 | int16_t table[16 * 8]; 71 | }; 72 | 73 | void alist_process_audio (struct hle_t* hle); 74 | void alist_process_audio_ge(struct hle_t* hle); 75 | void alist_process_audio_bc(struct hle_t* hle); 76 | 77 | 78 | /* audio list ucodes - naudio */ 79 | struct alist_naudio_t { 80 | /* gains */ 81 | int16_t dry; 82 | int16_t wet; 83 | 84 | /* envelopes (0:left, 1:right) */ 85 | int16_t vol[2]; 86 | int16_t target[2]; 87 | int32_t rate[2]; 88 | 89 | /* ADPCM loop point address */ 90 | uint32_t loop; 91 | 92 | /* storage for ADPCM table and polef coefficients */ 93 | int16_t table[16 * 8]; 94 | }; 95 | 96 | void alist_process_naudio (struct hle_t* hle); 97 | void alist_process_naudio_bk (struct hle_t* hle); 98 | void alist_process_naudio_dk (struct hle_t* hle); 99 | void alist_process_naudio_mp3 (struct hle_t* hle); 100 | void alist_process_naudio_cbfd(struct hle_t* hle); 101 | 102 | 103 | /* audio list ucodes - nead */ 104 | struct alist_nead_t { 105 | /* main buffers */ 106 | uint16_t in; 107 | uint16_t out; 108 | uint16_t count; 109 | 110 | /* envmixer ramps */ 111 | uint16_t env_values[3]; 112 | uint16_t env_steps[3]; 113 | 114 | /* ADPCM loop point address */ 115 | uint32_t loop; 116 | 117 | /* storage for ADPCM table and polef coefficients */ 118 | int16_t table[16 * 8]; 119 | 120 | /* filter audio command state */ 121 | uint16_t filter_count; 122 | uint32_t filter_lut_address[2]; 123 | }; 124 | 125 | void alist_process_nead_mk (struct hle_t* hle); 126 | void alist_process_nead_sfj (struct hle_t* hle); 127 | void alist_process_nead_sf (struct hle_t* hle); 128 | void alist_process_nead_fz (struct hle_t* hle); 129 | void alist_process_nead_wrjb(struct hle_t* hle); 130 | void alist_process_nead_ys (struct hle_t* hle); 131 | void alist_process_nead_1080(struct hle_t* hle); 132 | void alist_process_nead_oot (struct hle_t* hle); 133 | void alist_process_nead_mm (struct hle_t* hle); 134 | void alist_process_nead_mmb (struct hle_t* hle); 135 | void alist_process_nead_ac (struct hle_t* hle); 136 | 137 | 138 | /* mp3 ucode */ 139 | void mp3_task(struct hle_t* hle, unsigned int index, uint32_t address); 140 | 141 | 142 | /* musyx ucodes */ 143 | void musyx_v1_task(struct hle_t* hle); 144 | void musyx_v2_task(struct hle_t* hle); 145 | 146 | 147 | /* jpeg ucodes */ 148 | void jpeg_decode_PS0(struct hle_t* hle); 149 | void jpeg_decode_PS(struct hle_t* hle); 150 | void jpeg_decode_OB(struct hle_t* hle); 151 | 152 | #endif 153 | -------------------------------------------------------------------------------- /AziAudio/ABI_MixerInterleave.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include "audiohle.h" 13 | 14 | void ADDMIXER() { 15 | s16 Count = (k0 >> 12) & 0x0FF0; 16 | u16 InBuffer = (t9 >> 16); 17 | u16 OutBuffer = t9 & 0xffff; 18 | 19 | s16 *inp, *outp; 20 | s32 temp; 21 | inp = (s16 *)(BufferSpace + InBuffer); 22 | outp = (s16 *)(BufferSpace + OutBuffer); 23 | for (s16 cntr = 0; cntr < Count; cntr += 2) { 24 | temp = *outp + *inp; 25 | *outp = pack_signed(temp); 26 | outp++; inp++; 27 | } 28 | } 29 | 30 | void HILOGAIN() { 31 | u16 cnt = k0 & 0xffff; 32 | u16 out = (t9 >> 16) & 0xffff; 33 | s16 hi = (s16)((k0 >> 4) & 0xf000); 34 | u16 lo = (k0 >> 20) & 0xf; 35 | s16 *src; 36 | 37 | src = (s16 *)(BufferSpace + out); 38 | s32 tmp, val; 39 | 40 | while (cnt) { 41 | val = (s32)*src; 42 | //tmp = ((val * (s32)hi) + ((u64)(val * lo) << 16) >> 16); 43 | tmp = ((val * (s32)hi) >> 16) + (u32)(val * lo); 44 | *src = pack_signed(tmp); 45 | src++; 46 | cnt -= 2; 47 | } 48 | } 49 | 50 | void INTERLEAVE() { 51 | u32 inL, inR; 52 | u16 *outbuff = (u16 *)(AudioOutBuffer + BufferSpace); 53 | u16 *inSrcR; 54 | u16 *inSrcL; 55 | u16 Left, Right; 56 | 57 | inL = t9 & 0xFFFF; 58 | inR = (t9 >> 16) & 0xFFFF; 59 | 60 | inSrcR = (u16 *)(BufferSpace + inR); 61 | inSrcL = (u16 *)(BufferSpace + inL); 62 | 63 | for (int x = 0; x < (AudioCount / 4); x++) { 64 | Left = *(inSrcL++); 65 | Right = *(inSrcR++); 66 | 67 | *(outbuff++) = *(inSrcR++); 68 | *(outbuff++) = *(inSrcL++); 69 | *(outbuff++) = (u16)Right; 70 | *(outbuff++) = (u16)Left; 71 | } 72 | } 73 | 74 | void INTERL2() { 75 | s16 Count = k0 & 0xFFFF; 76 | u16 Out = t9 & 0xffff; 77 | u16 In = (t9 >> 16); 78 | u8* src; 79 | u8* dst; 80 | 81 | src = &BufferSpace[0];//[In]; 82 | dst = &BufferSpace[0];//[Out]; 83 | while (Count != 0) { 84 | *(s16 *)(dst + BES(Out)) = *(s16 *)(src + BES(In)); 85 | Out += 2; 86 | In += 4; 87 | Count--; 88 | } 89 | } 90 | 91 | void INTERLEAVE2() { // Needs accuracy verification... 92 | u32 inL, inR; 93 | u16 *outbuff; 94 | u16 *inSrcR; 95 | u16 *inSrcL; 96 | u16 Left, Right; 97 | u32 count; 98 | count = ((k0 >> 12) & 0xFF0); 99 | if (count == 0) { 100 | outbuff = (u16 *)(AudioOutBuffer + BufferSpace); 101 | count = AudioCount; 102 | } 103 | else { 104 | outbuff = (u16 *)((k0 & 0xFFFF) + BufferSpace); 105 | } 106 | 107 | inR = t9 & 0xFFFF; 108 | inL = (t9 >> 16) & 0xFFFF; 109 | 110 | inSrcR = (u16 *)(BufferSpace + inR); 111 | inSrcL = (u16 *)(BufferSpace + inL); 112 | 113 | for (u32 x = 0; x < (count / 4); x++) { 114 | Left = *(inSrcL++); 115 | Right = *(inSrcR++); 116 | 117 | *(outbuff++) = *(inSrcR++); 118 | *(outbuff++) = *(inSrcL++); 119 | *(outbuff++) = (u16)Right; 120 | *(outbuff++) = (u16)Left; 121 | } 122 | } 123 | 124 | void INTERLEAVE3() { // Needs accuracy verification... 125 | //u32 inL, inR; 126 | u16 *outbuff = (u16 *)(BufferSpace + 0x4f0);//(u16 *)(AudioOutBuffer+dmem); 127 | u16 *inSrcR; 128 | u16 *inSrcL; 129 | u16 Left, Right; 130 | 131 | //inR = t9 & 0xFFFF; 132 | //inL = (t9 >> 16) & 0xFFFF; 133 | 134 | inSrcR = (u16 *)(BufferSpace + 0xb40); 135 | inSrcL = (u16 *)(BufferSpace + 0x9d0); 136 | 137 | for (int x = 0; x < (0x170 / 4); x++) { 138 | Left = *(inSrcL++); 139 | Right = *(inSrcR++); 140 | 141 | *(outbuff++) = *(inSrcR++); 142 | *(outbuff++) = *(inSrcL++); 143 | *(outbuff++) = (u16)Right; 144 | *(outbuff++) = (u16)Left; 145 | /* 146 | Left=*(inSrcL++); 147 | Right=*(inSrcR++); 148 | *(outbuff++)=(u16)Left; 149 | Left >>= 16; 150 | *(outbuff++)=(u16)Right; 151 | Right >>= 16; 152 | *(outbuff++)=(u16)Left; 153 | *(outbuff++)=(u16)Right;*/ 154 | } 155 | } 156 | 157 | void MIXER() { 158 | u32 dmemin = (u16)(t9 >> 0x10); 159 | u32 dmemout = (u16)(t9 & 0xFFFF); 160 | //u8 flags = (u8)((k0 >> 16) & 0xff); 161 | s32 gain = (s16)(k0 & 0xFFFF); 162 | s32 temp; 163 | 164 | if (AudioCount == 0) 165 | return; 166 | 167 | for (int x = 0; x < AudioCount; x += 2) { 168 | temp = (*(s16 *)(BufferSpace + dmemin + x) * gain) >> 15; 169 | temp += *(s16 *)(BufferSpace + dmemout + x); 170 | 171 | *(s16 *)(BufferSpace + dmemout + x) = pack_signed(temp); 172 | } 173 | } 174 | 175 | void MIXER2() { // Needs accuracy verification... 176 | u16 dmemin = (u16)(t9 >> 0x10); 177 | u16 dmemout = (u16)(t9 & 0xFFFF); 178 | u32 count = ((k0 >> 12) & 0xFF0); 179 | s32 gain = (s16)(k0 & 0xFFFF) * 2; 180 | s32 temp; 181 | 182 | for (u32 x = 0; x < count; x += 2) { // I think I can do this a lot easier 183 | 184 | temp = (*(s16 *)(BufferSpace + dmemin + x) * gain) >> 16; 185 | temp += *(s16 *)(BufferSpace + dmemout + x); 186 | 187 | *(s16 *)(BufferSpace + dmemout + x) = pack_signed(temp); 188 | } 189 | } 190 | 191 | void MIXER3() { // Needs accuracy verification... 192 | u16 dmemin = (u16)(t9 >> 0x10) + 0x4f0; 193 | u16 dmemout = (u16)(t9 & 0xFFFF) + 0x4f0; 194 | //u8 flags = (u8)((k0 >> 16) & 0xff); 195 | s32 gain = (s16)(k0 & 0xFFFF) * 2; 196 | s32 temp; 197 | 198 | for (int x = 0; x < 0x170; x += 2) { // I think I can do this a lot easier 199 | temp = (*(s16 *)(BufferSpace + dmemin + x) * gain) >> 16; 200 | temp += *(s16 *)(BufferSpace + dmemout + x); 201 | 202 | *(s16 *)(BufferSpace + dmemout + x) = pack_signed(temp); 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/memory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - memory.h * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2014 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #ifndef MEMORY_H 32 | #define MEMORY_H 33 | 34 | #include 35 | #include 36 | 37 | #include "common.h" 38 | #include "hle_internal.h" 39 | 40 | #ifdef M64P_BIG_ENDIAN 41 | #define S 0 42 | #define S16 0 43 | #define S8 0 44 | #else 45 | #define S 1 46 | #define S16 2 47 | #define S8 3 48 | #endif 49 | 50 | enum { 51 | TASK_TYPE = 0xfc0, 52 | TASK_FLAGS = 0xfc4, 53 | TASK_UCODE_BOOT = 0xfc8, 54 | TASK_UCODE_BOOT_SIZE = 0xfcc, 55 | TASK_UCODE = 0xfd0, 56 | TASK_UCODE_SIZE = 0xfd4, 57 | TASK_UCODE_DATA = 0xfd8, 58 | TASK_UCODE_DATA_SIZE = 0xfdc, 59 | TASK_DRAM_STACK = 0xfe0, 60 | TASK_DRAM_STACK_SIZE = 0xfe4, 61 | TASK_OUTPUT_BUFF = 0xfe8, 62 | TASK_OUTPUT_BUFF_SIZE = 0xfec, 63 | TASK_DATA_PTR = 0xff0, 64 | TASK_DATA_SIZE = 0xff4, 65 | TASK_YIELD_DATA_PTR = 0xff8, 66 | TASK_YIELD_DATA_SIZE = 0xffc 67 | }; 68 | 69 | static inline unsigned int align(unsigned int x, unsigned amount) 70 | { 71 | --amount; 72 | return (x + amount) & ~amount; 73 | } 74 | 75 | static inline uint8_t* pt_u8(const unsigned char* buffer, unsigned address) 76 | { 77 | return (uint8_t*)(buffer + (address ^ S8)); 78 | } 79 | 80 | static inline uint16_t* pt_u16(const unsigned char* buffer, unsigned address) 81 | { 82 | assert((address & 1) == 0); 83 | return (uint16_t*)(buffer + (address ^ S16)); 84 | } 85 | 86 | static inline uint32_t* pt_u32(const unsigned char* buffer, unsigned address) 87 | { 88 | assert((address & 3) == 0); 89 | return (uint32_t*)(buffer + address); 90 | } 91 | 92 | void load_u8 (uint8_t* dst, const unsigned char* buffer, unsigned address, size_t count); 93 | void load_u16(uint16_t* dst, const unsigned char* buffer, unsigned address, size_t count); 94 | void load_u32(uint32_t* dst, const unsigned char* buffer, unsigned address, size_t count); 95 | void store_u8 (unsigned char* buffer, unsigned address, const uint8_t* src, size_t count); 96 | void store_u16(unsigned char* buffer, unsigned address, const uint16_t* src, size_t count); 97 | void store_u32(unsigned char* buffer, unsigned address, const uint32_t* src, size_t count); 98 | 99 | 100 | /* convenient function for DMEM access */ 101 | static inline uint32_t* dmem_u32(struct hle_t* hle, uint16_t address) 102 | { 103 | return pt_u32(hle->dmem, address & 0xfff); 104 | } 105 | 106 | /* convenient functions for DRAM access */ 107 | static inline uint8_t* dram_u8(struct hle_t* hle, uint32_t address) 108 | { 109 | return pt_u8(hle->dram, address & 0xffffff); 110 | } 111 | 112 | static inline uint16_t* dram_u16(struct hle_t* hle, uint32_t address) 113 | { 114 | return pt_u16(hle->dram, address & 0xffffff); 115 | } 116 | 117 | static inline uint32_t* dram_u32(struct hle_t* hle, uint32_t address) 118 | { 119 | return pt_u32(hle->dram, address & 0xffffff); 120 | } 121 | 122 | static inline void dram_load_u8(struct hle_t* hle, uint8_t* dst, uint32_t address, size_t count) 123 | { 124 | load_u8(dst, hle->dram, address & 0xffffff, count); 125 | } 126 | 127 | static inline void dram_load_u16(struct hle_t* hle, uint16_t* dst, uint32_t address, size_t count) 128 | { 129 | load_u16(dst, hle->dram, address & 0xffffff, count); 130 | } 131 | 132 | static inline void dram_load_u32(struct hle_t* hle, uint32_t* dst, uint32_t address, size_t count) 133 | { 134 | load_u32(dst, hle->dram, address & 0xffffff, count); 135 | } 136 | 137 | static inline void dram_store_u16(struct hle_t* hle, const uint16_t* src, uint32_t address, size_t count) 138 | { 139 | store_u16(hle->dram, address & 0xffffff, src, count); 140 | } 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /PropertySheets/Default.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 15 | 20 | 69 | 78 | 129 | 154 | 162 | 175 | 183 | 184 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/alist.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - alist.h * 3 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 4 | * Copyright (C) 2014 Bobby Smiles * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, write to the * 18 | * Free Software Foundation, Inc., * 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 20 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 21 | 22 | #ifndef ALIST_INTERNAL_H 23 | #define ALIST_INTERNAL_H 24 | 25 | #include 26 | #include 27 | 28 | struct hle_t; 29 | 30 | typedef void (*acmd_callback_t)(struct hle_t* hle, uint32_t w1, uint32_t w2); 31 | 32 | void alist_process(struct hle_t* hle, const acmd_callback_t abi[], unsigned int abi_size); 33 | uint32_t alist_get_address(struct hle_t* hle, uint32_t so, const uint32_t *segments, size_t n); 34 | void alist_set_address(struct hle_t* hle, uint32_t so, uint32_t *segments, size_t n); 35 | void alist_clear(struct hle_t* hle, uint16_t dmem, uint16_t count); 36 | void alist_load(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count); 37 | void alist_save(struct hle_t* hle, uint16_t dmem, uint32_t address, uint16_t count); 38 | void alist_move(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count); 39 | void alist_copy_every_other_sample(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count); 40 | void alist_repeat64(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint8_t count); 41 | void alist_copy_blocks(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t block_size, uint8_t count); 42 | void alist_interleave(struct hle_t* hle, uint16_t dmemo, uint16_t left, uint16_t right, uint16_t count); 43 | 44 | void alist_envmix_exp( 45 | struct hle_t* hle, 46 | bool init, 47 | bool aux, 48 | uint16_t dmem_dl, uint16_t dmem_dr, 49 | uint16_t dmem_wl, uint16_t dmem_wr, 50 | uint16_t dmemi, uint16_t count, 51 | int16_t dry, int16_t wet, 52 | const int16_t *vol, 53 | const int16_t *target, 54 | const int32_t *rate, 55 | uint32_t address); 56 | 57 | void alist_envmix_ge( 58 | struct hle_t* hle, 59 | bool init, 60 | bool aux, 61 | uint16_t dmem_dl, uint16_t dmem_dr, 62 | uint16_t dmem_wl, uint16_t dmem_wr, 63 | uint16_t dmemi, uint16_t count, 64 | int16_t dry, int16_t wet, 65 | const int16_t *vol, 66 | const int16_t *target, 67 | const int32_t *rate, 68 | uint32_t address); 69 | 70 | void alist_envmix_lin( 71 | struct hle_t* hle, 72 | bool init, 73 | uint16_t dmem_dl, uint16_t dmem_dr, 74 | uint16_t dmem_wl, uint16_t dmem_wr, 75 | uint16_t dmemi, uint16_t count, 76 | int16_t dry, int16_t wet, 77 | const int16_t *vol, 78 | const int16_t *target, 79 | const int32_t *rate, 80 | uint32_t address); 81 | 82 | void alist_envmix_nead( 83 | struct hle_t* hle, 84 | bool swap_wet_LR, 85 | uint16_t dmem_dl, 86 | uint16_t dmem_dr, 87 | uint16_t dmem_wl, 88 | uint16_t dmem_wr, 89 | uint16_t dmemi, 90 | unsigned count, 91 | uint16_t *env_values, 92 | uint16_t *env_steps, 93 | const int16_t *xors); 94 | 95 | void alist_mix(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count, int16_t gain); 96 | void alist_multQ44(struct hle_t* hle, uint16_t dmem, uint16_t count, int8_t gain); 97 | void alist_add(struct hle_t* hle, uint16_t dmemo, uint16_t dmemi, uint16_t count); 98 | 99 | void alist_adpcm( 100 | struct hle_t* hle, 101 | bool init, 102 | bool loop, 103 | bool two_bit_per_sample, 104 | uint16_t dmemo, 105 | uint16_t dmemi, 106 | uint16_t count, 107 | const int16_t* codebook, 108 | uint32_t loop_address, 109 | uint32_t last_frame_address); 110 | 111 | void alist_resample( 112 | struct hle_t* hle, 113 | bool init, 114 | bool flag2, 115 | uint16_t dmemo, uint16_t dmemi, uint16_t count, 116 | uint32_t pitch, uint32_t address); 117 | 118 | void alist_resample_zoh( 119 | struct hle_t* hle, 120 | uint16_t dmemo, 121 | uint16_t dmemi, 122 | uint16_t count, 123 | uint32_t pitch, 124 | uint32_t pitch_accu); 125 | 126 | void alist_filter( 127 | struct hle_t* hle, 128 | uint16_t dmem, 129 | uint16_t count, 130 | uint32_t address, 131 | const uint32_t* lut_address); 132 | 133 | void alist_polef( 134 | struct hle_t* hle, 135 | bool init, 136 | uint16_t dmemo, 137 | uint16_t dmemi, 138 | uint16_t count, 139 | uint16_t gain, 140 | int16_t* table, 141 | uint32_t address); 142 | /* 143 | * Audio flags 144 | */ 145 | 146 | #define A_INIT 0x01 147 | #define A_CONTINUE 0x00 148 | #define A_LOOP 0x02 149 | #define A_OUT 0x02 150 | #define A_LEFT 0x02 151 | #define A_RIGHT 0x00 152 | #define A_VOL 0x04 153 | #define A_RATE 0x00 154 | #define A_AUX 0x08 155 | #define A_NOAUX 0x00 156 | #define A_MAIN 0x00 157 | #define A_MIX 0x10 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/audio.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * * 9 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 10 | * * 11 | * Mupen64plus-rsp-hle - audio.c * 12 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 13 | * Copyright (C) 2013 Bobby Smiles * 14 | * * 15 | * This program is free software; you can redistribute it and/or modify * 16 | * it under the terms of the GNU General Public License as published by * 17 | * the Free Software Foundation; either version 2 of the License, or * 18 | * (at your option) any later version. * 19 | * * 20 | * This program is distributed in the hope that it will be useful, * 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 23 | * GNU General Public License for more details. * 24 | * * 25 | * You should have received a copy of the GNU General Public License * 26 | * along with this program; if not, write to the * 27 | * Free Software Foundation, Inc., * 28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 29 | *****************************************************************************/ 30 | 31 | #include 32 | #include 33 | 34 | #define S16(hex) \ 35 | ((hex) & 0x8000u) \ 36 | ? -(signed)((~(hex##u) + 1) & 0x7FFFu) \ 37 | : +(hex) \ 38 | 39 | #include "arithmetics.h" 40 | const i16 RESAMPLE_LUT[64 * 4] = { 41 | 0x0c39, 0x66ad, 0x0d46, S16(0xffdf), 42 | 0x0b39, 0x6696, 0x0e5f, S16(0xffd8), 43 | 0x0a44, 0x6669, 0x0f83, S16(0xffd0), 44 | 0x095a, 0x6626, 0x10b4, S16(0xffc8), 45 | 0x087d, 0x65cd, 0x11f0, S16(0xffbf), 46 | 0x07ab, 0x655e, 0x1338, S16(0xffb6), 47 | 0x06e4, 0x64d9, 0x148c, S16(0xffac), 48 | 0x0628, 0x643f, 0x15eb, S16(0xffa1), 49 | 0x0577, 0x638f, 0x1756, S16(0xff96), 50 | 0x04d1, 0x62cb, 0x18cb, S16(0xff8a), 51 | 0x0435, 0x61f3, 0x1a4c, S16(0xff7e), 52 | 0x03a4, 0x6106, 0x1bd7, S16(0xff71), 53 | 0x031c, 0x6007, 0x1d6c, S16(0xff64), 54 | 0x029f, 0x5ef5, 0x1f0b, S16(0xff56), 55 | 0x022a, 0x5dd0, 0x20b3, S16(0xff48), 56 | 0x01be, 0x5c9a, 0x2264, S16(0xff3a), 57 | 0x015b, 0x5b53, 0x241e, S16(0xff2c), 58 | 0x0101, 0x59fc, 0x25e0, S16(0xff1e), 59 | 0x00ae, 0x5896, 0x27a9, S16(0xff10), 60 | 0x0063, 0x5720, 0x297a, S16(0xff02), 61 | 0x001f, 0x559d, 0x2b50, S16(0xfef4), 62 | S16(0xffe2), 0x540d, 0x2d2c, S16(0xfee8), 63 | S16(0xffac), 0x5270, 0x2f0d, S16(0xfedb), 64 | S16(0xff7c), 0x50c7, 0x30f3, S16(0xfed0), 65 | S16(0xff53), 0x4f14, 0x32dc, S16(0xfec6), 66 | S16(0xff2e), 0x4d57, 0x34c8, S16(0xfebd), 67 | S16(0xff0f), 0x4b91, 0x36b6, S16(0xfeb6), 68 | S16(0xfef5), 0x49c2, 0x38a5, S16(0xfeb0), 69 | S16(0xfedf), 0x47ed, 0x3a95, S16(0xfeac), 70 | S16(0xfece), 0x4611, 0x3c85, S16(0xfeab), 71 | S16(0xfec0), 0x4430, 0x3e74, S16(0xfeac), 72 | S16(0xfeb6), 0x424a, 0x4060, S16(0xfeaf), 73 | S16(0xfeaf), 0x4060, 0x424a, S16(0xfeb6), 74 | S16(0xfeac), 0x3e74, 0x4430, S16(0xfec0), 75 | S16(0xfeab), 0x3c85, 0x4611, S16(0xfece), 76 | S16(0xfeac), 0x3a95, 0x47ed, S16(0xfedf), 77 | S16(0xfeb0), 0x38a5, 0x49c2, S16(0xfef5), 78 | S16(0xfeb6), 0x36b6, 0x4b91, S16(0xff0f), 79 | S16(0xfebd), 0x34c8, 0x4d57, S16(0xff2e), 80 | S16(0xfec6), 0x32dc, 0x4f14, S16(0xff53), 81 | S16(0xfed0), 0x30f3, 0x50c7, S16(0xff7c), 82 | S16(0xfedb), 0x2f0d, 0x5270, S16(0xffac), 83 | S16(0xfee8), 0x2d2c, 0x540d, S16(0xffe2), 84 | S16(0xfef4), 0x2b50, 0x559d, 0x001f, 85 | S16(0xff02), 0x297a, 0x5720, 0x0063, 86 | S16(0xff10), 0x27a9, 0x5896, 0x00ae, 87 | S16(0xff1e), 0x25e0, 0x59fc, 0x0101, 88 | S16(0xff2c), 0x241e, 0x5b53, 0x015b, 89 | S16(0xff3a), 0x2264, 0x5c9a, 0x01be, 90 | S16(0xff48), 0x20b3, 0x5dd0, 0x022a, 91 | S16(0xff56), 0x1f0b, 0x5ef5, 0x029f, 92 | S16(0xff64), 0x1d6c, 0x6007, 0x031c, 93 | S16(0xff71), 0x1bd7, 0x6106, 0x03a4, 94 | S16(0xff7e), 0x1a4c, 0x61f3, 0x0435, 95 | S16(0xff8a), 0x18cb, 0x62cb, 0x04d1, 96 | S16(0xff96), 0x1756, 0x638f, 0x0577, 97 | S16(0xffa1), 0x15eb, 0x643f, 0x0628, 98 | S16(0xffac), 0x148c, 0x64d9, 0x06e4, 99 | S16(0xffb6), 0x1338, 0x655e, 0x07ab, 100 | S16(0xffbf), 0x11f0, 0x65cd, 0x087d, 101 | S16(0xffc8), 0x10b4, 0x6626, 0x095a, 102 | S16(0xffd0), 0x0f83, 0x6669, 0x0a44, 103 | S16(0xffd8), 0x0e5f, 0x6696, 0x0b39, 104 | S16(0xffdf), 0x0d46, 0x66ad, 0x0c39, 105 | }; 106 | 107 | int32_t rdot(size_t n, const int16_t *x, const int16_t *y) 108 | { 109 | int32_t accu = 0; 110 | 111 | y += n; 112 | 113 | while (n != 0) { 114 | accu += *(x++) * *(--y); 115 | --n; 116 | } 117 | 118 | return accu; 119 | } 120 | 121 | void adpcm_compute_residuals(int16_t* dst, const int16_t* src, 122 | const int16_t* cb_entry, const int16_t* last_samples, size_t count) 123 | { 124 | const int16_t* const book1 = cb_entry; 125 | const int16_t* const book2 = cb_entry + 8; 126 | 127 | const int16_t l1 = last_samples[0]; 128 | const int16_t l2 = last_samples[1]; 129 | 130 | size_t i; 131 | 132 | assert(count <= 8); 133 | 134 | for(i = 0; i < count; ++i) { 135 | int32_t accu = (int32_t)src[i] << 11; 136 | accu += book1[i]*l1 + book2[i]*l2 + rdot(i, book2, src); 137 | dst[i] = clamp_s16(accu >> 11); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /AziAudio/Configuration.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | #pragma once 12 | 13 | //#include "common.h" 14 | #include "Settings.h" 15 | #ifdef _WIN32 16 | #include 17 | #endif 18 | 19 | /* strcpy() */ 20 | #include 21 | 22 | typedef struct 23 | { 24 | u16 validation; /* 0x00 */ 25 | u8 compression; /* 0x02 */ 26 | u8 unknown1; /* 0x03 */ 27 | u32 clockrate; /* 0x04 */ 28 | u32 programcounter; /* 0x08 */ 29 | u32 release; /* 0x0c */ 30 | u32 crc1; /* 0x10 */ 31 | u32 crc2; /* 0x14 */ 32 | u64 unknown2; /* 0x18 */ 33 | 34 | u8 name[20]; /* 0x20 - 0x33 */ 35 | 36 | u8 unknown3; /* 0x34 */ 37 | u8 unknown4; /* 0x35 */ 38 | u8 unknown5; /* 0x36 */ 39 | u8 unknown6; /* 0x37 */ 40 | u8 unknown7; /* 0x38 */ 41 | u8 unknown8; /* 0x39 */ 42 | u8 unknown9; /* 0x3a */ 43 | u8 manufacturerid; /* 0x3b */ 44 | u16 cartridgeid; /* 0x3c */ 45 | u8 countrycode; /* 0x3e */ 46 | u8 unknown10; /* 0x3f */ 47 | } t_romheader; 48 | 49 | #define CONFIGFILENAME "Config\\AziAudio.ini" 50 | 51 | #define KEY_INTNAME "INTERNAL_NAME" 52 | #define KEY_SYNCAUDIO "SyncAudio" 53 | #define KEY_FORCESYNC "ForceSync" 54 | #define KEY_AIEMULATION "AIEmulation" 55 | #define KEY_VOLUME "Volume" 56 | #define KEY_DRIVER "Driver" 57 | #define KEY_BUFFERLEVEL "BufferLevel" 58 | #define KEY_BUFFERFPS "BufferFPS" 59 | #define KEY_BACKENDFPS "BackendFPS" 60 | #define KEY_DISALLOWSLEEPXA2 "DisallowSleepXA2" 61 | #define KEY_DISALLOWSLEEPDS8 "DisallowSleepDS8" 62 | 63 | #define SECTION_GENERAL "DEFAULT_SETTINGS" 64 | 65 | class Configuration 66 | { 67 | protected: 68 | static const int MAX_FOLDER_LENGTH = 500; 69 | static const int MAX_DEVICE_LENGTH = 100; 70 | #ifdef _WIN32 71 | static INT_PTR CALLBACK ConfigProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam); 72 | static INT_PTR CALLBACK AdvancedProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 73 | static INT_PTR CALLBACK SettingsProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 74 | #endif 75 | static unsigned long configVolume; 76 | static char configAudioLogFolder[MAX_FOLDER_LENGTH]; 77 | //static LPGUID configDevice; 78 | static SoundDriverType configDriver; 79 | static Settings currentSettings; 80 | 81 | // Setters 82 | static void setAIEmulation(bool value) { currentSettings.configAIEmulation = value; } 83 | static void setSyncAudio(bool value) { currentSettings.configSyncAudio = value; } 84 | static void setForceSync(bool value) { currentSettings.configForceSync = value; } 85 | static void setVolume(unsigned long value) { configVolume = value; } 86 | static void setDriver(SoundDriverType value) { configDriver = value; } 87 | static void setFrequency(unsigned long value) { currentSettings.configFrequency = value; } 88 | static void setBitRate(unsigned long value) { currentSettings.configBitRate = value; } 89 | static void setBufferLevel(unsigned long value) { currentSettings.configBufferLevel = value; } 90 | static void setBufferFPS(unsigned long value) { currentSettings.configBufferFPS = value; } 91 | static void setBackendFPS(unsigned long value) { currentSettings.configBackendFPS = value; } 92 | static void setDisallowSleepXA2(bool value) { currentSettings.configDisallowSleepXA2 = value; } 93 | static void setDisallowSleepDS8(bool value) { currentSettings.configDisallowSleepDS8 = value; } 94 | static void setResTimer(bool value) { currentSettings.configResTimer = value; } 95 | 96 | static void ResetAdvancedPage(HWND hDlg); 97 | 98 | public: 99 | static t_romheader* Header; 100 | static bool RomRunning; 101 | static void LoadDefaults(); 102 | static void LoadSettings(); 103 | static void SaveSettings(); 104 | static bool config_load(); 105 | static bool config_load_rom(); 106 | static bool config_save(); 107 | static bool config_save_rom(); 108 | #ifdef _WIN32 109 | static void ConfigDialog(HWND hParent); 110 | static void AboutDialog(HWND hParent); 111 | #endif 112 | // Accessors for the Configuration variables to prevent changes outside of Configuration.cpp 113 | static bool getAIEmulation() { return currentSettings.configAIEmulation; } 114 | static unsigned long getVolume() { return configVolume; } 115 | static bool getForceSync() { return currentSettings.configForceSync; } 116 | static bool getSyncAudio() { return currentSettings.configSyncAudio; } 117 | static SoundDriverType getDriver() { return configDriver; } 118 | static unsigned long getFrequency() { return currentSettings.configFrequency; } 119 | static unsigned long getBitRate() { return currentSettings.configBitRate; } 120 | static unsigned long getBufferLevel() { return currentSettings.configBufferLevel; } 121 | static unsigned long getBufferFPS() { return currentSettings.configBufferFPS; } 122 | static unsigned long getBackendFPS() { return currentSettings.configBackendFPS; } 123 | static bool getDisallowSleepXA2() { return currentSettings.configDisallowSleepXA2; } 124 | static bool getDisallowSleepDS8() { return currentSettings.configDisallowSleepDS8; } 125 | static bool getResTimer() { return currentSettings.configResTimer; } 126 | 127 | static char* getAudioLogFolder() { 128 | static char retVal[MAX_FOLDER_LENGTH]; 129 | strcpy(retVal, configAudioLogFolder); 130 | return retVal; 131 | } 132 | #if 0 /* Disable Device Configuration */ 133 | static LPGUID getDevice() { return configDevice; } 134 | #endif 135 | }; 136 | -------------------------------------------------------------------------------- /AziAudio/ABI_Buffers.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | /* memset() and memcpy() */ 13 | #include 14 | 15 | #include "audiohle.h" 16 | 17 | void CLEARBUFF() { 18 | u32 addr = (u32)(k0 & 0xffff); 19 | u32 count = (u32)(t9 & 0xffff); 20 | addr &= 0xFFFC; 21 | memset(BufferSpace + addr, 0, (count + 3) & 0xFFFC); 22 | } 23 | 24 | void CLEARBUFF2() { 25 | u16 addr = (u16)(k0 & 0xffff); 26 | u16 count = (u16)(t9 & 0xffff); 27 | if (count > 0) 28 | memset(BufferSpace + addr, 0, count); 29 | } 30 | 31 | void CLEARBUFF3() { 32 | u16 addr = (u16)(k0 & 0xffff); 33 | u16 count = (u16)(t9 & 0xffff); 34 | memset(BufferSpace + addr + 0x4f0, 0, count); 35 | } 36 | 37 | void DMEMMOVE() { 38 | u32 v0, v1; 39 | u32 cnt; 40 | if ((t9 & 0xffff) == 0) 41 | return; 42 | v0 = (k0 & 0xFFFF); 43 | v1 = (t9 >> 0x10); 44 | 45 | u32 count = ((t9 + 3) & 0xfffc); 46 | 47 | for (cnt = 0; cnt < count; cnt += 4) { 48 | BufferSpace[BES(v1 + cnt + 0)] = BufferSpace[BES(v0 + cnt + 0)]; 49 | BufferSpace[BES(v1 + cnt + 1)] = BufferSpace[BES(v0 + cnt + 1)]; 50 | BufferSpace[BES(v1 + cnt + 2)] = BufferSpace[BES(v0 + cnt + 2)]; 51 | BufferSpace[BES(v1 + cnt + 3)] = BufferSpace[BES(v0 + cnt + 3)]; 52 | } 53 | } 54 | 55 | void DMEMMOVE2() { // Needs accuracy verification... 56 | u32 v0, v1; 57 | u32 cnt; 58 | if ((t9 & 0xffff) == 0) 59 | return; 60 | v0 = (k0 & 0xFFFF); 61 | v1 = (t9 >> 0x10); 62 | //assert ((v1 & 0x3) == 0); 63 | //assert ((v0 & 0x3) == 0); 64 | u32 count = ((t9 + 3) & 0xfffc); 65 | //v0 = (v0) & 0xfffc; 66 | //v1 = (v1) & 0xfffc; 67 | 68 | //memcpy (dmem+v1, dmem+v0, count-1); 69 | for (cnt = 0; cnt < count; cnt += 4) { 70 | BufferSpace[BES(v1 + cnt + 0)] = BufferSpace[BES(v0 + cnt + 0)]; 71 | BufferSpace[BES(v1 + cnt + 1)] = BufferSpace[BES(v0 + cnt + 1)]; 72 | BufferSpace[BES(v1 + cnt + 2)] = BufferSpace[BES(v0 + cnt + 2)]; 73 | BufferSpace[BES(v1 + cnt + 3)] = BufferSpace[BES(v0 + cnt + 3)]; 74 | } 75 | } 76 | 77 | void DMEMMOVE3() { // Needs accuracy verification... 78 | u32 v0, v1; 79 | u32 cnt; 80 | v0 = (k0 & 0xFFFF) + 0x4f0; 81 | v1 = (t9 >> 0x10) + 0x4f0; 82 | u32 count = ((t9 + 3) & 0xfffc); 83 | 84 | //memcpy (dmem+v1, dmem+v0, count-1); 85 | for (cnt = 0; cnt < count; cnt += 4) { 86 | BufferSpace[BES(v1 + cnt + 0)] = BufferSpace[BES(v0 + cnt + 0)]; 87 | BufferSpace[BES(v1 + cnt + 1)] = BufferSpace[BES(v0 + cnt + 1)]; 88 | BufferSpace[BES(v1 + cnt + 2)] = BufferSpace[BES(v0 + cnt + 2)]; 89 | BufferSpace[BES(v1 + cnt + 3)] = BufferSpace[BES(v0 + cnt + 3)]; 90 | } 91 | } 92 | 93 | void DUPLICATE2() { 94 | u16 Count = (k0 >> 16) & 0xff; 95 | u16 In = k0 & 0xffff; 96 | u16 Out = (t9 >> 16); 97 | 98 | u16 buff[64]; 99 | 100 | memcpy(buff, BufferSpace + In, 128); 101 | 102 | while (Count) { 103 | memcpy(BufferSpace + Out, buff, 128); 104 | Out += 128; 105 | Count--; 106 | } 107 | } 108 | 109 | // TODO: This comment has me wondering if there's a problem. 10+ year old comments are hard to remember. -Azimer 110 | void LOADBUFF() { // memcpy causes static... endianess issue :( 111 | u32 v0; 112 | if (AudioCount == 0) 113 | return; 114 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 115 | memcpy(BufferSpace + (AudioInBuffer & 0xFFFC), DRAM + v0, (AudioCount + 3) & 0xFFFC); 116 | } 117 | 118 | void LOADBUFF2() { // Needs accuracy verification... 119 | u32 v0; 120 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 121 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 122 | memcpy(BufferSpace + (k0 & 0xfffc), DRAM + v0, (cnt + 3) & 0xFFFC); 123 | } 124 | 125 | void LOADBUFF3() { 126 | u32 v0; 127 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 128 | v0 = (t9 & 0xfffffc); 129 | u32 src = (k0 & 0xffc) + 0x4f0; 130 | memcpy(BufferSpace + src, DRAM + v0, cnt); 131 | } 132 | 133 | // TODO: This comment has me wondering if there's a problem. 10+ year old comments are hard to remember. -Azimer 134 | void SAVEBUFF() { // memcpy causes static... endianess issue :( 135 | u32 v0; 136 | if (AudioCount == 0) 137 | return; 138 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 139 | memcpy(DRAM + v0, BufferSpace + (AudioOutBuffer & 0xFFFC), (AudioCount + 3) & 0xFFFC); 140 | } 141 | 142 | void SAVEBUFF2() { // Needs accuracy verification... 143 | u32 v0; 144 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 145 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 146 | memcpy(DRAM + v0, BufferSpace + (k0 & 0xfffc), (cnt + 3) & 0xFFFC); 147 | } 148 | 149 | void SAVEBUFF3() { 150 | u32 v0; 151 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 152 | v0 = (t9 & 0xfffffc); 153 | u32 src = (k0 & 0xffc) + 0x4f0; 154 | memcpy(DRAM + v0, BufferSpace + src, cnt); 155 | } 156 | 157 | void SEGMENT() { // Should work 158 | SEGMENTS[(t9 >> 24) & 0xf] = (t9 & 0xffffff); 159 | } 160 | 161 | void SEGMENT2() { 162 | if (isZeldaABI) { 163 | FILTER2(); 164 | return; 165 | } 166 | if ((k0 & 0xffffff) == 0) { 167 | isMKABI = true; 168 | //SEGMENTS[(t9>>24)&0xf] = (t9 & 0xffffff); 169 | } 170 | else { 171 | isMKABI = false; 172 | isZeldaABI = true; 173 | FILTER2(); 174 | } 175 | } 176 | 177 | void SETBUFF() { // Should work ;-) 178 | if ((k0 >> 0x10) & 0x8) { // A_AUX - Auxillary Sound Buffer Settings 179 | AudioAuxA = (u16)(k0 & 0xFFFF); 180 | AudioAuxC = (u16)((t9 >> 0x10)); 181 | AudioAuxE = (u16)(t9 & 0xFFFF); 182 | } 183 | else { // A_MAIN - Main Sound Buffer Settings 184 | AudioInBuffer = (u16)(k0 & 0xFFFF); // 0x00 185 | AudioOutBuffer = (u16)((t9 >> 0x10)); // 0x02 186 | AudioCount = (u16)(t9 & 0xFFFF); // 0x04 187 | } 188 | } 189 | 190 | void SETBUFF2() { 191 | AudioInBuffer = (u16)(k0 & 0xFFFF); // 0x00 192 | AudioOutBuffer = (u16)(t9 >> 0x10); // 0x02 193 | AudioCount = (u16)(t9 & 0xFFFF); // 0x04 194 | } 195 | 196 | void SETLOOP() { 197 | loopval = (t9 & 0xffffff);// + SEGMENTS[(t9>>24)&0xf]; 198 | //VolTrg_Left = (s16)(loopval>>16); // m_LeftVol 199 | //VolRamp_Left = (s16)(loopval); // m_LeftVolTarget 200 | } 201 | 202 | void SETLOOP2() { 203 | loopval = t9 & 0xffffff; // No segment? 204 | } 205 | 206 | void SETLOOP3() { 207 | loopval = (t9 & 0xffffff); 208 | } 209 | -------------------------------------------------------------------------------- /AziAudio/AziAudio2010.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {835979AC-BC6A-45B7-A513-8EEE79B443DE} 23 | AziAudio 24 | 25 | 26 | DynamicLibrary 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 35 | $(SolutionDir)Target\$(Platform)\$(Configuration)\ 36 | 37 | 38 | 39 | 40 | 41 | NotUsing 42 | $(SolutionDir)3rd Party\directx\include 43 | 44 | 45 | $(SolutionDir)3rd Party\directx\lib\x86 46 | $(SolutionDir)3rd Party\directx\lib\x64 47 | dsound.lib;%(AdditionalDependencies) 48 | UseLinkTimeCodeGeneration 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /AziAudio/AziAudio.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {835979AC-BC6A-45B7-A513-8EEE79B443DE} 23 | AziAudio 24 | AziAudio 25 | 10.0 26 | 27 | 28 | DynamicLibrary 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | $(SolutionDir)Build\$(Platform)\$(Configuration)\ 37 | $(SolutionDir)Target\$(Platform)\$(Configuration)\ 38 | 39 | 40 | 41 | 42 | 43 | NotUsing 44 | $(SolutionDir)3rd Party\directx\include 45 | 46 | 47 | $(SolutionDir)3rd Party\directx\lib\x86 48 | $(SolutionDir)3rd Party\directx\lib\x64 49 | dsound.lib;%(AdditionalDependencies) 50 | UseLinkTimeCodeGeneration 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /AziAudio/WaveOutSoundDriver.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include "common.h" 13 | #if defined(ENABLE_BACKEND_WAVEOUT) 14 | #include "WaveOutSoundDriver.h" 15 | #include "AudioSpec.h" 16 | #include 17 | #include "SoundDriverFactory.h" 18 | 19 | #pragma comment(lib, "winmm.lib") // TODO: Move this to the project / propsheets 20 | 21 | WaveOutSoundDriver* WaveOutSoundDriver::m_Instance; 22 | 23 | bool WaveOutSoundDriver::ClassRegistered = ValidateDriver() ? 24 | SoundDriverFactory::RegisterSoundDriver(SND_DRIVER_WAVEOUT, WaveOutSoundDriver::CreateSoundDriver, "WaveOut Driver", 1) : 25 | false; 26 | 27 | /* 28 | Will verify the driver can run in the configured environment 29 | */ 30 | bool WaveOutSoundDriver::ValidateDriver() 31 | { 32 | // This should be available in all versions of Windows in the last 25 years 33 | WAVEOUTCAPS caps; 34 | waveOutGetDevCaps(WAVE_MAPPER, &caps, sizeof(WAVEOUTCAPS)); 35 | if (caps.dwFormats & WAVE_FORMAT_4S16) 36 | return true; 37 | else 38 | return false; 39 | } 40 | 41 | WaveOutSoundDriver::WaveOutSoundDriver() 42 | { 43 | DEBUG_OUTPUT("WO Constructor"); 44 | m_hWave = NULL; 45 | SampleRate = 0; 46 | m_numOutputBuffers = 0; 47 | m_OutputBuffersSize = 0; 48 | m_OutputBuffers = NULL; 49 | m_BufferMemory = NULL; 50 | m_Instance = this; 51 | DEBUG_OUTPUT("WO Constructor done"); 52 | } 53 | 54 | WaveOutSoundDriver::~WaveOutSoundDriver() 55 | { 56 | DEBUG_OUTPUT("WO Deconstructor"); 57 | Teardown(); 58 | DEBUG_OUTPUT("WO Deconstructor done"); 59 | } 60 | 61 | void WaveOutSoundDriver::Teardown() 62 | { 63 | DEBUG_OUTPUT("WO: Teardown()\n"); 64 | WaitForSingleObject(m_hMutex, INFINITE); 65 | bIsDone = true; 66 | if (m_hWave != NULL) 67 | { 68 | waveOutReset(m_hWave); 69 | waveOutClose(m_hWave); 70 | } 71 | if (m_OutputBuffers != NULL) 72 | { 73 | delete m_OutputBuffers; 74 | } 75 | if (m_BufferMemory != NULL) 76 | { 77 | delete m_BufferMemory; 78 | } 79 | m_hWave = NULL; 80 | m_OutputBuffers = NULL; 81 | m_BufferMemory = NULL; 82 | ReleaseMutex(m_Instance->m_hMutex); 83 | DEBUG_OUTPUT("WO: Teardown() done\n"); 84 | } 85 | 86 | void WaveOutSoundDriver::Setup() 87 | { 88 | DEBUG_OUTPUT("WO: Setup()\n"); 89 | WAVEFORMATEX wfm; 90 | memset(&wfm, 0, sizeof(WAVEFORMATEX)); 91 | 92 | wfm.wFormatTag = WAVE_FORMAT_PCM; 93 | wfm.nChannels = 2; 94 | wfm.nSamplesPerSec = SampleRate; 95 | wfm.wBitsPerSample = 16; 96 | wfm.nBlockAlign = wfm.wBitsPerSample / 8 * wfm.nChannels; 97 | wfm.nAvgBytesPerSec = wfm.nSamplesPerSec * wfm.nBlockAlign; 98 | 99 | waveOutOpen(&m_hWave, WAVE_MAPPER, &wfm, (DWORD_PTR)waveOutProc, 0, CALLBACK_FUNCTION); 100 | bIsDone = false; 101 | DEBUG_OUTPUT("WO: Setup() done\n"); 102 | } 103 | 104 | BOOL WaveOutSoundDriver::Initialize() 105 | { 106 | DEBUG_OUTPUT("WO: Initialize()\n"); 107 | Teardown(); 108 | SampleRate = 0; 109 | 110 | DEBUG_OUTPUT("WO: Initialize() done\n"); 111 | if (m_hWave == NULL) 112 | return TRUE; 113 | else 114 | return FALSE; 115 | } 116 | 117 | void WaveOutSoundDriver::DeInitialize() 118 | { 119 | DEBUG_OUTPUT("WO: DeInitialize()\n"); 120 | Teardown(); 121 | DEBUG_OUTPUT("WO: DeInitialize() done\n"); 122 | } 123 | 124 | void WaveOutSoundDriver::SetFrequency(u32 Frequency) 125 | { 126 | DEBUG_OUTPUT("WO: SetFrequency()\n"); 127 | if (SampleRate != Frequency) 128 | { 129 | Teardown(); 130 | SampleRate = Frequency; 131 | Setup(); 132 | if (Configuration::getBackendFPS() <= 60) 133 | { 134 | m_OutputBuffersSize = (u32)((Frequency / Configuration::getBackendFPS())) * 4; 135 | } 136 | else 137 | { 138 | m_OutputBuffersSize = (u32)((Frequency / 60)) * 4; 139 | } 140 | m_numOutputBuffers = 3;// Configuration::getBufferLevel(); // TODO: Is this necessary? It seems "60 FPS" and 3 buffers is lowest before performance impact 141 | 142 | assert(m_OutputBuffers == NULL); 143 | assert(m_BufferMemory == NULL); 144 | assert(m_numOutputBuffers > 0); 145 | m_OutputBuffers = new WAVEHDR[m_numOutputBuffers]; 146 | m_BufferMemory = new u8[m_numOutputBuffers * m_OutputBuffersSize]; 147 | memset(m_BufferMemory, 0, sizeof(u8) * m_numOutputBuffers * m_OutputBuffersSize); 148 | memset(m_OutputBuffers, 0, sizeof(WAVEHDR) * m_numOutputBuffers); 149 | for (int i = 0; i < m_numOutputBuffers; i++) 150 | { 151 | m_OutputBuffers[i].lpData = (LPSTR)(m_BufferMemory + i*m_OutputBuffersSize); 152 | m_OutputBuffers[i].dwBufferLength = m_OutputBuffersSize; 153 | m_OutputBuffers[i].dwUser = i; 154 | waveOutPrepareHeader(m_hWave, &m_OutputBuffers[i], sizeof(WAVEHDR)); 155 | } 156 | for (int i = 0; i < m_numOutputBuffers; i++) 157 | { 158 | waveOutWrite(m_hWave, &m_OutputBuffers[i], sizeof(WAVEHDR)); 159 | } 160 | } 161 | } 162 | 163 | void WaveOutSoundDriver::StopAudio() 164 | { 165 | DEBUG_OUTPUT("WO: StopAudio()\n"); 166 | if (m_hWave != NULL) 167 | waveOutPause(m_hWave); 168 | DEBUG_OUTPUT("WO: StopAudio() done\n"); 169 | } 170 | 171 | void WaveOutSoundDriver::StartAudio() 172 | { 173 | DEBUG_OUTPUT("WO: StartAudio()\n"); 174 | if (m_hWave != NULL) 175 | waveOutRestart(m_hWave); 176 | DEBUG_OUTPUT("WO: StartAudio() done\n"); 177 | } 178 | 179 | void WaveOutSoundDriver::SetVolume(u32 volume) 180 | { 181 | DWORD level = (DWORD)((((float)(100-volume))/100.0) * 0xFFFF); 182 | DWORD result = (DWORD)((DWORD)(level & 0xFFFF) | ((DWORD)(level & 0xFFFF) * 0x10000)); 183 | 184 | waveOutSetVolume(m_hWave, result); 185 | } 186 | 187 | 188 | void CALLBACK WaveOutSoundDriver::waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) 189 | { 190 | UNREFERENCED_PARAMETER(dwParam2); 191 | UNREFERENCED_PARAMETER(dwInstance); 192 | UNREFERENCED_PARAMETER(hwo); 193 | LPWAVEHDR waveheader; 194 | DWORD index; 195 | 196 | if (m_Instance->bIsDone) return; 197 | switch (uMsg) 198 | { 199 | case WOM_OPEN: 200 | DEBUG_OUTPUT("WO: WOM_OPEN\n"); 201 | break; 202 | case WOM_CLOSE: 203 | DEBUG_OUTPUT("WO: WOM_CLOSE\n"); 204 | break; 205 | case WOM_DONE: 206 | WaitForSingleObject(m_Instance->m_hMutex, INFINITE); 207 | if (m_Instance->bIsDone) return; 208 | waveOutUnprepareHeader(m_Instance->m_hWave, (LPWAVEHDR)dwParam1, sizeof(WAVEHDR)); 209 | waveheader = (LPWAVEHDR)dwParam1; 210 | index = (DWORD)waveheader->dwUser; // We are using the dwUser not as a pointer but a DWORD value 211 | memset(&m_Instance->m_OutputBuffers[index], 0, sizeof(WAVEHDR)); 212 | m_Instance->m_OutputBuffers[index].lpData = (LPSTR)(m_Instance->m_BufferMemory + index*m_Instance->m_OutputBuffersSize); 213 | m_Instance->m_OutputBuffers[index].dwBufferLength = m_Instance->m_OutputBuffersSize; 214 | m_Instance->m_OutputBuffers[index].dwUser = index; 215 | m_Instance->LoadAiBuffer((u8 *)m_Instance->m_OutputBuffers[index].lpData, m_Instance->m_OutputBuffersSize); 216 | waveOutPrepareHeader(m_Instance->m_hWave, &m_Instance->m_OutputBuffers[index], sizeof(WAVEHDR)); 217 | waveOutWrite(m_Instance->m_hWave, &m_Instance->m_OutputBuffers[index], sizeof(WAVEHDR)); 218 | ReleaseMutex(m_Instance->m_hMutex); 219 | break; 220 | } 221 | } 222 | #endif 223 | -------------------------------------------------------------------------------- /AziAudio/ABI_Resample.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2019 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include "audiohle.h" 13 | 14 | u16 ResampleLUT[0x200] = { 15 | 0x0C39, 0x66AD, 0x0D46, 0xFFDF, 0x0B39, 0x6696, 0x0E5F, 0xFFD8, 16 | 0x0A44, 0x6669, 0x0F83, 0xFFD0, 0x095A, 0x6626, 0x10B4, 0xFFC8, 17 | 0x087D, 0x65CD, 0x11F0, 0xFFBF, 0x07AB, 0x655E, 0x1338, 0xFFB6, 18 | 0x06E4, 0x64D9, 0x148C, 0xFFAC, 0x0628, 0x643F, 0x15EB, 0xFFA1, 19 | 0x0577, 0x638F, 0x1756, 0xFF96, 0x04D1, 0x62CB, 0x18CB, 0xFF8A, 20 | 0x0435, 0x61F3, 0x1A4C, 0xFF7E, 0x03A4, 0x6106, 0x1BD7, 0xFF71, 21 | 0x031C, 0x6007, 0x1D6C, 0xFF64, 0x029F, 0x5EF5, 0x1F0B, 0xFF56, 22 | 0x022A, 0x5DD0, 0x20B3, 0xFF48, 0x01BE, 0x5C9A, 0x2264, 0xFF3A, 23 | 0x015B, 0x5B53, 0x241E, 0xFF2C, 0x0101, 0x59FC, 0x25E0, 0xFF1E, 24 | 0x00AE, 0x5896, 0x27A9, 0xFF10, 0x0063, 0x5720, 0x297A, 0xFF02, 25 | 0x001F, 0x559D, 0x2B50, 0xFEF4, 0xFFE2, 0x540D, 0x2D2C, 0xFEE8, 26 | 0xFFAC, 0x5270, 0x2F0D, 0xFEDB, 0xFF7C, 0x50C7, 0x30F3, 0xFED0, 27 | 0xFF53, 0x4F14, 0x32DC, 0xFEC6, 0xFF2E, 0x4D57, 0x34C8, 0xFEBD, 28 | 0xFF0F, 0x4B91, 0x36B6, 0xFEB6, 0xFEF5, 0x49C2, 0x38A5, 0xFEB0, 29 | 0xFEDF, 0x47ED, 0x3A95, 0xFEAC, 0xFECE, 0x4611, 0x3C85, 0xFEAB, 30 | 0xFEC0, 0x4430, 0x3E74, 0xFEAC, 0xFEB6, 0x424A, 0x4060, 0xFEAF, 31 | 0xFEAF, 0x4060, 0x424A, 0xFEB6, 0xFEAC, 0x3E74, 0x4430, 0xFEC0, 32 | 0xFEAB, 0x3C85, 0x4611, 0xFECE, 0xFEAC, 0x3A95, 0x47ED, 0xFEDF, 33 | 0xFEB0, 0x38A5, 0x49C2, 0xFEF5, 0xFEB6, 0x36B6, 0x4B91, 0xFF0F, 34 | 0xFEBD, 0x34C8, 0x4D57, 0xFF2E, 0xFEC6, 0x32DC, 0x4F14, 0xFF53, 35 | 0xFED0, 0x30F3, 0x50C7, 0xFF7C, 0xFEDB, 0x2F0D, 0x5270, 0xFFAC, 36 | 0xFEE8, 0x2D2C, 0x540D, 0xFFE2, 0xFEF4, 0x2B50, 0x559D, 0x001F, 37 | 0xFF02, 0x297A, 0x5720, 0x0063, 0xFF10, 0x27A9, 0x5896, 0x00AE, 38 | 0xFF1E, 0x25E0, 0x59FC, 0x0101, 0xFF2C, 0x241E, 0x5B53, 0x015B, 39 | 0xFF3A, 0x2264, 0x5C9A, 0x01BE, 0xFF48, 0x20B3, 0x5DD0, 0x022A, 40 | 0xFF56, 0x1F0B, 0x5EF5, 0x029F, 0xFF64, 0x1D6C, 0x6007, 0x031C, 41 | 0xFF71, 0x1BD7, 0x6106, 0x03A4, 0xFF7E, 0x1A4C, 0x61F3, 0x0435, 42 | 0xFF8A, 0x18CB, 0x62CB, 0x04D1, 0xFF96, 0x1756, 0x638F, 0x0577, 43 | 0xFFA1, 0x15EB, 0x643F, 0x0628, 0xFFAC, 0x148C, 0x64D9, 0x06E4, 44 | 0xFFB6, 0x1338, 0x655E, 0x07AB, 0xFFBF, 0x11F0, 0x65CD, 0x087D, 45 | 0xFFC8, 0x10B4, 0x6626, 0x095A, 0xFFD0, 0x0F83, 0x6669, 0x0A44, 46 | 0xFFD8, 0x0E5F, 0x6696, 0x0B39, 0xFFDF, 0x0D46, 0x66AD, 0x0C39 47 | }; 48 | 49 | s32 MultAddLUT(s16 *src, u32 srcPtr, u32 location) 50 | { 51 | s16 *lut = (s16 *)(((u8 *)ResampleLUT) + location); 52 | s32 accum = 0; 53 | for (int i = 0; i < 4; i++) 54 | { 55 | s32 temp = ((s32)*(s16*)(src + MES(srcPtr + i)) * ((s32)((s16)lut[i]))); 56 | accum += (s32)((temp+0x4000) >> 15); 57 | } 58 | 59 | return accum; 60 | } 61 | 62 | void RESAMPLE() { 63 | u8 Flags = (u8)((k0 >> 16) & 0xff); 64 | u32 Pitch = ((k0 & 0xffff)) << 1; 65 | u32 addy = (t9 & 0xffffff);// + SEGMENTS[(t9>>24)&0xf]; 66 | u32 Accum = 0; 67 | u32 location; 68 | s16 *dst; 69 | s16 *src; 70 | dst = (s16 *)(BufferSpace); 71 | src = (s16 *)(BufferSpace); 72 | u32 srcPtr = (AudioInBuffer / 2); 73 | u32 dstPtr = (AudioOutBuffer / 2); 74 | 75 | /* 76 | if (addy > (1024*1024*8)) 77 | addy = (t9 & 0xffffff); 78 | */ 79 | srcPtr -= 4; 80 | 81 | if ((Flags & 0x1) == 0) { 82 | //memcpy (src+srcPtr, rdram+addy, 0x8); 83 | for (int x = 0; x < 4; x++) 84 | src[MES(srcPtr + x)] = ((u16 *)DRAM)[MES((addy / 2) + x)]; 85 | Accum = *(u16 *)(DRAM + addy + 10); 86 | } 87 | else { 88 | for (int x = 0; x < 4; x++) 89 | src[MES(srcPtr + x)] = 0;//*(u16 *)(rdram + HES(addy + x)); 90 | } 91 | 92 | assert((Flags & 0x2) == 0); 93 | 94 | for (int i = 0; i < ((AudioCount + 0xf) & 0xFFF0) / 2; i++) { 95 | //location = (((Accum * 0x40) >> 0x10) * 8); 96 | location = (Accum >> 0xa) << 0x3; 97 | 98 | // mov eax, dword ptr [src+srcPtr]; 99 | // movsx edx, word ptr [lut]; 100 | // shl edx, 1 101 | // imul edx 102 | // test eax, 08000h 103 | // setz ecx 104 | // shl ecx, 16 105 | // xor eax, 08000h 106 | // add eax, ecx 107 | // and edx, 0f000h 108 | 109 | // imul 110 | 111 | dst[MES(dstPtr)] = pack_signed(MultAddLUT(src, srcPtr, location)); 112 | dstPtr++; 113 | Accum += Pitch; 114 | srcPtr += (Accum >> 16); 115 | Accum &= 0xffff; 116 | } 117 | for (int x = 0; x < 4; x++) 118 | ((u16 *)DRAM)[MES((addy / 2) + x)] = src[MES(srcPtr + x)]; 119 | //memcpy (RSWORK, src+srcPtr, 0x8); 120 | *(u16 *)(DRAM + addy + 10) = (u16)Accum; 121 | } 122 | 123 | void RESAMPLE2() { 124 | u8 Flags = (u8)((k0 >> 16) & 0xff); 125 | u32 Pitch = ((k0 & 0xffff)) << 1; 126 | u32 addy = (t9 & 0xffffff);// + SEGMENTS[(t9>>24)&0xf]; 127 | u32 Accum = 0; 128 | u32 location; 129 | s16 *dst; 130 | s16 *src; 131 | dst = (s16 *)(BufferSpace); 132 | src = (s16 *)(BufferSpace); 133 | u32 srcPtr = (AudioInBuffer / 2); 134 | u32 dstPtr = (AudioOutBuffer / 2); 135 | 136 | if (addy > (1024 * 1024 * 8)) 137 | addy = (t9 & 0xffffff); 138 | 139 | srcPtr -= 4; 140 | 141 | if ((Flags & 0x1) == 0) { 142 | for (int x = 0; x < 4; x++) //memcpy (src+srcPtr, rdram+addy, 0x8); 143 | src[MES(srcPtr + x)] = ((u16 *)DRAM)[MES((addy / 2) + x)]; 144 | Accum = *(u16 *)(DRAM + addy + 10); 145 | } 146 | else { 147 | for (int x = 0; x < 4; x++) 148 | src[MES(srcPtr + x)] = 0;//*(u16 *)(rdram + HES(addy + x)); 149 | } 150 | 151 | // assert((Flags & 0x2) == 0); 152 | 153 | for (int i = 0; i < ((AudioCount + 0xf) & 0xFFF0) / 2; i++) { 154 | location = (((Accum * 0x40) >> 0x10) * 8); 155 | //location = (Accum >> 0xa) << 0x3; 156 | 157 | dst[MES(dstPtr)] = pack_signed(MultAddLUT(src, srcPtr, location)); 158 | dstPtr++; 159 | Accum += Pitch; 160 | srcPtr += (Accum >> 16); 161 | Accum &= 0xffff; 162 | } 163 | for (int x = 0; x < 4; x++) 164 | ((u16 *)DRAM)[MES((addy / 2) + x)] = src[MES(srcPtr + x)]; 165 | *(u16 *)(DRAM + addy + 10) = (u16)Accum; 166 | //memcpy (RSWORK, src+srcPtr, 0x8); 167 | } 168 | 169 | void RESAMPLE3() { 170 | u8 Flags = (u8)((t9 >> 0x1e)); 171 | u32 Pitch = ((t9 >> 0xe) & 0xffff) << 1; 172 | u32 addy = (k0 & 0xffffff); 173 | u32 Accum = 0; 174 | u32 location; 175 | s16 *dst; 176 | s16 *src; 177 | dst = (s16 *)(BufferSpace); 178 | src = (s16 *)(BufferSpace); 179 | u32 srcPtr = ((((t9 >> 2) & 0xfff) + 0x4f0) / 2); 180 | u32 dstPtr;//=(AudioOutBuffer/2); 181 | 182 | //if (addy > (1024*1024*8)) 183 | // addy = (t9 & 0xffffff); 184 | 185 | srcPtr -= 4; 186 | 187 | if (t9 & 0x3) { 188 | dstPtr = 0x660 / 2; 189 | } 190 | else { 191 | dstPtr = 0x4f0 / 2; 192 | } 193 | 194 | if ((Flags & 0x1) == 0) { 195 | for (int x = 0; x < 4; x++) //memcpy (src+srcPtr, rdram+addy, 0x8); 196 | src[MES(srcPtr + x)] = ((u16 *)DRAM)[MES((addy / 2) + x)]; 197 | Accum = *(u16 *)(DRAM + addy + 10); 198 | } 199 | else { 200 | for (int x = 0; x < 4; x++) 201 | src[MES(srcPtr + x)] = 0;//*(u16 *)(rdram + HES(addy + x)); 202 | } 203 | 204 | #ifdef _DEBUG 205 | assert((Flags & 0x2) == 0); 206 | #endif 207 | 208 | for (int i = 0; i < 0x170 / 2; i++) { 209 | location = (((Accum * 0x40) >> 0x10) * 8); 210 | //location = (Accum >> 0xa) << 0x3; 211 | 212 | /* 213 | for (int i = 0; i < 4; i++) 214 | { 215 | temp = ((s64)*(s16*)(src + MES(srcPtr+i))*((s64)((s16)lut[i]<<1))); 216 | if (temp & 0x8000) temp = (temp^0x8000) + 0x10000; 217 | else temp = (temp^0x8000); 218 | temp = (s32)(temp >> 16); 219 | accum = (s32)pack_signed(temp); 220 | } 221 | */ 222 | 223 | dst[MES(dstPtr)] = pack_signed(MultAddLUT(src, srcPtr, location)); 224 | dstPtr++; 225 | Accum += Pitch; 226 | srcPtr += (Accum >> 16); 227 | Accum &= 0xffff; 228 | } 229 | for (int x = 0; x < 4; x++) 230 | ((u16 *)DRAM)[MES((addy / 2) + x)] = src[MES(srcPtr + x)]; 231 | *(u16 *)(DRAM + addy + 10) = (u16)Accum; 232 | } 233 | -------------------------------------------------------------------------------- /AziAudio/AziAudio.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {43b2e3b5-e716-4d8f-ba1a-b40e20c69319} 18 | 19 | 20 | {8c30a8de-e2ce-48be-af01-21ba3969d5f2} 21 | 22 | 23 | {95916df6-fc86-47c2-9217-016b83ad7d67} 24 | 25 | 26 | {25c811b5-8ad0-4d49-b449-e6b2a225ab89} 27 | 28 | 29 | 30 | 31 | Source Files\Sound Driver 32 | 33 | 34 | Source Files\Sound Driver 35 | 36 | 37 | Source Files\Sound Driver 38 | 39 | 40 | Mupen64Plus HLE\Mupen64Plus Headers 41 | 42 | 43 | Mupen64Plus HLE\Mupen64Plus Headers 44 | 45 | 46 | Mupen64Plus HLE\Mupen64Plus Headers 47 | 48 | 49 | Mupen64Plus HLE\Mupen64Plus Headers 50 | 51 | 52 | Mupen64Plus HLE\Mupen64Plus Headers 53 | 54 | 55 | Mupen64Plus HLE\Mupen64Plus Headers 56 | 57 | 58 | Mupen64Plus HLE\Mupen64Plus Headers 59 | 60 | 61 | Mupen64Plus HLE\Mupen64Plus Headers 62 | 63 | 64 | Header Files 65 | 66 | 67 | Header Files 68 | 69 | 70 | Header Files 71 | 72 | 73 | Header Files 74 | 75 | 76 | Header Files 77 | 78 | 79 | Header Files 80 | 81 | 82 | Source Files\Sound Driver 83 | 84 | 85 | Source Files\Sound Driver 86 | 87 | 88 | Source Files\Sound Driver 89 | 90 | 91 | Source Files 92 | 93 | 94 | Source Files\Sound Driver 95 | 96 | 97 | Source Files\Sound Driver 98 | 99 | 100 | Source Files\Sound Driver 101 | 102 | 103 | Source Files\Sound Driver 104 | 105 | 106 | Source Files\Sound Driver 107 | 108 | 109 | Source Files 110 | 111 | 112 | 113 | 114 | Source Files\Sound Driver 115 | 116 | 117 | Source Files\Sound Driver 118 | 119 | 120 | Source Files 121 | 122 | 123 | Source Files 124 | 125 | 126 | Source Files\HLE 127 | 128 | 129 | Source Files\HLE 130 | 131 | 132 | Source Files\HLE 133 | 134 | 135 | Source Files\HLE 136 | 137 | 138 | Source Files\HLE 139 | 140 | 141 | Mupen64Plus HLE 142 | 143 | 144 | Mupen64Plus HLE 145 | 146 | 147 | Mupen64Plus HLE 148 | 149 | 150 | Mupen64Plus HLE 151 | 152 | 153 | Source Files\HLE 154 | 155 | 156 | Source Files\HLE 157 | 158 | 159 | Source Files\HLE 160 | 161 | 162 | Source Files\HLE 163 | 164 | 165 | Source Files\HLE 166 | 167 | 168 | Source Files\HLE 169 | 170 | 171 | Source Files\Sound Driver 172 | 173 | 174 | Source Files\Sound Driver 175 | 176 | 177 | Source Files\Sound Driver 178 | 179 | 180 | Source Files\Sound Driver 181 | 182 | 183 | Source Files 184 | 185 | 186 | Source Files\Sound Driver 187 | 188 | 189 | Source Files\Sound Driver 190 | 191 | 192 | Source Files\Sound Driver 193 | 194 | 195 | Source Files\Sound Driver 196 | 197 | 198 | Source Files\Sound Driver 199 | 200 | 201 | 202 | 203 | Resource Files 204 | 205 | 206 | 207 | 208 | Resource Files 209 | 210 | 211 | --------------------------------------------------------------------------------