Paint on the TV screen with Arduino

I've read your post again, ...

Yes it run on an arduino, I've read it to quickly.

Ok for the optimizations possibles in asm, but I d'on't understand what yhe matter with bootloader and a slower program ? Could you explain us ?

I'm actually working on an (low res) code with tming "running" (I don't speak english :() with interrupt. I have sometimes "jitter" depends on code but I don't understand why ?

the code is below, have you any idea ?

#define _SYNC 0x00
#define _BLACK  0x01
#define _GRAY  0x02
#define _WHITE  0x03

// compensation chargement us de 1 incluse
/*
#define _NORMAL_SYNC 32
#define _LONG_SYNC 240
#define _SHORT_SYNC 16
#define _LONG_SYNC_DELAI 16
#define _SHORT_SYNC_DELAI 240
*/


#define _NB_PIXELS 29
#define _NB_LIGNES 19


#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

byte memVideo[_NB_PIXELS][_NB_LIGNES];
byte index, index2;
int noligne = 0;
byte diviseur = 0;

boolean bCalcul = false;

SIGNAL(SIG_OVERFLOW0)
{
  TCNT0 = 256 - 128;
  PORTB = _SYNC;
      
  if (noligne == 3 || noligne == 4)
  {
    // SYNCHRO
    while (TCNT0 < (128 + 4)); // 2 uS
        
    PORTB = _BLACK;
    while (TCNT0 < (128 + 60 + 4)); // 32 us 
    
    PORTB = _SYNC;
    while (TCNT0 < (128 + 60 + 4 + 4));
  }
    
  // fin
  if (noligne >= 309)
  {
    // SHORT
    while (TCNT0 < (128 + 4)); // 2 uS
    
    PORTB = _BLACK;
    while (TCNT0 < (128 + 60 + 4)); // 32 us
    
    // SHORT
    PORTB = _SYNC;
    while (TCNT0 < (128 + 60 + 4 + 4));
  }

  // image
  if (noligne >= 5 && noligne < 309)
  {
    // SYNC
    while (TCNT0 < (128 + 8));
    
    PORTB = _BLACK; // porch
    while (TCNT0 < (128 + 8 + 8));
    
    //** image ligne 52 uS
//##    if (noligne >= 32 && noligne < 304)
    {
      for (index = 0; index < _NB_PIXELS; index++)
      {
        PORTB = memVideo[index][(noligne>>4)];
        PORTB = PORTB;
        PORTB = PORTB;
      }
    }
  }
  
  if (noligne == 2)
  {
    // SYNCHRO
    while (TCNT0 < (128 + 60));
    
    PORTB = _BLACK;
    while (TCNT0 < (128 + 60 + 4));

    PORTB = _SYNC;
    while (TCNT0 < (128 + 60 + 4 + 4));
  }
  
  if (noligne < 2)
  {
    // SYNCHRO
    while (TCNT0 < (128 + 60));
    
    PORTB = _BLACK;
    while (TCNT0 < (128 + 60 + 4));

    PORTB = _SYNC;
    while (TCNT0 < (128 + 60 + 4 + 60));
  }
  
  PORTB = _BLACK;
      
  // COMPTEUR LIGNE
  if (noligne == 311)
    noligne = 0;
  else
    noligne++;
}

void InitTimer()
{
  #if defined(__AVR_ATmega168__)
      sbi(TCCR0A, WGM01);
      sbi(TCCR0A, WGM00);
  #endif  
      // set timer 0 prescale factor to 8
  #if defined(__AVR_ATmega168__)
        cbi(TCCR0B, CS02);
      sbi(TCCR0B, CS01);
      cbi(TCCR0B, CS00);
  #else
        cbi(TCCR0, CS02);
      sbi(TCCR0, CS01);
      cbi(TCCR0, CS00);
  #endif

      // enable timer 0 overflow interrupt
  #if defined(__AVR_ATmega168__)
        sbi(TIMSK0, TOIE0);
  #else
        sbi(TIMSK, TOIE0);
  #endif
}

void setup()
{
  pinMode (8, OUTPUT);
  pinMode (9, OUTPUT);
  digitalWrite (8, HIGH);
  digitalWrite (9, HIGH);
/*
  Serial.begin(19200);
  Serial.print ("GO");
  Serial.print (13, BYTE);
*/
  for (index2 = 0; index2 < _NB_LIGNES; index2++)
     for (index = 0; index < _NB_PIXELS; index++)
     {
       /*memVideo[index][index2] = _BLACK;*/
       memVideo[index][index2] = (index + index2) % 3 + 1;
     }

  memVideo[2][2] = _WHITE;

  InitTimer();
}

int ligne;
char car;
int cx=0, cy=0;
byte couleur = _BLACK;

void loop()
{
  /*
  if (bCalcul)
  {
    bCalcul = false;
   if (serialAvailable())
   {
     Serial.read();
   }
  }
  */
}

If I uncomment the line wich start with "//##" the screen is scrambled but stable ? ? ?