Esempio n. 1
0
void configchanged(void)
{
        unsigned char tempconfig,configtemp1,configtemp2;
        if(dispconfig[2]==0)//当进入菜单选择时
        {
            switch(dispconfig[0])//对按键行为进行判断
            {
                case 2 : dispconfig[2]=1;break;
                case 3 : dispconfig[2]=2;break;
                case 4 : dispconfig[2]=3;break;
								case 5 : dispconfig[2]=5;SaveData();break;
								case 6 : dispconfig[2]=6;break;
								case 7 : dispconfig[2]=4;			
												timer1.w_year=2014;
												timer1.w_month=5;
												timer1.w_date=10;
												timer1.hour=8;
												timer1.min=59;
												timer1.sec=50;break;
                case 255 : break;
            }
        }
        else if((dispconfig[2]==1)||(dispconfig[2]==2))//当进入人群和季节选择时
        {
            switch(dispconfig[0])//对按键行为进行判断
            {
                   case 1 : 
                  {
                    tempconfig=dispconfig[2];
                    config[tempconfig]=dispconfig[0]-1;
                    dispconfig[2]=0;
                    dispconfig[1]=0;
                    configtemp1=config[1];
                    configtemp2=config[2];
                    needwater=needdrink[configtemp1][configtemp2];
                    selecttemp[0]=tempdata1[configtemp1][configtemp2];
                    selecttemp[1]=tempdata2[configtemp1][configtemp2];
                  }
                  break;
                  case 2 : 
                  {
                    tempconfig=dispconfig[2];
                    config[tempconfig]=dispconfig[0]-1;
                    dispconfig[2]=0;
                    dispconfig[1]=0;
                    configtemp1=config[1];
                    configtemp2=config[2];
                    needwater=needdrink[configtemp1][configtemp2];
                    selecttemp[0]=tempdata1[configtemp1][configtemp2];
                    selecttemp[1]=tempdata2[configtemp1][configtemp2];
                  }
                  break;
                  case 3 : 
                  {
                    tempconfig=dispconfig[2];
                    config[tempconfig]=dispconfig[0]-1;
                    dispconfig[2]=0;
                    dispconfig[1]=0;
                    configtemp1=config[1];
                    configtemp2=config[2];
                    needwater=needdrink[configtemp1][configtemp2];
                    selecttemp[0]=tempdata1[configtemp1][configtemp2];
                    selecttemp[1]=tempdata2[configtemp1][configtemp2];
                  }
                  break;
                  case 4 : 
                  {
                    tempconfig=dispconfig[2];
                    config[tempconfig]=dispconfig[0]-1;
                    dispconfig[2]=0;
                    dispconfig[1]=0;
                    configtemp1=config[1];
                    configtemp2=config[2];
                    needwater=needdrink[configtemp1][configtemp2];
                    selecttemp[0]=tempdata1[configtemp1][configtemp2];
                    selecttemp[1]=tempdata2[configtemp1][configtemp2];
                  }
                  break;
									case 0 : dispconfig[2]=0; break;
                case 255 : break;
            }
        }
        else if(dispconfig[2]==3)//当进入理想温度设定
        {

            switch(dispconfig[0])//对按键行为进行判断
            {
                /*
                case 6 : if(dispconfig[1]==1)dispconfig[1]=0;else dispconfig[1]++;break;
                case 9 : if(dispconfig[1]==1)
                          {
                            if(selecttemp[1]==48)
                              selecttemp[1]=57;
                            else selecttemp[1]--;
                          }
                          else if(dispconfig[1]==0)
                          {
                            if(selecttemp[0]==51)
                              selecttemp[0]=57;
                            else selecttemp[0]--;
                          }break;
                case 10 : dispconfig[2]=0;dispconfig[1]=0;break;
                case 11 : if(dispconfig[1]==1)
                          {
                            if(selecttemp[1]==57)
                              selecttemp[1]=48;
                            else selecttemp[1]++;
                          }
                          else if(dispconfig[1]==0)
                          {
                            if(selecttemp[0]==57)
                              selecttemp[0]=51;
                            else selecttemp[0]++;
                          }break;
                case 14 : if(dispconfig[1]==0)dispconfig[1]=1;else dispconfig[1]--;break;*/
								case 0 : dispconfig[2]=0; break;
								case 1 :  {
                            if(selecttemp[0]==57)
                              selecttemp[0]=51;
                            else selecttemp[0]++;
                          }break;
							  case 2 :  {
                            if(selecttemp[0]==51)
                              selecttemp[0]=57;
                            else selecttemp[0]--;
                          }break;
								case 3 :  {
                            if(selecttemp[1]==57)
                              selecttemp[1]=48;
                            else selecttemp[1]++;
                          }break;
								case 5 :  {
                            if(selecttemp[1]==48)
                              selecttemp[1]=57;
                            else selecttemp[1]--;
                          }break;
                case 255 : break;
            }
        }
        else if(dispconfig[2]==4)//进入RTC
        {
            switch(dispconfig[0])//对按键行为进行判断
            {
              case 0 : dispconfig[2]=0;dispconfig[1]=0;break;
							case 1 : timer1.w_year++;break;
							case 2 : timer1.w_year--;break;
							case 3 : timer1.w_month++;if(timer1.w_month==13)timer1.w_month=1;break;
							case 4 : timer1.w_month--;if(timer1.w_month==0)timer1.w_month=12;break;
							case 5 : timer1.w_date++;if(timer1.w_date==32)timer1.w_date=1;break;
							case 6 : timer1.w_date--;if(timer1.w_date==0)timer1.w_date=31;break;
							case 7 : timer1.hour++;if(timer1.hour==24)timer1.hour=0;break;
							case 8 : timer1.hour--;if(timer1.hour==255)timer1.hour=23;break;
							case 9 : timer1.min++;if(timer1.min==60)timer1.min=0;break;
							case 10 : timer1.min--;if(timer1.min==255)timer1.min=59;break;
							case 11 : timer1.sec++;if(timer1.sec==60)timer1.sec=0;break;
              case 12 : timer1.sec--;if(timer1.sec==255)timer1.sec=59;break;
							case 13 : RTC_Set(timer1.w_year,timer1.w_month,timer1.w_date,timer1.hour,timer1.min,timer1.sec);break;
							case 255 : break;
            }
        }
        else if(dispconfig[2]==5)//进入主页2
        {
            switch(dispconfig[0])//对按键行为进行判断
            {
                case 0 : dispconfig[2]=0;dispconfig[1]=0;break;
								case 1 : if(startflag==0)
													{
														startflag=1;
														finalwater=0;
													}
													else if(startflag==1)
													{
														startflag=0;
														finalwater=0;
														waterflag=0;
														finaltime=0;
														buzzerflag=0;
													}
													LED3=!LED3;
													UR1TxReadIndex=0;
													UR1TxWriteIndex=0;
													UR1TxBuf[0]=48;
													UR1TxBuf[1]=table_mbtemp[0];
													UR1TxBuf[2]=table_mbtemp[1];
													UR1TxBuf[3]=dN1[0];
													UR1TxBuf[4]=dN1[1];
													UR1TxBuf[5]=finaltime;
													UR1TxBuf[6]=startflag+48;
													UR1TxBuf[7]=selecttemp[0];
													UR1TxBuf[8]=selecttemp[1];
													UR1TxBuf[9]=127;
													UR1TxBuf[10]=127;
													UR1TxBuf[11]=127;
													UR1TxBuf[12]=127;
													UR1TxBuf[13]=127;
													UR1TxBuf[14]=127;
													UR1TxBuf[15]=fanflag+48;
													UR2_TX(1);
													break;
								case 2 : if(fanflag==0)
													{
														fanflag=1;
														
													}
													else if(fanflag==1)
													{
														fanflag=0;
													}
													UR1TxReadIndex=0;
													UR1TxWriteIndex=0;
													UR1TxBuf[0]=48;
													UR1TxBuf[1]=table_mbtemp[0];
													UR1TxBuf[2]=table_mbtemp[1];
													UR1TxBuf[3]=dN1[0];
													UR1TxBuf[4]=dN1[1];
													UR1TxBuf[5]=finaltime;
													UR1TxBuf[6]=startflag+48;
													UR1TxBuf[7]=selecttemp[0];
													UR1TxBuf[8]=selecttemp[1];
													UR1TxBuf[9]=127;
													UR1TxBuf[10]=127;
													UR1TxBuf[11]=127;
													UR1TxBuf[12]=127;
													UR1TxBuf[13]=127;
													UR1TxBuf[14]=127;
													UR1TxBuf[15]=fanflag+48;
													UR2_TX(1);
													break;
                case 5 : dispconfig[2]=5;break;
								case 6 : dispconfig[2]=5;needwater=needdrink[config[1]][config[2]];break;
                case 255 : break;
            }
        }
        else if(dispconfig[2]==6)//进入测重校准
        {
            switch(dispconfig[0])//对按键行为进行判断
            {
                case 0 : dispconfig[2]=0;dispconfig[1]=0;break;
                case 5 : if((def>ad_c))def=ad_c+7;break;//开始校准
								case 6 : dispconfig[2]=6;
                case 14 : if((def<ad_c))def+=50000;break;//数据复位
                case 255 : if(def<ad_c)def+=775;break;//自动修正(有bug)
            }
        }             
}
void wxsSizerParentQP::OnBrdDlgChange(cb_unused wxCommandEvent& event)
{
    SaveData();
}
Esempio n. 3
0
 void wxsListbookParentQP::OnLabelKillFocus(wxFocusEvent& event)    { SaveData(); event.Skip(); }
