X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbakapi.c;h=9a5412c752b1935703a8f8008d0be51e51e08e6f;hb=75f96fbcc84be6379ff155c1635070054c48c971;hp=9f471fdc1d712f427addf7ec391a9a4bcec21c3d;hpb=8b0c324266dabf0954f60a4c5bb60e2c12560fdb;p=16.git diff --git a/src/bakapi.c b/src/bakapi.c index 9f471fdc..9a5412c7 100755 --- a/src/bakapi.c +++ b/src/bakapi.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 * * This file is part of Project 16. * @@ -33,6 +33,27 @@ int ch=0x0; void main(int argc, char *argvar[]) { + // DOSLIB: check our environment + probe_dos(); + + // DOSLIB: what CPU are we using? + // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS. + // So this code by itself shouldn't care too much what CPU it's running on. Except that other + // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for + // the CPU to carry out tasks. --J.C. + cpu_probe(); + + // DOSLIB: check for VGA + if (!probe_vga()) { + printf("VGA probe failed\n"); + return; + } + // hardware must be VGA or higher! + if (!(vga_state.vga_flags & VGA_IS_VGA)) { + printf("This program requires VGA or higher graphics hardware\n"); + return; + } + // main variables values d=4; // switch variable key=2; // default screensaver number @@ -44,7 +65,30 @@ main(int argc, char *argvar[]) #ifdef MXLIB VGAmodeX(1, &gvar); #else - mxSetMode(3); + int10_setmode(19); + update_state_from_vga(); + vga_enable_256color_modex(); // VGA mode X + vga_state.vga_width = 320; // VGA lib currently does not update this + vga_state.vga_height = 240; // VGA lib currently does not update this + +//#if 1 // 320x240 test mode: this is how Project 16 is using our code, enable for test case + { + struct vga_mode_params cm; + + vga_read_crtc_mode(&cm); + + // 320x240 mode 60Hz + cm.vertical_total = 525; + cm.vertical_start_retrace = 0x1EA; + cm.vertical_end_retrace = 0x1EC; + cm.vertical_display_end = 480; + cm.vertical_blank_start = 489; + cm.vertical_blank_end = 517; + + vga_write_crtc_mode(&cm,0); + } + vga_state.vga_height = 240; // VGA lib currently does not update this +//#endif #endif bakapee.xx = rand()&0%gvar.video.page[0].width; bakapee.yy = rand()&0%gvar.video.page[0].height; @@ -54,6 +98,7 @@ main(int argc, char *argvar[]) bakapee.bakax=0; bakapee.bakay=0; bakapee.coor=0; + bakapee.tile=0; /* setup camera and screen~ */ gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); @@ -77,29 +122,76 @@ main(int argc, char *argvar[]) } else { - #ifndef MXLIB - mxChangeMode(0); +#ifndef MXLIB + int10_setmode(3); #else VGAmodeX(0, &gvar); #endif - //modexLeave(); // user imput switch - fprintf(stderr, "xx=%d yy=%d\n", bakapee.xx, bakapee.yy); + fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile); printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n", getch()); // prompt the user -// printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n"); // prompt the user -// clrstdin(); - scanf("%d", &key); + //scanf("%d", &key); + if(scanf("%d", &key) != 1) + { + printf("%d\n", key); + } + getch(); //if(key==3){xx=yy=0;} // crazy screen saver wwww - if(key==0){ d=0; }else{ - gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); - gvar.video.page[0].width += (TILEWH*2); - gvar.video.page[0].height += (TILEWH*2); + switch (key) + { + case 0: + d=0; + break; + case 65536: + switch (bakapee.tile) + { + case 0: + bakapee.tile=1; + break; + case 1: + bakapee.tile=0; + break; + } + d=2; + default: #ifdef MXLIB - VGAmodeX(1, &gvar); + gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]); + gvar.video.page[0].width += (TILEWH*2); + gvar.video.page[0].height += (TILEWH*2); + VGAmodeX(1, &gvar); #else - mxChangeMode(3); + probe_dos(); + if (!probe_vga()) { + printf("VGA probe failed\n"); + return 1; + } + int10_setmode(19); + update_state_from_vga(); + vga_enable_256color_modex(); // VGA mode X + vga_state.vga_width = 320; // VGA lib currently does not update this + vga_state.vga_height = 240; // VGA lib currently does not update this + +//#if 1 // 320x240 test mode: this is how Project 16 is using our code, enable for test case + { + struct vga_mode_params cm; + + vga_read_crtc_mode(&cm); + + // 320x240 mode 60Hz + cm.vertical_total = 525; + cm.vertical_start_retrace = 0x1EA; + cm.vertical_end_retrace = 0x1EC; + cm.vertical_display_end = 480; + cm.vertical_blank_start = 489; + cm.vertical_blank_end = 517; + + vga_write_crtc_mode(&cm,0); + } + vga_state.vga_height = 240; // VGA lib currently does not update this +//#endif #endif - modexShowPage(&gvar.video.page[0]); + modexShowPage(&gvar.video.page[0]); + break; } } }