| 1 |
/*************************************************************************** |
| 2 |
cfg.c - description |
| 3 |
------------------- |
| 4 |
begin : Wed May 15 2002 |
| 5 |
copyright : (C) 2002 by Pete Bernert |
| 6 |
email : [email protected] |
| 7 |
***************************************************************************/ |
| 8 |
|
| 9 |
/*************************************************************************** |
| 10 |
* * |
| 11 |
* This program is free software; you can redistribute it and/or modify * |
| 12 |
* it under the terms of the GNU General Public License as published by * |
| 13 |
* the Free Software Foundation; either version 2 of the License, or * |
| 14 |
* (at your option) any later version. See also the license.txt file for * |
| 15 |
* additional informations. * |
| 16 |
* * |
| 17 |
***************************************************************************/ |
| 18 |
|
| 19 |
#include "stdafx.h" |
| 20 |
|
| 21 |
#define _IN_CFG |
| 22 |
|
| 23 |
#include "externals.h" |
| 24 |
|
| 25 |
//////////////////////////////////////////////////////////////////////// |
| 26 |
// WINDOWS CONFIG/ABOUT HANDLING |
| 27 |
//////////////////////////////////////////////////////////////////////// |
| 28 |
|
| 29 |
#include "resource.h" |
| 30 |
|
| 31 |
//////////////////////////////////////////////////////////////////////// |
| 32 |
// simple about dlg handler |
| 33 |
//////////////////////////////////////////////////////////////////////// |
| 34 |
|
| 35 |
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 36 |
{ |
| 37 |
switch(uMsg) |
| 38 |
{ |
| 39 |
case WM_COMMAND: |
| 40 |
{ |
| 41 |
switch(LOWORD(wParam)) |
| 42 |
{case IDOK: EndDialog(hW,TRUE);return TRUE;} |
| 43 |
} |
| 44 |
} |
| 45 |
return FALSE; |
| 46 |
} |
| 47 |
|
| 48 |
//////////////////////////////////////////////////////////////////////// |
| 49 |
// READ CONFIG: from win registry |
| 50 |
//////////////////////////////////////////////////////////////////////// |
| 51 |
|
| 52 |
void ReadConfig(void) |
| 53 |
{ |
| 54 |
HKEY myKey; |
| 55 |
DWORD temp; |
| 56 |
DWORD type; |
| 57 |
DWORD size; |
| 58 |
|
| 59 |
iVolume=1; // init vars |
| 60 |
iXAPitch=1; |
| 61 |
iUseTimer=2; |
| 62 |
iSPUIRQWait=1; |
| 63 |
iDebugMode=0; |
| 64 |
iRecordMode=0; |
| 65 |
iUseReverb=2; |
| 66 |
iUseInterpolation=2; |
| 67 |
iDisStereo=0; |
| 68 |
iFreqResponse=0; |
| 69 |
|
| 70 |
if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SPU\\DFSound",0,KEY_ALL_ACCESS,&myKey)==ERROR_SUCCESS) |
| 71 |
{ |
| 72 |
size = 4; |
| 73 |
if(RegQueryValueEx(myKey,"Volume",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 74 |
iVolume=(int)temp; |
| 75 |
size = 4; |
| 76 |
if(RegQueryValueEx(myKey,"XAPitch",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 77 |
iXAPitch=(int)temp; |
| 78 |
size = 4; |
| 79 |
if(RegQueryValueEx(myKey,"UseTimer",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 80 |
iUseTimer=(int)temp; |
| 81 |
size = 4; |
| 82 |
if(RegQueryValueEx(myKey,"SPUIRQWait",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 83 |
iSPUIRQWait=(int)temp; |
| 84 |
size = 4; |
| 85 |
if(RegQueryValueEx(myKey,"FreqResponse",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 86 |
iFreqResponse=(int)temp; |
| 87 |
size = 4; |
| 88 |
if(RegQueryValueEx(myKey,"DebugMode",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 89 |
iDebugMode=(int)temp; |
| 90 |
size = 4; |
| 91 |
if(RegQueryValueEx(myKey,"RecordMode",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 92 |
iRecordMode=(int)temp; |
| 93 |
size = 4; |
| 94 |
if(RegQueryValueEx(myKey,"UseReverb",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 95 |
iUseReverb=(int)temp; |
| 96 |
size = 4; |
| 97 |
if(RegQueryValueEx(myKey,"UseInterpolation",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 98 |
iUseInterpolation=(int)temp; |
| 99 |
size = 4; |
| 100 |
if(RegQueryValueEx(myKey,"DisStereo",0,&type,(LPBYTE)&temp,&size)==ERROR_SUCCESS) |
| 101 |
iDisStereo=(int)temp; |
| 102 |
|
| 103 |
RegCloseKey(myKey); |
| 104 |
} |
| 105 |
|
| 106 |
if(iUseTimer>2) iUseTimer=2; // some checks |
| 107 |
if(iVolume<1) iVolume=1; |
| 108 |
if(iVolume>5) iVolume=5; |
| 109 |
} |
| 110 |
|
| 111 |
//////////////////////////////////////////////////////////////////////// |
| 112 |
// WRITE CONFIG: in win registry |
| 113 |
//////////////////////////////////////////////////////////////////////// |
| 114 |
|
| 115 |
void WriteConfig(void) |
| 116 |
{ |
| 117 |
HKEY myKey; |
| 118 |
DWORD myDisp; |
| 119 |
DWORD temp; |
| 120 |
|
| 121 |
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SPU\\DFSound",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&myKey,&myDisp); |
| 122 |
temp=iVolume; |
| 123 |
RegSetValueEx(myKey,"Volume",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 124 |
temp=iXAPitch; |
| 125 |
RegSetValueEx(myKey,"XAPitch",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 126 |
temp=iUseTimer; |
| 127 |
RegSetValueEx(myKey,"UseTimer",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 128 |
temp=iSPUIRQWait; |
| 129 |
RegSetValueEx(myKey,"SPUIRQWait",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 130 |
temp=iFreqResponse; |
| 131 |
RegSetValueEx(myKey,"FreqResponse",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 132 |
temp=iDebugMode; |
| 133 |
RegSetValueEx(myKey,"DebugMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 134 |
temp=iRecordMode; |
| 135 |
RegSetValueEx(myKey,"RecordMode",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 136 |
temp=iUseReverb; |
| 137 |
RegSetValueEx(myKey,"UseReverb",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 138 |
temp=iUseInterpolation; |
| 139 |
RegSetValueEx(myKey,"UseInterpolation",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 140 |
temp=iDisStereo; |
| 141 |
RegSetValueEx(myKey,"DisStereo",0,REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 142 |
|
| 143 |
RegCloseKey(myKey); |
| 144 |
} |
| 145 |
|
| 146 |
//////////////////////////////////////////////////////////////////////// |
| 147 |
// INIT WIN CFG DIALOG |
| 148 |
//////////////////////////////////////////////////////////////////////// |
| 149 |
|
| 150 |
BOOL OnInitDSoundDialog(HWND hW) |
| 151 |
{ |
| 152 |
HWND hWC; |
| 153 |
|
| 154 |
ReadConfig(); |
| 155 |
|
| 156 |
if(iXAPitch) CheckDlgButton(hW,IDC_XAPITCH,TRUE); |
| 157 |
|
| 158 |
hWC=GetDlgItem(hW,IDC_VOLUME); |
| 159 |
ComboBox_AddString(hWC, "None"); |
| 160 |
ComboBox_AddString(hWC, "Low"); |
| 161 |
ComboBox_AddString(hWC, "Medium"); |
| 162 |
ComboBox_AddString(hWC, "Loud"); |
| 163 |
ComboBox_AddString(hWC, "Loudest"); |
| 164 |
ComboBox_SetCurSel(hWC,5-iVolume); |
| 165 |
|
| 166 |
if(iSPUIRQWait) CheckDlgButton(hW,IDC_IRQWAIT,TRUE); |
| 167 |
if(iDebugMode) CheckDlgButton(hW,IDC_DEBUGMODE,TRUE); |
| 168 |
if(iRecordMode) CheckDlgButton(hW,IDC_RECORDMODE,TRUE); |
| 169 |
if(iDisStereo) CheckDlgButton(hW,IDC_DISSTEREO,TRUE); |
| 170 |
if(iFreqResponse) CheckDlgButton(hW,IDC_FREQRESPONSE,TRUE); |
| 171 |
|
| 172 |
hWC=GetDlgItem(hW,IDC_USETIMER); |
| 173 |
ComboBox_AddString(hWC, "Fast mode (thread, less compatible spu timing)"); |
| 174 |
ComboBox_AddString(hWC, "High compatibility mode (timer event, slower)"); |
| 175 |
ComboBox_AddString(hWC, "Use SPUasync (must be supported by the emu)"); |
| 176 |
ComboBox_SetCurSel(hWC,iUseTimer); |
| 177 |
|
| 178 |
hWC=GetDlgItem(hW,IDC_USEREVERB); |
| 179 |
ComboBox_AddString(hWC, "No reverb (fastest)"); |
| 180 |
ComboBox_AddString(hWC, "Simple reverb (fakes the most common effects)"); |
| 181 |
ComboBox_AddString(hWC, "PSX reverb (best quality)"); |
| 182 |
ComboBox_SetCurSel(hWC,iUseReverb); |
| 183 |
|
| 184 |
hWC=GetDlgItem(hW,IDC_INTERPOL); |
| 185 |
ComboBox_AddString(hWC, "None (fastest)"); |
| 186 |
ComboBox_AddString(hWC, "Simple interpolation"); |
| 187 |
ComboBox_AddString(hWC, "Gaussian interpolation (good quality)"); |
| 188 |
ComboBox_AddString(hWC, "Cubic interpolation (better treble)"); |
| 189 |
ComboBox_SetCurSel(hWC,iUseInterpolation); |
| 190 |
|
| 191 |
return TRUE; |
| 192 |
} |
| 193 |
|
| 194 |
//////////////////////////////////////////////////////////////////////// |
| 195 |
// WIN CFG DLG OK |
| 196 |
//////////////////////////////////////////////////////////////////////// |
| 197 |
|
| 198 |
void OnDSoundOK(HWND hW) |
| 199 |
{ |
| 200 |
HWND hWC; |
| 201 |
|
| 202 |
if(IsDlgButtonChecked(hW,IDC_XAPITCH)) |
| 203 |
iXAPitch=1; else iXAPitch=0; |
| 204 |
|
| 205 |
hWC=GetDlgItem(hW,IDC_VOLUME); |
| 206 |
iVolume=5-ComboBox_GetCurSel(hWC); |
| 207 |
|
| 208 |
hWC=GetDlgItem(hW,IDC_USETIMER); |
| 209 |
iUseTimer=ComboBox_GetCurSel(hWC); |
| 210 |
|
| 211 |
hWC=GetDlgItem(hW,IDC_USEREVERB); |
| 212 |
iUseReverb=ComboBox_GetCurSel(hWC); |
| 213 |
|
| 214 |
hWC=GetDlgItem(hW,IDC_INTERPOL); |
| 215 |
iUseInterpolation=ComboBox_GetCurSel(hWC); |
| 216 |
|
| 217 |
if(IsDlgButtonChecked(hW,IDC_IRQWAIT)) |
| 218 |
iSPUIRQWait=1; else iSPUIRQWait=0; |
| 219 |
|
| 220 |
if(IsDlgButtonChecked(hW,IDC_DEBUGMODE)) |
| 221 |
iDebugMode=1; else iDebugMode=0; |
| 222 |
|
| 223 |
if(IsDlgButtonChecked(hW,IDC_RECORDMODE)) |
| 224 |
iRecordMode=1; else iRecordMode=0; |
| 225 |
|
| 226 |
if(IsDlgButtonChecked(hW,IDC_DISSTEREO)) |
| 227 |
iDisStereo=1; else iDisStereo=0; |
| 228 |
|
| 229 |
if(IsDlgButtonChecked(hW,IDC_FREQRESPONSE)) |
| 230 |
iFreqResponse=1; else iFreqResponse=0; |
| 231 |
|
| 232 |
WriteConfig(); // write registry |
| 233 |
|
| 234 |
EndDialog(hW,TRUE); |
| 235 |
} |
| 236 |
|
| 237 |
//////////////////////////////////////////////////////////////////////// |
| 238 |
// WIN CFG DLG CANCEL |
| 239 |
//////////////////////////////////////////////////////////////////////// |
| 240 |
|
| 241 |
void OnDSoundCancel(HWND hW) |
| 242 |
{ |
| 243 |
EndDialog(hW,FALSE); |
| 244 |
} |
| 245 |
|
| 246 |
//////////////////////////////////////////////////////////////////////// |
| 247 |
// WIN CFG PROC |
| 248 |
//////////////////////////////////////////////////////////////////////// |
| 249 |
|
| 250 |
BOOL CALLBACK DSoundDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 251 |
{ |
| 252 |
switch(uMsg) |
| 253 |
{ |
| 254 |
case WM_INITDIALOG: |
| 255 |
return OnInitDSoundDialog(hW); |
| 256 |
|
| 257 |
case WM_COMMAND: |
| 258 |
{ |
| 259 |
switch(LOWORD(wParam)) |
| 260 |
{ |
| 261 |
case IDCANCEL: OnDSoundCancel(hW);return TRUE; |
| 262 |
case IDOK: OnDSoundOK(hW); return TRUE; |
| 263 |
} |
| 264 |
} |
| 265 |
} |
| 266 |
return FALSE; |
| 267 |
} |