• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LittleShort函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LittleShort函数的典型用法代码示例。如果您正苦于以下问题:C++ LittleShort函数的具体用法?C++ LittleShort怎么用?C++ LittleShort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LittleShort函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Mod_LoadMarksurfaces

/*
=================
Mod_LoadMarksurfaces
=================
*/
void Mod_LoadMarksurfaces (lump_t *l)
{	
	int		i, j, count;
	short		*in;
	msurface_t **out;
	
	in = (short *)(mod_base + l->fileofs);
	if (l->filelen % sizeof(*in))
		VID_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
	count = l->filelen / sizeof(*in);
	out = (msurface_t **) Hunk_Alloc ( count*sizeof(*out));

	loadmodel->marksurfaces = out;
	loadmodel->nummarksurfaces = count;

	for ( i=0 ; i<count ; i++)
	{
		j = LittleShort(in[i]);
		if (j < 0 ||  j >= loadmodel->numsurfaces)
			VID_Error (ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
		out[i] = loadmodel->surfaces + j;
	}
}
开发者ID:turol,项目名称:webquake2,代码行数:28,代码来源:gl_model.c


示例2: R_LoadBspLeafSurfaces

/*
 * @brief
 */
static void R_LoadBspLeafSurfaces(r_bsp_model_t *bsp, const d_bsp_lump_t *l) {
	int32_t i;
	r_bsp_surface_t **out;

	const uint16_t *in = (const void *) (mod_base + l->file_ofs);
	if (l->file_len % sizeof(*in)) {
		Com_Error(ERR_DROP, "Funny lump size\n");
	}

	bsp->num_leaf_surfaces = l->file_len / sizeof(*in);
	bsp->leaf_surfaces = out = Z_LinkMalloc(bsp->num_leaf_surfaces * sizeof(*out), bsp);

	for (i = 0; i < bsp->num_leaf_surfaces; i++) {

		const uint16_t j = (uint16_t) LittleShort(in[i]);

		if (j >= bsp->num_surfaces) {
			Com_Error(ERR_DROP, "Bad surface number: %d\n", j);
		}

		out[i] = bsp->surfaces + j;
	}
}
开发者ID:devilx4,项目名称:quake2world,代码行数:26,代码来源:r_bsp_model.c


示例3: while

void DiskWriterIO::SetClockRate(double samples_per_tick)
{
	TimePerTick = samples_per_tick / OPL_SAMPLE_RATE * 1000.0;

	if (Format == FMT_RDOS)
	{
		double clock_rate;
		int clock_mul;
		WORD clock_word;

		clock_rate = samples_per_tick * ADLIB_CLOCK_MUL;
		clock_mul = 1;

		// The RDos raw format's clock rate is stored in a word. Therefore,
		// the longest tick that can be stored is only ~55 ms.
		while (clock_rate / clock_mul + 0.5 > 65535.0)
		{
			clock_mul++;
		}
		clock_word = WORD(clock_rate / clock_mul + 0.5);

		if (NeedClockRate)
		{ // Set the initial clock rate.
			clock_word = LittleShort(clock_word);
			fseek(File, 8, SEEK_SET);
			fwrite(&clock_word, 2, 1, File);
			fseek(File, 0, SEEK_END);
			NeedClockRate = false;
		}
		else
		{ // Change the clock rate in the middle of the song.
			BYTE clock_change[4] = { 0, 2, clock_word & 255, clock_word >> 8 };
			fwrite(clock_change, 1, 4, File);
		}
	}
}
开发者ID:WChrisK,项目名称:Zandronum,代码行数:36,代码来源:music_opldumper_mididevice.cpp


示例4: Cm_LoadBspLeafBrushes

/*
 * @brief
 */
static void Cm_LoadBspLeafBrushes(const d_bsp_lump_t *l) {

	const uint16_t *in = (const void *) (cm_bsp.base + l->file_ofs);

	if (l->file_len % sizeof(*in)) {
		Com_Error(ERR_DROP, "Funny lump size\n");
	}

	const int32_t count = l->file_len / sizeof(*in);

	if (count < 1) {
		Com_Error(ERR_DROP, "Invalid leaf brush count: %d\n", count);
	}
	if (count > MAX_BSP_LEAF_BRUSHES) {
		Com_Error(ERR_DROP, "%d > MAX_BSP_LEAF_BRUSHES\n", count);
	}

	uint16_t *out = cm_bsp.leaf_brushes;
	cm_bsp.num_leaf_brushes = count;

	for (int32_t i = 0; i < count; i++, in++, out++) {
		*out = LittleShort(*in);
	}
}
开发者ID:EEmmanuel7,项目名称:quetoo,代码行数:27,代码来源:cm_model.c


示例5: Mod_LoadMarksurfaces

/*
=================
Mod_LoadMarksurfaces
=================
*/
void Mod_LoadMarksurfaces (lump_t *l)
{
	int				i, j, count;
	unsigned short	*in;		// JDH: was signed short
	msurface_t		**out;

	in = (void *)(mod_base + l->fileofs);
	if (l->filelen % sizeof(*in))
		Host_Error ("Mod_LoadMarksurfaces: funny lump size in %s", loadmodel->name);	// was Sys_Error

	count = l->filelen / sizeof(*in);
	out = Hunk_AllocName (count * sizeof(*out), mod_loadname);

	loadmodel->marksurfaces = out;
	loadmodel->nummarksurfaces = count;

	for (i=0 ; i<count ; i++)
	{
		j = (unsigned short) LittleShort(in[i]);
		if (j >= loadmodel->numsurfaces)
			Host_Error ("Mod_LoadMarksurfaces: bad surface number");	// was Sys_Error
		out[i] = loadmodel->surfaces + j;
	}
}
开发者ID:SpiritQuaddicted,项目名称:reQuiem,代码行数:29,代码来源:gl_brush.c


示例6: Mod_LoadLeafs

void
Mod_LoadLeafs(lump_t *l)
{
	dleaf_t *in;
	mleaf_t *out;
	int i, j, count, p;

	in = (void *)(mod_base + l->fileofs);

	if (l->filelen % sizeof(*in))
	{
		ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",
				loadmodel->name);
	}

	count = l->filelen / sizeof(*in);
	out = Hunk_Alloc(count * sizeof(*out));

	loadmodel->leafs = out;
	loadmodel->numleafs = count;

	for (i = 0; i < count; i++, in++, out++)
	{
		for (j = 0; j < 3; j++)
		{
			out->minmaxs[j] = LittleShort(in->mins[j]);
			out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
		}

		p = LittleLong(in->contents);
		out->contents = p;

		out->cluster = LittleShort(in->cluster);
		out->area = LittleShort(in->area);

		out->firstmarksurface = loadmodel->marksurfaces +
								LittleShort(in->firstleafface);
		out->nummarksurfaces = LittleShort(in->numleaffaces);
	}
}
开发者ID:DrItanium,项目名称:yquake2,代码行数:40,代码来源:gl1_model.c


