palcfg.h 5.3 KB

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