Пример #1
0
bool FadeInAction::Update(float dt, float blend /*= 1.f*/)
{
	RETURN_FALSE_IF_FALSE(BaseFiniteAction::Update(dt,blend));
	float percent=Percent();
	percent=Math::Clamp(percent,0.f,1.f);
	INode* node = (INode*)mTarget;
	node->SetOpacity(percent);
	return true;
}
Пример #2
0
void ProgressBar::drawInternal(Graphics* const Graphics, Real32 Opacity) const
{

	//Draw The ProgressBar
    UIDrawObjectCanvasRefPtr DrawObject(getDrawnDrawObject());
    if(DrawObject != NULL)
    {
        if(DrawObject->getPosition() != _ProgressBarPosition)
        {
            DrawObject->setPosition(_ProgressBarPosition);
        }
        if(DrawObject->getSize() != _ProgressBarSize)
        {
            DrawObject->setSize(_ProgressBarSize);
        }
        DrawObject->draw(Graphics,getOpacity()*Opacity);
    }
	
	//Draw The Progress String
	if(getEnableProgressString() && getFont() != NULL)
	{
		Pnt2f TopLeft, BottomRight;
		getInsideBorderBounds(TopLeft, BottomRight);

		//Draw the progress String
		std::string StringToDraw;
		if(getProgressString().compare("") == 0)
		{
            if(!getIndeterminate())
            {
			    UInt32 Percent(static_cast<Int32>( osgFloor(getPercentComplete() * 100.0f) ));

			    std::stringstream TempSStream;
			    TempSStream << Percent;

			    StringToDraw = TempSStream.str() + std::string("%");
            }
		}
		else
		{
			StringToDraw = getProgressString();
		}

		//Calculate Alignment
		Pnt2f AlignedPosition;
		Pnt2f TextTopLeft, TextBottomRight;
		getFont()->getBounds(StringToDraw, TextTopLeft, TextBottomRight);

		AlignedPosition = calculateAlignment(TopLeft, (BottomRight-TopLeft), (TextBottomRight - TextTopLeft),getAlignment().y(), getAlignment().x());

		//Draw the Text
		Graphics->drawText(AlignedPosition, StringToDraw, getFont(), getDrawnTextColor(), getOpacity()*Opacity);
	}
}
Пример #3
0
void
tlbsum(void)
{
	if(tlb.on == 0)
		return;

	Bprint(bioout, "\n\nTlb summary\n");

	Bprint(bioout, "\n%-8d User entries\n", tlb.tlbsize);
	Bprint(bioout, "%-8d Accesses\n", tlb.hit+tlb.miss);
	Bprint(bioout, "%-8d Tlb hits\n", tlb.hit);
	Bprint(bioout, "%-8d Tlb misses\n", tlb.miss);
	Bprint(bioout, "%7d%% Hit rate\n", Percent(tlb.hit, tlb.hit+tlb.miss));
}
Пример #4
0
void ProgressBar::setupProgressBar(void)
{

    Pnt2f TopLeft, BottomRight;
    getInsideBorderBounds(TopLeft, BottomRight);
   
	if(getIndeterminate())
	{
		Real32 Pos;
		if(_IndeterminateBarPosition > 1.0)
		{
			Pos = 2.0 - _IndeterminateBarPosition;
		}
		else
		{
			Pos = _IndeterminateBarPosition;
		}
			switch(getOrientation())
			{
			case ProgressBar::HORIZONTAL_ORIENTATION:
                _ProgressBarPosition.setValues((BottomRight.x() - TopLeft.x())*Pos*(1.0-getIndeterminateBarSize()), TopLeft.y());
                _ProgressBarSize.setValues( (BottomRight.x() - TopLeft.x())*getIndeterminateBarSize(),BottomRight.y() - TopLeft.y());
				break;
			case ProgressBar::VERTICAL_ORIENTATION:
			default:
                _ProgressBarPosition.setValues( Pos*(BottomRight.x() - TopLeft.x())*(1.0-getIndeterminateBarSize()), TopLeft.y());
                _ProgressBarSize.setValues( TopLeft.x(), Pos*(BottomRight.y() - TopLeft.y())*(1.0-getIndeterminateBarSize()));
				break;
			}
	}
	else
	{
		if(getRangeModel() == NULL) {return;}

		Real32 Percent(getPercentComplete());

        _ProgressBarPosition = TopLeft;
		switch(getOrientation())
		{
		case ProgressBar::HORIZONTAL_ORIENTATION:
            _ProgressBarSize.setValues( (BottomRight.x() - TopLeft.x())*Percent,BottomRight.y() - TopLeft.y());
			break;
		case ProgressBar::VERTICAL_ORIENTATION:
		default:
            _ProgressBarSize.setValues( BottomRight.x() - TopLeft.x(),(BottomRight.y() - TopLeft.y())*Percent);
			break;
		}
	}
}
Пример #5
0
void FileTransfer::Start()
{
    emit StartReceiving();
    QFile file(path_);
    file.open(QIODevice::WriteOnly);
    QDataStream stream(&file);

    while (!sock_->atEnd())
    {
        QByteArray data = sock_->read(buf_size_);
        if (data.size() <= 0)
        {
            break;
        }
        bytes_read_ += data.size();
        stream.writeRawData(data.data(), data.size());
        emit Percent(bytes_read_/total_);
    }
    emit EndReceiving();
}
Пример #6
0
int QymodemTx::SendY(const char* fileName, size_t size, InStream& in, unsigned timeout)
        {
        Use1KBlocks = true;
        quint8 buffer[128];
        int result = MakeBlock0(buffer,fileName,size);
        if(result<0)
                return result;

        result = SendInitialise(timeout);
        if(result<0 && result!=ErrorBlockRetriesExceded)
                return result;
        emit Information("Sending "+QString(fileName),QymodemTx::InfoSending);
        BlockNumber = 0;
        result = SendBlock(buffer,sizeof(buffer));
        if(result<0)
                return result;

        result = InChar(SendTimeout);
        if(result<0)
                return result;
        if(result!=ModeChar)
                return ErrorReceiverNotBehaving;

        result = SendAll(in);
        if(result<0)
                return result;

        result = InChar(SendTimeout);
        if(result<0)
                return result;
        if(result!=ModeChar)
                return ErrorReceiverNotBehaving;

        memset(buffer,0,sizeof(buffer));
        BlockNumber = 0;
        result = SendBlock(buffer,sizeof(buffer));
        if(result<0)
                return result;
        emit Percent(100);
        return 0;
        }
