palcfg.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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.h: Configuration definition.
  23. // @Author: Lou Yihua <louyihua@21cn.com>, 2016.
  24. //
  25. #ifndef CONFIG_H
  26. #define CONFIG_H
  27. #include "common.h"
  28. #include "palcommon.h"
  29. #define PAL_MAX_SAMPLERATE 49716
  30. #define PAL_MAX_VOLUME 100
  31. typedef enum tagPALCFG_ITEM
  32. {
  33. PALCFG_ALL_MIN = 0,
  34. PALCFG_BOOLEAN_MIN = PALCFG_ALL_MIN,
  35. /* Booleans */
  36. PALCFG_FULLSCREEN = PALCFG_BOOLEAN_MIN,
  37. PALCFG_KEEPASPECTRATIO,
  38. PALCFG_LAUNCHSETTING,
  39. PALCFG_STEREO,
  40. PALCFG_USESURROUNDOPL,
  41. PALCFG_ENABLEKEYREPEAT,
  42. PALCFG_USETOUCHOVERLAY,
  43. PALCFG_ENABLEAVIPLAY,
  44. /* Booleans */
  45. PALCFG_BOOLEAN_MAX,
  46. PALCFG_INTEGER_MIN = PALCFG_BOOLEAN_MAX,
  47. /* Integers */
  48. PALCFG_SURROUNDOPLOFFSET = PALCFG_INTEGER_MIN,
  49. PALCFG_LOGLEVEL,
  50. /* Integers */
  51. PALCFG_INTEGER_MAX,
  52. PALCFG_UNSIGNED_MIN = PALCFG_INTEGER_MAX,
  53. /* Unsigneds */
  54. PALCFG_AUDIOBUFFERSIZE = PALCFG_UNSIGNED_MIN,
  55. PALCFG_OPLSAMPLERATE,
  56. PALCFG_RESAMPLEQUALITY,
  57. PALCFG_SAMPLERATE,
  58. PALCFG_MUSICVOLUME,
  59. PALCFG_SOUNDVOLUME,
  60. PALCFG_WINDOWHEIGHT,
  61. PALCFG_WINDOWWIDTH,
  62. /* Unsigneds */
  63. PALCFG_UNSIGNED_MAX,
  64. PALCFG_STRING_MIN = PALCFG_UNSIGNED_MAX,
  65. /* Strings */
  66. PALCFG_CD = PALCFG_STRING_MIN,
  67. PALCFG_GAMEPATH,
  68. PALCFG_SAVEPATH,
  69. PALCFG_MESSAGEFILE,
  70. PALCFG_FONTFILE,
  71. PALCFG_MUSIC,
  72. PALCFG_OPL,
  73. PALCFG_LOGFILE,
  74. PALCFG_RIXEXTRAINIT,
  75. PALCFG_MIDICLIENT,
  76. PALCFG_SCALEQUALITY,
  77. PALCFG_ASPECTRATIO,
  78. /* Strings */
  79. PALCFG_STRING_MAX,
  80. PALCFG_ALL_MAX = PALCFG_STRING_MAX
  81. } PALCFG_ITEM;
  82. typedef enum tagPALCFG_TYPE
  83. {
  84. PALCFG_STRING,
  85. PALCFG_BOOLEAN,
  86. PALCFG_INTEGER,
  87. PALCFG_UNSIGNED,
  88. } PALCFG_TYPE;
  89. typedef union tagConfigValue
  90. {
  91. LPCSTR sValue;
  92. DWORD uValue;
  93. INT iValue;
  94. BOOL bValue;
  95. } ConfigValue;
  96. typedef struct tagConfigItem
  97. {
  98. PALCFG_ITEM Item;
  99. PALCFG_TYPE Type;
  100. const char* Name;
  101. int NameLength;
  102. const ConfigValue DefaultValue;
  103. const ConfigValue MinValue;
  104. const ConfigValue MaxValue;
  105. } ConfigItem;
  106. typedef struct tagSCREENLAYOUT
  107. {
  108. PAL_POS EquipImageBox;
  109. PAL_POS EquipRoleListBox;
  110. PAL_POS EquipItemName;
  111. PAL_POS EquipItemAmount;
  112. PAL_POS EquipLabels[MAX_PLAYER_EQUIPMENTS];
  113. PAL_POS EquipNames[MAX_PLAYER_EQUIPMENTS];
  114. PAL_POS EquipStatusLabels[5];
  115. PAL_POS EquipStatusValues[5];
  116. PAL_POS RoleName;
  117. PAL_POS RoleImage;
  118. PAL_POS RoleExpLabel;
  119. PAL_POS RoleLevelLabel;
  120. PAL_POS RoleHPLabel;
  121. PAL_POS RoleMPLabel;
  122. PAL_POS RoleStatusLabels[5];
  123. PAL_POS RoleCurrExp;
  124. PAL_POS RoleNextExp;
  125. PAL_POS RoleExpSlash;
  126. PAL_POS RoleLevel;
  127. PAL_POS RoleCurHP;
  128. PAL_POS RoleMaxHP;
  129. PAL_POS RoleHPSlash;
  130. PAL_POS RoleCurMP;
  131. PAL_POS RoleMaxMP;
  132. PAL_POS RoleMPSlash;
  133. PAL_POS RoleStatusValues[5];
  134. PAL_POS RoleEquipImageBoxes[MAX_PLAYER_EQUIPMENTS];
  135. PAL_POS RoleEquipNames[MAX_PLAYER_EQUIPMENTS];
  136. PAL_POS RolePoisonNames[MAX_POISONS];
  137. PAL_POS ExtraItemDescLines;
  138. PAL_POS ExtraMagicDescLines;
  139. } SCREENLAYOUT;
  140. typedef struct tagCONFIGURATION
  141. {
  142. union {
  143. SCREENLAYOUT ScreenLayout;
  144. PAL_POS ScreenLayoutArray[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  145. };
  146. enum {
  147. USE_8x8_FONT = 1,
  148. DISABLE_SHADOW = 2,
  149. } ScreenLayoutFlag[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  150. /* Configurable options */
  151. char *pszGamePath;
  152. char *pszSavePath;
  153. char *pszMsgFile;
  154. char *pszFontFile;
  155. char *pszMIDIClient;
  156. char *pszLogFile;
  157. char *pszScaleQuality;
  158. DWORD dwWordLength;
  159. DWORD dwScreenWidth;
  160. DWORD dwScreenHeight;
  161. DWORD dwAspectX;
  162. DWORD dwAspectY;
  163. INT iSurroundOPLOffset;
  164. INT iAudioChannels;
  165. INT iSampleRate;
  166. INT iOPLSampleRate;
  167. INT iResampleQuality;
  168. INT iMusicVolume;
  169. INT iSoundVolume;
  170. LOGLEVEL iLogLevel;
  171. MUSICTYPE eMusicType;
  172. MUSICTYPE eCDType;
  173. OPLTYPE eOPLType;
  174. WORD wAudioBufferSize;
  175. BOOL fIsWIN95;
  176. BOOL fUseSurroundOPL;
  177. BOOL fKeepAspectRatio;
  178. BOOL fFullScreen;
  179. BOOL fEnableJoyStick;
  180. BOOL fUseCustomScreenLayout;
  181. BOOL fLaunchSetting;
  182. BOOL fEnableKeyRepeat;
  183. BOOL fUseTouchOverlay;
  184. BOOL fEnableAviPlay;
  185. #if USE_RIX_EXTRA_INIT
  186. uint32_t *pExtraFMRegs;
  187. uint8_t *pExtraFMVals;
  188. uint32_t dwExtraLength;
  189. #endif
  190. } CONFIGURATION, *LPCONFIGURATION;
  191. PAL_C_LINKAGE_BEGIN
  192. extern CONFIGURATION gConfig;
  193. void
  194. PAL_LoadConfig(
  195. BOOL fFromFile
  196. );
  197. BOOL
  198. PAL_SaveConfig(
  199. void
  200. );
  201. void
  202. PAL_FreeConfig(
  203. void
  204. );
  205. BOOL
  206. PAL_ParseConfigLine(
  207. const char * line,
  208. const ConfigItem ** pItem,
  209. ConfigValue * pValue
  210. );
  211. const char *
  212. PAL_ConfigName(
  213. PALCFG_ITEM item
  214. );
  215. PALCFG_ITEM
  216. PAL_ConfigIndex(
  217. const char *name
  218. );
  219. PALCFG_TYPE
  220. PAL_ConfigType(
  221. PALCFG_ITEM item
  222. );
  223. BOOL
  224. PAL_LimitConfig(
  225. PALCFG_ITEM item,
  226. ConfigValue * pValue
  227. );
  228. ConfigValue
  229. PAL_GetConfigItem(
  230. PALCFG_ITEM item,
  231. BOOL default_value
  232. );
  233. void
  234. PAL_SetConfigItem(
  235. PALCFG_ITEM item,
  236. const ConfigValue value
  237. );
  238. BOOL
  239. PAL_GetConfigBoolean(
  240. PALCFG_ITEM item,
  241. BOOL default_value
  242. );
  243. long
  244. PAL_GetConfigNumber(
  245. PALCFG_ITEM item,
  246. BOOL default_value
  247. );
  248. int
  249. PAL_GetConfigInteger(
  250. PALCFG_ITEM item,
  251. BOOL default_value
  252. );
  253. unsigned int
  254. PAL_GetConfigUnsigned(
  255. PALCFG_ITEM item,
  256. BOOL default_value
  257. );
  258. const char *
  259. PAL_GetConfigString(
  260. PALCFG_ITEM item,
  261. BOOL default_value
  262. );
  263. BOOL
  264. PAL_SetConfigBoolean(
  265. PALCFG_ITEM item,
  266. BOOL value
  267. );
  268. BOOL
  269. PAL_SetConfigNumber(
  270. PALCFG_ITEM item,
  271. long value
  272. );
  273. BOOL
  274. PAL_SetConfigInteger(
  275. PALCFG_ITEM item,
  276. int value
  277. );
  278. BOOL
  279. PAL_SetConfigUnsigned(
  280. PALCFG_ITEM item,
  281. unsigned int value
  282. );
  283. BOOL
  284. PAL_SetConfigString(
  285. PALCFG_ITEM item,
  286. const char *value
  287. );
  288. PAL_C_LINKAGE_END
  289. #endif