home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / SpriteWorld 2.2 / SpriteWorld files / Headers / BlitPixie.h next >
Encoding:
Text File  |  1999-01-14  |  9.0 KB  |  362 lines  |  [TEXT/CWIE]

  1. ///--------------------------------------------------------------------------------------
  2. //    BlitPixie.h
  3. //
  4. //    Description: This is the include file for all the BlitPixie source files.
  5. ///--------------------------------------------------------------------------------------
  6.  
  7.  
  8. #ifndef __BLITPIXIE__
  9. #define __BLITPIXIE__
  10.  
  11. #ifndef __SWCOMMON__
  12. #include "SWCommonHeaders.h"
  13. #endif
  14.  
  15. #ifndef __QUICKDRAW__
  16. #include <QuickDraw.h>
  17. #endif
  18.  
  19. #ifndef __SPRITEFRAME__
  20. #include "SpriteFrame.h"
  21. #endif
  22.  
  23. #ifndef __SPRITE__
  24. #include "Sprite.h"
  25. #endif
  26.  
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. #if PRAGMA_ALIGN_SUPPORTED
  33. #pragma options align=mac68k
  34. #endif
  35.  
  36.  
  37. ///--------------------------------------------------------------------------------------
  38. //        type definitions & conditional macros
  39. ///--------------------------------------------------------------------------------------
  40.  
  41.  
  42. #if !SW_PPC
  43. #define START_32_BIT_MODE    \
  44.     {    \
  45.         SInt8 mmuMode;    \
  46.         if (gSWmmuMode != true32b) \
  47.         {    \
  48.             mmuMode = true32b;    \
  49.             SwapMMUMode(&mmuMode);    \
  50.         }    
  51. #define END_32_BIT_MODE    \
  52.         if (gSWmmuMode != true32b)     \
  53.         {    \
  54.             SwapMMUMode(&mmuMode);    \
  55.         }    \
  56.     }
  57. #else
  58. #define START_32_BIT_MODE    // always 32-bit mode on PPC
  59. #define END_32_BIT_MODE
  60. #endif
  61.  
  62.  
  63. #define BP_CLIP_RECT(frameRect, srcRect, dstRect) \
  64.     /* clip off the top so we don't write into random memory */ \
  65.     if (dstRect.top < frameRect.top) { \
  66.         srcRect.top += frameRect.top - dstRect.top; \
  67.         dstRect.top =  frameRect.top; \
  68.     } \
  69.     /* clip off the bottom */ \
  70.     if (dstRect.bottom > frameRect.bottom) {     \
  71.         srcRect.bottom -= dstRect.bottom - frameRect.bottom; \
  72.         dstRect.bottom = frameRect.bottom;     \
  73.     }                             \
  74.     /* clip off the left */ \
  75.     if (dstRect.left < frameRect.left) { \
  76.         srcRect.left += frameRect.left - dstRect.left; \
  77.         dstRect.left = frameRect.left; \
  78.     } \
  79.     /* clip off the right */ \
  80.     if (dstRect.right > frameRect.right) { \
  81.         srcRect.right -= dstRect.right - frameRect.right; \
  82.         dstRect.right = frameRect.right; \
  83.     } \
  84.     /* Make sure height is valid */ \
  85.     if (dstRect.bottom <= dstRect.top) \
  86.         return; \
  87.     /* Make sure width is valid */ \
  88.     if (dstRect.right <= dstRect.left) \
  89.         return;
  90.  
  91.  
  92. #define BP_CLIP_RECT_INTERLACED(frameRect, srcRect, dstRect) \
  93.     /* clip off the top so we don't write into random memory */ \
  94.     if (dstRect.top < frameRect.top) { \
  95.         srcRect.top += frameRect.top - dstRect.top; \
  96.         dstRect.top =  frameRect.top; \
  97.     } \
  98.     /* clip off the bottom */ \
  99.     if (dstRect.bottom > frameRect.bottom) {     \
  100.         srcRect.bottom -= dstRect.bottom - frameRect.bottom; \
  101.         dstRect.bottom = frameRect.bottom;     \
  102.     }                             \
  103.     /* clip off the left */ \
  104.     if (dstRect.left < frameRect.left) { \
  105.         srcRect.left += frameRect.left - dstRect.left; \
  106.         dstRect.left = frameRect.left; \
  107.     } \
  108.     /* clip off the right */ \
  109.     if (dstRect.right > frameRect.right) { \
  110.         srcRect.right -= dstRect.right - frameRect.right; \
  111.         dstRect.right = frameRect.right; \
  112.     } \
  113.     /* If first line is not on an even number, skip it. */ \
  114.     if ((dstRect.top - frameRect.top) & 1) { \
  115.         srcRect.top++; \
  116.         dstRect.top++; \
  117.     } \
  118.     /* Make sure height is valid */ \
  119.     if (dstRect.bottom <= dstRect.top) \
  120.         return; \
  121.     /* Make sure width is valid */ \
  122.     if (dstRect.right <= dstRect.left) \
  123.         return;
  124.  
  125. typedef unsigned long PixelChunk, *PixelChunkPtr, **PixelChunkHdl;
  126.  
  127. #define BytesToChunks(b) ((b) >> 2)
  128. #define ChunksToBytes(b) ((b) << 2)
  129.  
  130.  
  131. typedef unsigned long* PixelPtr;
  132.  
  133. typedef struct StarArray
  134. {
  135.     short    horizLoc;            // Current horizontal position of the star
  136.     short    vertLoc;            // Current vertical position of the star
  137.     short    oldHorizLoc;        // Horizontal position of star the previous frame
  138.     short    oldVertLoc;            // Vertical position of star the previous frame
  139.     short    horizSpeed;            // To be used by the user to move the star
  140.     short    vertSpeed;            // To be used by the user to move the star
  141.     unsigned short    color;        // Current color of the star
  142.     Boolean    needsToBeErased;    // If drawn last frame, then it needs to be erased.
  143.     short    userData;            // Reserved for user 
  144. } StarArray;
  145.  
  146.  
  147. ///--------------------------------------------------------------------------------------
  148. //    Function prototypes for DoubleRect blitters
  149. ///--------------------------------------------------------------------------------------
  150.  
  151. SW_FUNC void BlitPixie8BitDoubleRectDrawProc(
  152.     FramePtr srcFrameP,
  153.     FramePtr dstFrameP,
  154.     Rect* srcRectA,
  155.     Rect* dstRectA,
  156.     Rect* srcRectB,
  157.     Rect* dstRectB);
  158.  
  159. SW_FUNC void BP8BitInterlacedDoubleRectDrawProc(
  160.     FramePtr srcFrameP,
  161.     FramePtr dstFrameP,
  162.     Rect* srcRectA,
  163.     Rect* dstRectA,
  164.     Rect* srcRectB,
  165.     Rect* dstRectB);
  166.  
  167. SW_FUNC void BlitPixie16BitDoubleRectDrawProc(
  168.     FramePtr srcFrameP,
  169.     FramePtr dstFrameP,
  170.     Rect* srcRectA,
  171.     Rect* dstRectA,
  172.     Rect* srcRectB,
  173.     Rect* dstRectB);
  174.  
  175. SW_FUNC void BP16BitInterlacedDoubleRectDrawProc(
  176.     FramePtr srcFrameP,
  177.     FramePtr dstFrameP,
  178.     Rect* srcRectA,
  179.     Rect* dstRectA,
  180.     Rect* srcRectB,
  181.     Rect* dstRectB);
  182.     
  183.  
  184. ///--------------------------------------------------------------------------------------
  185. //    Function prototypes for all-bit blitters
  186. ///--------------------------------------------------------------------------------------
  187.  
  188. SW_FUNC void BlitPixieAllBitRectDrawProc(
  189.     FramePtr srcFrameP,
  190.     FramePtr dstFrameP,
  191.     Rect *srcRect,
  192.     Rect *dstRect);
  193.  
  194. SW_FUNC void BPAllBitInterlacedRectDrawProc(
  195.     FramePtr srcFrameP,
  196.     FramePtr dstFrameP,
  197.     Rect* srcRect,
  198.     Rect* dstRect);
  199.  
  200. SW_FUNC void BlitPixieAllBitMaskDrawProc(
  201.     FramePtr srcFrameP,
  202.     FramePtr dstFrameP,
  203.     Rect *srcRect,
  204.     Rect *dstRect);
  205.  
  206. SW_FUNC void BlitPixieAllBitPartialMaskDrawProc(
  207.     FramePtr srcFrameP,
  208.     FramePtr dstFrameP,
  209.     Rect *srcRect,
  210.     Rect *dstRect);
  211.  
  212. SW_FUNC void BPAllBitInterlacedMaskDrawProc(
  213.     FramePtr srcFrameP,
  214.     FramePtr dstFrameP,
  215.     Rect* srcRect,
  216.     Rect* dstRect);
  217.  
  218. SW_FUNC void BPAllBitInterlacedPartialMaskDrawProc(
  219.     FramePtr srcFrameP,
  220.     FramePtr dstFrameP,
  221.     Rect* srcRect,
  222.     Rect* dstRect);
  223.  
  224. void BlitPixieAllBit(
  225.     register PixelPtr srcPixelP,
  226.     register PixelPtr dstPixelP,
  227.     unsigned long rowsToCopy,
  228.     unsigned long numBytesPerRow,
  229.     register unsigned long srcRowStride,
  230.     register unsigned long dstRowStride,
  231.     register unsigned long srcExtraStart,
  232.     register unsigned long dstExtraStart,
  233.     register unsigned long dstExtraEnd);
  234.     
  235. void BlitPixieAllBitMask(
  236.     register PixelPtr srcPixelP,
  237.     register PixelPtr dstPixelP,
  238.     register PixelPtr maskPixelP,
  239.     unsigned long rowsToCopy,
  240.     unsigned long numBytesPerRow,
  241.     register unsigned long srcRowStride,
  242.     register unsigned long dstRowStride,
  243.     register unsigned long srcExtraStart,
  244.     register unsigned long dstExtraStart,
  245.     register unsigned long dstExtraEnd);
  246.     
  247. void BlitPixieAllBitPartialMask(
  248.     register PixelPtr srcPixelP,
  249.     register PixelPtr dstPixelP,
  250.     register PixelPtr maskPixelP,
  251.     unsigned long rowsToCopy,
  252.     unsigned long numBytesPerRow,
  253.     register unsigned long srcRowStride,
  254.     register unsigned long dstRowStride,
  255.     register unsigned long srcExtraStart,
  256.     register unsigned long dstExtraStart,
  257.     register unsigned long dstExtraEnd);
  258.  
  259.     
  260.  
  261. ///--------------------------------------------------------------------------------------
  262. //    Function prototypes for 8-bit blitters
  263. ///--------------------------------------------------------------------------------------
  264.  
  265. SW_FUNC void BlitPixie8BitRectDrawProc(
  266.     FramePtr srcFrameP,
  267.     FramePtr dstFrameP,
  268.     Rect *srcRect,
  269.     Rect *dstRect);
  270.  
  271. SW_FUNC void BP8BitInterlacedRectDrawProc(
  272.     FramePtr srcFrameP,
  273.     FramePtr dstFrameP,
  274.     Rect* srcRect,
  275.     Rect* dstRect);
  276.  
  277. SW_FUNC void BlitPixie8BitMaskDrawProc(
  278.     FramePtr srcFrameP,
  279.     FramePtr dstFrameP,
  280.     Rect *srcRect,
  281.     Rect *dstRect);
  282.  
  283. SW_FUNC void BlitPixie8BitPartialMaskDrawProc(
  284.     FramePtr srcFrameP,
  285.     FramePtr dstFrameP,
  286.     Rect *srcRect,
  287.     Rect *dstRect);
  288.  
  289. SW_FUNC void BP8BitInterlacedMaskDrawProc(
  290.     FramePtr srcFrameP,
  291.     FramePtr dstFrameP,
  292.     Rect* srcRect,
  293.     Rect* dstRect);
  294.  
  295. SW_FUNC void BP8BitInterlacedPartialMaskDrawProc(
  296.     FramePtr srcFrameP,
  297.     FramePtr dstFrameP,
  298.     Rect* srcRect,
  299.     Rect* dstRect);
  300.  
  301. SW_FUNC void CompiledSprite8BitDrawProc(
  302.     FramePtr srcFrameP,
  303.     FramePtr dstFrameP,
  304.     Rect *srcRect,
  305.     Rect *dstRect);
  306.  
  307. SW_FUNC unsigned char BlitPixie8BitGetPixel(
  308.     FramePtr srcFrameP,
  309.     Point thePoint );
  310.  
  311. SW_FUNC void BlitPixie8BitSetPixel(
  312.     FramePtr srcFrameP,
  313.     Point thePoint,
  314.     unsigned char theColor);
  315.  
  316. SW_FUNC void SWAnimate8BitStarField(
  317.     SpriteWorldPtr    spriteWorldP,
  318.     StarArray        *starArray,
  319.     short            numStars,
  320.     unsigned short    backColor);
  321.  
  322. SW_FUNC void BlitPixie8BitFlipSprite(
  323.     SpritePtr srcSpriteP );
  324.  
  325. void BlitPixie8Bit(
  326.     register PixelChunkPtr srcPixelP,
  327.     register PixelChunkPtr dstPixelP,
  328.     register unsigned long rowsToCopy,
  329.     register unsigned long numBytesPerRow,
  330.     register unsigned long srcRowStride,
  331.     register unsigned long dstRowStride);
  332.  
  333. void BlitPixieMask8Bit(
  334.     register PixelPtr srcPixelP,
  335.     register PixelPtr dstPixelP,
  336.     register PixelPtr maskPixelP,
  337.     register unsigned long rowsToCopy,
  338.     register unsigned long numBytesPerRow,
  339.     register unsigned long srcRowStride,
  340.     register unsigned long dstRowStride);
  341.  
  342. void BlitPixiePartialMask8Bit(
  343.     register PixelPtr srcPixelP,
  344.     register PixelPtr dstPixelP,
  345.     register PixelPtr maskPixelP,
  346.     register unsigned long rowsToCopy,
  347.     register unsigned long numBytesPerRow,
  348.     register unsigned long srcRowStride,
  349.     register unsigned long dstRowStride);
  350.  
  351.  
  352. #if PRAGMA_ALIGN_SUPPORTED
  353. #pragma options align=reset
  354. #endif
  355.  
  356.  
  357. #ifdef __cplusplus
  358. }
  359. #endif
  360.  
  361. #endif /* __BLITPIXIE__ */
  362.