debug.c

来自「Lido PXA270平台开发板的最新BSP,包括源代码」· C语言 代码 · 共 2,713 行 · 第 1/5 页

C
2,713
字号
		{
			pszBlockName = "invalid";
			break;
		}
	}

	return pszBlockName;
}

/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdrZDias
    
 PURPOSE	: Decodes the Z-dias field from a TA primitive-block header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
  
 RETURNS	: PSTR		- The decoded Z-bias
*****************************************************************************/
PSTR DBGDecodePrimBlockHdrZBias(DWORD dwPrimHdr)
{
	static char		pszZBias[8];
	DWORD			dwBiasMode;
	DWORD			dwBiasAmount;

	dwBiasMode   = dwPrimHdr & MBX1_TAPRIM_ZBIAS_MODEMASK;
	dwBiasAmount = (dwPrimHdr & MBX1_TAPRIM_ZBIAS_AMOUNTMASK) >>
				   MBX1_TAPRIM_ZBIAS_SHIFT;

	if	(dwBiasMode == MBX1_TAPRIM_ZBIAS_MODEDECREASING)
	{
		sprintf(pszZBias, "-0x%.4X", dwBiasAmount);
	}
	else
	{
		sprintf(pszZBias, "+0x%.4X", dwBiasAmount);
	}

	return pszZBias;
}

/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdrZeroOffsetColourCtl
    
 PURPOSE	: Decodes the zero-offset colour control field in a TA primitive-
			  block header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
  
 RETURNS	: PSTR		- The decoded zero-offset colour state
*****************************************************************************/
PSTR DBGDecodePrimBlockHdrZeroOffsetColourCtl(DWORD dwPrimHdr)
{
	PSTR	pszState;

	if	(dwPrimHdr & MBX1_TAPRIM_ZEROOFFSETCOL)
	{
		pszState = "enabled";
	}
	else
	{
		pszState = "disabled";
	}

	return pszState;
}

/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdrCullMode
    
 PURPOSE	: Decodes the cull-mode field in a TA primitive-block header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
  
 RETURNS	: PSTR		- The decoded cull-mode
*****************************************************************************/
PSTR DBGDecodePrimBlockHdrCullMode(DWORD dwPrimHdr)
{
	PSTR	pszCullMode;
	DWORD	dwCullMode;

	dwCullMode = dwPrimHdr & (~MBX1_TAPRIM_CULLMODECLRMASK);
	switch (dwCullMode)
	{
		case MBX1_TAPRIM_CULLMODENONE:
		{
			pszCullMode = "none";
			break;
		}

		case MBX1_TAPRIM_CULLMODECW:
		{
			pszCullMode = "CW";
			break;
		}

		case MBX1_TAPRIM_CULLMODECCW:
		{
			pszCullMode = "CCW";
			break;
		}

		default:
		{
			pszCullMode = "invalid";
			break;
		}
	}

	return pszCullMode;
}

/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdrPerspectiveCorrectCtl
    
 PURPOSE	: Decodes the perspective-correct control field in a TA primitive-
			  block header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
  
 RETURNS	: PSTR		- The decoded perspective-correct control state
*****************************************************************************/
PSTR DBGDecodePrimBlockHdrPerspectiveCorrectCtl(DWORD dwPrimHdr)
{
	PSTR	pszState;

	if	(dwPrimHdr & MBX1_TAPRIM_NONPERSPCORRECT)
	{
		pszState = "enabled";
	}
	else
	{
		pszState = "disabled";
	}

	return pszState;
}

/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdrWBufferCtl
    
 PURPOSE	: Decodes the w-buffering control field in a TA primitive-block
			  header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
  
 RETURNS	: PSTR		- The decoded w-buffering enable state
*****************************************************************************/
PSTR DBGDecodePrimBlockHdrWBufferCtl(DWORD dwPrimHdr)
{
	PSTR	pszState;

	if	(dwPrimHdr & MBX1_TAPRIM_WBUFFERING_ENABLE)
	{
		pszState = "W-buffering";
	}
	else
	{
		pszState = "Z-buffering";
	}

	return pszState;
}

/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdrTexCoordWrapCtl
    
 PURPOSE	: Decodes the texture-coordinate wrapping enable control fields
			  in a TA primitive-block header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
			  dwLayer	- Which layer to decode the wrap-state for (0 or 1)
  
 RETURNS	: PSTR		- The decoded wrapping control state
