palcfg.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 4; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009-2011, Wei Mingzhi <whistler_wmz@users.sf.net>.
  4. // Copyright (c) 2011-2017, SDLPAL development team.
  5. // All rights reserved.
  6. //
  7. // This file is part of SDLPAL.
  8. //
  9. // SDLPAL is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation, either version 3 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. //
  22. // palcfg.c: Configuration definition.
  23. // @Author: Lou Yihua <louyihua@21cn.com>, 2016.
  24. //
  25. #include "global.h"
  26. #include "palcfg.h"
  27. #include "util.h"
  28. #include "resampler.h"
  29. #include <stdint.h>
  30. #if !defined(PAL_HAS_TOUCH)
  31. #define PAL_HAS_TOUCH 0
  32. #endif
  33. #define MAKE_VALUE(defv, minv, maxv) {(LPCSTR)(defv)}, {(LPCSTR)(minv)}, {(LPCSTR)(maxv)}
  34. static const ConfigItem gConfigItems[PALCFG_ALL_MAX] = {
  35. { PALCFG_FULLSCREEN, PALCFG_BOOLEAN, "FullScreen", 10, MAKE_VALUE(FALSE, FALSE, TRUE) },
  36. { PALCFG_KEEPASPECTRATIO, PALCFG_BOOLEAN, "KeepAspectRatio", 15, MAKE_VALUE(TRUE, FALSE, TRUE) },
  37. { PALCFG_LAUNCHSETTING, PALCFG_BOOLEAN, "LaunchSetting", 13, MAKE_VALUE(TRUE, FALSE, TRUE) },
  38. { PALCFG_STEREO, PALCFG_BOOLEAN, "Stereo", 6, MAKE_VALUE(TRUE, FALSE, TRUE) }, // Default for stereo audio
  39. { PALCFG_USEEMBEDDEDFONTS, PALCFG_BOOLEAN, "UseEmbeddedFonts", 16, MAKE_VALUE(TRUE, FALSE, TRUE) }, // Default for using embedded fonts in DOS version
  40. { PALCFG_USESURROUNDOPL, PALCFG_BOOLEAN, "UseSurroundOPL", 14, MAKE_VALUE(TRUE, FALSE, TRUE) }, // Default for using surround opl
  41. { PALCFG_USETOUCHOVERLAY, PALCFG_BOOLEAN, "UseTouchOverlay", 15, MAKE_VALUE(PAL_HAS_TOUCH, FALSE, TRUE) },
  42. { PALCFG_SURROUNDOPLOFFSET, PALCFG_INTEGER, "SurroundOPLOffset", 17, MAKE_VALUE(384, INT32_MIN, INT32_MAX) },
  43. { PALCFG_AUDIOBUFFERSIZE, PALCFG_UNSIGNED, "AudioBufferSize", 15, MAKE_VALUE(PAL_AUDIO_DEFAULT_BUFFER_SIZE, 2, 32768) },
  44. { PALCFG_CODEPAGE, PALCFG_UNSIGNED, "CodePage", 8, MAKE_VALUE(CP_BIG5, CP_MIN, CP_MAX - 1) }, // Default for BIG5
  45. { PALCFG_OPLSAMPLERATE, PALCFG_UNSIGNED, "OPLSampleRate", 13, MAKE_VALUE(49716, 0, UINT32_MAX) },
  46. { PALCFG_RESAMPLEQUALITY, PALCFG_UNSIGNED, "ResampleQuality", 15, MAKE_VALUE(RESAMPLER_QUALITY_MAX, RESAMPLER_QUALITY_MIN, RESAMPLER_QUALITY_MAX) }, // Default for best quality
  47. { PALCFG_SAMPLERATE, PALCFG_UNSIGNED, "SampleRate", 10, MAKE_VALUE(44100, 0, PAL_MAX_SAMPLERATE) },
  48. { PALCFG_MUSICVOLUME, PALCFG_UNSIGNED, "MusicVolume", 11, MAKE_VALUE(PAL_MAX_VOLUME, 0, PAL_MAX_VOLUME) }, // Default for maximum volume
  49. { PALCFG_SOUNDVOLUME, PALCFG_UNSIGNED, "SoundVolume", 11, MAKE_VALUE(PAL_MAX_VOLUME, 0, PAL_MAX_VOLUME) }, // Default for maximum volume
  50. { PALCFG_WINDOWHEIGHT, PALCFG_UNSIGNED, "WindowHeight", 12, MAKE_VALUE(PAL_DEFAULT_WINDOW_HEIGHT, 0, UINT32_MAX) },
  51. { PALCFG_WINDOWWIDTH, PALCFG_UNSIGNED, "WindowWidth", 11, MAKE_VALUE(PAL_DEFAULT_WINDOW_WIDTH, 0, UINT32_MAX) },
  52. { PALCFG_CD, PALCFG_STRING, "CD", 2, MAKE_VALUE("OGG", NULL, NULL) },
  53. { PALCFG_GAMEPATH, PALCFG_STRING, "GamePath", 8, MAKE_VALUE(NULL, NULL, NULL) },
  54. { PALCFG_SAVEPATH, PALCFG_STRING, "SavePath", 8, MAKE_VALUE(NULL, NULL, NULL) },
  55. { PALCFG_MESSAGEFILE, PALCFG_STRING, "MessageFileName", 15, MAKE_VALUE(NULL, NULL, NULL) },
  56. { PALCFG_BDFFILE, PALCFG_STRING, "BDFFileName", 11, MAKE_VALUE(NULL, NULL, NULL) },
  57. { PALCFG_MUSIC, PALCFG_STRING, "Music", 5, MAKE_VALUE("RIX", NULL, NULL) },
  58. { PALCFG_OPL, PALCFG_STRING, "OPL", 3, MAKE_VALUE("DOSBOX", NULL, NULL) },
  59. { PALCFG_RIXEXTRAINIT, PALCFG_STRING, "RIXExtraInit", 12, MAKE_VALUE(NULL, NULL, NULL) },
  60. { PALCFG_CLIMIDIPLAYER, PALCFG_STRING, "CLIMIDIPlayer", 13, MAKE_VALUE(NULL, NULL, NULL) },
  61. };
  62. static char * ParseStringValue(const char *sValue, char *original)
  63. {
  64. int n = strlen(sValue);
  65. while (n > 0 && isspace(sValue[n - 1])) n--;
  66. if (n > 0)
  67. {
  68. char *newval = (char *)realloc(original, n + 1);
  69. memcpy(newval, sValue, n);
  70. newval[n] = '\0';
  71. return newval;
  72. }
  73. return original;
  74. }
  75. BOOL
  76. PAL_ParseConfigLine(
  77. const char * line,
  78. const ConfigItem ** ppItem,
  79. ConfigValue * pValue
  80. )
  81. {
  82. //
  83. // Skip leading spaces
  84. //
  85. while (*line && isspace(*line)) line++;
  86. //
  87. // Skip comments
  88. //
  89. if (*line && *line != '#')
  90. {
  91. const char *ptr;
  92. if ((ptr = strchr(line, '=')) != NULL)
  93. {
  94. const char *end = ptr++;
  95. //
  96. // Skip tailing spaces
  97. //
  98. while (end > line && isspace(end[-1])) end--;
  99. int len = end - line;
  100. for (int i = 0; i < sizeof(gConfigItems) / sizeof(ConfigItem); i++)
  101. {
  102. if (gConfigItems[i].NameLength == len &&
  103. SDL_strncasecmp(line, gConfigItems[i].Name, len) == 0)
  104. {
  105. if (ppItem) *ppItem = &gConfigItems[i];
  106. if (pValue)
  107. {
  108. switch (gConfigItems[i].Type)
  109. {
  110. case PALCFG_UNSIGNED:
  111. sscanf(ptr, "%u", &pValue->uValue);
  112. if (pValue->uValue < gConfigItems[i].MinValue.uValue)
  113. pValue->uValue = gConfigItems[i].MinValue.uValue;
  114. else if (pValue->uValue > gConfigItems[i].MaxValue.uValue)
  115. pValue->uValue = gConfigItems[i].MaxValue.uValue;
  116. break;
  117. case PALCFG_INTEGER:
  118. sscanf(ptr, "%d", &pValue->iValue);
  119. if (pValue->iValue < gConfigItems[i].MinValue.iValue)
  120. pValue->iValue = gConfigItems[i].MinValue.iValue;
  121. else if (pValue->iValue > gConfigItems[i].MaxValue.iValue)
  122. pValue->iValue = gConfigItems[i].MaxValue.iValue;
  123. break;
  124. case PALCFG_BOOLEAN:
  125. sscanf(ptr, "%d", &pValue->bValue);
  126. pValue->bValue = pValue->bValue ? TRUE : FALSE;
  127. break;
  128. case PALCFG_STRING:
  129. //
  130. // Skip leading spaces
  131. //
  132. while (*ptr && isspace(*ptr)) ptr++;
  133. pValue->sValue = ptr;
  134. break;
  135. }
  136. return TRUE;
  137. }
  138. }
  139. }
  140. }
  141. }
  142. return FALSE;
  143. }
  144. ConfigValue
  145. PAL_DefaultConfig(
  146. PALCFG_ITEM item
  147. )
  148. {
  149. return gConfigItems[item].DefaultValue;
  150. }
  151. const char *
  152. PAL_ConfigName(
  153. PALCFG_ITEM item
  154. )
  155. {
  156. return gConfigItems[item].Name;
  157. }
  158. BOOL
  159. PAL_LimitConfig(
  160. PALCFG_ITEM item,
  161. ConfigValue * pValue
  162. )
  163. {
  164. if (!pValue) return FALSE;
  165. switch (gConfigItems[item].Type)
  166. {
  167. case PALCFG_UNSIGNED:
  168. if (pValue->uValue < gConfigItems[item].MinValue.uValue)
  169. {
  170. pValue->uValue = gConfigItems[item].MinValue.uValue;
  171. return TRUE;
  172. }
  173. else if (pValue->uValue > gConfigItems[item].MaxValue.uValue)
  174. {
  175. pValue->uValue = gConfigItems[item].MaxValue.uValue;
  176. return TRUE;
  177. }
  178. else
  179. return FALSE;
  180. case PALCFG_INTEGER:
  181. if (pValue->iValue < gConfigItems[item].MinValue.iValue)
  182. {
  183. pValue->iValue = gConfigItems[item].MinValue.iValue;
  184. return TRUE;
  185. }
  186. else if (pValue->iValue > gConfigItems[item].MaxValue.iValue)
  187. {
  188. pValue->iValue = gConfigItems[item].MaxValue.iValue;
  189. return TRUE;
  190. }
  191. else
  192. return FALSE;
  193. case PALCFG_BOOLEAN:
  194. if (pValue->bValue != TRUE && pValue->bValue != FALSE)
  195. {
  196. pValue->bValue = pValue->bValue ? TRUE : FALSE;
  197. return TRUE;
  198. }
  199. else
  200. return FALSE;
  201. default:
  202. return FALSE;
  203. }
  204. }
  205. VOID
  206. PAL_LoadConfig(
  207. BOOL fFromFile
  208. )
  209. {
  210. FILE *fp;
  211. ConfigValue values[PALCFG_ALL_MAX];
  212. MUSICTYPE eMusicType = MUSIC_RIX;
  213. MUSICTYPE eCDType = MUSIC_OGG;
  214. OPLTYPE eOPLType = OPL_DOSBOX;
  215. SCREENLAYOUT screen_layout = {
  216. // Equipment Screen
  217. PAL_XY(8, 8), PAL_XY(2, 95), PAL_XY(5, 70), PAL_XY(51, 57),
  218. { PAL_XY(92, 11), PAL_XY(92, 33), PAL_XY(92, 55), PAL_XY(92, 77), PAL_XY(92, 99), PAL_XY(92, 121) },
  219. { PAL_XY(130, 11), PAL_XY(130, 33), PAL_XY(130, 55), PAL_XY(130, 77), PAL_XY(130, 99), PAL_XY(130, 121) },
  220. { PAL_XY(226, 10), PAL_XY(226, 32), PAL_XY(226, 54), PAL_XY(226, 76), PAL_XY(226, 98) },
  221. { PAL_XY(260, 14), PAL_XY(260, 36), PAL_XY(260, 58), PAL_XY(260, 80), PAL_XY(260, 102) },
  222. // Status Screen
  223. PAL_XY(110, 8), PAL_XY(110, 30), PAL_XY(6, 6), PAL_XY(6, 32), PAL_XY(6, 54), PAL_XY(6, 76),
  224. { PAL_XY(6, 98), PAL_XY(6, 118), PAL_XY(6, 138), PAL_XY(6, 158), PAL_XY(6, 178) },
  225. PAL_XY(58, 6), PAL_XY(58, 15), PAL_XY(0, 0), PAL_XY(54, 35), PAL_XY(42, 56),
  226. PAL_XY(63, 61), PAL_XY(65, 58), PAL_XY(42, 78), PAL_XY(63, 83), PAL_XY(65, 80),
  227. { PAL_XY(42, 102), PAL_XY(42, 122), PAL_XY(42, 142), PAL_XY(42, 162), PAL_XY(42, 182) },
  228. { PAL_XY(189, -1), PAL_XY(247, 39), PAL_XY(251, 101), PAL_XY(201, 133), PAL_XY(141, 141), PAL_XY(81, 125) },
  229. { PAL_XY(195, 38), PAL_XY(253, 78), PAL_XY(257, 140), PAL_XY(207, 172), PAL_XY(147, 180), PAL_XY(87, 164) },
  230. { PAL_XY(185, 58), PAL_XY(185, 76), PAL_XY(185, 94), PAL_XY(185, 112), PAL_XY(185, 130), PAL_XY(185, 148), PAL_XY(185, 166), PAL_XY(185, 184), PAL_XY(185, 184), PAL_XY(185, 184) },
  231. // Extra Lines
  232. PAL_XY(0, 0), PAL_XY(0, 0)
  233. };
  234. for (PALCFG_ITEM i = PALCFG_ALL_MIN; i < PALCFG_ALL_MAX; i++) values[i] = PAL_DefaultConfig(i);
  235. if (fFromFile && (fp = fopen(va("%ssdlpal.cfg", PAL_CONFIG_PREFIX), "r")))
  236. {
  237. PAL_LARGE char buf[512];
  238. //
  239. // Load the configuration data
  240. //
  241. while (fgets(buf, 512, fp) != NULL)
  242. {
  243. ConfigValue value;
  244. const ConfigItem * item;
  245. if (PAL_ParseConfigLine(buf, &item, &value))
  246. {
  247. switch (item->Item)
  248. {
  249. case PALCFG_AUDIOBUFFERSIZE:
  250. if ((value.uValue & (value.uValue - 1)) != 0)
  251. {
  252. /* Make sure iAudioBufferSize is power of 2 */
  253. int n = 0;
  254. while (value.uValue) { value.uValue >>= 1; n++; }
  255. value.uValue = 1 << (n - 1);
  256. }
  257. values[item->Item] = value;
  258. break;
  259. case PALCFG_MESSAGEFILE:
  260. gConfig.pszMsgFile = ParseStringValue(value.sValue, gConfig.pszMsgFile);
  261. break;
  262. case PALCFG_BDFFILE:
  263. gConfig.pszBdfFile = ParseStringValue(value.sValue, gConfig.pszBdfFile);
  264. break;
  265. case PALCFG_GAMEPATH:
  266. gConfig.pszGamePath = ParseStringValue(value.sValue, gConfig.pszGamePath);
  267. break;
  268. case PALCFG_SAVEPATH:
  269. gConfig.pszSavePath = ParseStringValue(value.sValue, gConfig.pszSavePath);
  270. break;
  271. case PALCFG_CD:
  272. {
  273. if (PAL_HAS_MP3 && SDL_strncasecmp(value.sValue, "MP3", 3) == 0)
  274. eCDType = MUSIC_MP3;
  275. else if (PAL_HAS_OGG && SDL_strncasecmp(value.sValue, "OGG", 3) == 0)
  276. eCDType = MUSIC_OGG;
  277. else if (PAL_HAS_SDLCD && SDL_strncasecmp(value.sValue, "RAW", 3) == 0)
  278. eCDType = MUSIC_SDLCD;
  279. break;
  280. }
  281. case PALCFG_MUSIC:
  282. {
  283. if (PAL_HAS_NATIVEMIDI && SDL_strncasecmp(value.sValue, "MIDI", 4) == 0)
  284. eMusicType = MUSIC_MIDI;
  285. else if (PAL_HAS_MP3 && SDL_strncasecmp(value.sValue, "MP3", 3) == 0)
  286. eMusicType = MUSIC_MP3;
  287. else if (PAL_HAS_OGG && SDL_strncasecmp(value.sValue, "OGG", 3) == 0)
  288. eMusicType = MUSIC_OGG;
  289. else if (SDL_strncasecmp(value.sValue, "RIX", 3) == 0)
  290. eMusicType = MUSIC_RIX;
  291. break;
  292. }
  293. case PALCFG_OPL:
  294. {
  295. if (SDL_strncasecmp(value.sValue, "DOSBOXNEW", 9) == 0)
  296. eOPLType = OPL_DOSBOX_NEW;
  297. else if (SDL_strncasecmp(value.sValue, "DOSBOX", 6) == 0)
  298. eOPLType = OPL_DOSBOX;
  299. else if (SDL_strncasecmp(value.sValue, "MAME", 4) == 0)
  300. eOPLType = OPL_MAME;
  301. break;
  302. }
  303. case PALCFG_RIXEXTRAINIT:
  304. {
  305. #if USE_RIX_EXTRA_INIT
  306. int n = 1;
  307. char *p;
  308. for (p = ptr; *p < *end; p++)
  309. {
  310. if (*p == ',')
  311. n++;
  312. }
  313. n &= ~0x1;
  314. if (n > 0)
  315. {
  316. uint32_t *regs = malloc(sizeof(uint32_t) * (n >> 1));
  317. uint8_t *vals = malloc(sizeof(uint8_t) * (n >> 1));
  318. uint32_t d, i, v = 1;
  319. if (regs && vals)
  320. {
  321. for (p = ptr, i = 0; *p < *end; p++, i++)
  322. {
  323. if (sscanf(p, "%u", &regs[i]) == 0) { v = 0; break; }
  324. while (*p < *end && *p != ',') p++; p++;
  325. if (sscanf(p, "%u", &d) == 0) { v = 0; break; }
  326. while (*p < *end && *p != ',') p++;
  327. vals[i] = (uint8_t)d;
  328. }
  329. if (v)
  330. {
  331. gConfig.pExtraFMRegs = regs;
  332. gConfig.pExtraFMVals = vals;
  333. gConfig.dwExtraLength = n >> 1;
  334. }
  335. else
  336. {
  337. free(regs);
  338. free(vals);
  339. }
  340. }
  341. }
  342. #endif
  343. break;
  344. }
  345. case PALCFG_CLIMIDIPLAYER:
  346. gConfig.pszCLIMIDIPlayerPath = ParseStringValue(value.sValue, gConfig.pszCLIMIDIPlayerPath);
  347. break;
  348. default:
  349. values[item->Item] = value;
  350. break;
  351. }
  352. }
  353. }
  354. UTIL_CloseFile(fp);
  355. }
  356. //
  357. // Set configurable global options
  358. //
  359. if (!gConfig.pszSavePath) gConfig.pszSavePath = gConfig.pszGamePath ? strdup(gConfig.pszGamePath) : strdup(PAL_SAVE_PREFIX);
  360. if (!gConfig.pszGamePath) gConfig.pszGamePath = strdup(PAL_PREFIX);
  361. gConfig.eMusicType = eMusicType;
  362. gConfig.eCDType = eCDType;
  363. gConfig.eOPLType = eOPLType;
  364. gConfig.dwWordLength = 10; // This is the default value for Chinese version
  365. gConfig.ScreenLayout = screen_layout;
  366. gConfig.fIsWIN95 = FALSE; // Default for DOS version
  367. gConfig.fUseEmbeddedFonts = values[PALCFG_USEEMBEDDEDFONTS].bValue;
  368. gConfig.fUseSurroundOPL = values[PALCFG_STEREO].bValue && values[PALCFG_USESURROUNDOPL].bValue;
  369. gConfig.fLaunchSetting = values[PALCFG_LAUNCHSETTING].bValue;
  370. gConfig.fUseTouchOverlay = values[PALCFG_USETOUCHOVERLAY].bValue;
  371. gConfig.fKeepAspectRatio = values[PALCFG_KEEPASPECTRATIO].bValue;
  372. gConfig.fFullScreen = values[PALCFG_FULLSCREEN].bValue;
  373. gConfig.iAudioChannels = values[PALCFG_STEREO].bValue ? 2 : 1;
  374. gConfig.iSurroundOPLOffset = values[PALCFG_SURROUNDOPLOFFSET].iValue;
  375. gConfig.iSampleRate = values[PALCFG_SAMPLERATE].uValue;
  376. gConfig.iOPLSampleRate = values[PALCFG_OPLSAMPLERATE].uValue;
  377. gConfig.iResampleQuality = values[PALCFG_RESAMPLEQUALITY].uValue;
  378. gConfig.uCodePage = values[PALCFG_CODEPAGE].uValue;
  379. gConfig.wAudioBufferSize = (WORD)values[PALCFG_AUDIOBUFFERSIZE].uValue;
  380. gConfig.iMusicVolume = values[PALCFG_MUSICVOLUME].uValue;
  381. gConfig.iSoundVolume = values[PALCFG_SOUNDVOLUME].uValue;
  382. if (UTIL_GetScreenSize(&values[PALCFG_WINDOWWIDTH].uValue, &values[PALCFG_WINDOWHEIGHT].uValue))
  383. {
  384. gConfig.dwScreenWidth = values[PALCFG_WINDOWWIDTH].uValue;
  385. gConfig.dwScreenHeight = values[PALCFG_WINDOWHEIGHT].uValue;
  386. }
  387. else
  388. {
  389. gConfig.dwScreenWidth = PAL_DEFAULT_WINDOW_WIDTH;
  390. gConfig.dwScreenHeight = PAL_DEFAULT_WINDOW_HEIGHT;
  391. }
  392. }
  393. BOOL
  394. PAL_SaveConfig(
  395. VOID
  396. )
  397. {
  398. static const char *music_types[] = { "MIDI", "RIX", "MP3", "OGG", "RAW" };
  399. static const char *opl_types[] = { "DOSBOX", "MAME", "DOSBOXNEW" };
  400. char buf[512];
  401. FILE *fp = fopen(va("%ssdlpal.cfg", PAL_CONFIG_PREFIX), "w");
  402. if (fp)
  403. {
  404. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_KEEPASPECTRATIO), gConfig.fKeepAspectRatio); fputs(buf, fp);
  405. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_FULLSCREEN), gConfig.fFullScreen); fputs(buf, fp);
  406. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_LAUNCHSETTING), gConfig.fLaunchSetting); fputs(buf, fp);
  407. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_STEREO), gConfig.iAudioChannels == 2 ? TRUE : FALSE); fputs(buf, fp);
  408. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USEEMBEDDEDFONTS), gConfig.fUseEmbeddedFonts); fputs(buf, fp);
  409. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USESURROUNDOPL), gConfig.fUseSurroundOPL); fputs(buf, fp);
  410. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USETOUCHOVERLAY), gConfig.fUseTouchOverlay); fputs(buf, fp);
  411. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_SURROUNDOPLOFFSET), gConfig.iSurroundOPLOffset); fputs(buf, fp);
  412. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_AUDIOBUFFERSIZE), gConfig.wAudioBufferSize); fputs(buf, fp);
  413. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_CODEPAGE), gConfig.uCodePage); fputs(buf, fp);
  414. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_OPLSAMPLERATE), gConfig.iOPLSampleRate); fputs(buf, fp);
  415. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_RESAMPLEQUALITY), gConfig.iResampleQuality); fputs(buf, fp);
  416. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_SAMPLERATE), gConfig.iSampleRate); fputs(buf, fp);
  417. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_MUSICVOLUME), gConfig.iMusicVolume); fputs(buf, fp);
  418. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_SOUNDVOLUME), gConfig.iSoundVolume); fputs(buf, fp);
  419. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_WINDOWHEIGHT), gConfig.dwScreenHeight); fputs(buf, fp);
  420. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_WINDOWWIDTH), gConfig.dwScreenWidth); fputs(buf, fp);
  421. sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_CD), music_types[gConfig.eCDType]); fputs(buf, fp);
  422. sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_MUSIC), music_types[gConfig.eMusicType]); fputs(buf, fp);
  423. sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_OPL), opl_types[gConfig.eOPLType]); fputs(buf, fp);
  424. if (gConfig.pszGamePath && *gConfig.pszGamePath && strncmp(gConfig.pszGamePath, PAL_PREFIX, strnlen(gConfig.pszGamePath,PATH_MAX)) != 0) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_GAMEPATH), gConfig.pszGamePath); fputs(buf, fp); }
  425. if (gConfig.pszSavePath && *gConfig.pszSavePath && strncmp(gConfig.pszSavePath, PAL_SAVE_PREFIX, strnlen(gConfig.pszSavePath,PATH_MAX)) != 0) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_SAVEPATH), gConfig.pszSavePath); fputs(buf, fp); }
  426. if (gConfig.pszMsgFile && *gConfig.pszMsgFile) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_MESSAGEFILE), gConfig.pszMsgFile); fputs(buf, fp); }
  427. if (gConfig.pszBdfFile && *gConfig.pszBdfFile) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_BDFFILE), gConfig.pszBdfFile); fputs(buf, fp); }
  428. if (gConfig.pszCLIMIDIPlayerPath && *gConfig.pszCLIMIDIPlayerPath) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_CLIMIDIPLAYER), gConfig.pszCLIMIDIPlayerPath); fputs(buf, fp); }
  429. fclose(fp);
  430. return TRUE;
  431. }
  432. else
  433. return FALSE;
  434. }