palcommon.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. PAL_C_LINKAGE_BEGIN
  101. INT
  102. PAL_RLEBlitToSurface(
  103. LPCBITMAPRLE lpBitmapRLE,
  104. SDL_Surface *lpDstSurface,
  105. PAL_POS pos
  106. );
  107. INT
  108. PAL_RLEBlitToSurfaceWithShadow(
  109. LPCBITMAPRLE lpBitmapRLE,
  110. SDL_Surface *lpDstSurface,
  111. PAL_POS pos,
  112. BOOL bShadow
  113. );
  114. INT
  115. PAL_RLEBlitWithColorShift(
  116. LPCBITMAPRLE lpBitmapRLE,
  117. SDL_Surface *lpDstSurface,
  118. PAL_POS pos,
  119. INT iColorShift
  120. );
  121. INT
  122. PAL_RLEBlitMonoColor(
  123. LPCBITMAPRLE lpBitmapRLE,
  124. SDL_Surface *lpDstSurface,
  125. PAL_POS pos,
  126. BYTE bColor,
  127. INT iColorShift
  128. );
  129. INT
  130. PAL_FBPBlitToSurface(
  131. LPBYTE lpBitmapFBP,
  132. SDL_Surface *lpDstSurface
  133. );
  134. INT
  135. PAL_RLEGetWidth(
  136. LPCBITMAPRLE lpBitmapRLE
  137. );
  138. INT
  139. PAL_RLEGetHeight(
  140. LPCBITMAPRLE lpBitmapRLE
  141. );
  142. WORD
  143. PAL_SpriteGetNumFrames(
  144. LPCSPRITE lpSprite
  145. );
  146. LPCBITMAPRLE
  147. PAL_SpriteGetFrame(
  148. LPCSPRITE lpSprite,
  149. INT iFrameNum
  150. );
  151. INT
  152. PAL_MKFGetChunkCount(
  153. FILE *fp
  154. );
  155. INT
  156. PAL_MKFGetChunkSize(
  157. UINT uiChunkNum,
  158. FILE *fp
  159. );
  160. INT
  161. PAL_MKFReadChunk(
  162. LPBYTE lpBuffer,
  163. UINT uiBufferSize,
  164. UINT uiChunkNum,
  165. FILE *fp
  166. );
  167. INT
  168. PAL_MKFGetDecompressedSize(
  169. UINT uiChunkNum,
  170. FILE *fp
  171. );
  172. INT
  173. PAL_MKFDecompressChunk(
  174. LPBYTE lpBuffer,
  175. UINT uiBufferSize,
  176. UINT uiChunkNum,
  177. FILE *fp
  178. );
  179. // From yj1.c:
  180. extern INT
  181. (*Decompress)(
  182. LPCVOID Source,
  183. LPVOID Destination,
  184. INT DestSize
  185. );
  186. INT
  187. YJ1_Decompress(
  188. LPCVOID Source,
  189. LPVOID Destination,
  190. INT DestSize
  191. );
  192. INT
  193. YJ2_Decompress(
  194. LPCVOID Source,
  195. LPVOID Destination,
  196. INT DestSize
  197. );
  198. PAL_C_LINKAGE_END
  199. #define PAL_DelayUntil(t) \
  200. PAL_ProcessEvent(); \
  201. while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
  202. { \
  203. PAL_ProcessEvent(); \
  204. SDL_Delay(1); \
  205. }
  206. #endif // _PALUTILS_H