*****************************************************************************/
PSTR DBGDecodePrimBlockHdrTexCoordWrapCtl(DWORD dwPrimHdr, DWORD dwLayer)
{
	PSTR	pszWrapping;
	DWORD	dwWrapCtl;
	DWORD	dwWrapFlagShift;

	dwWrapFlagShift = MBX1_TAPRIM_VGP_TEXCOORDWRAP_LAYER0SHIFT + 
					  (dwLayer * MBX1_TAPRIM_VGP_TEXCOORDWRAP_LAYERSHIFT);
	dwWrapCtl = (dwPrimHdr >> dwWrapFlagShift) &
				MBX1_TAPRIM_VGP_TEXCOORDWRAP_WRAPMASK;

	switch (dwWrapCtl)
	{
		case 0:
		{
			pszWrapping = "no wrapping";
			break;
		}

		case MBX1_TAPRIM_VGP_TEXCOORDWRAP_WRAPU:
		{
			pszWrapping = "wrap U";
			break;
		}

		case MBX1_TAPRIM_VGP_TEXCOORDWRAP_WRAPV:
		{
			pszWrapping = "wrap V";
			break;
		}

		case MBX1_TAPRIM_VGP_TEXCOORDWRAP_WRAPU |
			 MBX1_TAPRIM_VGP_TEXCOORDWRAP_WRAPV:	  
		{
			pszWrapping = "wrap U+V";
			break;
		}

		default:
		{
			pszWrapping = "invalid";
			break;
		}
	}

	return pszWrapping;
}

/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdrDrawLastPixelCtl
    
 PURPOSE	: Decodes the draw-last pixel control field in a TA primitive-
			  block header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
  
 RETURNS	: PSTR		- The decoded draw-lastpixel control state
*****************************************************************************/
PSTR DBGDecodePrimBlockHdrDrawLastPixelCtl(DWORD dwPrimHdr)
{
	PSTR	pszState;

	if	(dwPrimHdr & MBX1_TAPRIM_DRAW_LASTPIXEL)
	{
		pszState = "enabled";
	}
	else
	{
		pszState = "disabled";
	}

	return pszState;
}


/*****************************************************************************
 FUNCTION	: DBGDecodePrimBlockHdr
    
 PURPOSE	: Decodes a primitive-block header word

 PARAMETERS	: dwPrimHdr	- A primitive-block header word
  
 RETURNS	: void
*****************************************************************************/
void DBGDecodePrimBlockHdr(LPD3DM_CONTEXT psContext, DWORD dwPrimHdr)
{
//	DBGDecodePF(psContext, " ");
	DBGDecodePF(psContext, "---- %hs primitive block header (0x%8.8lX)", DBGDecodeTACSBlockType(psContext, dwPrimHdr), dwPrimHdr);
	DBGDecodePF(psContext, "--                   Z-bias: %hs", DBGDecodePrimBlockHdrZBias(dwPrimHdr));
	DBGDecodePF(psContext, "--       Zero offset colour: %hs", DBGDecodePrimBlockHdrZeroOffsetColourCtl(dwPrimHdr));
	DBGDecodePF(psContext, "--                Cull-mode: %hs", DBGDecodePrimBlockHdrCullMode(dwPrimHdr));
	DBGDecodePF(psContext, "--      Perspective-correct: %hs", DBGDecodePrimBlockHdrPerspectiveCorrectCtl(dwPrimHdr));
	DBGDecodePF(psContext, "--            W/Z-buffering: %hs", DBGDecodePrimBlockHdrWBufferCtl(dwPrimHdr));
	DBGDecodePF(psContext, "--         Layer 0 wrapping: %hs", DBGDecodePrimBlockHdrTexCoordWrapCtl(dwPrimHdr, 0));
	DBGDecodePF(psContext, "--         Layer 1 wrapping: %hs", DBGDecodePrimBlockHdrTexCoordWrapCtl(dwPrimHdr, 1));
	DBGDecodePF(psContext, "--          Draw last pixel: %hs", DBGDecodePrimBlockHdrDrawLastPixelCtl(dwPrimHdr));
}

