1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
4 * This file is part of Project 16.
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.
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.
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.
23 #include "src/lib/bakapee.h"
25 /////////////////////////////////////////////////////////////////////////////
27 // setvideo() - This function Manages the video modes //
29 /////////////////////////////////////////////////////////////////////////////
30 void setVGAmodeX(global_game_variables_t *vid, boolean vq)
36 // change to the video mode we were in before we switched to mode 13h
39 in.h.al = vid->old_mode;
40 int86(0x10, &in, &out);
42 }else if(vq==1){ // init the video
45 int86(0x10, &in, &out);
46 vid->old_mode = out.h.al;
52 void pdump(page_t *pee)
55 int palq=(mult)*TILEWH;
58 for(paly=0; paly<palq; paly+=mult){
59 for(palx=0; palx<palq; palx+=mult){
60 modexClearRegion(pee, palx+TILEWH, paly+TILEWH, mult, mult, palcol);
66 /////////////////////////////////////////////////////////////////////////////
68 // cls() - This clears the screen to the specified color, on the VGA or on //
69 // the Virtual screen. //
71 /////////////////////////////////////////////////////////////////////////////
72 void cls(page_t *page, byte color, byte *Where)
74 //modexClearRegion(page, 0, 0, page->width, page->height, color);
75 _fmemset(Where, color, page->width*(page->height*2));
79 void colortest(page_t *page, bakapee_t *pee)
83 cls(page, pee->gq, VGA);
89 void colorz(page_t *page, bakapee_t *pee)
93 cls(page, pee->gq, VGA);
99 void ssd(page_t *page, bakapee_t *pee, word svq)
101 if(pee->sy < SCREEN_HEIGHT+1)
103 if(pee->sx < SCREEN_WIDTH+1)
105 //mxPutPixel(sx, sy, coor);
106 printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);
109 if(pee->sx == SCREEN_WIDTH)
112 if(svq == 7) pee->coor++;
113 if(pee->sy == SCREEN_HEIGHT && svq == 8) pee->coor = rand()%256;
118 void dingpp(page_t *page, bakapee_t *pee)
121 modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
123 modexputPixel(page, pee->xx, pee->yy, pee->coor);
127 void dingo(bakapee_t *pee)
130 if(pee->xx<0) pee->xx=(SCREEN_WIDTH-TILEWH);
131 if(pee->yy<0) pee->yy=(SCREEN_HEIGHT-TILEWH);
132 if(pee->xx>(SCREEN_WIDTH-TILEWH)) pee->xx=0;
133 if(pee->yy>(SCREEN_HEIGHT-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
135 if(pee->xx<0) pee->xx=SCREEN_WIDTH;
136 if(pee->yy<0) pee->yy=SCREEN_HEIGHT;
137 if(pee->xx>SCREEN_WIDTH) pee->xx=0;
138 if(pee->yy>SCREEN_HEIGHT) pee->yy=0;
142 void dingas(bakapee_t *pee)
144 if(pee->gq == BONK) dingu(pee);
153 else if(pee->bakax>1)
169 else if(pee->bakay>1)
179 void dingu(bakapee_t *pee)
181 if(pee->coor < HGQ && pee->coor < LGQ) pee->coor = LGQ;
185 }else{ pee->coor = LGQ;
186 pee->bakax = rand()%3; pee->bakay = rand()%3;
190 /*-----------ding-------------*/
191 void ding(page_t *page, bakapee_t *pee, word q)
195 //++++ if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;
201 if(pee->xx==SCREEN_WIDTH){pee->bakax=0;}
202 if(pee->xx==0){pee->bakax=1;}
203 if(pee->yy==SCREEN_HEIGHT){pee->bakay=0;}
204 if(pee->yy==0){pee->bakay=1;}
213 dingpp(page, pee); //plot the pixel/tile
215 modexClearRegion(page, (rand()*TILEWH)%SCREEN_WIDTH, (rand()*TILEWH)%(SCREEN_HEIGHT), TILEWH, TILEWH, 0);
217 modexputPixel(page, rand()%SCREEN_WIDTH, rand()%(SCREEN_HEIGHT), 0);
219 pee->bakax = rand()%3; pee->bakay = rand()%3;
226 if(pee->xx!=SCREEN_WIDTH||pee->yy!=SCREEN_HEIGHT)
228 if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
229 if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
230 if(pee->xx==SCREEN_WIDTH){pee->bakax=-1;pee->bakay=-1;d3y=1;}
231 if(pee->yy==SCREEN_HEIGHT){pee->bakax=1;pee->bakay=0;d3y=1;}
232 }else if(pee->xx==SCREEN_WIDTH&&pee->yy==SCREEN_HEIGHT) pee->xx=pee->yy=0;
262 dingpp(page, pee); //plot the pixel/tile
263 pee->bakax = rand()%3; pee->bakay = rand()%3;
268 colortest(page, pee);
271 pee->coor = rand()%256;
272 cls(page, pee->coor, VGA);
283 modexprint(page, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 1, 47, 0, "bakapi");
288 ssd(page, pee, q); pee->coor++;
293 ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
296 colorz(page, pee); delay(100);
299 case 16: //interesting effects
302 if(!pee->bakax){ pee->xx--;}
303 else if(pee->bakax>0){ pee->xx++; }
304 if(!pee->bakay){ pee->yy--;}
305 else if(pee->bakay>0){ pee->yy++; }
307 tx+=pee->xx+TILEWH+4;
308 ty+=pee->yy+TILEWH+4;
309 modexClearRegion(page, tx, ty, 4, 4, pee->coor);
311 modexClearRegion(page, (rand()*TILEWH)%SCREEN_WIDTH, (rand()*TILEWH)%(SCREEN_HEIGHT), TILEWH, TILEWH, 0);
313 modexputPixel(page, rand()%SCREEN_WIDTH, rand()%(SCREEN_HEIGHT), 0);
315 pee->bakax = rand()%3; pee->bakay = rand()%3;
316 //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);