示例7: LittleShort

/*
================
usercmd_t::ByteSwap
================
*/
void usercmd_t::ByteSwap( void ) {
	angles[0] = LittleShort( angles[0] );
	angles[1] = LittleShort( angles[1] );
	angles[2] = LittleShort( angles[2] );
	sequence = LittleLong( sequence );
}
开发者ID:Justasic,项目名称:DOOM-3,代码行数:11,代码来源:UsercmdGen.cpp


示例8: R_LoadMD3


//.........这里部分代码省略.........
            frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );
	    	frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] );
        }
	}

	// swap all the tags
    tag = (md3Tag_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsTags );
    for ( i = 0 ; i < mod->md3[lod]->numTags * mod->md3[lod]->numFrames ; i++, tag++) {
        for ( j = 0 ; j < 3 ; j++ ) {
			tag->origin[j] = LittleFloat( tag->origin[j] );
			tag->axis[0][j] = LittleFloat( tag->axis[0][j] );
			tag->axis[1][j] = LittleFloat( tag->axis[1][j] );
			tag->axis[2][j] = LittleFloat( tag->axis[2][j] );
        }
	}

	// swap all the surfaces
	surf = (md3Surface_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsSurfaces );
	for ( i = 0 ; i < mod->md3[lod]->numSurfaces ; i++) {

        LL(surf->ident);
        LL(surf->flags);
        LL(surf->numFrames);
        LL(surf->numShaders);
        LL(surf->numTriangles);
        LL(surf->ofsTriangles);
        LL(surf->numVerts);
        LL(surf->ofsShaders);
        LL(surf->ofsSt);
        LL(surf->ofsXyzNormals);
        LL(surf->ofsEnd);
		
		if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
			ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",
				mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
		}
		if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
			ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",
				mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );
		}
	
		// change to surface identifier
		surf->ident = SF_MD3;

		// lowercase the surface name so skin compares are faster
		Q_strlwr( surf->name );

		// strip off a trailing _1 or _2
		// this is a crutch for q3data being a mess
		j = strlen( surf->name );
		if ( j > 2 && surf->name[j-2] == '_' ) {
			surf->name[j-2] = 0;
		}

        // register the shaders
        shader = (md3Shader_t *) ( (byte *)surf + surf->ofsShaders );
        for ( j = 0 ; j < surf->numShaders ; j++, shader++ ) {
            shader_t	*sh;

            sh = R_FindShader( shader->name, LIGHTMAP_NONE, qtrue );
			if ( sh->defaultShader ) {
				shader->shaderIndex = 0;
			} else {
				shader->shaderIndex = sh->index;
			}
        }

		// swap all the triangles
		tri = (md3Triangle_t *) ( (byte *)surf + surf->ofsTriangles );
		for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {
			LL(tri->indexes[0]);
			LL(tri->indexes[1]);
			LL(tri->indexes[2]);
		}

		// swap all the ST
        st = (md3St_t *) ( (byte *)surf + surf->ofsSt );
        for ( j = 0 ; j < surf->numVerts ; j++, st++ ) {
            st->st[0] = LittleFloat( st->st[0] );
            st->st[1] = LittleFloat( st->st[1] );
        }

		// swap all the XyzNormals
        xyz = (md3XyzNormal_t *) ( (byte *)surf + surf->ofsXyzNormals );
        for ( j = 0 ; j < surf->numVerts * surf->numFrames ; j++, xyz++ ) 
		{
            xyz->xyz[0] = LittleShort( xyz->xyz[0] );
            xyz->xyz[1] = LittleShort( xyz->xyz[1] );
            xyz->xyz[2] = LittleShort( xyz->xyz[2] );

            xyz->normal = LittleShort( xyz->normal );
        }


		// find the next surface
		surf = (md3Surface_t *)( (byte *)surf + surf->ofsEnd );
	}
    
	return qtrue;
}
开发者ID:luaman,项目名称:zq,代码行数:101,代码来源:tr_model.c


