Ejemplo n.º 1
0
void BLMap::Generate()
{
    for (uint i=0 ; i<20 ; ++i)
    {
        Step(i);
    }

    ConvertTypeToTiles();
}
Ejemplo n.º 2
0
void ParallelSimulator::Simulate(int steps) {
    for (int i = 0; i < steps; i++) {
	Step();
        swap(state_, next_state_);
    }
    for (int row = first_row_; row <= last_row_; row++) {
	MPI_Send((void*) state_.GetRow(row), state_.m(), MPI_CHAR, 0, 0, MPI_COMM_WORLD);
    }
}
Ejemplo n.º 3
0
void IOService::Run()
{
    while (!exitRequest) {
        Step();

        // NOTE: I want to suppress energy impact if possible.
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}
Ejemplo n.º 4
0
unsigned int RunInterpreter()
{
	Running = true;
	
	while(Running)
		Step();
		
	return Registers[r0];
}
/******************************************************************************
 * 函 数 名:StepZ
 * 功能描述:驱动Z轴1步
 * 输入参数:行进方向(int)("0"为反向,"1"为正向)
 * 返 回 值:无
 ******************************************************************************/
void CTB_Stepper::StepZ(int dir) 
{
	switch(dir)
	{
		case 0:digitalWrite(PinZ_CW,LOW); break;
		case 1:digitalWrite(PinZ_CW,HIGH);
	}
	Step(SMPinZ);
}
Ejemplo n.º 6
0
void MoveMonitor::Terminate()
{
	// 清除当前移动路径
	m_Path.clear();
	Step(APoint(0,0));
	SetMoveTimeCost(0);
	SetMoveTimeCorrect(0);
	m_CurrPointOffset = Point::ZERO;
}
Ejemplo n.º 7
0
void Continue()
{
    while(1)
    {
       enum RETURNCODE ret = Step();
       if (ret == ERROR) exit(1);
       if (ret != OK) return;
    }
}
Ejemplo n.º 8
0
u32 CDead6800::Execute(u32 c)
{
u32 c1 = Cycle + c;
u32 c2 = Cycle;

while(Cycle < c1)
	Step();
return(Cycle - c2);
}
Ejemplo n.º 9
0
		//public interfae: whether exist a path from [srcx, srcy] to [desx, desy]
		bool findPath(const Step src, const Step des)
		{
			if(!outOfBorder(src.x, src.y) || !outOfBorder(des.x, des.y))
				return false;

			m_path.push_back(src);     
			m_maze[src.x][src.y] = -1;  //-1 indicates this point has already been visited
			while(m_path.size()> 0)
			{	
				Step cur = m_path[m_path.size() - 1]; //get the top point from path stack
				if(cur.x == des.x && cur.y == des.y)  //already reach to the destination 
				{
					output();
					return true;
				}

				if(outOfBorder(cur.x, cur.y-1) && m_maze[cur.x][cur.y-1] == 0)
				{   
					m_path.push_back(Step(cur.x, cur.y-1));
					m_maze[cur.x][cur.y-1] = -1;
				}
				else  if(outOfBorder(cur.x+1, cur.y) && m_maze[cur.x+1][cur.y] == 0)
				{
					m_path.push_back(Step(cur.x+1, cur.y));
					m_maze[cur.x+1][cur.y] = -1;
				}
				else  if(outOfBorder(cur.x, cur.y+1) && m_maze[cur.x][cur.y+1] == 0)
				{
					m_path.push_back(Step(cur.x, cur.y+1));
					m_maze[cur.x][cur.y+1] = -1;
				}
				else  if(outOfBorder(cur.x-1, cur.y) && m_maze[cur.x-1][cur.y] == 0)
				{
					m_path.push_back(Step(cur.x-1, cur.y));
					m_maze[cur.x-1][cur.y] = -1;
				}
				else
				{
					m_path.erase(m_path.end() - 1); 
				}
			}

			return false;
		}	
Ejemplo n.º 10
0
//=============================================================================
//	eZ80::Update
//-----------------------------------------------------------------------------
void eZ80::Update(int int_len, int* nmi_pending)
{
	if(!iff1 && halted)
		return;
	haltpos = 0;
	// INT check separated from main Z80 loop to improve emulation speed
	while(t < int_len)
	{
		if(iff1 && t != eipos) // int enabled in CPU not issued after EI
		{
			Int();
			break;
		}
		Step();
		if(halted)
			break;
	}
	eipos = -1;
	if(fast_emul)
	{
		while(t < frame_tacts)
		{
			StepF();
		}
	}
	else
	{
		while(t < frame_tacts)
		{
			Step();
//			if(*nmi_pending)
//			{
//				--*nmi_pending;
//				if(pc >= 0x4000)
//				{
//					Nmi();
//					*nmi_pending = 0;
//				}
//			}
		}
	}
	t -= frame_tacts;
	eipos -= frame_tacts;
}
Ejemplo n.º 11
0
	bool Statement::Step()
	{
		bool MoreData;
		bool Success = Step(MoreData);
		
		if (!Success)
			return false;
		else
			return MoreData;
	}
Ejemplo n.º 12
0
bool Animal::MoveTo(const sf::Vector2i& dst)
{
	while (dst != GetLocation())
	{
		if (!Step(dst))
			return false;
	}

	return true;
}
Ejemplo n.º 13
0
 void Base64Stream::flush()
   {
     if( !Cursor ) return;
     Convert();
     switch( Cursor ){
       case 1:  Data[ 0x02 ] = '=';
       case 2:  Data[ 0x03 ] = '=';
     }
     Step();
   }
void PhysicsEngine::PhysicsStep()
{
    for (EllipsoidBody* body : _ellipsoid_bodies)
    {
        body->velocity += _current_scene->gravity * body->gravity_scale;
        Step(*body);
        body->parent->location += body->velocity;
        body->velocity *= 0.8f;
    }
}
Ejemplo n.º 15
0
TextPointer*
PositionAtOffsetIterator::GetTextPointer (int offset, LogicalDirection dir)
{
	while (Step (&offset)) ;

	if (element == NULL)
		return NULL;

	return new TextPointer (element, location, dir);
}
Ejemplo n.º 16
0
	__forceinline void Step(SampleType& mixl, SampleType& mixr)
	{
		SampleType oLeft,oRight,oDsp;

		Step(oLeft,oRight,oDsp);

		*VolMix.DSPOut+=oDsp;
		mixl+=oLeft;
		mixr+=oRight;
	}
Ejemplo n.º 17
0
// Used by non-thread mode. Meant to be efficient.
int RunCycles(int cycles)
{
    // First, let's run a few cycles with no idle skipping so that things can
    // progress a bit.
    for (int i = 0; i < 8; i++)
    {
        if (g_dsp.cr & CR_HALT)
            return 0;
        Step();
        cycles--;
        if (cycles < 0)
            return 0;
    }

    while (true)
    {
        // Next, let's run a few cycles with idle skipping, so that we can skip
        // idle loops.
        for (int i = 0; i < 8; i++)
        {
            if (g_dsp.cr & CR_HALT)
                return 0;
            // Idle skipping.
            if (DSPAnalyzer::code_flags[g_dsp.pc] & DSPAnalyzer::CODE_IDLE_SKIP)
                return 0;
            Step();
            cycles--;
            if (cycles < 0)
                return 0;
        }

        // Now, lets run some more without idle skipping.
        for (int i = 0; i < 200; i++)
        {
            Step();
            cycles--;
            if (cycles < 0)
                return 0;
            // We don't bother directly supporting pause - if the main emu pauses,
            // it just won't call this function anymore.
        }
    }
}
Ejemplo n.º 18
0
//----------------------------------------------------------------------------------------------------
void GBEmulator::Update()
{
    const float    k_fFrameRate     = static_cast<float>( GBCpu::CLOCK_SPEED ) / static_cast<float>( kMaxCyclesPerFrame );
    const float    k_fFrameTime     = 1000.f / static_cast<float>( k_fFrameRate );

    if( m_bCartridgeLoaded )
    {
        m_fElapsedTime += static_cast<float>( SDL_GetTicks() ) - m_fElapsedTime;

        if( m_fElapsedTime >= m_fNextFrame )
        {
            if( !m_bDebugPaused )
            {
                float fDelta = m_fElapsedTime - m_fNextFrame;

                // Make sure we don't render faster than our framerate
                fDelta = fDelta > k_fFrameTime ? k_fFrameTime : fDelta;

                // Determine how much time was spend idle this frame since the end of the last emulation step
                m_fIdleTime += m_fNextFrame - m_fLastFrame;
                ++m_u32TotalFrames;

                // Calculate the idle time over the last second and reset counters
                if( static_cast<float>( m_u32TotalFrames ) >= k_fFrameRate )
                {
                    m_fAvgIdleTime      = static_cast<float>( m_fIdleTime / m_u32TotalFrames );
                    m_fIdleTime         = 0;
                    m_u32TotalFrames    = 0;
                }

                // Set the next frame render time
                m_fNextFrame = m_fElapsedTime + k_fFrameTime - fDelta;

                Step();

                // Calculate the last frame time after emulation step
                m_fLastFrame = static_cast<float>( SDL_GetTicks() );

                GTimer()->Update();

                // If the cart has a battery and something has changed, we need to update our .sav file
                if(     m_pCartridge->HasBattery()
                    &&  m_pCartridge->IsRamDirty() )
                {
                    m_pCartridge->FlushRamToSaveFile( GB_BATTERY_DIRECTORY );
                }
            }
        }
        else if( m_fNextFrame - m_fElapsedTime > 1.f )
        {
            // Wait a bit if we can, so we don't hog the cpu
            SDL_Delay( 1 );
        }
    }
}
Ejemplo n.º 19
0
 int Start(std::size_t terminate_)
 {
     std::size_t step = 0;
     while (step++ < terminate_)
     {
         this->Next(step);
         Step();
         // if (std::fabs(this->swarm.worst().position.fitness - this->swarm.best().position.fitness) < 0.001) return step;
     }
     return step;
 }
Ejemplo n.º 20
0
HTML_Element* SVGAreaIterator::Next()
{
	if (!m_current_elm && !m_prev_found)
		m_current_elm = m_doc_ctx->GetSVGRoot();
	else if (m_current_elm)
		m_current_elm = m_current_elm->Next();

	m_next_found = Step(TRUE /* forward */);

	return m_next_found ? m_current_elm : NULL;
}
Ejemplo n.º 21
0
real Burgers(real x, real t)
{
	real t2;

	t2 = t;

	if (t2 == 0.)
		return Step(x);
	else
		return .5*( 1 - tanh(0.25*Re*(x-0.5*t2)) );
}
Ejemplo n.º 22
0
u32 CDeadZ80::Execute(u32 c)
{
	unsigned long start = cycles;
	unsigned long end = cycles + c;

	while(cycles < end) {
		if(Step() > 0)
			return(BAD_OPCODE);
	}
	return(end - start);
}
Ejemplo n.º 23
0
HTML_Element* SVGAreaIterator::Prev()
{
	if (!m_current_elm && !m_next_found)
		m_current_elm = m_doc_ctx->GetSVGRoot()->LastChild();
	else if (m_current_elm)
		m_current_elm = m_current_elm->Prev();

	m_prev_found = Step(FALSE /* backward */);

	return m_prev_found ? m_current_elm : NULL;
}
Ejemplo n.º 24
0
void StreamPower::Start()
{
	char fname[100];
	sprintf_s(fname, "erosion_initial.asc");
	PrintState(fname);

	time = 0;
	while (time < duration)
	{
		Step();
	}
}
Ejemplo n.º 25
0
void CPU::Run()
{
    // Ignore this call if we are already running
    if (_runState == CPURunState::Running)
        return;

    _runState = CPURunState::Running;

    // Loop until something stops the CPU
    while (_runState == CPURunState::Running)
        Step();
}
Ejemplo n.º 26
0
uint32_t Timer::Loop()
{
	for (; m_continue;)
	{
		uint32_t result = Step();
		if (result > 0)
		{
			return result;
		}
	}
	return 0;
}
Ejemplo n.º 27
0
//------------------------------------------------------------------------------
bool Propagator::Step(Real dt)
{
    #ifdef DEBUG_PROPAGATOR_FLOW
       MessageInterface::ShowMessage(wxT("^"));
    #endif
    if (initialized)
    {
        stepSize = dt;
        return Step();
    }
    return false;
}
Ejemplo n.º 28
0
/** @brief perform steps until error <= max_allowed_error.
 *
 * The validity of the result can be checked with \ref flag()
 * @param max_steps the maximun amount of step to do before giving up
 * @return the number of steps taken
 */
int InvKinematic::Iterate(int max_steps) {
  double error;
  flag_ = NOTHING_WRONG;
  const int end = pivot_count_ -1;
  // store original angles and limits of the pivots
  double original_angles[end];
  double original_max[end];
  for (int i = 0; i < end; ++i) {
    original_angles[i] = pivots_[i]->angle();
    original_max[i] = pivots_[i]->abs_max_angle();
    pivots_[i]->set_abs_max_angle(M_PI);
    // setting abs_max_angle clears the current angle, so let's restore it:
    pivots_[i]->set_angle(original_angles[i]);
  }
  for (int i = 0; i < max_steps; ++i) {
    error = Step();
    if (flag_ != NOTHING_WRONG) {
      // restore original values
      for (int j = 0; j < end; ++j) {
        pivots_[j]->set_abs_max_angle(original_max[j]);
        pivots_[j]->set_angle(original_angles[j]);
      }
      return i;
    }
    if (error <= max_allowed_error_) {
      // success. now let's see if those angles actually available
      int success = 0;
      double angle;
      for (int j = 0; j < end; ++j) {
        angle = pivots_[j]->angle();
        pivots_[j]->set_abs_max_angle(original_max[j]);
        // this has cleared the angle, so let's try setting it again:
        if (pivots_[j]->set_angle(angle)) {
          ++success;
        }
      }
      if (success < end) {
        for (int j = 0; j < end; ++j) {
          pivots_[j]->set_angle(original_angles[j]);
          flag_ = NEW_ANGLE_OUT_OF_REACH;
        }
      }
      return i;
    }
  }
  flag_ = EXCEEDED_MAX_STEPS;
  // restore original values
  for (int j = 0; j < end; ++j) {
    pivots_[j]->set_abs_max_angle(original_max[j]);
    pivots_[j]->set_angle(original_angles[j]);
  }
  return(max_steps);
}
Ejemplo n.º 29
0
void PrivilegeDb::GetGroups(std::vector<std::string> &groups)
{
   try_catch<void>([&] {
        auto command = getStatement(StmtType::EGetGroups);

        while (command->Step()) {
            std::string groupName = command->GetColumnString(0);
            LogDebug("Group " << groupName);
            groups.push_back(groupName);
        };
    });
}
Ejemplo n.º 30
0
/********************************************************************
 * Function:        void ProcessIO(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        This function is a place holder for other user
 *                  routines. It is a mixture of both USB and
 *                  non-USB tasks.
 *
 * Note:            None
 *******************************************************************/
void ProcessIO(void)
{   
    //BMA150_REG reg_MSB;
    //BMA150_REG reg_LSB;
	unsigned int w1;

	if(DemoIntroState == 0xFF)
    {
	    //BL_CheckLoaderEnabled();
		
		if (g_ballGth == 0 && g_ballGtt == 0)
			Step(0.04f, 1);
		else
			Step(0.04f, 0);
		DrawScene();

		if (g_endGame == 1)
		{
			g_endGame = 0;
			DemoIntroState = 8;
		}
		
		w1 = mTouchReadButton(3);
		if (w1 < 600)
		{
			DemoIntroState = 6;
			g_menuSelected = 0;
			FillDisplay(0x00);
		}
		
    }
	
    // User Application USB tasks
    //if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;

	// Soft Start the APP_VDD
    if(AppPowerReady() == FALSE) return;

    DemoIntroduction();
}		//end ProcessIO