]> 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 publipage->shed 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 page->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.
20  *
21  */
22
23 #include "src/lib/bakapee.h"
24
25 //color \82Ä\82·\82Æ
26 void colortest(page_t *page, bakapee_t *pee)
27 {
28         //if(pee->coor < 256)
29         //{
30                 cls(page, pee->coor, VGA);
31                 pee->coor++;
32         //}else pee->coor = 0;
33 }
34
35 //color \82Ä\82·\82Æ
36 void colorz(page_t *page, bakapee_t *pee)
37 {
38         if(pee->coor <= HGQ)
39         {
40                 cls(page, pee->coor, VGA);
41                 pee->coor++;
42         }else pee->coor = LGQ;
43 }
44
45 //slow spectrum down
46 void ssd(page_t *page, bakapee_t *pee, word svq)
47 {
48         if(pee->sy < page->sh+1)
49         {
50                 if(pee->sx < page->sw+1)
51                 {
52                         //mxPutPixel(sx, sy, coor);
53                         //printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);
54                         dingpp(page, pee);
55                         pee->sx++;
56                 }else pee->sx = 0;
57                 if(pee->sx == page->sw)
58                 {
59                         pee->sy++;
60                         if(svq == 7) pee->coor++;
61                         if(pee->sy == page->sh && svq == 8) pee->coor = rand()%256;
62                 }
63         }else pee->sy = 0;
64 }
65
66 //plot pixel or plot tile
67 void dingpp(page_t *page, bakapee_t *pee)
68 {
69 #ifdef TILE
70         //fill_block(pee->xx, pee->yy, pee->xx+TILEWH, pee->yy+TILEWH, pee->coor);
71         modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
72 #else
73         modexputPixel(page, pee->xx, pee->yy, pee->coor);
74 #endif
75 }
76
77 void dingo(page_t *page, bakapee_t *pee)
78 {
79         #ifdef TILE
80         if(pee->xx<0) pee->xx=(page->sw-TILEWH);
81         if(pee->yy<0) pee->yy=(page->sh-TILEWH);
82         if(pee->xx>(page->sw-TILEWH)) pee->xx=0;
83         if(pee->yy>(page->sh-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
84         #else
85         if(pee->xx<0) pee->xx=page->sw;
86         if(pee->yy<0) pee->yy=page->sh;
87         if(pee->xx>page->sw) pee->xx=0;
88         if(pee->yy>page->sh) pee->yy=0;
89         #endif
90 }
91
92 //assigning values from randomizer
93 void dingas(bakapee_t *pee)
94 {
95         if(pee->gq == BONK) dingu(pee);
96         if(!pee->bakax)
97         {
98                 #ifdef TILE
99                 pee->xx-=TILEWH;
100                 #else
101                 pee->xx--;
102                 #endif
103         }
104         else if(pee->bakax>1)
105         {
106                 #ifdef TILE
107                 pee->xx+=TILEWH;
108                 #else
109                 pee->xx++;
110                 #endif
111         }
112         if(!pee->bakay)
113         {
114                 #ifdef TILE
115                 pee->yy-=TILEWH;
116                 #else
117                 pee->yy--;
118                 #endif
119         }
120         else if(pee->bakay>1)
121         {
122                 #ifdef TILE
123                 pee->yy+=TILEWH;
124                 #else
125                 pee->yy++;
126                 #endif
127         }
128 }
129
130 void dingu(bakapee_t *pee)
131 {
132         if(pee->coor < HGQ && pee->coor < LGQ) pee->coor = LGQ;
133         if(pee->coor < HGQ)
134         {
135                 pee->coor++;
136         }else{
137                 pee->coor = LGQ;
138         }
139 }
140
141 //randomizer
142 void dingq(bakapee_t *pee)
143 {
144         if(pee->gq<BONK)
145         {
146                 pee->gq++;
147         }
148         else
149         {
150                 dingu(pee);
151                 pee->gq = 0;
152         }
153         pee->bakax = rand()%3; pee->bakay = rand()%3;
154 }
155
156 /*-----------ding-------------*/
157 void ding(page_t *page, bakapee_t *pee, word q)
158 {
159         word d3y, tx=0,ty=0;
160
161 //++++  if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;
162         switch(q)
163         {
164                 case 1:
165                         dingq(pee);
166                         if(pee->xx==page->sw){pee->bakax=0;}
167                         if(pee->xx==0){pee->bakax=1;}
168                         if(pee->yy==page->sh){pee->bakay=0;}
169                         if(pee->yy==0){pee->bakay=1;}
170                 break;
171                 case 2:
172                         dingq(pee);
173                         dingas(pee);
174                         dingo(page, pee);
175                         dingpp(page, pee);      //plot the pixel/tile
176 #ifdef TILE
177                         modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
178 #else
179                         modexputPixel(page, rand()%page->width, rand()%page->height, 0);
180 #endif
181                 break;
182                 case 3:
183                         dingq(pee);
184                         if(pee->xx!=page->sw||pee->yy!=page->sh)
185                         {
186                                 if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
187                                 if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
188                                 if(pee->xx==page->sw){pee->bakax=-1;pee->bakay=-1;d3y=1;}
189                                 if(pee->yy==page->sh){pee->bakax=1;pee->bakay=0;d3y=1;}
190                         }else if(pee->xx==page->sw&&pee->yy==page->sh) pee->xx=pee->yy=0;
191                         if(d3y)
192                         {
193                                 if(pee->bakay<0)
194                                 {
195                                         pee->yy--;
196                                         d3y--;
197                                 }else
198                                 if(pee->bakay>0)
199                                 {
200                                         pee->yy++;
201                                         d3y--;
202                                 }
203                         }
204                         if(pee->bakax<0)
205                         {
206                                 pee->xx--;
207                         }else
208                         if(pee->bakax>0)
209                         {
210                                 pee->xx++;
211                         }
212                         dingpp(page, pee);      //plot the pixel/tile
213                 break;
214                 case 4:
215                         dingq(pee);
216                         dingas(pee);
217                         dingo(page, pee);
218                         dingpp(page, pee);      //plot the pixel/tile
219                 break;
220                 case 5:
221                         colortest(page, pee);
222                 break;
223                 case 6:
224                         pee->coor = rand()%256;
225                         cls(page, pee->coor, VGA);
226                 break;
227                 case 7:
228                         if(pee->coor <= HGQ)
229                         {
230                                 ssd(page, pee, q);
231                                 pee->coor++;
232                         }else pee->coor = LGQ;
233                 break;
234                 case 8:
235                         colorz(page, pee);
236                         modexprint(page, page->sw/2, page->sh/2, 1, 47, 0, "bakapi", 1);
237                 break;
238                 case 9:
239                         if(pee->coor <= HGQ)
240                         {
241                                 ssd(page, pee, q);
242                                 pee->coor++;
243                         }else pee->coor = LGQ;
244                 break;
245                 case 10:
246                         ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
247                 break;
248                 case 11:
249                         colorz(page, pee); delay(100);
250                 break;
251
252                 case 16:        //interesting effects
253                         dingq(pee);
254                         if(!pee->bakax){ pee->xx--;}
255                         else if(pee->bakax>0){ pee->xx++; }
256                         if(!pee->bakay){ pee->yy--;}
257                         else if(pee->bakay>0){ pee->yy++; }
258                         dingas(pee);
259                         tx+=pee->xx+TILEWH+4;
260                         ty+=pee->yy+TILEWH+4;
261                         modexClearRegion(page, tx, ty, 4, 4, pee->coor);
262 #ifdef TILE
263                         modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
264 #else
265                         modexputPixel(page, rand()%page->width, rand()%(page->height), 0);
266 #endif
267                         //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);
268                 break;
269                 default:
270                 break;
271         }
272         //pee->coor++;
273 }