Esempio n. 4
0
void KUiWndFrameTabControl::OnSelWnd()
{
    typedef std::vector<_tstring>	ListItemArray; 
    ListItemArray aList;
    char  szWndType[128] = "";  
    char  szWndName[128] = "";
    HMENU hMenu = NULL;
    int   i = 0;
    POINT MousePosition;
    int   nId = 0;
    int   nSel = 0;
    int   nMax = 0;
    IIniFile *pIni = g_Ui.GetIni();
    KG_PROCESS_ERROR(pIni);

    while (g_Ui.GetNextUnit(szWndName)) 
    {
        pIni->GetString(szWndName, "._WndType", "", szWndType, sizeof(szWndType));

        if (!IsItemExist(szWndName) && _tcsicmp(szWndType, g_GetWndTypeKey(UI_WND_FRAME)) != 0) 
        {
            aList.push_back(szWndName);
        }
    }

    nId =91000;
	hMenu = CreatePopupMenu();
    KG_PROCESS_ERROR(hMenu);   
    nMax = aList.size();
    for (i = 0; i < nMax; i++) 
    {
        strcpy(szWndName, aList[i].c_str());
        AppendMenu(hMenu, MF_ENABLED | MF_STRING, nId, szWndName);
        nId++;
    }
    AppendMenu(hMenu, MF_ENABLED | MF_STRING, nId, "全部添加");
    nId++;

    GetCursorPos(&MousePosition);
    nSel = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_NONOTIFY, 
        MousePosition.x, MousePosition.y, 0, m_hWnd, NULL);
	DestroyMenu(hMenu);

    KG_PROCESS_ERROR(nSel >= 91000 && nSel < nId);
    if (nSel == nId - 1) 
    {
        nMax = aList.size();
        for (i = 0; i < nMax; i++) 
        {
            strcpy(szWndName, aList[i].c_str());
            LV_ITEM			lvi;
            memset(&lvi, 0, sizeof(LV_ITEM));
            lvi.mask = LVIF_TEXT;
            lvi.pszText		= (char*)szWndName;
            lvi.cchTextMax  = strlen(szWndName);
            lvi.iItem       = ListView_GetItemCount(m_hListWnd);
            lvi.iItem		= ListView_InsertItem(m_hListWnd, &lvi);
        }
    }
    else
    {
        strcpy(szWndName, aList[nSel - 91000].c_str());
        LV_ITEM			lvi;
        memset(&lvi, 0, sizeof(LV_ITEM));
        lvi.mask = LVIF_TEXT;
        lvi.pszText		= (char*)szWndName;
        lvi.cchTextMax  = strlen(szWndName);
        lvi.iItem       = ListView_GetItemCount(m_hListWnd);
        lvi.iItem		= ListView_InsertItem(m_hListWnd, &lvi);
    }

    SaveData();

