⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdump.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
字号:
/**************************************************************************
 * Name         : pdump.c
 * Author       : BCB
 * Created      : 02/06/2003
 *
 * Copyright    : 2003 by Imagination Technologies Limited. All rights reserved.
 *              : No part of this software, either material or conceptual 
 *              : may be copied or distributed, transmitted, transcribed,
 *              : stored in a retrieval system or translated into any 
 *              : human or computer language in any form by any means,
 *              : electronic, mechanical, manual or other-wise, or 
 *              : disclosed to third parties without the express written
 *              : permission of Imagination Technologies Limited, Unit 8, HomePark
 *              : Industrial Estate, King's Langley, Hertfordshire,
 *              : WD4 8LZ, U.K.
 *
 * Platform     : ANSI
 *
 * $Date: 2004/07/20 11:00:22 $ $Revision: 1.5 $
 * $Log: pdump.c $
 **************************************************************************/
#define MODULE_ID MODID_PDUMP

/* Exclude from non-PDUMP builds */
#ifdef OLDPDUMP

#include "context.h"
#include <string.h>

/***********************************************************************************
 Function Name      : PDumpInit
 Inputs             : gc
 Outputs            : -
 Returns            : Success
 Description        : Initialise pdump script files.
************************************************************************************/

IMG_BOOL PDumpInit(GLESContext *gc)
{
	FILE *fpControl = fopen("pdump.txt","rt");

	if (( gc->fpScript = fopen("out.txt", "w")) == NULL)
		perror ("txt");
	else if (( gc->fpTex = fopen("out.tex", "wb")) == NULL)
		perror ("tex");
	else if (( gc->fpPrim = fopen("out.prm", "wb")) == NULL)
		perror ("prm");

	if(!gc->fpPrim || !gc->fpScript || !gc->fpTex)
	{
		return IMG_FALSE;
	}	

	if(fpControl)
	{
		fscanf(fpControl, "Start:%lu\nStop:%lu\nSkip:%lu",
			&gc->ui32PdumpStart, 
			&gc->ui32PdumpStop, 
			&gc->ui32PdumpSkip);

		fclose(fpControl);
	}
	else
	{
		gc->ui32PdumpStart = 0;
		gc->ui32PdumpStop = 0xFFFFFFFF;
		gc->ui32PdumpSkip = 1;
	}
	return IMG_TRUE;
}

/***********************************************************************************
 Function Name      : PDumpClose
 Inputs             : gc
 Outputs            : -
 Returns            : Success
 Description        : Close pdump script files.
************************************************************************************/

IMG_BOOL PDumpClose(GLESContext *gc)
{
	if(fclose(gc->fpPrim) != 0)
		return IMG_FALSE;

	if(fclose(gc->fpScript) != 0)
		return IMG_FALSE;

	if(fclose(gc->fpTex) != 0)
		return IMG_FALSE;

	return IMG_TRUE;
}

/***********************************************************************************
 Function Name      : PDumpSlavePort
 Inputs             : gc, ui32Data
 Outputs            : -
 Returns            : Success
 Description        : Write 32 bits to the primitive file
************************************************************************************/

IMG_BOOL PDumpSlavePort(GLESContext *gc, IMG_UINT32 ui32Data)
{
	IMG_UINT32 ui32Size;
	IMG_UINT32 ui32Frame = gc->sTexture.psTextureManager->ui32CurrentFrame;
	
	if(!ui32Frame ||
		((ui32Frame >= gc->ui32PdumpStart) &&
		(ui32Frame <= gc->ui32PdumpStop) &&
		!(ui32Frame%gc->ui32PdumpSkip)))
	{
		
		ui32Size = fwrite(&ui32Data, 1, 4, gc->fpPrim);
		
		if(!ui32Size)
			return IMG_FALSE;
	}
	return IMG_TRUE;
}

/***********************************************************************************
 Function Name      : PDumpTerminatePort
 Inputs             : gc, ui32Data
 Outputs            : -
 Returns            : Success
 Description        : Writes a terminate word to the script file
************************************************************************************/

IMG_BOOL PDumpTerminatePort(GLESContext *gc, IMG_UINT32 ui32Data)
{
	IMG_UINT32 ui32Size;
	IMG_UINT32 ui32Frame = gc->sTexture.psTextureManager->ui32CurrentFrame;

	if(!ui32Frame ||
		((ui32Frame >= gc->ui32PdumpStart) &&
		(ui32Frame <= gc->ui32PdumpStop) &&
		!(ui32Frame%gc->ui32PdumpSkip)))
	{
		PDumpPrim(gc);
		
		ui32Size = fprintf(gc->fpScript,"WRW :SP:C2C00000 %8.8lX\n",ui32Data);
		fflush(gc->fpScript);
		
		if(!ui32Size)
			return IMG_FALSE;
	}
	return IMG_TRUE;
}