示例9: convert_sample_data

void convert_sample_data(Sample *sp, const void *data)
{
    /* convert everything to 32-bit floating point data */
    sample_t *newdata = NULL;

    switch (sp->modes & (PATCH_16 | PATCH_UNSIGNED))
    {
    case 0:
    {   /* 8-bit, signed */
        SBYTE *cp = (SBYTE *)data;
        newdata = (sample_t *)safe_malloc((sp->data_length + 1) * sizeof(sample_t));
        for (int i = 0; i < sp->data_length; ++i)
        {
            if (cp[i] < 0)
            {
                newdata[i] = float(cp[i]) / 128.f;
            }
            else
            {
                newdata[i] = float(cp[i]) / 127.f;
            }
        }
        break;
    }

    case PATCH_UNSIGNED:
    {   /* 8-bit, unsigned */
        BYTE *cp = (BYTE *)data;
        newdata = (sample_t *)safe_malloc((sp->data_length + 1) * sizeof(sample_t));
        for (int i = 0; i < sp->data_length; ++i)
        {
            int c = cp[i] - 128;
            if (c < 0)
            {
                newdata[i] = float(c) / 128.f;
            }
            else
            {
                newdata[i] = float(c) / 127.f;
            }
        }
        break;
    }

    case PATCH_16:
    {   /* 16-bit, signed */
        SWORD *cp = (SWORD *)data;
        /* Convert these to samples */
        sp->data_length >>= 1;
        sp->loop_start >>= 1;
        sp->loop_end >>= 1;
        newdata = (sample_t *)safe_malloc((sp->data_length + 1) * sizeof(sample_t));
        for (int i = 0; i < sp->data_length; ++i)
        {
            int c = LittleShort(cp[i]);
            if (c < 0)
            {
                newdata[i] = float(c) / 32768.f;
            }
            else
            {
                newdata[i] = float(c) / 32767.f;
            }
        }
        break;
    }

    case PATCH_16 | PATCH_UNSIGNED:
    {   /* 16-bit, unsigned */
        WORD *cp = (WORD *)data;
        /* Convert these to samples */
        sp->data_length >>= 1;
        sp->loop_start >>= 1;
        sp->loop_end >>= 1;
        newdata = (sample_t *)safe_malloc((sp->data_length + 1) * sizeof(sample_t));
        for (int i = 0; i < sp->data_length; ++i)
        {
            int c = LittleShort(cp[i]) - 32768;
            if (c < 0)
            {
                newdata[i] = float(c) / 32768.f;
            }
            else
            {
                newdata[i] = float(c) / 32767.f;
            }
        }
        break;
    }
    }
    /* Duplicate the final sample for linear interpolation. */
    newdata[sp->data_length] = newdata[sp->data_length - 1];
    if (sp->data != NULL)
    {
        free(sp->data);
    }
    sp->data = newdata;
}
开发者ID:kevans91,项目名称:zdoom,代码行数:98,代码来源:instrum.cpp


示例10: LoadTGA

