1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\r
6 * Project 16 is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * Project 16 is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
\r
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
\r
19 * Fifth Floor, Boston, MA 02110-1301 USA.
\r
23 #include "src/lib/bakapee.h"
\r
25 /* clrstdin() clear any leftover chars tha may be in stdin stream */
\r
29 while( ( ch = getchar() ) != '\n' && ch != EOF );
\r
32 //color
\82Ä
\82·
\82Æ
\r
33 void colortest(page_t *page, bakapee_t *pee)
\r
35 //if(pee->coor < 256)
\r
37 modexcls(page, pee->coor, VGA);
\r
39 //}else pee->coor = 0;
\r
42 //color
\82Ä
\82·
\82Æ
\r
43 void colorz(page_t *page, bakapee_t *pee)
\r
45 if(pee->coor <= pee->hgq)
\r
47 modexcls(page, pee->coor, VGA);
\r
49 }else pee->coor = pee->lgq;
\r
52 //slow spectrum down
\r
53 void ssd(page_t *page, bakapee_t *pee, word svq)
\r
55 if(pee->sy < page->sh+1)
\r
57 if(pee->sx < page->sw+1)
\r
59 //mxPutPixel(sx, sy, coor);
\r
60 //printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);
\r
64 if(pee->sx == page->sw)
\r
67 if(svq == 7) pee->coor++;
\r
68 if(pee->sy == page->sh && svq == 8) pee->coor = rand()%256;
\r
73 //plot pixel or plot tile
\r
74 void dingpp(page_t *page, bakapee_t *pee)
\r
78 modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
\r
81 modexputPixel(page, pee->xx, pee->yy, pee->coor);
\r
84 void dingo(page_t *page, bakapee_t *pee)
\r
88 if(pee->xx<0) pee->xx=(page->sw-TILEWH);
\r
89 if(pee->yy<0) pee->yy=(page->sh-TILEWH);
\r
90 if(pee->xx>(page->sw-TILEWH)) pee->xx=0;
\r
91 if(pee->yy>(page->sh-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
\r
95 if(pee->xx<0) pee->xx=page->sw;
\r
96 if(pee->yy<0) pee->yy=page->sh;
\r
97 if(pee->xx>page->sw) pee->xx=0;
\r
98 if(pee->yy>page->sh) pee->yy=0;
\r
102 //assigning values from randomizer
\r
103 void dingas(bakapee_t *pee)
\r
105 if(pee->gq == pee->bonk) dingu(pee);
\r
112 else if(pee->bakax>1)
\r
124 else if(pee->bakay>1)
\r
132 void dingaso(bakapee_t *pee)
\r
134 if(pee->gq == pee->bonk) dingu(pee);
\r
161 void dingu(bakapee_t *pee)
\r
163 if(pee->coor < pee->hgq && pee->coor < pee->lgq) pee->coor = pee->lgq;
\r
164 if(pee->coor < pee->hgq)
\r
168 pee->coor = pee->lgq;
\r
173 void dingq(bakapee_t *pee)
\r
175 if(pee->gq<pee->bonk)
\r
184 pee->bakax = rand()%3; pee->bakay = rand()%3;
\r
187 void dingqo(bakapee_t *pee)
\r
189 if(pee->gq<pee->bonk)
\r
192 pee->bakax = rand()%3; pee->bakay = rand()%3;
\r
199 //either one will do wwww --4
\r
200 pee->bakax = rand()&0x1; pee->bakay = rand()&0x1;
\r
201 //pee->bakax = rand()%2; pee->bakay = rand()%2;
\r
204 /*-----------ding-------------*/
\r
205 void ding(page_t *page, bakapee_t *pee, word q)
\r
207 word tx=0,ty=0;//d3y,
\r
209 //++++ if(q <= 4 && q!=2 && gq == pee->bonk-1) coor = rand()%pee->hgq;
\r
214 if(pee->xx==page->sw){pee->bakax=0;}
\r
215 if(pee->xx==0){pee->bakax=1;}
\r
216 if(pee->yy==page->sh){pee->bakay=0;}
\r
217 if(pee->yy==0){pee->bakay=1;}*/
\r
221 dingpp(page, pee); //plot the pixel/tile
\r
223 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
\r
225 modexputPixel(page, rand()%page->width, rand()%page->height, 0);
\r
231 dingpp(page, pee); //plot the pixel/tile
\r
233 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
\r
235 modexputPixel(page, rand()%page->width, rand()%page->height, 0);
\r
239 if(pee->xx!=page->sw||pee->yy!=page->sh)
\r
241 if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
\r
242 if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
\r
243 if(pee->xx==page->sw){pee->bakax=-1;pee->bakay=-1;d3y=1;}
\r
244 if(pee->yy==page->sh){pee->bakax=1;pee->bakay=0;d3y=1;}
\r
245 }else if(pee->xx==page->sw&&pee->yy==page->sh) pee->xx=pee->yy=0;
\r
267 dingpp(page, pee); //plot the pixel/tile*/
\r
271 dingpp(page, pee); //plot the pixel/tile
\r
277 dingpp(page, pee); //plot the pixel/tile
\r
280 colortest(page, pee);
\r
283 pee->coor = rand()%256;
\r
284 modexcls(page, pee->coor, VGA);
\r
287 if(pee->coor <= pee->hgq)
\r
291 }else pee->coor = pee->lgq;
\r
295 modexprint(page, page->sw/2, page->sh/2, 1, 47, 0, "bakapi");
\r
298 if(pee->coor <= pee->hgq)
\r
302 }else pee->coor = pee->lgq;
\r
305 ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
\r
308 colorz(page, pee); delay(100);
\r
311 case 16: //interesting effects
\r
313 if(!pee->bakax){ pee->xx--;}
\r
314 else if(pee->bakax>0){ pee->xx++; }
\r
315 if(!pee->bakay){ pee->yy--;}
\r
316 else if(pee->bakay>0){ pee->yy++; }
\r
318 tx+=pee->xx+TILEWH+4;
\r
319 ty+=pee->yy+TILEWH+4;
\r
320 modexClearRegion(page, tx, ty, 4, 4, pee->coor);
\r
322 modexClearRegion(page, (rand()*4)%page->width, (rand()*4)%(page->height), 4, 4, 0);
\r
324 modexputPixel(page, rand()%page->width, rand()%(page->height), 0);
\r
325 //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);
\r