/***********************************************************************************
 Function Name      : PDumpString
 Inputs             : gc, pszString
 Outputs            : -
 Returns            : Success
 Description        : Writes a string to the script file
************************************************************************************/

IMG_BOOL PDumpString(GLESContext *gc, IMG_CHAR *pszString)
{
	IMG_UINT32 ui32Size = strlen(pszString);

	IMG_UINT32 ui32Frame = gc->sTexture.psTextureManager->ui32CurrentFrame;

	if(!ui32Frame ||
		((ui32Frame >= gc->ui32PdumpStart) &&
		(ui32Frame <= gc->ui32PdumpStop) &&
		!(ui32Frame%gc->ui32PdumpSkip)))
	{
		ui32Size = fwrite(pszString, ui32Size, 1, gc->fpScript);

		if(!ui32Size)
			return IMG_FALSE;
	}
	return IMG_TRUE;
}

/***********************************************************************************
 Function Name      : PDumpPrim
 Inputs             : gc
 Outputs            : -
 Returns            : Success
 Description        : Writes a primitive loading command to the script file. Updates
					  current primitive dumping position.
************************************************************************************/

IMG_BOOL PDumpPrim(GLESContext *gc)
{
	IMG_UINT32 ui32Size, ui32Pos;
	IMG_UINT32 ui32Frame = gc->sTexture.psTextureManager->ui32CurrentFrame;

	if(!ui32Frame ||
		((ui32Frame >= gc->ui32PdumpStart) &&
		(ui32Frame <= gc->ui32PdumpStop) &&
		!(ui32Frame%gc->ui32PdumpSkip)))
	{
		
		ui32Pos = ftell(gc->fpPrim);
		
		ui32Size = fprintf(gc->fpScript,"\nLDB :SP:%8.8lX %8.8lX %8.8lX %%0%%.prm\r\n",
			(unsigned long)0xC2800000, gc->ui32ScriptPos, ui32Pos - gc->ui32ScriptPos);
		fflush(gc->fpScript);
		if(!ui32Size)
			return IMG_FALSE;
		
		gc->ui32ScriptPos = ui32Pos;
	}
	return IMG_TRUE;
}

/***********************************************************************************
 Function Name      : PDumpReg
 Inputs             : gc, ui32Addr, ui32Data
 Outputs            : -
 Returns            : Success
 Description        : Writes a register to the script file
************************************************************************************/

IMG_BOOL PDumpReg(GLESContext *gc, IMG_UINT32 ui32Addr, IMG_UINT32 ui32Data)
{
	IMG_UINT32 ui32Size;
	IMG_UINT32 ui32Frame = gc->sTexture.psTextureManager->ui32CurrentFrame;

	if(!ui32Frame ||
		((ui32Frame >= gc->ui32PdumpStart) &&
		(ui32Frame <= gc->ui32PdumpStop) &&
		!(ui32Frame%gc->ui32PdumpSkip)))
	{
	
		ui32Size = fprintf(gc->fpScript,"WRW :REG:%8.8lX %8.8lX\n",ui32Addr,ui32Data);
		fflush(gc->fpScript);
		
		if(!ui32Size)
			return IMG_FALSE;
	}	
	return IMG_TRUE;
}

/***********************************************************************************
 Function Name      : PDumpTex
 Inputs             : gc, psTex
 Outputs            : -
 Returns            : Success
 Description        : Writes a texture to the tex file and a load command to the 
					  script file.
************************************************************************************/

IMG_BOOL PDumpTex(GLESContext *gc, GLEStexture *psTex)
{
	PVRSRV_MEM_INFO *psMemInfo = psTex->psMemInfo;
	IMG_UINT32 ui32Pos = ftell(gc->fpTex);
	IMG_UINT32 ui32Size;

	ui32Size = fwrite(psMemInfo->pvLinAddr, psMemInfo->ui32AllocSize, 1, gc->fpTex);

	if(!ui32Size)
		return IMG_FALSE;

	fprintf(gc->fpScript,"LDB :FB:%8.8lX %8.8lX %8.8lX %%0%%.tex\r\n", 
		psMemInfo->uiDevAddr.uiAddr, ui32Pos, psMemInfo->ui32AllocSize);
	fflush(gc->fpScript);

	return IMG_TRUE;
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -