]> 4ch.mooo.com Git - 16.git/blob - src/bakapi.c
remove copypasta from vga library. The modex16 routines are a better fit
[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                 if(!kbhit())
98                 { // conditions of screen saver
99                         ding(&gvar.video.page[0], &bakapee, key);
100                 }
101                 else
102                 {
103 # ifndef MXLIB
104 #  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.
105                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
106 # else
107                         VGAmodeX(0, &gvar);
108 # endif
109                         // user imput switch
110                         fprintf(stderr, "xx=%d  yy=%d   tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
111                         printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n", getch());  // prompt the user
112                         //scanf("%d", &key);
113                         if(scanf("%d", &key) != 1)
114                         {
115                                 printf("%d\n", key);
116                         }
117                         getch();
118                         //if(key==3){xx=yy=0;} // crazy screen saver wwww
119                         switch (key)
120                         {
121                                 case 0:
122                                         d=0;
123                                 break;
124                                 case 65536:
125                                         switch (bakapee.tile)
126                                         {
127                                                 case 0:
128                                                         bakapee.tile=1;
129                                                 break;
130                                                 case 1:
131                                                         bakapee.tile=0;
132                                                 break;
133                                         }
134                                         d=2;
135                                 default:
136 # ifdef MXLIB
137                                         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
138                                         gvar.video.page[0].width += (TILEWH*2);
139                                         gvar.video.page[0].height += (TILEWH*2);
140                                         VGAmodeX(1, &gvar);
141 # else
142 #  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.
143                 // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
144 # endif
145                                         modexShowPage(&gvar.video.page[0]);
146                                 break;
147                         }
148                 }
149         }
150 #else // !defined(BOINK)
151 // FIXME: Does not compile. Do you want to remove this?
152         while(1)
153         { // conditions of screen saver
154                 while(!kbhit())
155                 {
156                         ding(&gvar.video.page[0], &bakapee, key);
157                 }
158                 //end of screen savers
159                 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
160                 {
161                         modexputPixel(&page, x, 0, 15);
162                         mxPutPixel(x, gvar.video.page[0].height-1, 15);
163                         }
164                 for (int y = 0; y < VH; ++y)
165                         {
166                                 mxPutPixel(0, y, 15);
167                                 mxPutPixel(gvar.video.page[0].width-1, y, 15);
168                         }
169                 for (int x = 0; x < VW; ++x)
170                         {
171                                 mxPutPixel(x, 0, 15);
172                                 mxPutPixel(x, VH-1, 15);
173                         }
174                 for (int y = 240; y < VH; ++y)
175                         {
176                                 mxPutPixel(0, y, 15);
177                                 mxPutPixel(VW-1, y, 15);
178                         }*/
179                 pdump(&gvar.video.page[0]);
180                 getch();
181                 //text box
182                 /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background
183                 mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box
184                 //+(QUADWH*6)
185                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
186                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "|    |Chikyuu:$line1");
187                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "|    |$line2");
188                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "|    |$line3");
189                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "|    |$line4");
190                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-8,  "========================================");
191                 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
192                 getch();
193                 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
194                 getch();++++*/
195                 while(!kbhit())
196                 {
197                         //for(int i=0;i<TILEWH;i++){
198                                 ding(&gvar.video.page[0], &bakapee, key);
199                                 modexPanPage(&gvar.video.page[0], xpos, ypos);
200 //++++mxFillBox(384, 304, 384, 304, 10, OP_SET);
201 //mxBitBlt(xpos, ypos, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
202 //++++mxBitBlt(TILEWH*2, TILEWH*2, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
203                                 //for(word o = 0; o<TILEWH; o++){
204                                         xpos+=xdir;
205                                         ypos+=ydir;
206                                         //if(ypos==1 || (ypos==(BH-gvar.video.page[0].height-1)))delay(500);
207                                         //if((xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500);
208                                         //mxWaitRetrace();
209 //mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
210 //++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
211 //xpos=ypos=TILEWH*2;
212                                         //????modexPanPage(&gvar.video.page[0], 32, 32);
213                                 //}
214                                 if( (xpos>(VW-gvar.video.page[0].width-1))  || (xpos<1)){xdir=-xdir;}
215                                 if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
216                         //}//    direction!
217 //mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
218 //mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
219                 }
220         ch=getch();
221         if(ch==0x71)break; // 'q'
222         if(ch==0x1b)break; // 'ESC'
223         }
224 //      VGAmodeX(0, &gvar);
225 #endif // defined(BOINK)
226         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");
227 }
228 //pee!