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