home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!wupost!cs.utexas.edu!hellgate.utah.edu!cc.usu.edu!sl1zm
- From: sl1zm@cc.usu.edu
- Newsgroups: comp.sys.amiga.programmer
- Subject: Color cycle example C source
- Message-ID: <1992Sep4.113242.58631@cc.usu.edu>
- Date: 4 Sep 92 17:32:42 GMT
- Article-I.D.: cc.1992Sep4.113242.58631
- Organization: Utah State University
- Lines: 90
-
- Since I have allready speant more time explaining how to do a color cycle from
- an interrupt and why to do it that way than it's worth....
- here is some source code.
- -------------------------------
- /* Cycle.c */
- /* Data shared with cycle Task/interrupt */
- #include <iff/ilbm.h>
- #include <iff/myreadpict.h>
-
-
- extern CrngChunk *cyCrngs; /* give these a value */
- extern struct ViewPort *cyVport;
- extern int cyRegs , cyCnt;
- extern USHORT cyMap[];
- extern LONG cyClocks[];
- extern LONG cyRates[];
- extern BOOL CycleOn;
- extern BOOL CycleTemp;
-
- /* Cycle Task/interrupt stuff */
- #define CYCLETIME 16384L
- #define REVERSE 0x02
-
- /****************************************************************/
- /* Cycle interrupt changes */
- /****************************************************************/
- __interrupt MyVBlank()
- {
- register int i,j,k,l;
- register UBYTE low, high;
- register USHORT cyTmp;
- extern BOOL CycleOn; /* Is this necessary?? */
- register BOOL Cycled;
-
- if (CycleOn)
- {
- Cycled = FALSE;
- k = cyCnt;
- while(k > -1)
- {
- cyClocks[k] += cyRates[k];
- if (cyClocks[k] >= CYCLETIME)
- {
- low = cyCrngs[k].low;
- high = cyCrngs[k].high;
- cyClocks[k] -= CYCLETIME;
- l = high - low;
- Cycled = TRUE;
- if (cyCrngs[k].active & REVERSE)
- {
- cyTmp = cyMap[low];
- i = low;
- j = i + 1;
-
- while(l--)
- {
- cyMap[i++] = cyMap[j++];
- }
- cyMap[high] = cyTmp;
- }
- else
- {
- cyTmp = cyMap[high];
- i = high;
- j = i - 1;
-
- while(l--)
- {
- cyMap[i--] = cyMap[j--];
- }
- cyMap[low] = cyTmp;
- }
- }
- k--;
- }
- if(Cycled) LoadRGB4(cyVport, cyMap, cyRegs);
- }
- return(0); /* interrupt routines have to do this */
- }
- --------------------
-
- This routine is a combination of the display and EA code examples...
- figuring out the rest is up to you... the old iff examples should have
- enough code to help you figure it out.
-
- Keep in mind that interrupts should be as fast as possible and I reccomend
- this be downcoded to assembly... yes it *can* be optimised a lot.
-
-
- James Diffendaffer
-