OSDN Git Service

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