示例#1
0
//--------------------------------------------------------------------------------------------------
void CSoundStream::LoadADPCM( )
{
    char			buf	[255];
	int				pos;
	sxr_riff		riff;
	sxr_hdr			hdr;

	string256		fn;
	strconcat		(fn,fName,".ogg");

	DataPos			= NULL;

    hf				= FS.r_open("$game_sounds$",fn);
	R_ASSERT		(hf>=0);
	ZeroMemory		(&riff, sizeof(riff));
    XRead			(riff);
    CopyMemory	(buf,riff.id,4); buf[4]=0;
    CopyMemory	(buf,riff.wave_id,4); buf[4]=0;

    while (!hf->eof()) 
	{
		XRead			(hdr);
        CopyMemory	(buf,hdr.id,4); buf[4]=0;
        pos				= hf->tell();
        if (stricmp(buf, "fmt ")==0) {
			dwFMT_Size		= hdr.len;
			psrc			= (LPWAVEFORMATEX)xr_malloc(dwFMT_Size);
			pwfx			= (LPWAVEFORMATEX)xr_malloc(dwFMT_Size);
			hf->r			(psrc,		dwFMT_Size);
			CopyMemory	(pwfx,psrc,	dwFMT_Size);
			pwfx->wFormatTag = WAVE_FORMAT_PCM;
        } else {
            if (stricmp(buf,"data")==0) {
                DataPos=hf->tell();
				dwTotalSize=hdr.len;
            }
		}
        hf->seek(hdr.len+pos);
    }

	VERIFY	(DataPos);
	// dest format
	CHK_DX	(acmFormatSuggest(NULL,psrc,pwfx,dwFMT_Size,ACM_FORMATSUGGESTF_WFORMATTAG));
	// dest buffer (const size)
    WaveDest		= (unsigned char *)xr_malloc(dwDestBufSize);
	// wave source -- alloc on Play

    // DSound----------------------------------------------------------------
	ADPCMCreateSoundBuffer	(SoundRender.pDevice, &pBuffer, pwfx);
}
示例#2
0
reader::reader(IReader* freader)
{
	m_info_section				= NULL;
	m_jpeg_data					= NULL;
	VERIFY						(freader);
	
	u32 file_size				= freader->elapsed();
	VERIFY						(file_size);
	m_jpeg_data					= static_cast<u8*>(xr_malloc(file_size + 1));
	m_jpeg_data_size			= file_size;
	freader->r					(m_jpeg_data, m_jpeg_data_size);
	m_jpeg_data[file_size]		= 0;

	char* tmp_info_begin		= search_info_section(
		m_jpeg_data,
		m_jpeg_data_size);
	
	if (!tmp_info_begin)
	{
		Msg("Can't find info section");
		return;
	}
	--tmp_info_begin;//- '['
	u32 m_info_size				= xr_strlen(tmp_info_begin);
	m_info_pos					= static_cast<u32>((u8*)tmp_info_begin - m_jpeg_data);

	IReader	tmp_reader			(tmp_info_begin, m_info_size);
	m_info_section				= new CInifile(&tmp_reader);
}
示例#3
0
void ppmd_initialize		()
{
	if (trained_model)
		trained_model->rewind	();

	static bool	initialized	= false;
	if (initialized)
		return;

	string_path			file_name;

	FS.update_path		(file_name,"$game_config$","mp\\!PPMd.mdl");
	if (FS.exist(file_name)) {
		IReader			*reader = FS.r_open(file_name);
		R_ASSERT		(reader);
		u32				buffer_size = reader->length();
		u8				*buffer = (u8*)xr_malloc(buffer_size);
		reader->r		(buffer,buffer_size);
		FS.r_close		(reader);
		trained_model	= new stream(buffer,buffer_size);
	}

	initialized		= true;
	if (StartSubAllocator(suballocator_size))
		return;
	
	exit			(-1);
}
示例#4
0
void CSoundStream::Play	( BOOL loop, int cnt )
{
	VERIFY(Sound);

	if (isPause) { Pause(); return; }
	if (dwStatus & DSBSTATUS_PLAYING) return;
    dwDecPos		= 0;
	isPresentData	= true;
//----------------
	if (hAcmStream){
		CHK_DX(acmStreamClose(hAcmStream,0));
	}
	CHK_DX(acmStreamOpen(&hAcmStream,0,psrc,pwfx,0,NULL,0,0));
	CHK_DX(acmStreamSize(hAcmStream,dwDestBufSize,LPDWORD(&dwSrcBufSize),ACM_STREAMSIZEF_DESTINATION));
	// alloc source data buffer
	VERIFY(dwSrcBufSize);
	xr_free(WaveSource);
	WaveSource = (unsigned char *)xr_malloc(dwSrcBufSize);

	// seek to data start
	hf->seek	(DataPos);
	writepos	= 0;
	Decompress	(WaveDest);
	writepos	=stream.cbDstLengthUsed;
//-------
	iLoopCountRested= cnt;
	bMustLoop		= loop;
	bMustPlay		= true;
}
示例#5
0
void CImage::Create(u32 w, u32 h)
{
	xr_free		(pData);
	dwWidth		= w;
	dwHeight	= h;
	pData		= (u32*)(xr_malloc(w*h*sizeof(u32)));
}
示例#6
0
bool EDetail::Update	(LPCSTR name)
{
	m_sRefs				= name;
    // update link
    CEditableObject* R	= Lib.CreateEditObject(name);
    if (!R){
 		ELog.Msg		(mtError,"Can't load detail object '%s'.", name);
        return false;
    }
    if(R->SurfaceCount()!=1){
    	ELog.Msg		(mtError,"Object must contain 1 material.");
	    Lib.RemoveEditObject(R);
    	return false;
    }
	if(R->MeshCount()==0){
    	ELog.Msg		(mtError,"Object must contain 1 mesh.");
	    Lib.RemoveEditObject(R);
    	return false;
    }

    Lib.RemoveEditObject(m_pRefs);
    m_pRefs				= R;

    // fill geometry
    CEditableMesh* M	= *m_pRefs->FirstMesh();
    U16Vec inds;

    // fill vertices
    bv_bb.invalidate();
    u32 idx			= 0;
    for (u32 f_id=0; f_id<M->GetFCount(); f_id++){
        st_Face& F 	= M->GetFaces()[f_id];
    	u16 ind[3];
    	for (int k=0; k<3; k++,idx++){
            Fvector& P  = M->GetVerts()[F.pv[k].pindex];
            st_VMapPt&vm= M->GetVMRefs()[F.pv[k].vmref].pts[0];
            Fvector2& uv= M->GetVMaps()[vm.vmap_index]->getUV(vm.index);
        	ind[k]		= _AddVert	(P,uv.x,uv.y);
	        bv_bb.modify(vertices[ind[k]].P);
        }
        if (isDegenerated(ind))	continue;
        if (isEqual(inds,ind))	continue;
        inds.push_back(ind[0]);
        inds.push_back(ind[1]);
        inds.push_back(ind[2]);
    }
	number_indices 		= inds.size();
	indices				= (u16*)xr_malloc(number_indices*sizeof(u16));
    Memory.mem_copy		(indices,inds.begin(),number_indices*sizeof(u16));

	bv_bb.getsphere		(bv_sphere.P,bv_sphere.R);

    OnDeviceCreate		();

    return true;
}
void global_slots_data::read( INetReader &r  )
{
	
	r_pod( r, dtH );
	R_ASSERT( !dtS );
	const u32 buffer_size = sizeof( DetailSlot ) * dtH.slots_count();
	dtS = ( DetailSlot* )xr_malloc( buffer_size );
	R_ASSERT(dtS);
	r.r( dtS, buffer_size );
	recalculation_data.read( r );
}
示例#8
0
void read(INetReader &r, b_texture &b)
{
	r.r_string( b.name, sizeof(b.name) );
	b.dwWidth = r.r_u32(  );
	b.dwHeight = r.r_u32( );
	b.bHasAlpha = r.r_s32(  );

	b.pSurface = NULL;
	bool b_surface = !!r.r_u8();
	if(b_surface)
	{
		u32 size = sizeof( u32 ) *  b.dwWidth * b.dwHeight;
		b.pSurface = (u32*)xr_malloc( size );
		r.r( b.pSurface, size );
	}
}
示例#9
0
CSavedGameWrapper::CSavedGameWrapper		(LPCSTR saved_game_name)
{
	string_path					file_name;
	saved_game_full_name		(saved_game_name,file_name);
	R_ASSERT3					(FS.exist(file_name),"There is no saved game ",file_name);
	
	IReader						*stream = FS.r_open(file_name);
	if (!valid_saved_game(*stream)) {
		FS.r_close				(stream);
		CALifeTimeManager		time_manager(alife_section);
		m_game_time				= time_manager.game_time();
		m_actor_health			= 1.f;
		m_level_id				= ai().game_graph().header().levels().begin()->first;
		return;
	}

	u32							source_count = stream->r_u32();
	void						*source_data = xr_malloc(source_count);
	rtc_decompress				(source_data,source_count,stream->pointer(),stream->length() - 3*sizeof(u32));
	FS.r_close					(stream);

	IReader						reader(source_data,source_count);

	{
		CALifeTimeManager		time_manager(alife_section);
		time_manager.load		(reader);
		m_game_time				= time_manager.game_time();
	}

	{
		R_ASSERT2				(reader.find_chunk(OBJECT_CHUNK_DATA),"Can't find chunk OBJECT_CHUNK_DATA!");
		u32						count = reader.r_u32();
		VERIFY					(count > 0);
		CSE_ALifeDynamicObject	*object = CALifeObjectRegistry::get_object(reader);
		VERIFY					(object->ID == 0);
		CSE_ALifeCreatureActor	*actor = smart_cast<CSE_ALifeCreatureActor*>(object);
		VERIFY					(actor);

		m_actor_health			= actor->g_Health();
		m_level_id				= ai().game_graph().vertex(object->m_tGraphID)->level_id();

		F_entity_Destroy		(object);
	}

	xr_free						(source_data);
}
示例#10
0
u32*	Surface_Load(char* name, u32& w, u32& h)
{
	if (strchr(name,'.')) *(strchr(name,'.')) = 0;

	// detect format
	string_path		full;
	if (!Surface_Detect(full,name)) return NULL;

	FIBITMAP* map32		= Surface_Load(full);

	h					= FreeImage_GetHeight	(map32);
	w					= FreeImage_GetWidth	(map32);

	u32			memSize	= w*h*4;
	u32*		memPTR	= (u32*)(xr_malloc(memSize));
	u32*		memDATA	= (u32*)(FreeImage_GetScanLine(map32,0));
	CopyMemory	(memPTR,memDATA,memSize);
	FreeImage_Unload		(map32);
	return		memPTR;
}
示例#11
0
dx10ConstantBuffer::dx10ConstantBuffer(ID3D10ShaderReflectionConstantBuffer* pTable)
	: m_bChanged(true)
{
	D3D10_SHADER_BUFFER_DESC Desc;

	CHK_DX(pTable->GetDesc(&Desc));

	m_strBufferName._set(Desc.Name);
	m_eBufferType = Desc.Type;
	m_uiBufferSize = Desc.Size;

	//	Fill member list with variable descriptions
	m_MembersList.resize(Desc.Variables);
	m_MembersNames.resize(Desc.Variables);
	for (u32 i=0; i<Desc.Variables; ++i)
	{
		ID3D10ShaderReflectionVariable* pVar;
		ID3D10ShaderReflectionType*		pType;

		D3D10_SHADER_VARIABLE_DESC		var_desc;

		pVar = pTable->GetVariableByIndex(i);
		VERIFY(pVar);
		pType = pVar->GetType();
		VERIFY(pType);
		pType->GetDesc(&m_MembersList[i]);
		//	Buffers with the same layout can contain totally different members
		CHK_DX(pVar->GetDesc(&var_desc));
		m_MembersNames[i] = var_desc.Name;
	}

	m_uiMembersCRC = crc32( &m_MembersList[0], Desc.Variables*sizeof(m_MembersList[0]));

	R_CHK(dx10BufferUtils::CreateConstantBuffer(&m_pBuffer, Desc.Size));
	VERIFY(m_pBuffer);
	m_pBufferData = xr_malloc(Desc.Size);
	VERIFY(m_pBufferData);
}
示例#12
0
void InternalRender()
{
	Fvector S,P;
	LevelBB.getsize(S);
	dimX	= iCeil(S.x/g_params.fPatchSize);
	dimZ	= iCeil(S.z/g_params.fPatchSize);

	// allocation
	int		msize = dimX*dimZ*sizeof(Texel);
	texels	= (Texel*)xr_malloc(msize);
	ZeroMemory(texels,msize);

	// rasterization
	for (u32 i=0; i<g_nodes.size(); i++)
	{
		vertex&	N	= g_nodes[i];
		P.sub	(N.Pos, LevelBB.min);
		int		nx	= iFloor(P.x/g_params.fPatchSize+0.5f);	clamp(nx,0,dimX-1);
		int		nz	= iFloor(P.z/g_params.fPatchSize+0.5f);	clamp(nz,0,dimZ-1);

		Texel&	T	= texels[(dimZ-nz-1)*dimX+nx];
		T.depth++;
		if (T.N)	{ if (N.Pos.y>T.N->Pos.y)	T.N = &N; }
		else		T.N = &N;
	}

	// limits
	for (int t=0; t<dimX*dimZ; t++)
	{
		Texel& T	= texels[t];
		if (T.N)	{
			minH		= _min(minH,T.N->Pos.y);
			maxH		= _max(maxH,T.N->Pos.y);
		}
	}
}
示例#13
0
void line_edit_control::init( u32 str_buffer_size, init_mode mode )
{
	m_buffer_size = str_buffer_size;
	clamp( m_buffer_size, (int)MIN_BUF_SIZE, (int)MAX_BUF_SIZE );

	xr_free( m_edit_str );	m_edit_str = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) );
	xr_free( m_inserted );	m_inserted = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) );
	xr_free( m_undo_buf );	m_undo_buf = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) );
	
	xr_free( m_buf0 );		m_buf0 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) );
	xr_free( m_buf1 );		m_buf1 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) );
	xr_free( m_buf2 );		m_buf2 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) );
	xr_free( m_buf3 );		m_buf3 = (LPSTR)xr_malloc( m_buffer_size * sizeof(char) );

	clear_states();

	for ( u32 i = 0; i < DIK_COUNT; ++i )
	{
		xr_delete( m_actions[i] );
		m_actions[i] = NULL;
	}

	if ( mode == im_read_only )
	{
		assign_callback( DIK_A     , ks_Ctrl, Callback( this, &line_edit_control::select_all_buf       ) );
		assign_callback( DIK_C     , ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard    ) );
		assign_callback( DIK_INSERT, ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard    ) );

		assign_callback( DIK_HOME  , ks_free, Callback( this, &line_edit_control::move_pos_home        ) );
		assign_callback( DIK_END   , ks_free, Callback( this, &line_edit_control::move_pos_end         ) );
		assign_callback( DIK_LEFT  , ks_free, Callback( this, &line_edit_control::move_pos_left        ) );
		assign_callback( DIK_RIGHT , ks_free, Callback( this, &line_edit_control::move_pos_right       ) );
		assign_callback( DIK_LEFT  , ks_Ctrl, Callback( this, &line_edit_control::move_pos_left_word   ) );
		assign_callback( DIK_RIGHT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_right_word  ) );
	}
	else
	{
		assign_char_pairs( mode );

		assign_callback( DIK_INSERT, ks_free, Callback( this, &line_edit_control::flip_insert_mode     ) );
		assign_callback( DIK_A     , ks_Ctrl, Callback( this, &line_edit_control::select_all_buf       ) );
		assign_callback( DIK_Z     , ks_Ctrl, Callback( this, &line_edit_control::undo_buf             ) );

		assign_callback( DIK_C     , ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard    ) );
		assign_callback( DIK_V     , ks_Ctrl, Callback( this, &line_edit_control::paste_from_clipboard ) );
		assign_callback( DIK_X     , ks_Ctrl, Callback( this, &line_edit_control::cut_to_clipboard     ) );

		assign_callback( DIK_INSERT, ks_Ctrl, Callback( this, &line_edit_control::copy_to_clipboard    ) );
		assign_callback( DIK_INSERT, ks_Shift,Callback( this, &line_edit_control::paste_from_clipboard ) );
		assign_callback( DIK_DELETE, ks_Shift,Callback( this, &line_edit_control::cut_to_clipboard     ) );

		assign_callback( DIK_HOME  , ks_free, Callback( this, &line_edit_control::move_pos_home        ) );
		assign_callback( DIK_END   , ks_free, Callback( this, &line_edit_control::move_pos_end         ) );
		assign_callback( DIK_LEFT  , ks_free, Callback( this, &line_edit_control::move_pos_left        ) );
		assign_callback( DIK_RIGHT , ks_free, Callback( this, &line_edit_control::move_pos_right       ) );
		assign_callback( DIK_LEFT  , ks_Ctrl, Callback( this, &line_edit_control::move_pos_left_word   ) );
		assign_callback( DIK_RIGHT , ks_Ctrl, Callback( this, &line_edit_control::move_pos_right_word  ) );

		assign_callback( DIK_BACK  , ks_free, Callback( this, &line_edit_control::delete_selected_back ) );
		assign_callback( DIK_DELETE, ks_free, Callback( this, &line_edit_control::delete_selected_forward ) );
		assign_callback( DIK_BACK  , ks_Ctrl, Callback( this, &line_edit_control::delete_word_back     ) );
		assign_callback( DIK_DELETE, ks_Ctrl, Callback( this, &line_edit_control::delete_word_forward  ) );
	} // if mode

	create_key_state( DIK_LSHIFT  , ks_LShift );
	create_key_state( DIK_RSHIFT  , ks_RShift );
	create_key_state( DIK_LCONTROL, ks_LCtrl  );
	create_key_state( DIK_RCONTROL, ks_RCtrl  );
	create_key_state( DIK_LALT    , ks_LAlt   );
	create_key_state( DIK_RALT    , ks_RAlt   );
}
示例#14
0
void verify_level_graph	(LPCSTR name, bool verbose)
{
	Msg				("Verifying level %s",name);
	Phase			("Verifying level graph");
	Progress		(0.f);
	CLevelGraph		*level_graph = xr_new<CLevelGraph>(name);
	if (!level_graph->header().vertex_count()) {
		Progress	(1.f);
		Msg			("Level graph is empty!");
		xr_delete	(level_graph);
		return;
	}

	if (!verify_invalid_links(*level_graph)) {
		Progress	(1.f);
		Msg			("AI map is CORRUPTED : REGENERATE AI-MAP");
		xr_delete	(level_graph);
		return;
	}

	stack_storage	= (CLevelGraph::CVertex**)xr_malloc(level_graph->header().vertex_count()*sizeof(CLevelGraph::CVertex*));

	xr_vector<bool>	marks;

	xr_vector<u32>	single_links;
	single_links.reserve(level_graph->header().vertex_count());
	Progress		(0.05f);

	for (u32 i=0, n=level_graph->header().vertex_count(); i<n; ++i) {
		CLevelGraph::const_iterator	I, E;
		CLevelGraph::CVertex		*vertex = level_graph->vertex(i);
		level_graph->begin			(vertex,I,E);
		for ( ; I != E; ++I) {
			u32						neighbour_vertex_id = level_graph->value(vertex,I);
			if (level_graph->valid_vertex_id(neighbour_vertex_id) && single_link(*level_graph,neighbour_vertex_id,i,(I + 2)%4)) {
				single_links.push_back	(neighbour_vertex_id);
			}
		}
		Progress					(0.05f + 0.05f*float(i)/float(n));
	}

	bool							no_single_links = single_links.empty();
	Progress						(0.1f);
	if (single_links.empty())
		single_links.push_back		(0);

	{
		sort						(single_links.begin(),single_links.end());
		xr_vector<u32>::iterator	I = unique(single_links.begin(),single_links.end());
		single_links.erase			(I,single_links.end());
	}

	if (!no_single_links) {
		if (verbose) {
			xr_vector<u32>::const_iterator	I = single_links.begin();
			xr_vector<u32>::const_iterator	E = single_links.end();
			for ( ; I != E; ++I)
				Msg					("Vertex %d[%f][%f][%f] is single linked!",*I,VPUSH(level_graph->vertex_position(*I)));
		}
		Msg							("There are %d single linked nodes!",single_links.size());
	}

	Progress						(0.15f);
	bool							valid = true;
	xr_vector<u32>::const_iterator	I = single_links.begin();
	xr_vector<u32>::const_iterator	E = single_links.end();
	for (u32 i=0, n = single_links.size(); I != E; ++I, ++i) {
		marks.assign	(level_graph->header().vertex_count(),false);
		floodfill		(*level_graph,marks,*I);
		xr_vector<bool>::const_iterator	II = marks.begin(), BB = II;
		xr_vector<bool>::const_iterator	EE = marks.end();
		for ( ; II != EE; ++II)
			if (!*II) {
				valid	= false;
				Msg		("AI-map is NOT valid :\nNode \n%6d[%f][%f][%f]\ncannot be reached from the node\n%6d[%f][%f][%f]\n",u32(II - BB),VPUSH(level_graph->vertex_position(u32(II - BB))),*I,VPUSH(level_graph->vertex_position(*I)));
				break;
			}

		if (!valid)
			break;
		Progress		(0.15f + 0.85f*float(i)/float(n));
	}

	xr_free			(stack_storage);
	xr_delete		(level_graph);
	Progress		(1.f);
	if (valid)
		Msg			("AI-map is valid!");

	Msg				("Verifying level %s completed",name);
}
示例#15
0
bool CImage::LoadTGA(LPCSTR name)
{
	destructor<IReader>	TGA(FS.r_open(name));

	TGAHeader	hdr;
	BOOL		hflip, vflip;

	TGA().r(&hdr,sizeof(TGAHeader));

	if (!((hdr.imgtype==2)||(hdr.imgtype==10))){
    	Msg("Unsupported texture format (%s)",name);
        return false;
    }
	if (!((hdr.pixsize==24)||(hdr.pixsize==32))){
    	Msg("Texture (%s) - invalid pixsize: %d",name,hdr.pixsize);
        return false;
    }
#ifndef _EDITOR
	if (!btwIsPow2(hdr.width)){
    	Msg("Texture (%s) - invalid width: %d",name,hdr.width);
        return false;
    }
	if (!btwIsPow2(hdr.height)){
    	Msg("Texture (%s) - invalid height: %d",name,hdr.height);
        return false;
    }
#endif

	// Skip funky stuff
	if (hdr.idlen)	TGA().advance(hdr.idlen);
	if (hdr.cmlen)	TGA().advance(hdr.cmlen*((hdr.cmes+7)/8));

	hflip		= (hdr.desc & 0x10) ? TRUE : FALSE;		// Need hflip
	vflip		= (hdr.desc & 0x20) ? TRUE : FALSE;		// Need vflip

	dwWidth		= hdr.width;
	dwHeight	= hdr.height;
	bAlpha 		= (hdr.pixsize==32);

	// Alloc memory
	pData		= (u32*)xr_malloc(dwWidth*dwHeight*4);

    u32 pixel;
	u32*	ptr	= pData;
    for( int y=0; y<hdr.height; y++ ){
        u32 dwOffset = y*hdr.width;

        if( 0 == ( hdr.desc & 0x0010 ) ) dwOffset = (hdr.height-y-1)*hdr.width;
        for( int x=0; x<hdr.width; ){
            if( hdr.imgtype == 10 ){
                BYTE PacketInfo; TGA().r(&PacketInfo,1);
                u16 PacketType = u16(0x80 & PacketInfo);
                u16 PixelCount = u16(( 0x007f & PacketInfo ) + 1);
                if( PacketType ){
                    pixel = 0xffffffff;
                    if(hdr.pixsize==32) TGA().r(&pixel,4);
                    else                TGA().r(&pixel,3);
                    while( PixelCount-- ){
                    	*(ptr+dwOffset+x)=pixel;
                        x++;
                    }
                }else{
                    while( PixelCount-- ){
                        pixel = 0xffffffff;
                        if(hdr.pixsize==32) TGA().r(&pixel,4);
                        else                TGA().r(&pixel,3);
                    	*(ptr+dwOffset+x)=pixel;
                        x++;
                    }
                }
            }else{
                pixel = 0xffffffff;
                if(hdr.pixsize==32) TGA().r(&pixel,4);
                else                TGA().r(&pixel,3);
				*(ptr+dwOffset+x)	=pixel;
                x++;
            }
        }
    }
/*
	if (hdr.pixsize==24)
	{	// 24bpp
		bAlpha = FALSE;
		u32	pixel	= 0;
		u32*	ptr		= pData;
		for(int iy = 0; iy<hdr.height; ++iy) {
			for(int ix=0; ix<hdr.width; ++ix) {
				TGA.r(&pixel,3); *ptr++=pixel;
//				u32 R = RGBA_GETRED	(pixel)/2;
//				u32 G = RGBA_GETGREEN	(pixel)/2;
//				u32 B = RGBA_GETBLUE	(pixel)/2;
//				*ptr++ = D3DCOLOR_XRGB(R,G,B);
			}
		}
	}
	else
	{	// 32bpp
		bAlpha = TRUE;
		TGA.r(pData,hdr.width*hdr.height*4);
	}
*/
	if (vflip) Vflip();
	if (hflip) Hflip();

    return true;
}