palcommon.h 3.2 KB

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