palcommon.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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_RLEBlitWithColorShift(
  54. LPCBITMAPRLE lpBitmapRLE,
  55. SDL_Surface *lpDstSurface,
  56. PAL_POS pos,
  57. INT iColorShift
  58. );
  59. INT
  60. PAL_RLEBlitMonoColor(
  61. LPCBITMAPRLE lpBitmapRLE,
  62. SDL_Surface *lpDstSurface,
  63. PAL_POS pos,
  64. BYTE bColor,
  65. INT iColorShift
  66. );
  67. INT
  68. PAL_FBPBlitToSurface(
  69. LPBYTE lpBitmapFBP,
  70. SDL_Surface *lpDstSurface
  71. );
  72. INT
  73. PAL_RLEGetWidth(
  74. LPCBITMAPRLE lpBitmapRLE
  75. );
  76. INT
  77. PAL_RLEGetHeight(
  78. LPCBITMAPRLE lpBitmapRLE
  79. );
  80. WORD
  81. PAL_SpriteGetNumFrames(
  82. LPCSPRITE lpSprite
  83. );
  84. LPCBITMAPRLE
  85. PAL_SpriteGetFrame(
  86. LPCSPRITE lpSprite,
  87. INT iFrameNum
  88. );
  89. INT
  90. PAL_MKFGetChunkCount(
  91. FILE *fp
  92. );
  93. INT
  94. PAL_MKFGetChunkSize(
  95. UINT uiChunkNum,
  96. FILE *fp
  97. );
  98. INT
  99. PAL_MKFReadChunk(
  100. LPBYTE lpBuffer,
  101. UINT uiBufferSize,
  102. UINT uiChunkNum,
  103. FILE *fp
  104. );
  105. INT
  106. PAL_MKFGetDecompressedSize(
  107. UINT uiChunkNum,
  108. FILE *fp
  109. );
  110. INT
  111. PAL_MKFDecompressChunk(
  112. LPBYTE lpBuffer,
  113. UINT uiBufferSize,
  114. UINT uiChunkNum,
  115. FILE *fp
  116. );
  117. // From yj1.c:
  118. extern INT
  119. (*Decompress)(
  120. LPCVOID Source,
  121. LPVOID Destination,
  122. INT DestSize
  123. );
  124. INT
  125. YJ1_Decompress(
  126. LPCVOID Source,
  127. LPVOID Destination,
  128. INT DestSize
  129. );
  130. INT
  131. YJ2_Decompress(
  132. LPCVOID Source,
  133. LPVOID Destination,
  134. INT DestSize
  135. );
  136. #define PAL_DelayUntil(t) \
  137. PAL_ProcessEvent(); \
  138. while (!SDL_TICKS_PASSED(SDL_GetTicks(), (t))) \
  139. { \
  140. PAL_ProcessEvent(); \
  141. SDL_Delay(1); \
  142. }
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif // _PALUTILS_H