1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
4 * This file is part of Project 16.
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 published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
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.
16 * You should 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.
23 #include "src/lib/bakapee.h"
25 /* clrstdin() clear any leftover chars tha may be in stdin stream */
29 while( ( ch = getchar() ) != '\n' && ch != EOF );
33 void colortest(page_t *page, bakapee_t *pee)
37 modexcls(page, pee->coor, VGA);
39 //}else pee->coor = 0;
43 void colorz(page_t *page, bakapee_t *pee)
47 modexcls(page, pee->coor, VGA);
49 }else pee->coor = LGQ;
53 void ssd(page_t *page, bakapee_t *pee, word svq)
55 if(pee->sy < page->sh+1)
57 if(pee->sx < page->sw+1)
59 //mxPutPixel(sx, sy, coor);
60 //printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);
64 if(pee->sx == page->sw)
67 if(svq == 7) pee->coor++;
68 if(pee->sy == page->sh && svq == 8) pee->coor = rand()%256;
73 //plot pixel or plot tile
74 void dingpp(page_t *page, bakapee_t *pee)
79 //fill_block(pee->xx, pee->yy, pee->xx+TILEWH, pee->yy+TILEWH, pee->coor);
80 mxFillBox(pee->xx, pee->yy, TILEWH, TILEWH, pee->coor, OP_SET);
82 modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
86 modexputPixel(page, pee->xx, pee->yy, pee->coor);
89 void dingo(page_t *page, bakapee_t *pee)
93 if(pee->xx<0) pee->xx=(page->sw-TILEWH);
94 if(pee->yy<0) pee->yy=(page->sh-TILEWH);
95 if(pee->xx>(page->sw-TILEWH)) pee->xx=0;
96 if(pee->yy>(page->sh-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
100 if(pee->xx<0) pee->xx=page->sw;
101 if(pee->yy<0) pee->yy=page->sh;
102 if(pee->xx>page->sw) pee->xx=0;
103 if(pee->yy>page->sh) pee->yy=0;
107 //assigning values from randomizer
108 void dingas(bakapee_t *pee)
110 if(pee->gq == BONK) dingu(pee);
117 else if(pee->bakax>1)
129 else if(pee->bakay>1)
137 void dingu(bakapee_t *pee)
139 if(pee->coor < HGQ && pee->coor < LGQ) pee->coor = LGQ;
149 void dingq(bakapee_t *pee)
160 pee->bakax = rand()%3; pee->bakay = rand()%3;
163 /*-----------ding-------------*/
164 void ding(page_t *page, bakapee_t *pee, word q)
168 //++++ if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;
173 if(pee->xx==page->sw){pee->bakax=0;}
174 if(pee->xx==0){pee->bakax=1;}
175 if(pee->yy==page->sh){pee->bakay=0;}
176 if(pee->yy==0){pee->bakay=1;}
182 dingpp(page, pee); //plot the pixel/tile
184 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
186 modexputPixel(page, rand()%page->width, rand()%page->height, 0);
190 if(pee->xx!=page->sw||pee->yy!=page->sh)
192 if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
193 if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
194 if(pee->xx==page->sw){pee->bakax=-1;pee->bakay=-1;d3y=1;}
195 if(pee->yy==page->sh){pee->bakax=1;pee->bakay=0;d3y=1;}
196 }else if(pee->xx==page->sw&&pee->yy==page->sh) pee->xx=pee->yy=0;
218 dingpp(page, pee); //plot the pixel/tile
224 dingpp(page, pee); //plot the pixel/tile
227 colortest(page, pee);
230 pee->coor = rand()%256;
231 modexcls(page, pee->coor, VGA);
238 }else pee->coor = LGQ;
242 modexprint(page, page->sw/2, page->sh/2, 1, 47, 0, "bakapi");
249 }else pee->coor = LGQ;
252 ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
255 colorz(page, pee); delay(100);
258 case 16: //interesting effects
260 if(!pee->bakax){ pee->xx--;}
261 else if(pee->bakax>0){ pee->xx++; }
262 if(!pee->bakay){ pee->yy--;}
263 else if(pee->bakay>0){ pee->yy++; }
265 tx+=pee->xx+TILEWH+4;
266 ty+=pee->yy+TILEWH+4;
267 modexClearRegion(page, tx, ty, 4, 4, pee->coor);
269 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
271 modexputPixel(page, rand()%page->width, rand()%(page->height), 0);
272 //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);