1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\r
6 * Project 16 is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * Project 16 is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
\r
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
\r
19 * Fifth Floor, Boston, MA 02110-1301 USA.
\r
23 #include "src/lib/bakapee.h"
\r
25 //static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */
\r
26 //char global_temp_status_text[512];
\r
27 //char global_temp_status_text2[512];
\r
29 //==========================================================================
\r
36 = returns true if aborted
\r
41 //extern ControlInfo c;
\r
42 #define PIXPOSX gvar->video.page[0].sw/2
\r
43 #define PIXPOSY gvar->video.page[0].sh/2
\r
50 = returns true if aborted
\r
55 //extern ControlInfo c;
\r
56 //#define PIXPOSX gvar->video.page[0].sw/2
\r
57 //#define PIXPOSY gvar->video.page[0].sh/2
\r
58 #ifdef BAKAFIZZUNSIGNED
\r
59 boolean baka_FizzleFade (unsigned source, unsigned dest, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)
\r
62 unsigned drawofs,pagedelta;
\r
63 byte mask,maskb[8] = {1,2,4,8};
\r
68 unsigned esorig;//,q;
\r
71 pagedelta = dest-source;
\r
74 esorig = 0;// q = 16;
\r
77 pixperframe = (dword)(gvar->video.page[0].width*gvar->video.page[0].height)/frames;//64000/(dword)frames;
\r
78 screenseg = SCREENSEG;
\r
80 // IN_StartAck (gvar);
\r
82 // modexClearRegion(&(gvar->video.page[0]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 0);
\r
83 // modexClearRegion(&(gvar->video.page[1]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 15);
\r
94 if (abortable && kbhit())//IN_CheckAck (gvar) )
\r
101 for (p=0;p<pixperframe;p++)
\r
105 // seperate random value into x/y pair
\r
107 mov ax,[WORD PTR rndval]
\r
108 mov dx,[WORD PTR rndval+2]
\r
111 mov [BYTE PTR y],bl // low 8 bits - 1 = y xoordinate
\r
114 mov [BYTE PTR x],ah // next 9 bits = x xoordinate
\r
115 mov [BYTE PTR x+1],dl
\r
117 // advance to next random element
\r
124 #ifdef __BORLANDC__
\r
128 #ifdef __BORLANDC__
\r
131 mov [WORD PTR rndval],ax
\r
132 mov [WORD PTR rndval+2],dx
\r
135 if (x>width || y>height)
\r
136 // if ((x>width || y>height) && (x<width*2 && y<height*2))
\r
138 // drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);
\r
139 drawofs = source+(y*gvar->video.page[0].stridew) + (x>>2);
\r
141 sprintf(global_temp_status_text, "draw - %Fp", drawofs);
\r
142 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
143 sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);
\r
144 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
145 sprintf(global_temp_status_text, "srce - %Fp", source);
\r
146 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
147 sprintf(global_temp_status_text, "dest - %Fp", dest);
\r
148 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;
\r
156 mask = maskb[mask];
\r
166 if (rndval == 1) // entire sequence has been completed
\r
170 //-- while (TimeCount<frame){}//; // don't go too fast
\r
182 boolean baka_FizzleFade (page_t *sourcepage, page_t *destpage, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)
\r
184 word p,pixperframe;
\r
185 unsigned drawofs,pagedelta;
\r
186 // byte mask,maskb[8] = {1,2,4,8};
\r
187 unsigned x,y,frame ,esorig,q;
\r
189 unsigned source,dest;
\r
190 word screenseg = SCREENSEG;
\r
191 source = ((word)sourcepage->data); dest = ((word)destpage->data);
\r
193 pagedelta = dest-source;
\r
194 rndval = 1; esorig = 0; q = 16;
\r
195 x = y = 0;//destpage->dx;
\r
196 pixperframe = 76800/(dword)frames;
\r
200 // VL_ShowPage(&(gvar->video.page[0]), 1, 0);
\r
201 // VL_ShowPage(&(gvar->video.page[1]), 1, 0);
\r
203 // modexClearRegion(&(gvar->video.page[0]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 0);
\r
204 // modexClearRegion(&(gvar->video.page[1]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 15);
\r
205 // VL_SetLineWidth(80, gvar);
\r
214 sprintf(global_temp_status_text, "%u", frame);
\r
215 modexprint(destpage, PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
\r
216 if (abortable && kbhit())//IN_CheckAck () )
\r
223 for (p=0;p<pixperframe;p++)
\r
227 // seperate random value into x/y pair
\r
229 mov ax,[WORD PTR rndval]
\r
230 mov dx,[WORD PTR rndval+2]
\r
233 mov [BYTE PTR y],bl // low 8 bits - 1 = y xoordinate
\r
236 mov [BYTE PTR x],ah // next 9 bits = x xoordinate
\r
237 mov [BYTE PTR x+1],dl
\r
239 // advance to next random element
\r
246 #ifdef __BORLANDC__
\r
250 #ifdef __BORLANDC__
\r
253 mov [WORD PTR rndval],ax
\r
254 mov [WORD PTR rndval+2],dx
\r
257 // if (x>destpage->width || y>destpage->height)
\r
258 // if (x<destpage->sw || y<destpage->sh)
\r
259 if ((x>width || y>height) && (x<width*2 && y<height*2))
\r
261 drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);
\r
262 sprintf(global_temp_status_text, "draw - %Fp", drawofs);
\r
263 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
264 sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);
\r
265 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
266 sprintf(global_temp_status_text, "srcp - %Fp", sourcepage->data);
\r
267 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
268 sprintf(global_temp_status_text, "desp - %Fp", destpage->data);
\r
269 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
270 sprintf(global_temp_status_text, "srce - %Fp", source);
\r
271 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
272 sprintf(global_temp_status_text, "dest - %Fp", dest);
\r
273 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;
\r
281 mask = maskb[mask];
\r
284 // modexputPixel(&(gvar->video.page[0]), x, y, rand());
\r
285 // VL_Plot (x, y, 15, &(gvar->video.ofs));
\r
286 modexCopyPageRegion(destpage, sourcepage, x, y, x, y, 4, 4);
\r
295 if (rndval == 1) // entire sequence has been completed
\r
299 //-- while (TimeCount<frame){}//; // don't go too fast
\r
309 boolean baka_FizzleFade (page_t *sourcepage, page_t *destpage, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)
\r
311 word p,pixperframe;
\r
312 unsigned drawofs,pagedelta;
\r
313 byte mask,maskb[8] = {1,2,4,8};
\r
314 unsigned x,y,frame ,esorig,q;
\r
316 unsigned source,dest;
\r
317 // word TimeCount = *clockw;
\r
318 word screenseg = SCREENSEG;
\r
319 source = ((word)sourcepage->data); dest = ((word)destpage->data);
\r
321 pagedelta = dest-source;//(word)(source->data - dest->data);//(dest->data - source->data)
\r
322 rndval = 1; esorig = 0; q = 16;
\r
323 x = y = destpage->dx;
\r
324 pixperframe = /*76800*/64000/(dword)frames;
\r
328 // VL_ShowPage(destpage, 1, 0);
\r
329 // VL_ShowPage(sourcepage, 1, 0);
\r
331 // modexClearRegion(destpage, 0, 0, (destpage->width), (destpage->height), 12);
\r
332 modexClearRegion(sourcepage, 0, 0, (sourcepage->width), (sourcepage->height), 64);
\r
341 sprintf(global_temp_status_text, "%u", frame);
\r
342 modexprint(destpage, PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
\r
343 if (abortable && kbhit())//IN_CheckAck () )
\r
350 for (p=0;p<pixperframe;p++)
\r
354 // seperate random value into x/y pair
\r
356 mov ax,[WORD PTR rndval]
\r
357 mov dx,[WORD PTR rndval+2]
\r
360 mov [BYTE PTR y],bl // low 8 bits - 1 = y xoordinate
\r
363 mov [BYTE PTR x],ah // next 9 bits = x xoordinate
\r
364 mov [BYTE PTR x+1],dl
\r
366 // advance to next random element
\r
373 #ifdef __BORLANDC__
\r
377 #ifdef __BORLANDC__
\r
380 mov [WORD PTR rndval],ax
\r
381 mov [WORD PTR rndval+2],dx
\r
384 // if (x>destpage->width || y>destpage->height)
\r
385 // if (x<destpage->sw || y<destpage->sh)
\r
386 if (x>width || y>height)
\r
388 drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);
\r
389 sprintf(global_temp_status_text, "draw - %Fp", drawofs);
\r
390 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
391 sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);
\r
392 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
393 sprintf(global_temp_status_text, "srcp - %Fp", sourcepage->data);
\r
394 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
395 sprintf(global_temp_status_text, "desp - %Fp", destpage->data);
\r
396 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
397 sprintf(global_temp_status_text, "srce - %Fp", source);
\r
398 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;
\r
399 sprintf(global_temp_status_text, "dest - %Fp", dest);
\r
400 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;
\r
407 mask = maskb[mask];
\r
417 if (rndval == 1) // entire sequence has been completed
\r
421 //-- while (TimeCount<frame){}//; // don't go too fast
\r
429 // clrstdin() clear any leftover chars tha may be in stdin stream //
\r
433 while( ( ch = getchar() ) != '\n' && ch != EOF );
\r
436 //===========================================================================
\r
439 ====================
\r
443 ====================
\r
446 void TL_DosLibStartup(global_game_variables_t *gvar)
\r
448 if(gvar->DLStarted)
\r
451 // DOSLIB: check our environment
\r
454 // DOSLIB: what CPU are we using?
\r
455 // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.
\r
456 // So this code by itself shouldn't care too much what CPU it's running on. Except that other
\r
457 // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for
\r
458 // the CPU to carry out tasks. --J.C.
\r
461 // DOSLIB: check for VGA
\r
462 if (!probe_vga()) {
\r
463 printf("VGA probe failed\n");
\r
466 // hardware must be VGA or higher!
\r
467 if (!(vga_state.vga_flags & VGA_IS_VGA)) {
\r
468 printf("This program requires VGA or higher graphics hardware\n");
\r
473 gvar->DLStarted = true;
\r
476 //color
\82Ä
\82·
\82Æ
\r
477 void colortest(page_t *page, bakapee_t *pee)
\r
479 //if(pee->coor < 256)
\r
481 // modexcls(page, pee->coor, VGA);
\r
482 VL_ClearVideo (pee->coor);
\r
484 //}else pee->coor = 0;
\r
487 //color
\82Ä
\82·
\82Æ
\r
488 void colorz(page_t *page, bakapee_t *pee)
\r
490 if(pee->coor <= pee->hgq)
\r
492 // modexcls(page, pee->coor, VGA);
\r
493 VL_ClearVideo (pee->coor);
\r
495 }else pee->coor = pee->lgq;
\r
498 //slow spectrum down
\r
499 void ssd(page_t *page, bakapee_t *pee, word svq)
\r
501 if(pee->sy < page->sh+1)
\r
503 if(pee->sx < page->sw+1)
\r
505 //mxPutPixel(sx, sy, coor);
\r
506 //printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);
\r
510 if(pee->sx == page->sw)
\r
513 if(svq == 7) pee->coor++;
\r
514 if(pee->sy == page->sh && svq == 8) pee->coor = rand()%256;
\r
519 //plot pixel or plot tile
\r
520 void dingpp(page_t *page, bakapee_t *pee)
\r
524 modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
\r
527 modexputPixel(page, pee->xx, pee->yy, pee->coor);
\r
530 void dingo(page_t *page, bakapee_t *pee)
\r
534 if(pee->xx<0) pee->xx=(page->sw-TILEWH);
\r
535 if(pee->yy<0) pee->yy=(page->sh-TILEWH);
\r
536 if(pee->xx>(page->sw-TILEWH)) pee->xx=0;
\r
537 if(pee->yy>(page->sh-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
\r
541 if(pee->xx<0) pee->xx=page->sw;
\r
542 if(pee->yy<0) pee->yy=page->sh;
\r
543 if(pee->xx>page->sw) pee->xx=0;
\r
544 if(pee->yy>page->sh) pee->yy=0;
\r
548 //assigning values from randomizer
\r
549 void dingas(bakapee_t *pee)
\r
551 if(pee->gq == pee->bonk) dingu(pee);
\r
558 else if(pee->bakax>1)
\r
570 else if(pee->bakay>1)
\r
578 void dingaso(bakapee_t *pee)
\r
580 if(pee->gq == pee->bonk) dingu(pee);
\r
607 void dingu(bakapee_t *pee)
\r
609 if(pee->coor < pee->hgq && pee->coor < pee->lgq) pee->coor = pee->lgq;
\r
610 if(pee->coor < pee->hgq)
\r
614 pee->coor = pee->lgq;
\r
619 void dingq(bakapee_t *pee)
\r
621 if(pee->gq<pee->bonk)
\r
630 pee->bakax = rand()%3; pee->bakay = rand()%3;
\r
633 void dingqo(bakapee_t *pee)
\r
635 if(pee->gq<pee->bonk)
\r
638 pee->bakax = rand()%3; pee->bakay = rand()%3;
\r
645 //either one will do wwww --4
\r
646 pee->bakax = rand()&0x1; pee->bakay = rand()&0x1;
\r
647 //pee->bakax = rand()%2; pee->bakay = rand()%2;
\r
650 /*-----------ding-------------*/
\r
651 void ding(page_t *page, bakapee_t *pee, word q)
\r
653 word tx=0,ty=0;//d3y,
\r
655 //++++ if(q <= 4 && q!=2 && gq == pee->bonk-1) coor = rand()%pee->hgq;
\r
660 if(pee->xx==page->sw){pee->bakax=0;}
\r
661 if(pee->xx==0){pee->bakax=1;}
\r
662 if(pee->yy==page->sh){pee->bakay=0;}
\r
663 if(pee->yy==0){pee->bakay=1;}*/
\r
667 dingpp(page, pee); //plot the pixel/tile
\r
669 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
\r
671 modexputPixel(page, rand()%page->width, rand()%page->height, 0);
\r
677 dingpp(page, pee); //plot the pixel/tile
\r
679 modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
\r
681 modexputPixel(page, rand()%page->width, rand()%page->height, 0);
\r
685 if(pee->xx!=page->sw||pee->yy!=page->sh)
\r
687 if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
\r
688 if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
\r
689 if(pee->xx==page->sw){pee->bakax=-1;pee->bakay=-1;d3y=1;}
\r
690 if(pee->yy==page->sh){pee->bakax=1;pee->bakay=0;d3y=1;}
\r
691 }else if(pee->xx==page->sw&&pee->yy==page->sh) pee->xx=pee->yy=0;
\r
713 dingpp(page, pee); //plot the pixel/tile*/
\r
717 dingpp(page, pee); //plot the pixel/tile
\r
723 dingpp(page, pee); //plot the pixel/tile
\r
726 colortest(page, pee);
\r
729 // pee->coor = rand()%256;
\r
730 // modexcls(page, pee->coor, VGA);
\r
732 modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi");
\r
735 if(pee->coor <= pee->hgq)
\r
739 }else pee->coor = pee->lgq;
\r
743 modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi");
\r
746 modexClearRegion(&(ggvv->video.page[0]), 0, 0, ggvv->video.page[0].width/2, ggvv->video.page[0].height/2, 15);
\r
747 #ifdef BAKAFIZZUNSIGNED
\r
748 // baka_FizzleFade (ggvv->video.ofs.bufferofs, ggvv->video.ofs.displayofs, vga_state.vga_width, vga_state.vga_height, 70, true, ggvv);
\r
749 baka_FizzleFade (ggvv->video.ofs.bufferofs, ggvv->video.ofs.displayofs, ggvv->video.page[0].width, ggvv->video.page[0].height, 70, true, ggvv);
\r
751 baka_FizzleFade (&ggvv->video.page[1], &ggvv->video.page[0], vga_state.vga_width, vga_state.vga_height, 70, true, ggvv);
\r
755 ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
\r
758 colorz(page, pee); delay(100);
\r
761 case 16: //interesting effects
\r
763 if(!pee->bakax){ pee->xx--;}
\r
764 else if(pee->bakax>0){ pee->xx++; }
\r
765 if(!pee->bakay){ pee->yy--;}
\r
766 else if(pee->bakay>0){ pee->yy++; }
\r
768 tx+=pee->xx+TILEWH+4;
\r
769 ty+=pee->yy+TILEWH+4;
\r
770 modexClearRegion(page, tx, ty, 4, 4, pee->coor);
\r
772 modexClearRegion(page, (rand()*4)%page->width, (rand()*4)%(page->height), 4, 4, 0);
\r
774 modexputPixel(page, rand()%page->width, rand()%(page->height), 0);
\r
775 //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);
\r
780 //printf(" %dx%d %dx%d\n", pee->xx, pee->yy, tx, ty);
\r