/*
=============
LoadTGA
=============
*/
void LoadTGA( const char *name, byte **pic, int *width, int *height, byte alphaByte )
{
	unsigned int columns, rows, numPixels;
	byte        *pixbuf;
	int         row, column;
	byte        *buf_p;
	byte        *buffer;
	TargaHeader targa_header;
	byte        *targa_rgba;

	*pic = NULL;

	//
	// load the file
	//
	ri.FS_ReadFile( ( char * ) name, ( void ** ) &buffer );

	if ( !buffer )
	{
		return;
	}

	buf_p = buffer;

	targa_header.id_length = *buf_p++;
	targa_header.colormap_type = *buf_p++;
	targa_header.image_type = *buf_p++;

	targa_header.colormap_index = LittleShort( * ( short * ) buf_p );
	buf_p += 2;
	targa_header.colormap_length = LittleShort( * ( short * ) buf_p );
	buf_p += 2;
	targa_header.colormap_size = *buf_p++;
	targa_header.x_origin = LittleShort( * ( short * ) buf_p );
	buf_p += 2;
	targa_header.y_origin = LittleShort( * ( short * ) buf_p );
	buf_p += 2;
	targa_header.width = LittleShort( * ( short * ) buf_p );
	buf_p += 2;
	targa_header.height = LittleShort( * ( short * ) buf_p );
	buf_p += 2;
	targa_header.pixel_size = *buf_p++;
	targa_header.attributes = *buf_p++;

	if ( targa_header.image_type != 2 && targa_header.image_type != 10 && targa_header.image_type != 3 )
	{
		ri.FS_FreeFile( buffer );
		ri.Error( ERR_DROP, "LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported (%s)", name );
	}

	if ( targa_header.colormap_type != 0 )
	{
		ri.FS_FreeFile( buffer );
		ri.Error( ERR_DROP, "LoadTGA: colormaps not supported (%s)", name );
	}

	if ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) && targa_header.image_type != 3 )
	{
		ri.FS_FreeFile( buffer );
		ri.Error( ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps) (%s)", name );
	}

	columns = targa_header.width;
	rows = targa_header.height;
	numPixels = columns * rows * 4;

	if ( width )
	{
		*width = columns;
	}

	if ( height )
	{
		*height = rows;
	}

	if ( !columns || !rows || numPixels > 0x7FFFFFFF || numPixels / columns / 4 != rows )
	{
		ri.FS_FreeFile( buffer );
		ri.Error( ERR_DROP, "LoadTGA: %s has an invalid image size", name );
	}

	targa_rgba = (byte*) ri.Z_Malloc( numPixels );

	*pic = targa_rgba;

	if ( targa_header.id_length != 0 )
	{
		buf_p += targa_header.id_length; // skip TARGA image comment
	}

	if ( targa_header.image_type == 2 || targa_header.image_type == 3 )
	{
		// Uncompressed RGB or gray scale image
		for ( row = rows - 1; row >= 0; row-- )
//.........这里部分代码省略.........
开发者ID:Gireen,项目名称:Unvanquished,代码行数:101,代码来源:tr_image_tga.cpp


示例11: LoadPCX

void LoadPCX(const char *filename, byte ** pic, byte ** palette, int *width, int *height)
{
	byte           *raw;
	pcx_t          *pcx;
	int             x, y, lsize;
	int             len;
	int             dataByte, runLength;
	byte           *out, *pix;


	/* load the file */
	len = vfsLoadFile(filename, (void **)&raw, 0);
	if(len == -1)
		Error("LoadPCX: Couldn't read %s", filename);


	/* parse the PCX file */
	pcx = (pcx_t *) raw;
	raw = &pcx->data;

	pcx->xmin = LittleShort(pcx->xmin);
	pcx->ymin = LittleShort(pcx->ymin);
	pcx->xmax = LittleShort(pcx->xmax);
	pcx->ymax = LittleShort(pcx->ymax);
	pcx->hres = LittleShort(pcx->hres);
	pcx->vres = LittleShort(pcx->vres);
	pcx->bytes_per_line = LittleShort(pcx->bytes_per_line);
	pcx->palette_type = LittleShort(pcx->palette_type);

	if(pcx->manufacturer != 0x0a
	   || pcx->version != 5 || pcx->encoding != 1 || pcx->bits_per_pixel != 8 || pcx->xmax >= 640 || pcx->ymax >= 480)
		Error("Bad pcx file %s", filename);

	if(palette)
	{
		*palette = safe_malloc(768);
		memcpy(*palette, (byte *) pcx + len - 768, 768);
	}

	if(width)
		*width = pcx->xmax + 1;
	if(height)
		*height = pcx->ymax + 1;

	if(!pic)
		return;

	out = safe_malloc((pcx->ymax + 1) * (pcx->xmax + 1));
	if(!out)
		Error("LoadPCX: couldn't allocate");

	*pic = out;
	pix = out;

	/* RR2DO2: pcx fix  */
	lsize = pcx->color_planes * pcx->bytes_per_line;

	/* go scanline by scanline */
	for(y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1)
	{
		/* do a scanline */
		for(x = 0; x <= pcx->xmax;)
		{
			/* RR2DO2 */
			DECODEPCX(raw, dataByte, runLength);
			while(runLength-- > 0)
				pix[x++] = dataByte;
		}

		/* RR2DO2: discard any other data */
		while(x < lsize)
		{
			DECODEPCX(raw, dataByte, runLength);
			x++;
		}
		while(runLength-- > 0)
			x++;
	}

	/* validity check */
	if(raw - (byte *) pcx > len)
		Error("PCX file %s was malformed", filename);
	free(pcx);
}
开发者ID:redrumrobot,项目名称:dretchstorm,代码行数:84,代码来源:imagelib.c


示例12: Mod_LoadFaces

/*
=================
Mod_LoadFaces
=================
*/
void Mod_LoadFaces (lump_t *l)
{
    dface_t		*in;
    msurface_t 	*out;
    int			i, count, surfnum;
    int			planenum, side;

    in = (void *)(mod_base + l->fileofs);
    if (l->filelen % sizeof(*in))
        Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
    count = l->filelen / sizeof(*in);
    out = Hunk_AllocName ( count*sizeof(*out), loadname);

    loadmodel->surfaces = out;
    loadmodel->numsurfaces = count;

    for ( surfnum=0 ; surfnum<count ; surfnum++, in++, out++)
    {
        out->firstedge = LittleLong(in->firstedge);
        out->numedges = LittleShort(in->numedges);
        out->flags = 0;

        planenum = LittleShort(in->planenum);
        side = LittleShort(in->side);
        if (side)
            out->flags |= SURF_PLANEBACK;

        out->plane = loadmodel->planes + planenum;

        out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);

        CalcSurfaceExtents (out);

        // lighting info

        for (i=0 ; i<MAXLIGHTMAPS ; i++)
            out->styles[i] = in->styles[i];
        i = LittleLong(in->lightofs);
        if (i == -1)
            out->samples = NULL;
        else
            out->samples = loadmodel->lightdata + i;

        // set the drawing flags flag

        if (!Q_strncmp(out->texinfo->texture->name,"sky",3))	// sky
        {
            out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
#ifndef QUAKE2
            GL_SubdivideSurface (out);	// cut up polygon for warps
#endif
            continue;
        }

        if (!Q_strncmp(out->texinfo->texture->name,"*",1))		// turbulent
        {
            out->flags |= (SURF_DRAWTURB | SURF_DRAWTILED);
            for (i=0 ; i<2 ; i++)
            {
                out->extents[i] = 16384;
                out->texturemins[i] = -8192;
            }
            GL_SubdivideSurface (out);	// cut up polygon for warps
            continue;
        }

    }
}
开发者ID:Cabriter,项目名称:Quake,代码行数:73,代码来源:gl_model.c


