Missing dependencies added.
[AROS-Contrib.git] / dopus / Program / cycling.c
blob84ced04fd33492b72620e03077a1a7c3a95bdad5
1 /*
3 Directory Opus 4
4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #include "dopus.h"
33 static struct ViewPort *cy_VPort;
34 static struct Interrupt cy_VBlank;
35 static CRange *cy_Range;
36 static LONG cy_RangeNum,cy_ColNum;
37 static UWORD cy_ColMap[64],cy_TempCol,cy_UndoBuffer[64];
38 static short cy_TicksPassed[16],cy_WeAreWaiting,cy_Command;
39 static BOOL cy_CodeRun=FALSE;
41 void __saveds colourcycle()
43 short i,j;
45 if (cy_Command==CY_WAIT) {
46 if (!cy_WeAreWaiting) LoadRGB4(cy_VPort,cy_UndoBuffer,cy_ColNum);
47 cy_WeAreWaiting=TRUE;
48 return;
50 if (cy_WeAreWaiting) {
51 for (i=0;i<cy_ColNum;i++) cy_ColMap[i]=cy_UndoBuffer[i];
52 for (i=0;i<cy_RangeNum;i++) cy_TicksPassed[i]=0;
53 cy_WeAreWaiting=FALSE;
56 for (i=0;i<cy_RangeNum;i++) {
57 cy_TicksPassed[i]++;
58 if (cy_TicksPassed[i]==cy_Range[i].rate) {
59 cy_TicksPassed[i]=0;
60 if (!(cy_Range[i].active&CRNG_ACTIVE)) continue;
61 if (cy_Range[i].active&CRNG_REVERSE) {
62 cy_TempCol=cy_ColMap[cy_Range[i].low];
63 for (j=cy_Range[i].low;j<cy_Range[i].high;j++)
64 cy_ColMap[j]=cy_ColMap[j+1];
65 cy_ColMap[cy_Range[i].high]=cy_TempCol;
67 else {
68 cy_TempCol=cy_ColMap[cy_Range[i].high];
69 for (j=cy_Range[i].high;j>cy_Range[i].low;j--)
70 cy_ColMap[j]=cy_ColMap[j-1];
71 cy_ColMap[cy_Range[i].low]=cy_TempCol;
73 LoadRGB4(cy_VPort,cy_ColMap,cy_ColNum);
78 int initcycle(ViewPort,ColMap,ColNum,Range,RangeNum)
79 struct ViewPort *ViewPort;
80 UWORD *ColMap;
81 int ColNum;
82 CRange *Range;
83 int RangeNum;
85 register short i;
87 if (!ViewPort || !ColMap || !ColNum || ColNum>64 || !Range || !RangeNum) return(FALSE);
89 cy_VPort=ViewPort;
90 cy_ColNum=ColNum;
91 cy_Range=Range;
92 cy_RangeNum=RangeNum;
94 for (i=0;i<ColNum;i++) cy_ColMap[i]=ColMap[i];
95 for (i=0;i<cy_RangeNum;i++) cy_TicksPassed[i]=0;
96 for (i=0;i<cy_ColNum;i++) cy_UndoBuffer[i]=cy_ColMap[i];
98 cy_Command=CY_WAIT;
99 cy_WeAreWaiting=TRUE;
100 cy_VBlank.is_Data=(APTR)NULL;
101 cy_VBlank.is_Code=colourcycle;
102 cy_VBlank.is_Node.ln_Succ=NULL;
103 cy_VBlank.is_Node.ln_Pred=NULL;
104 cy_VBlank.is_Node.ln_Type=NT_INTERRUPT;
105 cy_VBlank.is_Node.ln_Pri=0;
106 cy_VBlank.is_Node.ln_Name="dopus_cycle";
107 AddIntServer(INTB_VERTB,&cy_VBlank);
108 cy_CodeRun=TRUE;
109 return(TRUE);
112 void stopcycle()
114 register short i;
116 if (!cy_CodeRun) return;
117 cy_WeAreWaiting=TRUE;
118 cy_Command=CY_WAIT;
119 RemIntServer(INTB_VERTB,&cy_VBlank);
120 for (i=0;i<cy_ColNum;i++) cy_ColMap[i]=cy_UndoBuffer[i];
121 WaitTOF();
122 WaitTOF();
123 WaitTOF();
124 cy_CodeRun=FALSE;
127 void togglecycle()
129 static short Mode=FALSE;
131 Mode^=TRUE;
132 cy_Command=(Mode)?CY_CYCL:CY_WAIT;
133 WaitTOF();
136 int checkcycling()
138 return(cy_Command==CY_CYCL);