palcfg.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. static const ConfigItem gConfigItems[PALCFG_ALL_MAX] = {
  34. { PALCFG_FULLSCREEN, PALCFG_BOOLEAN, "FULLSCREEN", 10, FALSE, FALSE, TRUE },
  35. { PALCFG_KEEPASPECTRATIO, PALCFG_BOOLEAN, "KEEPASPECTRATIO", 15, TRUE, FALSE, TRUE },
  36. { PALCFG_LAUNCHSETTING, PALCFG_BOOLEAN, "LAUNCHSETTING", 13, TRUE, FALSE, TRUE },
  37. { PALCFG_STEREO, PALCFG_BOOLEAN, "STEREO", 6, TRUE, FALSE, TRUE }, // Default for stereo audio
  38. { PALCFG_USEEMBEDDEDFONTS, PALCFG_BOOLEAN, "USEEMBEDDEDFONTS", 16, TRUE, FALSE, TRUE }, // Default for using embedded fonts in DOS version
  39. { PALCFG_USESURROUNDOPL, PALCFG_BOOLEAN, "USESURROUNDOPL", 14, TRUE, FALSE, TRUE }, // Default for using surround opl
  40. { PALCFG_USETOUCHOVERLAY, PALCFG_BOOLEAN, "USETOUCHOVERLAY", 15, PAL_HAS_TOUCH, FALSE, TRUE },
  41. { PALCFG_SURROUNDOPLOFFSET, PALCFG_INTEGER, "SURROUNDOPLOFFSET", 17, 384, INT32_MIN, INT32_MAX },
  42. { PALCFG_AUDIOBUFFERSIZE, PALCFG_UNSIGNED, "AUDIOBUFFERSIZE", 15, PAL_AUDIO_DEFAULT_BUFFER_SIZE, 2, 32768 },
  43. { PALCFG_CODEPAGE, PALCFG_UNSIGNED, "CODEPAGE", 8, CP_BIG5, CP_BIG5, CP_MAX - 1 }, // Default for BIG5
  44. { PALCFG_OPLSAMPLERATE, PALCFG_UNSIGNED, "OPLSAMPLERATE", 13, 49716, 0, UINT32_MAX },
  45. { PALCFG_RESAMPLEQUALITY, PALCFG_UNSIGNED, "RESAMPLEQUALITY", 15, RESAMPLER_QUALITY_MAX, RESAMPLER_QUALITY_MIN, RESAMPLER_QUALITY_MAX }, // Default for best quality
  46. { PALCFG_SAMPLERATE, PALCFG_UNSIGNED, "SAMPLERATE", 10, 44100, 0, PAL_MAX_SAMPLERATE },
  47. { PALCFG_MUSICVOLUME, PALCFG_UNSIGNED, "MUSICVOLUME", 11, PAL_MAX_VOLUME, 0, PAL_MAX_VOLUME }, // Default for maximum volume
  48. { PALCFG_SOUNDVOLUME, PALCFG_UNSIGNED, "SOUNDVOLUME", 11, PAL_MAX_VOLUME, 0, PAL_MAX_VOLUME }, // Default for maximum volume
  49. { PALCFG_WINDOWHEIGHT, PALCFG_UNSIGNED, "WINDOWHEIGHT", 12, PAL_DEFAULT_WINDOW_HEIGHT, 0, UINT32_MAX },
  50. { PALCFG_WINDOWWIDTH, PALCFG_UNSIGNED, "WINDOWWIDTH", 11, PAL_DEFAULT_WINDOW_WIDTH, 0, UINT32_MAX },
  51. { PALCFG_CD, PALCFG_STRING, "CD", 2, "OGG", NULL, NULL },
  52. { PALCFG_GAMEPATH, PALCFG_STRING, "GAMEPATH", 8, NULL, NULL, NULL },
  53. { PALCFG_SAVEPATH, PALCFG_STRING, "SAVEPATH", 8, NULL, NULL, NULL },
  54. { PALCFG_MESSAGEFILE, PALCFG_STRING, "MESSAGEFILENAME", 15, NULL, NULL, NULL },
  55. { PALCFG_BDFFILE, PALCFG_STRING, "BDFFILENAME", 11, NULL, NULL, NULL },
  56. { PALCFG_MUSIC, PALCFG_STRING, "MUSIC", 5, "RIX", NULL, NULL },
  57. { PALCFG_OPL, PALCFG_STRING, "OPL", 3, "DOSBOX", NULL, NULL },
  58. { PALCFG_RIXEXTRAINIT, PALCFG_STRING, "RIXEXTRAINIT", 12, NULL, NULL, NULL },
  59. };
  60. BOOL
  61. PAL_ParseConfigLine(
  62. const char * line,
  63. const ConfigItem ** ppItem,
  64. ConfigValue * pValue
  65. )
  66. {
  67. //
  68. // Skip leading spaces
  69. //
  70. while (*line && isspace(*line)) line++;
  71. //
  72. // Skip comments
  73. //
  74. if (*line && *line != '#')
  75. {
  76. const char *ptr;
  77. if (ptr = strchr(line, '='))
  78. {
  79. const char *end = ptr++;
  80. //
  81. // Skip tailing spaces
  82. //
  83. while (end > line && isspace(end[-1])) end--;
  84. int len = end - line;
  85. for (int i = 0; i < sizeof(gConfigItems) / sizeof(ConfigItem); i++)
  86. {
  87. if (gConfigItems[i].NameLength == len &&
  88. SDL_strncasecmp(line, gConfigItems[i].Name, len) == 0)
  89. {
  90. if (ppItem) *ppItem = &gConfigItems[i];
  91. if (pValue)
  92. {
  93. if (gConfigItems[i].Type != PALCFG_STRING)
  94. {
  95. switch (gConfigItems[i].Type)
  96. {
  97. case PALCFG_UNSIGNED:
  98. sscanf(ptr, "%u", &pValue->uValue);
  99. if (pValue->uValue < gConfigItems[i].MinValue.uValue)
  100. pValue->uValue = gConfigItems[i].MinValue.uValue;
  101. else if (pValue->uValue > gConfigItems[i].MaxValue.uValue)
  102. pValue->uValue = gConfigItems[i].MaxValue.uValue;
  103. break;
  104. case PALCFG_INTEGER:
  105. sscanf(ptr, "%d", &pValue->iValue);
  106. if (pValue->iValue < gConfigItems[i].MinValue.iValue)
  107. pValue->iValue = gConfigItems[i].MinValue.iValue;
  108. else if (pValue->iValue > gConfigItems[i].MaxValue.iValue)
  109. pValue->iValue = gConfigItems[i].MaxValue.iValue;
  110. break;
  111. case PALCFG_BOOLEAN:
  112. sscanf(ptr, "%d", &pValue->bValue);
  113. pValue->bValue = pValue->bValue ? TRUE : FALSE;
  114. break;
  115. }
  116. }
  117. else
  118. {
  119. //
  120. // Skip leading spaces
  121. //
  122. while (*ptr && isspace(*ptr)) ptr++;
  123. pValue->sValue = ptr;
  124. }
  125. return TRUE;
  126. }
  127. }
  128. }
  129. }
  130. }
  131. return FALSE;
  132. }
  133. ConfigValue
  134. PAL_DefaultConfig(
  135. PALCFG_ITEM item
  136. )
  137. {
  138. return gConfigItems[item].DefaultValue;
  139. }
  140. const char *
  141. PAL_ConfigName(
  142. PALCFG_ITEM item
  143. )
  144. {
  145. return gConfigItems[item].Name;
  146. }
  147. BOOL
  148. PAL_LimitConfig(
  149. PALCFG_ITEM item,
  150. ConfigValue * pValue
  151. )
  152. {
  153. if (!pValue) return FALSE;
  154. switch (gConfigItems[item].Type)
  155. {
  156. case PALCFG_UNSIGNED:
  157. if (pValue->uValue < gConfigItems[item].MinValue.uValue)
  158. {
  159. pValue->uValue = gConfigItems[item].MinValue.uValue;
  160. return TRUE;
  161. }
  162. else if (pValue->uValue > gConfigItems[item].MaxValue.uValue)
  163. {
  164. pValue->uValue = gConfigItems[item].MaxValue.uValue;
  165. return TRUE;
  166. }
  167. else
  168. return FALSE;
  169. case PALCFG_INTEGER:
  170. if (pValue->iValue < gConfigItems[item].MinValue.iValue)
  171. {
  172. pValue->iValue = gConfigItems[item].MinValue.iValue;
  173. return TRUE;
  174. }
  175. else if (pValue->iValue > gConfigItems[item].MaxValue.iValue)
  176. {
  177. pValue->iValue = gConfigItems[item].MaxValue.iValue;
  178. return TRUE;
  179. }
  180. else
  181. return FALSE;
  182. case PALCFG_BOOLEAN:
  183. if (pValue->bValue != TRUE && pValue->bValue != FALSE)
  184. {
  185. pValue->bValue = pValue->bValue ? TRUE : FALSE;
  186. return TRUE;
  187. }
  188. else
  189. return FALSE;
  190. default:
  191. return FALSE;
  192. }
  193. }
  194. VOID
  195. PAL_LoadConfig(
  196. BOOL fFromFile
  197. )
  198. {
  199. FILE *fp;
  200. ConfigValue values[PALCFG_ALL_MAX];
  201. MUSICTYPE eMusicType = MUSIC_RIX;
  202. MUSICTYPE eCDType = MUSIC_OGG;
  203. OPLTYPE eOPLType = OPL_DOSBOX;
  204. SCREENLAYOUT screen_layout = {
  205. // Equipment Screen
  206. PAL_XY(8, 8), PAL_XY(2, 95), PAL_XY(5, 70), PAL_XY(51, 57),
  207. { PAL_XY(92, 11), PAL_XY(92, 33), PAL_XY(92, 55), PAL_XY(92, 77), PAL_XY(92, 99), PAL_XY(92, 121) },
  208. { PAL_XY(130, 11), PAL_XY(130, 33), PAL_XY(130, 55), PAL_XY(130, 77), PAL_XY(130, 99), PAL_XY(130, 121) },
  209. { PAL_XY(226, 10), PAL_XY(226, 32), PAL_XY(226, 54), PAL_XY(226, 76), PAL_XY(226, 98) },
  210. { PAL_XY(260, 14), PAL_XY(260, 36), PAL_XY(260, 58), PAL_XY(260, 80), PAL_XY(260, 102) },
  211. // Status Screen
  212. PAL_XY(110, 8), PAL_XY(110, 30), PAL_XY(6, 6), PAL_XY(6, 32), PAL_XY(6, 54), PAL_XY(6, 76),
  213. { PAL_XY(6, 98), PAL_XY(6, 118), PAL_XY(6, 138), PAL_XY(6, 158), PAL_XY(6, 178) },
  214. PAL_XY(58, 6), PAL_XY(58, 15), PAL_XY(0, 0), PAL_XY(54, 35), PAL_XY(42, 56),
  215. PAL_XY(63, 61), PAL_XY(65, 58), PAL_XY(42, 78), PAL_XY(63, 83), PAL_XY(65, 80),
  216. { PAL_XY(42, 102), PAL_XY(42, 122), PAL_XY(42, 142), PAL_XY(42, 162), PAL_XY(42, 182) },
  217. { PAL_XY(189, -1), PAL_XY(247, 39), PAL_XY(251, 101), PAL_XY(201, 133), PAL_XY(141, 141), PAL_XY(81, 125) },
  218. { PAL_XY(195, 38), PAL_XY(253, 78), PAL_XY(257, 140), PAL_XY(207, 172), PAL_XY(147, 180), PAL_XY(87, 164) },
  219. { 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) },
  220. // Extra Lines
  221. PAL_XY(0, 0), PAL_XY(0, 0)
  222. };
  223. for (PALCFG_ITEM i = PALCFG_ALL_MIN; i < PALCFG_ALL_MAX; i++) values[i] = PAL_DefaultConfig(i);
  224. if (fFromFile && (fp = fopen(va("%ssdlpal.cfg", PAL_CONFIG_PREFIX), "r")))
  225. {
  226. PAL_LARGE char buf[512];
  227. //
  228. // Load the configuration data
  229. //
  230. while (fgets(buf, 512, fp) != NULL)
  231. {
  232. ConfigValue value;
  233. const ConfigItem * item;
  234. if (PAL_ParseConfigLine(buf, &item, &value))
  235. {
  236. switch (item->Item)
  237. {
  238. case PALCFG_AUDIOBUFFERSIZE:
  239. if ((value.uValue & (value.uValue - 1)) != 0)
  240. {
  241. /* Make sure iAudioBufferSize is power of 2 */
  242. int n = 0;
  243. while (value.uValue) { value.uValue >>= 1; n++; }
  244. value.uValue = 1 << (n - 1);
  245. }
  246. values[item->Item] = value;
  247. break;
  248. case PALCFG_MESSAGEFILE:
  249. {
  250. int n = strlen(value.sValue);
  251. while (n > 0 && isspace(value.sValue[n - 1])) n--;
  252. if (n > 0)
  253. {
  254. gConfig.pszMsgFile = (char *)realloc(gConfig.pszMsgFile, n + 1);
  255. memcpy(gConfig.pszMsgFile, value.sValue, n);
  256. gConfig.pszMsgFile[n] = '\0';
  257. }
  258. break;
  259. }
  260. case PALCFG_BDFFILE:
  261. {
  262. int n = strlen(value.sValue);
  263. while (n > 0 && isspace(value.sValue[n - 1])) n--;
  264. if (n > 0)
  265. {
  266. gConfig.pszBdfFile = (char *)realloc(gConfig.pszBdfFile, n + 1);
  267. memcpy(gConfig.pszBdfFile, value.sValue, n);
  268. gConfig.pszBdfFile[n] = '\0';
  269. }
  270. break;
  271. }
  272. case PALCFG_GAMEPATH:
  273. {
  274. int n = strlen(value.sValue);
  275. while (n > 0 && isspace(value.sValue[n - 1])) n--;
  276. if (n > 0)
  277. {
  278. gConfig.pszGamePath = (char *)realloc(gConfig.pszGamePath, n + 1);
  279. memcpy(gConfig.pszGamePath, value.sValue, n);
  280. gConfig.pszGamePath[n] = '\0';
  281. }
  282. break;
  283. }
  284. case PALCFG_SAVEPATH:
  285. {
  286. int n = strlen(value.sValue);
  287. while (n > 0 && isspace(value.sValue[n - 1])) n--;
  288. if (n > 0)
  289. {
  290. gConfig.pszSavePath = (char *)realloc(gConfig.pszSavePath, n + 1);
  291. memcpy(gConfig.pszSavePath, value.sValue, n);
  292. gConfig.pszSavePath[n] = '\0';
  293. }
  294. break;
  295. }
  296. case PALCFG_CD:
  297. {
  298. if (PAL_HAS_MP3 && SDL_strncasecmp(value.sValue, "MP3", 3) == 0)
  299. eCDType = MUSIC_MP3;
  300. else if (PAL_HAS_OGG && SDL_strncasecmp(value.sValue, "OGG", 3) == 0)
  301. eCDType = MUSIC_OGG;
  302. else if (PAL_HAS_SDLCD && SDL_strncasecmp(value.sValue, "RAW", 3) == 0)
  303. eCDType = MUSIC_SDLCD;
  304. break;
  305. }
  306. case PALCFG_MUSIC:
  307. {
  308. if (PAL_HAS_NATIVEMIDI && SDL_strncasecmp(value.sValue, "MIDI", 4) == 0)
  309. eMusicType = MUSIC_MIDI;
  310. else if (PAL_HAS_MP3 && SDL_strncasecmp(value.sValue, "MP3", 3) == 0)
  311. eMusicType = MUSIC_MP3;
  312. else if (PAL_HAS_OGG && SDL_strncasecmp(value.sValue, "OGG", 3) == 0)
  313. eMusicType = MUSIC_OGG;
  314. else if (SDL_strncasecmp(value.sValue, "RIX", 3) == 0)
  315. eMusicType = MUSIC_RIX;
  316. break;
  317. }
  318. case PALCFG_OPL:
  319. {
  320. if (SDL_strncasecmp(value.sValue, "DOSBOXNEW", 9) == 0)
  321. eOPLType = OPL_DOSBOX_NEW;
  322. else if (SDL_strncasecmp(value.sValue, "DOSBOX", 6) == 0)
  323. eOPLType = OPL_DOSBOX;
  324. else if (SDL_strncasecmp(value.sValue, "MAME", 4) == 0)
  325. eOPLType = OPL_MAME;
  326. break;
  327. }
  328. case PALCFG_RIXEXTRAINIT:
  329. {
  330. #if USE_RIX_EXTRA_INIT
  331. int n = 1;
  332. char *p;
  333. for (p = ptr; *p < *end; p++)
  334. {
  335. if (*p == ',')
  336. n++;
  337. }
  338. n &= ~0x1;
  339. if (n > 0)
  340. {
  341. uint32_t *regs = malloc(sizeof(uint32_t) * (n >> 1));
  342. uint8_t *vals = malloc(sizeof(uint8_t) * (n >> 1));
  343. uint32_t d, i, v = 1;
  344. if (regs && vals)
  345. {
  346. for (p = ptr, i = 0; *p < *end; p++, i++)
  347. {
  348. if (sscanf(p, "%u", &regs[i]) == 0) { v = 0; break; }
  349. while (*p < *end && *p != ',') p++; p++;
  350. if (sscanf(p, "%u", &d) == 0) { v = 0; break; }
  351. while (*p < *end && *p != ',') p++;
  352. vals[i] = (uint8_t)d;
  353. }
  354. if (v)
  355. {
  356. gConfig.pExtraFMRegs = regs;
  357. gConfig.pExtraFMVals = vals;
  358. gConfig.dwExtraLength = n >> 1;
  359. }
  360. else
  361. {
  362. free(regs);
  363. free(vals);
  364. }
  365. }
  366. }
  367. #endif
  368. break;
  369. }
  370. default:
  371. values[item->Item] = value;
  372. break;
  373. }
  374. }
  375. }
  376. UTIL_CloseFile(fp);
  377. }
  378. //
  379. // Set configurable global options
  380. //
  381. if (!gConfig.pszSavePath) gConfig.pszSavePath = gConfig.pszGamePath ? strdup(gConfig.pszGamePath) : strdup(PAL_SAVE_PREFIX);
  382. if (!gConfig.pszGamePath) gConfig.pszGamePath = strdup(PAL_PREFIX);
  383. gConfig.eMusicType = eMusicType;
  384. gConfig.eCDType = eCDType;
  385. gConfig.eOPLType = eOPLType;
  386. gConfig.dwWordLength = 10; // This is the default value for Chinese version
  387. gConfig.ScreenLayout = screen_layout;
  388. gConfig.fIsWIN95 = FALSE; // Default for DOS version
  389. gConfig.fUseEmbeddedFonts = values[PALCFG_USEEMBEDDEDFONTS].bValue;
  390. gConfig.fUseSurroundOPL = values[PALCFG_STEREO].bValue && values[PALCFG_USESURROUNDOPL].bValue;
  391. gConfig.fLaunchSetting = values[PALCFG_LAUNCHSETTING].bValue;
  392. gConfig.fUseTouchOverlay = values[PALCFG_USETOUCHOVERLAY].bValue;
  393. #if SDL_VERSION_ATLEAST(2,0,0)
  394. gConfig.fKeepAspectRatio = values[PALCFG_KEEPASPECTRATIO].bValue;
  395. #endif
  396. gConfig.fFullScreen = values[PALCFG_FULLSCREEN].bValue;
  397. gConfig.iAudioChannels = values[PALCFG_STEREO].bValue ? 2 : 1;
  398. gConfig.iSurroundOPLOffset = values[PALCFG_SURROUNDOPLOFFSET].iValue;
  399. gConfig.iSampleRate = values[PALCFG_SAMPLERATE].uValue;
  400. gConfig.iOPLSampleRate = values[PALCFG_OPLSAMPLERATE].uValue;
  401. gConfig.iResampleQuality = values[PALCFG_RESAMPLEQUALITY].uValue;
  402. gConfig.uCodePage = values[PALCFG_CODEPAGE].uValue;
  403. gConfig.wAudioBufferSize = (WORD)values[PALCFG_AUDIOBUFFERSIZE].uValue;
  404. gConfig.iMusicVolume = values[PALCFG_MUSICVOLUME].uValue;
  405. gConfig.iSoundVolume = values[PALCFG_SOUNDVOLUME].uValue;
  406. if (UTIL_GetScreenSize(&values[PALCFG_WINDOWWIDTH].uValue, &values[PALCFG_WINDOWHEIGHT].uValue))
  407. {
  408. gConfig.dwScreenWidth = values[PALCFG_WINDOWWIDTH].uValue;
  409. gConfig.dwScreenHeight = values[PALCFG_WINDOWHEIGHT].uValue;
  410. }
  411. else
  412. {
  413. gConfig.dwScreenWidth = PAL_DEFAULT_WINDOW_WIDTH;
  414. gConfig.dwScreenHeight = PAL_DEFAULT_WINDOW_HEIGHT;
  415. }
  416. }
  417. BOOL
  418. PAL_SaveConfig(
  419. VOID
  420. )
  421. {
  422. static const char *music_types[] = { "MIDI", "RIX", "MP3", "OGG", "RAW" };
  423. static const char *opl_types[] = { "DOSBOX", "MAME", "DOSBOXNEW" };
  424. char buf[512];
  425. FILE *fp = fopen(va("%ssdlpal.cfg", PAL_CONFIG_PREFIX), "w");
  426. if (fp)
  427. {
  428. #if SDL_VERSION_ATLEAST(2,0,0)
  429. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_KEEPASPECTRATIO), gConfig.fKeepAspectRatio); fputs(buf, fp);
  430. #endif
  431. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_FULLSCREEN), gConfig.fFullScreen); fputs(buf, fp);
  432. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_LAUNCHSETTING), gConfig.fLaunchSetting); fputs(buf, fp);
  433. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_STEREO), gConfig.iAudioChannels == 2 ? TRUE : FALSE); fputs(buf, fp);
  434. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USEEMBEDDEDFONTS), gConfig.fUseEmbeddedFonts); fputs(buf, fp);
  435. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USESURROUNDOPL), gConfig.fUseSurroundOPL); fputs(buf, fp);
  436. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_USETOUCHOVERLAY), gConfig.fUseTouchOverlay); fputs(buf, fp);
  437. sprintf(buf, "%s=%d\n", PAL_ConfigName(PALCFG_SURROUNDOPLOFFSET), gConfig.iSurroundOPLOffset); fputs(buf, fp);
  438. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_AUDIOBUFFERSIZE), gConfig.wAudioBufferSize); fputs(buf, fp);
  439. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_CODEPAGE), gConfig.uCodePage); fputs(buf, fp);
  440. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_OPLSAMPLERATE), gConfig.iOPLSampleRate); fputs(buf, fp);
  441. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_RESAMPLEQUALITY), gConfig.iResampleQuality); fputs(buf, fp);
  442. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_SAMPLERATE), gConfig.iSampleRate); fputs(buf, fp);
  443. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_MUSICVOLUME), gConfig.iMusicVolume); fputs(buf, fp);
  444. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_SOUNDVOLUME), gConfig.iSoundVolume); fputs(buf, fp);
  445. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_WINDOWHEIGHT), gConfig.dwScreenHeight); fputs(buf, fp);
  446. sprintf(buf, "%s=%u\n", PAL_ConfigName(PALCFG_WINDOWWIDTH), gConfig.dwScreenWidth); fputs(buf, fp);
  447. sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_CD), music_types[gConfig.eCDType]); fputs(buf, fp);
  448. sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_MUSIC), music_types[gConfig.eMusicType]); fputs(buf, fp);
  449. sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_OPL), opl_types[gConfig.eOPLType]); fputs(buf, fp);
  450. if (gConfig.pszGamePath) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_GAMEPATH), gConfig.pszGamePath); fputs(buf, fp); }
  451. if (gConfig.pszSavePath) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_SAVEPATH), gConfig.pszSavePath); fputs(buf, fp); }
  452. if (gConfig.pszMsgFile) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_MESSAGEFILE), gConfig.pszMsgFile); fputs(buf, fp); }
  453. if (gConfig.pszBdfFile) { sprintf(buf, "%s=%s\n", PAL_ConfigName(PALCFG_BDFFILE), gConfig.pszBdfFile); fputs(buf, fp); }
  454. fclose(fp);
  455. return TRUE;
  456. }
  457. else
  458. return FALSE;
  459. }