示例13: ResampleSfx

/*
================
ResampleSfx
================
*/
void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
{
	int		outcount;
	int		srcsample;
	float	stepscale;
	int		i;
	int		sample, samplefrac, fracstep;
	sfxcache_t	*sc;
	
	sc = sfx->cache;
	if (!sc)
		return;

	stepscale = (float)inrate / dma.speed;	// this is usually 0.5, 1, or 2

	outcount = sc->length / stepscale;
	sc->length = outcount;
	if (sc->loopstart != -1)
		sc->loopstart = sc->loopstart / stepscale;

	sc->speed = dma.speed;
	// moved in S_LoadSound
	/*
	if (s_loadas8bit->value)
		sc->width = 1;
	else
		sc->width = inwidth;
	*/
	sc->stereo = 0;

// resample / decimate to the current source rate

	if (stepscale == 1 && inwidth == 1 && sc->width == 1)
	{
#if DEBUG_AUDIO
	Com_Printf ("ResampleSfx : fast case 1\n" );
#endif
// fast special case
		for (i=0 ; i<outcount ; i++)
			((signed char *)sc->data)[i]
			= (int)( (unsigned char)(data[i]) - 128);
	}
	else if (stepscale == 1 && inwidth == 2 && sc->width == 1  )
	{
#if DEBUG_AUDIO
	Com_Printf ("ResampleSfx : fast case 2\n" );
#endif
// fast special case : used for android on arm processor
		for (i=0 ; i<outcount ; i++)
			((signed char *)sc->data)[i]
			= ( (signed char)(data[2*i+1]) );
	}
	else
	{
#if DEBUG_AUDIO
	Com_Printf ("ResampleSfx : stepscale=%.1f inwidth=%d outwidth=%d\n",
			stepscale, inwidth, sc->width  );
#endif
// general case
		samplefrac = 0;
		fracstep = stepscale*256;
		for (i=0 ; i<outcount ; i++)
		{
			srcsample = samplefrac >> 8;
			samplefrac += fracstep;
			if (inwidth == 2)
				sample = LittleShort ( ((short *)data)[srcsample] );
			else
				sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
			if (sc->width == 2)
				((short *)sc->data)[i] = sample;
			else
				((signed char *)sc->data)[i] = sample >> 8;
		}
	}
}
开发者ID:AbandonedCart,项目名称:XperiaPlayNative,代码行数:81,代码来源:snd_mem.c


示例14: AAS_RT_ReadRouteTable

