Esempio n. 1
0
void play(char win[], char j1[], char j2[],int *valMatches)//
{
    int tpm;
    int allumette=*valMatches;
    tpm=rand()%2; /*Randomly chooses the player who starts the game*/
    matches_21(X,Y,1,allumette,10);
    printf("\n\n\n\n\t\t\t\t%s vs %s ... Ready ... Fight !!!  (Press Enter)",j1,j2);
    getch();
    clrScr();
    matches_21(X,Y,1,allumette,10);
    setColour(ROUGE_VIF,NOIR);
    printf("\n\n\n\n\n\t\t\t\t\t#");
    setColour(BLANC,NOIR);
    printf(" There are");
    setColour(MAGENTA_VIF,NOIR);
    printf(" %d ",allumette);
    setColour(BLANC,NOIR);
    printf("matches on table ");
    setColour(ROUGE_VIF,NOIR);
    printf("#\n");
    setColour(BLANC,NOIR);
    do
    {
        allumette=game(allumette,tpm,win,j1,j2);
        tpm=change(tpm);
    }while(allumette>1);
    printf("\n\n\n\t\t\t\t\t    The Game is Finished !!!\n");
    winner(win,allumette);
}
Esempio n. 2
0
int game(int allumetteRestante, int tpm, char win[], char j1[], char j2[])//
{
    int allumetteJoue;
    int i;
    turn(tpm,win,j1,j2);
    printf("%c  Remove matches ? : ",175);
    allumetteJoue=warning(allumetteRestante);
    allumetteRestante=allumetteRestante-allumetteJoue;
    clrScr();
    if(allumetteRestante<21)
        graphic_game(allumetteRestante,allumetteJoue,10);
    matches_21(X,Y,1,allumetteRestante,10);
    setColour(ROUGE_VIF,NOIR);
    printf("\n\n\n\n\n\t\t\t\t\t#");
    setColour(BLANC,NOIR);
    printf(" There are");
    setColour(MAGENTA_VIF,NOIR);
    printf(" %d ",allumetteRestante);
    setColour(BLANC,NOIR);
    printf("matches on table ");
    setColour(ROUGE_VIF,NOIR);
    printf("#\n");
    setColour(BLANC,NOIR);
    return allumetteRestante;
}
Esempio n. 3
0
void chooseLevel(Player *joueur)
{
    DEFAUT;
    clrScr();
    setColour(JAUNE_VIF,NOIR);
    gotoXY(38,3);
    printf("%c  %c%c %c %c %c%c %c   %c  %c",219,219,219,219,219,219,219,219,219,219);
    setColour(BLEU_VIF,NOIR);
    gotoXY(38,4);
    printf("%c  %c%c %c %c %c%c %c   %c %c%c%c",219,219,254,219,219,219,254,219,219,219,254,219);
    setColour(ROUGE_VIF,NOIR);
    gotoXY(38,5);
    printf("%c%c %c%c  %c  %c%c %c%c  %c %c %c",219,219,219,219,219,219,219,219,219,219,219,219);
    gotoXY(5,10);
    setColour(MAGENTA_VIF,NOIR);
    puts("EASY (1)");
    RabbitHead(16,5);
    gotoXY(5,20);
    setColour(BLEU_VIF,NOIR);
    puts("MEDIUM (2)");
    GeekHead(16,15);
    gotoXY(5,30);
    setColour(ROUGE_VIF,NOIR);
    puts("HARD (3)");
    RedDogHead(16,25);
    gotoXY(79,10);
    setColour(BLANC_VIF,NOIR);
    puts("APOCALYPTIC (4)");
    MastersHead(58,11);
    gotoXY(39,22);
    printf("Which level ? : ");
    scanf("%d",&joueur->level);
}
Esempio n. 4
0
File: test.cpp Progetto: r043v/dstar
	void screenTest(void)
	{	saveBlitLimit();
		fullBlitLimit();
		clrScr(0);
		mkprints(84,100,".. please wait ..");
		mkprints(70,120,"test blit & lcd speed");
		mkprints(102,130," . %i mhz .",currentFrequency);
		Gdl_flip();
		clrScr(0);
		mkprints(84,100,".. please wait ..");
		mkprints(70,120,"test blit & lcd speed");
		mkprints(102,130," . %i mhz .",currentFrequency);
		Gdl_flip();

		u32 time = GetTickCount();
		u32 nb=64;
		
		while(nb--)
			{ while ((rLCDCON1 >> 18) !=   1) asm volatile("nop\n""nop\n""nop\n");
			  while ((rLCDCON1 >> 18) != 319) asm volatile("nop\n""nop\n""nop\n");
			  while ((rLCDCON1 >> 18) !=   1) asm volatile("nop\n""nop\n""nop\n");
			  while ((rLCDCON1 >> 18) != 319) asm volatile("nop\n""nop\n""nop\n");
			};
			
		tick = GetTickCount();
		time = tick - time;

		u32 frmDelay = time>>=7;
		shell.print("\n frmDellay %i\nfps %i",frmDelay,1000/frmDelay);
		Gdl_flip(); Gdl_flip();
		u32 tme = doBlitSpeedTest();

		u32 maxBlitPerFrm = (96*64*frmDelay)/tme;
		shell.print("\n maxBlit %i",maxBlitPerFrm);
		//Gdl_showMsg("%iMhz, %ifps (%ims), maxBlt %i",currentFrequency,1000/frmDelay,frmDelay,maxBlitPerFrm);
		clrScr(0);
		mkprints(10,230,"%iMhz, %ifps (%ims), maxBlt %i",currentFrequency,1000/frmDelay,frmDelay,maxBlitPerFrm);
		 Gdl_flip(); clrScr(0);
		mkprints(10,230,"%iMhz, %ifps (%ims), maxBlt %i",currentFrequency,1000/frmDelay,frmDelay,maxBlitPerFrm);
		 Gdl_flip();
		//gp_drawString(10,230,blitspeedsz,blitspeed,color,pixel);
		loadBlitLimit();
	}
