// fills attributes with statistics information
void CImpostorSceneNode::getStats( io::IAttributes* statistics)
{
	statistics->setAttribute("Nodes", s32(Impostors.size()));
	//statistics->setAttribute("Lights", 0 ); // todo
	statistics->setAttribute("Buffers", s32(Buffers.size()));
	s32 TotalSlots=0, UsedSlots=0;
	for (u32 i=0; i<Buffers.size(); ++i)
	{
		TotalSlots+= Buffers[i].Slots.size();
		UsedSlots += Buffers[i].Slots.size() - Buffers[i].FreeSlots;
	}
	statistics->setAttribute("TotalSlots", TotalSlots);
	statistics->setAttribute("UsedSlots", UsedSlots);
	statistics->setAttribute("SlotUsage%", f32(UsedSlots)/ f32(TotalSlots) * 100.0f);

	statistics->setAttribute("TotalTextureMB", f32(Buffers.size()*TextureWidth*TextureWidth*4)/1048576.0f );


	statistics->setAttribute("QueueLength", s32(RenderQueue.size()));
	//statistics->setAttribute("AverageQueueLength", 0); // todo

	// todo
	statistics->setAttribute("RenderCount", RenderCount);
	statistics->setAttribute("CacheHit%", (f32(CacheHits) / f32(CacheHits + CacheMisses)) * 100.0f );
	statistics->setAttribute("CacheHits", CacheHits);
	statistics->setAttribute("CacheMisses", CacheMisses);

	//statistics->setAttribute("LastRegisterTime", 0);
	//statistics->setAttribute("TotalRegisterTime", 0);
	//statistics->setAttribute("AvgRegisterTime", 0);

	//statistics->setAttribute("LastRenderTime", 0);
	//statistics->setAttribute("TotalRenderTime", 0);
	//statistics->setAttribute("AvgRenderTime", 0);
}
void	CSoundRender_TargetD::fill_parameters()
{
	inherited::fill_parameters();

	// 1. Set 3D params (including mode)
	{
		Fvector&			p_pos	= pEmitter->p_source.position;

		R_CHK(pControl->SetMode			(pEmitter->b2D ? DS3DMODE_HEADRELATIVE : DS3DMODE_NORMAL,DS3D_DEFERRED));
		R_CHK(pControl->SetMinDistance	(pEmitter->p_source.min_distance,	DS3D_DEFERRED));
		R_CHK(pControl->SetMaxDistance	(pEmitter->p_source.max_distance,	DS3D_DEFERRED));
		R_CHK(pControl->SetPosition		(p_pos.x,p_pos.y,p_pos.z,			DS3D_DEFERRED));
	}
	
	// 2. Set 2D params (volume, freq) + position(rewind)
	{
		float	_volume				= pEmitter->smooth_volume;				clamp	(_volume,EPS_S,1.f);
		s32		hw_volume			= iFloor	(7000.f*logf(_volume)/5.f);	clamp	(hw_volume,DSBVOLUME_MIN,DSBVOLUME_MAX);
		if (_abs(hw_volume-cache_hw_volume)>50){
			cache_hw_volume			= hw_volume;
			R_CHK(pBuffer->SetVolume(hw_volume));
		}

		float	_freq				= pEmitter->p_source.freq;
		s32		hw_freq				= iFloor	(_freq * float(wfx.nSamplesPerSec) + EPS);
		if (_abs(hw_freq-cache_hw_freq)>50)	{
			cache_hw_freq			= hw_freq;
			s32		hw_freq_set		= hw_freq;
			clamp	(hw_freq_set,s32(SoundRenderD->dsCaps.dwMinSecondarySampleRate),s32(SoundRenderD->dsCaps.dwMaxSecondarySampleRate));
			R_CHK	(pBuffer->SetFrequency	( hw_freq_set	));
		}
	}
}
Beispiel #3
0
 inline s32 Ceiling(const T& val)
 {
   if(val == s32(val))
     return s32(val);
   else if(val < T(0))
     return s32(val);
   else
     return (s32(val) + 1);
 }