/*****************************************************************************
 FUNCTION	: DBGDecodeVGPClipSectionsEnabled
    
 PURPOSE	: Decodes the section-enable controls from a VGP-clip control-word

 PARAMETERS	: dwVGPClip	- The VGP-clip control word to decode
  
 RETURNS	: PSTR		- The enabled-sections
*****************************************************************************/
PSTR DBGDecodeVGPClipSectionsEnabled(DWORD dwVGPClip)
{
	static char	pszSectionState[49];
	DWORD			dwSectionCtl;

	dwSectionCtl = dwVGPClip & MBX1_VGPCLIPCTL_SECTION_ENABLEMASK;
	switch (dwSectionCtl)
	{
		case 0:
		{
			strcpy(pszSectionState, "none");
			break;
		}

		case MBX1_VGPCLIPCTL_SECTION_ENABLEMASK:
		{
			strcpy(pszSectionState, "all");
			break;
		}

		default:
		{
			DWORD	dwNumEnabled;
			DWORD	i;

			dwNumEnabled = 0;

			for	(i = 0; dwSectionCtl; i++)
			{
				static char	pszTemp[7];
				DWORD			dwSectionFlag;

				dwSectionFlag = MBX1_VGPCLIPCTL_SECTION0_ENABLE << i;
				if	(dwSectionCtl & dwSectionFlag)
				{
					dwSectionCtl ^= dwSectionFlag;
					dwNumEnabled++;

					if	(dwNumEnabled == 1)
					{
						sprintf(pszSectionState, "%d", i);
					}
					else
					{
						if	(!dwSectionCtl)
						{
							sprintf(pszTemp, " and %d", i);
						}
						else
						{
							sprintf(pszTemp, ", %d", i);
						}
						strcat(pszSectionState, pszTemp);
					}
				}
			}
			break;
		}
	}

	return pszSectionState;
}

/*****************************************************************************
 FUNCTION	: DBGDecodeVGPClipStartSection
    
 PURPOSE	: Decodes the start-section from a VGP-clip control-word

 PARAMETERS	: dwVGPClip	- The VGP-clip control word to decode
  
 RETURNS	: PSTR		- The start-section
*****************************************************************************/
PSTR DBGDecodeVGPClipStartSection(DWORD dwVGPClip)
{
	static char	pszStartSection[3];
	DWORD			dwStartSection;

	dwStartSection = (dwVGPClip & MBX1_VGPCLIPCTL_STARTSECTION_MASK) >> 
				     MBX1_VGPCLIPCTL_STARTSECTION_SHIFT;

	sprintf(pszStartSection, "%d", dwStartSection);

	return pszStartSection;
}

/*****************************************************************************
 FUNCTION	: DBGDecodeVGPClipClipPlanesEnabled
    
 PURPOSE	: Decodes the clip-plane enable controls from a VGP-clip control-
			  word

 PARAMETERS	: dwVGPClip	- The VGP-clip control word to decode
  
 RETURNS	: PSTR		- The enabled clip-planes
*****************************************************************************/
PSTR DBGDecodeVGPClipClipPlanesEnabled(DWORD dwVGPClip)
{
	static char	pszPlanesEnabled[40];
	DWORD			dwClipPlaneCtl;

	dwClipPlaneCtl = dwVGPClip & MBX1_VGPCLIPCTL_CLIPPLANES_MASK;
	switch (dwClipPlaneCtl)
	{
		case 0:
		{
			strcpy(pszPlanesEnabled, "none");
			break;
		}

		case MBX1_VGPCLIPCTL_CLIPPLANES_MASK:
		{
			strcpy(pszPlanesEnabled, "all");
			break;
		}
	
		default:
		{
			DWORD	dwNumEnabled;
			DWORD	i;

			dwNumEnabled = 0;
			for	(i = 0; i < dwClipPlaneCtl; i++)
			{
				static char	pszTemp[11];
				static char	pszPlane[6];
				DWORD			dwClipPlaneFlag;

				dwClipPlaneFlag = MBX1_VGPCLIPCTL_ARBCLIPPLANE0_ENABLE << i;
				if	(dwClipPlaneCtl & dwClipPlaneFlag)
				{
					dwClipPlaneCtl ^= dwClipPlaneFlag;
					dwNumEnabled++;

					if	(dwClipPlaneFlag == MBX1_VGPCLIPCTL_FRONTCLIPPLANE_ENABLE)
					{
						strcpy(pszPlane, "front");		
					}
					if	(dwClipPlaneFlag == MBX1_VGPCLIPCTL_REARCLIPPLANE_ENABLE)
					{
						strcpy(pszPlane, "rear");		
					}
					if	(i < 8)
					{
						sprintf(pszPlane, "%d", i);		
					}

					if	(dwNumEnabled == 1)
					{
						sprintf(pszPlanesEnabled, "%hs", pszPlane);
					}
					else
					{
						if	(!dwClipPlaneCtl)
						{
							sprintf(pszTemp, " and %hs", pszPlane);
						}
						else
						{
							sprintf(pszTemp, ", %hs", pszPlane);
						}
						strcat(pszPlanesEnabled, pszTemp);
					}
				}
			}

			break;
		}
	}

	return pszPlanesEnabled;
}