Esempio n. 5
0
void InitLCD()
{
	//orient=orientation;
	orient=LANDSCAPE;

	LCD_Write_COM_DATA(0x00,0x0001);
	LCD_Write_COM_DATA(0x03,0xA8A4);
	LCD_Write_COM_DATA(0x0C,0x0000);
	LCD_Write_COM_DATA(0x0D,0x080C);
	LCD_Write_COM_DATA(0x0E,0x2B00);
	LCD_Write_COM_DATA(0x1E,0x00B7);
	LCD_Write_COM_DATA(0x01,0x693F);//693f
	LCD_Write_COM_DATA(0x02,0x0600);
	LCD_Write_COM_DATA(0x10,0x0000);
	LCD_Write_COM_DATA(0x11,0x6078);//6078
	LCD_Write_COM_DATA(0x05,0x0000);
	LCD_Write_COM_DATA(0x06,0x0000);
	LCD_Write_COM_DATA(0x16,0xEF1C);
	LCD_Write_COM_DATA(0x17,0x0003);
	LCD_Write_COM_DATA(0x07,0x0233);
	LCD_Write_COM_DATA(0x0B,0x0000);
	LCD_Write_COM_DATA(0x0F,0x0000);
	LCD_Write_COM_DATA(0x41,0x0000);
	LCD_Write_COM_DATA(0x42,0x0000);
	LCD_Write_COM_DATA(0x48,0x0000);
	LCD_Write_COM_DATA(0x49,0x013F);
	LCD_Write_COM_DATA(0x4A,0x0000);
	LCD_Write_COM_DATA(0x4B,0x0000);
	LCD_Write_COM_DATA(0x44,0xEF00);
	LCD_Write_COM_DATA(0x45,0x0000);
	LCD_Write_COM_DATA(0x46,0x013F);
	LCD_Write_COM_DATA(0x30,0x0707);
	LCD_Write_COM_DATA(0x31,0x0204);
	LCD_Write_COM_DATA(0x32,0x0204);
	LCD_Write_COM_DATA(0x33,0x0502);
	LCD_Write_COM_DATA(0x34,0x0507);
	LCD_Write_COM_DATA(0x35,0x0204);
	LCD_Write_COM_DATA(0x36,0x0204);
	LCD_Write_COM_DATA(0x37,0x0502);
	LCD_Write_COM_DATA(0x3A,0x0302);
	LCD_Write_COM_DATA(0x3B,0x0302);
	LCD_Write_COM_DATA(0x23,0x0000);
	LCD_Write_COM_DATA(0x24,0x0000);
	LCD_Write_COM_DATA(0x25,0x8000);
	LCD_Write_COM_DATA(0x4f,0x0000);
	LCD_Write_COM_DATA(0x4e,0x0000);
	LCD_Write_COM(0x22);

	//setColor(255, 255, 255);
	//setBackColor(0, 0, 0);
	cfont.font=0;
	clrScr();
}
Esempio n. 6
0
void	showImg(uchar * img, ushort largeur, ushort hauteur)
{		Gft * fnt = &nfont ;
		uchar * rotate_data=img ;
		ulong	cptx, cpty, startx, starty ;
		int		cpt ;//draw_pal = 0, cpt ;
		int	decalagex, size_draw_x ;
		int	decalagey, size_draw_y ;
		//int start_drax_x,start_drax_y, color ;
		int		scrool_speed = 8 ;
		ulong	scrool_time=0, speed_time=0, zoom_time=0 ;
		int		zoom  = 1	;
		int		nzoom = 2	;
		char buffer[512] ;
		int draw_pal=0 ;

		startx = (320-largeur)>>1 ;
		starty = (240-hauteur)>>1 ;

		decalagex=0 ;
		decalagey=0 ;

		size_draw_x = largeur ;
		size_draw_y = hauteur ;

		if(hauteur>240) {  starty=0 ;  size_draw_y = 240 ; }
		if(largeur>320) {  startx=0 ;  size_draw_x = 320 ; }
		loading=0 ;
		if(rotate_data)
		do {
			refreshKey() ;

			if(startx||starty)	clrScr() ;

			if(!zoom) // zoom 1/2
			{			
				  for(cptx=decalagex*nzoom;cptx<decalagex*nzoom+size_draw_x;cptx+=nzoom)
					for(cpty=decalagey*nzoom;cpty<decalagey*nzoom+size_draw_y;cpty+=nzoom)
					{	//*(screen[nflip] + (startx+(cptx/nzoom)-decalagex)*240 + (239-(starty+(cpty/nzoom)-decalagey))) = get_color_buffer(cptx, cpty, hauteur, rotate_data) ;
					} ;
			}
			else
			{
				if(zoom==1)
				{	  for(cptx=decalagex;cptx<decalagex+size_draw_x;cptx++)
						for(cpty=decalagey;cpty<decalagey+size_draw_y;cpty++)
						{	*(screen[nflip] + (startx+cptx-decalagex)*240 + (239-(starty+cpty-decalagey))) = get_color_buffer(cptx, cpty, hauteur, rotate_data) ;
						} ;
				} else {
					  for(cptx=decalagex;cptx<decalagex+(size_draw_x/zoom);cptx++)
						for(cpty=decalagey;cpty<decalagey+(size_draw_y/zoom);cpty++)
						{	rectFill(startx+(cptx-decalagex)*zoom,starty+(cpty-decalagey)*zoom,zoom,zoom,get_color_buffer(cptx, cpty, hauteur, rotate_data)) ;
						} ;
					}
			}

			if(!keyPush(kSelect))
			{
				if(keyPush(kRight)) // right
				{
					if(zoom) {	for(cpt=0;cpt<scrool_speed;cpt++)	if(decalagex+(size_draw_x/zoom)<largeur)	decalagex++ ; }
					else	{	if(!startx) for(cpt=0;cpt<scrool_speed;cpt++)	if(decalagex < largeur/2-320)		decalagex++ ;
							//if((size_draw_x+decalagex)*nzoom>largeur*nzoom) decalagex -= ((decalagex+size_draw_x)*nzoom-(largeur*nzoom)) ;
						}					
					scrool_time = GpTickCountGet() ;
				}
	
				if(keyPush(kLeft)) // left
				{
					for(cpt=0;cpt<scrool_speed;cpt++)	if(decalagex)	decalagex-- ;
					
					scrool_time = GpTickCountGet() ;
				}
				
				if(keyPush(kDown)) // down
				{
					if(zoom) {	for(cpt=0;cpt<scrool_speed;cpt++)	if(decalagey+(size_draw_y/zoom)<hauteur)	decalagey++ ; }
					else	{	if(!starty) for(cpt=0;cpt<scrool_speed;cpt++)	if(decalagey < hauteur/2-240)		decalagey++ ;
							//if((startx+size_draw_y+decalagey)*nzoom>hauteur*nzoom) decalagey -= ((startx+decalagey+size_draw_y)*nzoom-(hauteur*nzoom)) ;
						}


					scrool_time = GpTickCountGet() ;
				}
				
				if(keyPush(kUp)) // up
				{
					for(cpt=0;cpt<scrool_speed;cpt++)	if(decalagey)	decalagey-- ;
					
					scrool_time = GpTickCountGet() ;
				}
			} else {
				if(keyUp(kDown)) // down, zoom -
				{
					if(zoom>1)
					{
						short old, _new, dif, cpt ;
						
						old = (size_draw_x/zoom) ;
						_new = (size_draw_x/(zoom-1)) ;
						dif = (_new-old)/2 ;
						
						for(cpt=0;cpt<dif;cpt++)
							if(decalagex)	decalagex-- ;
						
						old = (size_draw_y/zoom) ;
						_new = (size_draw_y/(zoom-1)) ;
						dif = (_new-old)/2 ;

						for(cpt=0;cpt<dif;cpt++)
							if(decalagey)	decalagey-- ;

						zoom-- ;
						
						startx = (320-largeur*zoom)>>1 ;
						starty = (240-hauteur*zoom)>>1 ;
				
						size_draw_y = hauteur*zoom ;
						size_draw_x = largeur*zoom ;
				
						if(hauteur*zoom>240) {  starty=0 ;  size_draw_y = 240 ; }
						if(largeur*zoom>320) {  startx=0 ;  size_draw_x = 320 ; }
						
						if(size_draw_x/zoom+decalagex>largeur) decalagex -= (decalagex+size_draw_x/zoom)-largeur ;
						if(decalagey+size_draw_y/zoom>hauteur) decalagey -= (decalagey+size_draw_y/zoom)-hauteur ;
					}		/*else if(zoom==1)
							{
								short cpt ;
		
								for(cpt=0;cpt<size_draw_x/2;cpt++)
									if(decalagex)	decalagex-- ;
		
								for(cpt=0;cpt<size_draw_y/2;cpt++)
									if(decalagey)	decalagey-- ;
		
								zoom=0 ;
		
								startx = (320-largeur/2)>>1 ;
								starty = (240-hauteur/2)>>1 ;
						
								size_draw_y = hauteur ;
								size_draw_x = largeur ;
						
								if(hauteur/2>240) {  starty=0 ;  size_draw_y = 240*2 ; }
								if(largeur/2>320) {  startx=0 ;  size_draw_x = 320*2 ; }

								if(size_draw_x*2+decalagex>largeur*2) decalagex -= (decalagex+size_draw_x*2)-largeur*2 ;
								if(decalagey+size_draw_y*2>hauteur*2) decalagey -= (decalagey+size_draw_y*2)-hauteur*2 ;
								
								if(decalagey > hauteur/2-240) decalagey = hauteur/2-240 ;
								if(decalagex > largeur/2-320) decalagex = largeur/2-320 ;	
							}*/

					zoom_time = GpTickCountGet() ;
				}
				
				if(keyUp(kUp)) // up, zoom +
				{					
					if(zoom < 20)
					{
						short old, _new, dif, cpt ;
						
						if(zoom)
						{
							old = (size_draw_x/zoom) ;
							_new = (size_draw_x/(zoom+1)) ;
							dif = (old-_new)/2 ;

							for(cpt=0;cpt<dif;cpt++)
								if(decalagex+(size_draw_x/zoom)<largeur)	decalagex++ ;

							old = (size_draw_y/zoom) ;
							_new = (size_draw_y/(zoom+1)) ;
							dif = (old-_new)/2 ;
	
							for(cpt=0;cpt<dif;cpt++)
								if(decalagey+(size_draw_y/zoom)<hauteur)	decalagey++ ;
						}
						else
						{
							size_draw_y/=2 ;
							size_draw_x/=2 ;
							
							old = (size_draw_x*2) ;
							_new = (size_draw_x/2) ;
							dif = (old-_new)/2 ;
							
							for(cpt=0;cpt<dif;cpt++)
								if(decalagex+(size_draw_x*2)<largeur)	decalagex++ ;
								
							old = (size_draw_y*2) ;
							_new = (size_draw_y/2) ;
							dif = (old-_new)/2 ;
	
							for(cpt=0;cpt<dif;cpt++)
								if(decalagey+(size_draw_y*2)<hauteur)	decalagey++ ;
						}

						zoom++ ;
						
						startx = (320-largeur*zoom)>>1 ;
						starty = (240-hauteur*zoom)>>1 ;
				
						size_draw_y = hauteur*zoom ;
						size_draw_x = largeur*zoom ;
				
						if(hauteur*zoom>240) {  starty=0 ;  size_draw_y = 240 ; }
						if(largeur*zoom>320) {  startx=0 ;  size_draw_x = 320 ; }
					}
					
					zoom_time = GpTickCountGet() ;
				}
			}
Esempio n. 7
0
int main (void)
{
	
	int buf[318];
	int x, x2;
	int y, y2;
	int r;
	int i;
  	wiringPiSetup();									//设置树莓派GPIO
  	SetPinNU(0,1,2,3,4,5,6,7,8,10,9,11,15,16,14,12,13);	//设置引脚(参考树莓派GPIO映射图)
	SetLCDSize(LCD_28);									//设置使用的LCD尺寸	
  	Touch_Init();										//初始化触摸
	setFont(8,12);										//设置字体为8x12
  	setColor(0x07e0);									//设置字体颜色
  	setBackColor(0xf800);								//设置背景颜色	
	printf("Init is ok!\n");
	
 while(1) 
 {
   	clrScr();

   setColorRGB(255, 0, 0);
   fillRect(0, 0, 319, 13);
   setColorRGB(64, 64, 64);
   fillRect(0, 226, 319, 239);
   setColorRGB(255, 255, 255);
   setBackColorRGB(255, 0, 0);
   print("* Universal Color TFT Display Library *", CENTER,1,0);

   setBackColorRGB(64, 64, 64);
   setColorRGB(255,255,0);
   print("<http://electronics.henningkarlsen.com>", CENTER,227,0);
   setColorRGB(0, 0, 255);
   drawRect(0, 14,319,225);

// Draw crosshairs
   setColorRGB(0, 0, 255);
   setBackColorRGB(0, 0, 0);
   drawLine(159, 15, 159, 224);
   drawLine(1, 119, 318, 119);
  for (i=9; i<310; i+=10)
     drawLine(i, 117, i, 121);
  for (i=19; i<220; i+=10)
     drawLine(157, i, 161, i);

// Draw sin-, cos- and tan-lines  
   setColorRGB(0,255,255);
   print("Sin", 5, 15,0);
  for (i=1; i<318; i++)
  {
     drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95));
  }
  
   setColorRGB(255,0,0);
   print("Cos", 5, 27,0);
  for (i=1; i<318; i++)
  {
     drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95));
  }

   setColorRGB(255,255,0);
   print("Tan", 5, 39,0);
  for (i=1; i<318; i++)
  {
     drawPixel(i,119+(tan(((i*1.13)*3.14)/180)));
  }

  delay(2000);

   setColorRGB(0,0,0);
   fillRect(1,15,318,224);
   setColorRGB(0, 0, 255);
   setBackColorRGB(0, 0, 0);
   drawLine(159, 15, 159, 224);
   drawLine(1, 119, 318, 119);

