palcfg.h 5.5 KB

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