home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / comm / revrdist.sit / Local #includes / ShowInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-06  |  1.9 KB  |  92 lines  |  [TEXT/KAHL]

  1. /* -------------------  ShowInit.c   ----------------------------*/
  2. /*
  3.     Simple INIT notification routine in LightSpeedC 2.15
  4. */
  5.  
  6. #include <QuickDraw.h>
  7. #include <C_config.h>
  8.  
  9. #define CKSM(i)                \
  10.     asm {                    \
  11.         ROL #1,i            \
  12.         EOR #0x1021,i        \
  13.     }
  14.  
  15. typedef struct QuickDraw {        /* QuickDraw globals */
  16.     char private[76];
  17.     long randSeed;
  18.     BitMap screenBits;
  19.     Cursor arrow;
  20.     Pattern dkGray;
  21.     Pattern ltGray;
  22.     Pattern gray;
  23.     Pattern black;
  24.     Pattern white;
  25.     GrafPtr thePort;
  26. } QuickDraw;
  27.  
  28. extern short myH : 0x92C;        /* CurApName + 28 */
  29. extern short myCheck: 0x92E;    /* CurApName + 30 */
  30. extern long oldSig: 0xA78;        /* ApplScratch */
  31. extern short oldH: 0xA7E;        /* ApplScratch + 6 */
  32.  
  33. extern void ShowINIT (Integer);
  34.  
  35. void ShowINIT(iconID)
  36. register Integer iconID;        /* ICN# resource ID */
  37. {
  38.     register Handle h;
  39.     register short i;
  40.     Rect srcRect, destRect;
  41.     BitMap myBitMap;
  42.     GrafPort myPort;
  43.     QuickDraw qdGlobals;
  44.     Ptr localA5;
  45.  
  46.     asm {
  47.         MOVE.L A5,-(SP)
  48.         LEA.L localA5,A5
  49.     }
  50.     if (!(h = GetResource('ICN#', iconID)))
  51.         goto out;    /* Error */
  52.     InitGraf(&qdGlobals.thePort);
  53.     OpenPort(&myPort);
  54.  
  55.     i = myH;
  56.     CKSM(i);
  57.     if (i == myCheck)
  58.         i = myH;
  59.     else
  60.         if (oldSig == 'Paul')
  61.             i = oldH;
  62.         else
  63.             i = 8;
  64.     destRect.bottom = myPort.portRect.bottom - 8;
  65.     destRect.left = myPort.portRect.left + i;
  66.     destRect.top = destRect.bottom - 32;
  67.     destRect.right = destRect.left + 32;
  68.     i += 40;
  69.     myH = i;
  70.     CKSM(i);
  71.     myCheck = i;
  72.  
  73.     HLock(h);
  74.     srcRect.top = srcRect.left = 0;
  75.     srcRect.bottom = srcRect.right = 32;
  76.     myBitMap.rowBytes = 4;
  77.     myBitMap.bounds = srcRect;
  78.     myBitMap.baseAddr = *h + 128;    /* Skip to mask */
  79.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcBic, 0L);
  80.     myBitMap.baseAddr = *h;            /* Now draw icon */
  81.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcOr, 0L);
  82.     HUnlock(h);
  83.     ReleaseResource(h);
  84.  
  85.     ClosePort(&myPort);
  86. out:
  87.     asm {
  88.         MOVE.L (SP)+,A5
  89.     }
  90. }
  91. /*  end of ShowInit.c */
  92.