palcommon.h 3.5 KB

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