SPU2null reformat

This commit is contained in:
Clang Format 2016-08-24 23:15:05 +02:00 committed by Gregory Hainaut
parent 67e7d63f0f
commit e3a2ad03bc
5 changed files with 1224 additions and 1270 deletions

View File

@ -23,14 +23,16 @@ using namespace std;
extern string s_strIniPath;
PluginConf Ini;
EXPORT_C_(void) SPU2configure()
EXPORT_C_(void)
SPU2configure()
{
LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
SaveConfig();
}
EXPORT_C_(void) SPU2about()
EXPORT_C_(void)
SPU2about()
{
//SysMessage("%s %d.%d", libraryName, version, build);
SysMessage("SPU2null: A simple null plugin.");
@ -40,10 +42,9 @@ void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
if (!Ini.Open(iniFile, READ_FILE))
{
if (!Ini.Open(iniFile, READ_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
SaveConfig();//save and return
SaveConfig(); //save and return
return;
}
@ -55,8 +56,7 @@ void SaveConfig()
{
const std::string iniFile(s_strIniPath + "/Spu2null.ini");
if (!Ini.Open(iniFile, WRITE_FILE))
{
if (!Ini.Open(iniFile, WRITE_FILE)) {
printf("failed to open %s\n", iniFile.c_str());
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -24,8 +24,7 @@
#include <stdio.h>
#include <string.h>
extern "C"
{
extern "C" {
#define SPU2defs
#include "PS2Edefs.h"
}
@ -39,17 +38,17 @@ extern "C"
#ifdef _MSC_VER
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
#else
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
#endif
extern FILE *spu2Log;
extern FILE* spu2Log;
#define SPU2_LOG __Log //debug mode
extern const u8 version;
extern const u8 revision;
extern const u8 build;
extern const u32 minor;
extern char *libraryName;
extern char* libraryName;
typedef struct
{
@ -58,10 +57,10 @@ typedef struct
extern Config conf;
void __Log(char *fmt, ...);
void __Log(char* fmt, ...);
void SaveConfig();
void LoadConfig();
void SysMessage(char *fmt, ...);
void SysMessage(char* fmt, ...);
////////////////////
// SPU2 Registers //
@ -135,18 +134,19 @@ void SysMessage(char *fmt, ...);
#define SPDIF_MODE 0x07C6
#define SPDIF_MEDIA 0x07C8
#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem) & 0xffff])
#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem) & 0xffff])
#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem)&0xffff])
#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem)&0xffff])
//#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff])
//#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff])
#define IRQINFO spu2Ru16(REG_IRQINFO)
#define SPU2_GET32BIT(lo,hi) (((u32)(spu2Ru16(hi)&0x3f)<<16)|(u32)spu2Ru16(lo))
#define SPU2_SET32BIT(value, lo, hi) { \
spu2Ru16(hi) = ((value)>>16)&0x3f; \
#define SPU2_GET32BIT(lo, hi) (((u32)(spu2Ru16(hi) & 0x3f) << 16) | (u32)spu2Ru16(lo))
#define SPU2_SET32BIT(value, lo, hi) \
{ \
spu2Ru16(hi) = ((value) >> 16) & 0x3f; \
spu2Ru16(lo) = (value)&0xffff; \
} \
}
#define C0_IRQA SPU2_GET32BIT(REG_C0_IRQA_LO, REG_C0_IRQA_HI)
#define C1_IRQA SPU2_GET32BIT(REG_C1_IRQA_LO, REG_C1_IRQA_HI)
@ -178,12 +178,14 @@ struct _SPU_VOICE
{
union
{
struct {
struct
{
u16 Vol : 14;
u16 Inverted : 1;
u16 Sweep0 : 1;
} vol;
struct {
struct
{
u16 Vol : 7;
u16 res1 : 5;
u16 Inverted : 1;
@ -192,7 +194,7 @@ struct _SPU_VOICE
u16 Sweep1 : 1; // always one
} sweep;
u16 word;
} left, right;
} left, right;
u16 pitch : 14; // 1000 - no pitch, 2000 - pitch + 1, etc
u16 res0 : 2;
@ -234,7 +236,7 @@ struct ADSRInfoEx
#define NSSIZE 48 // ~ 1 ms of data
#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting
#define NSPACKETS 4
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED)-4*sizeof(void*))
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED) - 4 * sizeof(void*))
struct VOICE_PROCESSED
{
@ -275,14 +277,14 @@ struct VOICE_PROCESSED
// Sound Buffers //
///////////////////
u8* pStart; // start and end addresses
u8* pLoop, *pCurr;
u8 *pLoop, *pCurr;
_SPU_VOICE* pvoice;
};
struct ADMA
{
u16 * MemAddr;
u16* MemAddr;
s32 IntPointer;
s32 Index;
s32 AmountLeft;

View File

@ -21,46 +21,45 @@ extern HINSTANCE hInst;
void SaveConfig()
{
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\spu2null.ini");
sprintf(szValue,"%u",Conf1->Log);
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
sprintf(szValue, "%u", Conf1->Log);
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
}
void LoadConfig() {
FILE *fp;
void LoadConfig()
{
FILE* fp;
Config *Conf1 = &conf;
char *szTemp;
Config* Conf1 = &conf;
char* szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
if (!szTemp)
return;
strcpy(szTemp, "\\inis\\spu2null.ini");
fp=fopen("inis\\usbnull.ini","rt");//check if usbnull.ini really exists
if (!fp)
{
CreateDirectory("inis",NULL);
fp = fopen("inis\\usbnull.ini", "rt"); //check if usbnull.ini really exists
if (!fp) {
CreateDirectory("inis", NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
SaveConfig();//save and return
return ;
conf.Log = 0; //default value
SaveConfig(); //save and return
return;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return ;
return;
}

View File

@ -22,33 +22,37 @@
HINSTANCE hInst;
void SysMessage(char *fmt, ...) {
void SysMessage(char* fmt, ...)
{
va_list list;
char tmp[512];
va_start(list,fmt);
vsprintf(tmp,fmt,list);
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
MessageBox(0, tmp, "SPU2NULL Msg", 0);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
switch (uMsg) {
case WM_INITDIALOG:
LoadConfig();
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
if (conf.Log)
CheckDlgButton(hW, IDC_LOGGING, TRUE);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOGGING))
conf.Log = 1;
else conf.Log = 0;
else
conf.Log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
@ -57,13 +61,14 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
@ -72,15 +77,16 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
return FALSE;
}
void CALLBACK SPU2configure() {
void CALLBACK SPU2configure()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
void CALLBACK SPU2about() {
void CALLBACK SPU2about()
{
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
@ -89,8 +95,8 @@ void CALLBACK SPU2about() {
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
LPVOID lpReserved)
{
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}