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

📄 hammal_driver.c

📁 Haier2016芯片的SDK开发包,在2016开发板上面验证过.
💻 C
📖 第 1 页 / 共 2 页
字号:
	else if (data1 == 4 || data1 == 5)
	{
		if (data2 == 2 || data2 == 3)
		{
			if (ucBackStep > 5)
			{
				ucBackStep = 5;
				for (k=0;k<4;k++)
				{
					for (i=0; i<5; i++)
					{
						for(j=0;j<5;j++)
						{
							ucUndoTemp[k][i][j] = ucUndoTemp[k+1][i][j];
						}
					}
					ucManPos[k][0] = ucManPos[k+1][0];
					ucManPos[k][1] = ucManPos[k+1][1];
				}
			}
			ucManPos[ucBackStep-1][0] = ucManRow;
			ucManPos[ucBackStep-1][1] = ucManColumn;
			for (i=ucManRow - 2; i <= ucManRow + 2; i++)
				for (j=ucManColumn - 2; j<=ucManColumn + 2; j++)
					ucUndoTemp[ucBackStep-1][i-ucManRow+2][j-ucManColumn+2] = ucLevelTemp[i][j];
			ucBackStep++;
			if (ucLevel[ucClass-1][row][line] == 3 || ucLevel[ucClass-1][row][line] == 5)
			{
				data0 = 3;
				ucLevelTemp[row][line] = data0;
			}
			else
			{
				data0 = 2;
				ucLevelTemp[row][line] = data0;
			}
			if (data2 == 3)
			{
				data1=6;
				ucManRow = row1;
				ucManColumn = line1;
				ucLevelTemp[row1][line1] = data1;
				data2=5;
				ucLevelTemp[row2][line2] = data2;
			}
			else
			{
				data1=6;
				ucManRow = row1;
				ucManColumn = line1;
				ucLevelTemp[row1][line1] = data1;
				data2=4;
				ucLevelTemp[row2][line2] = data2;
			}

			HAMMAL_DrawBasicBoxBMP(row,line,data0);
			HAMMAL_DrawBasicBoxBMP(row2,line2,data2);
			HAMMAL_DrawBasicBoxBMP(row1,line1,data1);
		}
	}
}


/****************************************************************************
Name         : BoxUndoMove()
Description  : 反悔函数
Parameters   : HROSD_RegionHandle_t  Handle, HM_BYTE ucOpIndex
Return Value : void
****************************************************************************/
HM_VOID BoxUndoMove(HM_VOID) HAMMAL_POSTFIT
{
	HM_BYTE i,j;
	ucBackStep--;
	if (ucBackStep == 0)
	{
		ucBackStep = 1;
		return;
	}
	ucManRow    = ucManPos[ucBackStep-1][0];
	ucManColumn = ucManPos[ucBackStep-1][1];
	for (i=ucManRow - 2; i <= ucManRow + 2; i++)
	{
		for (j=ucManColumn - 2; j<= ucManColumn + 2; j++)
		{
			HAMMAL_DrawBasicBoxBMP(i,j,ucUndoTemp[ucBackStep-1][i-ucManRow+2][j-ucManColumn+2]);
			ucLevelTemp[i][j] = ucUndoTemp[ucBackStep-1][i-ucManRow+2][j-ucManColumn+2];
		}
	}
}

HM_BOOLEAN BoxSuccess(HM_VOID) HAMMAL_POSTFIT
{
	HM_BYTE i, j;
	for (i=0; i<11; i++)
		for (j=0; j<13; j++)
			if (ucLevelTemp[i][j] == 4)
				return FALSE;
	return TRUE;
}

HM_VOID ShortCut(HM_BYTE ucClass) HAMMAL_POSTFIT
{
	switch (ucClass)
	{
		case 1:
			{
				if (bCurStep<11)
				{
					BoxMove(Step1[bCurStep],ucClass);
				}
			}
		break;

		case 2:
			{
				if (bCurStep<93)
				{
					BoxMove(Step2[bCurStep], ucClass);
				}
			}
		break;

		case 3:
			{
				if (bCurStep<34)
				{
					BoxMove(Step3[bCurStep],ucClass);
				}
			}
		break;

		case 4:
			{
				if (bCurStep<65)
				{
					BoxMove(Step4[bCurStep],ucClass);
				}
			}
		break;

		case 5:
			{
				if (bCurStep<43)
				{
					BoxMove(Step5[bCurStep],ucClass);
				}
			}
		break;

		case 6:
			{
				if (bCurStep<72)
				{
					BoxMove(Step6[bCurStep],ucClass);
				}
			}
		break;

		case 7:
			{
				if (bCurStep<55)
				{
					BoxMove(Step7[bCurStep],ucClass);
				}
			}
		break;

		case 8:
			{
				if (bCurStep<100)
				{
					BoxMove(Step8[bCurStep],ucClass);
				}
			}
		break;

		case 9:
			{
				if (bCurStep<139)
				{
					BoxMove(Step9[bCurStep],ucClass);
				}
			}
		break;

		case 10:
			{
				if (bCurStep<90)
				{
					BoxMove(Step10[bCurStep],ucClass);
				}
			}
		break;

		case 11:
			{
				if (bCurStep<692)
				{
					BoxMove(Step11[bCurStep],ucClass);
				}
			}
		break;

	}

}