qboolean AAS_RT_ReadRouteTable(fileHandle_t fp)
{
	int                  ident, version, i;
	unsigned short int   crc, crc_aas;
	aas_rt_t             *routetable;
	aas_rt_child_t       *child;
	aas_rt_parent_t      *parent;
	aas_rt_parent_link_t *plink;
	unsigned short int   *psi;

	qboolean doswap;

#ifdef DEBUG_READING_TIME
	int pretime;

	pretime = Sys_MilliSeconds();
#endif

	routetable = (*aasworld).routetable;

	doswap = (LittleLong(1) != 1);

	// check ident
	AAS_RT_DBG_Read(&ident, sizeof(ident), fp);
	ident = LittleLong(ident);

	if (ident != RTBID)
	{
		AAS_Error("File is not an RTB file\n");
		botimport.FS_FCloseFile(fp);
		return qfalse;
	}

	// check version
	AAS_RT_DBG_Read(&version, sizeof(version), fp);
	version = LittleLong(version);

	if (version != RTBVERSION)
	{
		AAS_Error("File is version %i not %i\n", version, RTBVERSION);
		botimport.FS_FCloseFile(fp);
		return qfalse;
	}

	// read the CRC check on the AAS data
	AAS_RT_DBG_Read(&crc, sizeof(crc), fp);
	crc = LittleShort(crc);

	// calculate a CRC on the AAS areas
	crc_aas = CRC_ProcessString((unsigned char *)(*aasworld).areas, sizeof(aas_area_t) * (*aasworld).numareas);

	if (crc != crc_aas)
	{
		AAS_Error("Route-table is from different AAS file, ignoring.\n");
		botimport.FS_FCloseFile(fp);
		return qfalse;
	}

	// read the route-table

	// children
	botimport.FS_Read(&routetable->numChildren, sizeof(int), fp);
	routetable->numChildren = LittleLong(routetable->numChildren);
	routetable->children    = (aas_rt_child_t *) AAS_RT_GetClearedMemory(routetable->numChildren * sizeof(aas_rt_child_t));
	botimport.FS_Read(routetable->children, routetable->numChildren * sizeof(aas_rt_child_t), fp);
	child = &routetable->children[0];
	if (doswap)
	{
		for (i = 0; i < routetable->numChildren; i++, child++)
		{
			child->areanum          = LittleShort(child->areanum);
			child->numParentLinks   = LittleLong(child->numParentLinks);
			child->startParentLinks = LittleLong(child->startParentLinks);
		}
	}

	// parents
	botimport.FS_Read(&routetable->numParents, sizeof(int), fp);
	routetable->numParents = LittleLong(routetable->numParents);
	routetable->parents    = (aas_rt_parent_t *) AAS_RT_GetClearedMemory(routetable->numParents * sizeof(aas_rt_parent_t));
	botimport.FS_Read(routetable->parents, routetable->numParents * sizeof(aas_rt_parent_t), fp);
	parent = &routetable->parents[0];
	if (doswap)
	{
		for (i = 0; i < routetable->numParents; i++, parent++)
		{
			parent->areanum             = LittleShort(parent->areanum);
			parent->numParentChildren   = LittleLong(parent->numParentChildren);
			parent->startParentChildren = LittleLong(parent->startParentChildren);
			parent->numVisibleParents   = LittleLong(parent->numVisibleParents);
			parent->startVisibleParents = LittleLong(parent->startVisibleParents);
		}
	}

	// parentChildren
	botimport.FS_Read(&routetable->numParentChildren, sizeof(int), fp);
	routetable->numParentChildren = LittleLong(routetable->numParentChildren);
	routetable->parentChildren    = (unsigned short int *) AAS_RT_GetClearedMemory(routetable->numParentChildren * sizeof(unsigned short int));
	botimport.FS_Read(routetable->parentChildren, routetable->numParentChildren * sizeof(unsigned short int), fp);
	psi = &routetable->parentChildren[0];
//.........这里部分代码省略.........
开发者ID:morsik,项目名称:war-territory,代码行数:101,代码来源:be_aas_routetable.c


示例15: write_short

static void write_short(FILE *f, short v)
{
    v = LittleShort(v);
    write_data(&v, sizeof(v), f);
}
开发者ID:Jenco420,项目名称:q2pro,代码行数:5,代码来源:g_save.c


示例16: LittleShort

/*
 =================
 idFile::WriteUnsignedShort
 =================
 */
int idFile::WriteUnsignedShort( const unsigned short value ) {
    unsigned short v = LittleShort(value);
    return Write( &v, sizeof( v ) );
}
开发者ID:kortemik,项目名称:dhewm3,代码行数:9,代码来源:File.cpp


示例17: R_LoadMDC


//.........这里部分代码省略.........
			for (j = 0; j < 3; j++)
			{
				frame->bounds[0][j]   = 128;
				frame->bounds[1][j]   = -128;
				frame->localOrigin[j] = LittleFloat(mdcFrame->localOrigin[j]);
			}
		}
		else
