]> 4ch.mooo.com Git - 16.git/blob - src/lib/bakapee.c
====scroll.exe coverted and bakapi.exe converted!! this is a major commit!
[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->qq++;
158                 pee->coor++;
159         }else{ pee->coor = LGQ;
160                 pee->qq = 0;
161                 pee->bakax = rand()%3; pee->bakay = rand()%3;
162         }
163 }
164
165 /*-----------ding-------------*/
166 void ding(page_t *page, bakapee_t *pee, word q)
167 {
168         word d3y, tx=0,ty=0;
169
170 //++++  if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;
171         switch(q)
172         {
173                 case 1:
174                         if(pee->qq<BONK)
175                         {
176                                 if(pee->xx==SCREEN_WIDTH){pee->bakax=0;}
177                                 if(pee->xx==0){pee->bakax=1;}
178                                 if(pee->yy==SCREEN_HEIGHT){pee->bakay=0;}
179                                 if(pee->yy==0){pee->bakay=1;}
180                                 pee->qq++;
181                         }else pee->qq = 0;
182                 break;
183                 case 2:
184                         if(pee->qq<BONK)
185                         {
186                                 dingu(pee);
187                                 dingas(pee);
188                                 dingo(pee);
189                                 dingpp(page, pee);      //plot the pixel/tile
190 #ifdef TILE
191                                 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
192 #else
193                                 modexputPixel(page, rand()%page->width, rand()%page->height, 0);
194 #endif
195                                 pee->bakax = rand()%3; pee->bakay = rand()%3;
196                                 pee->qq++;
197                         }else pee->qq = 0;
198                 break;
199                 case 3:
200                         if(pee->qq<BONK)
201                         {
202                                 if(pee->xx!=SCREEN_WIDTH||pee->yy!=SCREEN_HEIGHT)
203                                 {
204                                         if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
205                                         if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
206                                         if(pee->xx==SCREEN_WIDTH){pee->bakax=-1;pee->bakay=-1;d3y=1;}
207                                         if(pee->yy==SCREEN_HEIGHT){pee->bakax=1;pee->bakay=0;d3y=1;}
208                                 }else if(pee->xx==SCREEN_WIDTH&&pee->yy==SCREEN_HEIGHT) pee->xx=pee->yy=0;
209                                 if(d3y)
210                                 {
211                                         if(pee->bakay<0)
212                                         {
213                                                 pee->yy--;
214                                                 d3y--;
215                                         }else
216                                         if(pee->bakay>0)
217                                         {
218                                                 pee->yy++;
219                                                 d3y--;
220                                         }
221                                 }
222                                 if(pee->bakax<0)
223                                 {
224                                         pee->xx--;
225                                 }else
226                                 if(pee->bakax>0)
227                                 {
228                                         pee->xx++;
229                                 }
230                                 pee->qq++;
231                         }else pee->qq = 0;
232                 break;
233                 case 4:
234                         if(pee->qq<BONK)
235                         {
236                                 dingu(pee);
237                                 dingas(pee);
238                                 dingo(pee);
239                                 dingpp(page, pee);      //plot the pixel/tile
240                                 pee->bakax = rand()%3; pee->bakay = rand()%3;
241                                 pee->qq++;
242                         }else pee->qq = 0;
243                 break;
244                 case 5:
245                         colortest(page, pee);
246                 break;
247                 case 6:
248                         pee->coor = rand()%256;
249                         cls(page, pee->coor, VGA);
250                 break;
251                 case 7:
252                         if(pee->gq <= HGQ)
253                         {
254                                 ssd(page, pee, q);
255                                 pee->gq++;
256                         }else pee->gq = LGQ;
257                 break;
258                 case 8:
259                         colorz(page, pee);
260                         modexprint(page, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 1, 47, 0, "bakapi");
261                 break;
262                 case 9:
263                         if(pee->gq <= HGQ)
264                         {
265                                 ssd(page, pee, q); pee->coor++;
266                                 pee->gq++;
267                         }else pee->gq = LGQ;
268                 break;
269                 case 10:
270                         ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
271                 break;
272                 case 11:
273                         colorz(page, pee); delay(100);
274                 break;
275
276                 case 16:        //interesting effects
277                         if(pee->qq<BONK)
278                         {
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                                 dingu(pee);
284                                 dingas(pee);
285                                 tx+=pee->xx+TILEWH+4;
286                                 ty+=pee->yy+TILEWH+4;
287                                 modexClearRegion(page, tx, ty, 4, 4, pee->coor);
288 #ifdef TILE
289                                 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
290 #else
291                                 modexputPixel(page, rand()%page->width, rand()%(page->height), 0);
292 #endif
293                                 pee->bakax = rand()%3; pee->bakay = rand()%3;
294                                 //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);
295                                 pee->qq++;
296                         }else pee->qq = 0;
297                 break;
298                 default:
299                 break;
300         }
301         //pee->coor++;
302 }