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