// // Remove the token from the system // void Placement::RemoveToken(Base::Token &token) { Locator *locator = locatorsIdle.Find(U32(&token)); if (locator) { locatorsIdle.Dispose(locator); } else { locator = locatorsActive.Find(U32(&token)); if (locator) { // If the iterator is pointing at this locator, advance the iterator if (locator == *locatorsActiveIterator) { ++locatorsActiveIterator; } locatorsActiveList.Unlink(locator); locatorsActive.Dispose(locator); } else { LOG_AI(("No Idle or Active locator for token [%08X]", U32(&token))) } } }
dpx::U32 dpx::IndustryHeader::TCFromString(const char* str) const { // make sure the string is the correct length if(::strlen(str) != 11) return U32(~0); U32 tc = 0; int i, idx; U8 ch; U32 value, mask; for(i = 0; i < 8; i++) { // determine string index skipping : idx = i + ((i + 1) / 3); ch = str[idx]; // error check if(ch < '0' || ch > '9') return 0xffffffff; value = U32(ch - '0') << (28 - (i * 4)); mask = 0xf << (28 - (i * 4)); // mask in new value tc = (tc & ~mask) | (value & mask); } return tc; }
void TCPObject::addToTable(NetSocket newTag) { removeFromTable(); mTag = newTag; mNext = table[U32(mTag) & TableMask]; table[U32(mTag) & TableMask] = this; }
void GuiGradientCtrl::removeColorRange( GuiGradientSwatchCtrl* swatch ) { if( mDisplayMode == pHorizColorRange ) { if( mColorRange.size() <= 1 ) return; for( S32 i = 0;i < mColorRange.size(); i++ ) { if( mColorRange[i].swatch == swatch ) { mColorRange.erase( U32(i) ); swatch->safeDeleteObject(); break; } } } else if( mDisplayMode == pHorizAlphaRange ) { if( mAlphaRange.size() <= 1 ) return; for( S32 i = 0;i < mAlphaRange.size(); i++ ) { if( mAlphaRange[i].swatch == swatch ) { mAlphaRange.erase( U32(i) ); swatch->safeDeleteObject(); break; } } } }
//-------------------------------------------------------------------------- U32 Projectile::packUpdate(NetConnection* con, U32 mask, BitStream* stream) { U32 retMask = Parent::packUpdate(con, mask, stream); // Initial update if (stream->writeFlag(mask & GameBase::InitialUpdateMask)) { Point3F pos; getTransform().getColumn(3, &pos); stream->writeCompressedPoint(pos); F32 len = mCurrVelocity.len(); if(stream->writeFlag(len > 0.02)) { Point3F outVel = mCurrVelocity; outVel *= 1 / len; stream->writeNormalVector(outVel, 10); len *= 32.0; // 5 bits for fraction if(len > 8191) len = 8191; stream->writeInt((S32)len, 13); } stream->writeRangedU32(mCurrTick, 0, MaxLivingTicks); if (mSourceObject.isValid()) { // Potentially have to write this to the client, let's make sure it has a // ghost on the other side... S32 ghostIndex = con->getGhostIndex(mSourceObject); if (stream->writeFlag(ghostIndex != -1)) { stream->writeRangedU32(U32(ghostIndex), 0, NetConnection::MaxGhostCount); stream->writeRangedU32(U32(mSourceObjectSlot), 0, ShapeBase::MaxMountedImages - 1); } else // havn't recieved the ghost for the source object yet, try again later retMask |= GameBase::InitialUpdateMask; } else stream->writeFlag(false); } // explosion update if (stream->writeFlag((mask & ExplosionMask) && mHidden)) { mathWrite(*stream, mExplosionPosition); mathWrite(*stream, mExplosionNormal); stream->write(mCollideHitType); } // bounce update if (stream->writeFlag(mask & BounceMask)) { // Bounce against dynamic object mathWrite(*stream, mCurrPosition); mathWrite(*stream, mCurrVelocity); } return retMask; }
template <typename T> U32 TVector4<T>::GetBGRAU32( void ) const { U32 r = U32(GetX()*T(255.0f)); U32 g = U32(GetY()*T(255.0f)); U32 b = U32(GetZ()*T(255.0f)); U32 a = U32(GetW()*T(255.0f)); return U32( (b<<24)|(g<<16)|(r<<8)|a ); }
template <typename T> U16 TVector4<T>::GetRGBU16( void ) const { U32 r = U32(GetX() * T(31.0f)); U32 g = U32(GetY() * T(31.0f)); U32 b = U32(GetZ() * T(31.0f)); U16 rval = U16((b<<10)|(g<<5)|r); return rval; }
void GFXGLCubemap::fillCubeTextures(GFXTexHandle* faces) { AssertFatal( faces, ""); AssertFatal( faces[0]->mMipLevels > 0, ""); PRESERVE_CUBEMAP_TEXTURE(); glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, faces[0]->mMipLevels - 1 ); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); U32 reqWidth = faces[0]->getWidth(); U32 reqHeight = faces[0]->getHeight(); GFXFormat regFaceFormat = faces[0]->getFormat(); const bool isCompressed = isCompressedFormat(regFaceFormat); mWidth = reqWidth; mHeight = reqHeight; mFaceFormat = regFaceFormat; mMipLevels = getMax( (U32)1, faces[0]->mMipLevels); AssertFatal(reqWidth == reqHeight, "GFXGLCubemap::fillCubeTextures - Width and height must be equal!"); for(U32 i = 0; i < 6; i++) { AssertFatal(faces[i], avar("GFXGLCubemap::fillCubeFaces - texture %i is NULL!", i)); AssertFatal((faces[i]->getWidth() == reqWidth) && (faces[i]->getHeight() == reqHeight), "GFXGLCubemap::fillCubeFaces - All textures must have identical dimensions!"); AssertFatal(faces[i]->getFormat() == regFaceFormat, "GFXGLCubemap::fillCubeFaces - All textures must have identical formats!"); mTextures[i] = faces[i]; GFXFormat faceFormat = faces[i]->getFormat(); GFXGLTextureObject* glTex = static_cast<GFXGLTextureObject*>(faces[i].getPointer()); if( isCompressed ) { for( U32 mip = 0; mip < mMipLevels; ++mip ) { const U32 mipWidth = getMax( U32(1), faces[i]->getWidth() >> mip ); const U32 mipHeight = getMax( U32(1), faces[i]->getHeight() >> mip ); const U32 mipDataSize = getCompressedSurfaceSize( mFaceFormat, mWidth, mHeight, mip ); U8* buf = glTex->getTextureData( mip ); glCompressedTexImage2D(faceList[i], mip, GFXGLTextureInternalFormat[mFaceFormat], mipWidth, mipHeight, 0, mipDataSize, buf); delete[] buf; } } else { U8* buf = glTex->getTextureData(); glTexImage2D(faceList[i], 0, GFXGLTextureInternalFormat[faceFormat], mWidth, mHeight, 0, GFXGLTextureFormat[faceFormat], GFXGLTextureType[faceFormat], buf); delete[] buf; } }
//-------------------------------------------------------------------------- U32 Projectile::packUpdate( NetConnection *con, U32 mask, BitStream *stream ) { U32 retMask = Parent::packUpdate( con, mask, stream ); const bool isInitalUpdate = mask & GameBase::InitialUpdateMask; // InitialUpdateMask if ( stream->writeFlag( isInitalUpdate ) ) { stream->writeRangedU32( mCurrTick, 0, MaxLivingTicks ); if ( mSourceObject.isValid() ) { // Potentially have to write this to the client, let's make sure it has a // ghost on the other side... S32 ghostIndex = con->getGhostIndex( mSourceObject ); if ( stream->writeFlag( ghostIndex != -1 ) ) { stream->writeRangedU32( U32(ghostIndex), 0, NetConnection::MaxGhostCount ); stream->writeRangedU32( U32(mSourceObjectSlot), 0, ShapeBase::MaxMountedImages - 1 ); } else // have not recieved the ghost for the source object yet, try again later retMask |= GameBase::InitialUpdateMask; } else stream->writeFlag( false ); } // ExplosionMask // // ExplosionMask will be set during the initial update but hidden is // only true if we have really exploded. if ( stream->writeFlag( ( mask & ExplosionMask ) && mHasExploded ) ) { mathWrite(*stream, mExplosionPosition); mathWrite(*stream, mExplosionNormal); stream->write(mCollideHitType); } // BounceMask if ( stream->writeFlag( mask & BounceMask ) ) { // Bounce against dynamic object mathWrite(*stream, mCurrPosition); mathWrite(*stream, mCurrVelocity); } return retMask; }
// public static void LLWorldMap::processMapLayerReply(LLMessageSystem* msg, void**) { llinfos << "LLWorldMap::processMapLayerReply from message system" << llendl; U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); if (agent_flags != (U32)LLWorldMap::getInstance()->mCurrentMap) { llwarns << "Invalid or out of date map image type returned!" << llendl; return; } LLUUID image_id; //U32 left, right, top, bottom; S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_LayerData); LLWorldMap::getInstance()->mMapLayers[agent_flags].clear(); BOOL adjust = FALSE; for (S32 block=0; block<num_blocks; ++block) { LLWorldMapLayer new_layer; new_layer.LayerDefined = TRUE; msg->getUUIDFast(_PREHASH_LayerData, _PREHASH_ImageID, new_layer.LayerImageID, block); new_layer.LayerImage = gImageList.getImage(new_layer.LayerImageID, MIPMAP_TRUE, FALSE); gGL.getTexUnit(0)->bind(new_layer.LayerImage.get()); new_layer.LayerImage->setAddressMode(LLTexUnit::TAM_CLAMP); U32 left, right, top, bottom; msg->getU32Fast(_PREHASH_LayerData, _PREHASH_Left, left, block); msg->getU32Fast(_PREHASH_LayerData, _PREHASH_Right, right, block); msg->getU32Fast(_PREHASH_LayerData, _PREHASH_Top, top, block); msg->getU32Fast(_PREHASH_LayerData, _PREHASH_Bottom, bottom, block); new_layer.LayerExtents.mLeft = left; new_layer.LayerExtents.mRight = right; new_layer.LayerExtents.mBottom = bottom; new_layer.LayerExtents.mTop = top; F32 x_meters = F32(left*REGION_WIDTH_UNITS); F32 y_meters = F32(bottom*REGION_WIDTH_UNITS); adjust = LLWorldMap::getInstance()->extendAABB(U32(x_meters), U32(y_meters), U32(x_meters+REGION_WIDTH_UNITS*new_layer.LayerExtents.getWidth()), U32(y_meters+REGION_WIDTH_UNITS*new_layer.LayerExtents.getHeight())) || adjust; LLWorldMap::getInstance()->mMapLayers[agent_flags].push_back(new_layer); } LLWorldMap::getInstance()->mMapLoaded[agent_flags] = TRUE; if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); }
inline void LLImageTGA::decodeTruecolorPixel15( U8* dst, const U8* src ) { // We expand 5 bit data to 8 bit sample width. // The format of the 16-bit (LSB first) input word is // xRRRRRGGGGGBBBBB U32 t = U32(src[0]) + (U32(src[1]) << 8); dst[2] = s5to8bits[t & 0x1F]; // blue t >>= 5; dst[1] = s5to8bits[t & 0x1F]; // green t >>= 5; dst[0] = s5to8bits[t & 0x1F]; // red }
/// Convert all Collada materials into a single TSMaterialList void TSShapeLoader::generateMaterialList() { // Install the materials into the material list shape->materialList = new TSMaterialList; for (int iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++) { updateProgress(Load_GenerateMaterials, "Generating materials...", AppMesh::appMaterials.size(), iMat); AppMaterial* appMat = AppMesh::appMaterials[iMat]; shape->materialList->push_back(appMat->getName(), appMat->getFlags(), U32(-1), U32(-1), U32(-1), 1.0f, appMat->getReflectance()); } }
/** * @luafunc Team LuaGameInfo::getTeam(int teamIndex) * * @brief Get a Team by index. * * @note Remember that Lua uses 1-based indices, so the index of the first team will be 1. * * @return The Team with the specified index. */ S32 LuaGameInfo::lua_getTeam(lua_State *L) { checkArgList(L, functionArgs, "GameInfo", "getTeam"); S32 index = getTeamIndex(L, 1); if(U32(index) >= U32(mServerGame->getTeamCount())) // Out of range index? return returnNil(L); TNLAssert(dynamic_cast<Team*>(mServerGame->getTeam(index)), "Bad team pointer or bad type"); return returnTeam(L, static_cast<Team*>(mServerGame->getTeam(index))); }
//============================================================================== Error TransientMemoryManager::init(const ConfigSet& cfg) { Array<const char*, U(TransientBufferType::COUNT)> configVars = { {"gr.uniformPerFrameMemorySize", "gr.storagePerFrameMemorySize", "gr.vertexPerFrameMemorySize", "gr.transferPerFrameMemorySize"}}; const VkPhysicalDeviceLimits& limits = m_manager->getImplementation().getPhysicalDeviceProperties().limits; Array<U32, U(TransientBufferType::COUNT)> alignments = { {U32(limits.minUniformBufferOffsetAlignment), U32(limits.minStorageBufferOffsetAlignment), sizeof(F32) * 4, sizeof(F32) * 4}}; Array<BufferUsageBit, U(TransientBufferType::COUNT)> usages = { {BufferUsageBit::UNIFORM_ANY_SHADER, BufferUsageBit::STORAGE_ANY, BufferUsageBit::VERTEX, BufferUsageBit::TRANSFER_SOURCE}}; auto alloc = m_manager->getAllocator(); for(TransientBufferType i = TransientBufferType::UNIFORM; i < TransientBufferType::COUNT; ++i) { PerFrameBuffer& frame = m_perFrameBuffers[i]; frame.m_size = cfg.getNumber(configVars[i]); ANKI_ASSERT(frame.m_size); // Create buffer frame.m_buff = alloc.newInstance<BufferImpl>(m_manager); ANKI_CHECK(frame.m_buff->init( frame.m_size, usages[i], BufferMapAccessBit::WRITE)); frame.m_bufferHandle = frame.m_buff->getHandle(); // Map once frame.m_mappedMem = static_cast<U8*>( frame.m_buff->map(0, frame.m_size, BufferMapAccessBit::WRITE)); ANKI_ASSERT(frame.m_mappedMem); // Init the allocator frame.m_alloc.init(frame.m_size, alignments[i]); } return ErrorCode::NONE; }
bool ManchesterAnalyzerSettings::SetSettingsFromInterfaces() { mInputChannel = mInputChannelInterface->GetChannel(); mMode = ManchesterMode( U32( mModeInterface->GetNumber() ) ); mBitRate = mBitRateInterface->GetInteger(); mInverted = bool( U32( mInvertedInterface->GetNumber() ) ); mBitsPerTransfer = U32( mBitsPerTransferInterface->GetNumber() ); mShiftOrder = AnalyzerEnums::ShiftOrder( U32( mShiftOrderInterface->GetNumber() ) ); mBitsToIgnore = mNumBitsIgnoreInterface->GetInteger(); mTolerance = ManchesterTolerance( U32( mToleranceInterface->GetNumber() ) ); ClearChannels(); AddChannel( mInputChannel, "Manchester", true ); return true; }
void SFXFMODEventSource::stop( F32 fadeOutTime ) { if( getStatus() == SFXStatusStopped ) return; AssertFatal( mHandle, "SFXFMODEvent::stop() - event not acquired" ); bool immediate = ( fadeOutTime == 0.f ); FMOD_RESULT result = SFXFMODDevice::smFunc->FMOD_Event_Stop( mHandle, immediate ); if( result != FMOD_OK ) Con::errorf( "SFXFMODEventSource::stop() - failed to stop event: %s", FMODResultToString( result ).c_str() ); mPlayTimer.stop(); _setStatus( SFXStatusStopped ); // Reset fade-in to default in case it got overwritten // in play(). U32 fade = U32( mFadeInTime * 1000.f ); SFXFMODDevice::smFunc->FMOD_Event_SetPropertyByIndex( mHandle, FMOD_EVENTPROPERTY_FADEIN, &fade, true ); _stop(); }
void SFXFMODEventSource::_setFadeTimes( F32 fadeInTime, F32 fadeOutTime ) { Parent::_setFadeTimes( fadeInTime, fadeOutTime ); U32 fadeIn = U32( mFadeInTime * 1000.f ); SFXFMODDevice::smFunc->FMOD_Event_SetPropertyByIndex( mHandle, FMOD_EVENTPROPERTY_FADEIN, &fadeIn, true ); U32 fadeOut = U32( mFadeOutTime * 1000.f ); SFXFMODDevice::smFunc->FMOD_Event_SetPropertyByIndex( mHandle, FMOD_EVENTPROPERTY_FADEOUT, &fadeOut, true ); }
void LLFloaterGodTools::sendGodUpdateRegionInfo() { LLFloaterGodTools* god_tools = LLFloaterReg::getTypedInstance<LLFloaterGodTools>("god_tools"); if (!god_tools) return; LLViewerRegion *regionp = gAgent.getRegion(); if (gAgent.isGodlike() && god_tools->mPanelRegionTools && regionp && gAgent.getRegionHost() == mCurrentHost) { LLMessageSystem *msg = gMessageSystem; LLPanelRegionTools *rtool = god_tools->mPanelRegionTools; U64 region_flags = computeRegionFlags(); msg->newMessage("GodUpdateRegionInfo"); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_RegionInfo); msg->addStringFast(_PREHASH_SimName, rtool->getSimName()); msg->addU32Fast(_PREHASH_EstateID, rtool->getEstateID()); msg->addU32Fast(_PREHASH_ParentEstateID, rtool->getParentEstateID()); // Legacy flags msg->addU32Fast(_PREHASH_RegionFlags, U32(region_flags)); msg->addF32Fast(_PREHASH_BillableFactor, rtool->getBillableFactor()); msg->addS32Fast(_PREHASH_PricePerMeter, rtool->getPricePerMeter()); msg->addS32Fast(_PREHASH_RedirectGridX, rtool->getRedirectGridX()); msg->addS32Fast(_PREHASH_RedirectGridY, rtool->getRedirectGridY()); msg->nextBlockFast(_PREHASH_RegionInfo2); msg->addU64Fast(_PREHASH_RegionFlagsExtended, region_flags); gAgent.sendReliableMessage(); } }
void SFXFMODEventSource::play( F32 fadeInTime ) { if( getStatus() == SFXStatusPlaying ) return; if( isPaused() ) SFXFMODDevice::smFunc->FMOD_Event_SetPaused( mHandle, false ); else { AssertFatal( getEvent()->getEventGroup()->isDataLoaded(), "SFXFMODEventSource::play() - event data for group not loaded" ); if( fadeInTime != -1.f ) { U32 fade = U32( fadeInTime * 1000.f ); SFXFMODDevice::smFunc->FMOD_Event_SetPropertyByIndex( mHandle, FMOD_EVENTPROPERTY_FADEIN, &fade, true ); } FMOD_RESULT result = SFXFMODDevice::smFunc->FMOD_Event_Start( mHandle ); if( result != FMOD_OK ) { Con::errorf( "SFXFMODEventSoure::play() - failed to start event: %s", FMODResultToString( result ).c_str() ); return; } } mPlayTimer.start(); _setStatus( SFXStatusPlaying ); _play(); }
TCPObject *TCPObject::find(NetSocket tag) { for(TCPObject *walk = table[U32(tag) & TableMask]; walk; walk = walk->mNext) if(walk->mTag == tag) return walk; return NULL; }
void AllocateMemoryPool() { gs_pMemoryBuffer = (U8*) GlobalAlloc( GMEM_ZEROINIT, MEMORY_POOL_SIZE ); ASSERT( gs_pMemoryBuffer != NULL, "Failed to allocate giant memory octop... never mind... POOL !" ); gs_pMemoryBufferAligned = (U8*) (U32(gs_pMemoryBuffer+31) & (~31)); }
U32 DDSFile::getSurfacePitch( U32 mipLevel ) const { if(mFlags.test(CompressedData)) { U32 sizeMultiple = 0; switch(mFormat) { case GFXFormatDXT1: sizeMultiple = 8; break; case GFXFormatDXT2: case GFXFormatDXT3: case GFXFormatDXT4: case GFXFormatDXT5: sizeMultiple = 16; break; default: AssertISV(false, "DDSFile::getPitch - invalid compressed texture format, we only support DXT1-5 right now."); break; } // Maybe need to be DWORD aligned? U32 align = getMax(U32(1), getWidth(mipLevel)/4) * sizeMultiple; align += 3; align >>=2; align <<=2; return align; }
static void _printf(LogEntry::Level level, LogEntry::Type type, const char* fmt, va_list argptr) { if (!active) return; Log::active = false; char buffer[8192]; U32 offset = 0; if (useTimestamp) { static U32 startTime = Platform::getRealMilliseconds(); U32 curTime = Platform::getRealMilliseconds() - startTime; offset += dSprintf(buffer + offset, sizeof(buffer) - offset, "[+%4d.%03d]", U32(curTime * 0.001), curTime % 1000); } dVsprintf(buffer + offset, sizeof(buffer) - offset, fmt, argptr); LogEntry entry; entry.mData = buffer; entry.mLevel = level; entry.mType = type; for(S32 i = 0; i < gConsumers.size(); i++) gConsumers[i](level, &entry); Log::active = true; }
// Note that time could be negative to shorten timer! -- TODO: Do we really want to alter the timer period here? void Timer::extend(S32 time) { U32 U32time = U32(abs(time)); if(time > 0) { if(U32time > (U32_MAX - mPeriod)) // Overflow protection mPeriod = U32time; else mPeriod += U32time; if(U32time > (U32_MAX - mCurrentCounter)) // Overflow protection mCurrentCounter = U32_MAX; else mCurrentCounter += U32time; } else if(time < 0) { if(U32time > mPeriod) // Underflow protection mPeriod = 0; else mPeriod -= U32time; if(U32time > mCurrentCounter) // Underflow protection mCurrentCounter = 0; else mCurrentCounter -= U32time; } }
Error Ssao::initMain(const ConfigSet& config) { // Noise ANKI_CHECK(getResourceManager().loadResource("engine_data/BlueNoiseLdrRgb64x64.ankitex", m_main.m_noiseTex)); // Shader if(m_useCompute) { ANKI_CHECK(getResourceManager().loadResource("shaders/SsaoCompute.glslp", m_main.m_prog)); } else { ANKI_CHECK(getResourceManager().loadResource("shaders/Ssao.glslp", m_main.m_prog)); } ShaderProgramResourceMutationInitList<2> mutators(m_main.m_prog); mutators.add("USE_NORMAL", (m_useNormal) ? 1u : 0u).add("SOFT_BLUR", (m_useSoftBlur) ? 1u : 0u); ShaderProgramResourceConstantValueInitList<7> consts(m_main.m_prog); consts.add("NOISE_MAP_SIZE", U32(m_main.m_noiseTex->getWidth())) .add("FB_SIZE", UVec2(m_width, m_height)) .add("RADIUS", 2.5f) .add("BIAS", 0.0f) .add("STRENGTH", 2.5f) .add("SAMPLE_COUNT", 8u) .add("WORKGROUP_SIZE", UVec2(m_workgroupSize[0], m_workgroupSize[1])); const ShaderProgramResourceVariant* variant; m_main.m_prog->getOrCreateVariant(mutators.get(), consts.get(), variant); m_main.m_grProg = variant->getProgram(); return Error::NONE; }
U32 Statistics::getDistanceTraveled() { if(mDist / DIST_MULTIPLIER > (U64)U32_MAX) return U32_MAX; else return U32(mDist / (DIST_MULTIPLIER * DIST_RATCHETING_DOWN_FACTOR)); }
/////////////////////////////////////////////////////////////////////////////// // // StrFmt // void TestStrFmt() { char s[17]; Clock::CycleWatch t1, t2, t3, t4; S32 testno = -1242435; for (int i = 0; i < 1000; i++) { t1.Start(); Utils::StrFmtDec(s, 16, testno); t1.Stop(); t2.Start(); ltoa(testno, s, 10); t2.Stop(); t3.Start(); Utils::StrFmtHex(s, 16, U32(testno)); t3.Stop(); t4.Start(); Utils::StrFmtFloat(s, 10, 3, 342.33F); t4.Stop(); } TestReport("StrFmtDec", t1); TestReport("ltoa ", t2); TestReport("StrFmtHex", t3); TestReport("StrFmtFloat", t4); }
bool Win32RedBookDevice::setVolume(F32 volume) { if(!mAcquired) { setLastError("Device has not been acquired"); return(false); } if(!mVolumeInitialized) { setLastError("Volume failed to initialize"); return(false); } // move into a U32 - left/right U16 volumes U32 vol = U32(volume * 65536.f); if(vol > 0xffff) vol = 0xffff; if(mUsingMixer) { mMixerVolumeValue.dwValue = vol; mixerSetControlDetails(mVolumeDeviceId, &mMixerVolumeDetails, MIXER_SETCONTROLDETAILSF_VALUE); } else { vol |= vol << 16; auxSetVolume(mAuxVolumeDeviceId, vol); } setLastError(""); return(true); }
const char* ManchesterAnalyzerSettings::SaveSettings() { SimpleArchive text_archive; text_archive << "SaleaeManchesterAnalyzer"; text_archive << mInputChannel; text_archive << U32( mMode ); text_archive << mBitRate; text_archive << mInverted; text_archive << mBitsPerTransfer; text_archive << U32( mShiftOrder ); text_archive << mBitsToIgnore; text_archive << U32( mTolerance ); return SetReturnString( text_archive.GetString() ); }
// // IFaceVar::Notify // // The var has changed value // void IFaceVar::Notify(VarNotify::Mode mode) { ASSERT(varPtr); switch (mode) { case VarNotify::CHANGED: { if (ctrl) { VALIDATE(ctrl); // Tell the control that the value changed ctrl->Notify(this); } break; } case VarNotify::DELETED: { Done(); break; } default: { ERR_FATAL(("Unknown VarNotify mode [%d]", U32(mode))); break; } } }