// // S_convertPCMU8 // // Convert unsigned 8-bit PCM to double precision floating point. // static void S_convertPCMU8(sfxinfo_t *sfx, const sounddata_t &sd) { sfx->alen = S_alenForSample(sd); sfx->data = Z_Malloc(sfx->alen*sizeof(float), PU_STATIC, &sfx->data); // haleyjd 12/18/13: Convert sound to target samplerate and into floating // point samples. if(sfx->alen != sd.samplecount) { unsigned int i; float *dest = static_cast<float *>(sfx->data); byte *src = sd.samplestart; unsigned int step = (sd.samplerate << 16) / TARGETSAMPLERATE; unsigned int stepremainder = 0, j = 0; // do linear filtering operation for(i = 0; i < sfx->alen && j < sd.samplecount - 1; i++) { double d = (((unsigned int)src[j ] * (0x10000 - stepremainder)) + ((unsigned int)src[j+1] * stepremainder)); d /= 65536.0; dest[i] = static_cast<float>(eclamp(d * 2.0 / 255.0 - 1.0, -1.0, 1.0)); stepremainder += step; j += (stepremainder >> 16); stepremainder &= 0xffff; } // fill remainder (if any) with final sample byte for(; i < sfx->alen; i++) dest[i] = static_cast<float>(eclamp(src[j] * 2.0 / 255.0 - 1.0, -1.0, 1.0)); }
// // PushRange // // Pushes the current palette translation range into the parser state object's // list of ranges. // static void PushRange(tr_pstate_t *pstate) { tr_range_t *newrange = estructalloc(tr_range_t, 1); newrange->srcbegin = eclamp(pstate->srcbegin, 0, 255); newrange->srcend = eclamp(pstate->srcend, 0, 255); newrange->dstbegin = eclamp(pstate->dstbegin, 0, 255); newrange->dstend = eclamp(pstate->dstend, 0, 255); // normalize ranges if(newrange->srcbegin > newrange->srcend) { int temp = newrange->srcbegin; newrange->srcbegin = newrange->srcend; newrange->srcend = temp; } if(newrange->dstbegin > newrange->dstend) { int temp = newrange->dstbegin; newrange->dstbegin = newrange->dstend; newrange->dstend = temp; } newrange->next = pstate->ranges; pstate->ranges = newrange; };
// // Loads sectors // void UDMFParser::loadSectors(UDMFSetupSettings &setupSettings) const { numsectors = (int)mSectors.getLength(); sectors = estructalloctag(sector_t, numsectors, PU_LEVEL); for(int i = 0; i < numsectors; ++i) { sector_t *ss = sectors + i; const USector &us = mSectors[i]; if(mNamespace == namespace_Eternity) { // These two pass the fixed_t value now ss->floorheight = us.heightfloor; ss->ceilingheight = us.heightceiling; // New to Eternity ss->floor_xoffs = us.xpanningfloor; ss->floor_yoffs = us.ypanningfloor; ss->ceiling_xoffs = us.xpanningceiling; ss->ceiling_yoffs = us.ypanningceiling; ss->floorbaseangle = static_cast<float> (E_NormalizeFlatAngle(us.rotationfloor) * PI / 180.0f); ss->ceilingbaseangle = static_cast<float> (E_NormalizeFlatAngle(us.rotationceiling) * PI / 180.0f); // Flags ss->flags |= us.secret ? SECF_SECRET : 0; // Friction: set the parameter directly from UDMF if(us.friction >= 0) // default: -1 { int friction, movefactor; P_CalcFriction(us.friction, friction, movefactor); ss->flags |= SECF_FRICTION; // add the flag too ss->friction = friction; ss->movefactor = movefactor; } // Damage ss->damage = us.damageamount; ss->damagemask = us.damageinterval; ss->damagemod = E_DamageTypeNumForName(us.damagetype.constPtr()); // If the following flags are true for the current sector, then set the // appropriate damageflags to true, otherwise don't set them. ss->damageflags |= us.damage_endgodmode ? SDMG_ENDGODMODE : 0; ss->damageflags |= us.damage_exitlevel ? SDMG_EXITLEVEL : 0; ss->damageflags |= us.damageterraineffect ? SDMG_TERRAINHIT : 0; ss->leakiness = eclamp(us.leakiness, 0, 256); // Terrain types if(us.floorterrain.strCaseCmp(DEFAULT_flat)) ss->floorterrain = E_TerrainForName(us.floorterrain.constPtr()); if (us.ceilingterrain.strCaseCmp(DEFAULT_flat)) ss->ceilingterrain = E_TerrainForName(us.ceilingterrain.constPtr()); // Lights ss->floorlightdelta = static_cast<int16_t>(us.lightfloor); ss->ceilinglightdelta = static_cast<int16_t>(us.lightceiling); ss->flags |= (us.lightfloorabsolute ? SECF_FLOORLIGHTABSOLUTE : 0) | (us.lightceilingabsolute ? SECF_CEILLIGHTABSOLUTE : 0); // sector colormaps ss->topmap = ss->midmap = ss->bottommap = -1; // mark as not specified } else { ss->floorheight = us.heightfloor << FRACBITS; ss->ceilingheight = us.heightceiling << FRACBITS; } ss->floorpic = R_FindFlat(us.texturefloor.constPtr()); P_SetSectorCeilingPic(ss, R_FindFlat(us.textureceiling.constPtr())); ss->lightlevel = us.lightlevel; ss->special = us.special; ss->tag = us.identifier; P_InitSector(ss); // // HERE GO THE PROPERTIES THAT MUST TAKE EFFECT AFTER P_InitSector // if(mNamespace == namespace_Eternity) { if(us.colormaptop.strCaseCmp(DEFAULT_default)) { ss->topmap = R_ColormapNumForName(us.colormaptop.constPtr()); setupSettings.setSectorFlag(i, UDMF_SECTOR_INIT_COLORMAPPED); } if(us.colormapmid.strCaseCmp(DEFAULT_default)) { ss->midmap = R_ColormapNumForName(us.colormapmid.constPtr()); setupSettings.setSectorFlag(i, UDMF_SECTOR_INIT_COLORMAPPED); } if(us.colormapbottom.strCaseCmp(DEFAULT_default)) { ss->bottommap = R_ColormapNumForName(us.colormapbottom.constPtr()); setupSettings.setSectorFlag(i, UDMF_SECTOR_INIT_COLORMAPPED); } // Portal fields // Floors ss->f_pflags |= us.portal_floor_alpha << PO_OPACITYSHIFT; ss->f_pflags |= us.portal_floor_blocksound ? PF_BLOCKSOUND : 0; ss->f_pflags |= us.portal_floor_disabled ? PF_DISABLED : 0; ss->f_pflags |= us.portal_floor_nopass ? PF_NOPASS : 0; ss->f_pflags |= us.portal_floor_norender ? PF_NORENDER : 0; if(!us.portal_floor_overlaytype.strCaseCmp(RENDERSTYLE_translucent)) ss->f_pflags |= PS_OVERLAY; else if(!us.portal_floor_overlaytype.strCaseCmp(RENDERSTYLE_add)) ss->f_pflags |= PS_OBLENDFLAGS; // PS_OBLENDFLAGS is PS_OVERLAY | PS_ADDITIVE ss->f_pflags |= us.portal_floor_useglobaltex ? PS_USEGLOBALTEX : 0; // Ceilings ss->c_pflags |= us.portal_ceil_alpha << PO_OPACITYSHIFT; ss->c_pflags |= us.portal_ceil_blocksound ? PF_BLOCKSOUND : 0; ss->c_pflags |= us.portal_ceil_disabled ? PF_DISABLED : 0; ss->c_pflags |= us.portal_ceil_nopass ? PF_NOPASS : 0; ss->c_pflags |= us.portal_ceil_norender ? PF_NORENDER : 0; if(!us.portal_ceil_overlaytype.strCaseCmp(RENDERSTYLE_translucent)) ss->c_pflags |= PS_OVERLAY; else if(!us.portal_ceil_overlaytype.strCaseCmp(RENDERSTYLE_add)) ss->c_pflags |= PS_OBLENDFLAGS; // PS_OBLENDFLAGS is PS_OVERLAY | PS_ADDITIVE ss->c_pflags |= us.portal_ceil_useglobaltex ? PS_USEGLOBALTEX : 0; } } }