palcommon.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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 OBJECT_ITEM_START 0x3D
  65. #define OBJECT_ITEM_END 0x126
  66. #define OBJECT_MAGIC_START 0x127
  67. #define OBJECT_MAGIC_END 0x18D
  68. #define MINIMAL_WORD_COUNT (MAX_OBJECTS + 13)
  69. typedef enum tagPALDIRECTION
  70. {
  71. kDirSouth = 0,
  72. kDirWest,
  73. kDirNorth,
  74. kDirEast,
  75. kDirUnknown
  76. } PALDIRECTION, *LPPALDIRECTION;
  77. typedef enum tagMUSICTYPE
  78. {
  79. MUSIC_MIDI,
  80. MUSIC_RIX,
  81. MUSIC_MP3,
  82. MUSIC_OGG,
  83. MUSIC_SDLCD
  84. } MUSICTYPE, *LPMUSICTYPE;
  85. typedef enum tagOPLTYPE
  86. {
  87. OPL_DOSBOX,
  88. OPL_MAME,
  89. OPL_DOSBOX_NEW,
  90. } OPLTYPE, *LPOPLTYPE;
  91. typedef enum tagCODEPAGE {
  92. CP_MIN = 0,
  93. CP_BIG5 = 0,
  94. CP_GBK = 1,
  95. //CP_SHIFTJIS = 2,
  96. //CP_JISX0208 = 3,
  97. CP_MAX = CP_GBK + 1,
  98. CP_UTF_8 = CP_MAX + 1
  99. } CODEPAGE;
  100. typedef enum tagPALFILE {
  101. PALFILE_ABC = 0x00000001,
  102. PALFILE_BALL = 0x00000002,
  103. PALFILE_DATA = 0x00000004,
  104. PALFILE_F = 0x00000008,
  105. PALFILE_FBP = 0x00000010,
  106. PALFILE_FIRE = 0x00000020,
  107. PALFILE_GOP = 0x00000040,
  108. PALFILE_MAP = 0x00000080,
  109. PALFILE_MGO = 0x00000100,
  110. PALFILE_PAT = 0x00000200,
  111. PALFILE_RGM = 0x00000400,
  112. PALFILE_RNG = 0x00000800,
  113. PALFILE_SSS = 0x00001000,
  114. PALFILE_MSG = 0x00002000,
  115. PALFILE_M = 0x00004000,
  116. PALFILE_WORD = 0x00008000,
  117. PALFILE_REQUIRED_MASK = 0x0000ffff,
  118. PALFILE_VOC = 0x00010000,
  119. PALFILE_SOUNDS = 0x00020000,
  120. PALFILE_SOUND_MASK = 0x00030000,
  121. PALFILE_MIDI = 0x00040000,
  122. PALFILE_MUS = 0x00080000,
  123. PALFILE_MUSIC_MASK = 0x000c0000,
  124. } PALFILE;
  125. #define PAL_MISSING_REQUIRED(x) (((x) & PALFILE_REQUIRED_MASK) != 0)
  126. #define PAL_MISSING_SOUND(x) (((x) & PALFILE_SOUND_MASK) == PALFILE_SOUND_MASK)
  127. #define PAL_MISSING_MUSIC(x) (((x) & PALFILE_MUSIC_MASK) == PALFILE_MUSIC_MASK)
  128. PAL_C_LINKAGE_BEGIN
  129. INT
  130. PAL_RLEBlitToSurface(
  131. LPCBITMAPRLE lpBitmapRLE,
  132. SDL_Surface *lpDstSurface,
  133. PAL_POS pos
  134. );
  135. INT
  136. PAL_RLEBlitToSurfaceWithShadow(
  137. LPCBITMAPRLE lpBitmapRLE,
  138. SDL_Surface *lpDstSurface,
  139. PAL_POS pos,
  140. BOOL bShadow
  141. );
  142. INT
  143. PAL_RLEBlitWithColorShift(
  144. LPCBITMAPRLE lpBitmapRLE,
  145. SDL_Surface *lpDstSurface,
  146. PAL_POS pos,
  147. INT iColorShift
  148. );
  149. INT
  150. PAL_RLEBlitMonoColor(
  151. LPCBITMAPRLE lpBitmapRLE,
  152. SDL_Surface *lpDstSurface,
  153. PAL_POS pos,
  154. BYTE bColor,
  155. INT iColorShift
  156. );
  157. INT
  158. PAL_FBPBlitToSurface(
  159. LPBYTE lpBitmapFBP,
  160. SDL_Surface *lpDstSurface
  161. );
  162. INT
  163. PAL_RLEGetWidth(
  164. LPCBITMAPRLE lpBitmapRLE
  165. );
  166. INT
  167. PAL_RLEGetHeight(
  168. LPCBITMAPRLE lpBitmapRLE
  169. );
  170. WORD
  171. PAL_SpriteGetNumFrames(
  172. LPCSPRITE lpSprite
  173. );
  174. LPCBITMAPRLE
  175. PAL_SpriteGetFrame(
  176. LPCSPRITE lpSprite,
  177. INT iFrameNum
  178. );
  179. INT
  180. PAL_MKFGetChunkCount(
  181. FILE *fp
  182. );
  183. INT
  184. PAL_MKFGetChunkSize(
  185. UINT uiChunkNum,
  186. FILE *fp
  187. );
  188. INT
  189. PAL_MKFReadChunk(
  190. LPBYTE lpBuffer,
  191. UINT uiBufferSize,
  192. UINT uiChunkNum,
  193. FILE *fp
  194. );
  195. INT
  196. PAL_MKFGetDecompressedSize(
  197. UINT uiChunkNum,
  198. FILE *fp
  199. );
  200. INT
  201. PAL_MKFDecompressChunk(
  202. LPBYTE lpBuffer,
  203. UINT uiBufferSize,
  204. UINT uiChunkNum,
  205. FILE *fp
  206. );
  207. // From yj1.c:
  208. extern INT
  209. (*Decompress)(
  210. LPCVOID Source,
  211. LPVOID Destination,
  212. INT DestSize
  213. );
  214. INT
  215. YJ1_Decompress(
  216. LPCVOID Source,
  217. LPVOID Destination,
  218. INT DestSize
  219. );
  220. INT
  221. YJ2_Decompress(
  222. LPCVOID Source,
  223. LPVOID Destination,
  224. INT DestSize
  225. );
  226. PAL_C_LINKAGE_END
  227. #define PAL_DelayUntil(t) \
  228. PAL_ProcessEvent(); \
  229. while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
  230. { \
  231. PAL_ProcessEvent(); \
  232. SDL_Delay(1); \
  233. }
  234. #endif // _PALUTILS_H