Esempio n. 1
0
void GUI(void){	
  SetDefaultLineType(0);
  DefineGraphNxN_R("phi", &phi[0][0], &xdim, &ydim, NULL);
  DefineGraphNxN_R("psi", &psi[0][0], &xdim, &ydim, NULL);
  DefineGraphNxN_R("rho", &rho[0][0], &xdim, &ydim, NULL); 
  NewGraph();

  StartMenu("Ising Bilayer",1);

  SetActiveGraph(0);
  DefineGraph(contour2d_,"Visualize");

  //StartMenu("Controls",0);
  DefineInt("iterations", &iterations);
  DefineInt("repeat", &repeat);
  //DefineInt("stabilize", &stabilize);
  DefineDouble("phi_init", &r_zero[0]);
  DefineDouble("psi_init", &r_zero[1]);
  DefineDouble("Temperature", &T);
  DefineDouble("Lambda", &lambda);
  //EndMenu();

  StartMenu("Secondary Inputs",0);
  DefineInt("xdim", &xdim);
  DefineInt("ydim", &ydim);
  EndMenu();

  DefineFunction("reinitialize",&Init);

  DefineBool("Pause",&Pause);
  DefineBool("Single Step",&singlestep);
  DefineBool("Done",&done);	
  EndMenu();
}
Esempio n. 2
0
/*
===============
idCommonLocal::AdvanceRenderDemo
===============
*/
void idCommonLocal::AdvanceRenderDemo( bool singleFrameOnly ) {
	int	ds = DS_FINISHED;
	readDemo->ReadInt( ds );

	switch ( ds ) {
	case DS_FINISHED:
		if ( numDemoFrames != 1 ) {
			// if the demo has a single frame (a demoShot), continuously replay
			// the renderView that has already been read
			Stop();
			StartMenu();
		}
		return;
	case DS_RENDER:
		if ( renderWorld->ProcessDemoCommand( readDemo, &currentDemoRenderView, &demoTimeOffset ) ) {
			// a view is ready to render
			numDemoFrames++;
		}
		break;
	case DS_SOUND:
		soundWorld->ProcessDemoCommand( readDemo );
		break;
	default:
		common->Error( "Bad render demo token" );
	}
}
Esempio n. 3
0
int StartMenu(void)
{
	int state = 1;
	//int x = 0;

	scr_printf("	CN-Cheat Shell Menu.\n	Press (X) to boot, Press SELECT for credits,	SQUARE to load cheats, Press UP to go into server mode\n");
	while (1)
	{

	
   if (padRead(0, 0, &buttons));
		{

		checkPadConnected();
		//read pad 1
		buttonStatts(0, 0);

			if (new_pad & PAD_SELECT)
			{
				state = 2;
				scr_clear();
				scr_printf("\n\n	CREDITS:\n");
				scr_printf("\n		Gtlcpimp: Basic Hook Concept (From His Sources), Code Designer (Tool Used For MIPS)");
				scr_printf("\n		Pyriel: Help On All The Troubleshooting With The Hook");
				scr_printf("\n		Badger41: Teaching Me MIPS Assembly");
				scr_printf("\n		cYs Driver: Source code For Cora Dumper (Initializing The Pad)\n");
				scr_printf("\n	END OF CREDITS\n 	Press (X) To Return To Menu\n");
			}

			if (state == 2)
			{
					if (new_pad & PAD_CROSS)
					{
						scr_clear();
						state = 1;
						StartMenu();
					}					

			}

			if (new_pad & PAD_SQUARE)
			{

			WriteCheats();

			}
			if (new_pad & PAD_CROSS)
			{
			
			ExecGame();
			
			}
			
		}
	}

   return 0;

}
Esempio n. 4
0
void GUI(){
  DefineGraphN_R("Density",density,&size,&densityreq);
  StartMenu("GUI",1);
    DefineDouble("T",&T);
    DefineDouble("omega",&omega);
    StartMenu("Restart",0);
      DefineMod("size",&size,SIZE+1);
      DefineDouble("Amplitude",&Amplitude);
      DefineFunction("Restart sin",&init);
      DefineFunction("Restart step",&init2);
    EndMenu();
    DefineGraph(curve2d_,"Density graph");
    DefineBool("Pause",&pause);
    DefineBool("Single step",&sstep);
    DefineInt("Repeat",&Repeat);    DefineBool("Done",&done);
  EndMenu();
}
Esempio n. 5
0
int main()
{
    head = InitMenu();
    AddMenuData(&head, "help", "menu list", Help);
    AddMenuData(&head, "version", "menu program v2.0", NULL);
    AddMenuData(&head, "quit", "quit menu", Quit);
    StartMenu(head);
}
Esempio n. 6
0
//. #include "ai_space.h"
//. #include "script_engine.h"
void CDialogHolder::StartStopMenu(CUIDialogWnd* pDialog, bool bDoHideIndicators)
{
//.	ai().script_engine().script_log	(eLuaMessageTypeError,"foo");
	if( pDialog->IsShown() )
		StopMenu(pDialog);
	else
		StartMenu(pDialog, bDoHideIndicators);
	
}
Esempio n. 7
0
void main(void) {
    InitPLL();

    InitServo();
    StartServo();
    SetServo(90);

    StartMenu();

    FOREVER();
}
Esempio n. 8
0
void UI::StartUI() {
	DisplayTitleScreen();
	int result = StartMenu();
	//Means quit game
	if (result == 1) {
		return;
	}
	CAI = SelectDifficulty();
	//CurrentGame = Game();
	PlacePieces(CurrentGame.GetP1Board());
	GameResult gr = PlayGame();
	return;
}
Esempio n. 9
0
void GUI(){
  DefineGraphNxN_R("rho",&rho[0][0],&Xdim,&Ydim,&rhoreq);
#ifdef DEBUG
  DefineGraphNxN_R("bb",&bb[0][0],&Xdim,&Ydim,&noreq);
  DefineGraphNxN_R("b1",&b1[0][0],&Xdim,&Ydim,&noreq);
  DefineGraphNxN_R("b3",&b3[0][0],&Xdim,&Ydim,&noreq);
  DefineGraphNxN_R("b5",&b5[0][0],&Xdim,&Ydim,&noreq);
  DefineGraphNxN_R("b6",&b6[0][0],&Xdim,&Ydim,&noreq);
#endif
  DefineGraphNxN_RxR("u",&u[0][0][0],&Xdim,&Ydim,&ureq);

  StartMenu("Lattice Boltzmann",1);
  DefineDouble("1/tau",&omega);
  DefineInt("Measurement freq.",&FrequencyMeasure);
  StartMenu("Reinitialize",0);
  DefineDouble("Amplitude",&Amp2);
  DefineDouble("Width",&Width);
  DefineFunction("reinitialize",&init);
  DefineFunction("Particle init",&initParticle);
  EndMenu();
  DefineDouble("Velocity amplitude",&Amp);
  StartMenu("Particle",0);
  DefineDouble("R",&R);
  DefineDouble("M",&M);
  DefineDouble("Ux",&Ux);
  DefineDouble("Uy",&Uy);
  DefineDouble("Cx",&Cx);
  DefineDouble("Cy",&Cy);
  DefineDouble("Mx",&Mx);
  DefineDouble("My",&My);
  EndMenu();
  DefineGraph(contour2d_,"Density&Vector plots");
  DefineInt("Repeat",&Repeat);
  DefineBool("Pause",&Pause);
  DefineBool("Single Step",&sstep);
  DefineBool("Done",&done);
  EndMenu();
}
Esempio n. 10
0
int main(void)
{
	SifInitRpc(0);
	init_scr();
	
	//LoadIRX();
	initalise();
	if (remove("mc0:/cheat.bin") < 0)
	{
		scr_printf("	Could not delete mc0:/cheat.bin");
	}
	scr_printf("	CN-CHEAT!\n");
	StartMenu();

	return 0;
}
Esempio n. 11
0
void WinMenuMenu(UltimateContext *TheWin,int x, int y)
{
  int a;
  Menu *men,*wsmen;
  MenuItem *item;
  short useTitle = (TheScreen.desktop.flags & UDESubMenuTitles);

  if(!(men = TheWin->title.name ? MenuCreate(TheWin->title.name)
                                : MenuCreate(NULL))) {
    SeeYa(1,"FATAL: out of memory!");
  }

  if(TheScreen.desktop.WorkSpaces > 1)
    {
      AppendMenuItem(men, _("Sticky window"), &sticky,\
                     (TheWin->WorkSpace==-1) ? I_SWITCH_ON: I_SWITCH_OFF);

      wsmen = MenuCreate((TheWin->title.name && useTitle)
                           ? TheWin->title.name : NULL);
      if(!wsmen)
        SeeYa(1,"FATAL: out of memory!");
      for (a=0; a<TheScreen.desktop.WorkSpaces; a++)
         if (a != TheScreen.desktop.ActiveWorkSpace)
           AppendMenuItem (wsmen, TheScreen.WorkSpace[a], &wsprocs[a],
                           I_SELECT);
      AppendMenuItem (men, _("Move to WorkSpace"), wsmen, I_SUBMENU);
    }

/*  AppendMenuItem(men,TheScreen.Texts.WinMenuMenu.AlwaysOnTop,NULL,I_SELECT);*/

  if((item=StartMenu(men,x,y,True,NULL))){
    if((item->type==I_SELECT)||(SWITCHTYPE(item->type))){
      Procs *pr;
      if((pr=item->data)){
        HandlerTable p;
        p=pr->Proc;
        p(TheWin,pr->arg);
      }
    }
  }
  DestroyMenu(men);
}
/*
==============
idSessionLocal::DispatchCommand
==============
*/
void idSessionLocal::DispatchCommand(idUserInterface *gui, const char *menuCommand, bool doIngame)
{

	if (!gui) {
		gui = guiActive;
	}

	if (gui == guiMainMenu) {
		HandleMainMenuCommands(menuCommand);
		return;
	} else if (gui == guiIntro) {
		HandleIntroMenuCommands(menuCommand);
	} else if (gui == guiMsg) {
		HandleMsgCommands(menuCommand);
	} else if (gui == guiTakeNotes) {
		HandleNoteCommands(menuCommand);
	} else if (gui == guiRestartMenu) {
		HandleRestartMenuCommands(menuCommand);
	} else if (game && guiActive && guiActive->State().GetBool("gameDraw")) {
		const char *cmd = game->HandleGuiCommands(menuCommand);

		if (!cmd) {
			guiActive = NULL;
		} else if (idStr::Icmp(cmd, "main") == 0) {
			StartMenu();
		} else if (strstr(cmd, "sound ") == cmd) {
			// pipe the GUI sound commands not handled by the game to the main menu code
			HandleMainMenuCommands(cmd);
		}
	} else if (guiHandle) {
		if ((*guiHandle)(menuCommand)) {
			return;
		}
	} else if (!doIngame) {
		common->DPrintf("idSessionLocal::DispatchCommand: no dispatch found for command '%s'\n", menuCommand);
	}

	if (doIngame) {
		HandleInGameCommands(menuCommand);
	}
}
Esempio n. 13
0
void WinMenuMenu(UltimateContext *TheWin,int x, int y)
{
  int a;
  Menu *men,*wsmen;
  MenuItem *item;
  short useTitle = (settings.global_settings->LayoutFlags & SUBMENU_TITLES);

  if(!(men = TheWin->title.name ? MenuCreate(TheWin->title.name) : MenuCreate("")))
    SeeYa(1,"FATAL: out of memory!");

  if(NUMBER_OF_WORKSPACES > 1)
    {
      AppendMenuItem(men, _("Sticky window"), &sticky,\
		     (TheWin->WorkSpace == -1) ? I_SWITCH_ON : I_SWITCH_OFF);

      wsmen = MenuCreate((TheWin->title.name && useTitle)
                         ? TheWin->title.name : NULL);
      if(!wsmen)
	SeeYa(1,"FATAL: out of memory!");
      for (a=0; a < NUMBER_OF_WORKSPACES; a++)
	   AppendMenuItem (wsmen, settings.workspace_settings[a]->Name,
			   &wsprocs[a], I_SELECT);
      AppendMenuItem (men, _("Move to WorkSpace"), wsmen, I_SUBMENU);
    }

/*  AppendMenuItem(men,TheScreen.Texts.WinMenuMenu.AlwaysOnTop,NULL,I_SELECT);*/

  if(item=StartMenu(men,x,y,True,NULL)){
    if((item->type==I_SELECT)||(SWITCHTYPE(item->type))){
      Procs *pr;
      if(pr=item->data){
        HandlerTable p;
        p=pr->Proc;
        p(TheWin,pr->arg);
      }
    }
  }
  DestroyMenu(men);
}
Esempio n. 14
0
/*
================
idCommonLocal::StartPlayingRenderDemo
================
*/
void idCommonLocal::StartPlayingRenderDemo( idStr demoName ) {
	if ( !demoName[0] ) {
		common->Printf( "idCommonLocal::StartPlayingRenderDemo: no name specified\n" );
		return;
	}

	// make sure localSound / GUI intro music shuts up
	soundWorld->StopAllSounds();
	soundWorld->PlayShaderDirectly( "", 0 );	
	menuSoundWorld->StopAllSounds();
	menuSoundWorld->PlayShaderDirectly( "", 0 );

	// exit any current game
	Stop();

	// automatically put the console away
	console->Close();

	readDemo = new (TAG_SYSTEM) idDemoFile;
	demoName.DefaultFileExtension( ".demo" );
	if ( !readDemo->OpenForReading( demoName ) ) {
		common->Printf( "couldn't open %s\n", demoName.c_str() );
		delete readDemo;
		readDemo = NULL;
		Stop();
		StartMenu();
		return;
	}

	const bool captureToImage = false;
	UpdateScreen( captureToImage );

	AdvanceRenderDemo( true );

	numDemoFrames = 1;

	timeDemoStartTime = Sys_Milliseconds();
}
Esempio n. 15
0
// main function
int main()
{
	CountRanking();
	while(1){
		selection=StartMenu(selection);
		switch(selection){
		case '1': // 게임 시작
			GamePlay();
			return 0;
		case '2': // Ranking 확인
			ViewRanking();
			break;
		case '3': // 도움말
			HelpScreen();
			break;
		case '4': // 게임 종료
			ExitGame();
			system("PAUSE");
			return 0;
			break;
		} // switch
	} // while
	return 0;
}
Esempio n. 16
0
/**
 *  Spiel starten
 */
