]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/bakapee.c
polished 16_vrs.h and put into make file AND! updated copyright to add yakui lover...
[16.git] / src / lib / bakapee.c
index 03be784f5cfa4bff7120ff6eb8fd31b9b35db317..3f8ab3e51b28c1f8fbbed1601e838b154fee7773 100755 (executable)
@@ -1,10 +1,10 @@
 /* Project 16 Source Code~
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
+ * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
  *
  * This file is part of Project 16.
  *
  * Project 16 is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as publiSCREEN_HEIGHTed by
+ * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
@@ -13,7 +13,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You SCREEN_HEIGHTould have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
  * write to the Free Software Foundation, Inc., 51 Franklin Street,
  * Fifth Floor, Boston, MA 02110-1301 USA.
 
 #include "src/lib/bakapee.h"
 
-void pdump(page_t *pee)
+/* clrstdin() clear any leftover chars tha may be in stdin stream */
+void clrstdin()
 {
-       int mult=(QUADWH);
-       int palq=(mult)*TILEWH;
-       int palcol=0;
-       int palx, paly;
-       for(paly=0; paly<palq; paly+=mult){
-               for(palx=0; palx<palq; palx+=mult){
-                               modexClearRegion(pee, palx+TILEWH, paly+TILEWH, mult, mult, palcol);
-                       palcol++;
-               }
-       }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                                                                                              //
-// cls() - This clears the screen to the specified color, on the VGA or on //
-//              the Virtual screen.                                                                                     //
-//                                                                                                                                              //
-/////////////////////////////////////////////////////////////////////////////
-void cls(page_t *page, byte color, byte *Where)
-{
-       //modexClearRegion(page, 0, 0, page->width, page->height, color);
-       _fmemset(Where, color, page->width*(page->height*2));
+   int ch = 0;
+   while( ( ch = getchar() ) != '\n' && ch != EOF );
 }
 
 //color \82Ä\82·\82Æ
@@ -53,7 +34,7 @@ void colortest(page_t *page, bakapee_t *pee)
 {
        //if(pee->coor < 256)
        //{
-               cls(page, pee->coor, VGA);
+               modexcls(page, pee->coor, VGA);
                pee->coor++;
        //}else pee->coor = 0;
 }
@@ -63,7 +44,7 @@ void colorz(page_t *page, bakapee_t *pee)
 {
        if(pee->coor <= HGQ)
        {
-               cls(page, pee->coor, VGA);
+               modexcls(page, pee->coor, VGA);
                pee->coor++;
        }else pee->coor = LGQ;
 }
@@ -71,47 +52,56 @@ void colorz(page_t *page, bakapee_t *pee)
 //slow spectrum down
 void ssd(page_t *page, bakapee_t *pee, word svq)
 {
-       if(pee->sy < SCREEN_HEIGHT+1)
+       if(pee->sy < page->sh+1)
        {
-               if(pee->sx < SCREEN_WIDTH+1)
+               if(pee->sx < page->sw+1)
                {
                        //mxPutPixel(sx, sy, coor);
                        //printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);
                        dingpp(page, pee);
                        pee->sx++;
                }else pee->sx = 0;
-               if(pee->sx == SCREEN_WIDTH)
+               if(pee->sx == page->sw)
                {
                        pee->sy++;
                        if(svq == 7) pee->coor++;
-                       if(pee->sy == SCREEN_HEIGHT && svq == 8) pee->coor = rand()%256;
+                       if(pee->sy == page->sh && svq == 8) pee->coor = rand()%256;
                }
        }else pee->sy = 0;
 }
 
-//plot pixel
+//plot pixel or plot tile
 void dingpp(page_t *page, bakapee_t *pee)
 {
-#ifdef TILE
-       modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
+       if(pee->tile)
+       {
+#ifndef MXLIB
+       //fill_block(pee->xx, pee->yy, pee->xx+TILEWH, pee->yy+TILEWH, pee->coor);
+               mxFillBox(pee->xx, pee->yy, TILEWH, TILEWH, pee->coor, OP_SET);
 #else
-       modexputPixel(page, pee->xx, pee->yy, pee->coor);
+               modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);
 #endif
+       }
+       else
+               modexputPixel(page, pee->xx, pee->yy, pee->coor);
 }
 
