//---------------------------------------------------------------------------
// Manage everything for the qualify percentage in shooting range
//---------------------------------------------------------------------------

Character *Percent[4];
int Percente;

//-------------------------------------
// Load blood sprites
//-------------------------------------
int LoadPercent (u_long *memptr)
{
   if ((*memptr) & 3)
      *memptr = (((*memptr) + 4) & 0xFFFFFFFC);
   Percent[0] = (Character *)*memptr;
   *memptr += sizeof (Character);
   Percent[0]->Load ("\\SPRITES\\SHOOTING\\NUMBER.KRT", memptr);
   Percent[0]->Set_Location (136,200);
   Percent[0]->SetDepth (14);
   Percent[0]->SetCharacteristics (128);

   Percent[1] = Percent[0]->Clone_Character (0, memptr);
   Percent[1]->Set_Location (152,200);
   Percent[1]->SetDepth (14);

   Percent[2] = Percent[0]->Clone_Character (0, memptr);
   Percent[2]->Set_Location (168,200);
   Percent[2]->SetDepth (14);

   Percent[3] = Percent[0]->Clone_Character (0, memptr);
   Percent[3]->Set_Location (185,205);
   Percent[3]->StartAction (10, 0);
   Percent[3]->SetDepth (14);
}

//-------------------------------------
// Set the percentage to be displayed
//-------------------------------------
void SetPercent (int pourcent)
{
   Percente = pourcent;
   Percent[0]->StartAction (pourcent / 100, 0);
   if (pourcent > 99)
   pourcent -= 100;
   Percent[1]->StartAction (pourcent / 10, 0);
   Percent[2]->StartAction (pourcent % 10, 0);
}

//-------------------------------------
// Draw the Percent animations in the
// screen
//-------------------------------------
void DrawPercent (DoubleBuffer *db)
{
   SPRT     *sprite;
   DR_MODE  *dr_mode;
   int      dummy;

   sprite = db->Get_Spr ();                 // "qalify"
   setXY0 (sprite, 134,175);
   setWH (sprite, 52,8);
   setUV0 (sprite, 172,48);
   sprite->clut = GetClut (0, FrgndClutY[0] + 480);
   SetSemiTrans (sprite, 0);
   db->Add_Spr (sprite, 14);

   RECT tww3 = {FrgndTX,FrgndTY,256,256};
   dr_mode = db->Get_DrMode ();
   SetDrawMode (dr_mode, 0, 0, GetTPage (1, 0, FrgndTX,FrgndTY), &tww3);
   db->Add_DrMode (dr_mode, 14);

   if (Percente > 99)
      Percent[0]->DrawNextFrame (0,0, db, &dummy, &dummy, &dummy);
   Percent[1]->DrawNextFrame (0,0, db, &dummy, &dummy, &dummy);
   Percent[2]->DrawNextFrame (0,0, db, &dummy, &dummy, &dummy);
   Percent[3]->DrawNextFrame (0,0, db, &dummy, &dummy, &dummy);
}
