palcommon.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. typedef LPBYTE LPSPRITE, LPBITMAPRLE;
  29. typedef LPCBYTE LPCSPRITE, LPCBITMAPRLE;
  30. #ifndef PAL_POS_DEFINED
  31. #define PAL_POS_DEFINED
  32. typedef DWORD PAL_POS;
  33. #endif
  34. #define PAL_XY(x, y) (PAL_POS)(((((WORD)(y)) << 16) & 0xFFFF0000) | (((WORD)(x)) & 0xFFFF))
  35. #define PAL_X(xy) (SHORT)((xy) & 0xFFFF)
  36. #define PAL_Y(xy) (SHORT)(((xy) >> 16) & 0xFFFF)
  37. #define PAL_XY_OFFSET(xy, x, y) (PAL_POS)(((((INT)(y) << 16) & 0xFFFF0000) + ((xy) & 0xFFFF0000)) | (((INT)(x) & 0xFFFF) + ((xy) & 0xFFFF)))
  38. typedef enum tagPALDIRECTION
  39. {
  40. kDirSouth = 0,
  41. kDirWest,
  42. kDirNorth,
  43. kDirEast,
  44. kDirUnknown
  45. } PALDIRECTION, *LPPALDIRECTION;
  46. INT
  47. PAL_RLEBlitToSurface(
  48. LPCBITMAPRLE lpBitmapRLE,
  49. SDL_Surface *lpDstSurface,
  50. PAL_POS pos
  51. );
  52. INT
  53. PAL_RLEBlitToSurfaceWithShadow(
  54. LPCBITMAPRLE lpBitmapRLE,
  55. SDL_Surface *lpDstSurface,
  56. PAL_POS pos,
  57. BOOL bShadow
  58. );
  59. INT
  60. PAL_RLEBlitWithColorShift(
  61. LPCBITMAPRLE lpBitmapRLE,
  62. SDL_Surface *lpDstSurface,
  63. PAL_POS pos,
  64. INT iColorShift
  65. );
  66. INT
  67. PAL_RLEBlitMonoColor(
  68. LPCBITMAPRLE lpBitmapRLE,
  69. SDL_Surface *lpDstSurface,
  70. PAL_POS pos,
  71. BYTE bColor,
  72. INT iColorShift
  73. );
  74. INT
  75. PAL_FBPBlitToSurface(
  76. LPBYTE lpBitmapFBP,
  77. SDL_Surface *lpDstSurface
  78. );
  79. INT
  80. PAL_RLEGetWidth(
  81. LPCBITMAPRLE lpBitmapRLE
  82. );
  83. INT
  84. PAL_RLEGetHeight(
  85. LPCBITMAPRLE lpBitmapRLE
  86. );
  87. WORD
  88. PAL_SpriteGetNumFrames(
  89. LPCSPRITE lpSprite
  90. );
  91. LPCBITMAPRLE
  92. PAL_SpriteGetFrame(
  93. LPCSPRITE lpSprite,
  94. INT iFrameNum
  95. );
  96. INT
  97. PAL_MKFGetChunkCount(
  98. FILE *fp
  99. );
  100. INT
  101. PAL_MKFGetChunkSize(
  102. UINT uiChunkNum,
  103. FILE *fp
  104. );
  105. INT
  106. PAL_MKFReadChunk(
  107. LPBYTE lpBuffer,
  108. UINT uiBufferSize,
  109. UINT uiChunkNum,
  110. FILE *fp
  111. );
  112. INT
  113. PAL_MKFGetDecompressedSize(
  114. UINT uiChunkNum,
  115. FILE *fp
  116. );
  117. INT
  118. PAL_MKFDecompressChunk(
  119. LPBYTE lpBuffer,
  120. UINT uiBufferSize,
  121. UINT uiChunkNum,
  122. FILE *fp
  123. );
  124. // From yj1.c:
  125. extern INT
  126. (*Decompress)(
  127. LPCVOID Source,
  128. LPVOID Destination,
  129. INT DestSize
  130. );
  131. INT
  132. YJ1_Decompress(
  133. LPCVOID Source,
  134. LPVOID Destination,
  135. INT DestSize
  136. );
  137. INT
  138. YJ2_Decompress(
  139. LPCVOID Source,
  140. LPVOID Destination,
  141. INT DestSize
  142. );
  143. #define PAL_DelayUntil(t) \
  144. PAL_ProcessEvent(); \
  145. while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
  146. { \
  147. PAL_ProcessEvent(); \
  148. SDL_Delay(1); \
  149. }
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif // _PALUTILS_H