home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / amiga / programm / 13088 < prev    next >
Encoding:
Text File  |  1992-09-04  |  2.4 KB  |  101 lines

  1. Path: sparky!uunet!ogicse!uwm.edu!wupost!cs.utexas.edu!hellgate.utah.edu!cc.usu.edu!sl1zm
  2. From: sl1zm@cc.usu.edu
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Color cycle example  C source
  5. Message-ID: <1992Sep4.113242.58631@cc.usu.edu>
  6. Date: 4 Sep 92 17:32:42 GMT
  7. Article-I.D.: cc.1992Sep4.113242.58631
  8. Organization: Utah State University
  9. Lines: 90
  10.  
  11. Since I have allready speant more time explaining how to do a color cycle  from
  12. an interrupt and why to do it that way than it's worth.... 
  13. here is some source code.
  14. -------------------------------
  15. /*            Cycle.c            */
  16. /* Data shared with cycle Task/interrupt */
  17. #include <iff/ilbm.h>
  18. #include <iff/myreadpict.h>
  19.  
  20.  
  21. extern CrngChunk         *cyCrngs;        /* give these a value */
  22. extern struct    ViewPort   *cyVport;
  23. extern int        cyRegs   , cyCnt;
  24. extern USHORT    cyMap[];
  25. extern LONG    cyClocks[];
  26. extern LONG    cyRates[];
  27. extern BOOL    CycleOn;
  28. extern BOOL    CycleTemp;
  29.  
  30. /* Cycle Task/interrupt stuff */
  31. #define CYCLETIME  16384L
  32. #define REVERSE    0x02
  33.  
  34. /****************************************************************/
  35. /*  Cycle interrupt changes                                     */
  36. /****************************************************************/
  37. __interrupt MyVBlank()
  38. {
  39.     register int    i,j,k,l;
  40.     register UBYTE    low, high;
  41.     register USHORT    cyTmp;
  42.     extern BOOL    CycleOn; /* Is this necessary?? */
  43.     register BOOL    Cycled;
  44.  
  45.     if (CycleOn)
  46.     {
  47.         Cycled = FALSE;
  48.         k = cyCnt;
  49.         while(k > -1)
  50.         {
  51.             cyClocks[k] += cyRates[k];
  52.             if (cyClocks[k] >= CYCLETIME)
  53.             {
  54.                 low  = cyCrngs[k].low;
  55.                 high = cyCrngs[k].high;
  56.                 cyClocks[k] -= CYCLETIME;
  57.                 l = high - low;
  58.                 Cycled = TRUE;
  59.                 if (cyCrngs[k].active & REVERSE)
  60.                 {
  61.                     cyTmp = cyMap[low];
  62.                     i = low;
  63.                     j = i + 1;
  64.  
  65.                     while(l--)
  66.                     {
  67.                         cyMap[i++] = cyMap[j++];
  68.                     }
  69.                     cyMap[high] = cyTmp;
  70.                 }
  71.                 else
  72.                 {
  73.                     cyTmp = cyMap[high];
  74.                     i = high;
  75.                     j = i - 1;
  76.  
  77.                     while(l--)
  78.                     {
  79.                         cyMap[i--] = cyMap[j--];
  80.                     }
  81.                     cyMap[low] = cyTmp;
  82.                 }
  83.             }
  84.             k--;
  85.         }
  86.         if(Cycled) LoadRGB4(cyVport, cyMap, cyRegs);
  87.     }
  88.     return(0);  /* interrupt routines have to do this */
  89. }
  90. --------------------
  91.  
  92. This routine is a combination of the display and EA code examples...
  93. figuring out the rest is up to you... the old iff examples should have 
  94. enough code to help you figure it out.
  95.  
  96. Keep in mind that interrupts should be as fast as possible and I reccomend
  97. this be downcoded to assembly... yes it *can* be optimised a lot.
  98.  
  99.  
  100. James Diffendaffer
  101.