Пример #7
0
/**
Send an entire stread of data.

@param in	The stream of data to send.

@return Zero if successful, or a negative error value if failed.

@pre SendInitialise() must have been successful.
*/
int QymodemTx::SendAll(InStream& in)
        {
        BlockNumber = 1; // first block to send is number one
        size_t size;
        do
                {
                // get data from input stream...
                quint8 data[1024];
                int result = in.In(data,sizeof(data));
                emit Percent(in.percent);
                if(result<0)
                        return ErrorInputStreamError;

                // send data...

                size = result;
                result = SendData(data,size);
                if(result<0)
                        return result;
                }
        while(size); // end when no more data left
        return 0;
        }
Пример #8
0
void
isum(void)
{
	Inst *i;
	int total, mems, arith, branch;
	int useddelay, taken, syscall;
	int pct, j;

	total = 0;
	mems = 0;
	arith = 0;
	branch = 0;
	useddelay = 0;
	taken = 0;
	syscall = 0;

	/* Compute the total so we can have percentages */
	for(i = itab; i->func; i++)
		if(i->name && i->count)
			total += i->count;

	Bprint(bioout, "\nInstruction summary.\n\n");

	for(j = 0; tables[j]; j++) {
		for(i = tables[j]; i->func; i++) {
			if(i->name) {
				/* This is gross */
				if(i->count == 0)
					continue;
				pct = Percent(i->count, total);
				if(pct != 0)
					Bprint(bioout, "%-8ud %3d%% %s\n",
						i->count, Percent(i->count,
						total), i->name);
				else
					Bprint(bioout, "%-8ud      %s\n",
						i->count, i->name);


				switch(i->type) {
				default:
					fatal(0, "isum bad stype %d\n", i->type);
				case Imem:
					mems += i->count;
					break;
				case Iarith:
					arith += i->count;
					break;
				case Ibranch:
					branch += i->count;
					taken += i->taken;
					useddelay += i->useddelay;
					break;
				case Isyscall:
					syscall += i->count;
					break;
				}
		
			}
		}
	}

	Bprint(bioout, "\n%-8ud      Memory cycles\n", mems+total);	
	Bprint(bioout, "%-8ud %3d%% Instruction cycles\n",
			total, Percent(total, mems+total));
	Bprint(bioout, "%-8ud %3d%% Data cycles\n\n",
			mems, Percent(mems, mems+total));	

	Bprint(bioout, "%-8ud %3d%% Arithmetic\n",
			arith, Percent(arith, total));

	Bprint(bioout, "%-8ud %3d%% System calls\n",
			syscall, Percent(syscall, total));

	Bprint(bioout, "%-8ud %3d%% Branches\n",
			branch, Percent(branch, total));

	Bprint(bioout, "   %-8ud %3d%% Branches taken\n",
			taken, Percent(taken, branch));

	Bprint(bioout, "   %-8ud %3d%% Delay slots\n",
			useddelay, Percent(useddelay, branch));

	Bprint(bioout, "   %-8ud %3d%% Unused delay slots\n", 
			branch-useddelay, Percent(branch-useddelay, branch));

	Bprint(bioout, "%-8ud %3d%% Program total delay slots\n",
			nopcount, Percent(nopcount, total));
}
Пример #9
0
//-----------------------------------------------------------------------------
void TestCommandHandle::Execute()
{
  if (!engine) {
    Output() << "Engine not set for 'test' command";
    return;
  }

  if (fileName.empty()) {
    Output() << "FileName not set for 'test' command";
    return;
  }

  char     fen[16384];
  int      depth = 0;
  int      line = 0;
  int      maxSearchDepth = 0;
  int      maxSeldepth = 0;
  int      minSearchDepth = -1;
  int      minSeldepth = -1;
  int      passed = 0;
  int      positions = 0;
  int      seldepth = 0;
  int      tested = 0;
  int      totalDepth = 0;
  int      totalSeldepth = 0;
  uint64_t nodes = 0;
  uint64_t qnodes = 0;
  uint64_t time = 0;
  uint64_t totalNodes = 0;
  uint64_t totalQnodes = 0;
  uint64_t totalTime = 0;
  FILE*    fp = NULL;

  try {
    MoveFinder moveFinder;

    if (!(fp = fopen(fileName.c_str(), "r"))) {
      Output() << "Cannot open '" << fileName << "': " << strerror(errno);
      return;
    }

    engine->ClearStopFlags();
    engine->ResetStatsTotals();

    while (fgets(fen, sizeof(fen), fp)) {
      line++;

      char* f = fen;
      if (!*NextWord(f) || (*f == '#')) {
        continue;
      }

      positions++;
      if (skipCount && (positions <= skipCount)) {
        continue;
      }

      Output() << "--- Test " << (++tested) << " at line " << line << ' ' << f;
      NormalizeString(f);
      const char* next = engine->SetPosition(f);
      if (!next || !moveFinder.LoadFEN(f)) {
        break;
      }
      f += (next - f);

      // consume 'am' and 'bm' parameters
      std::set<std::string> avoid;
      std::set<std::string> best;
      while (f && *NextWord(f)) {
        // null terminate this parameter (parameters end with ; or end of line)
        char* end = strchr(f, ';');
        if (end) {
          *end = 0;
        }

        if (!strncmp(f, "am ", 3)) {
          f += 3;
          while (*NextWord(f)) {
            std::string coord = moveFinder.ToCoordinates(f);
            if (coord.size()) {
              avoid.insert(coord);
            }
            else {
              break;
            }
          }
        }
        else if (!strncmp(f, "bm ", 3)) {
          f += 3;
          while (*NextWord(f)) {
            std::string coord = moveFinder.ToCoordinates(f);
            if (coord.size()) {
              best.insert(coord);
            }
            else {
              break;
            }
          }
        }

        // move 'f' to beginning of next parameter
        if (end) {
          f = (end + 1);
          continue;
        }
        break;
      }

      if (avoid.empty() && best.empty()) {
        Output() << "error at line " << line
                 << ", no best or avoid moves specified";
        break;
      }

      if (!noClear) {
        engine->ClearSearchData();
      }
      if (printBoard) {
        engine->PrintBoard();
      }

      const std::string bestmove = engine->Go(maxDepth, 0, maxTime);
      Output(Output::NoPrefix) << "bestmove " << bestmove;

      engine->GetStats(&depth, &seldepth, &nodes, &qnodes, &time);
      if (bestmove.empty() ||
          (best.size() && !best.count(bestmove)) ||
          (avoid.size() && avoid.count(bestmove)))
      {
        Output() << "--- FAILED! line " << line << " ("
                 << Percent(passed, tested) << "%) " << f;
      }
      else {
        passed++;
        Output() << "--- Passed. line " << line << " ("
                 << Percent(passed, tested) << "%) " << f;
      }

      if (depth > maxSearchDepth) {
        maxSearchDepth = depth;
      }
      if ((minSearchDepth < 0) || (depth < minSearchDepth)) {
        minSearchDepth = depth;
      }
      if (seldepth > maxSeldepth) {
        maxSeldepth = seldepth;
      }
      if ((minSeldepth < 0) || (seldepth < minSeldepth)) {
        minSeldepth = seldepth;
      }
      totalDepth += depth;
      totalNodes += nodes;
      totalQnodes += qnodes;
      totalSeldepth += seldepth;
      totalTime += time;

      if (engine->StopRequested() || (maxCount && (tested >= maxCount))) {
        break;
      }
    }

    Output() << "--- Completed " << tested << " test positions";
    Output() << "--- Passed    " << passed << " passed ("
             << Percent(passed, tested) << "%)";
    Output() << "--- Time      " << totalTime << " ("
             << Average(totalTime, static_cast<uint64_t>(tested)) << " avg)";
    Output() << "--- Nodes     " << totalNodes << ", "
             << Rate((totalNodes / 1000), totalTime) << " KNodes/sec";
    Output() << "--- QNodes    " << totalQnodes << " ("
             << Percent(totalQnodes, totalNodes) << "%)";
    Output() << "--- Depth     " << minSearchDepth << " min, "
             << static_cast<int>(Average(totalDepth, tested)) << " avg, "
             << maxSearchDepth << " max";
    Output() << "--- SelDepth  " << minSeldepth << " min, "
             << static_cast<int>(Average(totalSeldepth, tested)) << " avg, "
             << maxSeldepth << " max";

    engine->ShowStatsTotals();
  }
  catch (const std::exception& e) {
    Output() << "ERROR: " << e.what();
  }
  catch (...) {
    Output() << "Unknown error!";
  }

  if (fp) {
    fclose(fp);
    fp = NULL;
  }
}
Пример #10
0
//-----------------------------------------------------------------------------
void PerftCommandHandle::Execute()
{
  if (!engine) {
    Output() << "Engine not set for '" << command << "' command";
    return;
  }

  engine->ClearStopFlags();

  if (fileName.empty()) {
    if (qperft) {
      engine->QPerft(maxDepth);
    }
    else {
      engine->Perft(maxDepth);
    }
    return;
  }

  FILE* fp = NULL;
  try {
    if (!(fp = fopen(fileName.c_str(), "r"))) {
      Output() << "Cannot open '" << fileName << "': " << strerror(errno);
      return;
    }

    const uint64_t start = Now();
    uint64_t pcount = 0;
    uint64_t nodes = 0;
    uint64_t qnodes = 0;
    bool done = false;
    char fen[16384];
    int positions = 0;

    for (int line = 1; !done && fgets(fen, sizeof(fen), fp); ++line) {
      char* f = fen;
      if (!*NextWord(f) || (*f == '#')) {
        continue;
      }

      positions++;
      if ((skip > 0) && (positions <= skip)) {
        continue;
      }

      Output() << fileName << " line " << line << ' ' << f;
      NormalizeString(f);
      if (!(f = const_cast<char*>(engine->SetPosition(f)))) {
        break;
      }

      while (f && *f) {
        // null terminate this parameter (parameters end with ; or end of line)
        char* end = strchr(f, ';');
        if (end) {
          *end = 0;
        }

        // process "D<depth> <leafs>" parameters (e.g. D5 4865609)
        if ((*NextWord(f) == 'D') && isdigit(f[1])) {
          if (!Process(f, pcount, nodes, qnodes)) {
            done = true;
            break;
          }
        }

        // move 'f' to beginning of next parameter
        if (end) {
          f = (end + 1);
          continue;
        }
        break;
      }

      if ((count > 0) && (positions >= count)) {
        break;
      }
    }

    const uint64_t time = (Now() - start);
    if (qperft) {
      Output() << "Total QPerft " << pcount << ' '
               << Rate((pcount / 1000), time) << " KNodes/sec";
      Output() << "Total Snodes " << (nodes - qnodes) << ", Qnodes " << qnodes
               << " (" << Percent(qnodes, pcount) << "%)";
    }
    else {
      Output() << "Total Perft " << pcount << ' '
               << Rate((pcount / 1000), time) << " KLeafs/sec";
      Output() << "Total Nodes " << nodes << ' '
               << Rate((nodes / 1000), time) << " KNodes/sec";
    }
  }
  catch (const std::exception& e) {
    Output() << "ERROR: " << e.what();
  }
  catch (...) {
    Output() << "Unknown error!";
  }

  if (fp) {
    fclose(fp);
    fp = NULL;
  }
}
Пример #11
0
bool Random::CoinFlip () {
    return Percent() >= 0.5;
}
Пример #12
0
void
isum(void)
{
	Inst *i;
	int pct, j, k;
	int total, loads, stores, arith, branch;
	int taken, powerreg, syscall, realarith, control;

	total = 0;
	loads = 0;
	stores = 0;
	arith = 0;
	branch = 0;
	taken = 0;
	powerreg = 0;
	syscall = 0;
	realarith = 0;
	control = 0;

	/* Compute the total so we can have percentages */
	for(j = 0; tables[j]; j++)
		for(k = tables[j]->nel; --k >= 0;) {
			i = &tables[j]->tab[k];
			if(i->name && i->func)
				total += i->count;
		}

	Bprint(bioout, "\nInstruction summary.\n\n");

	for(j = 0; tables[j]; j++) {
		for(k =tables[j]->nel; --k>=0; ) {
			i = &tables[j]->tab[k];
			if(i->name && i->func) {
				if(i->count == 0)
					continue;
				pct = Percent(i->count, total);
				if(pct != 0)
					Bprint(bioout, "%-8ud %3d%% %s\n",
					i->count, Percent(i->count, total), i->name);
				else
					Bprint(bioout, "%-8ud      %s\n",
					i->count, i->name);
	
				switch(i->type) {
				default:
					fatal(0, "isum bad stype %d\n", i->type);
				case Iload:
					loads += i->count;
					break;
				case Istore:
					stores += i->count;
					break;
				case Ilog:
				case Iarith:
					arith += i->count;
					break;
				case Ibranch:
					branch += i->count;
					taken += i->taken;
					break;
				case Ireg:
					powerreg += i->count;
					break;
				case Isyscall:
					syscall += i->count;
					break;
				case Ifloat:
					realarith += i->count;
					break;
				case Inop:
					arith += i->count;
					i->count -= nopcount;
					break;
				case Icontrol:
					control += i->count;
					break;
				}
			}
		}
	}

	Bprint(bioout, "\n%-8ud      Memory cycles\n", loads+stores+total);

	if(total == 0)
		return;

	Bprint(bioout, "%-8ud %3d%% Instruction cycles\n",
				total, Percent(total, loads+stores+total));

	Bprint(bioout, "%-8ud %3d%% Data cycles\n\n",
				loads+stores, Percent(loads+stores, loads+stores+total));	

	Bprint(bioout, "%-8ud %3d%% Stores\n", stores, Percent(stores, total));

	Bprint(bioout, "%-8ud %3d%% Loads\n", loads, Percent(loads, total));

	Bprint(bioout, "   %-8ud Store stall\n", stores*2);

	Bprint(bioout, "   %-8lud Load stall\n", loadlock);

	Bprint(bioout, "%-8ud %3d%% Arithmetic\n", arith, Percent(arith, total));

	Bprint(bioout, "%-8ud %3d%% Floating point\n",
					realarith, Percent(realarith, total));

	Bprint(bioout, "%-8ud %3d%% PowerPC special register load/stores\n",
					powerreg, Percent(powerreg, total));

	Bprint(bioout, "%-8ud %3d%% PowerPC control instructions\n",
					control, Percent(control, total));

	Bprint(bioout, "%-8ud %3d%% System calls\n", syscall, Percent(syscall, total));

	Bprint(bioout, "%-8ud %3d%% Branches\n", branch, Percent(branch, total));

	Bprint(bioout, "   %-8ud %3d%% Branches taken\n",
					taken, Percent(taken, branch));
}
Пример #13
0
void
isum(void)
{
	Inst *i;
	int pct, j;
	int total, loads, stores, arith, branch;
	int useddelay, taken, sparcreg, syscall, realarith;

	total = 0;
	loads = 0;
	stores = 0;
	arith = 0;
	branch = 0;
	useddelay = 0;
	taken = 0;
	sparcreg = 0;
	syscall = 0;
	realarith = 0;

	/* Compute the total so we can have percentages */
	for(j = 0; tables[j]; j++)
		for(i = tables[j]; i->func; i++)
			if(i->name && i->count)
				total += i->count;

	Bprint(bioout, "\nInstruction summary.\n\n");

	for(j = 0; tables[j]; j++) {
		for(i =tables[j]; i->func; i++) {
			if(i->name) {
				if(i->count == 0)
					continue;
				pct = Percent(i->count, total);
				if(pct != 0)
					Bprint(bioout, "%-8ud %3d%% %s\n",
					i->count, Percent(i->count, total), i->name);
				else
					Bprint(bioout, "%-8ud      %s\n",
					i->count, i->name);
	
				switch(i->type) {
				default:
					fatal(0, "isum bad stype %d\n", i->type);
				case Iload:
					loads += i->count;
					break;
				case Istore:
					stores += i->count;
					break;
				case Iarith:
					arith += i->count;
					break;
				case Ibranch:
					branch += i->count;
					taken += i->taken;
					useddelay += i->useddelay;
					break;
				case Ireg:
					sparcreg += i->count;
					break;
				case Isyscall:
					syscall += i->count;
					break;
				case Ifloat:
					realarith += i->count;
					break;
				case Inop:
					arith += i->count;
					i->count -= nopcount;
					break;
				}
			}
		}
	}

	total += anulled;
	Bprint(bioout, "\n%-8ud      Memory cycles\n", loads+stores+total);
	
	Bprint(bioout, "%-8ud %3d%% Instruction cycles\n",
				total, Percent(total, loads+stores+total));
	Bprint(bioout, "%-8lud %3ld%% Annulled branch cycles\n",
				anulled, Percent(anulled, total));

	Bprint(bioout, "%-8ud %3d%% Data cycles\n\n",
				loads+stores, Percent(loads+stores, loads+stores+total));	

	Bprint(bioout, "%-8ud %3d%% Stores\n", stores, Percent(stores, total));

	Bprint(bioout, "%-8ud %3d%% Loads\n", loads, Percent(loads, total));

	Bprint(bioout, "   %-8ud Store stall\n", stores*2);

	Bprint(bioout, "   %-8lud Load stall\n", loadlock);

	Bprint(bioout, "%-8ud %3d%% Arithmetic\n", arith, Percent(arith, total));

	Bprint(bioout, "%-8ud %3d%% Floating point\n",
					realarith, Percent(realarith, total));

	Bprint(bioout, "%-8ud %3d%% Sparc special register load/stores\n",
					sparcreg, Percent(sparcreg, total));

	Bprint(bioout, "%-8ud %3d%% System calls\n", syscall, Percent(syscall, total));

	Bprint(bioout, "%-8ud %3d%% Branches\n", branch, Percent(branch, total));

	Bprint(bioout, "   %-8ud %3d%% Branches taken\n",
					taken, Percent(taken, branch));

	Bprint(bioout, "   %-8ud %3d%% Delay slots\n",
					useddelay, Percent(useddelay, branch));

	Bprint(bioout, "   %-8ud %3d%% Unused delay slots\n", 
					nopcount, Percent(nopcount, branch));

	Bprint(bioout, "%-8ud %3d%% Program total delay slots\n",
					nopcount, Percent(nopcount, total));
}
Пример #14
0
 /**
  * Returns the median.
  *
  * @returns The median
  */
 double Histogram::Median () const {
   return Percent (50.0);
 }