HM_VOID HammalInit(HM_BYTE ucClass) HAMMAL_POSTFIT
{
	HM_BYTE i,j;
	HM_SHORT sXPos = 290;
	HM_SHORT sYPos = 50;

	ucBackStep = 1;

//	HAMMAL_HideRegion();
	HAMMAL_FillRectangle(iXOffset,iYOffset,500,11*32u, TRANS_COLOR);
	for(i=0;i<11;i++)
	{
		for(j=0;j<13;j++)
		{
			ucLevelTemp[i][j] = ucLevel[ucClass-1][i][j];
			HAMMAL_DrawBasicBoxBMP(i,j,ucLevelTemp[i][j]);
			if (ucLevelTemp[i][j] == 6)
			{
				ucManRow    = i;
				ucManColumn = j;
			}
		}
	}

//	HAMMAL_ShowRegion();
}

HM_VOID HAMMAL_Set_Position(HM_INT xPos, HM_INT yPos) HAMMAL_POSTFIT
{
	iXOffset = xPos;
	iYOffset = yPos;
}

HM_BOOLEAN Hammal_Task(Hammal_command_Type tCommand) HAMMAL_POSTFIT
{
	if (tCommand == INIT_COMMAND)
	{
		ucClass = 1;
		ucManPos = (MANPOS *)HAMMAL_Allocate(5*2);
		ucUndoTemp = (UNDO_TYPE *)HAMMAL_Allocate(5*5*5);
		ucLevelTemp = (LEVEL_TYPE *)HAMMAL_Allocate(11*13);

		if (ucManPos == NULL || ucUndoTemp == NULL || ucLevelTemp == NULL)
		{
			HAMMAL_DeAllocate(ucLevelTemp);
			HAMMAL_DeAllocate(ucUndoTemp);
			HAMMAL_DeAllocate(ucManPos);
			ucLevelTemp = NULL;
			ucUndoTemp = NULL;
			ucManPos = NULL;
			return TRUE;
		}

		HammalInit(ucClass);
	}
	else if (tCommand == EXIT_COMMAND)
	{
		if (bEnterAuto)
		{
			bEnterAuto = FALSE;
			HammalInit(ucClass);
			return FALSE;
		}
		else
		{
			HAMMAL_DeAllocate(ucManPos);
			HAMMAL_DeAllocate(ucUndoTemp);
			HAMMAL_DeAllocate(ucLevelTemp);
			ucManPos = NULL;
			ucUndoTemp = NULL;
			ucLevelTemp = NULL;
			return TRUE;
		}
	}
	else if (tCommand == DOWN_KEY_COMMAND)
	{
		BoxMove(3,ucClass);
		if (BoxSuccess())
		{
			ucClass ++;
			if (ucClass == 12)
				ucClass = 1;
			HammalInit(ucClass);
		}
	}
	else if (tCommand == UP_KEY_COMMAND)
	{
		BoxMove(2,ucClass);
		if (BoxSuccess())
		{
			ucClass ++;
			if (ucClass == 12)
				ucClass = 1;
			HammalInit(ucClass);
		}
	}
	else if (tCommand == RIGHT_KEY_COMMAND)
	{
		BoxMove(1,ucClass);
		if (BoxSuccess())
		{
			ucClass ++;
			if (ucClass == 12)
				ucClass = 1;
			HammalInit(ucClass);
		}
	}
	else if (tCommand == LEFT_KEY_COMMAND)
	{
		BoxMove(0,ucClass);
		if (BoxSuccess())
		{
			ucClass ++;
			if (ucClass == 12)
				ucClass = 1;
			HammalInit(ucClass);
		}
	}
	else if (tCommand == F1_COMMAND)
	{
		if (!bEnterAuto)
		{
			ucClass ++;
			if (ucClass == 12)
				ucClass = 1;
			HammalInit(ucClass);
		}
	}
	else if (tCommand == F2_COMMAND)
	{
		if (!bEnterAuto)
		{
			ucClass --;
			if (ucClass == 0)
				ucClass = 11;
			HammalInit(ucClass);
		}
	}
	else if (tCommand == F3_COMMAND)
	{
		if (!bEnterAuto)
			HammalInit(ucClass);
	}
	else if (tCommand == F4_COMMAND)
	{
		if (!bEnterAuto)
			BoxUndoMove();
	}
	else if (tCommand == TRACK_COMMAND)
	{
		bEnterAuto = TRUE;
		bCurStep = 0;
		ShortCut(ucClass);
	}
	else if (tCommand == TIMEOUT_COMMAND)
	{
		if (bEnterAuto)
		{
			bCurStep++;
			ShortCut(ucClass);
			if (BoxSuccess())
			{
				ucClass ++;
				if (ucClass == 12)
					ucClass = 1;
				HammalInit(ucClass);
				return TRUE;
			}
		}
	}

	return FALSE;
}


⌨️ 快捷键说明

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