palcommon.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. CP_UCS = CP_UTF_8 + 1,
  96. } CODEPAGE;
  97. typedef enum tagPALFILE {
  98. PALFILE_ABC = 0x00000001,
  99. PALFILE_BALL = 0x00000002,
  100. PALFILE_DATA = 0x00000004,
  101. PALFILE_F = 0x00000008,
  102. PALFILE_FBP = 0x00000010,
  103. PALFILE_FIRE = 0x00000020,
  104. PALFILE_GOP = 0x00000040,
  105. PALFILE_MAP = 0x00000080,
  106. PALFILE_MGO = 0x00000100,
  107. PALFILE_PAT = 0x00000200,
  108. PALFILE_RGM = 0x00000400,
  109. PALFILE_RNG = 0x00000800,
  110. PALFILE_SSS = 0x00001000,
  111. PALFILE_MSG = 0x00002000,
  112. PALFILE_M = 0x00004000,
  113. PALFILE_WORD = 0x00008000,
  114. PALFILE_REQUIRED_MASK = 0x0000ffff,
  115. PALFILE_VOC = 0x00010000,
  116. PALFILE_SOUNDS = 0x00020000,
  117. PALFILE_SOUND_MASK = 0x00030000,
  118. PALFILE_MIDI = 0x00040000,
  119. PALFILE_MUS = 0x00080000,
  120. PALFILE_MUSIC_MASK = 0x000c0000,
  121. } PALFILE;
  122. #define PAL_MISSING_REQUIRED(x) (((x) & PALFILE_REQUIRED_MASK) != 0)
  123. #define PAL_MISSING_SOUND(x) (((x) & PALFILE_SOUND_MASK) == PALFILE_SOUND_MASK)
  124. #define PAL_MISSING_MUSIC(x) (((x) & PALFILE_MUSIC_MASK) == PALFILE_MUSIC_MASK)
  125. PAL_C_LINKAGE_BEGIN
  126. INT
  127. PAL_RLEBlitToSurface(
  128. LPCBITMAPRLE lpBitmapRLE,
  129. SDL_Surface *lpDstSurface,
  130. PAL_POS pos
  131. );
  132. INT
  133. PAL_RLEBlitToSurfaceWithShadow(
  134. LPCBITMAPRLE lpBitmapRLE,
  135. SDL_Surface *lpDstSurface,
  136. PAL_POS pos,
  137. BOOL bShadow
  138. );
  139. INT
  140. PAL_RLEBlitWithColorShift(
  141. LPCBITMAPRLE lpBitmapRLE,
  142. SDL_Surface *lpDstSurface,
  143. PAL_POS pos,
  144. INT iColorShift
  145. );
  146. INT
  147. PAL_RLEBlitMonoColor(
  148. LPCBITMAPRLE lpBitmapRLE,
  149. SDL_Surface *lpDstSurface,
  150. PAL_POS pos,
  151. BYTE bColor,
  152. INT iColorShift
  153. );
  154. INT
  155. PAL_FBPBlitToSurface(
  156. LPBYTE lpBitmapFBP,
  157. SDL_Surface *lpDstSurface
  158. );
  159. INT
  160. PAL_RLEGetWidth(
  161. LPCBITMAPRLE lpBitmapRLE
  162. );
  163. INT
  164. PAL_RLEGetHeight(
  165. LPCBITMAPRLE lpBitmapRLE
  166. );
  167. WORD
  168. PAL_SpriteGetNumFrames(
  169. LPCSPRITE lpSprite
  170. );
  171. LPCBITMAPRLE
  172. PAL_SpriteGetFrame(
  173. LPCSPRITE lpSprite,
  174. INT iFrameNum
  175. );
  176. INT
  177. PAL_MKFGetChunkCount(
  178. FILE *fp
  179. );
  180. INT
  181. PAL_MKFGetChunkSize(
  182. UINT uiChunkNum,
  183. FILE *fp
  184. );
  185. INT
  186. PAL_MKFReadChunk(
  187. LPBYTE lpBuffer,
  188. UINT uiBufferSize,
  189. UINT uiChunkNum,
  190. FILE *fp
  191. );
  192. INT
  193. PAL_MKFGetDecompressedSize(
  194. UINT uiChunkNum,
  195. FILE *fp
  196. );
  197. INT
  198. PAL_MKFDecompressChunk(
  199. LPBYTE lpBuffer,
  200. UINT uiBufferSize,
  201. UINT uiChunkNum,
  202. FILE *fp
  203. );
  204. // From yj1.c:
  205. extern INT
  206. (*Decompress)(
  207. LPCVOID Source,
  208. LPVOID Destination,
  209. INT DestSize
  210. );
  211. INT
  212. YJ1_Decompress(
  213. LPCVOID Source,
  214. LPVOID Destination,
  215. INT DestSize
  216. );
  217. INT
  218. YJ2_Decompress(
  219. LPCVOID Source,
  220. LPVOID Destination,
  221. INT DestSize
  222. );
  223. PAL_C_LINKAGE_END
  224. #define PAL_DelayUntil(t) \
  225. PAL_ProcessEvent(); \
  226. while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
  227. { \
  228. PAL_ProcessEvent(); \
  229. SDL_Delay(1); \
  230. }
  231. #endif // _PALUTILS_H