├── .gitattributes ├── .gitignore ├── 3rd Party ├── directx │ ├── include │ │ ├── audiodefs.h │ │ ├── comdecl.h │ │ ├── dsound.h │ │ ├── xaudio2.h │ │ └── xma2defs.h │ └── lib │ │ ├── x64 │ │ └── dsound.lib │ │ └── x86 │ │ └── dsound.lib └── sal.h ├── AziAudio.Xbx.sln ├── AziAudio.vs2008.sln ├── AziAudio.vs2013.sln ├── AziAudio ├── ABI1.cpp ├── ABI2.cpp ├── ABI3.cpp ├── ABI3mp3.cpp ├── ABI_Adpcm.cpp ├── ABI_Buffers.cpp ├── ABI_Envmixer.cpp ├── ABI_Filters.cpp ├── ABI_MixerInterleave.cpp ├── ABI_Resample.cpp ├── AudioSpec.h ├── AziAudio.vcproj ├── AziAudio.vcxproj ├── AziAudio.vcxproj.filters ├── AziAudio.xbx.vcproj ├── DirectSoundDriver.cpp ├── DirectSoundDriver.h ├── HLEMain.cpp ├── Mupen64plusHLE │ ├── Mupen64Support.c │ ├── alist.h │ ├── arithmetics.h │ ├── audio.c │ ├── audio.h │ ├── common.h │ ├── hle.h │ ├── hle_external.h │ ├── hle_internal.h │ ├── memory.c │ ├── memory.h │ ├── musyx.c │ └── ucodes.h ├── NoSoundDriver.cpp ├── NoSoundDriver.h ├── SoundDriver.cpp ├── SoundDriver.h ├── WaveOut.cpp ├── WaveOut.h ├── XAudio2SoundDriver.cpp ├── XAudio2SoundDriver.h ├── XBox │ ├── xbox_depp.cpp │ └── xbox_depp.h ├── audiohle.h ├── common.h ├── main.cpp ├── my_types.h ├── readme.txt ├── resource.h └── resource.rc ├── LICENSE ├── Makefile ├── PropertySheets ├── Debug.props ├── Debug.vsprops ├── Default.vsprops ├── Release.props ├── Release.vsprops ├── Win32.Debug.props ├── Win32.Debug.vsprops ├── Win32.Release.props ├── Win32.Release.vsprops ├── Win32.props ├── Win32.vsprops └── root.vsprops ├── README.md ├── make_wdk.cmd └── mingw-build.cmd /.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | # User-specific files 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | # User-specific files (MonoDevelop/Xamarin Studio) 9 | *.userprefs 10 | # Build results 11 | [Dd]ebug/ 12 | [Dd]ebugPublic/ 13 | [Rr]elease/ 14 | [Rr]eleases/ 15 | /x64/ 16 | /x86/ 17 | build/ 18 | bld/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | # Visual Studo 2015 cache/options directory 22 | .vs/ 23 | # MSTest test Results 24 | [Tt]est[Rr]esult*/ 25 | [Bb]uild[Ll]og.* 26 | # NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | # Build Results of an ATL Project 30 | [Dd]ebugPS/ 31 | [Rr]eleasePS/ 32 | dlldata.c 33 | *_i.c 34 | *_p.c 35 | *_i.h 36 | *.ilk 37 | *.meta 38 | *.obj 39 | *.pch 40 | *.pdb 41 | *.pgc 42 | *.pgd 43 | *.rsp 44 | *.sbr 45 | *.tlb 46 | *.tli 47 | *.tlh 48 | *.tmp 49 | *.tmp_proj 50 | *.log 51 | *.vspscc 52 | *.vssscc 53 | .builds 54 | *.pidb 55 | *.svclog 56 | *.scc 57 | # Chutzpah Test files 58 | _Chutzpah* 59 | # Visual C++ cache files 60 | ipch/ 61 | *.aps 62 | *.ncb 63 | *.opensdf 64 | *.sdf 65 | *.cachefile 66 | # Visual Studio profiler 67 | *.psess 68 | *.vsp 69 | *.vspx 70 | # TFS 2012 Local Workspace 71 | $tf/ 72 | # Guidance Automation Toolkit 73 | *.gpState 74 | # ReSharper is a .NET coding add-in 75 | _ReSharper*/ 76 | *.[Rr]e[Ss]harper 77 | *.DotSettings.user 78 | # JustCode is a .NET coding addin-in 79 | .JustCode 80 | # TeamCity is a build add-in 81 | _TeamCity* 82 | # DotCover is a Code Coverage Tool 83 | *.dotCover 84 | # NCrunch 85 | _NCrunch_* 86 | .*crunch*.local.xml 87 | # MightyMoose 88 | *.mm.* 89 | AutoTest.Net/ 90 | # Web workbench (sass) 91 | .sass-cache/ 92 | # Installshield output folder 93 | [Ee]xpress/ 94 | # DocProject is a documentation generator add-in 95 | DocProject/buildhelp/ 96 | DocProject/Help/*.HxT 97 | DocProject/Help/*.HxC 98 | DocProject/Help/*.hhc 99 | DocProject/Help/*.hhk 100 | DocProject/Help/*.hhp 101 | DocProject/Help/Html2 102 | DocProject/Help/html 103 | # Click-Once directory 104 | publish/ 105 | # Publish Web Output 106 | *.[Pp]ublish.xml 107 | *.azurePubxml 108 | # TODO: Comment the next line if you want to checkin your web deploy settings 109 | # but database connection strings (with potential passwords) will be unencrypted 110 | *.pubxml 111 | *.publishproj 112 | # NuGet Packages 113 | *.nupkg 114 | # The packages folder can be ignored because of Package Restore 115 | **/packages/* 116 | # except build/, which is used as an MSBuild target. 117 | !**/packages/build/ 118 | # Uncomment if necessary however generally it will be regenerated when needed 119 | #!**/packages/repositories.config 120 | # Windows Azure Build Output 121 | csx/ 122 | *.build.csdef 123 | # Windows Store app package directory 124 | AppPackages/ 125 | # Others 126 | *.[Cc]ache 127 | ClientBin/ 128 | [Ss]tyle[Cc]op.* 129 | ~$* 130 | *~ 131 | *.dbmdl 132 | *.dbproj.schemaview 133 | *.pfx 134 | *.publishsettings 135 | node_modules/ 136 | bower_components/ 137 | # RIA/Silverlight projects 138 | Generated_Code/ 139 | # Backup & report files from converting an old project file 140 | # to a newer Visual Studio version. Backup files are not needed, 141 | # because we have git ;-) 142 | _UpgradeReport_Files/ 143 | Backup*/ 144 | UpgradeLog*.XML 145 | UpgradeLog*.htm 146 | # SQL Server files 147 | *.mdf 148 | *.ldf 149 | # Business Intelligence projects 150 | *.rdl.data 151 | *.bim.layout 152 | *.bim_*.settings 153 | # Microsoft Fakes 154 | FakesAssemblies/ 155 | # Node.js Tools for Visual Studio 156 | .ntvs_analysis.dat 157 | # Visual Studio 6 build log 158 | *.plg 159 | # Visual Studio 6 workspace options file 160 | *.opt 161 | *.tlog 162 | AziAudio/Todo.txt -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /3rd Party/directx/lib/x64/dsound.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project64/AziAudio/6d736fa75eaa78383099f3d49dbbb85b106f0b13/3rd Party/directx/lib/x64/dsound.lib -------------------------------------------------------------------------------- /3rd Party/directx/lib/x86/dsound.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project64/AziAudio/6d736fa75eaa78383099f3d49dbbb85b106f0b13/3rd Party/directx/lib/x86/dsound.lib -------------------------------------------------------------------------------- /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.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.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.vs2013.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AziAudio", "AziAudio\AziAudio.vcxproj", "{835979AC-BC6A-45B7-A513-8EEE79B443DE}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|Win32.Build.0 = Debug|Win32 18 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|x64.ActiveCfg = Debug|x64 19 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Debug|x64.Build.0 = Debug|x64 20 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.ActiveCfg = Release|Win32 21 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|Win32.Build.0 = Release|Win32 22 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|x64.ActiveCfg = Release|x64 23 | {835979AC-BC6A-45B7-A513-8EEE79B443DE}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /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-2015 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/ABI2.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2015 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 | p_func ABI2[NUM_ABI_COMMANDS] = { 36 | SPNOOP , ADPCM2, CLEARBUFF2, SPNOOP, SPNOOP, RESAMPLE2 , SPNOOP , SEGMENT2, 37 | SETBUFF2 , DUPLICATE2, DMEMMOVE2, LOADADPCM2, MIXER2, INTERLEAVE2, SPNOOP, SETLOOP2, 38 | SPNOOP, INTERL2 , ENVSETUP1, ENVMIXER2, LOADBUFF2, SAVEBUFF2, ENVSETUP2, SPNOOP, 39 | SPNOOP , SPNOOP, SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP , SPNOOP 40 | }; 41 | /* NOTES: 42 | 43 | FILTER/SEGMENT - Still needs to be finished up... add FILTER? 44 | UNKNOWWN #27 - Is this worth doing? Looks like a pain in the ass just for WaveRace64 45 | */ 46 | -------------------------------------------------------------------------------- /AziAudio/ABI3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project64/AziAudio/6d736fa75eaa78383099f3d49dbbb85b106f0b13/AziAudio/ABI3.cpp -------------------------------------------------------------------------------- /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-2015 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 CLEARBUFF() { 15 | u32 addr = (u32)(k0 & 0xffff); 16 | u32 count = (u32)(t9 & 0xffff); 17 | addr &= 0xFFFC; 18 | memset(BufferSpace + addr, 0, (count + 3) & 0xFFFC); 19 | } 20 | 21 | void CLEARBUFF2() { 22 | u16 addr = (u16)(k0 & 0xffff); 23 | u16 count = (u16)(t9 & 0xffff); 24 | if (count > 0) 25 | memset(BufferSpace + addr, 0, count); 26 | } 27 | 28 | void CLEARBUFF3() { 29 | u16 addr = (u16)(k0 & 0xffff); 30 | u16 count = (u16)(t9 & 0xffff); 31 | memset(BufferSpace + addr + 0x4f0, 0, count); 32 | } 33 | 34 | void DMEMMOVE() { 35 | u32 v0, v1; 36 | u32 cnt; 37 | if ((t9 & 0xffff) == 0) 38 | return; 39 | v0 = (k0 & 0xFFFF); 40 | v1 = (t9 >> 0x10); 41 | 42 | u32 count = ((t9 + 3) & 0xfffc); 43 | 44 | for (cnt = 0; cnt < count; cnt += 4) { 45 | BufferSpace[BES(v1 + cnt + 0)] = BufferSpace[BES(v0 + cnt + 0)]; 46 | BufferSpace[BES(v1 + cnt + 1)] = BufferSpace[BES(v0 + cnt + 1)]; 47 | BufferSpace[BES(v1 + cnt + 2)] = BufferSpace[BES(v0 + cnt + 2)]; 48 | BufferSpace[BES(v1 + cnt + 3)] = BufferSpace[BES(v0 + cnt + 3)]; 49 | } 50 | } 51 | 52 | void DMEMMOVE2() { // Needs accuracy verification... 53 | u32 v0, v1; 54 | u32 cnt; 55 | if ((t9 & 0xffff) == 0) 56 | return; 57 | v0 = (k0 & 0xFFFF); 58 | v1 = (t9 >> 0x10); 59 | //assert ((v1 & 0x3) == 0); 60 | //assert ((v0 & 0x3) == 0); 61 | u32 count = ((t9 + 3) & 0xfffc); 62 | //v0 = (v0) & 0xfffc; 63 | //v1 = (v1) & 0xfffc; 64 | 65 | //memcpy (dmem+v1, dmem+v0, count-1); 66 | for (cnt = 0; cnt < count; cnt += 4) { 67 | BufferSpace[BES(v1 + cnt + 0)] = BufferSpace[BES(v0 + cnt + 0)]; 68 | BufferSpace[BES(v1 + cnt + 1)] = BufferSpace[BES(v0 + cnt + 1)]; 69 | BufferSpace[BES(v1 + cnt + 2)] = BufferSpace[BES(v0 + cnt + 2)]; 70 | BufferSpace[BES(v1 + cnt + 3)] = BufferSpace[BES(v0 + cnt + 3)]; 71 | } 72 | } 73 | 74 | void DMEMMOVE3() { // Needs accuracy verification... 75 | u32 v0, v1; 76 | u32 cnt; 77 | v0 = (k0 & 0xFFFF) + 0x4f0; 78 | v1 = (t9 >> 0x10) + 0x4f0; 79 | u32 count = ((t9 + 3) & 0xfffc); 80 | 81 | //memcpy (dmem+v1, dmem+v0, count-1); 82 | for (cnt = 0; cnt < count; cnt += 4) { 83 | BufferSpace[BES(v1 + cnt + 0)] = BufferSpace[BES(v0 + cnt + 0)]; 84 | BufferSpace[BES(v1 + cnt + 1)] = BufferSpace[BES(v0 + cnt + 1)]; 85 | BufferSpace[BES(v1 + cnt + 2)] = BufferSpace[BES(v0 + cnt + 2)]; 86 | BufferSpace[BES(v1 + cnt + 3)] = BufferSpace[BES(v0 + cnt + 3)]; 87 | } 88 | } 89 | 90 | void DUPLICATE2() { 91 | WORD Count = (k0 >> 16) & 0xff; 92 | WORD In = k0 & 0xffff; 93 | WORD Out = (t9 >> 16); 94 | 95 | WORD buff[64]; 96 | 97 | memcpy(buff, BufferSpace + In, 128); 98 | 99 | while (Count) { 100 | memcpy(BufferSpace + Out, buff, 128); 101 | Out += 128; 102 | Count--; 103 | } 104 | } 105 | 106 | // TODO: This comment has me wondering if there's a problem. 10+ year old comments are hard to remember. -Azimer 107 | void LOADBUFF() { // memcpy causes static... endianess issue :( 108 | u32 v0; 109 | if (AudioCount == 0) 110 | return; 111 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 112 | memcpy(BufferSpace + (AudioInBuffer & 0xFFFC), DRAM + v0, (AudioCount + 3) & 0xFFFC); 113 | } 114 | 115 | void LOADBUFF2() { // Needs accuracy verification... 116 | u32 v0; 117 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 118 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 119 | memcpy(BufferSpace + (k0 & 0xfffc), DRAM + v0, (cnt + 3) & 0xFFFC); 120 | } 121 | 122 | void LOADBUFF3() { 123 | u32 v0; 124 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 125 | v0 = (t9 & 0xfffffc); 126 | u32 src = (k0 & 0xffc) + 0x4f0; 127 | memcpy(BufferSpace + src, DRAM + v0, cnt); 128 | } 129 | 130 | // TODO: This comment has me wondering if there's a problem. 10+ year old comments are hard to remember. -Azimer 131 | void SAVEBUFF() { // memcpy causes static... endianess issue :( 132 | u32 v0; 133 | if (AudioCount == 0) 134 | return; 135 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 136 | memcpy(DRAM + v0, BufferSpace + (AudioOutBuffer & 0xFFFC), (AudioCount + 3) & 0xFFFC); 137 | } 138 | 139 | void SAVEBUFF2() { // Needs accuracy verification... 140 | u32 v0; 141 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 142 | v0 = (t9 & 0xfffffc);// + SEGMENTS[(t9>>24)&0xf]; 143 | memcpy(DRAM + v0, BufferSpace + (k0 & 0xfffc), (cnt + 3) & 0xFFFC); 144 | } 145 | 146 | void SAVEBUFF3() { 147 | u32 v0; 148 | u32 cnt = (((k0 >> 0xC) + 3) & 0xFFC); 149 | v0 = (t9 & 0xfffffc); 150 | u32 src = (k0 & 0xffc) + 0x4f0; 151 | memcpy(DRAM + v0, BufferSpace + src, cnt); 152 | } 153 | 154 | void SEGMENT() { // Should work 155 | SEGMENTS[(t9 >> 24) & 0xf] = (t9 & 0xffffff); 156 | } 157 | 158 | void SEGMENT2() { 159 | if (isZeldaABI) { 160 | FILTER2(); 161 | return; 162 | } 163 | if ((k0 & 0xffffff) == 0) { 164 | isMKABI = true; 165 | //SEGMENTS[(t9>>24)&0xf] = (t9 & 0xffffff); 166 | } 167 | else { 168 | isMKABI = false; 169 | isZeldaABI = true; 170 | FILTER2(); 171 | } 172 | } 173 | 174 | void SETBUFF() { // Should work ;-) 175 | if ((k0 >> 0x10) & 0x8) { // A_AUX - Auxillary Sound Buffer Settings 176 | AudioAuxA = (u16)(k0 & 0xFFFF); 177 | AudioAuxC = (u16)((t9 >> 0x10)); 178 | AudioAuxE = (u16)(t9 & 0xFFFF); 179 | } 180 | else { // A_MAIN - Main Sound Buffer Settings 181 | AudioInBuffer = (u16)(k0 & 0xFFFF); // 0x00 182 | AudioOutBuffer = (u16)((t9 >> 0x10)); // 0x02 183 | AudioCount = (u16)(t9 & 0xFFFF); // 0x04 184 | } 185 | } 186 | 187 | void SETBUFF2() { 188 | AudioInBuffer = (u16)(k0 & 0xFFFF); // 0x00 189 | AudioOutBuffer = (u16)(t9 >> 0x10); // 0x02 190 | AudioCount = (u16)(t9 & 0xFFFF); // 0x04 191 | } 192 | 193 | void SETLOOP() { 194 | loopval = (t9 & 0xffffff);// + SEGMENTS[(t9>>24)&0xf]; 195 | //VolTrg_Left = (s16)(loopval>>16); // m_LeftVol 196 | //VolRamp_Left = (s16)(loopval); // m_LeftVolTarget 197 | } 198 | 199 | void SETLOOP2() { 200 | loopval = t9 & 0xffffff; // No segment? 201 | } 202 | 203 | void SETLOOP3() { 204 | loopval = (t9 & 0xffffff); 205 | } 206 | -------------------------------------------------------------------------------- /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-2015 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 | WORD Out = t9 & 0xffff; 77 | WORD 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/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-2015 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, DWORD 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 >> 15); 57 | } 58 | 59 | return accum; 60 | } 61 | 62 | void RESAMPLE() { 63 | BYTE Flags = (u8)((k0 >> 16) & 0xff); 64 | DWORD Pitch = ((k0 & 0xffff)) << 1; 65 | u32 addy = (t9 & 0xffffff);// + SEGMENTS[(t9>>24)&0xf]; 66 | DWORD Accum = 0; 67 | DWORD 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 | BYTE Flags = (u8)((k0 >> 16) & 0xff); 125 | DWORD Pitch = ((k0 & 0xffff)) << 1; 126 | u32 addy = (t9 & 0xffffff);// + SEGMENTS[(t9>>24)&0xf]; 127 | DWORD Accum = 0; 128 | DWORD 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 | BYTE Flags = (u8)((t9 >> 0x1e)); 171 | DWORD Pitch = ((t9 >> 0xe) & 0xffff) << 1; 172 | u32 addy = (k0 & 0xffffff); 173 | DWORD Accum = 0; 174 | DWORD 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/AudioSpec.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************** 2 | Common Audio plugin spec, version #1.1 maintained by zilmar (zilmar@emulation64.com) 3 | 4 | All questions or suggestions should go through the mailing list. 5 | http://www.egroups.com/group/Plugin64-Dev 6 | ********************************************************************************** 7 | Notes: 8 | ------ 9 | 10 | Setting the appropriate bits in the MI_INTR_REG and calling CheckInterrupts which 11 | are both passed to the DLL in InitiateAudio will generate an Interrupt from with in 12 | the plugin. 13 | 14 | **********************************************************************************/ 15 | #ifndef _AUDIO_H_INCLUDED__ 16 | #define _AUDIO_H_INCLUDED__ 17 | 18 | #include "common.h" 19 | #include "my_types.h" 20 | //#include "Audio #1.1EXT.h" 21 | 22 | #if defined(__cplusplus) 23 | extern "C" { 24 | #endif 25 | 26 | /* Note: BOOL, BYTE, WORD, DWORD, TRUE, FALSE are defined in windows.h */ 27 | 28 | #define PLUGIN_TYPE_AUDIO 3 29 | 30 | #define SYSTEM_NTSC 0 31 | #define SYSTEM_PAL 1 32 | #define SYSTEM_MPAL 2 33 | 34 | /***** Structures *****/ 35 | 36 | 37 | typedef struct { 38 | WORD Version; /* Should be set to 0x0101 */ 39 | WORD Type; /* Set to PLUGIN_TYPE_AUDIO */ 40 | char Name[100]; /* Name of the DLL */ 41 | 42 | /* If DLL supports memory these memory options then set them to TRUE or FALSE 43 | if it does not support it */ 44 | BOOL NormalMemory; /* a normal BYTE array */ 45 | BOOL MemoryBswaped; /* a normal BYTE array where the memory has been pre 46 | bswap on a dword (32 bits) boundary */ 47 | } PLUGIN_INFO; 48 | 49 | 50 | typedef struct { 51 | HWND hwnd; 52 | HINSTANCE hinst; 53 | 54 | BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre 55 | // bswap on a dword (32 bits) boundary 56 | // eg. the first 8 bytes are stored like this: 57 | // 4 3 2 1 8 7 6 5 58 | BYTE * HEADER; // This is the rom header (first 40h bytes of the rom 59 | // This will be in the same memory format as the rest of the memory. 60 | BYTE * RDRAM; 61 | BYTE * DMEM; 62 | BYTE * IMEM; 63 | 64 | DWORD * MI_INTR_REG; 65 | 66 | DWORD * AI_DRAM_ADDR_REG; 67 | DWORD * AI_LEN_REG; 68 | DWORD * AI_CONTROL_REG; 69 | DWORD * AI_STATUS_REG; 70 | DWORD * AI_DACRATE_REG; 71 | DWORD * AI_BITRATE_REG; 72 | 73 | void (*CheckInterrupts)( void ); 74 | } AUDIO_INFO; 75 | 76 | /****************************************************************** 77 | Function: AiDacrateChanged 78 | Purpose: This function is called to notify the dll that the 79 | AiDacrate registers value has been changed. 80 | input: The System type: 81 | SYSTEM_NTSC 0 82 | SYSTEM_PAL 1 83 | SYSTEM_MPAL 2 84 | output: none 85 | *******************************************************************/ 86 | EXPORT void CALL AiDacrateChanged(int SystemType); 87 | 88 | /****************************************************************** 89 | Function: AiLenChanged 90 | Purpose: This function is called to notify the dll that the 91 | AiLen registers value has been changed. 92 | input: none 93 | output: none 94 | *******************************************************************/ 95 | EXPORT void CALL AiLenChanged(void); 96 | 97 | /****************************************************************** 98 | Function: AiReadLength 99 | Purpose: This function is called to allow the dll to return the 100 | value that AI_LEN_REG should equal 101 | input: none 102 | output: The amount of bytes still left to play. 103 | *******************************************************************/ 104 | EXPORT DWORD CALL AiReadLength(void); 105 | 106 | /****************************************************************** 107 | Function: AiUpdate 108 | Purpose: This function is called to allow the dll to update 109 | things on a regular basis (check how long to sound to 110 | go, copy more stuff to the buffer, anything you like). 111 | The function is designed to go in to the message loop 112 | of the main window ... but can be placed anywhere you 113 | like. 114 | input: if Wait is set to true, then this function should wait 115 | till there is a message in the its message queue. 116 | output: none 117 | *******************************************************************/ 118 | EXPORT void CALL AiUpdate(BOOL Wait); 119 | 120 | /****************************************************************** 121 | Function: CloseDLL 122 | Purpose: This function is called when the emulator is closing 123 | down allowing the dll to de-initialise. 124 | input: none 125 | output: none 126 | *******************************************************************/ 127 | EXPORT void CALL CloseDLL(void); 128 | 129 | /****************************************************************** 130 | Function: DllAbout 131 | Purpose: This function is optional function that is provided 132 | to give further information about the DLL. 133 | input: a handle to the window that calls this function 134 | output: none 135 | *******************************************************************/ 136 | EXPORT void CALL DllAbout(HWND hParent); 137 | 138 | /****************************************************************** 139 | Function: DllConfig 140 | Purpose: This function is optional function that is provided 141 | to allow the user to configure the dll 142 | input: a handle to the window that calls this function 143 | output: none 144 | *******************************************************************/ 145 | EXPORT void CALL DllConfig(HWND hParent); 146 | 147 | /****************************************************************** 148 | Function: DllTest 149 | Purpose: This function is optional function that is provided 150 | to allow the user to test the dll 151 | input: a handle to the window that calls this function 152 | output: none 153 | *******************************************************************/ 154 | EXPORT void CALL DllTest(HWND hParent); 155 | 156 | /****************************************************************** 157 | Function: GetDllInfo 158 | Purpose: This function allows the emulator to gather information 159 | about the dll by filling in the PluginInfo structure. 160 | input: a pointer to a PLUGIN_INFO structure that needs to be 161 | filled by the function. (see def above) 162 | output: none 163 | *******************************************************************/ 164 | EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); 165 | 166 | /****************************************************************** 167 | Function: InitiateSound 168 | Purpose: This function is called when the DLL is started to give 169 | information from the emulator that the n64 audio 170 | interface needs 171 | Input: Audio_Info is passed to this function which is defined 172 | above. 173 | Output: TRUE on success 174 | FALSE on failure to initialise 175 | 176 | ** note on interrupts **: 177 | To generate an interrupt set the appropriate bit in MI_INTR_REG 178 | and then call the function CheckInterrupts to tell the emulator 179 | that there is a waiting interrupt. 180 | *******************************************************************/ 181 | EXPORT BOOL CALL InitiateAudio(AUDIO_INFO Audio_Info); 182 | 183 | /****************************************************************** 184 | Function: ProcessAList 185 | Purpose: This function is called when there is a Alist to be 186 | processed. The Dll will have to work out all the info 187 | about the AList itself. 188 | input: none 189 | output: none 190 | *******************************************************************/ 191 | EXPORT void CALL ProcessAList(void); 192 | 193 | /****************************************************************** 194 | Function: RomClosed 195 | Purpose: This function is called when a rom is closed. 196 | input: none 197 | output: none 198 | *******************************************************************/ 199 | EXPORT void CALL RomClosed(void); 200 | EXPORT void CALL RomOpen(void); 201 | EXPORT void CALL PluginLoaded(void); 202 | 203 | EXPORT void CALL AiCallBack(void); 204 | 205 | extern AUDIO_INFO AudioInfo; 206 | 207 | void HLEStart (); 208 | void ChangeABI (int type); // type 0 = SafeMode 209 | 210 | #define AI_STATUS_FIFO_FULL 0x80000000 /* Bit 31: full */ 211 | #define AI_STATUS_DMA_BUSY 0x40000000 /* Bit 30: busy */ 212 | #define MI_INTR_AI 0x04 /* Bit 2: AI intr */ 213 | #define AI_CONTROL_DMA_ON 0x01 214 | #define AI_CONTROL_DMA_OFF 0x00 215 | 216 | #if defined(__cplusplus) 217 | } 218 | #endif 219 | 220 | #endif 221 | -------------------------------------------------------------------------------- /AziAudio/AziAudio.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 23 | 26 | 29 | 32 | 35 | 38 | 43 | 46 | 49 | 52 | 58 | 61 | 64 | 67 | 70 | 73 | 76 | 79 | 80 | 85 | 88 | 91 | 94 | 97 | 100 | 105 | 108 | 111 | 114 | 119 | 122 | 125 | 128 | 131 | 134 | 137 | 140 | 141 | 142 | 143 | 144 | 145 | 150 | 153 | 154 | 157 | 158 | 161 | 162 | 165 | 166 | 169 | 170 | 173 | 174 | 177 | 180 | 181 | 184 | 185 | 188 | 189 | 192 | 193 | 196 | 197 | 200 | 201 | 204 | 205 | 208 | 209 | 212 | 213 | 216 | 217 | 220 | 221 | 224 | 227 | 228 | 231 | 232 | 235 | 236 | 239 | 240 | 241 | 242 | 243 | 248 | 251 | 252 | 255 | 256 | 259 | 260 | 263 | 264 | 267 | 268 | 271 | 272 | 275 | 276 | 279 | 280 | 283 | 284 | 287 | 288 | 291 | 294 | 295 | 298 | 299 | 302 | 303 | 306 | 307 | 310 | 311 | 314 | 315 | 318 | 319 | 322 | 323 | 326 | 327 | 330 | 331 | 332 | 333 | 338 | 341 | 342 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | -------------------------------------------------------------------------------- /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 | 25 | 26 | 27 | DynamicLibrary 28 | MultiByte 29 | v120_xp 30 | 31 | 32 | true 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | $(ProjectName)_d 43 | 44 | 45 | 46 | NotUsing 47 | $(SolutionDir)3rd Party\directx\include 48 | Full 49 | AnySuitable 50 | true 51 | Neither 52 | true 53 | 54 | 55 | $(SolutionDir)3rd Party\directx\lib\x86 56 | $(SolutionDir)3rd Party\directx\lib\x64 57 | dsound.lib;%(AdditionalDependencies) 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 | -------------------------------------------------------------------------------- /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 | 86 | 87 | Source Files\Sound Driver 88 | 89 | 90 | Source Files\Sound Driver 91 | 92 | 93 | Source Files 94 | 95 | 96 | Source Files 97 | 98 | 99 | Source Files\HLE 100 | 101 | 102 | Source Files\HLE 103 | 104 | 105 | Source Files\HLE 106 | 107 | 108 | Source Files\HLE 109 | 110 | 111 | Source Files\HLE 112 | 113 | 114 | Mupen64Plus HLE 115 | 116 | 117 | Mupen64Plus HLE 118 | 119 | 120 | Mupen64Plus HLE 121 | 122 | 123 | Mupen64Plus HLE 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 | Source Files\HLE 142 | 143 | 144 | Source Files\Sound Driver 145 | 146 | 147 | Source Files\Sound Driver 148 | 149 | 150 | 151 | 152 | Resource Files 153 | 154 | 155 | 156 | 157 | Resource Files 158 | 159 | 160 | -------------------------------------------------------------------------------- /AziAudio/AziAudio.xbx.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 33 | 35 | 38 | 40 | 42 | 44 | 45 | 51 | 67 | 69 | 72 | 74 | 76 | 78 | 79 | 85 | 102 | 104 | 107 | 109 | 111 | 113 | 114 | 120 | 137 | 139 | 142 | 144 | 146 | 148 | 149 | 156 | 172 | 174 | 177 | 179 | 181 | 183 | 184 | 185 | 186 | 187 | 188 | 192 | 194 | 195 | 197 | 198 | 200 | 201 | 203 | 204 | 206 | 207 | 210 | 212 | 213 | 215 | 216 | 218 | 219 | 221 | 222 | 224 | 225 | 227 | 228 | 230 | 231 | 233 | 234 | 236 | 237 | 239 | 240 | 241 | 244 | 246 | 247 | 249 | 250 | 252 | 253 | 255 | 256 | 259 | 261 | 262 | 264 | 265 | 267 | 268 | 270 | 271 | 273 | 274 | 276 | 277 | 279 | 280 | 282 | 283 | 285 | 286 | 287 | 288 | 289 | 293 | 295 | 296 | 298 | 299 | 301 | 302 | 304 | 305 | 307 | 308 | 310 | 311 | 313 | 314 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | -------------------------------------------------------------------------------- /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-2015 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) && !defined(_XBOX) 15 | #include 16 | #endif 17 | 18 | #include "common.h" 19 | #include 20 | #include "SoundDriver.h" 21 | 22 | static DWORD sLOCK_SIZE; 23 | 24 | #define DS_SEGMENTS 4 25 | #define LOCK_SIZE 0x800 26 | // 0x600 27 | //sLOCK_SIZE 28 | //0x700 29 | 30 | #define TOTAL_SIZE (LOCK_SIZE*DS_SEGMENTS) 31 | 32 | #define MAXBUFFER 27000 33 | //27000 34 | //(LOCK_SIZE*DS_SEGMENTS+LOCK_SIZE) 35 | // LOCKSIZE must not be fractional 36 | //#define LOCK_SIZE (ac->SegmentSize) 37 | 38 | #define BUFFSIZE (writeLoc-readLoc) 39 | 40 | class DirectSoundDriver : public SoundDriver { 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(DirectSoundDriver *ac); 62 | 63 | DirectSoundDriver() { lpdsbuf = NULL; lpds = NULL; audioIsDone = false; hMutex = NULL; handleAudioThread = NULL; audioIsPlaying = FALSE; readLoc = writeLoc = remainingBytes = 0; }; 64 | //DirectSoundDriver() {}; 65 | ~DirectSoundDriver() { }; 66 | 67 | // Setup and Teardown Functions 68 | BOOL Initialize(); 69 | void DeInitialize(); 70 | 71 | // Buffer Functions for the Audio Code 72 | void SetFrequency(DWORD Frequency); // Sets the Nintendo64 Game Audio Frequency 73 | DWORD AddBuffer(BYTE *start, DWORD 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 | DWORD GetReadStatus(); // Returns the status on the read pointer 83 | 84 | void SetVolume(DWORD volume); 85 | 86 | }; 87 | -------------------------------------------------------------------------------- /AziAudio/HLEMain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project64/AziAudio/6d736fa75eaa78383099f3d49dbbb85b106f0b13/AziAudio/HLEMain.cpp -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/Mupen64Support.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "common.h" 5 | 6 | #include "hle_external.h" 7 | #include "hle_internal.h" 8 | #include "../AudioSpec.h" 9 | 10 | void HleWarnMessage(void* user_defined, const char *message, ...) 11 | { 12 | va_list args; 13 | va_start(args, message); 14 | //DebugMessage(M64MSG_WARNING, message, args); 15 | va_end(args); 16 | 17 | if (user_defined == NULL) 18 | return; 19 | /* user_defined possibly as a HWND, FILE pointer, window ID, ... ? */ 20 | } 21 | 22 | 23 | void HleVerboseMessage(void* user_defined, const char *message, ...) 24 | { 25 | va_list args; 26 | va_start(args, message); 27 | //DebugMessage(M64MSG_VERBOSE, message, args); 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 | static struct hle_t _hle; 37 | 38 | void SetupMusyX() 39 | { 40 | struct hle_t *hle = &_hle; 41 | 42 | hle->dram = AudioInfo.RDRAM; 43 | hle->dmem = AudioInfo.DMEM; 44 | hle->imem = AudioInfo.IMEM; 45 | /*hle->mi_intr = NULL; 46 | hle->sp_mem_addr = NULL; 47 | hle->sp_dram_addr = NULL; 48 | hle->sp_rd_length = NULL; 49 | hle->sp_wr_length = NULL; 50 | hle->sp_status = NULL; 51 | hle->sp_dma_full = NULL; 52 | hle->sp_dma_busy = NULL; 53 | hle->sp_pc = NULL; 54 | hle->sp_semaphore = NULL; 55 | hle->dpc_start = NULL; 56 | hle->dpc_end = NULL; 57 | hle->dpc_current = NULL; 58 | hle->dpc_status = NULL; 59 | hle->dpc_clock = NULL; 60 | hle->dpc_bufbusy = NULL; 61 | hle->dpc_pipebusy = NULL; 62 | hle->dpc_tmem = NULL; 63 | hle->user_defined = NULL;*/ 64 | } 65 | 66 | void ProcessMusyX_v1() 67 | { 68 | SetupMusyX(); 69 | musyx_v1_task(&_hle); 70 | } 71 | 72 | void ProcessMusyX_v2() 73 | { 74 | SetupMusyX(); 75 | musyx_v2_task(&_hle); 76 | } 77 | -------------------------------------------------------------------------------- /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/arithmetics.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - arithmetics.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 ARITHMETICS_H 23 | #define ARITHMETICS_H 24 | 25 | #include "common.h" 26 | 27 | /* 28 | * 2015.05.05 modified by cxd4 29 | * The `INT16_MIN' macro is a dependency of this RSP HLE code. 30 | * In practice, there are two problems with this: 31 | * 1. can (rather, must) define `INT16_MIN' as -32767 instead 32 | * of the necessary -32768, as is irrelevant to RSP 33 | * hardware limitations and is really more about the host's CPU. 34 | * http://www.open-std.org/jtc1/sc22/wg14/www/docs/n761.htm 35 | * 2. Not everybody has a working , nor should they need to, 36 | * as its existence is based on the opinion that the C language 37 | * itself should arbitrate traditional-size types for the programmer. 38 | * As none of the types are scientifically essential to 39 | * valid CPU hardware, such C impl. requirements are for laziness. 40 | */ 41 | #if !defined(INT16_MIN) && !defined(INT16_MAX) 42 | #define INT16_MIN -32768 43 | #define INT16_MAX +32767 44 | #endif 45 | 46 | static inline int16_t clamp_s16(int32_t x) 47 | { 48 | x = (x < INT16_MIN) ? INT16_MIN: x; 49 | x = (x > INT16_MAX) ? INT16_MAX: x; 50 | 51 | return (int16_t)x; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/audio.c: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - audio.c * 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 | #include 23 | #include 24 | 25 | #define S16(hex) \ 26 | ((hex) & 0x8000u) \ 27 | ? -(signed)((~(hex##u) + 1) & 0x7FFFu) \ 28 | : +(hex) \ 29 | 30 | #include "arithmetics.h" 31 | const i16 RESAMPLE_LUT[64 * 4] = { 32 | 0x0c39, 0x66ad, 0x0d46, S16(0xffdf), 33 | 0x0b39, 0x6696, 0x0e5f, S16(0xffd8), 34 | 0x0a44, 0x6669, 0x0f83, S16(0xffd0), 35 | 0x095a, 0x6626, 0x10b4, S16(0xffc8), 36 | 0x087d, 0x65cd, 0x11f0, S16(0xffbf), 37 | 0x07ab, 0x655e, 0x1338, S16(0xffb6), 38 | 0x06e4, 0x64d9, 0x148c, S16(0xffac), 39 | 0x0628, 0x643f, 0x15eb, S16(0xffa1), 40 | 0x0577, 0x638f, 0x1756, S16(0xff96), 41 | 0x04d1, 0x62cb, 0x18cb, S16(0xff8a), 42 | 0x0435, 0x61f3, 0x1a4c, S16(0xff7e), 43 | 0x03a4, 0x6106, 0x1bd7, S16(0xff71), 44 | 0x031c, 0x6007, 0x1d6c, S16(0xff64), 45 | 0x029f, 0x5ef5, 0x1f0b, S16(0xff56), 46 | 0x022a, 0x5dd0, 0x20b3, S16(0xff48), 47 | 0x01be, 0x5c9a, 0x2264, S16(0xff3a), 48 | 0x015b, 0x5b53, 0x241e, S16(0xff2c), 49 | 0x0101, 0x59fc, 0x25e0, S16(0xff1e), 50 | 0x00ae, 0x5896, 0x27a9, S16(0xff10), 51 | 0x0063, 0x5720, 0x297a, S16(0xff02), 52 | 0x001f, 0x559d, 0x2b50, S16(0xfef4), 53 | S16(0xffe2), 0x540d, 0x2d2c, S16(0xfee8), 54 | S16(0xffac), 0x5270, 0x2f0d, S16(0xfedb), 55 | S16(0xff7c), 0x50c7, 0x30f3, S16(0xfed0), 56 | S16(0xff53), 0x4f14, 0x32dc, S16(0xfec6), 57 | S16(0xff2e), 0x4d57, 0x34c8, S16(0xfebd), 58 | S16(0xff0f), 0x4b91, 0x36b6, S16(0xfeb6), 59 | S16(0xfef5), 0x49c2, 0x38a5, S16(0xfeb0), 60 | S16(0xfedf), 0x47ed, 0x3a95, S16(0xfeac), 61 | S16(0xfece), 0x4611, 0x3c85, S16(0xfeab), 62 | S16(0xfec0), 0x4430, 0x3e74, S16(0xfeac), 63 | S16(0xfeb6), 0x424a, 0x4060, S16(0xfeaf), 64 | S16(0xfeaf), 0x4060, 0x424a, S16(0xfeb6), 65 | S16(0xfeac), 0x3e74, 0x4430, S16(0xfec0), 66 | S16(0xfeab), 0x3c85, 0x4611, S16(0xfece), 67 | S16(0xfeac), 0x3a95, 0x47ed, S16(0xfedf), 68 | S16(0xfeb0), 0x38a5, 0x49c2, S16(0xfef5), 69 | S16(0xfeb6), 0x36b6, 0x4b91, S16(0xff0f), 70 | S16(0xfebd), 0x34c8, 0x4d57, S16(0xff2e), 71 | S16(0xfec6), 0x32dc, 0x4f14, S16(0xff53), 72 | S16(0xfed0), 0x30f3, 0x50c7, S16(0xff7c), 73 | S16(0xfedb), 0x2f0d, 0x5270, S16(0xffac), 74 | S16(0xfee8), 0x2d2c, 0x540d, S16(0xffe2), 75 | S16(0xfef4), 0x2b50, 0x559d, 0x001f, 76 | S16(0xff02), 0x297a, 0x5720, 0x0063, 77 | S16(0xff10), 0x27a9, 0x5896, 0x00ae, 78 | S16(0xff1e), 0x25e0, 0x59fc, 0x0101, 79 | S16(0xff2c), 0x241e, 0x5b53, 0x015b, 80 | S16(0xff3a), 0x2264, 0x5c9a, 0x01be, 81 | S16(0xff48), 0x20b3, 0x5dd0, 0x022a, 82 | S16(0xff56), 0x1f0b, 0x5ef5, 0x029f, 83 | S16(0xff64), 0x1d6c, 0x6007, 0x031c, 84 | S16(0xff71), 0x1bd7, 0x6106, 0x03a4, 85 | S16(0xff7e), 0x1a4c, 0x61f3, 0x0435, 86 | S16(0xff8a), 0x18cb, 0x62cb, 0x04d1, 87 | S16(0xff96), 0x1756, 0x638f, 0x0577, 88 | S16(0xffa1), 0x15eb, 0x643f, 0x0628, 89 | S16(0xffac), 0x148c, 0x64d9, 0x06e4, 90 | S16(0xffb6), 0x1338, 0x655e, 0x07ab, 91 | S16(0xffbf), 0x11f0, 0x65cd, 0x087d, 92 | S16(0xffc8), 0x10b4, 0x6626, 0x095a, 93 | S16(0xffd0), 0x0f83, 0x6669, 0x0a44, 94 | S16(0xffd8), 0x0e5f, 0x6696, 0x0b39, 95 | S16(0xffdf), 0x0d46, 0x66ad, 0x0c39, 96 | }; 97 | 98 | int32_t rdot(size_t n, const int16_t *x, const int16_t *y) 99 | { 100 | int32_t accu = 0; 101 | 102 | y += n; 103 | 104 | while (n != 0) { 105 | accu += *(x++) * *(--y); 106 | --n; 107 | } 108 | 109 | return accu; 110 | } 111 | 112 | void adpcm_compute_residuals(int16_t* dst, const int16_t* src, 113 | const int16_t* cb_entry, const int16_t* last_samples, size_t count) 114 | { 115 | const int16_t* const book1 = cb_entry; 116 | const int16_t* const book2 = cb_entry + 8; 117 | 118 | const int16_t l1 = last_samples[0]; 119 | const int16_t l2 = last_samples[1]; 120 | 121 | size_t i; 122 | 123 | assert(count <= 8); 124 | 125 | for(i = 0; i < count; ++i) { 126 | int32_t accu = (int32_t)src[i] << 11; 127 | accu += book1[i]*l1 + book2[i]*l2 + rdot(i, book2, src); 128 | dst[i] = clamp_s16(accu >> 11); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/audio.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - audio.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 AUDIO_H 23 | #define AUDIO_H 24 | 25 | #include 26 | 27 | #include "common.h" 28 | 29 | extern const int16_t RESAMPLE_LUT[64 * 4]; 30 | 31 | int32_t rdot(size_t n, const int16_t *x, const int16_t *y); 32 | 33 | static inline int16_t adpcm_predict_sample(uint8_t byte, uint8_t mask, 34 | unsigned lshift, unsigned rshift) 35 | { 36 | int16_t sample = (uint16_t)(byte & mask) << lshift; 37 | sample >>= rshift; /* signed */ 38 | return sample; 39 | } 40 | 41 | void adpcm_compute_residuals(int16_t* dst, const int16_t* src, 42 | const int16_t* cb_entry, const int16_t* last_samples, size_t count); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/common.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - common.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 COMMON_H 23 | #define COMMON_H 24 | 25 | #include "../my_types.h" 26 | 27 | /* macro for unused variable warning suppression */ 28 | #ifdef __GNUC__ 29 | # define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) 30 | #else 31 | # define UNUSED(x) UNUSED_ ## x 32 | #endif 33 | 34 | /* macro for inline keyword */ 35 | #ifdef _MSC_VER 36 | #define inline __inline 37 | #endif 38 | 39 | /* 40 | * 2015.05.07 cxd4 41 | * 42 | * `bool' is not C programming, even if C99 granted the request. 43 | * Relevant C interpretation of Booleans is: zero and nonzero. 44 | * 45 | * Past that, issues like allocation, packing or padding with Booleans are 46 | * more than controllable in correct C with or without type definitions, 47 | * especially in modern optimizing compilers. The remaining issue is the 48 | * ability to say "true" and "false"--again external features irrelevant to 49 | * completeness of C implementation for the specific hardware architecture. 50 | */ 51 | #if !defined(FALSE) && !defined(TRUE) 52 | enum { 53 | FALSE = 0, 54 | TRUE = 1 55 | }; 56 | #endif 57 | typedef int Boolean; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/hle.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - hle.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 HLE_H 23 | #define HLE_H 24 | 25 | #include "hle_internal.h" 26 | 27 | void hle_init(struct hle_t* hle, 28 | unsigned char* dram, 29 | unsigned char* dmem, 30 | unsigned char* imem, 31 | unsigned int* mi_intr, 32 | unsigned int* sp_mem_addr, 33 | unsigned int* sp_dram_addr, 34 | unsigned int* sp_rd_length, 35 | unsigned int* sp_wr_length, 36 | unsigned int* sp_status, 37 | unsigned int* sp_dma_full, 38 | unsigned int* sp_dma_busy, 39 | unsigned int* sp_pc, 40 | unsigned int* sp_semaphore, 41 | unsigned int* dpc_start, 42 | unsigned int* dpc_end, 43 | unsigned int* dpc_current, 44 | unsigned int* dpc_status, 45 | unsigned int* dpc_clock, 46 | unsigned int* dpc_bufbusy, 47 | unsigned int* dpc_pipebusy, 48 | unsigned int* dpc_tmem, 49 | void* user_defined); 50 | 51 | void hle_execute(struct hle_t* hle); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/hle_external.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - hle_external.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 HLE_EXTERNAL_H 23 | #define HLE_EXTERNAL_H 24 | 25 | /* users of the hle core are expected to define these functions */ 26 | 27 | void HleVerboseMessage(void* user_defined, const char *message, ...); 28 | void HleErrorMessage(void* user_defined, const char *message, ...); 29 | void HleWarnMessage(void* user_defined, const char *message, ...); 30 | 31 | void HleCheckInterrupts(void* user_defined); 32 | void HleProcessDlistList(void* user_defined); 33 | void HleProcessAlistList(void* user_defined); 34 | void HleProcessRdpList(void* user_defined); 35 | void HleShowCFB(void* user_defined); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/hle_internal.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - hle_internal.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 HLE_INTERNAL_H 23 | #define HLE_INTERNAL_H 24 | 25 | #include "ucodes.h" 26 | 27 | /* rsp hle internal state - internal usage only */ 28 | struct hle_t 29 | { 30 | unsigned char* dram; 31 | unsigned char* dmem; 32 | unsigned char* imem; 33 | 34 | unsigned int* mi_intr; 35 | 36 | unsigned int* sp_mem_addr; 37 | unsigned int* sp_dram_addr; 38 | unsigned int* sp_rd_length; 39 | unsigned int* sp_wr_length; 40 | unsigned int* sp_status; 41 | unsigned int* sp_dma_full; 42 | unsigned int* sp_dma_busy; 43 | unsigned int* sp_pc; 44 | unsigned int* sp_semaphore; 45 | 46 | unsigned int* dpc_start; 47 | unsigned int* dpc_end; 48 | unsigned int* dpc_current; 49 | unsigned int* dpc_status; 50 | unsigned int* dpc_clock; 51 | unsigned int* dpc_bufbusy; 52 | unsigned int* dpc_pipebusy; 53 | unsigned int* dpc_tmem; 54 | 55 | /* for user convenience, this will be passed to "external" functions */ 56 | void* user_defined; 57 | 58 | 59 | /* alist.c */ 60 | uint8_t alist_buffer[0x1000]; 61 | 62 | /* alist_audio.c */ 63 | struct alist_audio_t alist_audio; 64 | 65 | /* alist_naudio.c */ 66 | struct alist_naudio_t alist_naudio; 67 | 68 | /* alist_nead.c */ 69 | struct alist_nead_t alist_nead; 70 | 71 | /* mp3.c */ 72 | uint8_t mp3_buffer[0x1000]; 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/memory.c: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - memory.c * 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 | #include 23 | 24 | #include "memory.h" 25 | 26 | /* Global functions */ 27 | void load_u8(uint8_t* dst, const unsigned char* buffer, unsigned address, size_t count) 28 | { 29 | while (count != 0) { 30 | *(dst++) = *pt_u8(buffer, address); 31 | address += 1; 32 | --count; 33 | } 34 | } 35 | 36 | void load_u16(uint16_t* dst, const unsigned char* buffer, unsigned address, size_t count) 37 | { 38 | while (count != 0) { 39 | *(dst++) = *pt_u16(buffer, address); 40 | address += 2; 41 | --count; 42 | } 43 | } 44 | 45 | void load_u32(uint32_t* dst, const unsigned char* buffer, unsigned address, size_t count) 46 | { 47 | /* Optimization for uint32_t */ 48 | memcpy(dst, pt_u32(buffer, address), count * sizeof(uint32_t)); 49 | } 50 | 51 | void store_u8(unsigned char* buffer, unsigned address, const uint8_t* src, size_t count) 52 | { 53 | while (count != 0) { 54 | *pt_u8(buffer, address) = *(src++); 55 | address += 1; 56 | --count; 57 | } 58 | } 59 | 60 | void store_u16(unsigned char* buffer, unsigned address, const uint16_t* src, size_t count) 61 | { 62 | while (count != 0) { 63 | *pt_u16(buffer, address) = *(src++); 64 | address += 2; 65 | --count; 66 | } 67 | } 68 | 69 | void store_u32(unsigned char* buffer, unsigned address, const uint32_t* src, size_t count) 70 | { 71 | /* Optimization for uint32_t */ 72 | memcpy(pt_u32(buffer, address), src, count * sizeof(uint32_t)); 73 | } 74 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/memory.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - memory.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 MEMORY_H 23 | #define MEMORY_H 24 | 25 | #include 26 | #include 27 | 28 | #include "common.h" 29 | #include "hle_internal.h" 30 | 31 | #ifdef M64P_BIG_ENDIAN 32 | #define S 0 33 | #define S16 0 34 | #define S8 0 35 | #else 36 | #define S 1 37 | #define S16 2 38 | #define S8 3 39 | #endif 40 | 41 | enum { 42 | TASK_TYPE = 0xfc0, 43 | TASK_FLAGS = 0xfc4, 44 | TASK_UCODE_BOOT = 0xfc8, 45 | TASK_UCODE_BOOT_SIZE = 0xfcc, 46 | TASK_UCODE = 0xfd0, 47 | TASK_UCODE_SIZE = 0xfd4, 48 | TASK_UCODE_DATA = 0xfd8, 49 | TASK_UCODE_DATA_SIZE = 0xfdc, 50 | TASK_DRAM_STACK = 0xfe0, 51 | TASK_DRAM_STACK_SIZE = 0xfe4, 52 | TASK_OUTPUT_BUFF = 0xfe8, 53 | TASK_OUTPUT_BUFF_SIZE = 0xfec, 54 | TASK_DATA_PTR = 0xff0, 55 | TASK_DATA_SIZE = 0xff4, 56 | TASK_YIELD_DATA_PTR = 0xff8, 57 | TASK_YIELD_DATA_SIZE = 0xffc 58 | }; 59 | 60 | static inline unsigned int align(unsigned int x, unsigned amount) 61 | { 62 | --amount; 63 | return (x + amount) & ~amount; 64 | } 65 | 66 | static inline uint8_t* pt_u8(const unsigned char* buffer, unsigned address) 67 | { 68 | return (uint8_t*)(buffer + (address ^ S8)); 69 | } 70 | 71 | static inline uint16_t* pt_u16(const unsigned char* buffer, unsigned address) 72 | { 73 | assert((address & 1) == 0); 74 | return (uint16_t*)(buffer + (address ^ S16)); 75 | } 76 | 77 | static inline uint32_t* pt_u32(const unsigned char* buffer, unsigned address) 78 | { 79 | assert((address & 3) == 0); 80 | return (uint32_t*)(buffer + address); 81 | } 82 | 83 | void load_u8 (uint8_t* dst, const unsigned char* buffer, unsigned address, size_t count); 84 | void load_u16(uint16_t* dst, const unsigned char* buffer, unsigned address, size_t count); 85 | void load_u32(uint32_t* dst, const unsigned char* buffer, unsigned address, size_t count); 86 | void store_u8 (unsigned char* buffer, unsigned address, const uint8_t* src, size_t count); 87 | void store_u16(unsigned char* buffer, unsigned address, const uint16_t* src, size_t count); 88 | void store_u32(unsigned char* buffer, unsigned address, const uint32_t* src, size_t count); 89 | 90 | 91 | /* convenient functions for DMEM access */ 92 | static inline uint8_t* dmem_u8(struct hle_t* hle, uint16_t address) 93 | { 94 | return pt_u8(hle->dmem, address & 0xfff); 95 | } 96 | 97 | static inline uint16_t* dmem_u16(struct hle_t* hle, uint16_t address) 98 | { 99 | return pt_u16(hle->dmem, address & 0xfff); 100 | } 101 | 102 | static inline uint32_t* dmem_u32(struct hle_t* hle, uint16_t address) 103 | { 104 | return pt_u32(hle->dmem, address & 0xfff); 105 | } 106 | 107 | static inline void dmem_load_u8(struct hle_t* hle, uint8_t* dst, uint16_t address, size_t count) 108 | { 109 | load_u8(dst, hle->dmem, address & 0xfff, count); 110 | } 111 | 112 | static inline void dmem_load_u16(struct hle_t* hle, uint16_t* dst, uint16_t address, size_t count) 113 | { 114 | load_u16(dst, hle->dmem, address & 0xfff, count); 115 | } 116 | 117 | static inline void dmem_load_u32(struct hle_t* hle, uint32_t* dst, uint16_t address, size_t count) 118 | { 119 | load_u32(dst, hle->dmem, address & 0xfff, count); 120 | } 121 | 122 | static inline void dmem_store_u8(struct hle_t* hle, const uint8_t* src, uint16_t address, size_t count) 123 | { 124 | store_u8(hle->dmem, address & 0xfff, src, count); 125 | } 126 | 127 | static inline void dmem_store_u16(struct hle_t* hle, const uint16_t* src, uint16_t address, size_t count) 128 | { 129 | store_u16(hle->dmem, address & 0xfff, src, count); 130 | } 131 | 132 | static inline void dmem_store_u32(struct hle_t* hle, const uint32_t* src, uint16_t address, size_t count) 133 | { 134 | store_u32(hle->dmem, address & 0xfff, src, count); 135 | } 136 | 137 | /* convenient functions DRAM access */ 138 | static inline uint8_t* dram_u8(struct hle_t* hle, uint32_t address) 139 | { 140 | return pt_u8(hle->dram, address & 0xffffff); 141 | } 142 | 143 | static inline uint16_t* dram_u16(struct hle_t* hle, uint32_t address) 144 | { 145 | return pt_u16(hle->dram, address & 0xffffff); 146 | } 147 | 148 | static inline uint32_t* dram_u32(struct hle_t* hle, uint32_t address) 149 | { 150 | return pt_u32(hle->dram, address & 0xffffff); 151 | } 152 | 153 | static inline void dram_load_u8(struct hle_t* hle, uint8_t* dst, uint32_t address, size_t count) 154 | { 155 | load_u8(dst, hle->dram, address & 0xffffff, count); 156 | } 157 | 158 | static inline void dram_load_u16(struct hle_t* hle, uint16_t* dst, uint32_t address, size_t count) 159 | { 160 | load_u16(dst, hle->dram, address & 0xffffff, count); 161 | } 162 | 163 | static inline void dram_load_u32(struct hle_t* hle, uint32_t* dst, uint32_t address, size_t count) 164 | { 165 | load_u32(dst, hle->dram, address & 0xffffff, count); 166 | } 167 | 168 | static inline void dram_store_u8(struct hle_t* hle, const uint8_t* src, uint32_t address, size_t count) 169 | { 170 | store_u8(hle->dram, address & 0xffffff, src, count); 171 | } 172 | 173 | static inline void dram_store_u16(struct hle_t* hle, const uint16_t* src, uint32_t address, size_t count) 174 | { 175 | store_u16(hle->dram, address & 0xffffff, src, count); 176 | } 177 | 178 | static inline void dram_store_u32(struct hle_t* hle, const uint32_t* src, uint32_t address, size_t count) 179 | { 180 | store_u32(hle->dram, address & 0xffffff, src, count); 181 | } 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /AziAudio/Mupen64plusHLE/ucodes.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Mupen64plus-rsp-hle - ucodes.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 UCODES_H 23 | #define UCODES_H 24 | 25 | struct hle_t; 26 | 27 | 28 | /* cic_x105 ucode */ 29 | void cicx105_ucode(struct hle_t* hle); 30 | 31 | 32 | /* audio list ucodes - audio */ 33 | enum { N_SEGMENTS = 16 }; 34 | struct alist_audio_t { 35 | /* segments */ 36 | uint32_t segments[N_SEGMENTS]; 37 | 38 | /* main buffers */ 39 | uint16_t in; 40 | uint16_t out; 41 | uint16_t count; 42 | 43 | /* auxiliary buffers */ 44 | uint16_t dry_right; 45 | uint16_t wet_left; 46 | uint16_t wet_right; 47 | 48 | /* gains */ 49 | int16_t dry; 50 | int16_t wet; 51 | 52 | /* envelopes (0:left, 1:right) */ 53 | int16_t vol[2]; 54 | int16_t target[2]; 55 | int32_t rate[2]; 56 | 57 | /* ADPCM loop point address */ 58 | uint32_t loop; 59 | 60 | /* storage for ADPCM table and polef coefficients */ 61 | int16_t table[16 * 8]; 62 | }; 63 | 64 | void alist_process_audio (struct hle_t* hle); 65 | void alist_process_audio_ge(struct hle_t* hle); 66 | void alist_process_audio_bc(struct hle_t* hle); 67 | 68 | 69 | /* audio list ucodes - naudio */ 70 | struct alist_naudio_t { 71 | /* gains */ 72 | int16_t dry; 73 | int16_t wet; 74 | 75 | /* envelopes (0:left, 1:right) */ 76 | int16_t vol[2]; 77 | int16_t target[2]; 78 | int32_t rate[2]; 79 | 80 | /* ADPCM loop point address */ 81 | uint32_t loop; 82 | 83 | /* storage for ADPCM table and polef coefficients */ 84 | int16_t table[16 * 8]; 85 | }; 86 | 87 | void alist_process_naudio (struct hle_t* hle); 88 | void alist_process_naudio_bk (struct hle_t* hle); 89 | void alist_process_naudio_dk (struct hle_t* hle); 90 | void alist_process_naudio_mp3 (struct hle_t* hle); 91 | void alist_process_naudio_cbfd(struct hle_t* hle); 92 | 93 | 94 | /* audio list ucodes - nead */ 95 | struct alist_nead_t { 96 | /* main buffers */ 97 | uint16_t in; 98 | uint16_t out; 99 | uint16_t count; 100 | 101 | /* envmixer ramps */ 102 | uint16_t env_values[3]; 103 | uint16_t env_steps[3]; 104 | 105 | /* ADPCM loop point address */ 106 | uint32_t loop; 107 | 108 | /* storage for ADPCM table and polef coefficients */ 109 | int16_t table[16 * 8]; 110 | 111 | /* filter audio command state */ 112 | uint16_t filter_count; 113 | uint32_t filter_lut_address[2]; 114 | }; 115 | 116 | void alist_process_nead_mk (struct hle_t* hle); 117 | void alist_process_nead_sfj (struct hle_t* hle); 118 | void alist_process_nead_sf (struct hle_t* hle); 119 | void alist_process_nead_fz (struct hle_t* hle); 120 | void alist_process_nead_wrjb(struct hle_t* hle); 121 | void alist_process_nead_ys (struct hle_t* hle); 122 | void alist_process_nead_1080(struct hle_t* hle); 123 | void alist_process_nead_oot (struct hle_t* hle); 124 | void alist_process_nead_mm (struct hle_t* hle); 125 | void alist_process_nead_mmb (struct hle_t* hle); 126 | void alist_process_nead_ac (struct hle_t* hle); 127 | 128 | 129 | /* mp3 ucode */ 130 | void mp3_task(struct hle_t* hle, unsigned int index, uint32_t address); 131 | 132 | 133 | /* musyx ucodes */ 134 | void musyx_v1_task(struct hle_t* hle); 135 | void musyx_v2_task(struct hle_t* hle); 136 | 137 | 138 | /* jpeg ucodes */ 139 | void jpeg_decode_PS0(struct hle_t* hle); 140 | void jpeg_decode_PS(struct hle_t* hle); 141 | void jpeg_decode_OB(struct hle_t* hle); 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /AziAudio/NoSoundDriver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | NoSound Driver to demonstrate how to use the SoundDriver interface 3 | */ 4 | 5 | #include "NoSoundDriver.h" 6 | 7 | BOOL NoSoundDriver::Initialize() 8 | { 9 | BOOL result; 10 | result = QueryPerformanceFrequency(&perfFreq); 11 | result = QueryPerformanceCounter(&perfLast) || result; 12 | dllInitialized = true; 13 | isPlaying = false; 14 | return result; 15 | } 16 | 17 | void NoSoundDriver::DeInitialize() 18 | { 19 | isPlaying = false; 20 | dllInitialized = false; 21 | } 22 | 23 | 24 | // Management functions 25 | void NoSoundDriver::AiUpdate(BOOL Wait) 26 | { 27 | LARGE_INTEGER sampleInterval; 28 | long samples; 29 | if (Wait == TRUE) Sleep(1); 30 | if (isPlaying == true && countsPerSample.QuadPart > 0) 31 | { 32 | QueryPerformanceCounter(&perfTimer); 33 | sampleInterval.QuadPart = perfTimer.QuadPart - perfLast.QuadPart; 34 | samples = (long)(sampleInterval.QuadPart / countsPerSample.QuadPart); 35 | if (samples > 0) 36 | { 37 | perfLast.QuadPart = perfTimer.QuadPart;// += countsPerSample.QuadPart * samples; 38 | LoadAiBuffer(NULL, samples * 4); // NULL means it won't actually try to fill a buffer 39 | } 40 | } 41 | } 42 | 43 | void NoSoundDriver::StopAudio() 44 | { 45 | isPlaying = false; 46 | } 47 | 48 | void NoSoundDriver::StartAudio() 49 | { 50 | QueryPerformanceCounter(&perfLast); 51 | isPlaying = true; 52 | } 53 | 54 | void NoSoundDriver::SetFrequency(DWORD Frequency) 55 | { 56 | int SamplesPerSecond = Frequency; // 16 bit * stereo 57 | 58 | // Must determine the number of Counter units per Sample 59 | QueryPerformanceFrequency(&perfFreq); // Counters per Second 60 | 61 | countsPerSample.QuadPart = perfFreq.QuadPart / SamplesPerSecond; 62 | QueryPerformanceCounter(&perfTimer); 63 | perfLast.QuadPart = perfTimer.QuadPart; 64 | } 65 | -------------------------------------------------------------------------------- /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-2015 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 | 20 | class NoSoundDriver : 21 | public SoundDriver 22 | { 23 | public: 24 | NoSoundDriver() {}; 25 | ~NoSoundDriver() {}; 26 | 27 | // Setup and Teardown Functions 28 | BOOL Initialize(); 29 | void DeInitialize(); 30 | 31 | // Management functions 32 | void AiUpdate(BOOL Wait); 33 | void StopAudio(); 34 | void StartAudio(); 35 | void SetFrequency(DWORD Frequency); 36 | 37 | protected: 38 | 39 | bool dllInitialized; 40 | LARGE_INTEGER perfTimer; 41 | LARGE_INTEGER perfFreq; 42 | LARGE_INTEGER perfLast; 43 | LARGE_INTEGER countsPerSample; 44 | 45 | bool isPlaying; 46 | }; -------------------------------------------------------------------------------- /AziAudio/SoundDriver.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2015 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include "SoundDriver.h" 13 | 14 | // Load the buffer from the AI interface to our emulated buffer 15 | void SoundDriver::AI_LenChanged(BYTE *start, DWORD length) 16 | { 17 | #ifdef LEGACY_SOUND_DRIVER 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 | #else 28 | int targetDMABuffer; 29 | int numFullBuffers = 0; 30 | 31 | WaitForSingleObject(m_hMutex, INFINITE); 32 | targetDMABuffer = m_AI_CurrentDMABuffer; // Target register 33 | if (m_AI_DMARemaining[targetDMABuffer] > 0) 34 | { 35 | targetDMABuffer = m_AI_CurrentDMABuffer ^ 1; // Set new target 36 | if (m_AI_DMARemaining[targetDMABuffer] > 0) 37 | { 38 | // FIFO is full. We either need to ditch this buffer or wait 39 | if (configSyncAudio == true) 40 | { 41 | ReleaseMutex(m_hMutex); 42 | while (m_AI_DMARemaining[targetDMABuffer] > 0) 43 | Sleep(1); 44 | WaitForSingleObject(m_hMutex, INFINITE); 45 | m_AI_DMABuffer[targetDMABuffer] = start; 46 | m_AI_DMARemaining[targetDMABuffer] = length; 47 | } 48 | numFullBuffers = 2; 49 | // TODO: How do we handle interrupts if we end up having to skip a buffer -- chances are if this occurs we 50 | // are using FAT and an overflow occurred. In that case we wouldn't need to handle the AI emulation in the 51 | // first place so we will skip it 52 | } 53 | else 54 | { 55 | // Fill last buffer 56 | m_AI_DMABuffer[targetDMABuffer] = start; 57 | m_AI_DMARemaining[targetDMABuffer] = length; 58 | numFullBuffers = 2; 59 | } 60 | } 61 | else 62 | { 63 | // Fill first buffer 64 | m_AI_DMABuffer[targetDMABuffer] = start; 65 | m_AI_DMARemaining[targetDMABuffer] = length; 66 | numFullBuffers = 1; 67 | } 68 | 69 | if (numFullBuffers > 0) *AudioInfo.AI_STATUS_REG |= AI_STATUS_DMA_BUSY; 70 | if (numFullBuffers > 1) *AudioInfo.AI_STATUS_REG |= AI_STATUS_FIFO_FULL; 71 | ReleaseMutex(m_hMutex); 72 | #endif 73 | } 74 | 75 | void SoundDriver::AI_SetFrequency(DWORD Frequency) 76 | { 77 | #ifdef LEGACY_SOUND_DRIVER 78 | if (m_audioIsInitialized == true) SetFrequency(Frequency); 79 | #else 80 | SetFrequency(Frequency); 81 | m_MaxBufferSize = ((Frequency * 4) / 10) & 0xFFFFFFF8; // 8 byte aligned 82 | #endif 83 | } 84 | 85 | DWORD SoundDriver::AI_ReadLength() 86 | { 87 | #ifdef LEGACY_SOUND_DRIVER 88 | if (m_audioIsInitialized == false) return 0; 89 | return GetReadStatus(); 90 | #else 91 | DWORD retVal; 92 | 93 | WaitForSingleObject(m_hMutex, INFINITE); 94 | retVal = m_AI_DMARemaining[m_AI_CurrentDMABuffer]; 95 | ReleaseMutex(m_hMutex); 96 | return retVal; 97 | #endif 98 | } 99 | 100 | void SoundDriver::AI_Startup() 101 | { 102 | #ifdef LEGACY_SOUND_DRIVER 103 | if (m_audioIsInitialized == true) DeInitialize(); 104 | m_audioIsInitialized = (!Initialize() == TRUE); 105 | if (m_audioIsInitialized == true) SetVolume(configVolume); 106 | #else 107 | Initialize(); 108 | m_AI_CurrentDMABuffer = 0; 109 | m_AI_DMARemaining[0] = m_AI_DMARemaining[1] = 0; 110 | m_MaxBufferSize = MAX_SIZE; 111 | m_CurrentReadLoc = m_CurrentWriteLoc = m_BufferRemaining = 0; 112 | m_DMAEnabled = false; 113 | if (m_hMutex == NULL) 114 | { 115 | m_hMutex = CreateMutex(NULL, FALSE, NULL); 116 | } 117 | StartAudio(); 118 | #endif 119 | } 120 | 121 | void SoundDriver::AI_Shutdown() 122 | { 123 | #ifdef LEGACY_SOUND_DRIVER 124 | if (m_audioIsInitialized == true) DeInitialize(); 125 | m_audioIsInitialized = false; 126 | //DeInitialize(); 127 | #else 128 | StopAudio(); 129 | DeInitialize(); 130 | if (m_hMutex != NULL) 131 | { 132 | CloseHandle(m_hMutex); 133 | m_hMutex = NULL; 134 | } 135 | #endif 136 | } 137 | 138 | void SoundDriver::AI_ResetAudio() 139 | { 140 | if (m_audioIsInitialized) DeInitialize(); 141 | m_audioIsInitialized = false; 142 | m_audioIsInitialized = (!Initialize() == TRUE); 143 | StartAudio(); 144 | } 145 | 146 | void SoundDriver::AI_Update(BOOL Wait) 147 | { 148 | AiUpdate(Wait); 149 | } 150 | 151 | // Copies data to the audio playback buffer 152 | DWORD SoundDriver::LoadAiBuffer(BYTE *start, DWORD length) 153 | { 154 | DWORD bytesToMove = length & 0xFFFFFFF8; 155 | #ifndef LEGACY_SOUND_DRIVER 156 | BYTE *ptrStart = start; 157 | BYTE nullBuff[MAX_SIZE]; 158 | if (start == NULL) 159 | ptrStart = nullBuff; 160 | 161 | assert((length & 0x3) == 0); // TODO: 4 or 8 byte alignment?? 162 | 163 | m_DMAEnabled = (*AudioInfo.AI_CONTROL_REG & AI_CONTROL_DMA_ON) == AI_CONTROL_DMA_ON; 164 | 165 | if (bytesToMove > MAX_SIZE) 166 | { 167 | memset(ptrStart, 0, 100); 168 | return length; 169 | } 170 | 171 | if (m_DMAEnabled == false) 172 | { 173 | memset(ptrStart, 0, length); 174 | return length; 175 | } 176 | 177 | // Deplete stored buffer first 178 | while (bytesToMove > 0 && m_BufferRemaining > 0) 179 | { 180 | *(u32 *)(ptrStart) = *(u32 *)(m_Buffer + m_CurrentReadLoc); 181 | m_CurrentReadLoc += 4; 182 | ptrStart += 4; 183 | if (m_CurrentReadLoc > m_MaxBufferSize) 184 | m_CurrentReadLoc = 0; 185 | m_BufferRemaining -= 4; 186 | bytesToMove -= 4; 187 | } 188 | 189 | WaitForSingleObject(m_hMutex, INFINITE); 190 | // Move any streamed audio samples 191 | while (bytesToMove > 0 && m_AI_DMARemaining[m_AI_CurrentDMABuffer] > 0) 192 | { 193 | *(u32 *)(ptrStart) = *(u32 *)(m_AI_DMABuffer[m_AI_CurrentDMABuffer]); 194 | m_AI_DMABuffer[m_AI_CurrentDMABuffer] += 4; 195 | ptrStart += 4; 196 | m_AI_DMARemaining[m_AI_CurrentDMABuffer] -= 4; 197 | bytesToMove -= 4; 198 | 199 | if (m_AI_DMARemaining[m_AI_CurrentDMABuffer] == 0) 200 | { 201 | m_AI_CurrentDMABuffer ^= 1; // Switch 202 | *AudioInfo.AI_STATUS_REG &= ~AI_STATUS_FIFO_FULL; 203 | if (m_AI_DMARemaining[m_AI_CurrentDMABuffer] == 0) *AudioInfo.AI_STATUS_REG &= ~AI_STATUS_DMA_BUSY; 204 | *AudioInfo.MI_INTR_REG |= MI_INTR_AI; 205 | AudioInfo.CheckInterrupts(); 206 | } 207 | } 208 | /* 209 | // Refill buffer 210 | while (m_BufferRemaining < m_MaxBufferSize && m_AI_DMARemaining[m_AI_CurrentDMABuffer] > 0) 211 | { 212 | *(u32 *)(m_Buffer + m_CurrentWriteLoc) = *(u32 *)(m_AI_DMABuffer[m_AI_CurrentDMABuffer]); 213 | m_CurrentWriteLoc += 4; 214 | m_AI_DMABuffer[m_AI_CurrentDMABuffer] += 4; 215 | m_AI_DMARemaining[m_AI_CurrentDMABuffer] -= 4; 216 | m_BufferRemaining += 4; 217 | 218 | if (m_AI_DMARemaining[m_AI_CurrentDMABuffer] == 0) 219 | { 220 | m_AI_CurrentDMABuffer ^= 1; // Switch 221 | *AudioInfo.AI_STATUS_REG &= ~AI_STATUS_FIFO_FULL; 222 | if (m_AI_DMARemaining[m_AI_CurrentDMABuffer] == 0) *AudioInfo.AI_STATUS_REG &= ~AI_STATUS_DMA_BUSY; 223 | *AudioInfo.MI_INTR_REG |= MI_INTR_AI; 224 | AudioInfo.CheckInterrupts(); 225 | } 226 | } 227 | */ 228 | ReleaseMutex(m_hMutex); 229 | 230 | if (bytesToMove > 0) 231 | { 232 | memset(ptrStart, 0, bytesToMove); 233 | bytesToMove = 0; 234 | } 235 | #else 236 | void *junk; 237 | junk = start; 238 | 239 | #endif 240 | return (length - bytesToMove); 241 | } 242 | -------------------------------------------------------------------------------- /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-2015 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 | #include "AudioSpec.h" 16 | 17 | #define SND_IS_NOT_EMPTY 0x4000000 18 | #define SND_IS_FULL 0x8000000 19 | #define LEGACY_SOUND_DRIVER 20 | 21 | class SoundDriver 22 | { 23 | public: 24 | // Configuration variables 25 | // TODO: these may need to go elsewhere 26 | bool configAIEmulation; 27 | bool configSyncAudio; 28 | bool configForceSync; 29 | bool configMute; 30 | bool configHLE; 31 | bool configRSP; 32 | unsigned long configVolume; 33 | char configAudioLogFolder[500]; 34 | char configDevice[100]; 35 | 36 | // Setup and Teardown Functions 37 | virtual BOOL Initialize() = 0; 38 | virtual void DeInitialize() = 0; 39 | 40 | // Management functions 41 | virtual void AiUpdate(BOOL Wait) { UNREFERENCED_PARAMETER(Wait); }; // Optional 42 | virtual void StopAudio() = 0; // Stops the Audio PlayBack (as if paused) 43 | virtual void StartAudio() = 0; // Starts the Audio PlayBack (as if unpaused) 44 | virtual void SetFrequency(DWORD Frequency) = 0; // Sets the Nintendo64 Game Audio Frequency 45 | 46 | // Deprecated 47 | #ifdef LEGACY_SOUND_DRIVER 48 | virtual DWORD GetReadStatus() = 0; // Returns the status on the read pointer 49 | virtual DWORD AddBuffer(BYTE *start, DWORD length) = 0; // Uploads a new buffer and returns status 50 | #endif 51 | 52 | // Audio Spec interface methods (new) 53 | void AI_SetFrequency(DWORD Frequency); 54 | void AI_LenChanged(BYTE *start, DWORD length); 55 | DWORD AI_ReadLength(); 56 | void AI_Startup(); 57 | void AI_Shutdown(); 58 | void AI_ResetAudio(); 59 | void AI_Update(BOOL Wait); 60 | 61 | // Buffer Management methods 62 | DWORD LoadAiBuffer(BYTE *start, DWORD length); // Reads in length amount of audio bytes 63 | 64 | // Sound Driver Factory method 65 | static SoundDriver* SoundDriverFactory(); 66 | 67 | virtual void SetVolume(DWORD volume) { UNREFERENCED_PARAMETER(volume); }; // We could potentially do this ourselves within the buffer copy method 68 | virtual ~SoundDriver() {}; 69 | 70 | protected: 71 | // Temporary (to allow for incremental development) 72 | bool m_audioIsInitialized; 73 | 74 | // Mutex Handle 75 | HANDLE m_hMutex; 76 | 77 | // Variables for AI DMA emulation 78 | int m_AI_CurrentDMABuffer; // Currently playing AI Buffer 79 | int m_AI_WriteDMABuffer; // Which set of registers will be written to 80 | BYTE *m_AI_DMABuffer[2]; // Location in RDRAM containing buffer data 81 | DWORD m_AI_DMARemaining[2]; // How much RDRAM buffer is left to read 82 | 83 | // Variables for Buffering audio samples from AI DMA 84 | static const int MAX_SIZE = 44100 * 2 * 2; // Max Buffer Size (44100Hz * 16bit * Stereo) 85 | static const int NUM_BUFFERS = 4; // Number of emulated buffers 86 | u32 m_MaxBufferSize; // Variable size determined by Playback rate 87 | u32 m_CurrentReadLoc; // Currently playing Buffer 88 | u32 m_CurrentWriteLoc; // Currently writing Buffer 89 | u8 m_Buffer[MAX_SIZE]; // Emulated buffers 90 | u32 m_BufferRemaining; // Buffer remaining 91 | bool m_DMAEnabled; // Sets to true when DMA is enabled 92 | 93 | SoundDriver(){ 94 | m_audioIsInitialized = false; 95 | configAIEmulation = true; 96 | configSyncAudio = true; 97 | configForceSync = false; 98 | configMute = false; 99 | configHLE = true; 100 | configRSP = true; 101 | configVolume = 0; 102 | m_hMutex = NULL; 103 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) && !defined(_XBOX) 104 | strcpy_s(configAudioLogFolder, 500, "D:\\"); 105 | strcpy_s(configDevice, 100, ""); 106 | #else 107 | strcpy(configAudioLogFolder, "D:\\"); 108 | strcpy(configDevice, ""); 109 | #endif 110 | } 111 | }; 112 | -------------------------------------------------------------------------------- /AziAudio/WaveOut.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2015 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #include 13 | #include 14 | #include "WaveOut.h" 15 | 16 | void WaveOut::BeginWaveOut(char *filename, WORD channels, WORD bitsPerSample, DWORD sampleRate) 17 | { 18 | if (waveoutput != NULL) return; 19 | // Clear header 20 | memset(&header, 0, sizeof(WaveHeader)); 21 | header.AudioFormat = 1; 22 | header.BitsPerSample = bitsPerSample; 23 | header.NumChannels = channels; 24 | header.SampleRate = sampleRate; 25 | header.BlockAlign = header.NumChannels * (header.BitsPerSample/8); 26 | header.ByteRate = header.SampleRate * header.BlockAlign; 27 | memcpy (header.ChunkID, "RIFF", 4); 28 | header.ChunkSize=0; // TODO at EndWaveOut 29 | memcpy (header.format, "WAVE", 4); 30 | memcpy (header.Subchunk1ID, "fmt ", 4); 31 | header.Subchunk1Size = 16; 32 | memcpy(header.Subchunk2ID,"data",4); 33 | header.Subchunk2Size=0; // TODO at EndWaveOut 34 | 35 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) 36 | fopen_s(&waveoutput, filename, "wb"); 37 | #else 38 | waveoutput = fopen(filename, "wb"); 39 | #endif 40 | fwrite(&header, sizeof(WaveHeader), 1, waveoutput); 41 | datasize = 0; 42 | } 43 | 44 | void WaveOut::WriteData (unsigned char*data, DWORD size) 45 | { 46 | if (waveoutput == NULL) return; 47 | datasize += size; 48 | fwrite(data, size, 1, waveoutput); 49 | } 50 | 51 | void WaveOut::EndWaveOut() 52 | { 53 | if (waveoutput == NULL) return; 54 | header.ChunkSize = ftell(waveoutput)-8; 55 | header.Subchunk2Size = datasize; 56 | fseek(waveoutput, 0, SEEK_SET); 57 | fwrite(&header, sizeof(WaveHeader), 1, waveoutput); 58 | fclose(waveoutput); 59 | waveoutput = NULL; 60 | } 61 | -------------------------------------------------------------------------------- /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-2015 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 | 15 | typedef struct 16 | { 17 | // RIFF Header 18 | char ChunkID[4]; // "RIFF" 19 | DWORD ChunkSize; // FileSize - 8 20 | char format[4]; // "WAVE" 21 | // fmt Header 22 | char Subchunk1ID[4]; // "fmt " 23 | DWORD Subchunk1Size; // 16 for PCM 24 | WORD AudioFormat; // PCM=1 25 | WORD NumChannels; // Mono=1, Stereo=2 26 | DWORD SampleRate; // 8000, 44100, etc. 27 | DWORD ByteRate; // SampleRate*NumChannels*BitsPerSample/8 28 | WORD BlockAlign; // NumChannels * BitsPerSample/8 29 | WORD BitsPerSample; // 8bits = 8, 16 bits = 16 30 | // Data Header 31 | char Subchunk2ID[4]; // "data" 32 | DWORD Subchunk2Size; // NumSamples * NumChannels * BitsPerSample/8 33 | 34 | // Everything after is Data 35 | 36 | } WaveHeader; 37 | 38 | class WaveOut 39 | { 40 | protected: 41 | WaveHeader header; 42 | FILE *waveoutput; 43 | DWORD datasize; 44 | public: 45 | void BeginWaveOut(char *filename, WORD channels, WORD bitsPerSample, DWORD sampleRate); 46 | void EndWaveOut(); 47 | void WriteData (unsigned char*data, DWORD size); 48 | }; 49 | -------------------------------------------------------------------------------- /AziAudio/XAudio2SoundDriver.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2015 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 | #ifdef USE_XAUDIO2 14 | #include "XAudio2SoundDriver.h" 15 | #include "AudioSpec.h" 16 | #include 17 | 18 | static IXAudio2* g_engine; 19 | static IXAudio2SourceVoice* g_source; 20 | static IXAudio2MasteringVoice* g_master; 21 | 22 | static bool audioIsPlaying = false; 23 | static bool canPlay = false; 24 | 25 | static BYTE bufferData[10][44100 * 4]; 26 | static int bufferLength[10]; 27 | static int writeBuffer = 0; 28 | static int readBuffer = 0; 29 | static int filledBuffers; 30 | static int bufferBytes; 31 | static int lastLength = 1; 32 | 33 | static int cacheSize = 0; 34 | static int interrupts = 0; 35 | static VoiceCallback voiceCallback; 36 | XAudio2SoundDriver::XAudio2SoundDriver() 37 | { 38 | g_engine = NULL; 39 | g_source = NULL; 40 | g_master = NULL; 41 | dllInitialized = false; 42 | CoInitializeEx(NULL, COINIT_MULTITHREADED); 43 | } 44 | 45 | 46 | XAudio2SoundDriver::~XAudio2SoundDriver() 47 | { 48 | DeInitialize(); 49 | //Teardown(); 50 | CoUninitialize(); 51 | } 52 | static HANDLE hMutex; 53 | 54 | 55 | BOOL XAudio2SoundDriver::Initialize() 56 | { 57 | if (g_source != NULL) 58 | { 59 | g_source->Start(); 60 | } 61 | bufferLength[0] = bufferLength[1] = bufferLength[2] = bufferLength[3] = bufferLength[4] = bufferLength[5] = 0; 62 | bufferLength[6] = bufferLength[7] = bufferLength[8] = bufferLength[9] = 0; 63 | audioIsPlaying = false; 64 | writeBuffer = 0; 65 | readBuffer = 0; 66 | filledBuffers = 0; 67 | bufferBytes = 0; 68 | lastLength = 1; 69 | 70 | cacheSize = 0; 71 | interrupts = 0; 72 | return false; 73 | } 74 | 75 | BOOL XAudio2SoundDriver::Setup() 76 | { 77 | if (dllInitialized == true) return true; 78 | dllInitialized = true; 79 | bufferLength[0] = bufferLength[1] = bufferLength[2] = bufferLength[3] = bufferLength[4] = bufferLength[5] = 0; 80 | bufferLength[6] = bufferLength[7] = bufferLength[8] = bufferLength[9] = 0; 81 | audioIsPlaying = false; 82 | writeBuffer = 0; 83 | readBuffer = 0; 84 | filledBuffers = 0; 85 | bufferBytes = 0; 86 | lastLength = 1; 87 | 88 | cacheSize = 0; 89 | interrupts = 0; 90 | 91 | hMutex = CreateMutex(NULL, FALSE, NULL); 92 | if (FAILED(XAudio2Create(&g_engine))) 93 | { 94 | CoUninitialize(); 95 | return -1; 96 | } 97 | 98 | if (FAILED(g_engine->CreateMasteringVoice(&g_master))) 99 | { 100 | g_engine->Release(); 101 | CoUninitialize(); 102 | return -2; 103 | } 104 | canPlay = true; 105 | 106 | // Load Wave File 107 | 108 | WAVEFORMATEX wfm; 109 | 110 | memset(&wfm, 0, sizeof(WAVEFORMATEX)); 111 | 112 | wfm.wFormatTag = WAVE_FORMAT_PCM; 113 | wfm.nChannels = 2; 114 | wfm.nSamplesPerSec = 44100; 115 | wfm.wBitsPerSample = 16; // TODO: Allow 8bit audio... 116 | wfm.nBlockAlign = wfm.wBitsPerSample / 8 * wfm.nChannels; 117 | wfm.nAvgBytesPerSec = wfm.nSamplesPerSec * wfm.nBlockAlign; 118 | 119 | 120 | if (FAILED(g_engine->CreateSourceVoice(&g_source, &wfm, 0, XAUDIO2_DEFAULT_FREQ_RATIO, &voiceCallback, NULL, NULL))) 121 | { 122 | g_engine->Release(); 123 | CoUninitialize(); 124 | return -3; 125 | } 126 | 127 | g_source->Start(); 128 | 129 | return FALSE; 130 | } 131 | void XAudio2SoundDriver::DeInitialize() 132 | { 133 | Teardown(); 134 | /* 135 | if (g_source != NULL) 136 | { 137 | g_source->Stop(); 138 | g_source->FlushSourceBuffers(); 139 | //g_source->DestroyVoice(); 140 | }*/ 141 | 142 | } 143 | 144 | void XAudio2SoundDriver::Teardown() 145 | { 146 | if (dllInitialized == false) return; 147 | if (hMutex != NULL) 148 | WaitForSingleObject(hMutex, INFINITE); 149 | if (g_source != NULL) 150 | { 151 | g_source->Stop(); 152 | g_source->FlushSourceBuffers(); 153 | g_source->DestroyVoice(); 154 | } 155 | 156 | if (g_master != NULL) g_master->DestroyVoice(); 157 | if (g_engine != NULL && canPlay) 158 | { 159 | g_engine->StopEngine(); 160 | g_engine->Release(); 161 | } 162 | g_engine = NULL; 163 | g_master = NULL; 164 | g_source = NULL; 165 | if (hMutex != NULL) 166 | { 167 | ReleaseMutex(hMutex); 168 | CloseHandle(hMutex); 169 | } 170 | hMutex = NULL; 171 | dllInitialized = false; 172 | } 173 | 174 | void XAudio2SoundDriver::SetFrequency(DWORD Frequency) 175 | { 176 | cacheSize = (Frequency / 25) * 4;// (((Frequency * 4) / 100) & ~0x3) * 8; 177 | if (Setup() < 0) /* failed to apply a sound device */ 178 | return; 179 | g_source->SetSourceSampleRate(Frequency); 180 | } 181 | 182 | DWORD XAudio2SoundDriver::AddBuffer(BYTE *start, DWORD length) 183 | { 184 | if (length == 0 || g_source == NULL) { 185 | *AudioInfo.AI_STATUS_REG = 0; 186 | *AudioInfo.MI_INTR_REG |= MI_INTR_AI; 187 | AudioInfo.CheckInterrupts(); 188 | return 0; 189 | } 190 | lastLength = length; 191 | 192 | // Gracefully waiting for filled buffers to deplete 193 | if (configSyncAudio == true || configForceSync == true) 194 | while (filledBuffers == 10) Sleep(1); 195 | else 196 | if (filledBuffers == 10) return 0; 197 | 198 | WaitForSingleObject(hMutex, INFINITE); 199 | for (DWORD x = 0; x < length; x += 4) 200 | { 201 | bufferData[writeBuffer][x] = start[x + 2]; 202 | bufferData[writeBuffer][x+1] = start[x + 3]; 203 | bufferData[writeBuffer][x+2] = start[x]; 204 | bufferData[writeBuffer][x+3] = start[x + 1]; 205 | } 206 | bufferLength[writeBuffer] = length; 207 | bufferBytes += length; 208 | filledBuffers++; 209 | 210 | XAUDIO2_BUFFER xa2buff; 211 | 212 | xa2buff.Flags = XAUDIO2_END_OF_STREAM; // Suppress XAudio2 warnings 213 | xa2buff.PlayBegin = 0; 214 | xa2buff.PlayLength = 0; 215 | xa2buff.LoopBegin = 0; 216 | xa2buff.LoopLength = 0; 217 | xa2buff.LoopCount = 0; 218 | xa2buff.pContext = &bufferLength[writeBuffer]; 219 | xa2buff.AudioBytes = length; 220 | xa2buff.pAudioData = bufferData[writeBuffer]; 221 | if (canPlay) 222 | g_source->SubmitSourceBuffer(&xa2buff); 223 | 224 | ++writeBuffer; 225 | writeBuffer %= 10; 226 | 227 | if (bufferBytes < cacheSize || configForceSync == true) 228 | { 229 | *AudioInfo.AI_STATUS_REG = AI_STATUS_DMA_BUSY; 230 | *AudioInfo.MI_INTR_REG |= MI_INTR_AI; 231 | AudioInfo.CheckInterrupts(); 232 | } 233 | else 234 | { 235 | if (filledBuffers >= 2) 236 | *AudioInfo.AI_STATUS_REG |= AI_STATUS_FIFO_FULL; 237 | interrupts++; 238 | } 239 | ReleaseMutex(hMutex); 240 | 241 | return 0; 242 | } 243 | 244 | void XAudio2SoundDriver::AiUpdate(BOOL Wait) 245 | { 246 | if (Wait) 247 | WaitMessage(); 248 | } 249 | 250 | void XAudio2SoundDriver::StopAudio() 251 | { 252 | 253 | audioIsPlaying = false; 254 | if (g_source != NULL) 255 | g_source->FlushSourceBuffers(); 256 | 257 | } 258 | 259 | void XAudio2SoundDriver::StartAudio() 260 | { 261 | audioIsPlaying = true; 262 | } 263 | 264 | DWORD XAudio2SoundDriver::GetReadStatus() 265 | { 266 | XAUDIO2_VOICE_STATE xvs; 267 | int retVal; 268 | 269 | if (canPlay) 270 | g_source->GetState(&xvs); 271 | else 272 | return 0; 273 | 274 | // printf("%i - %i - %i\n", xvs.SamplesPlayed, bufferLength[0], bufferLength[1]); 275 | 276 | if (xvs.BuffersQueued == 0 || configForceSync == true) return 0; 277 | 278 | if (bufferBytes + lastLength < cacheSize) 279 | return 0; 280 | else 281 | retVal = (lastLength - xvs.SamplesPlayed * 4) & ~0x7;// bufferBytes % lastLength;// *(int *)xvs.pCurrentBufferContext - (int)xvs.SamplesPlayed; 282 | 283 | if (retVal < 0) return 0; else return retVal % lastLength; 284 | // return 0; 285 | } 286 | 287 | // 100 - Mute to 0 - Full Volume 288 | void XAudio2SoundDriver::SetVolume(DWORD volume) 289 | { 290 | float xaVolume = 1.0f - ((float)volume / 100.0f); 291 | if (g_source != NULL) g_source->SetVolume(xaVolume); 292 | //XAUDIO2_MAX_VOLUME_LEVEL 293 | } 294 | 295 | 296 | void __stdcall VoiceCallback::OnBufferEnd(void * pBufferContext) 297 | { 298 | WaitForSingleObject(hMutex, INFINITE); 299 | #ifdef SEH_SUPPORTED 300 | __try // PJ64 likes to close objects before it shuts down the DLLs completely... 301 | { 302 | #endif 303 | *AudioInfo.AI_STATUS_REG = AI_STATUS_DMA_BUSY; 304 | if (interrupts > 0) 305 | { 306 | interrupts--; 307 | *AudioInfo.MI_INTR_REG |= MI_INTR_AI; 308 | AudioInfo.CheckInterrupts(); 309 | } 310 | #ifdef SEH_SUPPORTED 311 | } 312 | __except (EXCEPTION_EXECUTE_HANDLER) 313 | { 314 | } 315 | #endif 316 | bufferBytes -= *(int *)(pBufferContext); 317 | filledBuffers--; 318 | ReleaseMutex(hMutex); 319 | } 320 | 321 | void __stdcall VoiceCallback::OnVoiceProcessingPassStart(UINT32 SamplesRequired) 322 | { 323 | UNREFERENCED_PARAMETER(SamplesRequired); 324 | //if (SamplesRequired > 0) 325 | // printf("SR: %i FB: %i BB: %i CS:%i\n", SamplesRequired, filledBuffers, bufferBytes, cacheSize); 326 | } 327 | #endif 328 | -------------------------------------------------------------------------------- /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-2015 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 | #include 15 | #include "SoundDriver.h" 16 | #include 17 | 18 | class VoiceCallback : public IXAudio2VoiceCallback 19 | { 20 | public: 21 | //HANDLE hBufferEndEvent; 22 | VoiceCallback() /*: hBufferEndEvent(CreateEvent(NULL, FALSE, FALSE, NULL))*/{} 23 | ~VoiceCallback(){/* CloseHandle(hBufferEndEvent); */} 24 | 25 | //Called when the voice has just finished playing a contiguous audio stream. 26 | void __stdcall OnStreamEnd() {/* SetEvent(hBufferEndEvent); */} 27 | 28 | //Unused methods are stubs 29 | 30 | void __stdcall OnVoiceProcessingPassEnd() { } 31 | void __stdcall OnVoiceProcessingPassStart(UINT32 SamplesRequired);// {} 32 | void __stdcall OnBufferEnd(void * pBufferContext);// {} 33 | void __stdcall OnBufferStart(void * pBufferContext) { UNREFERENCED_PARAMETER(pBufferContext); } 34 | void __stdcall OnLoopEnd(void * pBufferContext) { UNREFERENCED_PARAMETER(pBufferContext); } 35 | void __stdcall OnVoiceError(void * pBufferContext, HRESULT Error) { UNREFERENCED_PARAMETER(pBufferContext); UNREFERENCED_PARAMETER(Error); } 36 | 37 | /* 38 | STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired); 39 | STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS); 40 | STDMETHOD_(void, OnStreamEnd) (THIS); 41 | STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext); 42 | STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext); 43 | STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext); 44 | STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error); 45 | */ 46 | }; 47 | 48 | class XAudio2SoundDriver : 49 | public SoundDriver 50 | { 51 | public: 52 | XAudio2SoundDriver(); 53 | ~XAudio2SoundDriver(); 54 | 55 | // Setup and Teardown Functions 56 | BOOL Initialize(); 57 | void DeInitialize(); 58 | 59 | BOOL Setup(); 60 | void Teardown(); 61 | 62 | // Buffer Functions for the Audio Code 63 | void SetFrequency(DWORD Frequency); // Sets the Nintendo64 Game Audio Frequency 64 | DWORD AddBuffer(BYTE *start, DWORD length); // Uploads a new buffer and returns status 65 | 66 | // Management functions 67 | void AiUpdate(BOOL Wait); 68 | void StopAudio(); // Stops the Audio PlayBack (as if paused) 69 | void StartAudio(); // Starts the Audio PlayBack (as if unpaused) 70 | 71 | DWORD GetReadStatus(); // Returns the status on the read pointer 72 | 73 | void SetVolume(DWORD volume); 74 | 75 | protected: 76 | 77 | bool dllInitialized; 78 | }; 79 | 80 | /* 81 | * The GNU C++ compiler (ported to Windows through MinGW, for example) 82 | * references system C++ headers that use `__in` and `__out` for things 83 | * related to C++, which conflicts with Microsoft's driver macros for 84 | * the XAudio2 API. Perhaps either side could be blamed for this, but I 85 | * think that it shouldn't hurt to un-define the __in and __out stuff after 86 | * we have finished prototyping everything relevant to XAudio2. -- cxd4 87 | */ 88 | #if !defined(_MSC_VER) 89 | #undef __in 90 | #undef __out 91 | #endif 92 | -------------------------------------------------------------------------------- /AziAudio/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 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/audiohle.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2015 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 | 14 | /* 15 | * Ultra64 data types for working with RCP stuff--useful for HLE 16 | */ 17 | #include "my_types.h" 18 | 19 | /* Audio commands: ABI 1 */ 20 | /* 21 | #define A_SPNOOP 0 22 | #define A_ADPCM 1 23 | #define A_CLEARBUFF 2 24 | #define A_ENVMIXER 3 25 | #define A_LOADBUFF 4 26 | #define A_RESAMPLE 5 27 | #define A_SAVEBUFF 6 28 | #define A_SEGMENT 7 29 | #define A_SETBUFF 8 30 | #define A_SETVOL 9 31 | #define A_DMEMMOVE 10 32 | #define A_LOADADPCM 11 33 | #define A_MIXER 12 34 | #define A_INTERLEAVE 13 35 | #define A_POLEF 14 36 | #define A_SETLOOP 15 37 | */ 38 | #define ACMD_SIZE 32 39 | /* 40 | * Audio flags 41 | */ 42 | 43 | #define A_INIT 0x01 44 | #define A_CONTINUE 0x00 45 | #define A_LOOP 0x02 46 | #define A_OUT 0x02 47 | #define A_LEFT 0x02 48 | #define A_RIGHT 0x00 49 | #define A_VOL 0x04 50 | #define A_RATE 0x00 51 | #define A_AUX 0x08 52 | #define A_NOAUX 0x00 53 | #define A_MAIN 0x00 54 | #define A_MIX 0x10 55 | 56 | /* 57 | * The bit mask for each ABI command op-code seems to be: 58 | * (command & 0xFF00000000000000) >> 56 # w0[31..24], but actually the 59 | * repeating pattern seems to be that there are only 32 ABI commands. 60 | * Either doc is lazy, or the potential of 256 commands is a reserved thing. 61 | */ 62 | #define NUM_ABI_COMMANDS 32 63 | 64 | /* 65 | * number of elements in SIMD processor 66 | * In the RSP's case, this is always 8 elements per vector. 67 | */ 68 | #define N 8 69 | 70 | //------------------------------------------------------------------------------------------ 71 | 72 | // Use these functions to interface with the HLE Audio... 73 | #include "AudioSpec.h" 74 | 75 | extern u32 t9, k0; 76 | 77 | extern u8 * DMEM; 78 | extern u8 * IMEM; 79 | extern u8 * DRAM; 80 | 81 | extern u32 UCData, UDataLen; 82 | 83 | void SaveSettings( void ); 84 | void LoadSettings( void ); 85 | 86 | void RspDump (); 87 | 88 | // ABI Functions 89 | void ADDMIXER(); 90 | void ADPCM(); void ADPCM2(); void ADPCM3(); 91 | void CLEARBUFF(); void CLEARBUFF2(); void CLEARBUFF3(); 92 | void DMEMMOVE(); void DMEMMOVE2(); void DMEMMOVE3(); 93 | void DUPLICATE2(); 94 | void ENVMIXER(); void ENVMIXER2(); void ENVMIXER3(); void ENVMIXER_GE(); 95 | void ENVSETUP1(); void ENVSETUP2(); 96 | void FILTER2(); 97 | void HILOGAIN(); 98 | void INTERL2(); 99 | void INTERLEAVE(); void INTERLEAVE2(); void INTERLEAVE3(); 100 | void LOADADPCM(); void LOADADPCM2(); void LOADADPCM3(); 101 | void LOADBUFF(); void LOADBUFF2(); void LOADBUFF3(); 102 | void MIXER(); void MIXER2(); void MIXER3(); 103 | void MP3(); 104 | void MP3ADDY(); 105 | void POLEF(); 106 | void RESAMPLE(); void RESAMPLE2(); void RESAMPLE3(); 107 | void SAVEBUFF(); void SAVEBUFF2(); void SAVEBUFF3(); 108 | void SEGMENT(); void SEGMENT2(); 109 | void SETBUFF(); void SETBUFF2(); 110 | void SETLOOP(); void SETLOOP2(); void SETLOOP3(); 111 | void SETVOL(); void SETVOL3(); 112 | void SPNOOP(); 113 | void UNKNOWN(); 114 | 115 | // Buffer Space 116 | extern u8 BufferSpace[0x10000]; 117 | extern short hleMixerWorkArea[256]; 118 | extern u32 SEGMENTS[0x10]; // 0x0320 119 | extern u16 AudioInBuffer, AudioOutBuffer, AudioCount; 120 | extern u16 AudioAuxA, AudioAuxC, AudioAuxE; 121 | extern u32 loopval; // Value set by A_SETLOOP : Possible conflict with SETVOLUME??? 122 | extern bool isMKABI; 123 | extern bool isZeldaABI; 124 | 125 | /* 126 | * Each vector accumulator element is 48 bits, but that is a technical 127 | * advancement. Only 32 bits at a time can be accessed during clamping. 128 | */ 129 | extern s32 acc[32][N]; 130 | extern s16 acc_clamped[N]; 131 | 132 | /* 133 | * Include the SSE2 headers if MSVC is set to target SSE2 in code generation. 134 | * [Update 2015.07.08 ... or if targeting Intel x86_64.] 135 | */ 136 | #if defined(_M_IX86_FP) && (_M_IX86_FP >= 2) 137 | #include 138 | #endif 139 | #if defined(_M_X64) 140 | #include 141 | #endif 142 | 143 | /* ... or if compiled with the right preprocessor token on other compilers */ 144 | #ifdef SSE2_SUPPORT 145 | #include 146 | #endif 147 | 148 | /* The SSE1 and SSE2 headers always define these macro functions: */ 149 | #undef SSE2_SUPPORT 150 | #if defined(_MM_SHUFFLE) && defined(_MM_SHUFFLE2) 151 | #define SSE2_SUPPORT 152 | #endif 153 | 154 | #if 0 155 | #define PREFER_MACRO_FUNCTIONS 156 | #endif 157 | 158 | /* 159 | * RSP hardware has two types of saturated arithmetic: 160 | * 1. signed clamping from 32- to 16-bit elements 161 | * 2. unsigned clamping from 32- to 16-bit elements 162 | * (Note that no audio microcode for the RSP has ever been seen encountering 163 | * unsigned fractions or addends, so we only need to emulate signed clamps.) 164 | * 165 | * Accumulators are 48-bit, but only 32-bit-segment intervals at one time are 166 | * involved in the clamp. The upper and lower bounds for signed and unsigned 167 | * clamping match the ANSI C language minimum requirements for the types 168 | * `short` and `unsigned short`: -32768 <= x <= +32767 and 0 <= x <= +65535. 169 | * 170 | * A "slice" is an off-set portion of the accumulator: high, middle, or low. 171 | */ 172 | #ifdef PREFER_MACRO_FUNCTIONS 173 | #define sats_over(slice) (((slice) > +32767) ? +32767 : (slice)) 174 | #define sats_under(slice) (((slice) < -32768) ? -32768 : (slice)) 175 | #else 176 | extern INLINE s32 sats_over(s32 slice); 177 | extern INLINE s32 sats_under(s32 slice); 178 | #endif 179 | 180 | #ifdef PREFER_MACRO_FUNCTIONS 181 | #define pack_signed(slice) sats_over(sats_under(slice)) 182 | #else 183 | extern s16 pack_signed(s32 slice); 184 | #endif 185 | 186 | #ifdef PREFER_MACRO_FUNCTIONS 187 | #define vsats128(vd, vs) { \ 188 | vd[0] = pack_signed(vs[0]); vd[1] = pack_signed(vs[1]); \ 189 | vd[2] = pack_signed(vs[2]); vd[3] = pack_signed(vs[3]); } 190 | #else 191 | extern void vsats128(s16* vd, s32* vs); /* Clamp vectors using SSE2. */ 192 | #endif 193 | 194 | /* 195 | * Basically, if we can prove that, on the C implementation in question: 196 | * 1. Integers are negative if all bits are set (or simply the MSB). 197 | * 2. Shifting a signed integer to the right shifts in the sign bit. 198 | * ... then we are able to easily staticize [un-]signed clamping functions. 199 | */ 200 | #if (~0 < 0) 201 | #if ((~0 & ~1) >> 1 == ~0) 202 | #define TWOS_COMPLEMENT_NEGATION 203 | #endif 204 | #endif 205 | 206 | /* 207 | * There are two basic ways to copy an RSP vector to another RSP vector in 208 | * emulated memory: with alignment and without alignment. Forcing 128-bit 209 | * alignment requirements is a cycle or two faster on older CPUs, but on 210 | * modern hardware there is no reason to force memory alignment constrictions 211 | * or to use MOVDQA/MOVAPS and risk unaligned memory access seg. faults. 212 | */ 213 | extern void copy_vector(void * vd, const void * vs); 214 | 215 | /* 216 | * Unfortunately, as much of the RSP analysis had to work around some early 217 | * byte order tricks in zilmar's RSP interpreter, several cases of audio HLE 218 | * will have extra endianness adjustments to them, sometimes redundantly. 219 | * 220 | * For example, reads and writes might frequently XOR each 16-bit address 221 | * when moving to and from a location, to maintain little-endian vectors. 222 | * 223 | * This function will act as a temporary solution for optimizing away most 224 | * of that scenario until the memory layout is improved more permanently in 225 | * later changes. 226 | */ 227 | extern void swap_elements(void * vd, const void * vs); 228 | -------------------------------------------------------------------------------- /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-2015 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | #ifndef _COMMON_DOT_H_ 13 | #define _COMMON_DOT_H_ 14 | 15 | #if defined (_XBOX) 16 | #include 17 | #include "XBox/xbox_depp.h" 18 | #else 19 | #include 20 | #include 21 | #endif 22 | 23 | #include 24 | #include 25 | 26 | //#define ENABLEPROFILING 27 | 28 | #if defined(_MSC_VER) 29 | #define SEH_SUPPORTED 30 | #endif 31 | 32 | #ifndef XAUDIO_LIBRARIES_UNAVAILABLE 33 | #define USE_XAUDIO2 34 | #endif 35 | 36 | #include "my_types.h" 37 | 38 | typedef struct { 39 | u16 Version; 40 | u32 BufferSize; 41 | BOOL doAIHACK; 42 | BOOL syncAudio; 43 | BOOL fillAudio; 44 | BOOL oldStyle; 45 | BOOL Reserved2; 46 | BOOL Reserved3; 47 | u32 Reserved4; 48 | u32 Reserved5; 49 | u32 Reserved6; 50 | } rSettings; 51 | extern rSettings RegSettings; 52 | #endif 53 | 54 | #define AUDIOCODE 0 55 | #define HLECODE 1 56 | #define CPUCODE 2 57 | 58 | unsigned long GenerateCRC (unsigned char *data, int size); 59 | 60 | #ifdef USE_XAUDIO2 61 | #define PLUGIN_NAME "XA2 Audio" 62 | #else 63 | #define PLUGIN_NAME "DS8 Audio" 64 | #endif 65 | 66 | #ifdef DEVBUILD 67 | #ifdef __GNUC__ 68 | #define PLUGIN_BUILDSYS "Mingw" 69 | #else 70 | #define PLUGIN_BUILDSYS "MSVC" 71 | #endif 72 | #ifdef _DEBUG 73 | #define PLUGIN_DEBUG " (" PLUGIN_BUILDSYS " Debug)" 74 | #else 75 | #define PLUGIN_DEBUG " (" PLUGIN_BUILDSYS ")" 76 | #endif 77 | #else 78 | #ifdef _DEBUG 79 | #define PLUGIN_DEBUG " (Debug)" 80 | #else 81 | #define PLUGIN_DEBUG "" 82 | #endif 83 | #endif 84 | 85 | #define PLUGIN_RELEASE " v0.70 " 86 | #define PLUGIN_BUILD "WIP 6" \ 87 | PLUGIN_DEBUG 88 | 89 | #define PLUGIN_VERSION \ 90 | "Azimer's " \ 91 | PLUGIN_NAME \ 92 | PLUGIN_RELEASE \ 93 | PLUGIN_BUILD 94 | 95 | 96 | #ifdef ENABLEPROFILING 97 | 98 | extern u64 ProfileStartTimes[30]; 99 | extern u64 ProfileTimes[30]; 100 | 101 | inline void StartProfile (int profile) { 102 | u64 start; 103 | __asm { 104 | rdtsc; 105 | mov dword ptr [start+0], eax; 106 | mov dword ptr [start+4], edx; 107 | } 108 | ProfileStartTimes[profile] = start; 109 | } 110 | 111 | inline void EndProfile (int profile) { 112 | u64 end; 113 | __asm { 114 | rdtsc; 115 | mov dword ptr [end+0], eax; 116 | mov dword ptr [end+4], edx; 117 | } 118 | ProfileTimes[profile] = ProfileTimes[profile] + (end - ProfileStartTimes[profile]); 119 | } 120 | inline void PrintProfiles () { 121 | FILE *dfile = fopen ("d:\\profile.txt", "wt"); 122 | u64 totalTimes = 0; 123 | for (int x = 0; x < 30; x++) { 124 | if (ProfileTimes[x] != 0) { 125 | fprintf (dfile, "Times for %i is: %08X %08X\n", x, (u32)(ProfileTimes[x] >> 32), (u32)ProfileTimes[x]); 126 | totalTimes += ProfileTimes[x]; 127 | } 128 | } 129 | for (x = 0; x < 30; x++) { 130 | if (ProfileTimes[x] != 0) { 131 | fprintf (dfile, "Percent Time for %i is: %i%%\n", x, (u32)((ProfileTimes[x]*100) / totalTimes)); 132 | } 133 | } 134 | fclose (dfile); 135 | } 136 | inline void ClearProfiles () { 137 | for (int x = 0; x < 30; x++) { 138 | ProfileTimes[x] = 0; 139 | } 140 | } 141 | #else 142 | # define StartProfile(profile) // 143 | # define EndProfile(profile) // 144 | # define PrintProfiles() // 145 | # define ClearProfiles()// 146 | #endif 147 | 148 | /* 149 | * `strcpy` with bounds checking 150 | * This basically is a portable variation of Microsoft's `strcpy_s`. 151 | */ 152 | extern int safe_strcpy(char* dst, size_t limit, const char* src); 153 | -------------------------------------------------------------------------------- /AziAudio/readme.txt: -------------------------------------------------------------------------------- 1 | ************************************** 2 | *** Azimer's HLE Audio v0.70 WIP 1 *** 3 | ************************************** 4 | 5 | Last Updated: July 28th, 2014 6 | 7 | 8 | ----- Contents ----- 9 | 10 | 0. Disclaimer 11 | 1. What's New 12 | 2. Known Issues 13 | 3. What's Next 14 | 4. Usage 15 | 5. FAQ 16 | 6. Greetings and Closing Comments 17 | 18 | ---------------------------------------------------------------------------------- 19 | 20 | 0. Disclaimer 21 | 22 | This plugin is provided as is for beta testing purposes only. You are 23 | solely responsible for any damages or data loss incurred through use of 24 | this software. Use at your own risk. If you do not agree with these 25 | terms, please delete this application and use something else. The software 26 | has been tested to the best of my ability. There is no warranty expressed 27 | or implied. Commercial use of this product will constitute a criminal act. 28 | blah blah blah... if you can think of an illegitimate use for this product, 29 | please do not use it. I am not responsible for stupidity. Now that is over 30 | with... 31 | 32 | ---------------------------------------------------------------------------------- 33 | 34 | 1. What's New? 35 | 36 | *** v0.70 WIP 1 *** 37 | - Implemented XAudio2 with its own audio code. Use for best results. 38 | - Updated DirectSound code to better support Project64 2.1 39 | - Fixed issue where if there's no audio initialized it will throw errors. Now it 40 | it just won't do anything at all. 41 | - Fixed Mystical Ninja pops 42 | - Reduced Smash Bros crackles a little bit - still some issues 43 | - Stability changes (less crashing I hope) 44 | - Killed the smilies from this document 45 | 46 | *** v0.60 WIP 2 *** 47 | - New audio code - tested in Project64 1.6 48 | - New configuration though most things are disabled atm 49 | 50 | *** v0.56 WIP 2 *** 51 | - Bug Fix release... nothing much new 52 | - Finally received Project64 1.6 53 | - Hydro Thunder and Tarzan work well by using Project64 1.6's 54 | - Fixed those nasty SP_DMA_READ Errors 55 | - Fixed hangups in all roms which worked before 56 | - Eliminated some pops and crackles in games that shouldn't have them 57 | - And no... configuration has not been changed (least of my worries) 58 | 59 | *** v0.56 WIP 1 *** 60 | - Revamped Audio Code from v0.50.2 61 | - HLE Code is untouched as of now 62 | - Added some low level RSP code temporarily to assist in fixing HLE Audio 63 | - Added a hidden console window for Audio status/debugging (disabled unless public finds it desirable) 64 | - Fixed MANY stuttering issues and issues with MusyX games. Tarzan is still a problem because of timing. 65 | - Added Old Audio Sync option... You will need to set it every time you start the emulator if you want to use it. 66 | 67 | ---------------------------------------------------------------------------------- 68 | 2. Known Issues (possibly unfixable within the confines of this plugin spec) 69 | - Cruis'n World - Audio is too fast without emulator's audio fix and sync enabled 70 | - Twisted Edge - No audio (Emulator bug??) 71 | - Big Boss games - Stuntracer, Top Gear Rally, World Driver Championship, Twisted Edge 72 | - Still a huge issue with audio quality... I believe it's an emulator issue 73 | - Indiana Jones - Factor 5 intro sequence is very buggy 74 | 75 | ---------------------------------------------------------------------------------- 76 | 77 | 3. What's Next? 78 | *** Coming Soon *** 79 | - Merge DirectSound and XAudio2 code into one plugin again 80 | - Fix Golden Eye HLE Envelope Mixer code 81 | - Enabled saving audio config settings 82 | - Add MusyX HLE Code 83 | 84 | *** Near Future *** 85 | - More audio configuration options (Buffer size adjustments, Bitrate adjustments, MP3 logging) 86 | - Equalizer/Filters 87 | - HLE speedups/optimizations 88 | 89 | *** Maybes *** 90 | - Find a solution to decode Dolby Prologic 91 | - Music isolation for MP3 logging (big maybe) 92 | 93 | ---------------------------------------------------------------------------------- 94 | 95 | 4. Usage 96 | 97 | *** Setup *** 98 | 1. Place AziAudioDS8.dll and AziAudioXA2.dll into the "Project64" folder's "Plugin" folder. (ie C:\Project64 2.1\Plugin\Audio) 99 | 2. Go to the Options menu, click settings. 100 | 3. Go to the Plugins setting tab. 101 | 4. Under "Audio (sound) plugin click the drop down box. 102 | 5. Select "Azimer's XA2 Audio" whatever version is the latest (ie "Azimer's XA2 Audio v0.70 WIP 1") 103 | 6. All the default options should be okay, so click ok 104 | 105 | You should now be good to load an image as defined in the Project64 user help file. 106 | 107 | ---------------------------------------------------------------------------------- 108 | 109 | 5. FAQ 110 | 111 | 5.1.Q - Why do I hear some pops in some parts of the game? 112 | 5.1.A - I have noticed through my own testing that during certain parts of a game, the game uses the 113 | emulated processor power to the point where it can not perform at a constant 60/50FPS if even 114 | for a moment. This neglect will cause the constant stream of audio to the plugin to be halted 115 | for that brief popping period. It is not a problem with the Audio plugin and nothing can be 116 | done to accommodate. You can try setting the emulator to High priority to eliminate the turn 117 | around time for the emulator to preempt any process during its waitstate. It seems to have 118 | helped me. Another problem is that PJ64 1.5's speed limiter isn't the best. If it's a compatible 119 | game, you could attempt to use the old speed sync. A better speed fix is underway to go by samples 120 | per second based on the set frequency. This is likely another audio code revision just to try it out. 121 | 122 | 5.2.Q - Why isn't Tarzan allowing me to go in game? 123 | 5.2.A - This problem has finally be isolated to an option acquired in Project64 1.6. Make sure you have 124 | RSP Audio Signal checked in the Rom Settings options. 125 | 126 | 5.3.Q - Is there going to be another Project64 Audio Fix? 127 | 5.3.A - Nothing is planned. I'd rather contribute directly to the source but if a release is far off, 128 | it's a possibility. 129 | 130 | 5.4.Q - How come there's no audio in Tarzan, Hydro Thunder, TWINE, or any other MusyX game? 131 | 5.4.A - Try changing the options in the Emulator so Audio Lists are not processed by Audio HLE. Musyx is not 132 | currently supported. 133 | 134 | 5.5.A - There seems to be problems in a game I've been playing? How should I contact you? 135 | 5.5.Q - Please post all problems on EmuTalk's Apollo board. I will be more than happy to answer any questions. 136 | 137 | 5.6.A - I am getting an SP_READ_DMA Error? What does this mean? 138 | 5.6.Q - Either you are using an older version of this plugin or you have encountered a ROM I haven't tested. 139 | Please write me on emutalk with the specific GoodN64 rom title and I will look into it. Thanks. 140 | 141 | If none of those FAQs help you, please post on EmuTalk and I will answer the question and include it here. 142 | www.emutalk.net 143 | 144 | ---------------------------------------------------------------------------------- 145 | 146 | 6. Greetings and Closing Comments 147 | 148 | I would like to thank the following for all their help. 149 | RCP - For giving me a booster for HLE Audio. 150 | F|RES - Thanks for allowing me to join TR64 years ago and getting a start on Audio HLE from this. 151 | icepir8 - If you ever continue TR64, feel free to include my Audio plugin. It will always be a TR64 plugin. 152 | zilmar - The single biggest help with AudioHLE. Thank you for all the RSP help and information. It was invaluable. 153 | Jabo - I still use a variant of you Audio playing idea you proposed to be years ago from JNes. Thanks! 154 | LaC - Many long conversations that now make me feel newbish. Thanks for putting up with me. 155 | 156 | Hack, Rice, Schibo, Phrodide, episilon, realityman, and everyone else who has worked on N64 emulation. You all 157 | have contributed to the success of our interest. Also like to say thanks to breakpoint for pioneering N64 158 | emulation. I will never forget the days I waited to see better screenshots of MKT. I was very sad when you 159 | stopped. 160 | 161 | Special thanks to all my past beta testers and supporters. Thank you to olivieryuyu who maintained the Audio FAQ in 162 | the Apollo board. Your contribution has been tremendously helpful. Thank you to those who inspired me to 163 | continue working on new releases. It is not an easy thing to pick up again after years of non-work and a family 164 | to support. Thank you to all those who I have forgotten, it wasn't intentional. 165 | 166 | Though N64 emulation seems to have died out from it's golden age, there is still a lot of work that needs to be 167 | done. 168 | 169 | -Azimer (www.apollo64.com) 170 | -------------------------------------------------------------------------------- /AziAudio/resource.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * * 3 | * Azimer's HLE Audio Plugin for Project64 Compatible N64 Emulators * 4 | * http://www.apollo64.com/ * 5 | * Copyright (C) 2000-2015 Azimer. All rights reserved. * 6 | * * 7 | * License: * 8 | * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * 9 | * * 10 | ****************************************************************************/ 11 | 12 | //{{NO_DEPENDENCIES}} 13 | // Microsoft Visual C++ generated include file. 14 | // Used by resource.rc 15 | // 16 | #define IDD_CONFIG 101 17 | #define IDC_AUDIOSYNC 1000 18 | #define IDC_AI 1001 19 | #define IDC_OLDSYNC 1002 20 | #define IDC_VOLUME 1003 21 | #define IDC_MUTE 1004 22 | #define IDC_EDIT1 1005 23 | #define IDC_EDIT2 1006 24 | #define IDC_EDIT3 1007 25 | #define IDC_CHECK2 1008 26 | #define IDC_HLE 1008 27 | #define IDC_RSP 1009 28 | #define IDC_DIRECTORY 1010 29 | #define IDC_BROWSE 1011 30 | #define IDC_START 1012 31 | #define IDC_STOP 1013 32 | #define IDC_EDIT5 1014 33 | #define IDC_EDIT6 1015 34 | #define IDC_DEVICE 1016 35 | 36 | // Next default values for new objects 37 | // 38 | #ifdef APSTUDIO_INVOKED 39 | #ifndef APSTUDIO_READONLY_SYMBOLS 40 | #define _APS_NEXT_RESOURCE_VALUE 103 41 | #define _APS_NEXT_COMMAND_VALUE 40001 42 | #define _APS_NEXT_CONTROL_VALUE 1017 43 | #define _APS_NEXT_SYMED_VALUE 101 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /AziAudio/resource.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include 11 | #ifndef IDC_STATIC 12 | #define IDC_STATIC (-1) 13 | #endif 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | #undef APSTUDIO_READONLY_SYMBOLS 17 | 18 | ///////////////////////////////////////////////////////////////////////////// 19 | // English (United States) resources 20 | 21 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 22 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 23 | #pragma code_page(1252) 24 | 25 | #ifdef APSTUDIO_INVOKED 26 | ///////////////////////////////////////////////////////////////////////////// 27 | // 28 | // TEXTINCLUDE 29 | // 30 | 31 | 1 TEXTINCLUDE 32 | BEGIN 33 | "resource.h\0" 34 | END 35 | 36 | 2 TEXTINCLUDE 37 | BEGIN 38 | "#include ""afxres.h""\r\n" 39 | "\0" 40 | END 41 | 42 | 3 TEXTINCLUDE 43 | BEGIN 44 | "\r\n" 45 | "\0" 46 | END 47 | 48 | #endif // APSTUDIO_INVOKED 49 | 50 | 51 | ///////////////////////////////////////////////////////////////////////////// 52 | // 53 | // Dialog 54 | // 55 | 56 | IDD_CONFIG DIALOGEX 0, 0, 417, 251 57 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU 58 | CAPTION "Audio Options" 59 | FONT 8, "MS Sans Serif", 0, 0, 0x0 60 | BEGIN 61 | LTEXT "Disable if the emulator handles its own AI emulation.",IDC_STATIC,36,172,177,14 62 | CONTROL "Prevent Buffer Overruns",IDC_AUDIOSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,41,95,8 63 | CONTROL "Force Old Audio Sync",IDC_OLDSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,87,86,10 64 | CONTROL "Emulate Audio Interface",IDC_AI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,161,116,9 65 | CONTROL "Enable HLE Audio",IDC_HLE,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,24,182,74,10 66 | CONTROL "Enable RSP Emulation",IDC_RSP,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,24,201,87,10 67 | COMBOBOX IDC_DEVICE,229,32,165,132,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP 68 | EDITTEXT IDC_DIRECTORY,261,66,134,14,ES_AUTOHSCROLL | WS_DISABLED 69 | PUSHBUTTON "Start",IDC_START,227,89,50,14,WS_DISABLED 70 | PUSHBUTTON "Stop",IDC_STOP,285,89,50,14,WS_DISABLED 71 | PUSHBUTTON "&Browse",IDC_BROWSE,343,89,50,14,WS_DISABLED 72 | EDITTEXT IDC_EDIT2,282,134,66,12,ES_AUTOHSCROLL | WS_DISABLED,WS_EX_STATICEDGE 73 | EDITTEXT IDC_EDIT3,282,151,66,12,ES_AUTOHSCROLL | WS_DISABLED,WS_EX_STATICEDGE 74 | EDITTEXT IDC_EDIT1,282,169,66,12,ES_AUTOHSCROLL | WS_DISABLED,WS_EX_STATICEDGE 75 | EDITTEXT IDC_EDIT5,282,185,66,12,ES_AUTOHSCROLL | WS_DISABLED,WS_EX_STATICEDGE 76 | EDITTEXT IDC_EDIT6,282,201,66,12,ES_AUTOHSCROLL | WS_DISABLED,WS_EX_STATICEDGE 77 | CONTROL "",IDC_VOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_BORDER | WS_TABSTOP,362,132,32,67,WS_EX_STATICEDGE 78 | DEFPUSHBUTTON "OK",IDOK,23,222,50,14 79 | PUSHBUTTON "Cancel",IDCANCEL,84,223,50,14 80 | LTEXT "Designed for use with Project64 2.1.0.1",IDC_STATIC,24,10,163,10 81 | GROUPBOX "Playback Options",IDC_STATIC,17,23,200,120 82 | GROUPBOX "Volume",IDC_STATIC,357,121,45,94 83 | CONTROL "Mute",IDC_MUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,362,201,32,10 84 | LTEXT "Mute:",IDC_STATIC,228,169,53,8 85 | LTEXT "Volume Up:",IDC_STATIC,228,137,53,8 86 | LTEXT "Volume Down:",IDC_STATIC,228,153,53,8 87 | GROUPBOX "Emulation Options",IDC_STATIC,16,148,200,70 88 | GROUPBOX "Audio Logging",IDC_STATIC,221,52,181,68 89 | LTEXT "Directory:",IDC_STATIC,229,68,31,8 90 | GROUPBOX "Shortcut Keys",IDC_STATIC,221,121,132,96 91 | LTEXT "Start Audio Log:",IDC_STATIC,228,186,53,8 92 | LTEXT "Stop Audio Log:",IDC_STATIC,228,204,53,8 93 | GROUPBOX "Playback Device",IDC_STATIC,222,23,180,28 94 | LTEXT "Old school Audio Sync. Works well for emulators with poor Speed Limiter but will not work with some other games. Use is not recommended.",IDC_STATIC,37,99,133,35 95 | LTEXT "Gracefully services buffer overruns by waiting for space to be available rather than skipping the buffer completely.",IDC_STATIC,37,52,172,29 96 | END 97 | 98 | 99 | ///////////////////////////////////////////////////////////////////////////// 100 | // 101 | // DESIGNINFO 102 | // 103 | 104 | #ifdef APSTUDIO_INVOKED 105 | GUIDELINES DESIGNINFO 106 | BEGIN 107 | IDD_CONFIG, DIALOG 108 | BEGIN 109 | LEFTMARGIN, 7 110 | RIGHTMARGIN, 410 111 | TOPMARGIN, 7 112 | BOTTOMMARGIN, 244 113 | END 114 | END 115 | #endif // APSTUDIO_INVOKED 116 | 117 | #endif // English (United States) resources 118 | ///////////////////////////////////////////////////////////////////////////// 119 | 120 | 121 | 122 | #ifndef APSTUDIO_INVOKED 123 | ///////////////////////////////////////////////////////////////////////////// 124 | // 125 | // Generated from the TEXTINCLUDE 3 resource. 126 | // 127 | 128 | 129 | ///////////////////////////////////////////////////////////////////////////// 130 | #endif // not APSTUDIO_INVOKED 131 | 132 | -------------------------------------------------------------------------------- /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 YES for a debug build. Anything else for a release build. 8 | 9 | 10 | #### Compiler and tool definitions shared by all build targets ##### 11 | CC = gcc 12 | CXX = g++ 13 | WINDRES = windres 14 | CFLAGS = $(BASICOPTS) -msse2 -DSSE2_SUPPORT -mstackrealign 15 | CXXFLAGS = $(BASICOPTS) -msse2 -DSSE2_SUPPORT -mstackrealign 16 | LDFLAGS = -static-libstdc++ -static-libgcc 17 | XA_FLAGS = -I3rd\ Party/directx/include -I3rd\ Party 18 | DS_FLAGS = -DXAUDIO_LIBRARIES_UNAVAILABLE -I3rd\ Party/directx/include 19 | 20 | # Cfg 21 | ifeq ($(BUILD_ARCH),) 22 | GCC_ARCH = $(shell gcc -dumpmachine | sed s/-.*//) 23 | ifeq ($(GCC_ARCH),x86_64) 24 | BUILD_ARCH = x86_64 25 | else 26 | BUILD_ARCH = x86 27 | endif 28 | endif 29 | 30 | ifneq ($(BUILD_DEBUG),YES) 31 | BUILD_DEBUG = NO 32 | DS_PLUGIN_FILE = AziAudioDS8_m.dll 33 | XA_PLUGIN_FILE = AziAudioXA2_m.dll 34 | RESFLAGS = 35 | BASICOPTS = -O2 36 | BUILD_TYPE = Release 37 | else 38 | BUILD_DEBUG = YES 39 | DS_PLUGIN_FILE = AziAudioDS8_md.dll 40 | XA_PLUGIN_FILE = AziAudioXA2_md.dll 41 | RESFLAGS = -D_DEBUG 42 | BASICOPTS = -g -D_DEBUG 43 | BUILD_TYPE = Debug 44 | endif 45 | 46 | # Define the target directories. 47 | #OBJDIR=obj 48 | #BUILDDIR=build 49 | ifeq ($(BUILD_ARCH),x86_64) 50 | FOLDER = $(BUILD_TYPE)_mingw64 51 | else 52 | FOLDER = $(BUILD_TYPE)_mingw32 53 | endif 54 | OBJDIR = build/$(FOLDER)/AziAudio 55 | BUILDDIR = bin/$(FOLDER) 56 | SRCDIR=AziAudio 57 | 58 | all: ds xa 59 | 60 | ds: $(BUILDDIR)/$(DS_PLUGIN_FILE) 61 | 62 | xa: $(BUILDDIR)/$(XA_PLUGIN_FILE) 63 | 64 | directsound: ds 65 | 66 | directsound8: ds 67 | 68 | ds8: ds 69 | 70 | xaudio: xa 71 | 72 | xaudio2: xa 73 | 74 | xa2: xa 75 | 76 | release: all 77 | 78 | #debug: debugvar all 79 | 80 | #debugvar: 81 | # $(eval BASICOPTS := -g -D_DEBUG) 82 | 83 | COMMON_OBJS = \ 84 | $(OBJDIR)/WaveOut.o \ 85 | $(OBJDIR)/ABI_Resample.o \ 86 | $(OBJDIR)/ABI_MixerInterleave.o \ 87 | $(OBJDIR)/ABI_Filters.o \ 88 | $(OBJDIR)/ABI_Envmixer.o \ 89 | $(OBJDIR)/ABI_Buffers.o \ 90 | $(OBJDIR)/ABI_Adpcm.o \ 91 | $(OBJDIR)/ABI3mp3.o \ 92 | $(OBJDIR)/ABI3.o \ 93 | $(OBJDIR)/ABI2.o \ 94 | $(OBJDIR)/ABI1.o \ 95 | $(OBJDIR)/Mupen64plusHLE/musyx.o \ 96 | $(OBJDIR)/Mupen64plusHLE/Mupen64Support.o \ 97 | $(OBJDIR)/Mupen64plusHLE/memory.o \ 98 | $(OBJDIR)/Mupen64plusHLE/audio.o \ 99 | $(OBJDIR)/resource.o 100 | 101 | XA_OBJS = \ 102 | $(OBJDIR)/XA/XAudio2SoundDriver.o \ 103 | $(OBJDIR)/XA/HLEMain.o \ 104 | $(OBJDIR)/XA/SoundDriver.o \ 105 | $(OBJDIR)/XA/main.o 106 | 107 | DS_OBJS = \ 108 | $(OBJDIR)/DS/DirectSoundDriver.o \ 109 | $(OBJDIR)/DS/HLEMain.o \ 110 | $(OBJDIR)/DS/SoundDriver.o \ 111 | $(OBJDIR)/DS/main.o 112 | 113 | 114 | # Link or archive 115 | $(BUILDDIR)/$(XA_PLUGIN_FILE): $(BUILDDIR) $(OBJDIR) $(XA_OBJS) $(COMMON_OBJS) 116 | $(CXX) -shared $(CXXFLAGS) $(CPPFLAGS) -o $@ $(XA_OBJS) $(COMMON_OBJS) $(LDFLAGS) -lole32 117 | 118 | $(BUILDDIR)/$(DS_PLUGIN_FILE): $(BUILDDIR) $(OBJDIR) $(DS_OBJS) $(COMMON_OBJS) 119 | $(CXX) -shared $(CXXFLAGS) $(CPPFLAGS) -o $@ $(DS_OBJS) $(COMMON_OBJS) $(LDFLAGS) -ldsound 120 | 121 | 122 | # Compile source files into .o files 123 | 124 | $(OBJDIR)/XA/XAudio2SoundDriver.o: $(OBJDIR)/XA $(SRCDIR)/XAudio2SoundDriver.cpp 125 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(XA_FLAGS) -o $@ -c $(SRCDIR)/XAudio2SoundDriver.cpp 126 | 127 | $(OBJDIR)/DS/DirectSoundDriver.o: $(OBJDIR)/DS $(SRCDIR)/DirectSoundDriver.cpp 128 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DS_FLAGS) -o $@ -c $(SRCDIR)/DirectSoundDriver.cpp 129 | 130 | $(OBJDIR)/XA/SoundDriver.o: $(OBJDIR)/DS $(SRCDIR)/SoundDriver.cpp 131 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DS_FLAGS) -o $@ -c $(SRCDIR)/SoundDriver.cpp 132 | 133 | $(OBJDIR)/DS/SoundDriver.o: $(OBJDIR)/DS $(SRCDIR)/SoundDriver.cpp 134 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DS_FLAGS) -o $@ -c $(SRCDIR)/SoundDriver.cpp 135 | 136 | $(OBJDIR)/XA/NoSoundDriver.o: $(OBJDIR)/DS $(SRCDIR)/NoSoundDriver.cpp 137 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DS_FLAGS) -o $@ -c $(SRCDIR)/NoSoundDriver.cpp 138 | 139 | $(OBJDIR)/DS/NoSoundDriver.o: $(OBJDIR)/DS $(SRCDIR)/NoSoundDriver.cpp 140 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DS_FLAGS) -o $@ -c $(SRCDIR)/NoSoundDriver.cpp 141 | 142 | $(OBJDIR)/XA/main.o: $(OBJDIR)/XA $(SRCDIR)/main.cpp 143 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(XA_FLAGS) -o $@ -c $(SRCDIR)/main.cpp 144 | 145 | $(OBJDIR)/DS/main.o: $(OBJDIR)/DS $(SRCDIR)/main.cpp 146 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DS_FLAGS) -o $@ -c $(SRCDIR)/main.cpp 147 | 148 | $(OBJDIR)/XA/HLEMain.o: $(OBJDIR)/XA $(SRCDIR)/HLEMain.cpp 149 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(XA_FLAGS) -o $@ -c $(SRCDIR)/HLEMain.cpp 150 | 151 | $(OBJDIR)/DS/HLEMain.o: $(OBJDIR)/DS $(SRCDIR)/HLEMain.cpp 152 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DS_FLAGS) -o $@ -c $(SRCDIR)/HLEMain.cpp 153 | 154 | $(OBJDIR)/WaveOut.o: $(OBJDIR) $(SRCDIR)/WaveOut.cpp 155 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/WaveOut.cpp 156 | 157 | $(OBJDIR)/ABI_Resample.o: $(OBJDIR) $(SRCDIR)/ABI_Resample.cpp 158 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI_Resample.cpp 159 | 160 | $(OBJDIR)/ABI_MixerInterleave.o: $(OBJDIR) $(SRCDIR)/ABI_MixerInterleave.cpp 161 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI_MixerInterleave.cpp 162 | 163 | $(OBJDIR)/ABI_Filters.o: $(OBJDIR) $(SRCDIR)/ABI_Filters.cpp 164 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI_Filters.cpp 165 | 166 | $(OBJDIR)/ABI_Envmixer.o: $(OBJDIR) $(SRCDIR)/ABI_Envmixer.cpp 167 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI_Envmixer.cpp 168 | 169 | $(OBJDIR)/ABI_Buffers.o: $(OBJDIR) $(SRCDIR)/ABI_Buffers.cpp 170 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI_Buffers.cpp 171 | 172 | $(OBJDIR)/ABI_Adpcm.o: $(OBJDIR) $(SRCDIR)/ABI_Adpcm.cpp 173 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI_Adpcm.cpp 174 | 175 | $(OBJDIR)/ABI3mp3.o: $(OBJDIR) $(SRCDIR)/ABI3mp3.cpp 176 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI3mp3.cpp 177 | 178 | $(OBJDIR)/ABI3.o: $(OBJDIR) $(SRCDIR)/ABI3.cpp 179 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI3.cpp 180 | 181 | $(OBJDIR)/ABI2.o: $(OBJDIR) $(SRCDIR)/ABI2.cpp 182 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI2.cpp 183 | 184 | $(OBJDIR)/ABI1.o: $(OBJDIR) $(SRCDIR)/ABI1.cpp 185 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/ABI1.cpp 186 | 187 | $(OBJDIR)/Mupen64plusHLE/musyx.o: $(OBJDIR)/Mupen64plusHLE $(SRCDIR)/Mupen64plusHLE/musyx.c 188 | $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/Mupen64plusHLE/musyx.c 189 | 190 | $(OBJDIR)/Mupen64plusHLE/Mupen64Support.o: $(OBJDIR)/Mupen64plusHLE $(SRCDIR)/Mupen64plusHLE/Mupen64Support.c 191 | $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/Mupen64plusHLE/Mupen64Support.c 192 | 193 | $(OBJDIR)/Mupen64plusHLE/memory.o: $(OBJDIR)/Mupen64plusHLE $(SRCDIR)/Mupen64plusHLE/memory.c 194 | $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/Mupen64plusHLE/memory.c 195 | 196 | $(OBJDIR)/Mupen64plusHLE/audio.o: $(OBJDIR)/Mupen64plusHLE $(SRCDIR)/Mupen64plusHLE/audio.c 197 | $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(SRCDIR)/Mupen64plusHLE/audio.c 198 | 199 | $(OBJDIR)/resource.o: $(OBJDIR) $(SRCDIR)/resource.rc 200 | $(WINDRES) $(RESFLAGS) $(SRCDIR)/resource.rc $@ 201 | 202 | 203 | #### Clean target deletes all generated files #### 204 | clean: 205 | rm -f -r \ 206 | $(BUILDDIR) \ 207 | $(OBJDIR) 208 | 209 | 210 | # Create the target directory (if needed) 211 | $(BUILDDIR): 212 | mkdir -p $@ 213 | 214 | $(OBJDIR): 215 | mkdir -p $@ 216 | 217 | $(OBJDIR)/Mupen64plusHLE: 218 | mkdir -p $@ 219 | 220 | $(OBJDIR)/XA: 221 | mkdir -p $@ 222 | 223 | $(OBJDIR)/DS: 224 | mkdir -p $@ 225 | 226 | # Enable dependency checking 227 | .KEEP_STATE: 228 | .KEEP_STATE_FILE:.make.state 229 | -------------------------------------------------------------------------------- /PropertySheets/Debug.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_ProjectFileVersion>12.0.21005.1 6 | 7 | 8 | 9 | _DEBUG;DEBUG;%(PreprocessorDefinitions) 10 | Disabled 11 | Default 12 | false 13 | Neither 14 | false 15 | false 16 | false 17 | EnableFastChecks 18 | true 19 | MultiThreadedDebug 20 | 21 | 22 | 23 | 24 | 25 | _DEBUG;DEBUG;%(PreprocessorDefinitions) 26 | 27 | 28 | _DEBUG;DEBUG;%(PreprocessorDefinitions) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /PropertySheets/Debug.vsprops: -------------------------------------------------------------------------------- 1 |  2 | 8 | 22 | 26 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /PropertySheets/Default.vsprops: -------------------------------------------------------------------------------- 1 |  2 | 15 | 20 | 69 | 78 | 129 | 154 | 162 | 175 | 183 | 184 | -------------------------------------------------------------------------------- /PropertySheets/Release.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>12.0.21005.1 5 | 6 | 7 | 8 | MinSpace 9 | Default 10 | false 11 | Size 12 | false 13 | false 14 | false 15 | NDEBUG;%(PreprocessorDefinitions) 16 | false 17 | MultiThreaded 18 | 19 | 20 | 21 | 22 | 23 | NDEBUG;%(PreprocessorDefinitions) 24 | 25 | 26 | NDEBUG;%(PreprocessorDefinitions) 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /PropertySheets/Release.vsprops: -------------------------------------------------------------------------------- 1 |  2 | 8 | 21 | 25 | 29 | 33 | 34 | -------------------------------------------------------------------------------- /PropertySheets/Win32.Debug.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <_ProjectFileVersion>12.0.21005.1 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /PropertySheets/Win32.Debug.vsprops: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | -------------------------------------------------------------------------------- /PropertySheets/Win32.Release.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | <_ProjectFileVersion>12.0.21005.1 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /PropertySheets/Win32.Release.vsprops: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | -------------------------------------------------------------------------------- /PropertySheets/Win32.vsprops: -------------------------------------------------------------------------------- 1 |  2 | 7 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /PropertySheets/root.vsprops: -------------------------------------------------------------------------------- 1 |  2 | 7 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AziAudio 2 | ## Azimer's Audio HLE Plugin for N64 emulators 3 | -------------------------------------------------------------------------------- /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%\DirectSoundDriver.cpp^ 30 | %src%\HLEMain.cpp^ 31 | %src%\SoundDriver.cpp^ 32 | %src%\NoSoundDriver.cpp^ 33 | %src%\WaveOut.cpp^ 34 | %src%\XAudio2SoundDriver.cpp^ 35 | %src%\Mupen64plusHLE\audio.c^ 36 | %src%\Mupen64plusHLE\memory.c^ 37 | %src%\Mupen64plusHLE\Mupen64Support.c^ 38 | %src%\Mupen64plusHLE\musyx.c 39 | 40 | %DDK%\bin\x86\rc.exe %incl% /fo %obj%\resource.res %src%\resource.rc 41 | %MSVC%\cl.exe %files% %incl% %C_FLAGS% /link /OUT:AziAudio.dll %LINK_FLAGS% 42 | 43 | pause 44 | -------------------------------------------------------------------------------- /mingw-build.cmd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/project64/AziAudio/6d736fa75eaa78383099f3d49dbbb85b106f0b13/mingw-build.cmd --------------------------------------------------------------------------------