palcommon.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. #ifndef _PALUTILS_H
  23. #define _PALUTILS_H
  24. #include "common.h"
  25. typedef LPBYTE LPSPRITE, LPBITMAPRLE;
  26. typedef LPCBYTE LPCSPRITE, LPCBITMAPRLE;
  27. #ifndef PAL_POS_DEFINED
  28. #define PAL_POS_DEFINED
  29. typedef DWORD PAL_POS;
  30. #endif
  31. #define PAL_XY(x, y) (PAL_POS)(((((WORD)(y)) << 16) & 0xFFFF0000) | (((WORD)(x)) & 0xFFFF))
  32. #define PAL_X(xy) (SHORT)((xy) & 0xFFFF)
  33. #define PAL_Y(xy) (SHORT)(((xy) >> 16) & 0xFFFF)
  34. #define PAL_XY_OFFSET(xy, x, y) (PAL_POS)(((((INT)(y) << 16) & 0xFFFF0000) + ((xy) & 0xFFFF0000)) | (((INT)(x) & 0xFFFF) + ((xy) & 0xFFFF)))
  35. // maximum number of players in party
  36. #define MAX_PLAYERS_IN_PARTY 3
  37. // total number of possible player roles
  38. #define MAX_PLAYER_ROLES 6
  39. // totally number of playable player roles
  40. #define MAX_PLAYABLE_PLAYER_ROLES 5
  41. // maximum entries of inventory
  42. #define MAX_INVENTORY 256
  43. // maximum items in a store
  44. #define MAX_STORE_ITEM 9
  45. // total number of magic attributes
  46. #define NUM_MAGIC_ELEMENTAL 5
  47. // maximum number of enemies in a team
  48. #define MAX_ENEMIES_IN_TEAM 5
  49. // maximum number of equipments for a player
  50. #define MAX_PLAYER_EQUIPMENTS 6
  51. // maximum number of magics for a player
  52. #define MAX_PLAYER_MAGICS 32
  53. // maximum number of scenes
  54. #define MAX_SCENES 300
  55. // maximum number of objects
  56. #define MAX_OBJECTS 600
  57. // maximum number of event objects (should be somewhat more than the original,
  58. // as there are some modified versions which has more)
  59. #define MAX_EVENT_OBJECTS 5500
  60. // maximum number of effective poisons to players
  61. #define MAX_POISONS 16
  62. // maximum number of level
  63. #define MAX_LEVELS 99
  64. #define MINIMAL_WORD_COUNT (MAX_OBJECTS + 13)
  65. typedef enum tagPALDIRECTION
  66. {
  67. kDirSouth = 0,
  68. kDirWest,
  69. kDirNorth,
  70. kDirEast,
  71. kDirUnknown
  72. } PALDIRECTION, *LPPALDIRECTION;
  73. typedef enum tagMUSICTYPE
  74. {
  75. MUSIC_MIDI,
  76. MUSIC_RIX,
  77. MUSIC_MP3,
  78. MUSIC_OGG,
  79. MUSIC_SDLCD
  80. } MUSICTYPE, *LPMUSICTYPE;
  81. typedef enum tagOPLTYPE
  82. {
  83. OPL_DOSBOX,
  84. OPL_MAME,
  85. OPL_DOSBOX_NEW,
  86. } OPLTYPE, *LPOPLTYPE;
  87. typedef enum tagCODEPAGE {
  88. CP_MIN = 0,
  89. CP_BIG5 = 0,
  90. CP_GBK = 1,
  91. //CP_SHIFTJIS = 2,
  92. //CP_JISX0208 = 3,
  93. CP_MAX = CP_GBK + 1,
  94. CP_UTF_8 = CP_MAX + 1
  95. } CODEPAGE;
  96. typedef enum tagPALFILE {
  97. PALFILE_ABC = 0x00000001,
  98. PALFILE_BALL = 0x00000002,
  99. PALFILE_DATA = 0x00000004,
  100. PALFILE_F = 0x00000008,
  101. PALFILE_FBP = 0x00000010,
  102. PALFILE_FIRE = 0x00000020,
  103. PALFILE_GOP = 0x00000040,
  104. PALFILE_MAP = 0x00000080,
  105. PALFILE_MGO = 0x00000100,
  106. PALFILE_PAT = 0x00000200,
  107. PALFILE_RGM = 0x00000400,
  108. PALFILE_RNG = 0x00000800,
  109. PALFILE_SSS = 0x00001000,
  110. PALFILE_MSG = 0x00002000,
  111. PALFILE_M = 0x00004000,
  112. PALFILE_WORD = 0x00008000,
  113. PALFILE_REQUIRED_MASK = 0x0000ffff,
  114. PALFILE_VOC = 0x00010000,
  115. PALFILE_SOUNDS = 0x00020000,
  116. PALFILE_SOUND_MASK = 0x00030000,
  117. PALFILE_MIDI = 0x00040000,
  118. PALFILE_MUS = 0x00080000,
  119. PALFILE_MUSIC_MASK = 0x000c0000,
  120. } PALFILE;
  121. #define PAL_MISSING_REQUIRED(x) (((x) & PALFILE_REQUIRED_MASK) != 0)
  122. #define PAL_MISSING_SOUND(x) (((x) & PALFILE_SOUND_MASK) == PALFILE_SOUND_MASK)
  123. #define PAL_MISSING_MUSIC(x) (((x) & PALFILE_MUSIC_MASK) == PALFILE_MUSIC_MASK)
  124. PAL_C_LINKAGE_BEGIN
  125. INT
  126. PAL_RLEBlitToSurface(
  127. LPCBITMAPRLE lpBitmapRLE,
  128. SDL_Surface *lpDstSurface,
  129. PAL_POS pos
  130. );
  131. INT
  132. PAL_RLEBlitToSurfaceWithShadow(
  133. LPCBITMAPRLE lpBitmapRLE,
  134. SDL_Surface *lpDstSurface,
  135. PAL_POS pos,
  136. BOOL bShadow
  137. );
  138. INT
  139. PAL_RLEBlitWithColorShift(
  140. LPCBITMAPRLE lpBitmapRLE,
  141. SDL_Surface *lpDstSurface,
  142. PAL_POS pos,
  143. INT iColorShift
  144. );
  145. INT
  146. PAL_RLEBlitMonoColor(
  147. LPCBITMAPRLE lpBitmapRLE,
  148. SDL_Surface *lpDstSurface,
  149. PAL_POS pos,
  150. BYTE bColor,
  151. INT iColorShift
  152. );
  153. INT
  154. PAL_FBPBlitToSurface(
  155. LPBYTE lpBitmapFBP,
  156. SDL_Surface *lpDstSurface
  157. );
  158. INT
  159. PAL_RLEGetWidth(
  160. LPCBITMAPRLE lpBitmapRLE
  161. );
  162. INT
  163. PAL_RLEGetHeight(
  164. LPCBITMAPRLE lpBitmapRLE
  165. );
  166. WORD
  167. PAL_SpriteGetNumFrames(
  168. LPCSPRITE lpSprite
  169. );
  170. LPCBITMAPRLE
  171. PAL_SpriteGetFrame(
  172. LPCSPRITE lpSprite,
  173. INT iFrameNum
  174. );
  175. INT
  176. PAL_MKFGetChunkCount(
  177. FILE *fp
  178. );
  179. INT
  180. PAL_MKFGetChunkSize(
  181. UINT uiChunkNum,
  182. FILE *fp
  183. );
  184. INT
  185. PAL_MKFReadChunk(
  186. LPBYTE lpBuffer,
  187. UINT uiBufferSize,
  188. UINT uiChunkNum,
  189. FILE *fp
  190. );
  191. INT
  192. PAL_MKFGetDecompressedSize(
  193. UINT uiChunkNum,
  194. FILE *fp
  195. );
  196. INT
  197. PAL_MKFDecompressChunk(
  198. LPBYTE lpBuffer,
  199. UINT uiBufferSize,
  200. UINT uiChunkNum,
  201. FILE *fp
  202. );
  203. // From yj1.c:
  204. extern INT
  205. (*Decompress)(
  206. LPCVOID Source,
  207. LPVOID Destination,
  208. INT DestSize
  209. );
  210. INT
  211. YJ1_Decompress(
  212. LPCVOID Source,
  213. LPVOID Destination,
  214. INT DestSize
  215. );
  216. INT
  217. YJ2_Decompress(
  218. LPCVOID Source,
  219. LPVOID Destination,
  220. INT DestSize
  221. );
  222. PAL_C_LINKAGE_END
  223. #define PAL_DelayUntil(t) \
  224. PAL_ProcessEvent(); \
  225. while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
  226. { \
  227. PAL_ProcessEvent(); \
  228. SDL_Delay(1); \
  229. }
  230. #endif // _PALUTILS_H