]> 4ch.mooo.com Git - 16.git/blobdiff - src/bakapi.c
remove copypasta from vga library. The modex16 routines are a better fit
[16.git] / src / bakapi.c
index eccaa3550e504272bceff3ed9a11b4647e2f0ec5..5549ee4694f76163662a8d6d770180ba7d04a6de 100755 (executable)
@@ -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
@@ -42,9 +63,10 @@ main(int argc, char *argvar[])
        ydir=1;
 
 #ifdef MXLIB
-       VGAmodeX(1, &gvar);
+       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.
 #else
-       mxSetMode(3);
+# 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.
+               // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
 #endif
        bakapee.xx = rand()&0%gvar.video.page[0].width;
        bakapee.yy = rand()&0%gvar.video.page[0].height;
@@ -78,13 +100,14 @@ main(int argc, char *argvar[])
                }
                else
                {
-                       #ifndef MXLIB
-                       mxChangeMode(0);
-#else
+# ifndef MXLIB
+#  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.
+               // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
+# else
                        VGAmodeX(0, &gvar);
-#endif
+# endif
                        // 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
                        //scanf("%d", &key);
                        if(scanf("%d", &key) != 1)
@@ -93,20 +116,39 @@ main(int argc, char *argvar[])
                        }
                        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);
-#ifdef MXLIB
-                               VGAmodeX(1, &gvar);
-#else
-                               mxChangeMode(3);
-#endif
-                               modexShowPage(&gvar.video.page[0]);
+                       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
+                                       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
+#  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.
+               // we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
+# endif
+                                       modexShowPage(&gvar.video.page[0]);
+                               break;
                        }
                }
        }
-#else
+#else // !defined(BOINK)
+// FIXME: Does not compile. Do you want to remove this?
        while(1)
        { // conditions of screen saver
                while(!kbhit())
@@ -180,7 +222,7 @@ main(int argc, char *argvar[])
        if(ch==0x1b)break; // 'ESC'
        }
 //     VGAmodeX(0, &gvar);
-#endif
+#endif // defined(BOINK)
        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");
 }
 //pee!