/*****************************************************************************
 FUNCTION	: DBGDecodeVGPClipViewportTransCtl
    
 PURPOSE	: Decodes the viewport-transform enable control from a VGP-clip
			  control-word

 PARAMETERS	: dwVGPClip	- The VGP-clip control word to decode
  
 RETURNS	: PSTR		- Whether the viewport-transform is enabled or not
*****************************************************************************/
PSTR DBGDecodeVGPClipViewportTransCtl(DWORD dwVGPClip)
{
	PSTR	pszState;

	if	(dwVGPClip & MBX1_VGPCLIPCTL_VIEWPORTTRANS_ENABLE)
	{
		pszState = "enabled";
	}
	else
	{
		pszState = "disabled";
	}

	return pszState;
}

/*****************************************************************************
 FUNCTION	: DBGDecodeVGPClipWClampCtl
    
 PURPOSE	: Decodes the W-clamping control from a VGP-clip control-word

 PARAMETERS	: dwVGPClip	- The VGP-clip control word to decode
  
 RETURNS	: PSTR		- Whether w-clamping is enabled or not
*****************************************************************************/
PSTR DBGDecodeVGPClipWClampCtl(DWORD dwVGPClip)
{
	PSTR	pszState;

	if	(dwVGPClip & MBX1_VGPCLIPCTL_WCLAMP_ENABLE)
	{
		pszState = "enabled";
	}
	else
	{
		pszState = "disabled";
	}

	return pszState;
}

/*****************************************************************************
 FUNCTION	: DBGDecodeVGPClipWord
    
 PURPOSE	: Decode a VGP-clip control word to the PDUMP and/or DEBUG text
			  output streams

 PARAMETERS	: dwVGPClip	- The VGP-clip control word to decode
  
 RETURNS	: void
*****************************************************************************/
void DBGDecodeVGPClipWord(LPD3DM_CONTEXT psContext, DWORD dwVGPClip)
{
//	DBGDecodePF(psContext, " ");
	DBGDecodePF(psContext, "---- VGP clip word (0x%8.8lX)", dwVGPClip);
	DBGDecodePF(psContext, "--         Sections enabled: %hs", DBGDecodeVGPClipSectionsEnabled(dwVGPClip));
	DBGDecodePF(psContext, "--            Start Section: %hs", DBGDecodeVGPClipStartSection(dwVGPClip));
	DBGDecodePF(psContext, "--      Clip-planes enabled: %hs", DBGDecodeVGPClipClipPlanesEnabled(dwVGPClip));
	DBGDecodePF(psContext, "--           Viewport-trans: %hs", DBGDecodeVGPClipViewportTransCtl(dwVGPClip));
	DBGDecodePF(psContext, "--               W-clamping: %hs", DBGDecodeVGPClipWClampCtl(dwVGPClip));
}

/*****************************************************************************
 FUNCTION	: DBGDecodeTACtl3DStateBlockHdrPresFlag
    
 PURPOSE	: Decodes a TA-ctl/3D-state block header presence flag

 PARAMETERS	: dwFlag	- The flag to get the meaning of
  
 RETURNS	: PSTR		- The significance of the given flag
*****************************************************************************/
PSTR DBGDecodeTACtl3DStateBlockHdrPresFlag(DWORD dwFlag)
{
	PSTR pszFlagName;

	switch (dwFlag)
	{
		case 0:
		{
			pszFlagName = "";

⌨️ 快捷键说明

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