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