Exit0:
    aList.clear();
    return;
}
void wxsSizerParentQP::OnBrdSizeChange(cb_unused wxSpinEvent& event)
{
    SaveData();
}
Esempio n. 6
0
void CQueryWizardDialog::OnNext() {
	returnValue = QW_NEXT;
	SaveData( builder );
	CDialog::OnOK();
}
Esempio n. 7
0
void CQueryWizardDialog::OnExit() {
	returnValue = QW_EXIT;
	SaveData( builder );
	CDialog::OnOK();
}
Esempio n. 8
0
//=============================================================================
// 更新処理
//=============================================================================
void UpdateGameManager(void)
{
#ifdef _DEBUG
	if(GetKeyboardTrigger(DIK_F1))
	{
		g_nGameMode = SELECTMODE_PLAY;
	}
	if(GetKeyboardTrigger(DIK_F2))
	{
		g_nGameMode = SELECTMODE_WALLEDIT;
	}
	if(GetKeyboardTrigger(DIK_F3))
	{
		g_nGameMode = SELECTMODE_GIMMICKEDIT;
	}
	if(GetKeyboardTrigger(DIK_F4))
	{
		g_nGameMode = SELECTMODE_PLAYEREDIT;
	}
	if(GetKeyboardTrigger(DIK_F5))
	{
		g_nGameMode = SELECTMODE_DELETE;
	}
	if(GetKeyboardTrigger(DIK_F6))
	{
		g_nGameMode = SELECTMODE_SCENECHANGE;
	}
	if(GetKeyboardTrigger(DIK_F7))
	{
		g_nGameMode = SELECTMODE_PLAYERBAR_NUM;
	}
	if(GetKeyboardTrigger(DIK_F8))
	{
		g_nGameMode = SELECTMODE_ITEMNUMEDIT;
	}
	if(g_nGameMode != SELECTMODE_PLAY)
		GetBackG()[BACKGROUND_EDIT_NET].bUse = true;
	else
		GetBackG()[BACKGROUND_EDIT_NET].bUse = false;

#endif

	switch (g_nGameMode)
	{
	case SELECTMODE_PLAY:
	{
		PrintDebugProc("【ゲームモード】\n");
		if(GetTimeCounter()->fCurrentTime > TIME_15)
			g_bIsPlay = false;

		if(!g_bIsPlay)
		{
			if(IsMouseRightTriggered())
			{
				int nGimNum = -1;
				int nItemNum = GetItemNum()->nItemLockTime;
				bool bIsLock = false;

				if(IsGimmickLock(&nGimNum, &bIsLock, &nItemNum) == true)
				{
					if(bIsLock == true)
					{
						SetItem(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), ITEM_TYPE_01, nGimNum);
						UpdataItemNum(-1);
					}
					else
					{
						DeleteItem(nGimNum);
						UpdataItemNum(1);
					}
				}
			}
		}
		break;
	}
	case SELECTMODE_WALLEDIT:
	{
		PrintDebugProc("【壁を編集するモード】\n");
		WallCreateMode();
		break;
	}
	case SELECTMODE_GIMMICKEDIT:
	{
		PrintDebugProc("【ギミック編集モード】\n");
		GimmickCreateMode();
		break;
	}
	case SELECTMODE_PLAYEREDIT:
	{
		PrintDebugProc("【プレイヤー編集モード】\n");
		if(IsMouseLeftPressed())
			IsMouseHitPlayer();
		PlayerEdit();
		break;
	}
	case SELECTMODE_DELETE:
	{
		PrintDebugProc("【削除モード】\n");
		DeleteGimmick();
		DeleteWall();
		break;
	}
	case SELECTMODE_SCENECHANGE:
	{
		PrintDebugProc("【ステージ切り替えるモード】\n");
		if(IsMouseRightTriggered())
		{
			if(*GetSceneNum() < SCENE_TYPE_MAX)
				(*GetSceneNum())++;
			if(*GetSceneNum() == SCENE_TYPE_MAX)
				*GetSceneNum() = 0;
			g_bIsSceneInit = true;
		}

		if(g_bIsSceneInit == true)
		{
			g_bIsSceneInit = false;
			switch (*GetSceneNum())
			{
			case SCENE_01:
				// 从文件中读取
				LoadData(SCENE_01);
				break;
			case SCENE_02:
				// 从文件中读取
				LoadData(SCENE_02);
				break;
			case SCENE_03:
				// 从文件中读取
				LoadData(SCENE_03);
				break;
			case SCENE_04:
				// 从文件中读取
				LoadData(SCENE_04);
				break;
			case SCENE_05:
				// 从文件中读取
				LoadData(SCENE_05);
				break;
			default:
				break;
			}
			// 読み込むデータを初期化
			InitDataPlayer();
			InitDataWall();
			InitDataGimmick();
			InitDataPlayerbar();

			for(int nCntGim = 0; nCntGim < MAX_GIMMICK; nCntGim++)
			{
				// 根据补完的数据对机关场景进行位置和运动预处理
				SetupGimmickTrack(nCntGim);
				*GetCleanupSwitch() = false;
			}
		}
		break;
	}
	case SELECTMODE_PLAYERBAR_NUM:
	{
		PrintDebugProc("【時間軸編集モード】\n");
		PrintDebugProc("数字キー「1」 時間軸数:1\n");
		PrintDebugProc("数字キー「2」 時間軸数:2\n");
		PrintDebugProc("数字キー「3」 時間軸数:3\n");
		if(GetKeyboardTrigger(DIK_1))
		{
			for(int nCntPlayBar = 0; nCntPlayBar < MAX_PLAYBAR; nCntPlayBar++)
			{
				//if(g_pPlaybar_GM[nCntPlayBar].bUse == true)
					g_pPlaybar_GM[nCntPlayBar].bUse = false;
			}
			for(int nCntGim = 0; nCntGim < MAX_GIMMICK; nCntGim++)
			{
				if(g_pGimmick_GM[nCntGim].bUse)
				{
					g_pGimmick_GM[nCntGim].nPriorityNum01 = -1;
					g_pGimmick_GM[nCntGim].nPriorityNum02 = -1;
					g_pGimmick_GM[nCntGim].nPriorityNum03 = -1;
				}
			}
			SetPlaybar(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), PLAYBAR_3_1);
			PlaybarNumCount();
		}
		if(GetKeyboardTrigger(DIK_2))
		{
			for(int nCntPlayBar = 0; nCntPlayBar < MAX_PLAYBAR; nCntPlayBar++)
			{
				//if(g_pPlaybar_GM[nCntPlayBar].bUse == true)
					g_pPlaybar_GM[nCntPlayBar].bUse = false;
			}
			for(int nCntGim = 0; nCntGim < MAX_GIMMICK; nCntGim++)
			{
				if(g_pGimmick_GM[nCntGim].bUse)
				{
					g_pGimmick_GM[nCntGim].nPriorityNum01 = -1;
					g_pGimmick_GM[nCntGim].nPriorityNum02 = -1;
					g_pGimmick_GM[nCntGim].nPriorityNum03 = -1;
				}
			}
			SetPlaybar(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), PLAYBAR_3_1);
			SetPlaybar(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), PLAYBAR_3_2);
			PlaybarNumCount();
		}
		if(GetKeyboardTrigger(DIK_3))
		{
			for(int nCntPlayBar = 0; nCntPlayBar < MAX_PLAYBAR; nCntPlayBar++)
			{
				//if(g_pPlaybar_GM[nCntPlayBar].bUse == true)
					g_pPlaybar_GM[nCntPlayBar].bUse = false;
			}
			for(int nCntGim = 0; nCntGim < MAX_GIMMICK; nCntGim++)
			{
				if(g_pGimmick_GM[nCntGim].bUse)
				{
					g_pGimmick_GM[nCntGim].nPriorityNum01 = -1;
					g_pGimmick_GM[nCntGim].nPriorityNum02 = -1;
					g_pGimmick_GM[nCntGim].nPriorityNum03 = -1;
				}
			}
			SetPlaybar(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), PLAYBAR_3_1);
			SetPlaybar(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), PLAYBAR_3_2);
			SetPlaybar(D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), PLAYBAR_3_3);
			PlaybarNumCount();
		}
		break;
	}
	case SELECTMODE_ITEMNUMEDIT:
	{
		PrintDebugProc("【アイテム個数編集モード】\n");
		PrintDebugProc("【メニュー】    【アイテム】    【個数】\n");
		PrintDebugProc("数字キー「1」 時間固定アイテム:%d\n\n", g_pItemNum_GM->nItemLockTime);

		if(GetKeyboardTrigger(DIK_1))
		{
			g_nMenuSelect_GM = 1;
		}

		switch (g_nMenuSelect_GM)
		{

			case 1:
				PrintDebugProc("矢印キー【左】、【右】   【プラス/マイナス 1】\n");
				PrintDebugProc("矢印キー【上】、【下】   【プラス/マイナス 5】\n");

				if(GetKeyboardRepeat(DIK_LEFT))
				{
					g_pItemNum_GM->nItemLockTime -= 1;
					if(g_pItemNum_GM->nItemLockTime < 0)
						g_pItemNum_GM->nItemLockTime = 0;
				}
				if(GetKeyboardRepeat(DIK_RIGHT))
				{
					g_pItemNum_GM->nItemLockTime += 1;
					if(g_pItemNum_GM->nItemLockTime > 9)
						g_pItemNum_GM->nItemLockTime = 9;
				}
				if(GetKeyboardRepeat(DIK_DOWN))
				{
					g_pItemNum_GM->nItemLockTime -= 5;
					if(g_pItemNum_GM->nItemLockTime < 0)
						g_pItemNum_GM->nItemLockTime = 0;
				}
				if(GetKeyboardRepeat(DIK_UP))
				{
					g_pItemNum_GM->nItemLockTime += 5;
					if(g_pItemNum_GM->nItemLockTime > 9)
						g_pItemNum_GM->nItemLockTime = 9;
				}
				break;
			default:
				break;
		}

	}
	default:
		break;
	}

	if(!g_bIsPlay)
	{
		switch (*GetSceneNum())
		{
		case SCENE_01:
			PrintDebugProc("【SCENE_01】\n");
			// 今のシーンをセーフする
			if(IsMouseCenterTriggered())
				SaveData(SCENE_01);
			break;

		case SCENE_02:
			PrintDebugProc("【SCENE_02】\n");
			if(IsMouseCenterTriggered())
				SaveData(SCENE_02);
			break;

		case SCENE_03:
			PrintDebugProc("【SCENE_03】\n");
			if(IsMouseCenterTriggered())
				SaveData(SCENE_03);
			break;

		case SCENE_04:
			PrintDebugProc("【SCENE_04】\n");
			if(IsMouseCenterTriggered())
				SaveData(SCENE_04);
			break;

		case SCENE_05:
			PrintDebugProc("【SCENE_05】\n");
			if(IsMouseCenterTriggered())
				SaveData(SCENE_05);
			break;

		default:
			break;
		}
	}

	switch(*GetMode())
	{
	case GAMEMODE_LOGO:
		break;

	case GAMEMODE_TITLE:
	{
		if(GetKeyboardTrigger(DIK_RETURN) || IsMouseLeftTriggered())
			SetFade(FADE_OUT, FADE_IN, GAMEMODE_STAGE_SELECT);
		break;
	}
	case GAMEMODE_STAGE_SELECT:
	{
		g_bIsStop = true;
		g_bIsPlay = false;

		if(GetKeyboardTrigger(DIK_RETURN))
			SetFade(FADE_OUT, FADE_IN, GAMEMODE_GAME);

		if(IsMouseLeftTriggered())
		{
			int pIconNum = 0;
			if(IsMouseHitIcon(&pIconNum) == true)
			{
				*GetSceneNum() = GetGameElement()[pIconNum].nType;
				g_bIsSceneInit = true;
			}
		}

		if(g_bIsSceneInit == true)
		{
			g_bIsSceneInit = false;
			switch (*GetSceneNum())
			{
			case SCENE_01:
				// 从文件中读取
				LoadData(SCENE_01);
				break;
			case SCENE_02:
				// 从文件中读取
				LoadData(SCENE_02);
				break;
			case SCENE_03:
				// 从文件中读取
				LoadData(SCENE_03);
				break;
			case SCENE_04:
				// 从文件中读取
				LoadData(SCENE_04);
				break;
			case SCENE_05:
				// 从文件中读取
				LoadData(SCENE_05);
				break;
			default:
				break;
			}
			// 読み込むデータを初期化
			InitDataPlayer();
			InitDataWall();
			InitDataGimmick();
			InitDataPlayerbar();

			for(int nCntGim = 0; nCntGim < MAX_GIMMICK; nCntGim++)
			{
				// 根据补完的数据对机关场景进行位置和运动预处理
				SetupGimmickTrack(nCntGim);
				*GetCleanupSwitch() = false;
			}
			//*GetMode() = GAMEMODE_GAME;

			SetFade(FADE_OUT, FADE_IN, GAMEMODE_GAME);
		}
		
		break;
	}
	case GAMEMODE_GAME:
		break;

	case GAMEMODE_END:
		break;

	default:
		break;
	}



}
Esempio n. 9
0
/*
**      The AGM itself
**
** A[0]=1 B[0]=1/sqrt(2) Sum=1
**
** n=1..inf
** A[n] = (A[n-1] + B[n-1])/2
** B[n] = Sqrt(A[n-1]*B[n-1])
** C[n] = (A[n-1]-B[n-1])/2    or:
** C[n]^2 = A[n]^2 - B[n]^2    or:
** C[n]^2 = 4A[n+1]*C[n+1]
** Sum  = Sum - C[n]^2*(2^(n+1))
** PI[n] = 4A[n+1]^2 / Sum
**
** However, it's not implemented that way.  We can save a full
** sized multiplication (with two numbers) by rearranging it,
** and keeping the squares of the A and B.  Also, we can do the
** first pass a little differently since A and A^2 will both be 1.
**
** A[0]=1           A[0]^2=1
** B[0]=1/sqrt(2)   B[0]^2=0.5
**
** First pass:
**
** A[1]     = (A[0] + B[0])/2
** B[1]^2   = A[0]*B[0]  ; Since A[0]==1, B[1]^2=B[0]
** C[1]^2   = ((A[0]^2+B[0]^2)/2-B[1]^2)/2
**
** Remainging passes:
**
** C[n]     = (A[n-1]-B[n-1])/2; C[n] is actually temp usage of C[n]^2
** A[n]     = A[n-1] - C[n]
** C[n]^2   = C[n]*C[n]
** B[n]^2   = (A[n-1]^2+B[n-1]^2-4C[n]^2)/2
**
** Then the rest of the formula is done the same:
**
** A[n]^2   = C[n]^2 + B[n]^2
** B[n]     = sqrt(B[n]^2)
** Sum      = Sum - C[n]^2*(2^(n+1))
**
** It is an unusual arrangment, but they are all derived directly
** from the standard AGM formulas as given by Salamin.
**
*/
static int
ComputeFastAGM(size_t Len, size_t MaxPasses)
{
  int Sign;
  size_t Pass;
  double Pow2;
  clock_t LoopTime,EndTime,StartTime;
  BigInt AGM_A, AGM_B, AGM_Sum, AGM_C2;
  BigInt AGM_A2, AGM_B2; /* Squares */
  int Done; /* boolean */

  if ((Cfg.PiFormulaToUse != 2) && (Cfg.PiFormulaToUse != 3))
    FatalError("FastAGM was somehow called with pi formula %d\n",
               Cfg.PiFormulaToUse);

  if (!Cfg.Macintosh) fprintf(stderr,"Creating vars");
  AGM_A   = CreateBigInt(Len);
  AGM_A2  = CreateBigInt(Len);
  AGM_B   = CreateBigInt(Len);
  AGM_B2  = CreateBigInt(Len);
  AGM_C2  = CreateBigInt(Len);
  AGM_Sum = CreateBigInt(Len);
  if (!Cfg.Macintosh) BackSpace(13);

  Num1IsCached = Num2IsCached = 0;
  StartTime = clock();
  Pow2 = 4.0;
  Pass = 0;
  if (!LoadData(AGM_A,AGM_A2,AGM_B,AGM_B2,AGM_Sum,OldRoot,
    &StartTime,&Pow2,&Pass,Len,Cfg.PiFormulaToUse))
    {
     fprintf(stderr, "Init     : ");
     LoopTime = clock();
     Pow2 = 4.0;
     Pass = 0;

     if (Cfg.PiFormulaToUse==2)
       {
        if (!Cfg.Macintosh) fprintf(stderr,"Setting vars");
        SetNum(AGM_A,Len,  BI_One,0);
        SetNum(AGM_A2,Len, BI_One,0);
        SetNum(AGM_B2,Len, BI_OneHalf,0);
        SetNum(AGM_Sum,Len,BI_One,0);
        ClearBigInt(OldRoot,Len);
        if (!Cfg.Macintosh) BackSpace(12);
        Sqrt05(AGM_B,Len);
        if ((Cfg.AGMSelfCheck == 3) || (Cfg.AGMSelfCheck == 4))
          {
         /* We can use OldRoot and DSWork as scratch. */
           if (!Cfg.Macintosh) fprintf(stderr,"Self Check");
           SpecialSquare(OldRoot,AGM_B,Len,DSWork);
           DoCheck(OldRoot,AGM_B2,0,Len);
           ClearBigInt(OldRoot,Len);
           if (!Cfg.Macintosh) BackSpace(10);
          }
       }
     else
       {
        Sqrt20(AGM_A,Len);
        Sqrt60(AGM_A2,Len);
        if (!Cfg.Macintosh) fprintf(stderr,"Square");
        Add(AGM_B,AGM_A,AGM_A2,Len);
        DivBy(AGM_B,AGM_B,4,Len);
        SpecialSquare(AGM_B2,AGM_B,Len,AGM_A);
        if (!Cfg.Macintosh) BackSpace(6);
        if (!Cfg.Macintosh) fprintf(stderr,"Setting vars");
        ClearBigInt(OldRoot,Len);
        SetNum(AGM_A,Len,  BI_One,0);
        SetNum(AGM_A2,Len, BI_One,0);
        SetNum(AGM_Sum,Len,BI_One,0);
        if (!Cfg.Macintosh) BackSpace(12);
        Pass=1;
       }

     EndTime = clock();
     fprintf(stderr, "Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     if (Cfg.AlwaysSaveData)
        SaveData(AGM_A,AGM_A2,AGM_B,AGM_B2,AGM_Sum,OldRoot,
                 ((double)EndTime-(double)StartTime)/CLOCKS_PER_SEC,
	  Pow2,Pass,Len,Cfg.PiFormulaToUse);
    }

/*
  DumpBigInt("AGM_A  ",AGM_A,Len);
  DumpBigInt("AGM_A2 ",AGM_A2,Len);
  DumpBigInt("AGM_B  ",AGM_B,Len);
  DumpBigInt("AGM_B2 ",AGM_B2,Len);
  DumpBigInt("AGM_C2 ",AGM_C2,Len);
  DumpBigInt("AGM_Sum",AGM_Sum,Len);
*/

  Done=0;
  MaxPasses+=Pass;
  while ((!Done) && (Pass < MaxPasses))
    {size_t FNZ;
     int Key=0;
/* DJGPP stuff to test the self checking.
** Comment out the keyboard break statement at the end of the loop.
     extern int getkey(void);
     if (TestKeyboard()) {Key=getkey();srand((unsigned int)time(NULL));}
*/

      fprintf(stderr, "Pass %4s: ", Num2Str(2<<(++Pass)));
      LoopTime = clock();

      if ((Pass==1) &&
          (strcmp(GetCheckStr(AGM_A),"1000000000000000")==0))
        {
/*
** Since AGM_A==1, we can do the first pass a little differently
** and avoide the multiplication completely.
*/
         if (!Cfg.Macintosh) fprintf(stderr,"AGM Part1");

         /* Compute a=(a+b)/2 */
         if (Key=='1') CorruptVar(AGM_A,Len);
         Add(AGM_A, AGM_A, AGM_B, Len);DivBy(AGM_A,AGM_A, 2, Len);
         if (Cfg.AGMSelfCheck >= 1)
           {
            DivBy(DSWork,AGM_B,2,Len);AddInt(DSWork,BI_OneHalf);
            DoCheck(DSWork,AGM_A,1,Len);
           }

         /* Compute C^2 and B^2 */
         Add(AGM_C2,AGM_A2,AGM_B2,Len);DivBy(AGM_C2,AGM_C2,2,Len);
         if (Cfg.AGMSelfCheck >= 1) Add(DSWork,AGM_A2,AGM_B2,Len);
         Copy(AGM_B2,AGM_B,Len); /* AGM_A == 1.0, so we can copy */
         Sign=Sub(AGM_C2,AGM_C2,AGM_B2,Len);DivBy(AGM_C2,AGM_C2,2,Len);
         if (Key=='4') CorruptVar(AGM_B2,Len);
         if (Key=='5') CorruptVar(AGM_C2,Len);
         if (Sign) FatalError("AGM_C2 should never be negative.\n");
         if (!Cfg.Macintosh) BackSpace(9);
        }
      else
        {
         if (!Cfg.Macintosh) fprintf(stderr,"AGM Part1");

         /* Compute C */
/*
         Sign=Sub(AGM_C2, AGM_A, AGM_B, Len);DivBy(AGM_C2,AGM_C2,2,Len);
*/
         Sign=HalfDiff(AGM_C2,AGM_A,AGM_B,Len);
         if (Sign) FatalError("AGM_C2 should never be negative.\n");

         /* Compute A.  AGM_C2 is still only C at the moment. */
         if (Cfg.AGMSelfCheck >= 1)
           {Add(DSWork,AGM_A,AGM_B,Len);DivBy(DSWork,DSWork,2,Len);}
         if (Sub(AGM_A,AGM_A,AGM_C2,Len))
            FatalError("AGM_A should never be negative.\n");
         if (Key=='1') CorruptVar(AGM_A,Len);
         if (Cfg.AGMSelfCheck >= 1) DoCheck(DSWork,AGM_A,2,Len);

         if (!Cfg.Macintosh) BackSpace(9);
         if (!Cfg.Macintosh) fprintf(stderr,"Sqr");
         /* Compute C^2 */
         SpecialSquare(AGM_C2,AGM_C2,Len,AGM_B);
         if (Key=='5') CorruptVar(AGM_C2,Len);
         if (!Cfg.Macintosh) BackSpace(3);

         if (!Cfg.Macintosh) fprintf(stderr,"AGM Part2");
         if (Cfg.AGMSelfCheck >= 1) Add(DSWork,AGM_A2,AGM_B2,Len);
         /* Compute B^2 */
         Sign=SpecialAGMFunc1(AGM_B2,AGM_A2,AGM_C2,Len);
         if (Key=='4') CorruptVar(AGM_B2,Len);
/*
         Add(AGM_B2,AGM_B2,AGM_A2,Len);
         MulBy(AGM_A2,AGM_C2,4,Len);
         Sign=Sub(AGM_B2,AGM_B2,AGM_A2,Len);
         DivBy(AGM_B2,AGM_B2,2,Len);
*/

         if (Sign) FatalError("AGM_B2 should never be negative.\n");
         if (!Cfg.Macintosh) BackSpace(9);
        }

      if (!Cfg.Macintosh) fprintf(stderr,"AGM Part3");
      /* Compute A^2 */
      if (Cfg.AGMSelfCheck >= 1)
        {
         Add(DSWork,DSWork,AGM_B2,Len);
         Add(DSWork,DSWork,AGM_B2,Len);
         DivBy(DSWork,DSWork,4,Len);
        }
      Add(AGM_A2,AGM_C2,AGM_B2,Len);
      if (Key=='2') CorruptVar(AGM_A2,Len);
      if (Cfg.AGMSelfCheck >= 1) DoCheck(DSWork,AGM_A2,3,Len);
      if (!Cfg.Macintosh) BackSpace(9);

/*
** Do some self checking.  The estimate formula predicts the number of
** leading zeros.  It's based on the regular AGM accuracy formula.  It
** predicts just a couple of digits less than what is actually there,
** so if anything happens, this should fail.  But, since it is so
** close, it just might fail for the wrong reason.
*/
      if (!Cfg.Macintosh) fprintf(stderr,"Self Check");
      FNZ=FindFirstNonZero(AGM_C2,Len);
      if ((Pass > 3) && (FNZ != Len))
        {size_t P=Pass-2;size_t Est;
         /* formula based on the AGM 'number of digits right' formula */
         if (Cfg.PiFormulaToUse==2)
            Est=(1.364376354*(1<<(P))-P*.301029995-2.342434419)/2;
         else /* other agm does 1 less pass, so pass is one higher, so div by 4 */
            Est=(sqrt(3.0)*1.364376354*(1<<(P))-P*.301029995-2.690531961)/4;

         if (Est >= FNZ)
           {
            fprintf(stderr,"\aAGM self check fails.  Predicted: %lu Actual: %lu\n",
                    (ULINT)Est,(ULINT)FNZ);
            fprintf(stderr,"Beyond what I've tested, this may not be an actual failure\n");
            fprintf(stderr,"but an inaccuracy in the self check formula itself.\n");
           }
        }

      /* See if it's done.  (ie: more than half zeros) */
      if (FNZ > Len/2+4) Done=1;

      if ((Cfg.AGMSelfCheck == 2) || (Cfg.AGMSelfCheck == 4))
        {
      /* We can use AGM_B and DSWork as scratch. */
         SpecialSquare(AGM_B,AGM_A,Len,DSWork);
         DoCheck(AGM_B,AGM_A2,4,Len);
        }
      if (!Cfg.Macintosh) BackSpace(10);

      /* Compute B=sqrt(B^2) */
      if (!Done)
        AGMSqrt(AGM_B, AGM_B2, Len,  (Pass>5) ? (2<<(Pass-5)) : 0);
      if (Key=='3') CorruptVar(AGM_B,Len);

      if (!Cfg.Macintosh) fprintf(stderr,"AGM Part4");
      /* Sum = Sum - C2 * 2^(J+1) */
      MulByFloat(AGM_C2,Pow2,Len);Pow2 *= 2.0;
      if (Sub(AGM_Sum,AGM_Sum,AGM_C2,Len))
        FatalError("AGM_Sum should never be negative.\n");

      EndTime=clock();
/*
      DumpBigInt("AGM_A  ",AGM_A,Len);
      DumpBigInt("AGM_A2 ",AGM_A2,Len);
      DumpBigInt("AGM_B  ",AGM_B,Len);
      DumpBigInt("AGM_B2 ",AGM_B2,Len);
      DumpBigInt("AGM_C2 ",AGM_C2,Len);
      DumpBigInt("AGM_Sum",AGM_Sum,Len);
*/

      if (!Cfg.Macintosh) BackSpace(9);
      if (!Done && ((Cfg.AGMSelfCheck == 3) || (Cfg.AGMSelfCheck == 4)))
        {
      /* We can use AGM_C2 and DSWork as scratch. */
         if (!Cfg.Macintosh) fprintf(stderr,"Self Check");
         SpecialSquare(AGM_C2,AGM_B,Len,DSWork);
         DoCheck(AGM_C2,AGM_B2,5,Len);
         if (!Cfg.Macintosh) BackSpace(10);
        }

      DumpDebug("Pass %u took:", Pass);
      fprintf(stderr,"Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
      DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);

      if (Cfg.AlwaysSaveData)
        SaveData(AGM_A,AGM_A2,AGM_B,AGM_B2,AGM_Sum,OldRoot,
                 ((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);
      if (TestKeyboard()) break;
    }


/* We've done the AGM part, now do the final calculation. */
  LoopTime=clock();
  if (Done)
    {
     fprintf(stderr, "Final    : ");
/*
** Since AGM_A and AGM_B have converged, I can compute the AGM_A2
** by calculating AGM_B2.  That can be done like up above, except
** we don't need the 4*AGM_C2 because that will be zero.
*/
     if (!Cfg.Macintosh) fprintf(stderr,"Part 1");
     Add(AGM_B2,AGM_B2,AGM_A2,Len);
     MulBy(AGM_B2,AGM_B2,2,Len);
     if (!Cfg.Macintosh) BackSpace(6);

     if (Cfg.PiFormulaToUse==3)
       {
        if (!Cfg.Macintosh) fprintf(stderr,"Part 2");
        if (!Cfg.Macintosh) BackSpace(6);
        Sqrt30(AGM_A2,Len);
        if (!Cfg.Macintosh) fprintf(stderr,"Part 3");
        SpecialFullMul(AGM_A,AGM_Sum,AGM_A2,Len,AGM_B);
        SubInt(AGM_A, BI_OneHalf);
        Copy(AGM_Sum,AGM_A,Len);
        if (!Cfg.Macintosh) BackSpace(6);
       }

     AGMDivide(AGM_B, AGM_B2, AGM_Sum, Len, AGM_A2);

     EndTime=clock();
     fprintf(stderr, "Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);

     if (Cfg.PiFormulaToUse==2)
        PrintFormattedPi("Fast 1/sqrt(2) AGM",((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC, AGM_B, Len);
     else
        PrintFormattedPi("Fast sqrt(3) AGM",((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC, AGM_B, Len);

     DeleteSaveFile();
    }
  else if (Pass >= FatalPasses)
       FatalError("The AGM didn't converge.\n");
  else SaveData(AGM_A,AGM_A2,AGM_B,AGM_B2,AGM_Sum,OldRoot,
                ((double)clock()-(double)StartTime)
	     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);

  fprintf(stderr,"\nTotal Execution time: %0.2f\n\n",((double)clock()-(double)StartTime)
	     /CLOCKS_PER_SEC);
  if (!Done) DumpTimings(((double)clock()-(double)StartTime)
	     /CLOCKS_PER_SEC);

  return (Done);
}
Esempio n. 10
0
int NFCCreateRoleModule::SaveDataOnTime(const NFGUID & self, const std::string & name, const float fIntervalTime, const int nCount)
{
	SaveData(self);
	return 0;
}
Esempio n. 11
0
CAppIni::~CAppIni()
{
	SaveData();
}
Esempio n. 12
0
		/// <summary>
		/// Request to save user progress
		/// </summary>
		/// <returns>
		/// arSuccess - application saved user's progress
		/// arFailure - application couldn't save user's progress
		/// arNotImplemented
		/// </returns>
		ApplicationResult RequestApplicationSave()
		{
			printf("GFN requested an application save.\n");
			SaveData();
			return arSuccess;
		}
Esempio n. 13
0
CKademlia::~CKademlia()
{
	SaveData();
}
Esempio n. 14
0
CKademlia::CKademlia(uint16 Port, bool bIPv6, const CVariant& Config, const string& Version)
{
	m_Protocol = KAD_PROT_VER;

	if(!Version.empty())
		m_Version += Version;
	else
		m_Version = "v " STR(KAD_PROT_MJR) "." STR(KAD_PROT_MIN);

	m_pConfig = new CKadConfig(this);
	if(Config.IsValid())
		m_pConfig->Merge(Config);

	LoadData();

	if(m_pKadKey->GetAlgorithm() == CAbstractKey::eUndefined)
	{
		m_pKadKey->SetAlgorithm(CAbstractKey::eECP);
		//m_pKadKey->GenerateKey("secp256r1"); // NIST: P-256
		m_pKadKey->GenerateKey("brainpoolP256r1"); // dont trust NIST (NSA) curves, use brainpool
		LogLine(LOG_INFO, L"Generated new Private NodeKey");
		SaveData();
	}

	m_pSocket = new CSmartSocket(SEC2MS(Cfg()->GetInt("ConnectionTimeout")), this);

	CScoped<CPublicKey> pKey = m_pKadKey->PublicKey();

	CUInt128 ID;
	CKadID::MakeID(pKey, ID.GetData(), ID.GetSize());
	LogLine(LOG_INFO, L"Neo Kad ID: %s", ID.ToHex().c_str());

	uint64 RecvKey;
	CAbstractKey::Fold(ID.GetData(), ID.GetSize(),(byte*)&RecvKey, sizeof(RecvKey));
	m_pSocket->SetupCrypto(RecvKey, m_pKadKey);

#ifdef _DEBUG
	LogLine(LOG_INFO, L"Socket PassKey is %I64u", RecvKey);
#endif

	m_Port = 0;
	m_IPv4 = CAddress(CAddress::IPv4);
	m_IPv6 = CAddress(CAddress::IPv6);

	for(int i=Port; i < Port + 1000; i++)
	{
		CUTPSocketListner* pSocketListner = new CUTPSocketListner(m_pSocket);
		CUTPSocketListner* pSocketListnerV6 = bIPv6 ? new CUTPSocketListner(m_pSocket) : NULL;
		bool bV4 = pSocketListner->Bind(i, CAddress(CAddress::IPv4));
		bool bV6 = !pSocketListnerV6 || pSocketListnerV6->Bind(i, CAddress(CAddress::IPv6));
		if(bV4 && bV6)
		{
			m_pSocket->InstallListener(pSocketListner);
			if(pSocketListnerV6)
				m_pSocket->InstallListener(pSocketListnerV6);
			m_Port = i;
			break;
		}
		delete pSocketListner;
		delete pSocketListnerV6;
	}
}
Esempio n. 15
0
bool EMVideoClipMixer::SaveSetting(EMProjectDataSaver* p_opSaver)
{
	return SaveData(p_opSaver);
}
Esempio n. 16
0
/*
*****************************************************
**      The AGM itself                             **
**                                                 **
** A[n] = (A[n-1] + B[n-1])/2                      **
** B[n] = Sqrt(A[n-1]*B[n-1])                      **
** C[n] = (A[n-1]-B[n-1])/2                        **
**                                                 **
**                          n                      **
** PI[n] = 4A[n+1]^2 / (1-(Sum (2^(j+1))*C[j]^2))  **
**                        j = 1                    **
*****************************************************
*/
static int
ComputeSlowAGM(size_t Len, size_t MaxPasses)
{
  int Sign;
  size_t Pass;
  double Pow2;
  clock_t LoopTime,StartTime,EndTime;
  BigInt AGM_A, AGM_B, AGM_C, AGMWork;
  int Done; /* boolean */

  if ((Cfg.PiFormulaToUse != 2) && (Cfg.PiFormulaToUse != 3))
    FatalError("SlowAGM was somehow called with pi formula %d\n",
               Cfg.PiFormulaToUse);

  AGM_A = CreateBigInt(Len);
  AGM_B = CreateBigInt(Len);
  AGM_C = CreateBigInt(Len);
  AGMWork = CreateBigInt(Len);

  Num1IsCached = Num2IsCached = 0;
  StartTime = clock();
  Pow2 = 4.0;
  Pass = 0;

  if (!LoadData(AGM_A,AGM_B,AGM_C,OldRoot,NO_NUM,NO_NUM,
                &StartTime,&Pow2,&Pass,Len,Cfg.PiFormulaToUse))
    {
     LoopTime = clock();
     fprintf(stderr, "Init     : ");

     if (Cfg.PiFormulaToUse==2)
       {
        SetNum(AGM_A,Len,BI_One,0);
        SetNum(AGM_C,Len,BI_One,0);
        ClearBigInt(OldRoot,Len);
        Sqrt05(AGM_B,Len);
       }
     else
       {
        Sqrt20(AGM_A,Len);
        Sqrt60(AGM_C,Len);
        if (!Cfg.Macintosh) fprintf(stderr,"Square");
        Add(AGM_B,AGM_A,AGM_C,Len);
        DivBy(AGM_B,AGM_B,4,Len);
        if (!Cfg.Macintosh) BackSpace(6);
        if (!Cfg.Macintosh) fprintf(stderr,"Setting vars");
        ClearBigInt(OldRoot,Len);
        SetNum(AGM_A,Len,BI_One,0);
        SetNum(AGM_C,Len,BI_One,0);
        if (!Cfg.Macintosh) BackSpace(12);
        Pass=1;
       }

     EndTime = clock();
     fprintf(stderr,"Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     if (Cfg.AlwaysSaveData)
        SaveData(AGM_A,AGM_B,AGM_C,OldRoot,NO_NUM,NO_NUM,
                 ((double)EndTime-(double)StartTime)
     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);
    }

/*
  DumpBigInt("AGM_A",AGM_A,Len);
  DumpBigInt("AGM_B",AGM_B,Len);
  DumpBigInt("AGM_C",AGM_C,Len);
*/

  Done=0;
  MaxPasses+=Pass;
  while ((!Done) && (Pass < MaxPasses))
    {
      fprintf(stderr, "Pass %4s: ", Num2Str(1<<(++Pass)));
      LoopTime = clock();

      if (!Cfg.Macintosh) fprintf(stderr,"AGM Part1");
      /* w = (a-b)/2 */
      Sign = Sub(AGMWork, AGM_A, AGM_B, Len);
      if (Sign) Negate(AGMWork,Len);
      DivBy(AGMWork,AGMWork, 2, Len);

      {size_t Nz;
       Nz=FindFirstNonZero(AGMWork,Len);
       if ((Pass > 4) && (Nz != Len))
         if ((1<<(Pass-4)) > Nz)
           fprintf(stderr,"AGMCheck1 fails.  Predicted: %lu Actual: %lu\a\n",
                   (unsigned long)1<<(Pass-4),(ULINT)Nz);
      }
      if (!Cfg.Macintosh) BackSpace(9);

      /* m = w*w */
      if (!Cfg.Macintosh) fprintf(stderr,"Sqr1");
      if (IsZero(AGMWork,Len/2)) Done=1;
      if (Done) ClearBigInt(AGMWork,Len);
      else FullMul(AGMWork, AGMWork, AGMWork, Len);
      if (!Cfg.Macintosh) BackSpace(4);

      if (!Cfg.Macintosh) fprintf(stderr,"AGM Part2");
      {size_t Nz;
      Nz=FindFirstNonZero(AGMWork,Len);
      if ((Pass > 3) && (Nz != Len))
        if ((1<<(Pass-3)) > Nz)
          fprintf(stderr,"AGMCheck2 fails.  Predicted: %lu Actual: %lu\a\n",
                  (unsigned long)1<<(Pass-3),(ULINT)Nz);
      }

      /* m = m* w^(J+1) */
      MulByFloat(AGMWork,Pow2,Len);
      Pow2 *= 2.0;

      /* c = c - m */
      if (Sign) Add(AGM_C, AGM_C, AGMWork, Len);
      else      Sub(AGM_C, AGM_C, AGMWork, Len);

      /* See if it's done */
      if (IsZero(AGMWork,Len-(Len/16))) Done=1;
      if (!Cfg.Macintosh) BackSpace(9);

      /* m = a*b */
      if (!Cfg.Macintosh) fprintf(stderr,"Sqr2");
      if (Pass==1) Copy(AGMWork,AGM_B,Len); /* first pass, AGM_A = 1.0 */
      else if (!Done)   /* If last iter, we can skip it. */
         FullMul(AGMWork, AGM_A, AGM_B, Len);
      if (!Cfg.Macintosh) BackSpace(4);

      /* a = (a+b)/2 */
      Add(AGM_A, AGM_A, AGM_B, Len);
      DivBy(AGM_A,AGM_A, 2, Len);

      /* b = sqrt(a*b) */
      if (!Done) /* Optimization */
          AGMSqrt(AGM_B, AGMWork, Len, (Pass>5) ? (2<<(Pass-5)) : 0 );

      EndTime=clock();

/*
      DumpBigInt("AGM_A",AGM_A,Len);
      DumpBigInt("AGM_B",AGM_B,Len);
      DumpBigInt("AGM_C",AGM_C,Len);
*/
      DumpDebug("Pass %u took:", Pass);
      fprintf(stderr, "Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
     /CLOCKS_PER_SEC);
      DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);

      if (TestKeyboard()) break;
     if (Cfg.AlwaysSaveData)
        SaveData(AGM_A,AGM_B,AGM_C,OldRoot,NO_NUM,NO_NUM,
                 ((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);
    }

  LoopTime=clock();
  if (Done)
    {
     fprintf(stderr,"Final    : ");
     if (!Cfg.Macintosh) fprintf(stderr,"Sqr");
     SpecialSquare(AGM_A, AGM_A, Len, AGMWork);
     MulBy(AGM_A,AGM_A,4,Len);
     if (!Cfg.Macintosh) BackSpace(3);

     if (Cfg.PiFormulaToUse==3)
       {
        Sqrt30(AGM_B,Len);
        if (!Cfg.Macintosh) fprintf(stderr,"Part 2");
        FullMul(AGM_C,AGM_C,AGM_B,Len);
        SubInt(AGM_C, BI_OneHalf);
        if (!Cfg.Macintosh) BackSpace(6);
       }

     AGMDivide(AGM_B, AGM_A, AGM_C, Len, AGMWork);
     EndTime=clock();
     fprintf(stderr, "Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     if (Cfg.PiFormulaToUse==2)
        PrintFormattedPi("Slow 1/sqrt(2) AGM",((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC, AGM_B, Len);
     else
        PrintFormattedPi("Slow sqrt(3) AGM",((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC, AGM_B, Len);
     DeleteSaveFile();
    }
  else if (Pass >= FatalPasses)
       FatalError("The AGM didn't converge.\n");
  else SaveData(AGM_A,AGM_B,AGM_C,OldRoot,NO_NUM,NO_NUM,
                ((double)clock()-(double)StartTime)
	     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);

  fprintf(stderr,"\nTotal Execution time: %0.2f seconds.\n\n",((double)clock()-(double)LoopTime)
	     /CLOCKS_PER_SEC);
  if (!Done) DumpTimings(((double)clock()-(double)LoopTime)
	     /CLOCKS_PER_SEC);

  return (Done);
}
Esempio n. 17
0
BOOL TranContorlData::Save(CStdioFile &file)
{
	return SaveData(file);
}
Esempio n. 18
0
static int
ComputeClassicAGM(size_t Len, size_t MaxPasses)
{
  int Sign;
  size_t Pass;
  double Pow2;
  clock_t LoopTime,EndTime,StartTime;
  BigInt AGM_A, AGM_B, AGM_C, AGMWork;
  int Done; /* boolean */

  AGM_A = CreateBigInt(Len);
  AGM_B = CreateBigInt(Len);
  AGM_C = CreateBigInt(Len);
  AGMWork = OldRoot;

  StartTime = clock();
  Pow2 = 4.0;
  Pass = 0;

  if (!LoadData(AGM_A,AGM_B,AGM_C,NO_NUM,NO_NUM,NO_NUM,
                &StartTime,&Pow2,&Pass,Len,Cfg.PiFormulaToUse))
    {
     fprintf(stderr, "Init     : ");
     LoopTime = clock();
     SetNum(AGM_A,Len,BI_One,0);
     SetNum(AGM_C,Len,BI_OneHalf,0);
     ClassicSqrt(AGM_B,AGM_C,Len);
     SetNum(AGM_C,Len,BI_One,0);
     EndTime = clock();
     fprintf(stderr,"Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     if (Cfg.AlwaysSaveData)
        SaveData(AGM_A,AGM_B,AGM_C,NO_NUM,NO_NUM,NO_NUM,
                 ((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);
    }

/*
  DumpBigInt("AGM_A",AGM_A,Len);
  DumpBigInt("AGM_B",AGM_B,Len);
  DumpBigInt("AGM_C",AGM_C,Len);
*/

  Done=0;
  MaxPasses+=Pass;
  while ((!Done) && (Pass < MaxPasses))
    {
      fprintf(stderr, "Pass %4s: ", Num2Str(1<<(++Pass)));
      LoopTime = clock();

      if (!Cfg.Macintosh) fprintf(stderr,"AGM Part1");
      /* w = (a-b)/2 */
      Sign = Sub(AGMWork, AGM_A, AGM_B, Len);
      if (Sign) Negate(AGMWork,Len);
      DivBy(AGMWork,AGMWork, 2, Len);
      if (!Cfg.Macintosh) BackSpace(9);

      /* m = w*w */
      if (!Cfg.Macintosh) fprintf(stderr,"Sqr1");
      if (IsZero(AGMWork,Len/2)) Done=1;
      if (Done) ClearBigInt(AGMWork,Len);
      else FullMul(AGMWork, AGMWork, AGMWork, Len);
      if (!Cfg.Macintosh) BackSpace(4);

      if (!Cfg.Macintosh) fprintf(stderr,"AGM Part2");

      /* m = m* w^(J+1) */
      MulByFloat(AGMWork,Pow2,Len);
      Pow2 *= 2.0;

      /* c = c - m */
      if (Sign) Add(AGM_C, AGM_C, AGMWork, Len);
      else      Sub(AGM_C, AGM_C, AGMWork, Len);

      /* See if it's done */
      if (IsZero(AGMWork,Len-(Len/16))) Done=1;
      if (!Cfg.Macintosh) BackSpace(9);

      /* m = a*b */
      if (!Cfg.Macintosh) fprintf(stderr,"Sqr2");
      if (Pass==1) Copy(AGMWork,AGM_B,Len); /* first pass, AGM_A = 1.0 */
      else if (!Done)   /* If last iter, we can skip it. */
         FullMul(AGMWork, AGM_A, AGM_B, Len);

      /* a = (a+b)/2 */
      Add(AGM_A, AGM_A, AGM_B, Len);
      DivBy(AGM_A,AGM_A, 2, Len);
      if (!Cfg.Macintosh) BackSpace(4);

      /* b = sqrt(a*b) */
      if (!Done) /* Optimization */
          ClassicSqrt(AGM_B, AGMWork, Len);

      EndTime=clock();

/*
      DumpBigInt("AGM_A",AGM_A,Len);
      DumpBigInt("AGM_B",AGM_B,Len);
      DumpBigInt("AGM_C",AGM_C,Len);
*/
      DumpDebug("Pass %u took:", Pass);
      fprintf(stderr, "Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
      DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);

      if (TestKeyboard()) break;
     if (Cfg.AlwaysSaveData)
        SaveData(AGM_A,AGM_B,AGM_C,NO_NUM,NO_NUM,NO_NUM,
                 ((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);
    }

  LoopTime=clock();
  if (Done)
    {
     fprintf(stderr,"Final    : ");
     if (!Cfg.Macintosh) fprintf(stderr,"Sqr");
     FullMul(AGM_A, AGM_A, AGM_A, Len);
     MulBy(AGM_A,AGM_A,4,Len);
     if (!Cfg.Macintosh) BackSpace(3);

     ClassicDivide(AGM_B, AGM_A, AGM_C,Len);
     EndTime=clock();
     fprintf(stderr, "Time= %0.2f\n", ((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     DumpTimings(((double)EndTime-(double)LoopTime)
	     /CLOCKS_PER_SEC);
     PrintFormattedPi("Classic AGM",((double)EndTime-(double)StartTime)
	     /CLOCKS_PER_SEC, AGM_B, Len);
     DeleteSaveFile();
    }
  else if (Pass >= FatalPasses)
       FatalError("The AGM didn't converge.\n");
  else SaveData(AGM_A,AGM_B,AGM_C,NO_NUM,NO_NUM,NO_NUM,
                ((double)clock()-(double)StartTime)
	     /CLOCKS_PER_SEC,Pow2,Pass,Len,Cfg.PiFormulaToUse);

  fprintf(stderr,"\nTotal Execution time: %0.2f seconds.\n\n",((double)clock()-(double)StartTime)
	     /CLOCKS_PER_SEC);
  if (!Done) DumpTimings(((double)clock()-(double)StartTime)
	     /CLOCKS_PER_SEC);

  return (Done);
}
Esempio n. 19
0
void CQueryWizardDialog::OnBack() {
	returnValue = QW_BACK;
	SaveData( builder );
	CDialog::OnOK();
}
 void wxsChoicebookParentQP::OnLabelText(cb_unused wxCommandEvent& event)       { SaveData(); }
Esempio n. 21
0
void CQueryWizardDialog::OnFinish() {
	//returnValue = QW_FINISH;
	SaveData( builder );
	((CQueryWizard*)::AfxGetApp())->ExecuteQuery( *builder );
	//CDialog::OnOK();
}
 void wxsChoicebookParentQP::OnLabelKillFocus(cb_unused wxFocusEvent& event)    { SaveData(); event.Skip(); }
Esempio n. 23
0
LRESULT CLearnWorldServerDlg::DatabaseManage(WPARAM wParam, LPARAM lParam)
{
	CString Command;
	if (WSAGETSELECTERROR(lParam))
	{
		// Display the error and close the socket
		closesocket(wParam);
	}
	switch (WSAGETSELECTEVENT(lParam))
	{
	case FD_ACCEPT:
	{
		ClientSocket[NumberOfClient] = accept(wParam, NULL, NULL);
		NumberOfClient++;
		break;
	}
	case FD_READ:
	{
		int post = -1, dpos = -1;

		for (int i = 0; i<NumberOfClient; i++)
		{
			if (ClientSocket[i] == wParam)
			{
				if (i<NumberOfClient)
					post = i;
			}
		}
		CString strResult[2];
		CString temp;
		if (RecvString(wParam, temp) < 0)
			break;
		SplitFlag(temp, strResult);
		int flag = _ttoi(strResult[0]);
		
		switch (flag)
		{
			case -1 : // Logout
				OnSignOut(wParam, strResult[1]);
				break;
			case 0://Login
				OnSignIn(wParam ,strResult[1]);
				break;
			case 1://Register
				OnRegister(wParam, strResult[1]);
				SaveData();
				break;
			case 2://Forgot password
				OnForgotPass(wParam, strResult[1]);
				SaveData();
				break;
			case 3:// Edit Information
				OnEditInfo(wParam, strResult[1]);
				SaveData();
				break;
			case 4: // Add Teacher
				OnAddTeacher(wParam,strResult[1]);
				SaveData();
				break;
			case 13: // Search Teacher
				OnSearchTeacher(wParam, strResult[1]);
				break;
			case 14: // Search User
				OnSearchUser(wParam, strResult[1]);
				break;
			case 15: // Get user list to create table
				OnCreateTable(wParam, strResult[1]);
				break;
			case 16: // Search Username for Delete / Deactivated / Activate
				OnSearchAccount(wParam, strResult[1]);
				break;
			case 17: // Delete Account
				OnDeleteAccount(wParam, strResult[1]);
				SaveData();
				break;
			case 18: // Deactivate Account
				OnDeactivateAccount(wParam, strResult[1]);
				SaveData();
				break;
			case 19: // Activate Account
				OnActivateAccount(wParam, strResult[1]);
				SaveData();
				break;
			case 20: //Rate teacher
				OnEvaluateTeacher(wParam, strResult[1]);
				break;
		}
		break;
	}

	case FD_CLOSE:
	{
		//MessageBox(L"Client closed connection", NULL, MB_OK);
		UpdateData();
		int post = -1;
		for (int i = 0; i<NumberOfClient; i++)
		{
			if (ClientSocket[i] == wParam)
			{
				if (i<NumberOfClient)
					post = i;
			}
		}
		closesocket(wParam);
		for (int j = post; j < NumberOfClient; j++)
		{
			ClientSocket[post] = ClientSocket[post + 1];
		}
		
		NumberOfClient--;
		UpdateData(FALSE);
		if (NumberOfClient == 0);
		break;
	}

	}
	return 0;
}
 void wxsChoicebookParentQP::OnSelectionChange(cb_unused wxCommandEvent& event) { SaveData(); }
void wxsSizerParentQP::OnProportionChange(cb_unused wxSpinEvent& event)
{
    SaveData();
}
Esempio n. 26
0
void taskMgr::Tick()
{
    savetm++;
    bool havesaml = false;
    for(auto item : m_misslist)
    {
        if(item.second->missiontm > 0 && item.second->missState != 999999)
        {
            if(item.second->missType == 0)//主线
            {
                if(item.second->missState < item.second->missNeed) //进行中
                {
                    item.second->missiontm -= 1;
                    string sec = GetMissTm(item.second->missiontm);
                    m_maintmlab->setString(sec);
                }
            }
            else
            {
                //支线
                if(item.second->missState < item.second->missNeed) //进行中
                {
                    havesaml = true;
                    item.second->missiontm -= 1;
                    string strDes = StringUtils::format("%d/%d\n",item.second->missState,item.second->missNeed);
                    string sec = strDes + GetMissTm(item.second->missiontm);
                    m_samllab->setString(sec);
                }
                else
                {
                    havesaml = (item.second->missState == 888888||item.second->missState == item.second->missNeed);
                }
            }   
        }
        else if(item.second->missState != 999999)
        {
            tasktimeout(item.second);
        }
    }
    if(!havesaml)
    {
        long now = GameScene::GetTimeNow();
        long tm;
        if(m_firstsml == 0)
        {
            tm = Player::getInstance()->getLoginTime();
            if(now - tm > 5)
            {
                popsaml();
            }
        }
        else
        {
            if(now - m_firstsml > 3)
            {
                popsaml();
            }
        }
    }
    
    if(savetm%5 == 0)
    {
        SaveData();
    }
}
Esempio n. 27
0
 void wxsListbookParentQP::OnLabelText(wxCommandEvent& event)       { SaveData(); }
Esempio n. 28
0
SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
{
	SHADERUID uid;
	GetShaderId(&uid, dstAlphaMode, components);

	// Check if the shader is already set
	if (last_entry)
	{
		if (uid == last_uid)
		{
			GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
			last_entry->shader.Bind();
			return &last_entry->shader;
		}
	}

	last_uid = uid;

	// Check if shader is already in cache
	PCache::iterator iter = pshaders.find(uid);
	if (iter != pshaders.end())
	{
		PCacheEntry *entry = &iter->second;
		last_entry = entry;

		GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
		last_entry->shader.Bind();
		return &last_entry->shader;
	}

	// Make an entry in the table
	PCacheEntry& newentry = pshaders[uid];
	last_entry = &newentry;
	newentry.in_cache = 0;

	VertexShaderCode vcode;
	PixelShaderCode pcode;
	GenerateVertexShaderCode(vcode, components, API_OPENGL);
	GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL, components);

	if (g_ActiveConfig.bEnableShaderDebugging)
	{
		newentry.shader.strvprog = vcode.GetBuffer();
		newentry.shader.strpprog = pcode.GetBuffer();
	}

#if defined(_DEBUG) || defined(DEBUGFAST)
	if (g_ActiveConfig.iLog & CONF_SAVESHADERS)
	{
		static int counter = 0;
		std::string filename =  StringFromFormat("%svs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
		SaveData(filename, vcode.GetBuffer());

		filename = StringFromFormat("%sps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
		SaveData(filename, pcode.GetBuffer());
	}
#endif

	if (!CompileShader(newentry.shader, vcode.GetBuffer(), pcode.GetBuffer()))
	{
		GFX_DEBUGGER_PAUSE_AT(NEXT_ERROR, true);
		return nullptr;
	}

	INCSTAT(stats.numPixelShadersCreated);
	SETSTAT(stats.numPixelShadersAlive, pshaders.size());
	GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);

	last_entry->shader.Bind();
	return &last_entry->shader;
}
Esempio n. 29
0
 void wxsListbookParentQP::OnSelectionChange(wxCommandEvent& event) { SaveData(); }
void CPage_Node_Movement::OnOK( )
{
	SaveData();
	CPropertyPage::OnOK();
}