bool GameManager::Start()
{
    // Einstellungen laden
    if(!SETTINGS.Load())
        return false;

    /// Videotreiber laden
    if(!VIDEODRIVER.LoadDriver())
    {
        LOG.lprintf("Video driver couldn't be loaded!\n");
        return false;
    }

    // Im Vollbildmodus überprüfen, ob Video-Mode überhaupt existiert
    if(SETTINGS.video.fullscreen) //-V807
    {
        std::vector<VideoMode> available_video_modes;
        VIDEODRIVER.ListVideoModes(available_video_modes);

        bool found = false;
        for(size_t i = 0; i < available_video_modes.size(); ++i)
        {
            if(available_video_modes[i].width == SETTINGS.video.fullscreen_width &&
                    available_video_modes[i].height == SETTINGS.video.fullscreen_height)
                found = true;
        }

        if(!found && !available_video_modes.empty())
        {
            // Nicht gefunden, erste gültige Auflösung nehmen
            SETTINGS.video.fullscreen_width = available_video_modes[0].width;
            SETTINGS.video.fullscreen_height = available_video_modes[0].height;
        }
    }

    // Fenster erstellen
    if(!VIDEODRIVER.CreateScreen(SETTINGS.video.fullscreen ? SETTINGS.video.fullscreen_width : SETTINGS.video.windowed_width,
            SETTINGS.video.fullscreen ? SETTINGS.video.fullscreen_height : SETTINGS.video.windowed_height,
            SETTINGS.video.fullscreen))
        return false;

    /// Audiodriver laden
    if(!AUDIODRIVER.LoadDriver())
    {
        LOG.lprintf("Audio driver couldn't be loaded!\n");
        //return false;
    }

    /// Lautstärken gleich mit setzen
    AUDIODRIVER.SetMasterEffectVolume(SETTINGS.sound.effekte_volume); //-V807
    AUDIODRIVER.SetMasterMusicVolume(SETTINGS.sound.musik_volume);

    // Treibereinstellungen abspeichern
    SETTINGS.Save();

    LOG.lprintf("\nStarte das Spiel\n");
    if(!StartMenu())
        return false;

    std::string playlist = iwMusicPlayer::GetFullPlaylistPath(SETTINGS.sound.playlist);
    if(MUSICPLAYER.Load(playlist))
        MUSICPLAYER.Play();

    return true;
}
Esempio n. 17
0
void render(void)
{
    Rect r;
    //Clear the screen
    glClearColor(1.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);

    //
    //
    //draw a quad with texture
    glColor3f(1.0, 1.0, 1.0);

    //Loop the background
    double *yOFFsetLevel = &setLevel;
    double *yOFFsetMountain = &setMountain;

    if(*yOFFsetLevel <= -(levelImage->width))
        *yOFFsetLevel = 0.0;
    if(*yOFFsetMountain <= -(mountainsImage->width))
        *yOFFsetMountain = 0.0;
    /////////////////////////////////////////////

    if (background) {
        draw_background();
    }
    if (start) {
        StartMenu();
    }

    perspective();

    if(show_ufo)
    {
        draw_ufo();
        draw_yellow();
    }
    if(white)
    {
        draw_white();
    }
    if (lives <= 0) {
        GameOver();
        gameover = 1;
        if(soundcount == 0)
            fmod_playsound(1);
        soundcount++;
    }

    glDisable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glDisable(GL_BLEND);
    glEnable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D, 0);

    r.bot = yres - 20;
    r.left = 10;
    r.center = 0;
    unsigned int cref = 0x00ffffff;

    if(start)
    {
        r.bot = yres - 175;
        r.left = (xres/2) - 80;
        r.center = 0;
        unsigned int cref = 0x00000000;

        //Help menu only show in start
        ggprint10(&r, 16, cref, "Move Up: UP Arrow Key");
        ggprint10(&r, 16, cref, "Move Down: Down Arrow Key");
        ggprint10(&r, 16, cref, "Move Left: Left Arrow Key");
        ggprint10(&r, 16, cref, "Move Right: Right Arrow Key");
        ggprint10(&r, 16, cref, "Punch: Space Key");
    }
    if(show_animal && show_rhino)
    {
        //In game menu, only show in game
        ggprint16(&r, 16, cref, "Lives: %i", lives);
        ggprint16(&r, 16, cref, "High Score: %i", high_score);
        if(ufocount) {
            ggprint16(&r, 16, cref, "UFO Help (Press Enter): %i", ufocount);
        }
    }
}
Esempio n. 18
0
main()
{    
      
time_t seconds;          //Declare variable to hold seconds on clock.

time(&seconds);          //Get value from system clock andplace in seconds variable.

srand((unsigned int) seconds);               //Convert seconds to a unsignedinteger.
 
  initwindow(1350, 700, "MAZE TRIAL");    
 floodfill(0,0,WHITE);
 
  int r=c=0; // Stores the values of rows and coloumns;
  int R,C; //No. of boxes
  
 /*setbkcolor(BLACK);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
outtextxy(500,5,"enter the ROWS ");
  
  char num[3];
 int i,k=1;
 
 while((i=getch())!=13)
    {
     r+=(i-48)*pow(10,k);
     k--;
    }
    cout<<r;
    
  num[0]=((r-(r%10))/10)+48;
  num[1]=(r%10)+48;
  num[2]='\0';
  
  outtextxy(500,5,"NUMBER OF ROWS ARE : ");
  outtextxy(500,20,num);
   
   getch();
   
   floodfill(0,0,BLUE);

 setbkcolor(BLACK);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
outtextxy(500,5,"enter the COLUMNS ");


 k=1;
 
 while((i=getch())!=13)
    {
     c+=(i-48)*pow(10,k);
     k--;
    }

  num[0]=((c-(c%10))/10)+48;
  num[1]=(c%10)+48;
  num[2]='\0';
  
  outtextxy(500,5,"NUMBER OF COLUMNS ARE : ");
  outtextxy(500,20,num);

getch();

 setbkcolor(WHITE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);


floodfill(0,0,BLUE);*/


  /*cout<<" Columns: ";
  cin>> c;*/
  R=r=10;
  C=c=10;
  
   
   
  while(1)
  {
     for(int i=0;i<r;i++)
     for(int j=0; j<c; j++)
        a[i][j]=0;
      
  stack adrs[1000];   //////////////////////////////////////////////////////////////////
             
      
  adrs[top].x=0;
  adrs[top].y=0;              // initially the address is 0,0   
   
  
  
  
     
     StartMenu();
     int ch;
     ch=getch();
     ch-=48;
     
     setfillstyle(SOLID_FILL,WHITE);
     floodfill(0,0,MAGENTA);
   
   setfillstyle(SOLID_FILL,WHITE);
  floodfill(0,0,BLACK);
  
  settextstyle(3,0,6);
  setbkcolor(WHITE);
  setcolor(BLACK);
  outtextxy(100,100,"Choose Level");
  setbkcolor(RED);
  setcolor(WHITE);
  outtextxy(500,100," 1 EASY ");
  setbkcolor(GREEN);
  setcolor(WHITE);
  outtextxy(750,100," 2 MEDIUM");
  setbkcolor(BLUE);
  setcolor(WHITE);
  outtextxy(1050,100," 3 HARD");
   
   int Level=getch();
   setfillstyle(SOLID_FILL,WHITE);
   floodfill(0,0,MAGENTA);
     
   switch(Level)
   {
    case 49: R=r=10;
             C=c=10;
             break;
             
    case 50: R=r=13;
             C=c=24;
             break;
             
    case 51: R=r=18;
             C=c=35;
             break;
   }
   
  r=(2*r)-1;
  c=(2*c)-1;
   
   basic_design(r,c,ch);
   //out_boundary(r,c);
   int H=1, L=3;
  
   out_boundary(r,c,ch);
      
 getch();
 
     a[0][0]=1;      //int k=0;
     
   while(1)
    { int ender=0;
     
     D=direc(); 
     //cout<<"Receiving "<<D<<"\n\n";
     //getch();
        
     //cout<<"Direction ? ";
     //cin>>D;
     
     switch(D)
     {  
        int nx,ny,ox,oy;
           
        case 1:
                                  
             cout<<"\n\nPresent TOP: "<<top;            //UP
             cout<<"\nPresent TOP x: "<<adrs[top].x;   
             cout<<"\nPresent TOP y: "<<adrs[top].y;
               
                if(adrs[top].x > 0) //if 1
                 {
                  nx = adrs[top].x-2;
                  ny = adrs[top].y;
                  ox = adrs[top].x;
                  oy = adrs[top].y;
                  
                 cout<<"\nFuture New: "<<nx<<ny<<"\n\n";
                  
                  if(nx==adrs[top-1].x && ny==adrs[top-1].y)// if 2
                    continue;
                  else// else 2
                    {
                     if( a[nx][ny] !=1 )//if 3
                       {
                        cout<<"\nOld: "<<ox<<oy;
                        cout<<"\nNew: "<<nx<<ny;
                        cout<<"\nMoved";
                        cout<<"\n\n";
                        
                        top++;
                        adrs[top].x = nx;
                        adrs[top].y = ny;
                        a[nx][ny]=1;
                        a[nx+1][ny]=1;
                        bx=nx+1;
                        by=ny;
                       // setcolor(WHITE);
                        //line(25+25*ny,50+25*nx,50+25*ny,50+25*nx);  
                        coord_cal(bx,by);  // panting the red brick -> white
                       }  // Pointer moved. Next iteration
                     else     //else 3
                      {
                       count++;
                       if(count==5)
                          {
                            count=0;
                           --top; 
                          }//if
                      }//else
                              //Pointer backtracked. Next iteration
                    }  
            
            }   
         break;

         
 
case 2:      
                    //right
       cout<<"\n\nPresent TOP: "<<top;
       cout<<"\nPresent TOP x: "<<adrs[top].x;   
             cout<<"\nPresent TOP y: "<<adrs[top].y;
         
           
                   
       if(adrs[top].y <c-1)
         {
          nx = adrs[top].x;
          ny = adrs[top].y+2;
          ox = adrs[top].x; 
          oy = adrs[top].y;
           
        
          cout<<"\nFuture New: "<<nx<<ny;
          cout<<"\n\n";     
           
                  
          if(top!=0)
            {
             if(nx==adrs[top-1].x && ny==adrs[top-1].y)   
               continue;                   
             else
               {
                if( a[nx][ny] !=1)
                  {
                    cout<<"\nOld: "<<ox<<oy;
                    cout<<"\nNew: "<<nx<<ny;
                    cout<<"Moved";
                    cout<<"\n\n";
               
                    top++;
                    adrs[top].x = nx;
                    adrs[top].y = ny;
                    a[nx][ny]=1;
                    a[nx][ny-1]=1;
                    bx=nx;
                    by=ny-1;
                    //setcolor(BLACK);
                    //line( 50+25*oy,25+25*ox,50+25*oy,50+25*ox );   
                     coord_cal(bx,by);   // panting the red brick -> white
                    // return; // return back to direction specifier.
                  }
                else
                 {count++;
                      if(count==5)
                      {
                        count=0;  --top;} }   //return; // return back to direction specifier
               }
            }
          else
          {
           top++;
           adrs[top].x = nx;
           adrs[top].y = ny;
           a[nx][ny]=1;
           a[nx][ny-1]=1;
                               bx=nx;
                    by=ny-1;
                            coord_cal(bx,by);
           //setcolor(BLACK);
           //line( 50+25*oy,25+25*ox,50+25*oy,50+25*ox );
          }
}         

     break;
  
  case 3:
                                 //DOWN
           cout<<"\n\nPresent TOP: "<<top;
           cout<<"\nPresent TOP x: "<<adrs[top].x;   
             cout<<"\nPresent TOP y: "<<adrs[top].y;
             
             
              
            if(adrs[top].x <r-1)
              {
               nx = adrs[top].x+2;
               ny = adrs[top].y;
               ox = adrs[top].x; 
               oy = adrs[top].y; 
               
        
               cout<<"\nFuture New: "<<nx<<ny;
               cout<<"\n\n";
                              
               if(top!=0)
            {
             if(nx==adrs[top-1].x && ny==adrs[top-1].y)   
               continue;                   
             else
               {
                if( a[nx][ny] !=1)
                  {
                    cout<<"\nOld: "<<ox<<oy;
                    cout<<"\nNew: "<<nx<<ny;
                    cout<<"Moved";
                    cout<<"\n\n";
               
                    top++;
                    adrs[top].x = nx;
                    adrs[top].y = ny;
                    a[nx][ny]=1;
                     a[nx-1][ny]=1;
                     bx=nx-1;
                     by=ny;
                    //setcolor(BLACK);
                   // line( 25+25*oy,50+25*ox,50+25*oy,50+25*ox ); 
                    coord_cal(bx,by);     // panting the red brick -> white
                    // return; // return back to direction specifier.
                  }
                else
                  {count++;
                      if(count==5)
                          { count=0;--top; } }   //return; // return back to direction specifier
               }
            }
          else
          {
           top++;
           adrs[top].x = nx;
           adrs[top].y = ny;
           a[nx][ny]=1;
           a[nx-1][ny]=1;
           bx=nx-1;
                     by=ny;
                    coord_cal(bx,by); 
       
       //    setcolor(BLACK);
         //  line( 25+25*oy,50+25*ox,50+25*oy,50+25*ox );
          }
          
}
     break;
     
case 4:            //left
           
            cout<<"\n\nPresent TOP: "<<top;
            cout<<"\nPresent TOP x: "<<adrs[top].x;   
            cout<<"\nPresent TOP y: "<<adrs[top].y;
            
            if(adrs[top].y >0)
              {
               nx = adrs[top].x;
               ny = adrs[top].y-2;
               ox = adrs[top].x; 
               oy = adrs[top].y; 
               
               cout<<"\nFuture New: "<<nx<<ny<<endl;
                     
               if(nx==adrs[top-1].x && ny==adrs[top-1].y) 
                 continue;
               else 
               {
                if( a[nx][ny] !=1)
                    {
                     cout<<"\nOld: "<<ox<<oy;
                     cout<<"\nNew: "<<nx<<ny;
                     cout<<"Moved";
                     cout<<"\n\n";
                     
                     top++;
                     adrs[top].x = nx;
                     adrs[top].y = ny;
                     a[nx][ny]=1;
                     a[nx][ny+1]=1;
                     bx=nx;
                     by=ny+1;
                     //setcolor(BLACK);
                    // line( 50+25*ny,25+25*nx,50+25*ny,50+25*nx );      
                     coord_cal(bx,by);// panting the red brick -> white
                     //return; // return back to direction specifier.
                    }
                  else
                     {count++;
                      if(count==5)
                       {count=0; --top;} } 
               }
                     //return; // return back to direction specifier.
                  
}
          
          break;
           
}//END OF switch()
           
    for(int i=0;i<r;i+=2)
     for(int j=0; j<c; j+=2)
        {  if(a[i][j]==1)
              ender++;
         }
             
    if(ender==(R*C))
         break;
    
    
      
                   
     
     
     
}// while loop ends
   
   lining_sqb(r, c,a,ch);
 
 
  out_boundary(r,c,ch);
    play(a,r,c,ch);
    // while (!kbhit( ))
       // delay(750);   //getch();
        
  setfillstyle(SOLID_FILL,WHITE);
  floodfill(0,0,MAGENTA);
    }
}  // END OF main()
Esempio n. 19
0
// 核心进程
void CoreControl(void) {
    INT16U i = 0, j;
    INT8U tpls = 0;
//    INT16U tmp;

    // 串口发送的状态, 和串口字
    //INT8U sciState = 0;//, sciChar;

    StartSpeeder();
    ClearDistanceCounter();

    MotorControlInit();

    crsN = 0;
    nowLoop = 0;


    FOREVER() {
        //PORTB = ~PORTB;

        // 判断小按键是否按下, 是则进入菜单
        if (!PTIP_PTIP0) {
            WaitEnable();
            Wait(20);
            if (!PTIP_PTIP0) {
                StopRun();
                StartMenu();
                WaitSmallButtonPress();
                Wait(1500);
            }
        }


        // 采集红外值
        for (i = 0;i < nIR / 2;i++) {
            irSendDouble(irRevPair[i][0], irRevPair[i][1]);

            for (j = 0;j < 100;j++);

            ReadADCDouble(irRevPair[i][2],irRevPair[i][3], &wir[irRevPair[i][0]], &wir[irRevPair[i][1]]);
        }

        // 将各值归一化
        for (i = 0;i < nIR;i++) {
            if (whiteAvg[i] < wir[i]) {
                irValue[i] = 100;
            } else if (blackAvg[i] > wir[i]) {
                irValue[i] = 0;
            } else {
                irValue[i] = (100 * (wir[i] - blackAvg[i])) / ( whiteAvg[i] - blackAvg[i]);
            }
        }

        /** 红外值的手工修正 **/
        //irValue[2] = irValue[2] * 100 / 94;
        //irValue[3] = irValue[3] * 100 / 86;
        //irValue[6] = irValue[6] * 100 / 94;


        // 找最低
        minIRv = 100;
        maxIRv = 0;
        ttotal = 0;
        for (i = 0;i < nIR;i++) {
            if ( minIRv > irValue[i] ) {
                minIRn2 = minIRn;
                minIRn = i;
                minIRv2 = minIRv;
                minIRv = irValue[i];
            }

            if ( maxIRv < irValue[i] ) {
                maxIRv = irValue[i];
            }

            ttotal+= irValue[i];
        }
        total = ttotal;



        // 求出精确位置
        if ( minIRn <= (nIR - 1 - 1) && minIRn >= 1) {
            position = ir_position[minIRn - 1] + irValue[minIRn - 1] * IR_SPACE_BETWEEN / (irValue[minIRn - 1] + irValue[minIRn + 1]);
        } else if (minIRn == 0) {
            if (irValue[1] >= 90) {
                position = ir_position[0] - (IR_SPACE_BETWEEN / 2) * irValue[0] / (irValue[0] + irValue[1]);
            } else {
                position = ir_position[0] + (IR_SPACE_BETWEEN / 2) * irValue[0] / (irValue[0] + irValue[1]);
            }
        } else {
            if (irValue[nIR - 1 - 1] >= 92/** TODO 这样合适么? **/) {
                position = ir_position[nIR - 1] + (IR_SPACE_BETWEEN / 2) * irValue[nIR - 1] / (irValue[nIR - 1 - 1] + irValue[nIR - 1]);
            } else {
                position = ir_position[nIR - 1] - (IR_SPACE_BETWEEN / 2) * irValue[nIR - 1] / (irValue[nIR - 1 - 1] + irValue[nIR - 1]);
            }
        }

        // 排错, 理论上前后两次之间的值相差不应超过15

        if ( ((position > last_position)?(position - last_position):(last_position - position)) > 60) {
            if (nowLoop == 1) {
                if (GetDistance() - lastAllWhiteDist > 50)
                    position = last_position;
            } else if (nowLoop == 2) {
                if (GetDistance() - (StartLineDist[1] - StartLineDist[0]) - lastAllWhiteDist > 50)
                    position = last_position;
            }

        }


        // 类模糊法判断各种路面情况
        /** TODO 各各变量的权值还可以调节(通过数据), 变量数还可以增加 **/
        //情况                  minIRv              minIRv2             maxIRv              total
        blStateArr[NORMAL]  =   (100 - minIRv) +    (100 - minIRv2) +   maxIRv          +   total / nIR;
        blStateArr[LOST]    =   minIRv         +    minIRv2         +   maxIRv          +   (100 - total / nIR);
        blStateArr[CROSS]   =   (100 - minIRv) +    (100 - minIRv2) +   (100 - maxIRv)  +   (100 - total / nIR);
        blStateArr[START]   =   (100 - minIRv) +    (100 - minIRv2) +   maxIRv          +   (100 - total / nIR);

        // 找最有可能的情况
        blState = NORMAL;
        for (i = 1;i < 4;i++) {
            if (blStateArr[blState] < blStateArr[i]) {
                blState = i;
            }
        }

        tBlState = blState;


        // 根据判断结果作出相应
        if ( blState != NORMAL) {


            ProcessSpecialPoint();
            if (GetDistance() - lastAllWhiteDist < 50) {
                last_position = position;
            } else {
                position = last_position;
            }


        } else {
            last_position = position;
        }

        // 得出舵机转角
#if nIR == 8
        // 与以前的匹配
        if (position > 125) {
            position = 125 + (position - 125) * 220 / 175;
        } else {
            position = 125 - (125 - position) * 220 / 175;
        }
#endif
        /** TODO 使用一个函数发生器来为舵机提供转角 **/
        servoTgtAngle = (INT8U)PosToAgl(position);

        //累加舵机角度
        if (PerDistSrvTotal < 0xFFFFFF && PerDistSrvN < 0xFFF0 && servoTgtAngle < 130 && servoTgtAngle > 50 ) {
            PerDistSrvTotal += servoTgtAngle;
            PerDistSrvN++;
        }


        // 简单转速控制
        tgtSpeed = (INT16S)(minSpeed + (maxSpeed - minSpeed) * (speed_arr[position] ) / 40);


        if (tgtSpeed < 50 || tgtSpeed > XSpeed) {
            tgtSpeed = lastTgtSpeed;
        } else {
            lastTgtSpeed = tgtSpeed;
        }


        // 转动舵机
        ServoControl();

        // 转动马达, 有限制距离的
        if (DistLimit != 0 && DistLimit * 25 < GetDistance() ) {
            StopRun();
        } else {
            MotorControl();
        }

        tdist = GetDistance();

        /*if(SCI0SR1 & 0x80) {
            switch(sciState) {
                case 0:
                    sciChar = 0xFE;
                    break;
                case 1:
                    sciChar = (INT8U)position;
                    break;
                case 2:
                    sciChar = (INT8U)servoTgtAngle;
                    break;
                case 3:
                    sciChar = ((INT8U)((3927 * 4) / GetSpeed())  * _RTI_P )& 0xFF;
                    break;
                case 4:
                    sciChar = (INT8U)(GetDistance());
                default:  
                    break;            
            }
            sciState = (INT16U)(sciState + 1) % 5;
            SCI0DRL = sciChar;
        } */
        ///////////////////////////////////////////////////////////////////////
    }

}
Esempio n. 20
0
/*
 * TryCompileableToken - process token that can also be compiled
 */