Beispiel #4
0
 inline s32 Floor(const T& val)
 {
   if(val == s32(val))
     return s32(val);
   else if(val < T(0))
     return (s32(val) - 1);
   else
     return s32(val);
 }
Beispiel #5
0
 bool Jungle::treeExistAt(core::vector3df position)
 {
     //
     position /= this->getScale();
     s32 idx = s32(position.X / CHUNK_RENDER_DIMENSION);
     s32 idy = s32(position.Z / CHUNK_RENDER_DIMENSION);
     if(idx < 0)return false;
     if(idy < 0)return false;
     if(idx >= WORLD_SIZE)return false;
     if(idy >= WORLD_SIZE)return false;
     return chunks[idx][idy].treeExistAt(position);
 }
Beispiel #6
0
void setNewActivePhysicsRect(daMegaGoomba_c *actor, Vec *scale) {
	float amtX = scale->x * 0.5f;
	float amtY = scale->y * 0.5f;

	actor->belowSensor.flags = SENSOR_LINE;
	actor->belowSensor.lineA = s32((amtX * -28.0f) * 4096.0f);
	actor->belowSensor.lineB = s32((amtX * 28.0f) * 4096.0f);
	actor->belowSensor.distanceFromCenter = 0;

	actor->adjacentSensor.flags = SENSOR_LINE;
	actor->adjacentSensor.lineA = s32((amtY * 4.0f) * 4096.0f);
	actor->adjacentSensor.lineB = s32((amtY * 32.0f) * 4096.0f);
	actor->adjacentSensor.distanceFromCenter = s32((amtX * 46.0f) * 4096.0f);

	u8 cat1 = 3, cat2 = 0;
	u32 bitfield1 = 0x6f, bitfield2 = 0xffbafffe;

	ActivePhysics::Info info = {
		0.0f, amtY*57.0f, amtX*20.0f, amtY*31.0f,
		cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
	actor->aPhysics.initWithStruct(actor, &info);

	// Original trapezium was -12,12 to -48,48
	ActivePhysics::Info left = {
		amtX*-32.0f, amtY*55.0f, amtX*12.0f, amtY*30.0f,
		cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
	actor->leftTrapAPhysics.initWithStruct(actor, &left);
	actor->leftTrapAPhysics.trpValue0 = amtX * 12.0f;
	actor->leftTrapAPhysics.trpValue1 = amtX * 12.0f;
	actor->leftTrapAPhysics.trpValue2 = amtX * -12.0f;
	actor->leftTrapAPhysics.trpValue3 = amtX * 12.0f;
	actor->leftTrapAPhysics.collisionCheckType = 3;

	ActivePhysics::Info right = {
		amtX*32.0f, amtY*55.0f, amtX*12.0f, amtY*30.0f,
		cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
	actor->rightTrapAPhysics.initWithStruct(actor, &right);
	actor->rightTrapAPhysics.trpValue0 = amtX * -12.0f;
	actor->rightTrapAPhysics.trpValue1 = amtX * -12.0f;
	actor->rightTrapAPhysics.trpValue2 = amtX * -12.0f;
	actor->rightTrapAPhysics.trpValue3 = amtX * 12.0f;
	actor->rightTrapAPhysics.collisionCheckType = 3;

	ActivePhysics::Info stalk = {
		0.0f, amtY*12.0f, amtX*28.0f, amtY*12.0f,
		cat1, cat2, bitfield1, bitfield2, 0, &dEn_c::collisionCallback};
	actor->stalkAPhysics.initWithStruct(actor, &stalk);

}
Beispiel #7
0
s32 CGUIScrollBar::getPosFromMousePos(s32 x, s32 y) const
{
	if (Horizontal)
	{
		const f32 w = RelativeRect.getWidth() - f32(RelativeRect.getHeight())*3.0f;
		const f32 p = x - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight()*1.5f;
		return s32( p/w * f32(Max) );
	}
	else
	{
		const f32 h = RelativeRect.getHeight() - f32(RelativeRect.getWidth())*3.0f;
		const f32 p = y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth()*1.5f;
		return s32( p/h * f32(Max) );
	}
}
Beispiel #8
0
inline
void
op_diagvec::apply(Mat<typename T1::elem_type>& out, const Op<T1, op_diagvec>& X)
  {
  arma_extra_debug_sigprint();
  
  typedef typename T1::elem_type eT;
  
  const s32 id = (X.aux_u32_b > 0) ? -s32(X.aux_u32_a) : s32(X.aux_u32_a);
  
  const unwrap_check<T1> tmp(X.m, out);
  const Mat<eT>& A     = tmp.M;

  out = A.diag(id);
  }
//*************************************************************************************
//
//*************************************************************************************
void CTraceRecorder::Analyse( SRegisterUsageInfo & register_usage )
{
	DAEDALUS_PROFILE( "CTraceRecorder::Analyse" );

	std::pair< s32, s32 >		reg_spans[ NUM_N64_REGS ];
	std::pair< s32, s32 >		invalid_span( std::pair< s32, s32 >( mTraceBuffer.size(), -1 ) );

	std::fill( reg_spans, reg_spans + NUM_N64_REGS, invalid_span );		// Set the interval to an invalid range

	for( u32 i = 0; i < mTraceBuffer.size(); ++i )
	{
		const STraceEntry & ti( mTraceBuffer[ i ] );
		const StaticAnalysis::RegisterUsage&	usage = ti.Usage;

		register_usage.RegistersRead |= usage.RegReads;
		register_usage.RegistersWritten |= usage.RegWrites;
		register_usage.RegistersAsBases |= usage.RegBase;

		u32		all_uses( usage.RegReads | usage.RegWrites | usage.RegBase );

		// Update the live span
		for( s32 reg = 1; reg < NUM_N64_REGS; ++reg )
		{
			if( all_uses & (1<<reg) )
			{
				if( s32( i ) < reg_spans[ reg ].first )		reg_spans[ reg ].first = i;
				if( s32( i ) > reg_spans[ reg ].second )	reg_spans[ reg ].second = i;
			}
		}
	}

	register_usage.SpanList.clear();
	register_usage.SpanList.reserve( NUM_N64_REGS );

	// Iterate through registers, inserting all that are used into span list
	for( u32 i = 0; i < NUM_N64_REGS; ++i )
	{
		s32		start( reg_spans[ i ].first );
		s32		end( reg_spans[ i ].second );

		if( start <= end )
		{
			SRegisterSpan	span( EN64Reg( i ), start, end );

			register_usage.SpanList.push_back( span );
		}
	}
}
Beispiel #10
0
// returns true on success
bool CImageLoaderRGB::readHeader(io::IReadFile* file, rgbStruct& rgb) const
{
	if ( file->read(&rgb.Header, sizeof(rgb.Header)) < s32(sizeof(rgb.Header)) )
		return false;

	// test for INTEL or BIG ENDIAN processor
	// if INTEL, then swap the byte order on 16 bit INT's to make them BIG ENDIAN
	// because that is the native format for the .rgb file
#ifndef __BIG_ENDIAN__
	rgb.Header.Magic     = os::Byteswap::byteswap(rgb.Header.Magic);
	rgb.Header.Storage   = os::Byteswap::byteswap(rgb.Header.Storage);
	rgb.Header.Dimension = os::Byteswap::byteswap(rgb.Header.Dimension);
	rgb.Header.Xsize     = os::Byteswap::byteswap(rgb.Header.Xsize);
	rgb.Header.Ysize     = os::Byteswap::byteswap(rgb.Header.Ysize);
	rgb.Header.Zsize     = os::Byteswap::byteswap(rgb.Header.Zsize);
	rgb.Header.Pixmin    = os::Byteswap::byteswap(rgb.Header.Pixmin);
	rgb.Header.Pixmax    = os::Byteswap::byteswap(rgb.Header.Pixmax);
	rgb.Header.Colormap  = os::Byteswap::byteswap(rgb.Header.Colormap);
#endif

	// calculate the size of the buffer needed: XSIZE * YSIZE * ZSIZE * BPC
	rgb.ImageSize = (rgb.Header.Xsize)*(rgb.Header.Ysize)*(rgb.Header.Zsize)*(rgb.Header.BPC);

	return true;
}
Beispiel #11
0
void	CActor::OnPrevWeaponSlot()
{
	u32 ActiveSlot = inventory().GetActiveSlot();
	if (ActiveSlot == NO_ACTIVE_SLOT) 
		ActiveSlot = inventory().GetPrevActiveSlot();

	if (ActiveSlot == NO_ACTIVE_SLOT) 
		ActiveSlot = KNIFE_SLOT;

	u32 NumSlotsToCheck = sizeof(SlotsToCheck)/sizeof(SlotsToCheck[0]);	
	u32 CurSlot		= 0;

	for (; CurSlot<NumSlotsToCheck; CurSlot++)
	{
		if (SlotsToCheck[CurSlot] == ActiveSlot) break;
	};

	if (CurSlot >= NumSlotsToCheck) 
		CurSlot	= NumSlotsToCheck-1; //last in row

	for (s32 i=s32(CurSlot-1); i>=0; i--)
	{
		if (inventory().ItemFromSlot(SlotsToCheck[i]))
		{
			if (SlotsToCheck[i] == ARTEFACT_SLOT) 
			{
				IR_OnKeyboardPress(kARTEFACT);
			}
			else
				IR_OnKeyboardPress(kWPN_1 + i);
			return;
		}
	}
};
Beispiel #12
0
void EventSystem::propagateMouseEvent(Event* event)
{
  updateCurrentViewStack(event);
  if(currentViewStack.size() == 0) { return; } // bail if no views, happens when mouse outside of window

//  logViewStack(currentViewStack);
  
  event->base.bubbles = true;
  event->base.stopDispatch = false;
  event->base.stopPropagation = false;
  EventType et = event->base.type;
  
  if((et == ET_MouseUp) || (et == ET_MouseDown))
  {
    propagateUpDownEvent(event);
    if(et == ET_MouseDown)
    {
      propagateFocusEvent(event);
    }
  }
  else
  {
    // propagate scroll/move
    event->base.target = currentViewStack.back();
    s32 targetIndex = s32(currentViewStack.size())-1;
    propagateEvent(currentViewStack, event, targetIndex);
  }
  
  // enter/leave
  if(et == ET_MouseMove)
  {
    propagateEnterLeaveEvent(event);
    previousMouseMoveStack = currentViewStack;
  }
}
Beispiel #13
0
bool CMotionStats::is_good_motion(u32 elems_checked) 
{
	u32 from_index;
	u32 to_index;

	if (index == 0) return true;
	else from_index = index-1;

	if (s32(index - elems_checked) < 0) return true;
	else to_index = index - elems_checked;
	
	bool bGood = true;
	float test_speed = _data[from_index].speed;
	
	for (u32 i=from_index; i>to_index;i--) {
		
		// считать только, если все элементы содержат одинаковые скорости	
		if (!fsimilar(test_speed,_data[i].speed)) break;

		float	cur_dist	= _data[i].position.distance_to(_data[i-1].position); 
		TTime	delta_t		= _data[i].time - _data[i-1].time;
		float	speed		= cur_dist * 1000.f / float(delta_t);
		
		if (fsimilar(_data[i-1].speed,0.0f)) continue; 
		
		if (speed * 5.f < _data[i].speed) {
			bGood = false;
			break;
		}
	}
	return bGood;
}
Beispiel #14
0
	void PPCXEmitter::BLE (const void *fnptr) {		
		CHECK_SMALL_JUMP

		s32 func =  (s32)fnptr - s32(code);
		u32 instr = (0x40810000 | (((s16)(((func)+1))) & 0xfffc));
		Write32(instr);
	}
// This method needs a properly cleaned error state before the checked instruction is called
bool COpenGLShaderMaterialRenderer::checkError(const irr::c8* type)
{
#if defined(GL_ARB_vertex_program) || defined(GL_NV_vertex_program) || defined(GL_ARB_fragment_program) || defined(GL_NV_fragment_program)
	GLenum g = glGetError();
	if (g == GL_NO_ERROR)
		return false;

	core::stringc errString = type;
	errString += " compilation failed";

	errString += " at position ";
	GLint errPos=-1;
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
	glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos );
#else
	glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos );
#endif
	errString += core::stringc(s32(errPos));
	errString += ":\n";
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
	errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_ARB));
