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