vi_rc TryCompileableToken( int token, const char *data, bool iscmdline )
{
    vi_rc       rc = ERR_INVALID_COMMAND;
    bool        mflag;

    switch( token ) {
    case PCL_T_MAPBASE_DMT:
    case PCL_T_MAP_DMT:
    case PCL_T_MAPBASE:
    case PCL_T_MAP:
        if( iscmdline ) {
            mflag = MAPFLAG_MESSAGE;
        } else {
            mflag = 0;
        }
        if( token == PCL_T_MAPBASE || token == PCL_T_MAPBASE_DMT ) {
            mflag |= MAPFLAG_BASE;
        }
        if( token == PCL_T_MAP_DMT || token == PCL_T_MAPBASE_DMT ) {
            mflag |= MAPFLAG_DAMMIT;
        }
        rc = MapKey( mflag, data );
        break;
    case PCL_T_MENUFILELIST:
        rc = MenuItemFileList();
        break;
    case PCL_T_MENULASTFILES:
        rc = MenuItemLastFiles();
        break;
    case PCL_T_MENU:
        rc = StartMenu( data );
        break;
    case PCL_T_MENUITEM:
        rc = MenuItem( data );
        break;
    case PCL_T_FLOATMENU:
        rc = ActivateFloatMenu( data );
        break;
    case PCL_T_ENDMENU:
        rc = ViEndMenu();
        break;
    case PCL_T_FILETYPESOURCE:
        rc = FTSStart( data );
        break;
    case PCL_T_ADDTOOLBARITEM:
#ifdef __WIN__
        rc = AddBitmapToToolBar( data );
#endif
        break;
    case PCL_T_DELETETOOLBARITEM:
#ifdef __WIN__
        rc = DeleteFromToolBar( data );
#endif
        break;
    case PCL_T_ACTIVATE_IDE:
#ifdef __WIN__
        StartIDE( InstanceHandle, TRUE );
        rc = ERR_NO_ERR;
#endif
        break;
    case PCL_T_ALIAS:
        rc = SetAlias( data );
        break;
    case PCL_T_ABBREV:
        rc = Abbrev( data );
        break;
    case PCL_T_SET:
        if( iscmdline ) {
            data = Expand( dataBuff, data, NULL );
        }
        rc = Set( data );
        break;
    case PCL_T_SETCOLOR:
        rc = SetAColor( data );
        break;
    case PCL_T_SETFONT:
        rc = SetFont( data );
        break;
    case PCL_T_MATCH:
        rc = AddMatchString( data );
        break;
    case PCL_T_LOCATE:
        rc = LocateCmd( data );
        break;
    default:
        rc = NOT_COMPILEABLE_TOKEN;
        break;
    }
    return( rc );

} /* TryCompileableToken */