// Draw a moving sinewave
  x=1;
  for (i=1; i<(318*20); i++) 
  {
    x++;
    if (x==319)
      x=1;
    if (i>319)
    {
      if ((x==159)||(buf[x-1]==119))
         setColorRGB(0,0,255);
      else
         setColorRGB(0,0,0);
       drawPixel(x,buf[x-1]);
    }
     setColorRGB(0,255,255);
    y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100)));
     drawPixel(x,y);
    buf[x-1]=y;
  }

  delay(2000);
  
   setColorRGB(0,0,0);
   fillRect(1,15,318,224);

// Draw some filled rectangles
  for (i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
         setColorRGB(255,0,255);
        break;
      case 2:
         setColorRGB(255,0,0);
        break;
      case 3:
         setColorRGB(0,255,0);
        break;
      case 4:
         setColorRGB(0,0,255);
        break;
      case 5:
         setColorRGB(255,255,0);
        break;
    }
     fillRect(70+(i*20), 30+(i*20), 130+(i*20), 90+(i*20));
  }

  delay(2000);
  
   setColorRGB(0,0,0);
   fillRect(1,15,318,224);

// Draw some filled, rounded rectangles
  for (i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
         setColorRGB(255,0,255);
        break;
      case 2:
         setColorRGB(255,0,0);
        break;
      case 3:
         setColorRGB(0,255,0);
        break;
      case 4:
         setColorRGB(0,0,255);
        break;
      case 5:
         setColorRGB(255,255,0);
        break;
    }
     fillRoundRect(190-(i*20), 30+(i*20), 250-(i*20), 90+(i*20));
  }
  
  delay(2000);
  
   setColorRGB(0,0,0);
   fillRect(1,15,318,224);

