drc: merge Ari64's patch: 14_dont_save_or_restore_temporary
[pcsx_rearmed.git] / plugins / dfsound / cfg.c
CommitLineData
ef79bbde
P
1/***************************************************************************\r
2 cfg.c - description\r
3 -------------------\r
4 begin : Wed May 15 2002\r
5 copyright : (C) 2002 by Pete Bernert\r
6 email : BlackDove@addcom.de\r
7 ***************************************************************************/\r
8/***************************************************************************\r
9 * *\r
10 * This program is free software; you can redistribute it and/or modify *\r
11 * it under the terms of the GNU General Public License as published by *\r
12 * the Free Software Foundation; either version 2 of the License, or *\r
13 * (at your option) any later version. See also the license.txt file for *\r
14 * additional informations. *\r
15 * *\r
16 ***************************************************************************/\r
17\r
18#include "stdafx.h"\r
19\r
20#define _IN_CFG\r
21\r
22#include "externals.h"\r
23\r
24////////////////////////////////////////////////////////////////////////\r
25// LINUX CONFIG/ABOUT HANDLING\r
26////////////////////////////////////////////////////////////////////////\r
27\r
28#include <unistd.h>\r
29\r
30////////////////////////////////////////////////////////////////////////\r
31// START EXTERNAL CFG TOOL\r
32////////////////////////////////////////////////////////////////////////\r
33\r
34void StartCfgTool(char * pCmdLine)\r
35{\r
36 FILE * cf;\r
37 char filename[255];\r
38\r
39 strcpy(filename,"cfgDFSound");\r
40 cf=fopen(filename,"rb");\r
41 if(cf!=NULL)\r
42 {\r
43 fclose(cf);\r
44 if(fork()==0)\r
45 {\r
46 execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL);\r
47 exit(0);\r
48 }\r
49 }\r
50 else\r
51 {\r
52 strcpy(filename,"cfg/cfgDFSound");\r
53 cf=fopen(filename,"rb");\r
54 if(cf!=NULL)\r
55 {\r
56 fclose(cf);\r
57 if(fork()==0)\r
58 {\r
59 chdir("cfg");\r
60 execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL);\r
61 exit(0);\r
62 }\r
63 }\r
64 else\r
65 {\r
66 sprintf(filename,"%s/cfgDFSound",getenv("HOME"));\r
67 cf=fopen(filename,"rb");\r
68 if(cf!=NULL)\r
69 {\r
70 fclose(cf);\r
71 if(fork()==0)\r
72 {\r
73 chdir(getenv("HOME"));\r
74 execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL);\r
75 exit(0);\r
76 }\r
77 }\r
78 else printf("Sound error: cfgDFSound not found!\n");\r
79 }\r
80 }\r
81}\r
82\r
83/////////////////////////////////////////////////////////\r
84// READ LINUX CONFIG FILE\r
85/////////////////////////////////////////////////////////\r
86\r
e906c010 87static void ReadConfigFile(void)\r
ef79bbde
P
88{\r
89 FILE *in;char t[256];int len;\r
90 char * pB, * p;\r
91\r
92 strcpy(t,"dfsound.cfg");\r
93 in = fopen(t,"rb"); \r
94 if(!in) \r
95 {\r
96 strcpy(t,"cfg/dfsound.cfg");\r
97 in = fopen(t,"rb"); \r
98 if(!in) \r
99 {\r
100 sprintf(t,"%s/dfsound.cfg",getenv("HOME")); \r
101 in = fopen(t,"rb"); \r
102 if(!in) return;\r
103 }\r
104 }\r
105\r
106 pB = (char *)malloc(32767);\r
107 memset(pB,0,32767);\r
108\r
109 len = fread(pB, 1, 32767, in);\r
110 fclose(in);\r
111\r
112 strcpy(t,"\nVolume");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
113 if(p) iVolume=4-atoi(p+len);\r
114 if(iVolume<1) iVolume=1;\r
115 if(iVolume>4) iVolume=4;\r
116\r
117 strcpy(t,"\nXAPitch");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
118 if(p) iXAPitch=atoi(p+len);\r
119 if(iXAPitch<0) iXAPitch=0;\r
120 if(iXAPitch>1) iXAPitch=1;\r
121\r
122 strcpy(t,"\nHighCompMode");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
123 if(p) iUseTimer=atoi(p+len); \r
124 if(iUseTimer<0) iUseTimer=0; \r
125 // note: timer mode 1 (win time events) is not supported\r
126 // in linux. But timer mode 2 (spuupdate) is safe to use.\r
127 if(iUseTimer) iUseTimer=2; \r
128\r
129 strcpy(t,"\nSPUIRQWait");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
130 if(p) iSPUIRQWait=atoi(p+len); \r
131 if(iSPUIRQWait<0) iSPUIRQWait=0; \r
132 if(iSPUIRQWait>1) iSPUIRQWait=1; \r
133\r
134 strcpy(t,"\nUseReverb");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
135 if(p) iUseReverb=atoi(p+len); \r
136 if(iUseReverb<0) iUseReverb=0; \r
137 if(iUseReverb>2) iUseReverb=2; \r
138\r
139 strcpy(t,"\nUseInterpolation");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
140 if(p) iUseInterpolation=atoi(p+len); \r
141 if(iUseInterpolation<0) iUseInterpolation=0; \r
142 if(iUseInterpolation>3) iUseInterpolation=3; \r
143\r
ef79bbde
P
144 free(pB);\r
145}\r
146\r
147/////////////////////////////////////////////////////////\r
148// READ CONFIG called by spu funcs\r
149/////////////////////////////////////////////////////////\r
150\r
e906c010 151void ReadConfigSPU(void)\r
ef79bbde
P
152{\r
153 iVolume=2;\r
154 iXAPitch=0;\r
367b1b93 155 iSPUIRQWait=0;\r
ef79bbde
P
156 iUseTimer=2;\r
157 iUseReverb=2;\r
158 iUseInterpolation=2;\r
ef79bbde
P
159\r
160 ReadConfigFile();\r
161}\r