palcfg.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 4; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2016, Lou Yihua <louyihua@21cn.com>.
  4. // All rights reserved.
  5. //
  6. // This file is part of SDLPAL.
  7. //
  8. // SDLPAL is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. #ifndef CONFIG_H
  22. #define CONFIG_H
  23. # ifdef __cplusplus
  24. extern "C"
  25. {
  26. # endif
  27. #include "palcommon.h"
  28. #ifdef __EMSCRIPTEN__
  29. #include <ctype.h>
  30. #endif
  31. #define PAL_MAX_SAMPLERATE 48000
  32. #define PAL_MAX_VOLUME 100
  33. typedef enum tagPALCFG_ITEM
  34. {
  35. PALCFG_ALL_MIN = 0,
  36. PALCFG_BOOLEAN_MIN = PALCFG_ALL_MIN,
  37. /* Booleans */
  38. PALCFG_FULLSCREEN = PALCFG_BOOLEAN_MIN,
  39. PALCFG_KEEPASPECTRATIO,
  40. PALCFG_LAUNCHSETTING,
  41. PALCFG_STEREO,
  42. PALCFG_USEEMBEDDEDFONTS,
  43. PALCFG_USESURROUNDOPL,
  44. PALCFG_USETOUCHOVERLAY,
  45. /* Booleans */
  46. PALCFG_BOOLEAN_MAX,
  47. PALCFG_INTEGER_MIN = PALCFG_BOOLEAN_MAX,
  48. /* Integers */
  49. PALCFG_SURROUNDOPLOFFSET = PALCFG_INTEGER_MIN,
  50. /* Integers */
  51. PALCFG_INTEGER_MAX,
  52. PALCFG_UNSIGNED_MIN = PALCFG_INTEGER_MAX,
  53. /* Unsigneds */
  54. PALCFG_AUDIOBUFFERSIZE = PALCFG_UNSIGNED_MIN,
  55. PALCFG_CODEPAGE,
  56. PALCFG_OPLSAMPLERATE,
  57. PALCFG_RESAMPLEQUALITY,
  58. PALCFG_SAMPLERATE,
  59. PALCFG_MUSICVOLUME,
  60. PALCFG_SOUNDVOLUME,
  61. PALCFG_WINDOWHEIGHT,
  62. PALCFG_WINDOWWIDTH,
  63. /* Unsigneds */
  64. PALCFG_UNSIGNED_MAX,
  65. PALCFG_STRING_MIN = PALCFG_UNSIGNED_MAX,
  66. /* Strings */
  67. PALCFG_CD = PALCFG_STRING_MIN,
  68. PALCFG_GAMEPATH,
  69. PALCFG_MESSAGEFILE,
  70. PALCFG_BDFFILE,
  71. PALCFG_MUSIC,
  72. PALCFG_OPL,
  73. PALCFG_RIXEXTRAINIT,
  74. /* Strings */
  75. PALCFG_STRING_MAX,
  76. PALCFG_ALL_MAX = PALCFG_STRING_MAX
  77. } PALCFG_ITEM;
  78. typedef enum tagPALCFG_TYPE
  79. {
  80. PALCFG_STRING,
  81. PALCFG_BOOLEAN,
  82. PALCFG_INTEGER,
  83. PALCFG_UNSIGNED,
  84. } PALCFG_TYPE;
  85. typedef union tagConfigValue
  86. {
  87. LPCSTR sValue;
  88. DWORD uValue;
  89. INT iValue;
  90. BOOL bValue;
  91. } ConfigValue;
  92. typedef struct tagConfigItem
  93. {
  94. PALCFG_ITEM Item;
  95. PALCFG_TYPE Type;
  96. const char* Name;
  97. int NameLength;
  98. const ConfigValue DefaultValue;
  99. const ConfigValue MinValue;
  100. const ConfigValue MaxValue;
  101. } ConfigItem;
  102. typedef struct tagSCREENLAYOUT
  103. {
  104. PAL_POS EquipImageBox;
  105. PAL_POS EquipRoleListBox;
  106. PAL_POS EquipItemName;
  107. PAL_POS EquipItemAmount;
  108. PAL_POS EquipLabels[MAX_PLAYER_EQUIPMENTS];
  109. PAL_POS EquipNames[MAX_PLAYER_EQUIPMENTS];
  110. PAL_POS EquipStatusLabels[5];
  111. PAL_POS EquipStatusValues[5];
  112. PAL_POS RoleName;
  113. PAL_POS RoleImage;
  114. PAL_POS RoleExpLabel;
  115. PAL_POS RoleLevelLabel;
  116. PAL_POS RoleHPLabel;
  117. PAL_POS RoleMPLabel;
  118. PAL_POS RoleStatusLabels[5];
  119. PAL_POS RoleCurrExp;
  120. PAL_POS RoleNextExp;
  121. PAL_POS RoleExpSlash;
  122. PAL_POS RoleLevel;
  123. PAL_POS RoleCurHP;
  124. PAL_POS RoleMaxHP;
  125. PAL_POS RoleHPSlash;
  126. PAL_POS RoleCurMP;
  127. PAL_POS RoleMaxMP;
  128. PAL_POS RoleMPSlash;
  129. PAL_POS RoleStatusValues[5];
  130. PAL_POS RoleEquipImageBoxes[MAX_PLAYER_EQUIPMENTS];
  131. PAL_POS RoleEquipNames[MAX_PLAYER_EQUIPMENTS];
  132. PAL_POS RolePoisonNames[MAX_POISONS];
  133. PAL_POS ExtraItemDescLines;
  134. PAL_POS ExtraMagicDescLines;
  135. } SCREENLAYOUT;
  136. typedef struct tagCONFIGURATION
  137. {
  138. union {
  139. SCREENLAYOUT ScreenLayout;
  140. PAL_POS ScreenLayoutArray[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  141. };
  142. enum {
  143. USE_8x8_FONT = 1,
  144. DISABLE_SHADOW = 2,
  145. } ScreenLayoutFlag[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  146. /* Configurable options */
  147. char *pszGamePath;
  148. char *pszMsgFile;
  149. char *pszBdfFile;
  150. CODEPAGE uCodePage;
  151. DWORD dwWordLength;
  152. DWORD dwScreenWidth;
  153. DWORD dwScreenHeight;
  154. INT iSurroundOPLOffset;
  155. INT iAudioChannels;
  156. INT iSampleRate;
  157. INT iOPLSampleRate;
  158. INT iResampleQuality;
  159. INT iMusicVolume;
  160. INT iSoundVolume;
  161. MUSICTYPE eMusicType;
  162. MUSICTYPE eCDType;
  163. OPLTYPE eOPLType;
  164. WORD wAudioBufferSize;
  165. BOOL fIsWIN95;
  166. BOOL fUseEmbeddedFonts;
  167. BOOL fUseSurroundOPL;
  168. #if SDL_VERSION_ATLEAST(2,0,0)
  169. BOOL fKeepAspectRatio;
  170. #endif
  171. BOOL fFullScreen;
  172. BOOL fEnableJoyStick;
  173. BOOL fUseCustomScreenLayout;
  174. BOOL fLaunchSetting;
  175. BOOL fUseTouchOverlay;
  176. #if USE_RIX_EXTRA_INIT
  177. uint32_t *pExtraFMRegs;
  178. uint8_t *pExtraFMVals;
  179. uint32_t dwExtraLength;
  180. #endif
  181. } CONFIGURATION, *LPCONFIGURATION;
  182. extern CONFIGURATION gConfig;
  183. VOID
  184. PAL_LoadConfig(
  185. BOOL fFromFile
  186. );
  187. BOOL
  188. PAL_SaveConfig(
  189. VOID
  190. );
  191. BOOL
  192. PAL_ParseConfigLine(
  193. const char * line,
  194. const ConfigItem ** pItem,
  195. ConfigValue * pValue
  196. );
  197. ConfigValue
  198. PAL_DefaultConfig(
  199. PALCFG_ITEM item
  200. );
  201. const char *
  202. PAL_ConfigName(
  203. PALCFG_ITEM item
  204. );
  205. BOOL
  206. PAL_LimitConfig(
  207. PALCFG_ITEM item,
  208. ConfigValue * pValue
  209. );
  210. # ifdef __cplusplus
  211. }
  212. # endif
  213. #endif