-void dingo(bakapee_t *pee)
+void dingo(page_t *page, bakapee_t *pee)
 {
-       #ifdef TILE
-       if(pee->xx<0) pee->xx=(SCREEN_WIDTH-TILEWH);
-       if(pee->yy<0) pee->yy=(SCREEN_HEIGHT-TILEWH);
-       if(pee->xx>(SCREEN_WIDTH-TILEWH)) pee->xx=0;
-       if(pee->yy>(SCREEN_HEIGHT-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
-       #else
-       if(pee->xx<0) pee->xx=SCREEN_WIDTH;
-       if(pee->yy<0) pee->yy=SCREEN_HEIGHT;
-       if(pee->xx>SCREEN_WIDTH) pee->xx=0;
-       if(pee->yy>SCREEN_HEIGHT) pee->yy=0;
-       #endif
+       if(pee->tile)
+       {
+               if(pee->xx<0) pee->xx=(page->sw-TILEWH);
+               if(pee->yy<0) pee->yy=(page->sh-TILEWH);
+               if(pee->xx>(page->sw-TILEWH)) pee->xx=0;
+               if(pee->yy>(page->sh-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;
+       }
+               else
+       {
+               if(pee->xx<0) pee->xx=page->sw;
+               if(pee->yy<0) pee->yy=page->sh;
+               if(pee->xx>page->sw) pee->xx=0;
+               if(pee->yy>page->sh) pee->yy=0;
+       }
 }
 
 //assigning values from randomizer
@@ -120,35 +110,27 @@ void dingas(bakapee_t *pee)
        if(pee->gq == BONK) dingu(pee);
        if(!pee->bakax)
        {
-               #ifdef TILE
+               if(pee->tile)
                pee->xx-=TILEWH;
-               #else
-               pee->xx--;
-               #endif
+               else pee->xx--;
        }
        else if(pee->bakax>1)
        {
-               #ifdef TILE
+               if(pee->tile)
                pee->xx+=TILEWH;
-               #else
-               pee->xx++;
-               #endif
+               else pee->xx++;
        }
        if(!pee->bakay)
        {
-               #ifdef TILE
+               if(pee->tile)
                pee->yy-=TILEWH;
-               #else
-               pee->yy--;
-               #endif
+               else pee->yy--;
        }
        else if(pee->bakay>1)
        {
-               #ifdef TILE
+               if(pee->tile)
                pee->yy+=TILEWH;
-               #else
-               pee->yy++;
-               #endif
+               else pee->yy++;
        }
 }
 
@@ -188,31 +170,30 @@ void ding(page_t *page, bakapee_t *pee, word q)
        {
                case 1:
                        dingq(pee);
-                       if(pee->xx==SCREEN_WIDTH){pee->bakax=0;}
+                       if(pee->xx==page->sw){pee->bakax=0;}
                        if(pee->xx==0){pee->bakax=1;}
-                       if(pee->yy==SCREEN_HEIGHT){pee->bakay=0;}
+                       if(pee->yy==page->sh){pee->bakay=0;}
                        if(pee->yy==0){pee->bakay=1;}
                break;
                case 2:
                        dingq(pee);
                        dingas(pee);
-                       dingo(pee);
+                       dingo(page, pee);
                        dingpp(page, pee);      //plot the pixel/tile
-#ifdef TILE
+                       if(pee->tile)
                        modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
-#else
+                       else
                        modexputPixel(page, rand()%page->width, rand()%page->height, 0);
-#endif
                break;
                case 3:
                        dingq(pee);
-                       if(pee->xx!=SCREEN_WIDTH||pee->yy!=SCREEN_HEIGHT)
+                       if(pee->xx!=page->sw||pee->yy!=page->sh)
                        {
                                if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}
                                if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}
-                               if(pee->xx==SCREEN_WIDTH){pee->bakax=-1;pee->bakay=-1;d3y=1;}
-                               if(pee->yy==SCREEN_HEIGHT){pee->bakax=1;pee->bakay=0;d3y=1;}
-                       }else if(pee->xx==SCREEN_WIDTH&&pee->yy==SCREEN_HEIGHT) pee->xx=pee->yy=0;
+                               if(pee->xx==page->sw){pee->bakax=-1;pee->bakay=-1;d3y=1;}
+                               if(pee->yy==page->sh){pee->bakax=1;pee->bakay=0;d3y=1;}
+                       }else if(pee->xx==page->sw&&pee->yy==page->sh) pee->xx=pee->yy=0;
                        if(d3y)
                        {
                                if(pee->bakay<0)
@@ -239,7 +220,7 @@ void ding(page_t *page, bakapee_t *pee, word q)
                case 4:
                        dingq(pee);
                        dingas(pee);
-                       dingo(pee);
+                       dingo(page, pee);
                        dingpp(page, pee);      //plot the pixel/tile
                break;
                case 5:
@@ -247,7 +228,7 @@ void ding(page_t *page, bakapee_t *pee, word q)
                break;
                case 6:
                        pee->coor = rand()%256;
-                       cls(page, pee->coor, VGA);
+                       modexcls(page, pee->coor, VGA);
                break;
                case 7:
                        if(pee->coor <= HGQ)
@@ -258,7 +239,7 @@ void ding(page_t *page, bakapee_t *pee, word q)
                break;
                case 8:
                        colorz(page, pee);
-                       modexprint(page, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 1, 47, 0, "bakapi");
+                       modexprint(page, page->sw/2, page->sh/2, 1, 47, 0, "bakapi");
                break;
                case 9:
                        if(pee->coor <= HGQ)
@@ -284,11 +265,10 @@ void ding(page_t *page, bakapee_t *pee, word q)
                        tx+=pee->xx+TILEWH+4;
                        ty+=pee->yy+TILEWH+4;
                        modexClearRegion(page, tx, ty, 4, 4, pee->coor);
-#ifdef TILE
-                       modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);
-#else
+                       if(pee->tile)
+                       modexClearRegion(page, (rand()*4)%page->width, (rand()*4)%(page->height), 4, 4, 0);
+                       else
                        modexputPixel(page, rand()%page->width, rand()%(page->height), 0);
-#endif
                        //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);
                break;
                default: