OSDN Git Service

Merge remote-tracking branch 'upstream/master'
[proj16/16.git] / src / bakapi.c
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
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 published 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/bakapi.h"
24
25 /*
26  * BAKAPEE!
27  */
28 global_game_variables_t gvar;
29 static bakapee_t bakapee;
30 word key,d,xpos,ypos,xdir,ydir;
31 int ch=0x0;
32
33 void
34 main(int argc, char *argvar[])
35 {
36         // main variables values
37         d=4; // switch variable
38         key=2; // default screensaver number
39         xpos=TILEWH*2;
40         ypos=TILEWH*2;
41         xdir=1;
42         ydir=1;
43
44 #ifdef MXLIB
45         VGAmodeX(1, &gvar);
46 #else
47         mxSetMode(3);
48 #endif
49         bakapee.xx = rand()&0%gvar.video.page[0].width;
50         bakapee.yy = rand()&0%gvar.video.page[0].height;
51         bakapee.gq = 0;
52         bakapee.sx=0;
53         bakapee.sy=0;
54         bakapee.bakax=0;
55         bakapee.bakay=0;
56         bakapee.coor=0;
57         bakapee.tile=0;
58
59         /* setup camera and screen~ */
60         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
61         gvar.video.page[0].width += (TILEWH*2);
62         gvar.video.page[0].height += (TILEWH*2);
63         textInit();
64
65         //modexPalUpdate(bmp.palette); //____
66         //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
67         //getch(); //____
68
69         modexShowPage(&gvar.video.page[0]);
70
71 // screen savers
72 #ifdef BOINK
73         while(d>0)      // on!
74         {
75                 if(!kbhit())
76                 { // conditions of screen saver
77                         ding(&gvar.video.page[0], &bakapee, key);
78                 }
79                 else
80                 {
81                         #ifndef MXLIB
82                         mxChangeMode(0);
83 #else
84                         VGAmodeX(0, &gvar);
85 #endif
86                         // user imput switch
87                         fprintf(stderr, "xx=%d  yy=%d\n", bakapee.xx, bakapee.yy);
88                         printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n", getch());  // prompt the user
89                         //scanf("%d", &key);
90                         if(scanf("%d", &key) != 1)
91                         {
92                                 printf("%d\n", key);
93                         }
94                         getch();
95                         //if(key==3){xx=yy=0;} // crazy screen saver wwww
96                         if(key==0){ d=0; }else{
97                                 gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
98                                 gvar.video.page[0].width += (TILEWH*2);
99                                 gvar.video.page[0].height += (TILEWH*2);
100 #ifdef MXLIB
101                                 VGAmodeX(1, &gvar);
102 #else
103                                 mxChangeMode(3);
104 #endif
105                                 modexShowPage(&gvar.video.page[0]);
106                         }
107                 }
108         }
109 #else
110         while(1)
111         { // conditions of screen saver
112                 while(!kbhit())
113                 {
114                         ding(&gvar.video.page[0], &bakapee, key);
115                 }
116                 //end of screen savers
117                 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
118                 {
119                         modexputPixel(&page, x, 0, 15);
120                         mxPutPixel(x, gvar.video.page[0].height-1, 15);
121                         }
122                 for (int y = 0; y < VH; ++y)
123                         {
124                                 mxPutPixel(0, y, 15);
125                                 mxPutPixel(gvar.video.page[0].width-1, y, 15);
126                         }
127                 for (int x = 0; x < VW; ++x)
128                         {
129                                 mxPutPixel(x, 0, 15);
130                                 mxPutPixel(x, VH-1, 15);
131                         }
132                 for (int y = 240; y < VH; ++y)
133                         {
134                                 mxPutPixel(0, y, 15);
135                                 mxPutPixel(VW-1, y, 15);
136                         }*/
137                 pdump(&gvar.video.page[0]);
138                 getch();
139                 //text box
140                 /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background
141                 mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box
142                 //+(QUADWH*6)
143                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
144                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "|    |Chikyuu:$line1");
145                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "|    |$line2");
146                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "|    |$line3");
147                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "|    |$line4");
148                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-8,  "========================================");
149                 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
150                 getch();
151                 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
152                 getch();++++*/
153                 while(!kbhit())
154                 {
155                         //for(int i=0;i<TILEWH;i++){
156                                 ding(&gvar.video.page[0], &bakapee, key);
157                                 modexPanPage(&gvar.video.page[0], xpos, ypos);
158 //++++mxFillBox(384, 304, 384, 304, 10, OP_SET);
159 //mxBitBlt(xpos, ypos, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
160 //++++mxBitBlt(TILEWH*2, TILEWH*2, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
161                                 //for(word o = 0; o<TILEWH; o++){
162                                         xpos+=xdir;
163                                         ypos+=ydir;
164                                         //if(ypos==1 || (ypos==(BH-gvar.video.page[0].height-1)))delay(500);
165                                         //if((xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500);
166                                         //mxWaitRetrace();
167 //mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
168 //++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
169 //xpos=ypos=TILEWH*2;
170                                         //????modexPanPage(&gvar.video.page[0], 32, 32);
171                                 //}
172                                 if( (xpos>(VW-gvar.video.page[0].width-1))  || (xpos<1)){xdir=-xdir;}
173                                 if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
174                         //}//    direction!
175 //mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
176 //mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
177                 }
178         ch=getch();
179         if(ch==0x71)break; // 'q'
180         if(ch==0x1b)break; // 'ESC'
181         }
182 //      VGAmodeX(0, &gvar);
183 #endif
184         printf("bakapi ver. 1.04.13.04\nis made by sparky4\81i\81\86\83Ö\81\85\81j feel free to use it ^^\nLicence: GPL v3\n");
185 }
186 //pee!