palcfg.c 16 KB

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