#endif
		{
			frame->radius = LittleFloat(mdcFrame->radius);

			for (j = 0; j < 3; j++)
			{
				frame->bounds[0][j]   = LittleFloat(mdcFrame->bounds[0][j]);
				frame->bounds[1][j]   = LittleFloat(mdcFrame->bounds[1][j]);
				frame->localOrigin[j] = LittleFloat(mdcFrame->localOrigin[j]);
			}
		}
	}

	// swap all the tags
	mdvModel->numTags = mdcModel->numTags;
	mdvModel->tags    = tag = ri.Hunk_Alloc(sizeof(*tag) * (mdcModel->numTags * mdcModel->numFrames), h_low);

	mdcTag = ( mdcTag_t * )(( byte * ) mdcModel + mdcModel->ofsTags);

	for (i = 0; i < mdcModel->numTags * mdcModel->numFrames; i++, tag++, mdcTag++)
	{
		vec3_t angles;

		for (j = 0; j < 3; j++)
		{
			tag->origin[j] = ( float ) LittleShort(mdcTag->xyz[j]) * MD3_XYZ_SCALE;
			angles[j]      = ( float ) LittleShort(mdcTag->angles[j]) * MDC_TAG_ANGLE_SCALE;
		}

		AnglesToAxis(angles, tag->axis);
	}

	mdvModel->tagNames = tagName = ri.Hunk_Alloc(sizeof(*tagName) * (mdcModel->numTags), h_low);

	mdcTagName = ( mdcTagName_t * )(( byte * ) mdcModel + mdcModel->ofsTagNames);

	for (i = 0; i < mdcModel->numTags; i++, tagName++, mdcTagName++)
	{
		Q_strncpyz(tagName->name, mdcTagName->name, sizeof(tagName->name));
	}

	// swap all the surfaces
	mdvModel->numSurfaces = mdcModel->numSurfaces;
	mdvModel->surfaces    = surf = ri.Hunk_Alloc(sizeof(*surf) * mdcModel->numSurfaces, h_low);

	mdcSurf = ( mdcSurface_t * )(( byte * ) mdcModel + mdcModel->ofsSurfaces);

	for (i = 0; i < mdcModel->numSurfaces; i++)
	{
		LL(mdcSurf->ident);
		LL(mdcSurf->flags);
		LL(mdcSurf->numBaseFrames);
		LL(mdcSurf->numCompFrames);
		LL(mdcSurf->numShaders);
		LL(mdcSurf->numTriangles);
		LL(mdcSurf->ofsTriangles);
		LL(mdcSurf->numVerts);
		LL(mdcSurf->ofsShaders);
开发者ID:Ododo,项目名称:etlegacy,代码行数:67,代码来源:tr_model_mdc.c


示例18: R_LoadMD3


//.........这里部分代码省略.........
    tag = (md3Tag_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsTags );
    for ( i = 0 ; i < mod->md3[lod]->numTags * mod->md3[lod]->numFrames ; i++, tag++) {
        for ( j = 0 ; j < 3 ; j++ ) {
			tag->origin[j] = LittleFloat( tag->origin[j] );
			tag->axis[0][j] = LittleFloat( tag->axis[0][j] );
			tag->axis[1][j] = LittleFloat( tag->axis[1][j] );
			tag->axis[2][j] = LittleFloat( tag->axis[2][j] );
        }
	}
#endif

	// swap all the surfaces
	surf = (md3Surface_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsSurfaces );
	for ( i = 0 ; i < mod->md3[lod]->numSurfaces ; i++) {
        LL(surf->flags);
        LL(surf->numFrames);
        LL(surf->numShaders);
        LL(surf->numTriangles);
        LL(surf->ofsTriangles);
        LL(surf->numVerts);
        LL(surf->ofsShaders);
        LL(surf->ofsSt);
        LL(surf->ofsXyzNormals);
        LL(surf->ofsEnd);
		
		if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
			Com_Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",
				mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
		}
		if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
			Com_Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",
				mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );
		}
	
		// change to surface identifier
		surf->ident = SF_MD3;

		// lowercase the surface name so skin compares are faster
		Q_strlwr( surf->name );

		// strip off a trailing _1 or _2
		// this is a crutch for q3data being a mess
		j = strlen( surf->name );
		if ( j > 2 && surf->name[j-2] == '_' ) {
			surf->name[j-2] = 0;
		}

        // register the shaders
        shader = (md3Shader_t *) ( (byte *)surf + surf->ofsShaders );
        for ( j = 0 ; j < surf->numShaders ; j++, shader++ ) {
            shader_t	*sh;

            sh = R_FindShader( shader->name, lightmapsNone, stylesDefault, qtrue );
			if ( sh->defaultShader ) {
				shader->shaderIndex = 0;
			} else {
				shader->shaderIndex = sh->index;
			}
			RE_RegisterModels_StoreShaderRequest(mod_name, &shader->name[0], &shader->shaderIndex);
        }


#if 0 //#ifndef _M_IX86
//
// optimisation, we don't bother doing this for standard intel case since our data's already in that format...
//

		// swap all the triangles
		tri = (md3Triangle_t *) ( (byte *)surf + surf->ofsTriangles );
		for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {
			LL(tri->indexes[0]);
			LL(tri->indexes[1]);
			LL(tri->indexes[2]);
		}

		// swap all the ST
        st = (md3St_t *) ( (byte *)surf + surf->ofsSt );
        for ( j = 0 ; j < surf->numVerts ; j++, st++ ) {
            st->st[0] = LittleFloat( st->st[0] );
            st->st[1] = LittleFloat( st->st[1] );
        }

		// swap all the XyzNormals
        xyz = (md3XyzNormal_t *) ( (byte *)surf + surf->ofsXyzNormals );
        for ( j = 0 ; j < surf->numVerts * surf->numFrames ; j++, xyz++ ) 
		{
            xyz->xyz[0] = LittleShort( xyz->xyz[0] );
            xyz->xyz[1] = LittleShort( xyz->xyz[1] );
            xyz->xyz[2] = LittleShort( xyz->xyz[2] );

            xyz->normal = LittleShort( xyz->normal );
        }
#endif

		// find the next surface
		surf = (md3Surface_t *)( (byte *)surf + surf->ofsEnd );
	}
    
	return qtrue;
}
开发者ID:Almightygir,项目名称:OpenJK,代码行数:101,代码来源:tr_model.cpp


示例19: Zip_FindCentralDir

