382Fermer384
nullLe 18/02/2004 à 18:43
Voilà enfin ma routine terminé :

#define height_screen 100
#define width_screen 160
__attribute__((regparm))void PutBitmap(short x, short y,BITMAP* BMP,unsigned char *video_plane)
{
	
  short i=0,j=0;
  short nb_c=BMP->NumCols;
  short nb_l=BMP->NumRows;

  unsigned char *pic=BMP->Data;
  if(y+nb_l>=height_screen) 
  nb_l=height_screen-y; 
  
  short lenght = (nb_c>>3)+1;
  short nb_sprite;
  if(y<0)
  {
  	nb_sprite = -y*lenght;
        pic=pic+nb_sprite;
        nb_l=nb_l+y;
        y=0;
    
  }
  short nb_sprite_out_right =0;
  
  if((x+nb_c)>=width_screen-8)
  {
        nb_sprite_out_right = ((x+nb_c-(width_screen-2))>>3);
  	lenght = lenght-nb_sprite_out_right;
  }
  
  short nb_sprite_out_left=0;
  if(x<0)
  {
  	nb_sprite_out_left=((-1-x)>>3);
  	lenght = lenght - nb_sprite_out_left;
  }
  
  if(lenght<0)
  lenght=0;
  short mask1 = x&7;
  short m=nb_l;
  for(j=0;j<nb_l;j++)
  {
       
       short x_ = x;
       short i=0;
       if(x_<0)
       x_=-1;
       unsigned char *pointeur = (video_plane+(((y<<8)-(y<<4)+x_)>>3));
       /*                                    (256y-16y+x)/8       */
         
       short n=lenght;
       pic=(pic+nb_sprite_out_left);
       while(n--)
       {
  	     
  	       if(x_>=0)
  	     	 *(pointeur) |=((*(pic)>>(mask1)));
  	       pointeur++;
  	       if(x_<width_screen-8)
  	       {
  	     	   *(pointeur) |=(((*(pic)<<(8-mask1))));
  	       }
  	     	
  	       pic++;
  	       x_=x_+8;
      
       }
       y++;
       pic=pic+nb_sprite_out_right;
       
  }

Si vous voyez des erreurs (enfin ça va être très dur à voir) ou des optimisations qui vous sauterais aux yeux, n'hésitez pas à m'en faire part.
J'ai passé très longtemps à débbugé avec VTI parce-que je n'ai pas encore compris grand chose. grin
Et sinon j'ai toujours le même problème avec certaine PIC qui s'affiche pas correctement du tout... je ne comprends par pourquoi. A mon avais ça peut venir du nombre de colones ou de lignes qui font foiré ma routine et je ne sais pas comment y remédier.