Ejemplo n.º 1
0
void Switch() {
/*	if(ControlRequests!=0) {
		char String[16];
		IntToString(ControlRequests, String);
		Break(String);
	} */
        IntsOff();
	ExchangeRegs();
	ControlRequests++;
        GetStackPointerASM(_OldSP);
	SaveIndexes();
	Scheduler(OldSP);
}
Ejemplo n.º 2
0
void _InterruptService() {
        register short i;
        ExchangeRegs();
        GetStackPointerASM(_UserSP);
        SaveIndexes();
	if(ControlRequests<0) Halt("NEGATIVE CONTROLREQUESTS");
        if(!IsMultitasking()) Halt("INTERRUPT IN KERNEL MODE");
	ControlRequests++;
        Tick();
        for(i=0; i<InterruptVectorCount; i++) {
                (InterruptVector[i])();
        }
        Scheduler(UserSP);
        Halt("OUT OF REACH");
}
Ejemplo n.º 3
0
std::vector<unsigned char> CEntityWriter::SaveEntity(CSerializationEntity& pRoot)
{
	std::vector<unsigned char> data;

	// save mesh information. 
	long magic = 0; // static mesh is being saved.
	if (pRoot.m_Bones.size() > 0 ) 
	{
		magic = 1; // animated mesh is being saved.
	}
	push_long(data, magic);
	push_matrix(data, pRoot.m_Pos);
	assert(pRoot.m_EntityName.size()> 0);
	const char * cStr = pRoot.m_EntityName.c_str();

	push_string(data, pRoot.m_EntityName);
	
	push_float(data, pRoot.globalScale);

	// save mesh information
	std::vector<CRenderable_Export >  v = pRoot.m_ExportShapes;
	long num_renderables = v.size();
	push_long(data, num_renderables);
	for (int i= 0 ; i < num_renderables ; i ++ ) 
	{
		const CRenderable_Export& pRenderable  = v[i];
		push_long(data, pRenderable.m_UsedBones.size() );
		append(pRenderable.m_UsedBones, data);
		push_long(data, pRenderable.m_Geometries.size() );
		for (int geomIndex = 0; geomIndex < pRenderable.m_Geometries.size() ; geomIndex ++ ) 
		{
			
			const CRenderable_AbstractGeometry&  pGeometry = pRenderable.m_Geometries[geomIndex];
			push_long(data, pGeometry.m_VertexBuffers.size());	
			for (unsigned int j = 0 ; j < pGeometry.m_VertexBuffers.size() ; j ++ ) 
			{
				std::vector<unsigned char> vertexes;
				const CRenderable_AbstractVertexBuffer& pBuffer = pGeometry.m_VertexBuffers[j];
				vertexes = SaveVertexes(pBuffer);
				long size = vertexes.size();
				push_long(data, size);
				append(vertexes, data);			
			}
			push_long(data, pGeometry.m_IndexBuffers.size());	
			for (unsigned int j = 0 ; j < pGeometry.m_IndexBuffers.size() ; j ++ ) 
			{
				std::vector<unsigned char> indexes;
				const CRenderable_AbstractIndexBuffer& pIndex = pGeometry.m_IndexBuffers[j];
				indexes = SaveIndexes(pIndex);
				long size = indexes.size();
				push_long(data, size);
				append(indexes, data);

			}
			push_long(data,  pGeometry.m_RenderCalls.size());	
			for (unsigned int j = 0 ; j < pGeometry.m_RenderCalls.size() ; j ++ ) 
			{
				std::vector<unsigned char> calls;
				const CRenderable_AbstractRenderCall& pCall = pGeometry.m_RenderCalls[j];
				calls = SaveRenderCalls(pCall);
				long size = calls.size();
				push_long(data, size);
				append(calls, data);
			
			}
		}
		push_long(data, pRenderable.m_ExportMaterial.m_Name.size());
		for (unsigned int i = 0 ; i < pRenderable.m_ExportMaterial.m_Name.size() ; i ++ ) 
		{
			data.push_back(pRenderable.m_ExportMaterial.m_Name[i]);
		}
	}
	// save static bone information
	push_long(data, pRoot.m_Bones.size());
	
	std::vector<CBoneSerialized>& bonez =  pRoot.m_Bones;
	std::vector<CBoneSerialized>::iterator it = bonez.begin();
	while (it != pRoot.m_Bones.end())
	{
		/*
			CBoneSerialized* m_pParent;
			std::list<CBoneSerialized*> m_ChildrenPtr;
			CMatrix m_InitialMatrix;
			CMatrix m_InvBoneSkinMatrix;
			CMatrix m_FinalMatrix;
			CVector m_Pos;
			long m_Index;
			std::string m_ID;
			std::list<CMatrix> m_AnimationMatrices;
		*/
		long parentIndex = -1;
		if ((*it).m_pParent >= 0)
		{
			parentIndex = bonez[(*it).m_pParent].m_Index;
		}
		push_long(data, parentIndex);

		std::vector<unsigned char> matrixVector;
		matrixVector.resize(sizeof(CMatrix));
		

		memcpy(&matrixVector[0] , &(*it).m_InitialMatrix, sizeof(CMatrix));
		data.insert(data.end() , matrixVector.begin(), matrixVector.end());

		memcpy(&matrixVector[0] ,&(*it).m_InvBoneSkinMatrix, sizeof(CMatrix));
		data.insert(data.end() , matrixVector.begin(), matrixVector.end());

	
		push_long(data,(*it).m_Index);
		push_long(data,(*it).m_ID.size());
		assert( (*it).m_ID.size() < 100 ) ;
		CBoneSerialized& pBone = (*it);
		data.insert(data.end(), pBone.m_ID.begin(), pBone.m_ID.end());
		//data.insert(data.end() ,(*it)->m_ID.begin() , (*it)->m_ID.end());
		/*push_long(data, (*it)->m_MatrixMapping.size() );
		
		for (int i = 0 ; i < (*it)->m_MatrixMapping.size() ; i ++ ) 
		{
			data.push_back( (*it)->m_MatrixMapping[i].first );
			data.push_back( (*it)->m_MatrixMapping[i].second );
		}*/
		//PrintBone(*it);
		it++;
	}



	return data;
}