]> 4ch.mooo.com Git - 16.git/blob - src/lib/bakapee.c
wwww
[16.git] / src / lib / bakapee.c
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as publiSCREEN_HEIGHTed by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You SCREEN_HEIGHTould have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22
23 #include "src/lib/bakapee.h"
24
25 void pdump(page_t *pee)
26 {
27         int mult=(QUADWH);
28         int palq=(mult)*TILEWH;
29         int palcol=0;
30         int palx, paly;
31         for(paly=0; paly<palq; paly+=mult){
32                 for(palx=0; palx<palq; palx+=mult){
33                                 modexClearRegion(pee, palx+TILEWH, paly+TILEWH, mult, mult, palcol);
34                         palcol++;
35                 }
36         }
37 }
38
39 //color \82Ä\82·\82Æ
40 void colortest(page_t *page, bakapee_t *pee)
41 {
42         //if(pee->coor < 256)
43         //{
44                 cls(page, pee->coor, VGA);
45                 pee->coor++;
46         //}else pee->coor = 0;
47 }
48
49 //color \82Ä\82·\82Æ
50 void colorz(page_t *page, bakapee_t *pee)
51 {
52         if(pee->coor <= HGQ)
53         {
54                 cls(page, pee->coor, VGA);
55                 pee->coor++;
56         }else pee->coor = LGQ;
57 }
58
59 //slow spectrum down
60 void ssd(page_t *page, bakapee_t *pee, word svq)
61 {
62         if(pee->sy < SCREEN_HEIGHT+1)
63         {
64                 if(pee->sx < SCREEN_WIDTH+1)
65                 {
66                         //mxPutPixel(sx, sy, coor);
67                         //printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);
68                         dingpp(page, pee);
69                         pee->sx++;
70                 }else pee->sx = 0;
71                 if(pee->sx == SCREEN_WIDTH)
72                 {
73                         pee->sy++;
74                         if(svq == 7) pee->coor++;
75                         if(pee->sy == SCREEN_HEIGHT && svq == 8) pee->coor = rand()%256;
76                 }
77         }else pee->sy = 0;
78 }
79
80 //plot pixel
81 void dingpp(page_t *page, bakapee_t *pee)
82 {
83 #ifdef TILE
84         modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
85 #else
86         modexputPixel(page, pee->xx, pee->yy, pee->coor);
87 #endif
88 }
89
90 void dingo(bakapee_t *pee)
91 {
92         #ifdef TILE
93         if(pee->xx<0) pee->xx=(SCREEN_WIDTH-TILEWH);
94         if(pee->yy<0) pee->yy=(SCREEN_HEIGHT-TILEWH);
95         if(pee->xx>(SCREEN_WIDTH-TILEWH)) pee->xx=0;
96         if(pee->yy>(SCREEN_HEIGHT-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
97         #else
98         if(pee->xx<0) pee->xx=SCREEN_WIDTH;
99         if(pee->yy<0) pee->yy=SCREEN_HEIGHT;
100         if(pee->xx>SCREEN_WIDTH) pee->xx=0;
101         if(pee->yy>SCREEN_HEIGHT) pee->yy=0;
102         #endif
103 }
104
105 //assigning values from randomizer
106 void dingas(bakapee_t *pee)
107 {
108         if(pee->gq == BONK) dingu(pee);
109         if(!pee->bakax)
110         {
111                 #ifdef TILE
112                 pee->xx-=TILEWH;
113                 #else
114                 pee->xx--;
115                 #endif
116         }
117         else if(pee->bakax>1)
118         {
119                 #ifdef TILE
120                 pee->xx+=TILEWH;
121                 #else
122                 pee->xx++;
123                 #endif
124         }
125         if(!pee->bakay)
126         {
127                 #ifdef TILE
128                 pee->yy-=TILEWH;
129                 #else
130                 pee->yy--;
131                 #endif
132         }
133         else if(pee->bakay>1)
134         {
135                 #ifdef TILE
136                 pee->yy+=TILEWH;
137                 #else
138                 pee->yy++;
139                 #endif
140         }
141 }
142
143 void dingu(bakapee_t *pee)
144 {
145         if(pee->coor < HGQ && pee->coor < LGQ) pee->coor = LGQ;
146         if(pee->coor < HGQ)
147         {
148                 pee->coor++;
149         }else{
150                 pee->coor = LGQ;
151         }
152 }
153
154 //randomizer
155 void dingq(bakapee_t *pee)
156 {
157         if(pee->gq<BONK)
158         {
159                 pee->gq++;
160         }
161         else
162         {
163                 dingu(pee);
164                 pee->gq = 0;
165         }
166         pee->bakax = rand()%3; pee->bakay = rand()%3;
167 }
168
169 /*-----------ding-------------*/
170 void ding(page_t *page, bakapee_t *pee, word q)
171 {
172         word d3y, tx=0,ty=0;
173
174 //++++  if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;
175         switch(q)
176         {
177                 case 1:
178                         dingq(pee);
179                         if(pee->xx==SCREEN_WIDTH){pee->bakax=0;}
180                         if(pee->xx==0){pee->bakax=1;}
181                         if(pee->yy==SCREEN_HEIGHT){pee->bakay=0;}
182                         if(pee->yy==0){pee->bakay=1;}
183                 break;
184                 case 2:
185                         dingq(pee);
186                         dingas(pee);
187                         dingo(pee);
188                         dingpp(page, pee);      //plot the pixel/tile
189 #ifdef TILE
190                         modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
191 #else
192                         modexputPixel(page, rand()%page->width, rand()%page->height, 0);
193 #endif
194                 break;
195                 case 3:
196                         dingq(pee);
197                         if(pee->xx!=SCREEN_WIDTH||pee->yy!=SCREEN_HEIGHT)
198                         {
199                                 if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
200                                 if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
201                                 if(pee->xx==SCREEN_WIDTH){pee->bakax=-1;pee->bakay=-1;d3y=1;}
202                                 if(pee->yy==SCREEN_HEIGHT){pee->bakax=1;pee->bakay=0;d3y=1;}
203                         }else if(pee->xx==SCREEN_WIDTH&&pee->yy==SCREEN_HEIGHT) pee->xx=pee->yy=0;
204                         if(d3y)
205                         {
206                                 if(pee->bakay<0)
207                                 {
208                                         pee->yy--;
209                                         d3y--;
210                                 }else
211                                 if(pee->bakay>0)
212                                 {
213                                         pee->yy++;
214                                         d3y--;
215                                 }
216                         }
217                         if(pee->bakax<0)
218                         {
219                                 pee->xx--;
220                         }else
221                         if(pee->bakax>0)
222                         {
223                                 pee->xx++;
224                         }
225                         dingpp(page, pee);      //plot the pixel/tile
226                 break;
227                 case 4:
228                         dingq(pee);
229                         dingas(pee);
230                         dingo(pee);
231                         dingpp(page, pee);      //plot the pixel/tile
232                 break;
233                 case 5:
234                         colortest(page, pee);
235                 break;
236                 case 6:
237                         pee->coor = rand()%256;
238                         cls(page, pee->coor, VGA);
239                 break;
240                 case 7:
241                         if(pee->coor <= HGQ)
242                         {
243                                 ssd(page, pee, q);
244                                 pee->coor++;
245                         }else pee->coor = LGQ;
246                 break;
247                 case 8:
248                         colorz(page, pee);
249                         modexprint(page, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 1, 47, 0, "bakapi");
250                 break;
251                 case 9:
252                         if(pee->coor <= HGQ)
253                         {
254                                 ssd(page, pee, q);
255                                 pee->coor++;
256                         }else pee->coor = LGQ;
257                 break;
258                 case 10:
259                         ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
260                 break;
261                 case 11:
262                         colorz(page, pee); delay(100);
263                 break;
264
265                 case 16:        //interesting effects
266                         dingq(pee);
267                         if(!pee->bakax){ pee->xx--;}
268                         else if(pee->bakax>0){ pee->xx++; }
269                         if(!pee->bakay){ pee->yy--;}
270                         else if(pee->bakay>0){ pee->yy++; }
271                         dingas(pee);
272                         tx+=pee->xx+TILEWH+4;
273                         ty+=pee->yy+TILEWH+4;
274                         modexClearRegion(page, tx, ty, 4, 4, pee->coor);
275 #ifdef TILE
276                         modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
277 #else
278                         modexputPixel(page, rand()%page->width, rand()%(page->height), 0);
279 #endif
280                         //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);
281                 break;
282                 default:
283                 break;
284         }
285         //pee->coor++;
286 }