-/***************************************************************************\r
- cfg.c - description\r
- -------------------\r
- begin : Wed May 15 2002\r
- copyright : (C) 2002 by Pete Bernert\r
- email : BlackDove@addcom.de\r
- ***************************************************************************/\r
-/***************************************************************************\r
- * *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or *\r
- * (at your option) any later version. See also the license.txt file for *\r
- * additional informations. *\r
- * *\r
- ***************************************************************************/\r
-\r
-#include "stdafx.h"\r
-\r
-#define _IN_CFG\r
-\r
-#include "externals.h"\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// LINUX CONFIG/ABOUT HANDLING\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-#include <unistd.h>\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// START EXTERNAL CFG TOOL\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-void StartCfgTool(char * pCmdLine)\r
-{\r
- FILE * cf;\r
- char filename[255];\r
-\r
- strcpy(filename,"cfgDFSound");\r
- cf=fopen(filename,"rb");\r
- if(cf!=NULL)\r
- {\r
- fclose(cf);\r
- if(fork()==0)\r
- {\r
- execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL);\r
- exit(0);\r
- }\r
- }\r
- else\r
- {\r
- strcpy(filename,"cfg/cfgDFSound");\r
- cf=fopen(filename,"rb");\r
- if(cf!=NULL)\r
- {\r
- fclose(cf);\r
- if(fork()==0)\r
- {\r
- chdir("cfg");\r
- execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL);\r
- exit(0);\r
- }\r
- }\r
- else\r
- {\r
- sprintf(filename,"%s/cfgDFSound",getenv("HOME"));\r
- cf=fopen(filename,"rb");\r
- if(cf!=NULL)\r
- {\r
- fclose(cf);\r
- if(fork()==0)\r
- {\r
- chdir(getenv("HOME"));\r
- execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL);\r
- exit(0);\r
- }\r
- }\r
- else printf("Sound error: cfgDFSound not found!\n");\r
- }\r
- }\r
-}\r
-\r
-/////////////////////////////////////////////////////////\r
-// READ LINUX CONFIG FILE\r
-/////////////////////////////////////////////////////////\r
-\r
-static void ReadConfigFile(void)\r
-{\r
- FILE *in;char t[256];int len;\r
- char * pB, * p;\r
-\r
- strcpy(t,"dfsound.cfg");\r
- in = fopen(t,"rb"); \r
- if(!in) \r
- {\r
- strcpy(t,"cfg/dfsound.cfg");\r
- in = fopen(t,"rb"); \r
- if(!in) \r
- {\r
- sprintf(t,"%s/dfsound.cfg",getenv("HOME")); \r
- in = fopen(t,"rb"); \r
- if(!in) return;\r
- }\r
- }\r
-\r
- pB = (char *)malloc(32767);\r
- memset(pB,0,32767);\r
-\r
- len = fread(pB, 1, 32767, in);\r
- fclose(in);\r
-\r
- strcpy(t,"\nVolume");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iVolume=4-atoi(p+len);\r
- if(iVolume<1) iVolume=1;\r
- if(iVolume>4) iVolume=4;\r
-\r
- strcpy(t,"\nXAPitch");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
- if(p) iXAPitch=atoi(p+len);\r
- if(iXAPitch<0) iXAPitch=0;\r
- if(iXAPitch>1) iXAPitch=1;\r
-\r
- strcpy(t,"\nHighCompMode");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
- if(p) iUseTimer=atoi(p+len); \r
- if(iUseTimer<0) iUseTimer=0; \r
- // note: timer mode 1 (win time events) is not supported\r
- // in linux. But timer mode 2 (spuupdate) is safe to use.\r
- if(iUseTimer) iUseTimer=2; \r
-\r
- strcpy(t,"\nSPUIRQWait");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
- if(p) iSPUIRQWait=atoi(p+len); \r
- if(iSPUIRQWait<0) iSPUIRQWait=0; \r
- if(iSPUIRQWait>1) iSPUIRQWait=1; \r
-\r
- strcpy(t,"\nUseReverb");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
- if(p) iUseReverb=atoi(p+len); \r
- if(iUseReverb<0) iUseReverb=0; \r
- if(iUseReverb>2) iUseReverb=2; \r
-\r
- strcpy(t,"\nUseInterpolation");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
- if(p) iUseInterpolation=atoi(p+len); \r
- if(iUseInterpolation<0) iUseInterpolation=0; \r
- if(iUseInterpolation>3) iUseInterpolation=3; \r
-\r
- free(pB);\r
-}\r
-\r
-/////////////////////////////////////////////////////////\r
-// READ CONFIG called by spu funcs\r
-/////////////////////////////////////////////////////////\r
-\r
-void ReadConfigSPU(void)\r
-{\r
- iVolume=2;\r
- iXAPitch=0;\r
- iSPUIRQWait=0;\r
- iUseTimer=2;\r
- iUseReverb=2;\r
- iUseInterpolation=2;\r
-\r
- ReadConfigFile();\r
-}\r