Пример #15
0
int ModeHandler(int mode, char *textIn, int argc, char **argv)
{
	LcdSpi *lcd;
	Spi *spiBus0;
	ScreenData *screenBg;
	int result = 0;
	Fonts font;
	iconv_t ic;
	size_t res;
	char text[MAX_ISO8859_LEN] = "";
	
	memset(&font, 0, sizeof(Fonts));
	spiBus0 = SpiCreate(0);
	if (spiBus0 == NULL) {
		printf("SPI-Error\n");
		exit(EXITCODE_ERROR);
	}
	lcd = LcdOpen(spiBus0);
	if (!lcd) {
		printf("LCD-Error\n");
		exit(EXITCODE_ERROR);
	}
	if (gConfig.mIsInit == 1) {
		LcdInit(lcd);
	} else if (gConfig.mIsInit == 2) {
		LcdUninit(lcd);
		exit(EXITCODE_OK);
	}
	if (gConfig.mIsBgLight) {
		LcdSetBgLight(lcd, gConfig.mBgLight & 1, gConfig.mBgLight & 2, gConfig.mBgLight & 4);
	}
	screenBg = ScreenInit(LCD_X, LCD_Y);
	if (!screenBg) {
		printf("Screen-Error\n");
		exit(EXITCODE_ERROR);
	}
	ScreenClear(screenBg);
	if (gConfig.mBgFilename) {
		if (ScreenLoadImage(screenBg, gConfig.mBgFilename, gConfig.mBgOffX, gConfig.mBgOffY) != 0) {
			ScreenClear(screenBg);
		}
	}
	
	if (textIn) {
		int testInLen = strlen(textIn);
		char **inPtr = &textIn;
		char *outPtr = &text[0];
		
		ic = iconv_open("ISO-8859-1", "UTF-8");
		if (ic != (iconv_t)(-1)) {
			size_t inBytesLeft = testInLen;
			size_t outBytesLeft = sizeof(text) - 1;
		   
			res = iconv(ic, inPtr, &inBytesLeft, &outPtr, &outBytesLeft);
			if ((int)res != -1 && outBytesLeft) {
				outPtr[0] = 0;
			} else {
				strncpy(text, textIn, sizeof(text) - 1);
				text[sizeof(text) - 1] = 0;
			}
			iconv_close(ic);
		}
	}
	
	//printf("Mode: %i\n", mode);
	switch (mode) {
	case OPT_YESNO:
		LoadFonts(&font);
		result = YesNo(lcd, &font, text, screenBg);
		break;
	case OPT_OK:
		LoadFonts(&font);
		result = Ok(lcd, &font, text, screenBg);
		break;
	case OPT_MENU:
		LoadFonts(&font);
		result = Menu(lcd, &font, screenBg, optind, argc, argv);
		break;
	case OPT_IPV4:
		LoadFonts(&font);
		result = Ipv4(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_SUBNETMASK:
		LoadFonts(&font);
		result = Subnetmask(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_INFO:
		LoadFonts(&font);
		result = Info(lcd, &font, text, screenBg);
		break;
	case OPT_BUTTONWAIT:
		result = ButtonWait();
		break;
	case OPT_INTINPUT:
		LoadFonts(&font);
		result = IntInput(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_PROGRESS:
		LoadFonts(&font);
		result = Progress(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	case OPT_PERCENT:
		LoadFonts(&font);
		result = Percent(lcd, &font, text, screenBg, optind, argc, argv);
		break;
	default:
		break;
	}
	
	if (font.mSystem) {
		//FontDestroy(font.mSystem);
	}
	if (font.mInternal) {
		//FontDestroy(font.mInternal);
	}

	if (gConfig.mIsClear) {
		LcdCls(lcd);
	}
	ScreenDestroy(screenBg);
	LcdCleanup(lcd);
	SpiDestroy(spiBus0);
	
	return result;
}
Пример #16
0
void
isum(void)
{
	Inst *i;
	int total, loads, stores, arith, branch, realarith;
	int useddelay, taken, mipreg, syscall;
	int ldsunused, ldsused, ltotal;
	int pct, j;

	total = 0;
	loads = 0;
	stores = 0;
	arith = 0;
	branch = 0;
	useddelay = 0;
	taken = 0;
	mipreg = 0;
	syscall = 0;
	realarith = 0;

	/* Compute the total so we can have percentages */
	for(i = itab; i->func; i++)
		if(i->name && i->count)
			total += i->count;

	for(i = ispec; i->func; i++) {
		if(i->name && i->count) {
		}
	}
	/* Compute the total so we can have percentages */
	for(j = 0; tables[j]; j++) {
		for(i = tables[j]; i->func; i++) {
			if(i->name && i->count) {
				/* Dont count floating point twice */
				if(strcmp(i->name, "cop1") == 0)	
					i->count = 0;
				else
					total += i->count;
			}
		}
	}

	Bprint(bioout, "\nInstruction summary.\n\n");

	for(j = 0; tables[j]; j++) {
		for(i =tables[j]; i->func; i++) {
			if(i->name) {
				/* This is gross */
				if(strcmp(i->name, INOPINST) == 0)
					i->count -= nopcount;
				if(i->count == 0)
					continue;
				pct = Percent(i->count, total);
				if(pct != 0)
					Bprint(bioout, "%-8ud %3d%% %s\n",
						i->count, Percent(i->count,
						total), i->name);
				else
					Bprint(bioout, "%-8ud      %s\n",
						i->count, i->name);


				switch(i->type) {
				default:
					fatal(0, "isum bad stype %d\n", i->type);
				case Iload:
					loads += i->count;
					break;
				case Istore:
					stores += i->count;
					break;
				case Iarith:
					arith += i->count;
					break;
				case Ibranch:
					branch += i->count;
					taken += i->taken;
					useddelay += i->useddelay;
					break;
				case Ireg:
					mipreg += i->count;
					break;
				case Isyscall:
					syscall += i->count;
					break;
				case Ifloat:
					realarith += i->count;
					break;
				}
		
			}
		}
	}

	Bprint(bioout, "\n%-8ud      Memory cycles\n", loads+stores+total);	
	Bprint(bioout, "%-8ud %3d%% Instruction cycles\n",
			total, Percent(total, loads+stores+total));
	Bprint(bioout, "%-8ud %3d%% Data cycles\n\n",
			loads+stores, Percent(loads+stores, loads+stores+total));	

	Bprint(bioout, "%-8ud %3d%% Stores\n", stores, Percent(stores, total));
	Bprint(bioout, "%-8ud %3d%% Loads\n", loads, Percent(loads, total));

	/* Delay slots for loads/stores */
	ldsunused = nopcount-(branch-useddelay);
	ldsused = loads-ldsunused;
	ltotal = ldsused + ldsunused;
	Bprint(bioout, "   %-8ud %3d%% Delay slots\n",
			ldsused, Percent(ldsused, ltotal));

	Bprint(bioout, "   %-8ud %3d%% Unused delay slots\n", 
			ldsunused, Percent(ldsunused, ltotal));

	Bprint(bioout, "%-8ud %3d%% Arithmetic\n",
			arith, Percent(arith, total));

	Bprint(bioout, "%-8ud %3d%% Floating point\n",
			realarith, Percent(realarith, total));

	Bprint(bioout, "%-8ud %3d%% Mips special register load/stores\n",
			mipreg, Percent(mipreg, total));

	Bprint(bioout, "%-8ud %3d%% System calls\n",
			syscall, Percent(syscall, total));

	Bprint(bioout, "%-8ud %3d%% Branches\n",
			branch, Percent(branch, total));

	Bprint(bioout, "   %-8ud %3d%% Branches taken\n",
			taken, Percent(taken, branch));

	Bprint(bioout, "   %-8ud %3d%% Delay slots\n",
			useddelay, Percent(useddelay, branch));

	Bprint(bioout, "   %-8ud %3d%% Unused delay slots\n", 
			branch-useddelay, Percent(branch-useddelay, branch));

	Bprint(bioout, "%-8ud %3d%% Program total delay slots\n",
			nopcount, Percent(nopcount, total));
}