/*EdQuake v0.50 source code
  (c) Copyright 1996 Scott Mitting
  email:smitting@netusa1.net
  ----------------------------------
  INIT.C  -  Runs init routines for SVGACC. If you cant pass these
	     then you can't run quake anyways, so why make a level
	     for it?

  __variables:
  int startvideomode       -- video mode upon entry
  __functions:
  void initcpu()	   -- runs all system diagnostic routines:
			      386/mouse/512k video
  ----------------------------------
  the entire source code is under renovation to make it easier
  to understand.  happy coding.
*/

#include "svgacc.h"

int startvideomode;

void initcpu()
{
    int cpu, videomemory, mouse, mjv, mnv, tp, i;
    char buf[80];

    startvideomode = videomodeget();
    restext();
    clrscr();
    gotoxy(1,1);
    printf("Init EdQuake v0.5\n");
    cpu = whichcpu();
    if (cpu < 386) {
	printf("386 or better processor required.\n");
	printf("Processor is identified as an 80%d.\n", cpu);
	printf("press a key...\n");
	getch();
	videomodeset(startvideomode);
	exit(0);
    }
	switch(whichvga()) {
	case ACUMOS:
	    printf("Acumos AVGA2/3 SuperVGA\n");
	    break;
	case ATI:
	    printf("ATI Technologies 18/28/38/68800 SuperVGA\n");
	    break;
	case AHEADA:
	    printf("Ahead V5000 Ver A SuperVGA\n");
	    break;
	case AHEADB:
	    printf("Ahead V5000 Ver B SuperVGA\n");
	    break;
	case CHIPSTECH:
	    printf("Chips and Technologies 82C450/1/2/3/5/6/7 SuperVGA\n");
	    break;
	case CIRRUS:
	    printf("Cirrus Logic CL-GD 5xx,6xx,28xx,54xx,62xx SuperVGA\n");
	    break;
	case EVEREX:
	    printf("Everex EV236/6xx Micro Enhancer SuperVGA\n");
	    break;
	case GENOA:
	    printf("Genoa 61/62/63/64/6600 SuperVGA\n");
	    break;
	case NCR:
	    printf("NCR 77C21/22/22E/22E+ SuperVGA\n");
	    break;
	case OAKTECH:
	    printf("Oak Technologies OTI-037/67/77/87C SuperVGA\n");
	    break;
	case PARADISE:
	    printf("Paradise/Western Digital PVGA1A,WD90C00/1x/2x/3x SuperVGA\n");
	    break;
	case REALTEK:
	    printf("Realtek RT3106 SuperVGA\n");
	    break;
	case TRIDENT:
	    printf("Trident 8800CS,8900B/C/CL/CX,90x0 SuperVGA\n");
	    break;
	case TSENG3:
	    printf("Tseng Labs ET3000-AX/BX/BP SuperVGA\n");
	    break;
	case TSENG4:
	    printf("Tseng Labs ET4000/W32/W32I SuperVGA\n");
	    break;
	case VESA:
	    printf("VESA compatible SuperVGA\n");
	    break;
	case VIDEO7:
	    printf("Video 7 HT-208/16 SuperVGA\n");
	    break;
	case AVANCE:
	    printf("Avance Logic AL2101 SuperVGA\n");
	    break;
	case MXIC:
	    printf("MXIC MX68000/10 SuperVGA\n");
	    break;
	case PRIMUS:
	    printf("Primus P2000 SuperVGA\n");
	    break;
	default:
	    printf("Sorry, unable to identify video card or it is not a SuperVGA video adapter.\n");
	    printf("press a key...\n");
	    getch();
	    videomodeset(startvideomode);
	    exit(0);
    }
    videomemory = whichmem();
    printf("videoram=%i\n",videomemory);
    if (videomemory < 511) {
	printf("Sorry, 512k of video ram required.\n");
	printf("press a key...\n");
	getch();
	videomodeset(startvideomode);
	exit(0);
    } else
    mouse = whichmouse();
    if (mouse > 0) {
        mouseinfo(&mjv, &mnv, &tp, &i);
        switch (tp) {
	    case 1:
		sprintf(buf,"bus mouse\n");
		break;
	    case 2:
		sprintf(buf,"serial mouse\n");
		break;
	    case 3:
		sprintf(buf,"Inport mouse\n");
		break;
	    case 4:
		sprintf(buf,"PS/2 mouuse\n");
		break;
	    case 5:
		sprintf(buf,"HP mouse\n");
		break;
	    default:
		sprintf(buf,"unknown type\n");
	}
    } else
    {
	printf("Microsoft compatible mouse required.\n");
	printf("press a key...\n");
	getch();
	videomodeset(startvideomode);
	exit(0);
    }
    printf("%i detected.\n",cpu);

    printf("Init EdQuake v0.5\n");
}
