1 /* Project 16 Source Code~
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
4 * This file is part of Project 16.
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.
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.
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.
23 #include "src/bakapi.h"
28 global_game_variables_t gvar;
29 static bakapee_t bakapee;
30 word key,d,xpos,ypos,xdir,ydir;
34 main(int argc, char *argvar[])
36 // DOSLIB: check our environment
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.
46 // DOSLIB: check for VGA
48 printf("VGA probe failed\n");
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");
57 // main variables values
58 d=4; // switch variable
59 key=2; // default screensaver number
69 update_state_from_vga();
70 vga_enable_256color_modex(); // VGA mode X
71 vga_state.vga_width = 320; // VGA lib currently does not update this
72 vga_state.vga_height = 240; // VGA lib currently does not update this
74 //#if 1 // 320x240 test mode: this is how Project 16 is using our code, enable for test case
76 struct vga_mode_params cm;
78 vga_read_crtc_mode(&cm);
81 cm.vertical_total = 525;
82 cm.vertical_start_retrace = 0x1EA;
83 cm.vertical_end_retrace = 0x1EC;
84 cm.vertical_display_end = 480;
85 cm.vertical_blank_start = 489;
86 cm.vertical_blank_end = 517;
88 vga_write_crtc_mode(&cm,0);
90 vga_state.vga_height = 240; // VGA lib currently does not update this
93 bakapee.xx = rand()&0%gvar.video.page[0].width;
94 bakapee.yy = rand()&0%gvar.video.page[0].height;
103 /* setup camera and screen~ */
104 gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
105 gvar.video.page[0].width += (TILEWH*2);
106 gvar.video.page[0].height += (TILEWH*2);
109 //modexPalUpdate(bmp.palette); //____
110 //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
113 modexShowPage(&gvar.video.page[0]);
120 { // conditions of screen saver
121 ding(&gvar.video.page[0], &bakapee, key);
131 fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
132 printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n", getch()); // prompt the user
134 if(scanf("%d", &key) != 1)
139 //if(key==3){xx=yy=0;} // crazy screen saver wwww
146 switch (bakapee.tile)
158 gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
159 gvar.video.page[0].width += (TILEWH*2);
160 gvar.video.page[0].height += (TILEWH*2);
165 printf("VGA probe failed\n");
169 update_state_from_vga();
170 vga_enable_256color_modex(); // VGA mode X
171 vga_state.vga_width = 320; // VGA lib currently does not update this
172 vga_state.vga_height = 240; // VGA lib currently does not update this
174 //#if 1 // 320x240 test mode: this is how Project 16 is using our code, enable for test case
176 struct vga_mode_params cm;
178 vga_read_crtc_mode(&cm);
181 cm.vertical_total = 525;
182 cm.vertical_start_retrace = 0x1EA;
183 cm.vertical_end_retrace = 0x1EC;
184 cm.vertical_display_end = 480;
185 cm.vertical_blank_start = 489;
186 cm.vertical_blank_end = 517;
188 vga_write_crtc_mode(&cm,0);
190 vga_state.vga_height = 240; // VGA lib currently does not update this
193 modexShowPage(&gvar.video.page[0]);
200 { // conditions of screen saver
203 ding(&gvar.video.page[0], &bakapee, key);
205 //end of screen savers
206 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
208 modexputPixel(&page, x, 0, 15);
209 mxPutPixel(x, gvar.video.page[0].height-1, 15);
211 for (int y = 0; y < VH; ++y)
213 mxPutPixel(0, y, 15);
214 mxPutPixel(gvar.video.page[0].width-1, y, 15);
216 for (int x = 0; x < VW; ++x)
218 mxPutPixel(x, 0, 15);
219 mxPutPixel(x, VH-1, 15);
221 for (int y = 240; y < VH; ++y)
223 mxPutPixel(0, y, 15);
224 mxPutPixel(VW-1, y, 15);
226 pdump(&gvar.video.page[0]);
229 /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background
230 mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box
232 mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
233 mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "| |Chikyuu:$line1");
234 mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "| |$line2");
235 mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "| |$line3");
236 mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "| |$line4");
237 mxOutText(xpos+1, ypos+gvar.video.page[0].height-8, "========================================");
238 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
240 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
244 //for(int i=0;i<TILEWH;i++){
245 ding(&gvar.video.page[0], &bakapee, key);
246 modexPanPage(&gvar.video.page[0], xpos, ypos);
247 //++++mxFillBox(384, 304, 384, 304, 10, OP_SET);
248 //mxBitBlt(xpos, ypos, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
249 //++++mxBitBlt(TILEWH*2, TILEWH*2, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
250 //for(word o = 0; o<TILEWH; o++){
253 //if(ypos==1 || (ypos==(BH-gvar.video.page[0].height-1)))delay(500);
254 //if((xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500);
256 //mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
257 //++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
258 //xpos=ypos=TILEWH*2;
259 //????modexPanPage(&gvar.video.page[0], 32, 32);
261 if( (xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1)){xdir=-xdir;}
262 if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
264 //mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
265 //mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
268 if(ch==0x71)break; // 'q'
269 if(ch==0x1b)break; // 'ESC'
271 // VGAmodeX(0, &gvar);
273 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");