palcfg.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 48000
  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_USEEMBEDDEDFONTS,
  41. PALCFG_USESURROUNDOPL,
  42. PALCFG_USETOUCHOVERLAY,
  43. /* Booleans */
  44. PALCFG_BOOLEAN_MAX,
  45. PALCFG_INTEGER_MIN = PALCFG_BOOLEAN_MAX,
  46. /* Integers */
  47. PALCFG_SURROUNDOPLOFFSET = PALCFG_INTEGER_MIN,
  48. PALCFG_LOGLEVEL,
  49. /* Integers */
  50. PALCFG_INTEGER_MAX,
  51. PALCFG_UNSIGNED_MIN = PALCFG_INTEGER_MAX,
  52. /* Unsigneds */
  53. PALCFG_AUDIOBUFFERSIZE = PALCFG_UNSIGNED_MIN,
  54. PALCFG_CODEPAGE,
  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_BDFFILE,
  71. PALCFG_MUSIC,
  72. PALCFG_OPL,
  73. PALCFG_RIXEXTRAINIT,
  74. PALCFG_CLIMIDIPLAYER,
  75. /* Strings */
  76. PALCFG_STRING_MAX,
  77. PALCFG_ALL_MAX = PALCFG_STRING_MAX
  78. } PALCFG_ITEM;
  79. typedef enum tagPALCFG_TYPE
  80. {
  81. PALCFG_STRING,
  82. PALCFG_BOOLEAN,
  83. PALCFG_INTEGER,
  84. PALCFG_UNSIGNED,
  85. } PALCFG_TYPE;
  86. typedef union tagConfigValue
  87. {
  88. LPCSTR sValue;
  89. DWORD uValue;
  90. INT iValue;
  91. BOOL bValue;
  92. } ConfigValue;
  93. typedef struct tagConfigItem
  94. {
  95. PALCFG_ITEM Item;
  96. PALCFG_TYPE Type;
  97. const char* Name;
  98. int NameLength;
  99. const ConfigValue DefaultValue;
  100. const ConfigValue MinValue;
  101. const ConfigValue MaxValue;
  102. } ConfigItem;
  103. typedef struct tagSCREENLAYOUT
  104. {
  105. PAL_POS EquipImageBox;
  106. PAL_POS EquipRoleListBox;
  107. PAL_POS EquipItemName;
  108. PAL_POS EquipItemAmount;
  109. PAL_POS EquipLabels[MAX_PLAYER_EQUIPMENTS];
  110. PAL_POS EquipNames[MAX_PLAYER_EQUIPMENTS];
  111. PAL_POS EquipStatusLabels[5];
  112. PAL_POS EquipStatusValues[5];
  113. PAL_POS RoleName;
  114. PAL_POS RoleImage;
  115. PAL_POS RoleExpLabel;
  116. PAL_POS RoleLevelLabel;
  117. PAL_POS RoleHPLabel;
  118. PAL_POS RoleMPLabel;
  119. PAL_POS RoleStatusLabels[5];
  120. PAL_POS RoleCurrExp;
  121. PAL_POS RoleNextExp;
  122. PAL_POS RoleExpSlash;
  123. PAL_POS RoleLevel;
  124. PAL_POS RoleCurHP;
  125. PAL_POS RoleMaxHP;
  126. PAL_POS RoleHPSlash;
  127. PAL_POS RoleCurMP;
  128. PAL_POS RoleMaxMP;
  129. PAL_POS RoleMPSlash;
  130. PAL_POS RoleStatusValues[5];
  131. PAL_POS RoleEquipImageBoxes[MAX_PLAYER_EQUIPMENTS];
  132. PAL_POS RoleEquipNames[MAX_PLAYER_EQUIPMENTS];
  133. PAL_POS RolePoisonNames[MAX_POISONS];
  134. PAL_POS ExtraItemDescLines;
  135. PAL_POS ExtraMagicDescLines;
  136. } SCREENLAYOUT;
  137. typedef struct tagCONFIGURATION
  138. {
  139. union {
  140. SCREENLAYOUT ScreenLayout;
  141. PAL_POS ScreenLayoutArray[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  142. };
  143. enum {
  144. USE_8x8_FONT = 1,
  145. DISABLE_SHADOW = 2,
  146. } ScreenLayoutFlag[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  147. /* Configurable options */
  148. char *pszGamePath;
  149. char *pszSavePath;
  150. char *pszMsgFile;
  151. char *pszBdfFile;
  152. char *pszCLIMIDIPlayerPath;
  153. CODEPAGE uCodePage;
  154. DWORD dwWordLength;
  155. DWORD dwScreenWidth;
  156. DWORD dwScreenHeight;
  157. INT iSurroundOPLOffset;
  158. INT iAudioChannels;
  159. INT iSampleRate;
  160. INT iOPLSampleRate;
  161. INT iResampleQuality;
  162. INT iMusicVolume;
  163. INT iSoundVolume;
  164. LOGLEVEL iLogLevel;
  165. MUSICTYPE eMusicType;
  166. MUSICTYPE eCDType;
  167. OPLTYPE eOPLType;
  168. WORD wAudioBufferSize;
  169. BOOL fIsWIN95;
  170. BOOL fUseEmbeddedFonts;
  171. BOOL fUseSurroundOPL;
  172. BOOL fKeepAspectRatio;
  173. BOOL fFullScreen;
  174. BOOL fEnableJoyStick;
  175. BOOL fUseCustomScreenLayout;
  176. BOOL fLaunchSetting;
  177. BOOL fUseTouchOverlay;
  178. #if USE_RIX_EXTRA_INIT
  179. uint32_t *pExtraFMRegs;
  180. uint8_t *pExtraFMVals;
  181. uint32_t dwExtraLength;
  182. #endif
  183. } CONFIGURATION, *LPCONFIGURATION;
  184. PAL_C_LINKAGE_BEGIN
  185. extern CONFIGURATION gConfig;
  186. VOID
  187. PAL_LoadConfig(
  188. BOOL fFromFile
  189. );
  190. BOOL
  191. PAL_SaveConfig(
  192. VOID
  193. );
  194. BOOL
  195. PAL_ParseConfigLine(
  196. const char * line,
  197. const ConfigItem ** pItem,
  198. ConfigValue * pValue
  199. );
  200. ConfigValue
  201. PAL_DefaultConfig(
  202. PALCFG_ITEM item
  203. );
  204. const char *
  205. PAL_ConfigName(
  206. PALCFG_ITEM item
  207. );
  208. BOOL
  209. PAL_LimitConfig(
  210. PALCFG_ITEM item,
  211. ConfigValue * pValue
  212. );
  213. PAL_C_LINKAGE_END
  214. #endif