bool FZipFile::Open(bool quiet)
{
	DWORD centraldir = Zip_FindCentralDir(Reader);
	FZipEndOfCentralDirectory info;
	int skipped = 0;

	Lumps = NULL;

	if (centraldir == 0)
	{
		if (!quiet) Printf(TEXTCOLOR_RED "\n%s: ZIP file corrupt!\n", Filename);
		return false;
	}

	// Read the central directory info.
	Reader->Seek(centraldir, SEEK_SET);
	Reader->Read(&info, sizeof(FZipEndOfCentralDirectory));

	// No multi-disk zips!
	if (info.NumEntries != info.NumEntriesOnAllDisks ||
		info.FirstDisk != 0 || info.DiskNumber != 0)
	{
		if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Multipart Zip files are not supported.\n", Filename);
		return false;
	}

	NumLumps = LittleShort(info.NumEntries);
	Lumps = new FZipLump[NumLumps];

	// Load the entire central directory. Too bad that this contains variable length entries...
	int dirsize = LittleLong(info.DirectorySize);
	void *directory = malloc(dirsize);
	Reader->Seek(LittleLong(info.DirectoryOffset), SEEK_SET);
	Reader->Read(directory, dirsize);

	char *dirptr = (char*)directory;
	FZipLump *lump_p = Lumps;
	for (DWORD i = 0; i < NumLumps; i++)
	{
		FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr;

		int len = LittleShort(zip_fh->NameLength);
		FString name(dirptr + sizeof(FZipCentralDirectoryInfo), len);
		dirptr += sizeof(FZipCentralDirectoryInfo) + 
				  LittleShort(zip_fh->NameLength) + 
				  LittleShort(zip_fh->ExtraLength) + 
				  LittleShort(zip_fh->CommentLength);

		if (dirptr > ((char*)directory) + dirsize)	// This directory entry goes beyond the end of the file.
		{
			free(directory);
			if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Central directory corrupted.", Filename);
			return false;
		}
		
		// skip Directories
		if (name[len - 1] == '/' && LittleLong(zip_fh->UncompressedSize) == 0) 
		{
			skipped++;
			continue;
		}

		// Ignore unknown compression formats
		zip_fh->Method = LittleShort(zip_fh->Method);
		if (zip_fh->Method != METHOD_STORED &&
			zip_fh->Method != METHOD_DEFLATE &&
			zip_fh->Method != METHOD_LZMA &&
			zip_fh->Method != METHOD_BZIP2 &&
			zip_fh->Method != METHOD_IMPLODE &&
			zip_fh->Method != METHOD_SHRINK)
		{
			if (!quiet) Printf(TEXTCOLOR_YELLOW "\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", Filename, name.GetChars(), zip_fh->Method);
			skipped++;
			continue;
		}
		// Also ignore encrypted entries
		zip_fh->Flags = LittleShort(zip_fh->Flags);
		if (zip_fh->Flags & ZF_ENCRYPTED)
		{
			if (!quiet) Printf(TEXTCOLOR_YELLOW "\n%s: '%s' is encrypted. Encryption is not supported.\n", Filename, name.GetChars());
			skipped++;
			continue;
		}

		FixPathSeperator(name);
		name.ToLower();

		lump_p->LumpNameSetup(name);
		lump_p->LumpSize = LittleLong(zip_fh->UncompressedSize);
		lump_p->Owner = this;
		// The start of the Reader will be determined the first time it is accessed.
		lump_p->Flags = LUMPF_ZIPFILE | LUMPFZIP_NEEDFILESTART;
		lump_p->Method = BYTE(zip_fh->Method);
		lump_p->GPFlags = zip_fh->Flags;
		lump_p->CompressedSize = LittleLong(zip_fh->CompressedSize);
		lump_p->Position = LittleLong(zip_fh->LocalHeaderOffset);
		lump_p->CheckEmbedded();

		// Ignore some very specific names
		if (0 == stricmp("dehacked.exe", name))
//.........这里部分代码省略.........
开发者ID:Accusedbold,项目名称:zdoom,代码行数:101,代码来源:file_zip.cpp


示例20: LittleShort

	fracstep = ((unsigned)rate << 8) / (unsigned)dma.speed;
	samplefrac = 0;

	if( width == 2 ) {
		int16 *in = (int16 *)data;

		if( nchannels == 2 ) {
			for( src = 0; src < samples; samplefrac += fracstep, src = (samplefrac >> 8) ) {
				dst = s_rawend++ & (MAX_RAW_SAMPLES - 1);
				s_rawsamples[dst].left = LittleShort( in[src*2] ) * snd_vol;
				s_rawsamples[dst].right = LittleShort( in[src*2+1] ) * snd_vol;
			}
		} else  {
			for( src = 0; src < samples; samplefrac += fracstep, src = (samplefrac >> 8) ) {
				dst = s_rawend++ & (MAX_RAW_SAMPLES - 1);
				s_rawsamples[dst].left = s_rawsamples[dst].right = LittleShort( in[src] ) * snd_vol;
			}
		}
	} else {
		if( nchannels == 2 ) {
			char *in = (char *)data;

			for( src = 0; src < samples; samplefrac += fracstep, src = (samplefrac >> 8) ) {
				dst = s_rawend++ & (MAX_RAW_SAMPLES - 1);
				s_rawsamples[dst].left = in[src*2] << 8 * snd_vol;
				s_rawsamples[dst].right = in[src*2+1] << 8 * snd_vol;
			}
		} else {
			for( src = 0; src < samples; samplefrac += fracstep, src = (samplefrac >> 8) ) {
				dst = s_rawend++ & (MAX_RAW_SAMPLES - 1);
				s_rawsamples[dst].left = s_rawsamples[dst].right = (data[src] - 128) << 8 * snd_vol;
开发者ID:hifi-unmaintained,项目名称:aprq2,代码行数:31,代码来源:snd_dma.c



注:本文中的LittleShort函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LnkMsg函数代码示例发布时间:2022-05-30
下一篇:
C++ LittleFloat函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap