#include "UserCodeSet.h"
#include "Runtime.h"

extern "C"{
	#include "user_norflash.h"
	#include "user_eeprom.h"
	#include "uart_key_drv.h"
	#include "HW_config.h"
}

//#define dFlash4AreaChip			(0)
//#define dFlash4Area			(0x00BB'0000)

#define dWdClr		clSkyBlue
#define dWdDisabelClr	clNearWhite

#define dWWidth	24
#define dWHeigh	24
#define dRoundR	7

const int xInc = 84;
const int xDec = 180;
const int xModify = 84;
const int xSave = 180;

static const char CharBcdText[20]= {"0123456789*------\0"};

void TUserCodeSet::Init()
{
	IsPermission =0;
	
	CtlIndex = 0;
	IsShow = 0;
	ListPage = 0;
	
	PortNum = 0;
	AddrStart =0;
	AddrEnd =0;
	dType =0;
	
	PortValid = 1;
	AddrStartValid =1;
	AddrEndValid =1;
	dTypeValid =1;
	
	IncDec = 0;
	
	Sta =0;
}

void TUserCodeSet::DelayMs(unsigned int aMs)
{
	volatile unsigned int mTick;
	volatile unsigned int Tick;
	for(Tick=0; Tick<aMs; Tick++){
		for(mTick=0; mTick<160000; mTick++);
		sys_error_led_task();
	}
}

void TUserCodeSet::RenderBackGround(void)
{
	RectFillRender(ContentGeometry.Left, ContentGeometry.Top, ContentGeometry.Right, ContentGeometry.Bottom, ContentColor);
}

void TUserCodeSet::RenderBackGround(unsigned int aClr)
{
	RectFillRender(ContentGeometry.Left, ContentGeometry.Top, ContentGeometry.Right, ContentGeometry.Bottom, aClr);
}

void TUserCodeSet::DrawFixText()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Caption.Left + 10, Lv.Caption.Top +4, clNearWhite, CaptionColor, "联动->二次码编辑");
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +6, clNearWhite, "回路号");
		TextRender_string24(Lv.Grid.Left[0] + 186, Lv.Grid.Top[0] +6, clNearWhite, "机器号");
		TextRender_string24(Lv.Grid.Left[0] + 286, Lv.Grid.Top[0] +6, clNearWhite, "本机");
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +44, clNearWhite, "地址段");
		TextRender_string24(Lv.Grid.Left[0] + 136, Lv.Grid.Top[0] +44, clNearWhite, "-");
		TextRender_string24(Lv.Grid.Left[0] + 240, Lv.Grid.Top[0] +44, clNearWhite, "起始地址指派类型");
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +6, clNearWhite, "起始地址分区简称");
		TextRender_string24(Lv.Grid.Left[2] + 10, Lv.Grid.Top[2] +6, clNearWhite, "通配二次码");
		TextRender_string24(Lv.Grid.Left[3] + 10, Lv.Grid.Top[3] +6, clNearWhite, "置换二次码");
		TextRender_string24(Lv.Grid.Left[4] + 10, Lv.Grid.Top[4] +6, clNearWhite, "模式");
		TextRender_string24(Lv.Grid.Left[4] + xInc +30, Lv.Grid.Top[4] +8, clNearWhite, "递增");
		TextRender_string24(Lv.Grid.Left[4] + xDec +30, Lv.Grid.Top[4] +8, clNearWhite, "递减");
		TextRender_string24(Lv.Grid.Left[5] + 10, Lv.Grid.Top[5] +6, clNearWhite, "操作");
		TRoundRect::sDrawBySize(xModify, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clNearWhite, "确认", 14, clNearBlack);
		TRoundRect::sDrawBySize(xSave, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clNearWhite, "保存", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Caption.Left + 10, Lv.Caption.Top +4, clNearWhite, CaptionColor, "Linkage->Aux ID Setting");
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +6, clNearWhite, "LoopID");
		TextRender_string24(Lv.Grid.Left[0] + 186, Lv.Grid.Top[0] +6, clNearWhite, "CtlID");
		TextRender_string24(Lv.Grid.Left[0] + 286, Lv.Grid.Top[0] +6, clNearWhite, " Local");
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +44, clNearWhite, "Range");
		TextRender_string24(Lv.Grid.Left[0] + 136, Lv.Grid.Top[0] +44, clNearWhite, "-");
		TextRender_string24(Lv.Grid.Left[0] + 240, Lv.Grid.Top[0] +44, clNearWhite, "     Device Type");
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +6, clNearWhite,   "Zone Brief");
		TextRender_string24(Lv.Grid.Left[2] + 10, Lv.Grid.Top[2] +6, clNearWhite, "ID With * ");
		TextRender_string24(Lv.Grid.Left[3] + 10, Lv.Grid.Top[3] +6, clNearWhite, "ReplaceNum");
		TextRender_string24(Lv.Grid.Left[4] + 10, Lv.Grid.Top[4] +6, clNearWhite, "Mode");
		TextRender_string24(Lv.Grid.Left[4] + xInc +30, Lv.Grid.Top[4] +8, clNearWhite, "Inc ");
		TextRender_string24(Lv.Grid.Left[4] + xDec +30, Lv.Grid.Top[4] +8, clNearWhite, "Dec ");
		TextRender_string24(Lv.Grid.Left[5] + 10, Lv.Grid.Top[5] +6, clNearWhite, "Opera");
		TRoundRect::sDrawBySize(xModify, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clNearWhite, "View", 14, clNearBlack);
		TRoundRect::sDrawBySize(xSave, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clNearWhite, "Save", 14, clNearBlack);
	}
}

void TUserCodeSet::DrawSelf(void)
{
	RenderBackGround();
	RectFillRender(Lv.Caption.Left, Lv.Caption.Top, Lv.Caption.Right, Lv.Caption.Bottom, CaptionColor);

	for(int i=0; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);


	TextDigitRender2_24(Lv.Grid.Left[0] + 260, Lv.Grid.Top[0] +6, clNearWhite, MainCtl.fData.Split.MyNum);

	
	IList->STextDType.Init(Lv.Grid.Left[0] + 492,  Lv.Grid.Top[0] +44, 300, 32, 0,0, clNearWhite, ItemColor);
	IList->STextDType.TextClear();
	IList->STextDType.Visible = 1;
	
	//Port Num
	IList->EditPortNum.Init(Lv.Grid.Left[0] + 86, Lv.Grid.Top[0] +4, 48, 30, 0,0,1,clNearWhite);
	IList->EditPortNum.Str.Clear();
	IList->EditPortNum.SetMaxLen(2);
	IList->EditPortNum.Enable =1;
	
	//Start Addr
	IList->EditAddrNum.Init(Lv.Grid.Left[0] + 86, Lv.Grid.Top[0] +40, 48, 30, 0,0,1,clNearWhite);
	IList->EditAddrNum.Str.Clear();
	IList->EditAddrNum.SetMaxLen(3);
	IList->EditAddrNum.Enable =1;
	
	//End Addr
	IList->Edit[0].Init(Lv.Grid.Left[0] + 152, Lv.Grid.Top[0] +40, 	48, 30, 0,0,1,clNearWhite);
	IList->Edit[0].Str.Clear();
	IList->Edit[0].SetMaxLen(3);
	IList->Edit[0].Enable =1;
	
	//Assign Type
	IList->EditCtlNum.Init(Lv.Grid.Left[0] + 440, Lv.Grid.Top[0] +40, 48, 30, 0,0,1,clNearWhite);
	IList->EditCtlNum.Str.Clear();
	IList->EditCtlNum.SetMaxLen(3);
	IList->EditCtlNum.Enable =0;
	
	//Short Name
	IList->Edit[1].Init(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +36, 		270, 30, 0,0,1,clNearWhite);
	IList->Edit[1].Str.Clear();
	IList->Edit[1].Enable =0;
	
	//Descp
	//mlEdit.Init(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] +32, 				270, 64, 0,0,1,clNearWhite);
	//mlEdit.SetLineSpacing(4);
	//mlEdit.Str.Clear();
	//mlEdit.Enable =0;
	
	//Prv UserCode
	IList->Edit[2].Init(Lv.Grid.Left[2] + 132, Lv.Grid.Top[2] +4, 		110, 30, 0,0,1,clNearWhite);
	IList->Edit[2].SetMaxLen(8);
	IList->Edit[2].Str.Clear();
	IList->Edit[2].Enable =1;
	
	//New UserCode
	IList->Edit[3].Init(Lv.Grid.Left[3] + 132, Lv.Grid.Top[3] +4, 		110, 30, 0,0,1,clNearWhite);
	IList->Edit[3].SetMaxLen(8);
	IList->Edit[3].Str.Clear();
	IList->Edit[3].Enable =1;
	
	IList->EditPortNum.Str.FromUInt2Dg(PortNum+1);
	IList->EditAddrNum.Str.FromUInt3Dg(AddrStart+1);
	IList->Edit[0].Str.FromUInt3Dg(AddrEnd+1);
	IList->EditCtlNum.Str.FromUInt3Dg(dType);
	IList->EditPortNum.SetPstTail();
	IList->EditAddrNum.SetPstTail();
	IList->Edit[0].SetPstTail();
	IList->EditCtlNum.SetPstTail();
	
	IList->EditPortNum.Show();
	IList->EditAddrNum.Show();
	IList->Edit[0].Show();
	IList->EditCtlNum.Show();
	IList->STextDType.Show();
	IList->Edit[1].Show();
	IList->Edit[2].Show();
	IList->Edit[3].Show();
	//IList->EditAreaAssign.Show();
	//mlEdit.Show();
	DrawFixText();
	DrawIncDec();
	
	Check4Selected();
}

void TUserCodeSet::Show(void)
{	
	IsShow = 1;
	RenderBackGround();
	DrawSelf();
	DrawList();
}

void TUserCodeSet::DrawIncDec()
{
	if(IncDec==0){
		TRoundSquare::sDrawBySize(xInc, Lv.Grid.Top[4] + 8, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(xDec, Lv.Grid.Top[4] + 8, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}else{
		TRoundSquare::sDrawBySize(xInc, Lv.Grid.Top[4] + 8, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(xDec, Lv.Grid.Top[4] + 8, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}
}

void TUserCodeSet::ShowSta()
{
	if(LanguageEnCn==0){
		if(Sta == 0){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "        ");
		}else
		if(Sta == 1){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "保存成功");
		}else
		if(Sta == -1){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "保存失败");
		}else
		if(Sta == -2){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "无效操作");
		}
	}else{
		if(Sta == 0){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "        ");
		}else
		if(Sta == 1){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "Saved OK");
		}else
		if(Sta == -1){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "Failed  ");
		}else
		if(Sta == -2){
			TextRender_string24(ResultTipPoint.x, ResultTipPoint.y, clNearWhite, ItemColor, "Invalid ");
		}
	}
}

void TUserCodeSet::ShowSta(int aSta)
{
	Sta = aSta;
	ShowSta();
}

void TUserCodeSet::FullRedraw(int Prm)
{	
	if(Prm == 0){
		RenderBackGround();
		DrawSelf();
		ShowSta();
	}else
	if(Prm == 1){
		RectFillRender(GuiRedrawDataList[1][0], GuiRedrawDataList[1][1], GuiRedrawDataList[1][2], GuiRedrawDataList[1][3], ContentColor);
		for(int i=0; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
		if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);

		TextDigitRender2_24(Lv.Grid.Left[0] + 260, Lv.Grid.Top[0] +6, clNearWhite, MainCtl.fData.Split.MyNum);
		DrawFixText();
		
		IList->STextDType.Show();
		IList->EditPortNum.Show();
		IList->EditAddrNum.Show();
		IList->Edit[0].Show();
		IList->EditCtlNum.Show();
		IList->Edit[1].Show();
		IList->Edit[2].Show();
		
		Check4Selected();
		
		if(IsPermission)PmsIntervene4Gui.ReDraw4GuiRecall();
	}
}


//______________________________________________________________________________________________________________________________
void TUserCodeSet::ClearSelected(void)
{
	char *tText;
	switch(CtlIndex){
		case 0:
			IList->EditPortNum.Selected =0;
			IList->EditPortNum.Show();
			break;
		case 1:
			IList->EditAddrNum.Selected =0;
			IList->EditAddrNum.Show();
			break;
		case 2:
			IList->Edit[0].Selected =0;
			IList->Edit[0].Show();
			break;
		case 3:
			IList->Edit[2].Selected =0;
			IList->Edit[2].Show();
			break;
		case 4:
			IList->Edit[3].Selected =0;
			IList->Edit[3].Show();
			break;
		case 5:
			TRoundSquare::sSelected(xInc, Lv.Grid.Top[4]+8, dWWidth, dWHeigh, 4, ItemColor);
			break;
		case 6:
			TRoundSquare::sSelected(xDec, Lv.Grid.Top[4]+8, dWWidth, dWHeigh, 4, ItemColor);
			break;
		case 7:
			if(LanguageEnCn==0)tText="确定"; else tText="View";
			TRoundRect::sDrawBySize(xModify, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clNearWhite, tText, 14, clNearBlack);
			break;
		case 8:
			if(LanguageEnCn==0)tText="保存"; else tText="Save";
			TRoundRect::sDrawBySize(xSave, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clNearWhite, tText, 14, clNearBlack);
			break;
		default:

			break;
	}	
}

void TUserCodeSet::Check4Selected(void)
{
	char *tText;
	switch(CtlIndex){
		case 0:
			IList->EditPortNum.Selected =1;
			IList->EditPortNum.SetPstTail();
			IList->EditPortNum.Show();
			break;
		case 1:
			IList->EditAddrNum.Selected =1;
			IList->EditAddrNum.SetPstTail();
			IList->EditAddrNum.Show();
			break;
		case 2:
			IList->Edit[0].Selected =1;
			IList->Edit[0].SetPstTail();
			IList->Edit[0].Show();
			break;
		case 3:
			IList->Edit[2].Selected =1;
			IList->Edit[2].SetPstTail();
			IList->Edit[2].Show();
			break;
		case 4:
			IList->Edit[3].Selected =1;
			IList->Edit[3].SetPstTail();
			IList->Edit[3].Show();
			break;
		case 5:
			TRoundSquare::sSelected(xInc, Lv.Grid.Top[4]+8, dWWidth, dWHeigh, 4, clNearWhite);
			//sDrawBySize(int x, int y, int aW, int aH, int RoundR, u32 aClr, int Active);
			break;
		case 6:
			TRoundSquare::sSelected(xDec, Lv.Grid.Top[4]+8, dWWidth, dWHeigh, 4, clNearWhite);
			break;
		case 7:
			if(LanguageEnCn==0)tText="确定"; else tText="View";
			TRoundRect::sDrawBySize(xModify, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clBlue, tText, 14, clNearWhite);
			break;
		case 8:
			if(LanguageEnCn==0)tText="保存"; else tText="Save";
			TRoundRect::sDrawBySize(xSave, 	Lv.Grid.Top[5] + 6, 76, 30, 7, clBlue, tText, 14, clNearWhite);
			break;
		default:

			break;
	}	
}

void TUserCodeSet::PermissionCmdGO()
{
	if((PermissionCmd == 1) || (PermissionCmd == 2)){
		if(0 == DrawDetail()){
			Write2Flash();
		}else{
			ShowSta(-2);
		}
	}
}

void TUserCodeSet::PermissionCmdReturnDraw()
{
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
}

void TUserCodeSet::InitPanel()
{
	int x,y,x2,y2, aW,aH,i;

	x = 10;
	y = 240;
	x2 = 789;
	y2 = 430;
	aW = x2 - x +1;
	aH = y2 -y +1;
	
	aPanel->Init(x,y,aW,aH,0,0,clMoneyGreen, bvRaised);
	
	aPanel->Caption.Init(1,1,aW-3,32,x,y,clNearWhite,clBlue);
	if(LanguageEnCn==0)aPanel->Caption.SetText("按中/EN键切换输入法,设置键保存更改,返回键放弃更改并返回",24);
	else aPanel->Caption.SetText("Key 中/EN To Switch Input Method,Key Set To Save",24);
	aPanel->Caption.Enable = 1;
	aPanel->Caption.Visible = 1;

	aPanel->SText[0].Init(460,40,300,34,x,y,clNearBlack,clMoneyGreen);
	if(LanguageEnCn==0)TMyString::sFromStr("当前快捷输入数字", aPanel->SText[0].Text);
	else TMyString::sFromStr("Enter Numbers", aPanel->SText[0].Text);
	aPanel->SText[0].Enable = 1;
	aPanel->SText[0].Visible = 1;
	
	aPanel->Edit[ 0].Init(10,40,420,30,x,y,1,clNearBlack);
	aPanel->Edit[ 0].Str.FromStr(IList->EditDescpShow.Str.Text);
	
	for(i=0; i<1;i++){
		aPanel->Edit[i].Enable = 1;
		aPanel->Edit[i].Visible = 1;
		aPanel->Edit[i].SetMaxLen(32);
		aPanel->Edit[i].SetPstTail();
		aPanel->Edit[i].Selected = 1;
	}
	
	aPanel->Show();
	aPanel->Caption.Show();
	aPanel->SText[0].Show();
	aPanel->Edit[0].Show();
	aPanel->Edit[0].ShowCursor();
}

//_____________________________________________________________________________________________________________________________

TGuiMsgReturn TUserCodeSet::KeyIn(unsigned char aKey)
{
	TGuiMsgReturn aMsg = guiMsgNone;
	TGuiMsgReturn PmsRtnMsg = guiMsgNone;
	int iVal;
	int HadPrc;

	if(IsPermission){
		PmsRtnMsg = PmsIntervene4Gui.KeyIn(aKey);
		if(PmsRtnMsg == guiMsgOkAndReturn){
			//Enter And Run Go
			IsPermission = 0;
			PermissionCmdReturnDraw();
			PermissionCmdGO();
		}else
		if(PmsRtnMsg == guiMsgReturn){
			//Not Enter Redraw
			IsPermission = 0;
			PermissionCmdReturnDraw();
		}
		return aMsg;
	}else{
		switch(aKey){
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
			case VK_LEFT:
			case VK_RIGHT:
			case VK_DELETE:
				HadPrc =0;
				if( (aKey == VK_LEFT) || (aKey == VK_RIGHT) ){
					if(CtlIndex == 1){
						if(aKey == VK_RIGHT){
							if(IList->EditAddrNum.Pst >= IList->EditAddrNum.Str.GetEndPst()){
								if( (PortValid + dTypeValid + AddrStartValid + AddrEndValid) == 4){
									ClearSelected();
									CtlIndex++;
									Check4Selected();
									HadPrc =1;
								}
							}
						}
					}else
					if(CtlIndex == 2){
						if(aKey == VK_LEFT){
							if(IList->Edit[0].Pst <0){
								if( (PortValid + dTypeValid + AddrStartValid + AddrEndValid) == 4){
									ClearSelected();
									CtlIndex--;
									Check4Selected();
									HadPrc =1;
								}
							}
						}
					}else
					if(CtlIndex == 5){
						if(aKey == VK_RIGHT){
							ClearSelected();
							CtlIndex++;
							Check4Selected();
							HadPrc =1;
						}
					}else
					if(CtlIndex == 6){
						if(aKey == VK_LEFT){
							ClearSelected();
							CtlIndex--;
							Check4Selected();
							HadPrc =1;
						}
					}else
					if(CtlIndex == 7){
						if(aKey == VK_RIGHT){
							ClearSelected();
							CtlIndex++;
							Check4Selected();
							HadPrc =1;
						}
					}else
					if(CtlIndex == 8){
						if(aKey == VK_LEFT){
							ClearSelected();
							CtlIndex--;
							Check4Selected();
							HadPrc =1;
						}
					}
				}
				if(HadPrc == 0){
					if(CtlIndex == 0){
						IList->EditPortNum.KeyIn(aKey);
						int iVal;
						iVal = IList->EditPortNum.Str.ToInteger();
						if( (iVal <1) || (iVal > dPORT_MAX_COUNT) ){
							PortValid =0;
							IList->EditPortNum.SelectedColor = clRed;
						}else{
							PortValid =1;
							IList->EditPortNum.SelectedColor = clBlue;
							iVal--;
							if(iVal != PortNum){
								PortNum = iVal;
								LoadData();
							}
						}
						IList->EditPortNum.Show();
					}else
					if(CtlIndex == 1){
							IList->EditAddrNum.KeyIn(aKey);
							int iVal;
							iVal = IList->EditAddrNum.Str.ToInteger();
							if( (iVal <1) || (iVal > dEP_MAX_COUNT_PER_PORT) ){
								AddrStartValid =0;
								IList->EditAddrNum.SelectedColor = clRed;
							}else{
								AddrStartValid =1;
								IList->EditAddrNum.SelectedColor = clBlue;
								iVal--;
								if(iVal != AddrStart){
									AddrStart = iVal;
									LoadData();
								}
							}
							IList->EditAddrNum.Show();
					}else
					if(CtlIndex == 2){
							IList->Edit[0].KeyIn(aKey);
							int iVal;
							iVal = IList->Edit[0].Str.ToInteger();
							if( (iVal <1) || (iVal > dEP_MAX_COUNT_PER_PORT) ){
								AddrEndValid =0;
								IList->Edit[0].SelectedColor = clRed;
							}else{
								AddrEndValid =1;
								IList->Edit[0].SelectedColor = clBlue;
								iVal--;
								if(iVal != AddrEnd){
									AddrEnd = iVal;
								}
							}
							IList->Edit[0].Show();
					}else
					if(CtlIndex == 3){
						IList->Edit[2].KeyIn(aKey);
						IList->Edit[2].Show();
					}else
					if(CtlIndex == 4){
						IList->Edit[3].KeyIn(aKey);
						IList->Edit[3].Show();
					}
				}
				break;
			case dfKEY_ASTERISK:
					if(CtlIndex == 3){
						IList->Edit[2].KeyIn(aKey);
						IList->Edit[2].Show();
					}
				break;
			case VK_UP:
				if(CtlIndex >0){
					if( (PortValid + dTypeValid + AddrStartValid + AddrEndValid) == 4){
						ClearSelected();
						CtlIndex--;
						Check4Selected();
					}
				}else{
					if( (PortValid + dTypeValid + AddrStartValid + AddrEndValid) == 4){
						ClearSelected();
						CtlIndex =8;
						Check4Selected();
					}
				}
				break;
			case VK_DOWN:
				if(CtlIndex <8){
					if( (PortValid + dTypeValid + AddrStartValid + AddrEndValid) == 4){
						ClearSelected();
						CtlIndex++;
						Check4Selected();
					}
				}else{
					ClearSelected();
					CtlIndex=0;
					Check4Selected();
				}
				break;

			case VK_TAB:
				//IsList = 1;
				//DrawList();
				//ClearSelected();
				break;				
			case dfKEY_SETUP:		//0x70		//  Key value for SETUP
				if( (CtlIndex == 5) || (CtlIndex == 6) ){
					IncDec = IncDec ? 0 :1;
					DrawIncDec();
				}
				break;
			case VK_EXECUTE:
				if( (CtlIndex == 5) || (CtlIndex == 6) ){
					IncDec = IncDec ? 0 :1;
					DrawIncDec();
				}else
				if(CtlIndex == 7){
					DrawDetail();
				}else
				if(CtlIndex == 8){
					//Save Data Here
					PermissionCmd = 1;
					if(SystemPermission > 2){
						PermissionCmdGO();
					}else{
						IsPermission = 1;
						ClearSelected();
						PmsIntervene4Gui.Show4Gui(Lv.Panel.Left + 16, Lv.Panel.Top + 16, Lv.Panel.Width -36 , 140, 3);
					}
				}
				break;
			case VK_RETURN:
				aMsg = guiMsgReturn;
				break;
			default :
				break;
		}
		
		if(VK_EXECUTE != aKey){
			ShowSta(0);
		}
	}
	
	return aMsg;	
}

void TUserCodeSet::LoadAssignType()
{
	int i;
	unsigned int Idf, aOrd, sAddr;
	unsigned char AssignType;
	
	if( (PortNum < dPORT_MAX_COUNT ) && (AddrStart < dEP_MAX_COUNT_PER_PORT) ){
		AssignType = Port[PortNum].AssignType[AddrStart];
		IList->EditCtlNum.Str.FromUInt3Dg(AssignType);
		if(LanguageEnCn==0)IList->STextDType.SetText(StrTypeShortName[AssignType] ,24);
		else IList->STextDType.SetText(StrTypeShortNameEn[AssignType] ,24);
	}else{
		IList->EditCtlNum.Str.FromStr("---");
		IList->STextDType.SetText("----" ,24);
	}
	IList->EditCtlNum.Show();
	IList->STextDType.Show();
}

void TUserCodeSet::LoadUcBcdText()
{
	int i;
	unsigned int Idf, aOrd, sAddr;
	
	if( (PortNum < dPORT_MAX_COUNT ) && (AddrStart < dEP_MAX_COUNT_PER_PORT) ){
		IList->Edit[2].Str.FromUInt8Dg(Port[PortNum].UcList[AddrStart].Full);
	}else{
		IList->Edit[2].Str.FromStr("00000000");
	}
	IList->Edit[2].Show();
}

void TUserCodeSet::LoadShortName()
{
	unsigned int Idf, sAddr;
	
	if( (PortNum < dPORT_MAX_COUNT ) && (AddrStart < dEP_MAX_COUNT_PER_PORT) ){
		AreaNum = Port[PortNum].Area[AddrStart];
		if(AreaNum){
			AreaNum--;
		}else{
			AreaNum = dAreaCountMax +10;
		}
	}else{
		AreaNum = dAreaCountMax +10;;
	}
	
	if(AreaNum >= dAreaCountMax ){
		IList->Edit[1].Str.FromStr("------");
		IList->Edit[1].Show();
		return;
	}
	
	sAddr = dAddrSdRam_4Area + (AreaNum * 64);
	Idf = *(volatile unsigned int *)(sAddr);
	if(Idf == 0xA8A7A6A5){
		sAddr = dAddrSdRam_4Area + (AreaNum * 64) + 16;
		for(int i=0; i<16; i++){
			IList->Edit[1].Str.Text[i] = *(volatile unsigned char *)(sAddr +i);
		}
		IList->Edit[1].Str.Text[16] = '\0';
	}else{
		IList->Edit[1].Str.Text[0] = '\0';
		IList->Edit[1].Str.Text[1] = '\0';
	}
	IList->Edit[1].Show();
}

void TUserCodeSet::LoadData()
{
	LoadAssignType();
	LoadUcBcdText();
	LoadShortName();
}

int TUserCodeSet::DrawDetail()
{
	int x,y, Pst;
	char tText[16];
	unsigned int tUc, HadGotAsFinished;
	int AstStartPoint, AstEndPoint, AstLength, InputLength, InputVal, Step;
	x = Lv.Panel.Left +4;
	y = Lv.Panel.Top +4;
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(LanguageEnCn==0){
		if(PortNum >= dPORT_MAX_COUNT){
			TextRender_string24(x, y, clNearWhite, "回路号不正确");
			return -1;
		}else
		if(AddrStart >= dEP_MAX_COUNT_PER_PORT){
			TextRender_string24(x, y,  clNearWhite, "起始地址不正确");
			return -1;
		}else
		if(AddrEnd >= dEP_MAX_COUNT_PER_PORT){
			TextRender_string24(x, y,  clNearWhite, "结束地址不正确");
			return -1;
		}else
		if(AddrStart > AddrEnd){
			TextRender_string24(x, y,  clNearWhite, "起始-结束 地址不正确");
			return -1;
		}
		
		if(IList->Edit[2].Str.Text[8] != '\0'){
			TextRender_string24(x, y,  clNearWhite, "通配二次码超出长度");
			return -1;
		}
	}else{
		if(PortNum >= dPORT_MAX_COUNT){
			TextRender_string24(x, y, clNearWhite, 	"Loop ID Invalid");
			return -1;
		}else
		if(AddrStart >= dEP_MAX_COUNT_PER_PORT){
			TextRender_string24(x, y,  clNearWhite, 	"Begin Addr Invalid");
			return -1;
		}else
		if(AddrEnd >= dEP_MAX_COUNT_PER_PORT){
			TextRender_string24(x, y,  clNearWhite, "End Addr Invalid");
			return -1;
		}else
		if(AddrStart > AddrEnd){
			TextRender_string24(x, y,  clNearWhite, "Begin-End Addr Invalid");
			return -1;
		}
		
		if(IList->Edit[2].Str.Text[8] != '\0'){
			TextRender_string24(x, y,  clNearWhite, "Aux ID Invalid");
			return -1;
		}
	}
	Step =0;
	GotAst = 0;
	HadGotAsFinished =0;
	for(int i=0; i<16; i++)tText[i] = '\0';
	for(Pst=0; Pst<8; Pst++){
		if(IList->Edit[2].Str.Text[Pst] != '\0'){
			if(HadGotAsFinished == 1){
				if(IList->Edit[2].Str.Text[Pst] == '*'){
					if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "通配二次码存在两段或以上的通配字段");
					else TextRender_string24(x, y, clNearWhite, "Invalid,Aux ID 2 Paragraphs Wildcard");
					return -1;
				}else{
					tText[Pst] = IList->Edit[2].Str.Text[Pst];
					Step++;
				}
			}else{
				if(IList->Edit[2].Str.Text[Pst] == '*'){
					tText[Pst] = '0';
					if(GotAst == 0)AstStartPoint = Pst;
					GotAst =1;
					AstEndPoint = Pst;
				}else{
					tText[Pst] = IList->Edit[2].Str.Text[Pst];
					if(GotAst){
						HadGotAsFinished = 1;
						Step++;
					}
				}
			}
		}else{
			break;
		}
	}
	UserCodeItv = 1;
	for(int i=0; i< Step; i++){
		UserCodeItv *= 10;
	}
	AstLength = AstEndPoint - AstStartPoint +1;
	if(IList->Edit[3].Str.Text[8] != '\0'){
		if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "新二次码长度超出范围");
		else TextRender_string24(x, y, clNearWhite, "New Aux ID Invalid");	//value out of range
		return -1;
	}
	InputLength =0;
	for(int i=0; i<8; i++){
		if(IList->Edit[3].Str.Text[i] != '\0')InputLength++;
		else break;
	}
	InputVal = IList->Edit[3].Str.ToInteger();
	
	if(GotAst){
		if(InputLength > AstLength){
			if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "新二次码长度超出通配字段长度");
			else TextRender_string24(x, y, clNearWhite, "Replacing Num Out Of Wildcard");
			return -1;
		}
		unsigned int tScope =1;
		for(int i=0, z=0; (i<8) && (z<AstLength); i++, z++){
			tScope = tScope * 10;
		}
		
		if(tScope < (AddrEnd - AddrStart)){
			if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, 	"通配字段长度不足,需求:");	//Length Of Wildcard Field
			else TextRender_string24(x, y, clNearWhite, 			"Invalid,Length Of Wildcard Field");
			x += 264;
			TextDigitRender3_24(x, y, clNearWhite, AddrEnd - AddrStart +1);
			return -1;
		}
		
		InputVal = IList->Edit[3].Str.ToInteger();
		if(IncDec == 0){
			if( (InputVal + (AddrEnd - AddrStart) ) > tScope){
				if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, 	"通配字段递增溢出");
				else TextRender_string24(x, y, clNearWhite, 			"Invalid,Value Out Of Range");
				return -1;
			}
		}else{
			if( (InputVal - (AddrEnd - AddrStart) ) < 0){
				if(LanguageEnCn)TextRender_string24(x, y, clNearWhite, "通配字段递减溢出");
				else TextRender_string24(x, y, clNearWhite, 			"Invalid,Value Out Of Range");
				return -1;
			}
		}
		
		
		
		UserCodePrv = TMyString::sToInteger(tText);
		if(UserCodePrv>99'999'999)UserCodePrv=99'999'999;
		if(UserCodePrv==0)UserCodePrv=1;
		UserCodeStart = UserCodePrv + (InputVal * UserCodeItv);
		if(UserCodeStart>99'999'999)UserCodeStart=99'999'999;
		else if(UserCodeStart==0)UserCodeStart=1;
		if(LanguageEnCn==0){
			TextRender_string24(x, y, clNearWhite, 	"使用通配字:");
			x += 132;
			TextDigitRender8_24(x, y, clNearWhite, UserCodePrv);
			x += 110;
			TextRender_string24(x, y, clNearWhite, "开始");
			x += 48;
			TextDigitRender8_24(x, y, clNearWhite, UserCodeStart);
			x += 96;
			TextRender_string24(x, y, clNearWhite, "+");
			x += 12;
			TextDigitRender8_24(x, y, clNearWhite, UserCodeItv);
		}else{
			TextRender_string24(x, y, clNearWhite, 			"With Wildcard");
			x += 13 *12;
			TextDigitRender8_24(x, y, clNearWhite, UserCodePrv);
			x += 110;
			TextRender_string24(x, y, clNearWhite, "Begin");
			x += 5*12;
			TextDigitRender8_24(x, y, clNearWhite, UserCodeStart);
			x += 96;
			TextRender_string24(x, y, clNearWhite, "+");
			x += 12;
			TextDigitRender8_24(x, y, clNearWhite, UserCodeItv);
		}
	}else{
		UserCodeStart = IList->Edit[2].Str.ToInteger();
		if(UserCodeStart>99'999'999)UserCodeStart=99'999'999;
		else if(UserCodeStart==0)UserCodeStart=1;
		if(LanguageEnCn==0){
			TextRender_string24(x, y, clNearWhite, "无通配字 开始:");
			x += 170;
			TextDigitRender8_24(x, y, clNearWhite, UserCodeStart);
			x += 96;
			TextRender_string24(x, y, clNearWhite, "+");
			x += 12;
			TextDigitRender8_24(x, y, clNearWhite, 1);
		}else{
			TextRender_string24(x, y, clNearWhite, "Without Wildcard");
			x += 16*12;
			TextDigitRender8_24(x, y, clNearWhite, UserCodeStart);
			x += 96;
			TextRender_string24(x, y, clNearWhite, "+");
			x += 12;
			TextDigitRender8_24(x, y, clNearWhite, 1);
		}
	}
	
	IList->RealtimeData.Reset();
	x = Lv.Panel.Left +4;
	y+=28;
	if(LanguageEnCn==0){
		TextRender_string24(x, y, clNearWhite, "写入条目数量:");
		x += 156;
	}else{
		TextRender_string24(x, y, clNearWhite, "Numbers Of Items:");
		x += 17*12;
	}
	TextDigitRender5_24(x, y, clNearWhite, AddrEnd-AddrStart+1);
	x += 72;
	TextDigitRender5_24(x, y, clNearWhite, AddrStart+1);
	x += 72;
	TextRender_string24(x, y, clNearWhite, "-");
	x += 12;
	TextDigitRender3_24(x, y, clNearWhite, AddrEnd+1);
	
	
	const int Count = AddrEnd - AddrStart +1;
	tUc = UserCodeStart;
	int aAddr = AddrStart;
	if(Count < 7){
		for(int i=0; i<Count; i++){
			x = Lv.Panel.Left +4;
			y+=28;
			if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "回路:");
			else TextRender_string24(x, y, clNearWhite, "Loop:");
			x += 60;
			TextDigitRender2_24(x, y, clNearWhite, PortNum+1);
			x += 36;
			if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "地址:");
			else TextRender_string24(x, y, clNearWhite, "Addr:");
			x += 60;
			TextDigitRender3_24(x, y, clNearWhite, aAddr+1);
			x += 60;
			if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "原:");
			else TextRender_string24(x, y, clNearWhite, "   "); 
			x += 36;
			TextDigitRender8_24(x, y, clNearWhite, Port[PortNum].UcList[aAddr].Full );
			x += 100;
			TextRender_string24(x, y, clNearWhite, "-->");
			x += 36;
			TextDigitRender8_24(x, y, clNearWhite, tUc );
			
			if(IncDec==0){
				tUc += UserCodeItv;
				if( (tUc>99'999'999) || (tUc==0) )tUc=1;
			}else{
				tUc -= UserCodeItv;
				if( (tUc>99'999'999) || (tUc==0) )tUc=99'999'999;
			}
			aAddr ++;
		}
	}else{
		for(int i=0; i<Count; i++){
			if( (i<3) || (i>(Count-4)) ){
				x = Lv.Panel.Left +4;
				y+=28;
				if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "回路:");
				else TextRender_string24(x, y, clNearWhite, "Loop:");
				x += 60;
				TextDigitRender2_24(x, y, clNearWhite, PortNum+1);
				x += 36;
				if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "地址:");
				else TextRender_string24(x, y, clNearWhite, "Addr:");
				x += 60;
				TextDigitRender3_24(x, y, clNearWhite, aAddr+1);
				x += 60;
				if(LanguageEnCn==0)TextRender_string24(x, y, clNearWhite, "原:");
			else TextRender_string24(x, y, clNearWhite, "   ");
				x += 36;
				TextDigitRender8_24(x, y, clNearWhite, Port[PortNum].UcList[aAddr].Full );
				x += 100;
				TextRender_string24(x, y, clNearWhite, "-->");
				x += 36;
				TextDigitRender8_24(x, y, clNearWhite, tUc );
			}
			if( i==3){
				x = Lv.Panel.Left + 200;
				y+=28;
				TextRender_string24(x, y, clNearWhite, "............");
			}
			
			if(IncDec==0){
				tUc += UserCodeItv;
				if( (tUc>99'999'999) || (tUc==0) )tUc=1;
			}else{
				tUc -= UserCodeItv;
				if( (tUc>99'999'999) || (tUc==0) )tUc=99'999'999;
			}
			aAddr ++;
		}
	}
	
	return 0;
}

void TUserCodeSet::Write2Flash()
{
	unsigned int fAddr;
	unsigned int i,z;
	unsigned int aUcFull;
	volatile unsigned int x, GetSta;
	unsigned char wP1;
	TDMix tCrc;
	
	if( (PortValid + dTypeValid + AddrStartValid + AddrEndValid) != 4){
		return;
	}
	
	do{
		DelayMs(3);
		GetSta = nor_get_busy_state(dFlashAddrDevUserCodeChip);
	}while(GetSta);
	
	//Erase 1 * 4K Blocks
	if( (PortNum  < dPORT_MAX_COUNT) ){
		fAddr = dFlashAddrDevUserCode + (PortNum * 4096);
		nor_erase_sector_4k(dFlashAddrDevUserCodeChip,fAddr);
		DelayMs(100);
		
		do{
			DelayMs(10);
			GetSta = nor_get_busy_state(dFlashAddrDevUserCodeChip);
		}while(GetSta);
		
		aUcFull = UserCodeStart;
		Crc32Reset();
		for(i=0; i<64; i++)IList->ReadWriteData.D32[i] = 0;
		for(i=0; i<4; i++){
			for(x=0;x<64;x++){
				IList->ReadWriteData.D32[x] = Port[PortNum].UcList[i*64 + x].Full;
				if(   ( (i*64 + x) >= AddrStart) && ((i*64 + x) <= AddrEnd)  ){
					IList->ReadWriteData.D32[x] = aUcFull;
					if(IncDec == 0){
						aUcFull += UserCodeItv;
						if( (aUcFull >99999999) || (aUcFull==0) )aUcFull =1;
					}else{
						aUcFull -= UserCodeItv;
						if( (aUcFull >99999999) || (aUcFull==0) )aUcFull =99999999;
					}
				}
				if( (i<3) or (x< (dEP_MAX_COUNT_PER_PORT % 64 ) ) ){
					Crc32Feed(IList->ReadWriteData.D32[x]);
				}
			}
			if(i==3){
				IList->ReadWriteData.D32[63] = Crc32GetResult();
			}
			fAddr = dFlashAddrDevUserCode + (PortNum * 4096) + (i * 256);
			nor_write_page(dFlashAddrDevUserCodeChip, fAddr, IList->ReadWriteData.D8);
			do{
				DelayMs(5);
				GetSta = nor_get_busy_state(dFlashAddrDevUserCodeChip);
			}while(GetSta);
		}
		
		for(x=0;x<dEP_MAX_COUNT_PER_PORT;x++){
			IList->ReadWriteData.D8[x] = Port[PortNum].AssignType[x];
			if(dType !=0){
				if( (x >= AddrStart) && (x <= AddrEnd) ){
					IList->ReadWriteData.D8[x] = dType;
				}
			}
		}
		Crc32Reset();
		for(x=0; x<dEP_MAX_COUNT_PER_PORT; x++)Crc32Feed(static_cast<unsigned int>(IList->ReadWriteData.D8[x]));
		tCrc.D32 = Crc32GetResult();
		IList->ReadWriteData.D8[252] = tCrc.D8[0];
		IList->ReadWriteData.D8[253] = tCrc.D8[1];
		IList->ReadWriteData.D8[254] = tCrc.D8[2];
		IList->ReadWriteData.D8[255] = tCrc.D8[3];
		fAddr = dFlashAddrDevUserCode + (PortNum * 4096) + (4 * 256);
		nor_write_page(dFlashAddrDevUserCodeChip, fAddr, IList->ReadWriteData.D8);
		do{
			DelayMs(5);
			GetSta = nor_get_busy_state(dFlashAddrDevUserCodeChip);
		}while(GetSta);
		
		//Signal Type
		for(x=0;x<dEP_MAX_COUNT_PER_PORT;x++){
			IList->ReadWriteData.D8[x] = Port[PortNum].FuncSetByte[x];
		}
		Crc32Reset();
		for(x=0; x<dEP_MAX_COUNT_PER_PORT; x++)Crc32Feed(static_cast<unsigned int>(IList->ReadWriteData.D8[x]));
		tCrc.D32 = Crc32GetResult();
		IList->ReadWriteData.D8[252] = tCrc.D8[0];
		IList->ReadWriteData.D8[253] = tCrc.D8[1];
		IList->ReadWriteData.D8[254] = tCrc.D8[2];
		IList->ReadWriteData.D8[255] = tCrc.D8[3];
		fAddr = dFlashAddrDevUserCode + (PortNum * 4096) + (5 * 256);
		nor_write_page(dFlashAddrDevUserCodeChip, fAddr, IList->ReadWriteData.D8);
		do{
			DelayMs(5);
			GetSta = nor_get_busy_state(dFlashAddrDevUserCodeChip);
		}while(GetSta);
	}
	
	Record.ReadDevUserSet();
	
	int Count = AddrEnd -AddrEnd +1;
	int NotEqOcc =0;
	int aAddr = AddrStart;
	aUcFull = UserCodeStart;
	for(int Gz=0; Gz<Count; Gz++){
		if(aUcFull != Port[PortNum].UcList[aAddr].Full){
			NotEqOcc = 1;
			break;
		}
		if(IncDec == 0){
			aUcFull += UserCodeItv;
			if( (aUcFull >99999999) || (aUcFull==0) )aUcFull =1;
		}else{
			aUcFull -= UserCodeItv;
			if( (aUcFull >99999999) || (aUcFull==0) )aUcFull =99999999;
		}
		aAddr++;
	}
	
	if(NotEqOcc){
		//Error
		ShowSta(-1);
	}else{
		//OK
		ShowSta(1);
	}
}

