示例#1
0
static void InitGame(void)
{
#ifndef SPEARDEMO
    boolean didjukebox=false;
#endif

    /* initialize SDL */
    if(LR_Init(0) < 0)
        exit(1);
    atexit(LR_Quit);

    SignonScreen ();

    VH_Startup ();
    IN_Startup ();
    PM_Startup ();
    SD_Startup ();
    CA_Startup ();
    US_Startup ();

    /* TODO: Will any memory checking be needed someday?? */

    /* build some tables */
    InitDigiMap ();

    ReadConfig ();

    SetupSaveGames();

    /* HOLDING DOWN 'M' KEY? */
#ifndef SPEARDEMO
    if (Keyboard[sc_M])
    {
        DoJukebox();
        didjukebox=true;
    }
    else
#endif
        /* draw intro screen stuff */
        IntroScreen ();

    /* load in and lock down some basic chunks */
    CA_CacheGrChunk(STARTFONT);
    CA_CacheGrChunk(STATUSBARPIC);

    LoadLatchMem ();
    BuildTables ();          /* trig tables */
    SetupWalls ();

    NewViewSize (viewsize);

    /* initialize variables */
    InitRedShifts ();
#ifndef SPEARDEMO
    if(!didjukebox)
#endif
        FinishSignon();
}
示例#2
0
文件: pacman.c 项目: esanwit/os3_es
int main(int argc, char *argv[100]) {

	int j = 0;
	srand( (unsigned)time( NULL ) );

	InitCurses();
	CheckScreenSize();
	CreateWindows(29, 28, 1, 1);

	//If they specified a level to load
	if((argc > 1) && (strlen(argv[1]) > 1)) {
		argv[1][99] = '\0';
		LoadLevel(argv[1]);
		MainLoop();
	}
        
	//If not, display intro screen then use default levels
	else {
		//Show intro "movie"
		IntroScreen();

		j = 1;
		//They want to start at a level 1-9
		if(argc > 1)
			for(LevelNumber = '1'; LevelNumber <= '9'; LevelNumber++)
				if(LevelNumber == argv[1][0]) j = LevelNumber - '0';

		//Load 9 levels, 1 by 1, if you can beat all 9 levels in a row, you're awesome
		for(LevelNumber = j; LevelNumber < 10; LevelNumber++) {
                        LevelFile[strlen(LevelFile) - 6] = '0';
			LevelFile[strlen(LevelFile) - 5] = LevelNumber + '0';
			LoadLevel(LevelFile);
			Invincible = 0;			//Reset invincibility
			MainLoop();
		}

	}

	ExitProgram("Good bye!");
}
示例#3
0
void CRacingFrame::CoreFrame()
{
	while(1){
	system("CLS");
	IntroScreen();
	cout<<"Input your choice:";
	int choice;
	cin>>choice;
	switch (choice)
	{

	case 1:
		{
		if(PlayerCar!=NULL) delete PlayerCar;
		PlayerCar=NULL;
		RunGame();
		system("CLS");
		char yes_no=' ';
		while(yes_no!='y'&&yes_no!='n'){
		fflush(stdin);
		cout<<"Do you want to save your record?(y/n):";
		cin>>yes_no;
		}
		
		if(yes_no=='y') {
			LoadRecord();
			string _Name;
			fflush(stdin);
			cout<<"Input your name:";
			getline(cin,_Name);
			CPlayer record_after_play(_Name,PlayerCar->getCarType(),Point);
			Player_Record.push_back(record_after_play);
			SortScore();
			SaveRecord();
		}
		if(yes_no=='n') {
			fflush(stdin);
			Sleep(500);
		}
		break;
		}
	case 2:
		{
			CMapRacing::SetColor(2);
		LoadRecord();
		ShowRecord();
		CMapRacing::SetColor(0);
		break;
		}
	case 3:
		{
			CMapRacing::SetColor(3);
		CustomCar();
		CMapRacing::SetColor(0);
		break;
		}
	case 4:
		break;
	default:
		{
		cout<<"Oopp! You got a wrong choice!";
		Sleep(500);
		break;
		}
	}
	if(choice==4) {
		system("CLS");
		cout<<"You was out of game";
		Sleep(500);
		break;
	}
	}

}
示例#4
0
int _WDOGBitTest(unsigned base,unsigned irqnum,int df)
{
  //non debug code is taken from pwdg-csm sample1
  int i;
  float Tmp;
  unsigned long int timeout = 4000000;
  int aborted;
  ADDRESS = base;//set global ADDRESS for ISR
  textcolor(LIGHTGRAY);
  IntroScreen();
  getch();
  puts("Press any key to stop test");
  inportb(base+4);   //clear any potentially pending interrupts
  //initirq(irqnum,setintflag);  //initialize the irq
  SetCounter();  //initialize counter
  inportb(base+4);   //clear any potentially pending interrupts
  outportb(base+7,0);  //enable counters
  if(df){ //loops until keypressed in debug mode
      delay(50);
      textcolor(LIGHTGRAY);
      cprintf("Bit Value           Status Register\n\r");
      for(i = 0;!kbhit(); i++){
         inportb(base+4);//clear pending interrupts so it won't lockup
         delay(100);
         CtrMode(base,1,2); //set counter 1 to mode 2
         CtrLoad(base,1,0x0050);  //load counter 1 with 20 hex
         printf("Updating counter 1, Loop number %3d\n",i);
         byte = inportb(base+4);
         printf("\nValue in status register: %x\n",byte);
          if ((byte & 1)==1)
             cprintf("1                   Watchdog OK       \n\r");
          else
             cprintf("0                   Watchdog timed out\n\r");
          if ((byte & 2)==2)
             cprintf("1                   Temperature OK         \n\r");
          else
             cprintf("0                   Temperature above 120 F\n\r");
          if ((byte & 4)==4)
             cprintf("1                   5VDC on input #1\n\r");
          else
             cprintf("0                   0VDC on input #1\n\r");
          if ((byte & 8)==8)
             cprintf("1                   5VDC on input #0\n\r");
          else
             cprintf("0                   0VDC on input #0\n\r");
          if ((byte & 16)==16)
             cprintf("1                   Fan good                     \n\r");
          else
             cprintf("0                   Fan speed out of range     \n\r");
          if ((byte & 32)==32)
             cprintf("1                   Voltage supplies OK       \n\r");
          else
             cprintf("0                   One of three supplies high\n\r");
          if ((byte & 64)==64)
             cprintf("1                   Voltage supplies OK       \n\r");
          else
             cprintf("0                   One of three supplies low\n\r");
          if ((byte & 128)==128)
             cprintf("1                   Interrupt   \n\r");
          else
             cprintf("0                   No interrupt\n\r");
         Tmp = (inportb(base+5) * (11.0 / 15.0)) + 7;//calculate temp
         printf("Temperature inside computer: %5.1f\n", Tmp);
         gotoxy(wherex(),wherey()-12);
      }
    getch();//get keypressed
  }
    if(!df){
      for(i = 0;i<=100; i++){
         delay(100);
         textcolor(LIGHTGRAY);
         CtrMode(base,1,2); //set counter 1 to mode 2
         CtrLoad(base,1,0x0020);  //load counter 1 with 50 hex
         printf("Updating counter 1, Loop number %3d\n",i);
         byte = inportb(base+4);
         printf("\nValue in status register: %x\n",byte);
          if ((byte & 1)==1)
             cprintf("1                   Watchdog OK       \n\r");
          else
             cprintf("0                   Watchdog timed out\n\r");
          if ((byte & 2)==2)
             cprintf("1                   Temperature OK         \n\r");
          else
             cprintf("0                   Temperature above 120 F\n\r");
          if ((byte & 4)==4)
             cprintf("1                   5VDC on input #1\n\r");
          else
             cprintf("0                   0VDC on input #1\n\r");
          if ((byte & 8)==8)
             cprintf("1                   5VDC on input #0\n\r");
          else
             cprintf("0                   0VDC on input #0\n\r");
          if ((byte & 16)==16)
             cprintf("1                   Fan good                     \n\r");
          else
             cprintf("0                   Fan speed out of range     \n\r");
          if ((byte & 32)==32)
             cprintf("1                   Voltage supplies OK       \n\r");
          else
             cprintf("0                   One of three supplies high\n\r");
          if ((byte & 64)==64)
             cprintf("1                   Voltage supplies OK       \n\r");
          else
             cprintf("0                   One of three supplies low\n\r");
          if ((byte & 128)==128)
             cprintf("1                   Interrupt   \n\r");
          else
             cprintf("0                   No interrupt\n\r");
         Tmp = (inportb(base+5) * (11.0 / 15.0)) + 7;//calculate temp
         printf("Temperature inside computer: %5.1f\n", Tmp);
         gotoxy(wherex(),wherey()-12);
      }
    }
  gotoxy(wherex(),wherey()+11);
  printf("\nWaiting for timeout\n");
  while((byte=(inportb(base+4) & 1)) == 1);
  if((byte & 1)==1)
    puts("Watchdog did not time out");
  else
    puts("Watchdog timed out");
  byte=inportb(base+4);//read register
  printf("\nValue in status register: %x\n",byte);//print inportb(base+4) from ISR
  delay(200);
  if (df) {puts("Press any key to turn off reset and exit");getch();}
  puts("Exiting test!                  ");
  inportb(base+7);  //disable counters
  delay(100);

  CtrMode(ADDRESS, 2, 0); // set counter 2 to mode 0
  outportb(base + 5,0); //turn off buzzer
  delay(100);
  outportb(base + 6,0);
  //restoreirq(irqnum);
  return 0;
}
示例#5
0
static void InitGame()
{
#ifndef SPEARDEMO
    boolean didjukebox=false;
#endif

    // initialize SDL
#if defined _WIN32
    putenv("SDL_VIDEODRIVER=directx");
#endif
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
    {
        printf("Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }
    atexit(SDL_Quit);

    int numJoysticks = SDL_NumJoysticks();
    if(param_joystickindex && (param_joystickindex < -1 || param_joystickindex >= numJoysticks))
    {
        if(!numJoysticks)
            printf("No joysticks are available to SDL!\n");
        else
            printf("The joystick index must be between -1 and %i!\n", numJoysticks - 1);
        exit(1);
    }

#if defined(GP2X_940)
    GP2X_MemoryInit();
#endif

    SignonScreen ();

#if defined _WIN32
    if(!fullscreen)
    {
        struct SDL_SysWMinfo wmInfo;
        SDL_VERSION(&wmInfo.version);

        if(SDL_GetWMInfo(&wmInfo) != -1)
        {
            HWND hwndSDL = wmInfo.window;
            DWORD style = GetWindowLong(hwndSDL, GWL_STYLE) & ~WS_SYSMENU;
            SetWindowLong(hwndSDL, GWL_STYLE, style);
            SetWindowPos(hwndSDL, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
        }
    }
#endif
	VW_UpdateScreen();

    VH_Startup ();
    IN_Startup ();
    PM_Startup ();
    SD_Startup ();
    CA_Startup ();
    US_Startup ();

    // TODO: Will any memory checking be needed someday??
#ifdef NOTYET
#ifndef SPEAR
    if (mminfo.mainmem < 235000L)
#else
    if (mminfo.mainmem < 257000L && !MS_CheckParm("debugmode"))
#endif
    {
        byte *screen;

        CA_CacheGrChunk (ERRORSCREEN);
        screen = grsegs[ERRORSCREEN];
        ShutdownId();
/*        memcpy((byte *)0xb8000,screen+7+7*160,17*160);
        gotoxy (1,23);*/
        exit(1);
    }
#endif


//
// build some tables
//
    InitDigiMap ();

    ReadConfig ();

    SetupSaveGames();

//
// HOLDING DOWN 'M' KEY?
//
	IN_ProcessEvents();

#ifndef SPEARDEMO
    if (Keyboard[sc_M])
    {
        DoJukebox();
        didjukebox=true;
    }
    else
#endif

//
// draw intro screen stuff
//
    IntroScreen ();

#ifdef _arch_dreamcast
    //TODO: VMU Selection Screen
#endif

//
// load in and lock down some basic chunks
//

    CA_CacheGrChunk(STARTFONT);
    CA_CacheGrChunk(STATUSBARPIC);

    LoadLatchMem ();
    BuildTables ();          // trig tables
    SetupWalls ();

    NewViewSize (viewsize);

//
// initialize variables
//
    InitRedShifts ();
#ifndef SPEARDEMO
    if(!didjukebox)
#endif
        FinishSignon();

#ifdef NOTYET
    vdisp = (byte *) (0xa0000+PAGE1START);
    vbuf = (byte *) (0xa0000+PAGE2START);
#endif
}