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