home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / SpriteWorld 2.2 / SpriteWorld files / Headers / SWCommonHeaders.h < prev    next >
Encoding:
Text File  |  1999-01-06  |  3.8 KB  |  139 lines  |  [TEXT/CWIE]

  1. ///--------------------------------------------------------------------------------------
  2. //    SWCommonHeaders.h
  3. //
  4. //    Portions are copyright: c 1991-94 Tony Myles, All rights reserved worldwide.
  5. //
  6. //    Description:    common macros, constants, and stuff, used throughout SpriteWorld
  7. ///--------------------------------------------------------------------------------------
  8.  
  9. #ifndef __RETRACE__
  10. #include <Retrace.h>
  11. #endif
  12.  
  13. #ifndef __SWCOMMON__
  14. #define __SWCOMMON__
  15.              
  16. ///--------------------------------------------------------------------------------------
  17. //    VBL-related stuff
  18. ///--------------------------------------------------------------------------------------
  19.  
  20. typedef struct VBLTaskRec VBLTaskRec;
  21. typedef VBLTaskRec *VBLTaskRecPtr, **VBLTaskRecHdl;
  22.  
  23. struct VBLTaskRec
  24. {
  25.     VBLTask    myVBLTask;
  26.     volatile Boolean hasVBLFired;
  27. };
  28.  
  29.  
  30. ///--------------------------------------------------------------------------------------
  31. //    sprite world definitions
  32. ///--------------------------------------------------------------------------------------
  33.  
  34. typedef struct SpriteWorldRec SpriteWorldRec;
  35. typedef SpriteWorldRec *SpriteWorldPtr, **SpriteWorldHdl;
  36.  
  37.  
  38. ///--------------------------------------------------------------------------------------
  39. //    SW_ASSERT
  40. ///--------------------------------------------------------------------------------------
  41.  
  42. #define SW_ASSERT_ON    1    // Change this to 0 to turn assertions off. use 1/0, not true/false.
  43.  
  44. #define kAssertAlertID    128        // The resource ID of the Alert dialog box used for assertions.
  45.  
  46. #if (SW_ASSERT_ON == 1)
  47. #define SW_ASSERT( condition )    \
  48.     if ( !(condition) )            \
  49.         SWAssertFail( __FILE__, __LINE__ );        // Defined in SpriteWorldUtils.c
  50. #else
  51. #define SW_ASSERT(f)    NULL
  52. #endif
  53.  
  54.  
  55. ///--------------------------------------------------------------------------------------
  56. //    sprite world macros
  57. ///--------------------------------------------------------------------------------------
  58.  
  59. #if defined(powerc) || defined(__powerc)
  60. #define SW_PPC 1
  61. #else 
  62. #define SW_PPC 0
  63. #endif
  64.  
  65. #define SW_MIN(a, b) ((a) < (b) ? (a) : (b))
  66. #define SW_MAX(a, b) ((a) > (b) ? (a) : (b))
  67.  
  68. #define SW_RECT_WIDTH(theRect)        (theRect.right - theRect.left)
  69. #define SW_RECT_HEIGHT(theRect)        (theRect.bottom - theRect.top)
  70.  
  71. #define SW_SET_RECT(theRect, myleft, mytop, myright, mybottom) \
  72.     theRect.left = myleft; \
  73.     theRect.top = mytop; \
  74.     theRect.right = myright; \
  75.     theRect.bottom = mybottom;
  76.  
  77. #define SW_RECT_IS_IN_RECT(rectA, rectB) \
  78.     ( (rectA.top < rectB.bottom) &&    \
  79.       (rectA.bottom > rectB.top) &&    \
  80.       (rectA.left < rectB.right) &&    \
  81.       (rectA.right > rectB.left) )
  82.  
  83.     // Clips rectA with rectB
  84. #define SW_CLIP_RECT(rectA, rectB) \
  85.     if (rectA.top < rectB.top)  \
  86.         rectA.top = rectB.top;    \
  87.     if (rectA.bottom > rectB.bottom) \
  88.         rectA.bottom = rectB.bottom; \
  89.     if (rectA.left < rectB.left) \
  90.         rectA.left = rectB.left; \
  91.     if (rectA.right > rectB.right) \
  92.         rectA.right = rectB.right;
  93.  
  94.  
  95.     // Generally MacHeaders provides these macros. If you're not using MacHeaders
  96.     // for some strange reason, uncomment these lines:
  97. /*
  98. #define topLeft(theRect)     (*(Point*)&theRect.top)
  99. #define botRight(theRect)     (*(Point*)&theRect.bottom)
  100. */
  101.  
  102.     // set to 'pascal' so the library will be callable from pascal
  103. #define SW_FUNC pascal
  104.  
  105. #define kBitsPerByte 8
  106.  
  107. #if __MWERKS__
  108.  
  109. #define SW_ASM_FUNC asm
  110. #define SW_ASM_BEGIN machine 68020
  111. #define SW_ASM_END rts
  112.  
  113. #elif THINK_C
  114.  
  115. #define SW_ASM_FUNC
  116. #define SW_ASM_BEGIN asm 68020{
  117. #define SW_ASM_END }
  118.  
  119. #endif
  120.  
  121.  
  122. ///--------------------------------------------------------------------------------------
  123. //    compiled sprite definitions
  124. ///--------------------------------------------------------------------------------------
  125.  
  126. typedef short PixelCode, *PixelCodePtr, **PixelCodeHdl;
  127.  
  128. typedef void (*BlitFuncPtr)(
  129.     long srcStride,
  130.     long destStride,
  131.     Ptr srcBaseAddr,
  132.     Ptr destBaseAddr);
  133.  
  134. #endif /*__SWCOMMON__*/
  135.  
  136.  
  137.  
  138.  
  139.