// Draw some filled circles
  for (i=1; i<6; i++)
  {
    switch (i)
    {
      case 1:
         setColorRGB(255,0,255);
        break;
      case 2:
         setColorRGB(255,0,0);
        break;
      case 3:
         setColorRGB(0,255,0);
        break;
      case 4:
         setColorRGB(0,0,255);
        break;
      case 5:
         setColorRGB(255,255,0);
        break;
    }
     fillCircle(100+(i*20),60+(i*20), 30);
  }

  delay(2000);

   setColorRGB(0,0,0);
   fillRect(1,15,318,224);

// Draw some lines in a pattern
   setColorRGB(255,0,0);
  for (i=15; i<224; i+=5)
  {
     drawLine(1, i, (i*1.44)-10, 224);
  }
   setColorRGB(255,0,0);
  for (i=224; i>15; i-=5)
  {
     drawLine(318, i, (i*1.44)-11, 15);
  }
   setColorRGB(0,255,255);
  for (i=224; i>15; i-=5)
  {
     drawLine(1, i, 331-(i*1.44), 15);
  }
   setColorRGB(0,255,255);
  for (i=15; i<224; i+=5)
  {
     drawLine(318, i, 330-(i*1.44), 224);
  }

  delay(2000);

   setColorRGB(0,0,0);
   fillRect(1,15,318,224);

// Draw some random circle
   fillScrRGB(0, 0, 255);
   setColorRGB(255, 0, 0);
   fillRoundRect(80, 70, 239, 169);

   setColorRGB(255, 255, 255);
   setBackColorRGB(255, 0, 0);
   print("That's it!", CENTER, 93,0);
   print("Restarting in a", CENTER, 119,0);
   print("few seconds...", CENTER, 142,0);

   setColorRGB(0, 255, 0);
   setBackColorRGB(0, 0, 255);
   print("Runtime: (msecs)", CENTER, 210,0);
   printNumI(millis(), CENTER, 225,0,0);
   
   delay (2000);
   if(Touch_DataAvailable())
   {
		Touch_Read();
		x=Touch_GetX();
		y=Touch_GetY();
		printf("%d,%d\n",x,y);
   }
  }

}