palcfg.h 5.5 KB

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