void TUserCodeSet::DrawList()
{
	int i, z, x, y;
	unsigned int aClr, TopInx, sAddr, Idf;
	
	return;
	
	IsList ? aClr=clBlue : aClr=clMedGray;
	RectFillRender(Lv.Panel.Left,Lv.Panel.Top,Lv.Panel.Right,Lv.Panel.Bottom,PanelColor);
	RectFillRender(Lv.Panel.Left,Lv.Panel.Top,Lv.Panel.Left +4,Lv.Panel.Bottom,aClr);
	RectFillRender(Lv.Panel.Left,Lv.Panel.Top,Lv.Panel.Right,Lv.Panel.Top +4,aClr);
	RectFillRender(Lv.Panel.Right-4,Lv.Panel.Top,Lv.Panel.Right,Lv.Panel.Bottom,aClr);
	RectFillRender(Lv.Panel.Left,Lv.Panel.Bottom -4,Lv.Panel.Right,Lv.Panel.Bottom,aClr);
	
	const unsigned int PageCount = dAreaCountMax / 8;
	if(ListPage >= PageCount) ListPage = 0;

	x = Lv.Panel.Left+6;
	y = Lv.Panel.Top +6;
	TextRender_string24(x, y, clNearBlack, PanelColor, "区域号   配置     简称           二次码");
	TopInx = ListPage * 8;
	for(i=0,z=TopInx; (i<8) && (z<dAreaCountMax); i++, z++){
		aClr = clNearWhite;
		x = Lv.Panel.Left+6;
		y+=28;
		TextDigitRender4Right24(x, y, aClr, PanelColor, z+1);
		x+=96;
		
		sAddr = dAddrSdRam_4Area + (z * 64);
		Idf = *(volatile unsigned int *)(sAddr);
		if(Idf == 0xA8A7A6A5){
			TextRender_string24(x, y, clNearBlack, PanelColor, "已配置");
			
			//Show ShortName
			for(int g=0; g<20;g++)ListText[g] =0;
			sAddr = dAddrSdRam_4Area + (z * 64) + 16;
			for(int g=0; g<16; g++){
				ListText[g] = *(volatile unsigned char *)(sAddr +g);
			}
			x+=96;
			TextRender_string24(x, y, clNearBlack, PanelColor, ListText);
			
			//Show UserCode
			for(int g=0; g<20;g++)ListText[g] =0;
			sAddr = dAddrSdRam_4Area + (z * 64) + 4;
			for(int g=0; g<8; g++){
				ListText[g] = *(volatile unsigned char *)(sAddr +g);
			}
			x+=200;
			TextRender_string24(x, y, clNearBlack, PanelColor, ListText);
		}else{
			TextRender_string24(x, y, clNearBlack, PanelColor, " ----");
		}
	}	
}




