view msdos/menu.c @ 64:c272f66c5eb8

Add pwplib_end() to public header.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 06 Aug 2011 10:41:08 +0300
parents acb5694e93d9
children
line wrap: on
line source

#include <dos.h>

#include "pwplib.h"

#define DEMOBANNER "PWPLIB!"

extern int detectvideo();

extern char auditype;

extern char setup_rtc;
extern char setup_force25;
extern char setup_nohibit;
extern char setup_english;

/*extern void setmono();*/

char *setmenu[6][4]=
      {"ega/vga",  "cga",     "mda/hgc", "",
       "80x50",    "80x25",   "","",
       "on",       "off",     "","",
       "on",       "off",     "","",
       "none",     "ibm pc",  "adlib/sb", "g.u.z.",
       "scene",    "english", "",""
};

char numsels[6]={3,2,2,2,4,2};
char menusel[6]={0,0,0,0,1,0};

vuwmenu(int x,int y,int c,int joo)
{
      textcolor(c);
      gotoxy(25+12*x,10+y*2);cprintf(setmenu[y][x]);
      if ((menusel[y]==x)&&joo) {textcolor(15);cprintf("!!");}else cprintf("  ");
}

void zetmenu(char y,char x)
{
	vuwmenu(menusel[y],y,12,0);
	menusel[y]=x;
	vuwmenu(x,y,12,1);
}

int pwplib_init(int argc,char**argv)
{
      signed int x,y,ch=0,cntdwn=40;

      char det=detectvideo();

      textbackground(0);textcolor(15);
      clrscr();

      switch(det){
            case(0):menusel[0]= menusel[1]= menusel[2]= menusel[3]=1;
                    break;
	    case(1):menusel[1]=2; menusel[2]=1; break;}

      if (getenv("ULTRASND")) menusel[4]=3;

      if (getenv("BLASTER")) menusel[4]=2;


gotoxy(1,2);
cprintf("       лллллллллллллллл   лллл    лллл    лллл    лллллллллллллллл\n\r"
	"       лллл        лллл   лллл    лллл    лллл    лллл        лллл\n\r"
	"       лллллллллллллллл   лллл    лллл    лллл    лллллллллллллллл\n\r"
	"       лллл               лллллллллллллллллллл    лллл\n\r");

      gotoxy(5,8);
      cprintf( DEMOBANNER "\n");

      textcolor(15);
      gotoxy(1,10); cprintf("video output");
      gotoxy(1,12);cprintf("resolution");
      gotoxy(1,14);cprintf("bg highbit (ega+)");
      gotoxy(1,16);cprintf("vertical retrace check");
      gotoxy(1,18);cprintf("audio output");
      gotoxy(1,20);cprintf("language");

      for(y=0;y<6;y++)for(x=0;x<4;x++) vuwmenu(x,y,12,1);
      y=5;

      gotoxy(7,23);
      textcolor(15);
      while(cntdwn&&(!kbhit())){
	int tups=peek(0,1132);
	while(tups==peek(0,1132)){}
	gotoxy(25,23);textcolor(15);
	cprintf("you now have %i/18.22 seconds for setup  ",cntdwn--);gotoxy(35,23);
      }
      if(!cntdwn)ch=13;

      while((ch!=13)&&(ch!=27)){
            x=menusel[y];
	      vuwmenu(x,y,14+128,1);
		ch=getch();if(!ch)ch=getch();
	      vuwmenu(x,y,12,0);
            switch(ch){
		  case('4'):case('K'):x--;if(x<0) x=0; menusel[y]=x; break;
		  case('6'):case('M'):x++;if(x>3) x=3;
			if(x>=numsels[y]){vuwmenu(x,y,12,1);x--;}
                        menusel[y]=x;
			if(y==0){
				if(x==2){zetmenu(1,1);zetmenu(2,1);zetmenu(3,1);}
				if(x==1){zetmenu(1,1);zetmenu(2,1);}
			}
		  break;
		  case('8'):case('H'):vuwmenu(x,y,12,1);y--;if(y<0) y=0;x=menusel[y];break;
		  case('2'):case('P'):vuwmenu(x,y,12,1);y++;if(y>5) y=5;x=menusel[y];break;}


      }
      auditype=menusel[4];
      setup_mono=menusel[0];
      setup_rtc=!menusel[3];
      setup_force25=menusel[1];
      setup_nohibit=menusel[2];
      setup_english=menusel[5];

      if (auditype==3){
	    clrscr();textcolor(15);auditype=2;
	    cprintf("ARE YOU SURE YOU HAVE SBOS INSTALLED? [Y/n]");
	    ch=getch();if((ch|32)=='n'){ch=27;
		cprintf("\r\n\nKANNATTAISI OPPIA HYVŽKSYMŽŽN ELŽMŽN REALITEETIT\r\n\n");}else ch=13;
      }
      return ch;
}