#else
	errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_NV));
#endif
#else
	core::stringc errString("Shaders not supported.");
#endif
	os::Printer::log(errString.c_str(), ELL_ERROR);
	return true;
}
Beispiel #16
0
	void PPCXEmitter::BNE (const void *fnptr) {
		CHECK_SMALL_JUMP

		s32 func =  (s32)fnptr - s32(code);
		u32 instr = (0x40820000 | ( func & 0xfffc));
		Write32(instr);
	}
Beispiel #17
0
//! Sets the name of a material renderer.
void CNullDriver::setMaterialRendererName(s32 idx, const char* name)
{
	if (idx < s32(sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 ||
		idx >= (s32)MaterialRenderers.size())
		return;

	MaterialRenderers[idx].Name = name;
}
Beispiel #18
0
void GameScene::FogReveal(const vec3 &pos, u32 radius)
{
	if (!pFog)
		return;

	auto px = pos.x - 20.f;
	auto py = pos.y - 20.f;
	auto sx = s32((px / iTileSize) + iTileSize / 2) - 4;
	auto sy = s32((py / iTileSize) + iTileSize / 2) - 4;
	auto r = s32(radius);
	for (auto y = -r; y <= r; y++)
	{
		for (auto x = -r; x <= r; x++)
		{
			pFog->SetTileAt(sx + x, sy + y, 5); // 5 == ultimo tile, transparente
		}
	}
}
	//! event handlers
	void ObjectViewer::OnColumnClick(wxListEvent& event)
	{
		m_ColumnToSort = event.GetColumn();

		m_pObjectList->SortItems(ObjectViewer::ObjectViewerSort, (long)this);

		SHOOT_ASSERT(m_ColumnToSort >= 0 && m_ColumnToSort < s32(NumColumns), "Invalid Column Index");
		m_ColumSortDescending[m_ColumnToSort] = !m_ColumSortDescending[m_ColumnToSort];
	}
	//! updates the visitor	
	void FollowCameraPathVisitor::Update()
	{
		if(!m_bActive)
		{
			return;
		}

		f32 fRatio = m_fTimer/m_fDuration;
		m_pCamera->SetPosition(m_Path->GetPosition(m_CurrentElement, m_CurrentElement+1, fRatio));
		m_pCamera->SetLookAt(m_Path->GetLookAt(m_CurrentElement, m_CurrentElement+1, fRatio));

		if(m_fTimer < m_fDuration)
		{
			m_fTimer += g_fDeltaTime;
		}
		else if(m_CurrentElement < s32(m_Path->GetChildCount())-2)
		{
			++m_CurrentElement;
			f32 newDuration = m_Path->GetElement(m_CurrentElement)->GetFollowDuration();
			f32 fOverTime = (m_fTimer-m_fDuration)*(m_fDuration/newDuration);			
			m_fDuration = newDuration-fOverTime;
			m_fTimer = fOverTime + g_fDeltaTime;
		}
		else
		{
			m_iPlayCount++;
			switch(m_ePlaybackType)
			{
			case PT_Once:
				Leave();
				break;

			case PT_Loop:
				if((m_iMaxPlayCount < 0) || (m_iPlayCount < m_iMaxPlayCount))
				{
					m_CurrentElement = 0;
					f32 newDuration = m_Path->GetElement(m_CurrentElement)->GetFollowDuration();
					f32 fOverTime = (m_fTimer-m_fDuration)*(m_fDuration/newDuration);			
					m_fDuration = newDuration-fOverTime;
					m_fTimer = fOverTime + g_fDeltaTime;
				}
				else
				{
					Leave();
				}
				break;

			case PT_Toggle:
				SHOOT_WARNING(false, "FollowCameraPathVisitor Unsupported PlaybackType: PT_Toggle");
				Leave();
				break;
				
			default:
				Leave();
			}
		}		
	}
//*************************************************************************************
//
//*************************************************************************************
EMenuOption	IMainMenuScreen::AsMenuOption( s32 option )
{
	s32 m( option % s32(NUM_MENU_OPTIONS) );
	if( m < 0 )
		m += NUM_MENU_OPTIONS;

	DAEDALUS_ASSERT( m >= 0 && m < (s32)NUM_MENU_OPTIONS, "Whoops" );

	return EMenuOption( m );
}
//! Writes attributes of the element.
void CGUITabControl::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
{
	IGUITabControl::serializeAttributes(out,options);

	out->addInt ("ActiveTab",	ActiveTab);
	out->addBool("Border",		Border);
	out->addBool("FillBackground",	FillBackground);
	out->addInt ("TabHeight",	TabHeight);
	out->addEnum("TabVerticalAlignment", s32(VerticalAlignment), GUIAlignmentNames);
}
Beispiel #23
0
 void Jungle::addTreeAt(core::vector3df position,
                                 u8 segment_count,
                                 f32 min_rotation,
                                 f32 max_rotation,
                                 f32 branch_length,
                                 u8 branch_count,
                                 f32 max_radius,
                                 u8 ground_root_count,
                                 f32 leaf_width,
                                 f32 leaf_length,
                                 u8 leaf_segment,
                                 f32 leaf_stiffness,
                                 u8 leaf_type,
                                 u8 bark_type,
                                 u8 seed,
                                 bool instant)
 {
     position /= this->getScale();
     s32 idx = s32(position.X / CHUNK_RENDER_DIMENSION);
     s32 idy = s32(position.Z / CHUNK_RENDER_DIMENSION);
     if(idx < 0)return;
     if(idy < 0)return;
     if(idx >= WORLD_SIZE)return;
     if(idy >= WORLD_SIZE)return;
     s32 age = 0;
     if(instant)age = 10000;
     chunks[idx][idy].growTreeAt(position,
                                 segment_count,
                                 min_rotation,
                                 max_rotation,
                                 branch_length,
                                 branch_count,
                                 max_radius,
                                 ground_root_count,
                                 bark_type,
                                 leaf_width,
                                 leaf_length,
                                 leaf_segment,
                                 leaf_stiffness,
                                 leaf_type,
                                 seed,
                                 age);//(position, segment_count, min_rotation, max_rotation, branch_length, branch_count, seed);
 }
Beispiel #24
0
error_code cellAudioAdd6chData(u32 portNum, vm::ptr<float> src, float volume)
{
	cellAudio.trace("cellAudioAdd6chData(portNum=%d, src=*0x%x, volume=%f)", portNum, src, volume);

	auto g_audio = g_idm->lock<named_thread<audio_thread>>(0);

	if (!g_audio)
	{
		return CELL_AUDIO_ERROR_NOT_INIT;
	}

	if (portNum >= AUDIO_PORT_COUNT || !src || !src.aligned())
	{
		return CELL_AUDIO_ERROR_PARAM;
	}

	const audio_port& port = g_audio->ports[portNum];

	const auto dst = vm::ptr<float>::make(port.addr.addr() + s32(port.tag % port.block) * port.channel * 256 * u32{sizeof(float)});

	g_audio.unlock();

	if (port.channel == 6)
	{
		for (u32 i = 0; i < 256; i++)
		{
			dst[i * 6 + 0] += src[i * 6 + 0] * volume; // mix L ch
			dst[i * 6 + 1] += src[i * 6 + 1] * volume; // mix R ch
			dst[i * 6 + 2] += src[i * 6 + 2] * volume; // mix center
			dst[i * 6 + 3] += src[i * 6 + 3] * volume; // mix LFE
			dst[i * 6 + 4] += src[i * 6 + 4] * volume; // mix rear L
			dst[i * 6 + 5] += src[i * 6 + 5] * volume; // mix rear R
		}
	}
	else if (port.channel == 8)
	{
		for (u32 i = 0; i < 256; i++)
		{
			dst[i * 8 + 0] += src[i * 6 + 0] * volume; // mix L ch
			dst[i * 8 + 1] += src[i * 6 + 1] * volume; // mix R ch
			dst[i * 8 + 2] += src[i * 6 + 2] * volume; // mix center
			dst[i * 8 + 3] += src[i * 6 + 3] * volume; // mix LFE
			dst[i * 8 + 4] += src[i * 6 + 4] * volume; // mix rear L
			dst[i * 8 + 5] += src[i * 6 + 5] * volume; // mix rear R
			//dst[i * 8 + 6] += 0.0f; // side L
			//dst[i * 8 + 7] += 0.0f; // side R
		}
	}
	else
	{
		cellAudio.error("cellAudioAdd6chData(portNum=%d): invalid port.channel value (%d)", portNum, port.channel);
	}

	return CELL_OK;
}
//*************************************************************************************
//
//*************************************************************************************
void	IMainMenuScreen::Render()
{
	mpContext->ClearBackground();


	c32		valid_colour( mpContext->GetDefaultTextColour() );
	c32		invalid_colour( 200, 200, 200 );

	f32		min_scale( 0.60f );
	f32		max_scale( 1.0f );

	s32		SCREEN_LEFT = 20;
	s32		SCREEN_RIGHT = SCREEN_WIDTH - 20;

	mpContext->SetFontStyle( CUIContext::FS_HEADING );

	s32		y( TEXT_AREA_TOP + mpContext->GetFontHeight() );

	for( s32 i = -2; i <= 2; ++i )
	{
		EMenuOption		option( AsMenuOption( mCurrentOption + i ) );
		c32				text_col( IsOptionValid( option ) ? valid_colour : invalid_colour );
		const char *	option_text( gMenuOptionNames[ option ] );
		u32				text_width( mpContext->GetTextWidth( option_text ) );

		f32				diff( f32( mCurrentOption + i ) - mCurrentDisplayOption );
		f32				dist( Abs( diff ) );

		s32				centre( ( SCREEN_WIDTH - text_width ) / 2 );
		s32				extreme( diff < 0 ? SCREEN_LEFT : s32( SCREEN_RIGHT - (text_width * min_scale) ) );

		// Interpolate between central and extreme position and centre
		f32				scale( max_scale + (min_scale - max_scale) * dist );
		s32				x( s32( centre + (extreme - centre) * dist ) );

		mpContext->DrawTextScale( x, y, scale, option_text, text_col );
	}

	mpContext->SetFontStyle( CUIContext::FS_REGULAR );

	mOptionComponents[ GetCurrentOption() ]->Render();
}
Beispiel #26
0
 inline s32 Round(const T& val)
 {
   if(val < T(0))
     return (T(-0.5f) < val - s32(val) ? s32(val) : s32(val - 1));
   else
     return (val - s32(val) < T(0.5f) ? s32(val) : s32(val + 1));
 }
u16 ResolverIn::getAngle()
{
	static DelayedConditional faultdelay(parentSys,0.2,false);
	//TODO

	/* status 9.2012:
	 * pinnia heilutetaan systemin hf taskista
	 *
	 *
	 * update:kytkis loytyy psvn skemana, natti RC ulostulo resosta
	 *
	 * luenta:
	 * säädetään keskeytys 20kHz:iin ja luetaan adc arvot talteen pulssin keskeltä
	 *
	 * skooppi:
	 * transcend muistitikulla skooppikuvia resolverista kun lähdön kanssa sarjassa 6.8 ohm ja
	 * kelan rinnan 0.33uf -> melkein siniaalto mutta LC oskillaatiota reunoissa
	 *
	 * sin ja kelt: käämin päät maahan nähden
	 * pink: erotus käämin yli
	 * vih: toision ulostulo
	 *
	 * Tarvinnee myös isomman sarjaresistanssin koska driveri lämpenee 70Chen 25Cssä ja ulostuloksi tulee
	 * yli +-2v
	 *
	 */

	/* TODO add fault detection if voltages of both channels less than 100mV or so
	 * this detects disconnected resolver and prevents angle going crazy*/

	lastAngle = currAngle;
	float x, y; //parentSys->physIO.ADin.getVoltageVolts(AnalogIn::EncA),parentSys->physIO.ADin.getVoltageVolts(AnalogIn::EncB)

	getSamples( x, y );

	//detect loss of input voltage (resolver disconnected or miswired)
	bool fault=false;
	if((x*x+y*y)<(0.2*0.2)) fault=true;
	if(faultdelay.delayedTrue( fault ) )
	{
		parentSys->setFault(FLT_ENCODER,FAULTLOCATION_BASE+101);
	}


	currAngle = u16( s32( 65536.0 * atan2f( x, y ) * (0.5 / M_PI) ) );

	lastOutputCount = outputCount;
	unrolledCount += s16( currAngle - lastAngle );
	outputCount = unrolledCount / (65536 / countsPerRev);

	return outputCount;
}
Beispiel #28
0
void rgbaint_t::blend(const rgbaint_t& color2, u8 color1scale)
{
	s32 scale1 = s32(color1scale);
	s32 scale2 = 256 - scale1;

	m_a = (m_a * scale1 + color2.m_a * scale2) >> 8;
	m_r = (m_r * scale1 + color2.m_r * scale2) >> 8;
	m_g = (m_g * scale1 + color2.m_g * scale2) >> 8;
	m_b = (m_b * scale1 + color2.m_b * scale2) >> 8;
	m_a |= (m_a & 0x00800000) ? 0xff000000 : 0;
	m_r |= (m_r & 0x00800000) ? 0xff000000 : 0;
	m_g |= (m_g & 0x00800000) ? 0xff000000 : 0;
	m_b |= (m_b & 0x00800000) ? 0xff000000 : 0;
}
bool IPacketReceiver::_targetChange(IWorldPlayer *_player)
{
	FDASSERT(_player);

	CByteArray &t_packet = _player->getClient()->incoming();

	ID t_targetId = t_packet.getInt();
	s8 t_action = t_packet.getByte();

#ifdef SDEBUG
	Log::write(LOG_DEBUG, "Player target changed: %d (%d)", t_targetId, s32(t_action));
#endif

	return !t_packet.end();
}
Beispiel #30
0
	void PPCXEmitter::BLT (const void *fnptr) {
		//CHECK_JUMP
		if (!IS_SMALL_JUMP) {
			u32 func_addr = (u32) fnptr;
			// Load func address
			MOVI2R(R0, func_addr);
			// Set it to link register
			MTCTR(R0);
			// Branch
			BLTCTR();
			return;
		}

		s32 func =  (s32)fnptr - s32(code);
		u32 instr = (0x41800000 | (((s16)(((func)+1))) & 0xfffc));
		Write32(instr);
	}