]> 4ch.mooo.com Git - 16.git/blob - src/bakapi.c
7724507f7bb81d55f7bcbbb3d8c4d3bdc45a910b
[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         // DOSLIB: check our environment
37         probe_dos();
38
39         // DOSLIB: what CPU are we using?
40         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.
41         //      So this code by itself shouldn't care too much what CPU it's running on. Except that other
42         //      parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for
43         //      the CPU to carry out tasks. --J.C.
44         cpu_probe();
45
46         // DOSLIB: check for VGA
47         if (!probe_vga()) {
48                 printf("VGA probe failed\n");
49                 return;
50         }
51         // hardware must be VGA or higher!
52         if (!(vga_state.vga_flags & VGA_IS_VGA)) {
53                 printf("This program requires VGA or higher graphics hardware\n");
54                 return;
55         }
56
57         // main variables values
58         d=4; // switch variable
59         key=2; // default screensaver number
60         xpos=TILEWH*2;
61         ypos=TILEWH*2;
62         xdir=1;
63         ydir=1;
64
65 #ifdef MXLIB
66         VGAmodeX(1, &gvar); // TODO: Suggestion: Instead of magic numbers for the first param, might I suggest defining an enum or some #define constants that are easier to remember? --J.C.
67 #else
68 # error REMOVED // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
69                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
70 #endif
71         bakapee.xx = rand()&0%gvar.video.page[0].width;
72         bakapee.yy = rand()&0%gvar.video.page[0].height;
73         bakapee.gq = 0;
74         bakapee.sx=0;
75         bakapee.sy=0;
76         bakapee.bakax=0;
77         bakapee.bakay=0;
78         bakapee.coor=0;
79         bakapee.tile=0;
80
81         /* setup camera and screen~ */
82         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
83         gvar.video.page[0].width += (TILEWH*2);
84         gvar.video.page[0].height += (TILEWH*2);
85         textInit();
86
87         //modexPalUpdate(bmp.palette); //____
88         //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
89         //getch(); //____
90
91         modexShowPage(&gvar.video.page[0]);
92
93 // screen savers
94 #ifdef BOINK
95         while(d>0)      // on!
96         {
97                 /* run screensaver routine until keyboard input */
98                 while (key > 0) {
99                         if (kbhit()) {
100                                 getch(); // eat keyboard input
101                                 break;
102                         }
103
104                         ding(&gvar.video.page[0], &bakapee, key);
105                 }
106
107                 {
108                         int c;
109
110 # ifndef MXLIB
111 #  error REMOVED // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
112                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
113 # else
114                         VGAmodeX(0, &gvar);
115 # endif
116                         // user imput switch
117                         fprintf(stderr, "xx=%d  yy=%d   tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
118                         printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n");
119
120                         c = getch();
121                         switch (c) {
122                                 case 27: /* Escape key */
123                                 case '0':
124                                         d=0;
125                                         break;
126                                 case 'b': // test tile change
127                                         switch (bakapee.tile)
128                                         {
129                                                 case 0:
130                                                         bakapee.tile=1;
131                                                 break;
132                                                 case 1:
133                                                         bakapee.tile=0;
134                                                 break;
135                                         }
136                                         key=0;
137                                         break;
138                                 case '1':
139                                 case '2':
140                                 case '3':
141                                 case '4':
142                                 case '5':
143                                 case '6':
144                                         key = c - '0';
145 # ifdef MXLIB
146                                         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
147                                         gvar.video.page[0].width += (TILEWH*2);
148                                         gvar.video.page[0].height += (TILEWH*2);
149                                         VGAmodeX(1, &gvar);
150 # else
151 #  error REMOVED // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
152                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
153 # endif
154                                         modexShowPage(&gvar.video.page[0]);
155                                         break;
156                                 default:
157                                         key=0;
158                                         break;
159                         }
160                 }
161         }
162 #else // !defined(BOINK)
163 // FIXME: Does not compile. Do you want to remove this?
164         while(1)
165         { // conditions of screen saver
166                 while(!kbhit())
167                 {
168                         ding(&gvar.video.page[0], &bakapee, key);
169                 }
170                 //end of screen savers
171                 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
172                 {
173                         modexputPixel(&page, x, 0, 15);
174                         mxPutPixel(x, gvar.video.page[0].height-1, 15);
175                         }
176                 for (int y = 0; y < VH; ++y)
177                         {
178                                 mxPutPixel(0, y, 15);
179                                 mxPutPixel(gvar.video.page[0].width-1, y, 15);
180                         }
181                 for (int x = 0; x < VW; ++x)
182                         {
183                                 mxPutPixel(x, 0, 15);
184                                 mxPutPixel(x, VH-1, 15);
185                         }
186                 for (int y = 240; y < VH; ++y)
187                         {
188                                 mxPutPixel(0, y, 15);
189                                 mxPutPixel(VW-1, y, 15);
190                         }*/
191                 pdump(&gvar.video.page[0]);
192                 getch();
193                 //text box
194                 /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background
195                 mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box
196                 //+(QUADWH*6)
197                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
198                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "|    |Chikyuu:$line1");
199                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "|    |$line2");
200                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "|    |$line3");
201                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "|    |$line4");
202                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-8,  "========================================");
203                 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
204                 getch();
205                 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
206                 getch();++++*/
207                 while(!kbhit())
208                 {
209                         //for(int i=0;i<TILEWH;i++){
210                                 ding(&gvar.video.page[0], &bakapee, key);
211                                 modexPanPage(&gvar.video.page[0], xpos, ypos);
212 //++++mxFillBox(384, 304, 384, 304, 10, OP_SET);
213 //mxBitBlt(xpos, ypos, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
214 //++++mxBitBlt(TILEWH*2, TILEWH*2, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
215                                 //for(word o = 0; o<TILEWH; o++){
216                                         xpos+=xdir;
217                                         ypos+=ydir;
218                                         //if(ypos==1 || (ypos==(BH-gvar.video.page[0].height-1)))delay(500);
219                                         //if((xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500);
220                                         //mxWaitRetrace();
221 //mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
222 //++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
223 //xpos=ypos=TILEWH*2;
224                                         //????modexPanPage(&gvar.video.page[0], 32, 32);
225                                 //}
226                                 if( (xpos>(VW-gvar.video.page[0].width-1))  || (xpos<1)){xdir=-xdir;}
227                                 if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
228                         //}//    direction!
229 //mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
230 //mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
231                 }
232         ch=getch();
233         if(ch==0x71)break; // 'q'
234         if(ch==0x1b)break; // 'ESC'
235         }
236 //      VGAmodeX(0, &gvar);
237 #endif // defined(BOINK)
238         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");
239 }
240 //pee!