palcommon.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  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 _PALUTILS_H
  22. #define _PALUTILS_H
  23. #include "common.h"
  24. typedef LPBYTE LPSPRITE, LPBITMAPRLE;
  25. typedef LPCBYTE LPCSPRITE, LPCBITMAPRLE;
  26. #ifndef PAL_POS_DEFINED
  27. #define PAL_POS_DEFINED
  28. typedef DWORD PAL_POS;
  29. #endif
  30. #define PAL_XY(x, y) (PAL_POS)(((((WORD)(y)) << 16) & 0xFFFF0000) | (((WORD)(x)) & 0xFFFF))
  31. #define PAL_X(xy) (SHORT)((xy) & 0xFFFF)
  32. #define PAL_Y(xy) (SHORT)(((xy) >> 16) & 0xFFFF)
  33. #define PAL_XY_OFFSET(xy, x, y) (PAL_POS)(((((INT)(y) << 16) & 0xFFFF0000) + ((xy) & 0xFFFF0000)) | (((INT)(x) & 0xFFFF) + ((xy) & 0xFFFF)))
  34. // maximum number of players in party
  35. #define MAX_PLAYERS_IN_PARTY 3
  36. // total number of possible player roles
  37. #define MAX_PLAYER_ROLES 6
  38. // totally number of playable player roles
  39. #define MAX_PLAYABLE_PLAYER_ROLES 5
  40. // maximum entries of inventory
  41. #define MAX_INVENTORY 256
  42. // maximum items in a store
  43. #define MAX_STORE_ITEM 9
  44. // total number of magic attributes
  45. #define NUM_MAGIC_ELEMENTAL 5
  46. // maximum number of enemies in a team
  47. #define MAX_ENEMIES_IN_TEAM 5
  48. // maximum number of equipments for a player
  49. #define MAX_PLAYER_EQUIPMENTS 6
  50. // maximum number of magics for a player
  51. #define MAX_PLAYER_MAGICS 32
  52. // maximum number of scenes
  53. #define MAX_SCENES 300
  54. // maximum number of objects
  55. #define MAX_OBJECTS 600
  56. // maximum number of event objects (should be somewhat more than the original,
  57. // as there are some modified versions which has more)
  58. #define MAX_EVENT_OBJECTS 5500
  59. // maximum number of effective poisons to players
  60. #define MAX_POISONS 16
  61. // maximum number of level
  62. #define MAX_LEVELS 99
  63. #define OBJECT_ITEM_START 0x3D
  64. #define OBJECT_ITEM_END 0x126
  65. #define OBJECT_MAGIC_START 0x127
  66. #define OBJECT_MAGIC_END 0x18D
  67. #define MINIMAL_WORD_COUNT (MAX_OBJECTS + 13)
  68. typedef enum tagPALDIRECTION
  69. {
  70. kDirSouth = 0,
  71. kDirWest,
  72. kDirNorth,
  73. kDirEast,
  74. kDirUnknown
  75. } PALDIRECTION, *LPPALDIRECTION;
  76. typedef enum tagMUSICTYPE
  77. {
  78. MUSIC_MIDI,
  79. MUSIC_RIX,
  80. MUSIC_MP3,
  81. MUSIC_OGG,
  82. MUSIC_SDLCD
  83. } MUSICTYPE, *LPMUSICTYPE;
  84. typedef enum tagOPLTYPE
  85. {
  86. OPL_DOSBOX,
  87. OPL_MAME,
  88. OPL_DOSBOX_NEW,
  89. } OPLTYPE, *LPOPLTYPE;
  90. typedef enum tagCODEPAGE {
  91. CP_MIN = 0,
  92. CP_BIG5 = 0,
  93. CP_GBK = 1,
  94. CP_SHIFTJIS = 2,
  95. CP_JISX0208 = 3,
  96. CP_MAX = CP_GBK + 1,
  97. CP_UTF_8 = CP_MAX + 1
  98. } CODEPAGE;
  99. PAL_C_LINKAGE_BEGIN
  100. INT
  101. PAL_RLEBlitToSurface(
  102. LPCBITMAPRLE lpBitmapRLE,
  103. SDL_Surface *lpDstSurface,
  104. PAL_POS pos
  105. );
  106. INT
  107. PAL_RLEBlitToSurfaceWithShadow(
  108. LPCBITMAPRLE lpBitmapRLE,
  109. SDL_Surface *lpDstSurface,
  110. PAL_POS pos,
  111. BOOL bShadow
  112. );
  113. INT
  114. PAL_RLEBlitWithColorShift(
  115. LPCBITMAPRLE lpBitmapRLE,
  116. SDL_Surface *lpDstSurface,
  117. PAL_POS pos,
  118. INT iColorShift
  119. );
  120. INT
  121. PAL_RLEBlitMonoColor(
  122. LPCBITMAPRLE lpBitmapRLE,
  123. SDL_Surface *lpDstSurface,
  124. PAL_POS pos,
  125. BYTE bColor,
  126. INT iColorShift
  127. );
  128. INT
  129. PAL_FBPBlitToSurface(
  130. LPBYTE lpBitmapFBP,
  131. SDL_Surface *lpDstSurface
  132. );
  133. INT
  134. PAL_RLEGetWidth(
  135. LPCBITMAPRLE lpBitmapRLE
  136. );
  137. INT
  138. PAL_RLEGetHeight(
  139. LPCBITMAPRLE lpBitmapRLE
  140. );
  141. WORD
  142. PAL_SpriteGetNumFrames(
  143. LPCSPRITE lpSprite
  144. );
  145. LPCBITMAPRLE
  146. PAL_SpriteGetFrame(
  147. LPCSPRITE lpSprite,
  148. INT iFrameNum
  149. );
  150. INT
  151. PAL_MKFGetChunkCount(
  152. FILE *fp
  153. );
  154. INT
  155. PAL_MKFGetChunkSize(
  156. UINT uiChunkNum,
  157. FILE *fp
  158. );
  159. INT
  160. PAL_MKFReadChunk(
  161. LPBYTE lpBuffer,
  162. UINT uiBufferSize,
  163. UINT uiChunkNum,
  164. FILE *fp
  165. );
  166. INT
  167. PAL_MKFGetDecompressedSize(
  168. UINT uiChunkNum,
  169. FILE *fp
  170. );
  171. INT
  172. PAL_MKFDecompressChunk(
  173. LPBYTE lpBuffer,
  174. UINT uiBufferSize,
  175. UINT uiChunkNum,
  176. FILE *fp
  177. );
  178. // From yj1.c:
  179. extern INT
  180. (*Decompress)(
  181. LPCVOID Source,
  182. LPVOID Destination,
  183. INT DestSize
  184. );
  185. INT
  186. YJ1_Decompress(
  187. LPCVOID Source,
  188. LPVOID Destination,
  189. INT DestSize
  190. );
  191. INT
  192. YJ2_Decompress(
  193. LPCVOID Source,
  194. LPVOID Destination,
  195. INT DestSize
  196. );
  197. PAL_C_LINKAGE_END
  198. #define PAL_DelayUntil(t) \
  199. PAL_ProcessEvent(); \
  200. while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
  201. { \
  202. PAL_ProcessEvent(); \
  203. SDL_Delay(1); \
  204. }
  205. #endif // _PALUTILS_H