Esempio n. 1
0
void module_error(int err)
{
	switch (err)
	{
		case MODULE_BASE_NOT_FOUND:
			Flash("Failed to obtain debuggee's ImageBase");
			Addtolist(0, 1, "Failed to obtain debuggee's ImageBase");
			break;

		case MODULE_OUT_OF_RANGE:
			Flash("You are not viewing any module");
			break;

		case MODULE_FILE_MAPPING_FAILURE:
			Flash("Failed to create file mapping");
			Addtolist(0, 1, "Failed to create file mapping");
			break;

		case MODULE_FILE_SHARING_VIOLATION:
			Flash("Failed to obtain file handle");
			Addtolist(0, 1, "Failed to obtain file handle");
			break;

		default:
			break;
	}
}
Esempio n. 2
0
// ----------------------------------------------------------------------- //
// Associate this item with a particular weapon record
// ----------------------------------------------------------------------- //
void CHUDWeapon::SetWeaponRecord(HWEAPON hWeapon)
{
	//flash if we pickup a weapon
	if (hWeapon && !m_hWeapon)
	{
		Flash("Pickup");
	}

	m_hWeapon = hWeapon;
	m_bDraw = true;
	if (m_hWeapon)
	{
		HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(m_hWeapon, !USE_AI_DATA);
		m_hIconTexture.Load( g_pWeaponDB->GetString( hWpnData, WDB_WEAPON_sIcon ) );
	}
	else
	{
		m_hIconTexture.Load( g_pLayoutDB->GetString(m_hLayout,"IconTexture") );
		Select(false);
	}

	SetupQuadUVs(m_IconPoly, m_hIconTexture, 0.0f, 0.0f, 1.0f, 1.0f);
	m_nCount = -1;
	Update();
}
task main()
{
  int nState = 4;

  while (true)
  {
    for (int i = 0; i < 6; ++i)
    {
      switch (nState)
      {
      default:
        nState = 0;
        // Fall through to next case

      case 0:   cylonEye();           break;
      case 1:   drawRight();          break;
      case 2:   drawLeft();           break;
      case 3:   Flash();              break;
      case 4:   drawCrossed();        break;
      }
    }
    ++nState;
    wait1Msec(500);
  }
}
Esempio n. 4
0
// This function receives possible keyboard shortcuts from standard OllyDbg
// windows. If it recognizes shortcut, it must process it and return 1,
// otherwise it returns 0.
extc int _export cdecl ODBG_Pluginshortcut(
    int origin, int ctrl, int alt, int shift, int key, void *item)
{
	t_dump *pd;
	t_bookmark mark, *pm;
	// Plugin accepts shortcuts in form Alt+x or Shift+Alt+x, where x is a key
	// '0'..'9'. Shifted shortcut sets bookmark (only in Disassembler),
	// non-shifted jumps to bookmark from everywhere.
	if (ctrl == 0 && alt != 0 && key >= '0' && key <= '9')
	{
		if (shift != 0 && origin == PM_DISASM && item != NULL)
		{
			// Set new or replace existing bookmark.
			pd = (t_dump *)item;
			mark.index = key - '0';
			mark.size = 1;
			mark.type = 0;
			mark.addr = pd->sel0;
			Addsorteddata(&(bookmark.data), &mark);
			if (bookmark.hw != NULL) InvalidateRect(bookmark.hw, NULL, FALSE);
			return 1;
		}                      // Shortcut recognized
		else if (shift == 0)
		{
			// Jump to existing bookmark (from any window).
			pm = Findsorteddata(&(bookmark.data), key - '0');
			if (pm == NULL)
				Flash("Undefined bookmark");
			else
				Setcpu(0, pm->addr, 0, 0, CPU_ASMHIST | CPU_ASMCENTER | CPU_ASMFOCUS);
			return 1;                        // Shortcut recognized
		};
	};
	return 0;                            // Shortcut not recognized
};
Esempio n. 5
0
void MeaPointTool::Enable()
{
    if (IsEnabled()) {
        return;
    }

    MeaTool::Enable();

    // Tell the tool manager which data display fields
    // we will be using.
    //
    m_mgr->EnableRegionFields(MeaX1Field | MeaY1Field, MeaX1Field | MeaY1Field);

    if (!IsWindow(m_crossHair)) {
        Create();
    }

    // Show one liner on how to use the tool.
    //
    m_mgr->SetStatus(IDS_MEA_POINT_STATUS);

    // Make the crosshair visible, flash it and update
    // the data display.
    //
    EnableCrosshairs();
    Flash();
    Update(NormalUpdate);
}
Esempio n. 6
0
void _export cdecl ODBG_Pluginaction(int origin, int action, void *item)
{
	list_t* names;
	TCHAR path[TEXTLEN];
	t_status status;
	if (origin == PM_MAIN)
	{
		switch (action)
		{
			case ACTION_IMPORT:
				status = Getstatus();
				if (status && status != STAT_FINISHED && status != STAT_CLOSING)
				{
					if (mapfile_browse(path))
					{
						names = mapfile_parse(path);
						if (names)
						{
							mapfile_apply(names);
							list_freenames(names);
							Setcpu(0, 0, 0, 0, CPU_ASMFOCUS);
						}
						else
						{
							Flash("Failed to open the file");
						}
					}
				}
				else
				{
					Flash("Start the debugging session first");
				}
				break;

			case ACTION_OPTIONS:
				configwnd_create();
				break;

			case ACTION_ABOUT:
				MessageBox(g_hwndOlly, c_About, "About mapimp", MB_ICONINFORMATION);
				break;

			default:
				break;
		}
	}
}
Esempio n. 7
0
void SendCmd(int fd, unsigned char* cmd, int len)
{
  Flash(fd);

  int rb = write(fd, cmd, len);
  tcdrain(fd); 
  printf("\r\nWrite bytes %d, change to 115200.\r\n", rb);
}
void Sprite_Character::Update() {
	Sprite::Update();
	Rect r;
	if (tile_id != character->GetTileId() ||
		character_name != character->GetCharacterName() ||
		character_index != character->GetCharacterIndex()) {
		tile_id = character->GetTileId();
		character_name = character->GetCharacterName();
		character_index = character->GetCharacterIndex();
		if (tile_id > 0) {
			BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
			SetBitmap(tile);
			r.Set(0, 0, 16, 16);
			SetSrcRect(r);
			SetOx(8);
			SetOy(16);
		} else {
			if (character_name.empty()) {
				SetBitmap(BitmapRef());
			} else {
				SetBitmap(Cache::Charset(character_name));
				chara_width = GetBitmap()->GetWidth() / 4 / 3;
				chara_height = GetBitmap()->GetHeight() / 2 / 4;
				SetOx(chara_width / 2);
				SetOy(chara_height);
				int sx = (character_index % 4) * chara_width * 3;
				int sy = (character_index / 4) * chara_height * 4;
				r.Set(sx, sy, chara_width * 3, chara_height * 4);
				SetSpriteRect(r);
			}
		}
	}

	if (tile_id == 0) {
		int row = character->GetDirection();
		r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height);
		SetSrcRect(r);
	}

	if (character->IsFlashPending()) {
		Color col;
		int dur;
		character->GetFlashParameters(col, dur);
		Flash(col, dur);
	}

	SetVisible(character->GetVisible());
	if (GetVisible()) {
		SetOpacity(character->GetOpacity());
	}

	SetX(character->GetScreenX());
	SetY(character->GetScreenY());
	SetZ(character->GetScreenZ(chara_height));
	
	//SetBlendType(character->GetBlendType());
	//SetBushDepth(character->GetBushDepth());
}
Esempio n. 9
0
void Sprite_Character::Update() {
	Sprite::Update();
	Rect r;
	if (tile_id != character->GetTileId() ||
		character_name != character->GetSpriteName() ||
		character_index != character->GetSpriteIndex()) {
		tile_id = character->GetTileId();
		character_name = character->GetSpriteName();
		character_index = character->GetSpriteIndex();
		if (tile_id > 0) {
			if (tile_request) {
				tile_request->Unbind(tile_request_id);
			}
			tile_request = AsyncHandler::RequestFile("ChipSet", Game_Map::GetChipsetName());
			tile_request_id = tile_request->Bind(&Sprite_Character::OnTileSpriteReady, this);
			tile_request->Start();
		} else {
			if (character_name.empty()) {
				SetBitmap(BitmapRef());
			} else {
				if (char_request) {
					char_request->Unbind(char_request_id);
				}
				char_request = AsyncHandler::RequestFile("CharSet", character_name);
				char_request_id = char_request->Bind(&Sprite_Character::OnCharSpriteReady, this);
				char_request->Start();
			}
		}
	}

	if (tile_id == 0) {
		int row = character->GetSpriteDirection();
		r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height);
		SetSrcRect(r);
	}

	if (character->IsFlashPending()) {
		Color col = character->GetFlashColor();
		int dur = character->GetFlashTimeLeft();
		Flash(col, dur);
		// TODO: Gradual decrease of Flash Time Left
		character->SetFlashTimeLeft(0);
	}

	SetVisible(character->GetVisible());
	if (GetVisible()) {
		SetOpacity(character->GetOpacity());
	}

	SetX(character->GetScreenX());
	SetY(character->GetScreenY());
	SetZ(character->GetScreenZ());

	//SetBlendType(character->GetBlendType());
	int bush_split = 4 - character->GetBushDepth();
	SetBushDepth(bush_split > 3 ? 0 : GetHeight() / bush_split);
}
Esempio n. 10
0
void Sprite_Character::Update() {
	Sprite::Update();
	Rect r;
	if (tile_id != character->GetTileId() ||
		character_name != character->GetSpriteName() ||
		character_index != character->GetSpriteIndex()) {
		tile_id = character->GetTileId();
		character_name = character->GetSpriteName();
		character_index = character->GetSpriteIndex();
		if (tile_id > 0) {
			BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
			SetBitmap(tile);
			r.Set(0, 0, TILE_SIZE, TILE_SIZE);
			SetSrcRect(r);
			SetOx(8);
			SetOy(16);
		} else {
			if (character_name.empty()) {
				SetBitmap(BitmapRef());
			} else {
				SetBitmap(Cache::Charset(character_name));
				SetOx(chara_width / 2);
				SetOy(chara_height);
				int sx = (character_index % 4) * chara_width * 3;
				int sy = (character_index / 4) * chara_height * 4;
				r.Set(sx, sy, chara_width * 3, chara_height * 4);
				SetSpriteRect(r);
			}
		}
	}

	if (tile_id == 0) {
		int row = (character->IsSpinning() ? character->GetPrelockDirection() : character->GetDirection());
		r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height);
		SetSrcRect(r);
	}

	if (character->IsFlashPending()) {
		Color col = character->GetFlashColor();
		int dur = character->GetFlashTimeLeft();
		Flash(col, dur);
		// TODO: Gradual decrease of Flash Time Left
		character->SetFlashTimeLeft(0);
	}

	SetVisible(character->GetVisible());
	if (GetVisible()) {
		SetOpacity(character->GetOpacity());
	}

	SetX(character->GetScreenX());
	SetY(character->GetScreenY());
	SetZ(character->GetScreenZ(chara_height));
	
	//SetBlendType(character->GetBlendType());
	//SetBushDepth(character->GetBushDepth());
}
Esempio n. 11
0
int main()
{
    P0 = 0xfe;      // 1111 1110
    while(1)
    {
        Delayms(500);
        Flash();
    }

    return 0;
}
Esempio n. 12
0
Colour PowerUpManager::GetPlayerColour(int playerId)
{
  // First 0.5 of time, solid colour, then flash for 0.25, then flash
  //  quickly for 0.25.
  // TODO Matching sound
  static const float POWER_UP_TIME = ROConfig()->GetFloat("power-up-time");
  static const float FLASH_PERIOD = ROConfig()->GetFloat("power-up-flash-period", 0.2f);
  const float HALF = POWER_UP_TIME / 2;
  const float QUARTER = HALF / 2;
  int c = (int)powerUps[playerId]; // colour index - 0 means white/no extra colour
  float t = powerUpTime[playerId];
  if (t < QUARTER)
  {
    bool fastFlash = Flash(t, FLASH_PERIOD);
    c = fastFlash ? c : 0;
  }
  else if (t < HALF)
  {
    bool slowFlash = Flash(t, FLASH_PERIOD * 2);
    c = slowFlash ? c : 0;
  }
  return COLOURS[c];
}
Esempio n. 13
0
int _export cdecl ODBG_Pausedex(int reason, int extdata, t_reg *reg, DEBUG_EVENT *debugevent)
{
	list_t* names;
	WIN32_FIND_DATA fdata;
	TCHAR path[MAX_PATH];
	TCHAR* pos;
	HANDLE result;
	if ((reason & PP_INT3BREAK) && !g_SessionStarted && !g_Autoloaded)
	{
		g_SessionStarted = TRUE;
		strcpy(path, (TCHAR*)Plugingetvalue(VAL_EXEFILENAME));
		pos = strrchr(path, '.');
		if (pos)
		{
			strcpy(pos, ".map");
		}
		else
		{
			strcat(path, ".map");
		}
		result = FindFirstFile(path, &fdata);
		if (result != INVALID_HANDLE_VALUE)
		{
			FindClose(result);
			g_Autoloaded = TRUE;
			if ((g_Config->aimport == AUTOIMPORT_ASK) && (MessageBox(g_hwndOlly, "Corresponding map file found. Do you want to import it now?",
				"mapimp", MB_YESNO | MB_ICONQUESTION) == IDYES) || (g_Config->aimport == AUTOIMPORT_ALWAYS))
			{
				names = mapfile_parse(path);
				if (names)
				{
					mapfile_apply(names);
					list_freenames(names);
					Setcpu(0, 0, 0, 0, CPU_ASMFOCUS);
				}
				else
				{
					Flash("Failed to open the file");
				}
			}
		}
	}
	return 0;
}
Esempio n. 14
0
BYTE BumperReaction(BYTE BLeft, BYTE BRight)
// Реакция на препятствие
{         
  if(!BLeft && !BRight) return 0;
  
  RobotStop(); 

  Flash(L_RED, 200);
  Beep(1);  

  RobotGoBack(); 
  delay_ms(750); 
  
  if(BLeft && BRight) RobotTurnRandom();
  if(BLeft) RobotGoRight();
  if(BRight) RobotGoLeft();

  delay_ms(750); 
  RobotStop(); 
  return 1;
}
Esempio n. 15
0
void BattleAnimation::ProcessAnimationTiming(const RPG::AnimationTiming& timing) {
	// Play the SE.
	Game_System::SePlay(timing.se);

	// Flash.
	if (timing.flash_scope == RPG::AnimationTiming::FlashScope_target) {
		Flash(Color(timing.flash_red,
			timing.flash_green,
			timing.flash_blue,
			timing.flash_power));
	} else if (timing.flash_scope == RPG::AnimationTiming::FlashScope_screen && ShouldScreenFlash()) {
		Main_Data::game_screen->FlashOnce(
			timing.flash_red,
			timing.flash_green,
			timing.flash_blue,
			timing.flash_power,
			flash_duration);
	}

	// TODO: Shake.
}
Esempio n. 16
0
void CHUDArmor::Update()
{
	uint8 nValue = g_pPlayerStats->GetArmor();
	if (nValue > m_nLastValue)
	{
		Flash("Pickup");
	}
	m_nLastValue = nValue;

	wchar_t szTmp[16] = L"";
	swprintf(szTmp,L"%d",nValue);
	m_Text.SetText(szTmp);

	ResetFade();
	EnableFade( (m_nFadeThreshold == 0) || g_pPlayerStats->GetArmor() > m_nFadeThreshold );

	if (!m_bFadeEnabled)
	{
		m_Text.SetColor(m_cTextColor);
		DrawPrimSetRGBA(m_IconPoly,m_cIconColor);
	}
	UpdateBar();
}
Esempio n. 17
0
void wxGISMapView::StartFlashing(wxGISEnumFlashStyle eFlashStyle)
{
    m_eFlashStyle = eFlashStyle;

    Flash(eFlashStyle);

    Refresh();

    //wait drawings end to flash
    if (GetThread() && GetThread()->IsRunning())
    {
        GetThread()->Wait();
    }

    int nMilliSec = DEFAULT_FLASH_PERIOD;
    switch(eFlashStyle)
    {
    case enumGISMapFlashWaves:
        nMilliSec /= 2;
        {
        wxGISAppConfig oConfig = GetConfig();
        if(oConfig.IsOk())
            nMilliSec = oConfig.ReadInt(enumGISHKCU, wxString(wxT("wxGISCommon/map/flash_waves_time")), nMilliSec);
        }
        break;
    default:
    case enumGISMapFlashNewColor:
        {
        wxGISAppConfig oConfig = GetConfig();
        if(oConfig.IsOk())
            nMilliSec = oConfig.ReadInt(enumGISHKCU, wxString(wxT("wxGISCommon/map/flash_newcolor_time")), nMilliSec);
        }
        break;
    };
    m_nDrawingState = enumGISMapFlashing;
    m_timer.Start(nMilliSec);
}
Esempio n. 18
0
void CHUDControlPointBar::CHUDControlPoint::SetTeam(ETeamId eTeamID)
{
	ETeamId eLocalID = ( ETeamId )g_pInterfaceMgr->GetClientInfoMgr()->GetLocalTeam( );

	if (eTeamID == INVALID_TEAM)
	{
		m_hIconTexture = m_hTeamIcon[1];
		m_cIconColor = m_cTeamColor[1];
	}
	else
	{
		if (eTeamID == eLocalID)
		{
			m_hIconTexture = m_hTeamIcon[0];
			m_cIconColor = m_cTeamColor[0];
		}
		else
		{
			m_hIconTexture = m_hTeamIcon[2];
			m_cIconColor = m_cTeamColor[2];
		}
	}

	if (m_hIconTexture)
	{
		SetupQuadUVs(m_IconPoly, m_hIconTexture, 0.0f,0.0f,1.0f,1.0f);
	}

	m_Text.SetColor(m_cTextColor);
	DrawPrimSetRGBA(m_IconPoly,m_cIconColor);

	if (eTeamID != m_eTeamId)
	{
		m_eTeamId = eTeamID;
		Flash("CPStatus");
	}
}
Esempio n. 19
0
static int ProcessMenu(const char *mask1, const char *mask2)
{
    void *bg = GraphicsDF->get("mmnulogo");
    byte *pt1 = (byte*) GraphicsI18nDF->get(mask1);
    byte *pt2 = (byte*) GraphicsI18nDF->get(mask2);
    int oldsel, sel = 0;
    TEvent e;


    DrawMN(pt1, pt2, bg, sel);
    while (TRUE) {
        GetEvent(&e);
        if (e.What == evMouseMove) {
            oldsel = sel;
            sel = (e.Mouse.Where.y - 290) / 60;
            if (sel < 0) sel = 0;
            if (sel > 3) sel = 3;
            if (sel != oldsel) {
                PlaySample(MenuSnd, 8, 32, 128);
                DrawMN(pt1, pt2, bg, sel);
            }
        }
        if (e.What == evMouseDown) {
            FlashPos = 130 + 180 * sel;
            Flash1st = TRUE;
            Flash();
            break;
        }
        if ((e.What == evKeyDown) && (e.Key.KeyCode == kbEsc)) {sel = 3; break;}
    }
    
    memfree(pt1);
    memfree(pt2);
    memfree(bg);
    ClearScr();
    return sel;
}
Esempio n. 20
0
void MeaAngleTool::Enable()
{
    if (IsEnabled()) {
        return;
    }

    MeaTool::Enable();

    // Tell the tool manager which data display fields
    // we will be using.
    //
    m_mgr->EnableRegionFields(MeaX1Field | MeaY1Field |
                                MeaX2Field | MeaY2Field |
                                MeaXVField | MeaYVField |
                                MeaAngleField,
                                MeaX1Field | MeaY1Field |
                                MeaX2Field | MeaY2Field |
                                MeaXVField | MeaYVField);

    if (!IsWindow(m_line1)) {
        Create();
    }

    // Show one liner on how to use the tool.
    //
    m_mgr->SetStatus(IDS_MEA_ANGLE_STATUS);

    // Make the lines and crosshairs visible, flash
    // the crosshairs and update the data display.
    //
    m_line1.Show();
    m_line2.Show();
    m_lineB.Show();
    EnableCrosshairs();
    Flash();
    Update(NormalUpdate);
}
Esempio n. 21
0
//=============================================================================
// FunctionName: ChangeGuiState
// Param: void
// ReturnValue: void
// Content: Guiの状態によって変化させる
//=============================================================================
void CCharPicture::ChangeGuiState(GUI_MODE paramMode){

	// 遷移状態の更新
	m_Mode = paramMode;

	// 指定された状態によって分岐
	switch (paramMode)
	{

		// 通常状態の場合
	case GUI_MODE::NORMAL:

		// α値だけ変える
		m_Diff.a = 1.0f;

		// 色情報を設定
		SetDiffuse(m_Diff.r, m_Diff.g, m_Diff.b, m_Diff.a);

		// 分岐を抜ける
		break;

		// 点滅状態
	case GUI_MODE::FLASH:

		// チカチカさせる
		Flash();

		// 分岐を抜ける
		break;

		// 点滅状態
	case GUI_MODE::DESELECT:

		// ポリゴンを徐々に不透明にする
		m_Diff.a += m_FadeCoff;

		// もしα値が最大だったら
		if (m_Diff.a >= 1.0f)
		{
			m_Diff.a = 1.0f;

			// 通常状態に遷移
			m_Mode = GUI_MODE::NORMAL;

		}

		// 頂点の色の変更
		SetDiffuse(m_Diff.a, m_Diff.a, m_Diff.a, 1.0f);

		// 分岐を抜ける
		break;

		// 表示させたくない状態
	case GUI_MODE::HIDE:

		// α値だけ変える
		m_Diff.a = 0.0f;

		// 色情報を設定
		SetDiffuse(m_Diff.r, m_Diff.g, m_Diff.b, m_Diff.a);

		// 分岐を抜ける
		break;

		// 表示させたくない状態
	case GUI_MODE::GRADUALLY_DESELECT:



		// 分岐を抜ける
		break;
		// 表示させたくない状態
	case GUI_MODE::GRADUALLY_SELECT:

		// ポリゴンを徐々に不透明にする
		m_Diff.a += m_FadeCoff;

		// もしα値が最大だったら
		if (m_Diff.a >= 1.0f)
		{
			m_Diff.a = 1.0f;

			// 通常状態に遷移
			m_Mode = GUI_MODE::NORMAL;

		}

		// 頂点の色の変更
		SetDiffuse(m_Diff.r, m_Diff.g, m_Diff.b, m_Diff.a);

		// 分岐を抜ける
		break;
		// 上記以外の場合
	default:

		// 分岐を抜ける
		break;

	}// switch


}// ChangeGuiState
Esempio n. 22
0
void wxGISMapView::OnTimer( wxTimerEvent& event )
{
    //event.Skip();
    //wxSafeYield(this, true);
#ifdef __WXGTK__
    wxWakeUpIdle();
#endif

    switch(m_nDrawingState)
    {
    case enumGISMapZooming:
    {
        //stop zooming action
		if(m_pGISDisplay && !wxGetMouseState().LeftIsDown()) //user release mouse button, so draw contents
		{
		    wxRect rc = GetClientRect();
        	m_pGISDisplay->SetDeviceFrame(rc);
			m_pGISDisplay->SetDerty(true);
			m_nDrawingState = enumGISMapDrawing;
            CreateAndRunDrawThread();
			//wxCommandEvent evt(wxEVT_COMMAND_STARTDRAWING);wxEVT_COMMAND_DATA_SENT
			//GetEventHandler()->ProcessEvent( evt );

//                if(!m_pMapDrawingThread)//m_nDrawingState = enumGISMapDrawing
//                {
//                    StartDraingThread();
//                }
            m_timer.Stop();	//Thaw();
		}
    }
    break;
    case enumGISMapWheeling:
		m_nDrawingState = enumGISMapWheelingStop;
		return;
    case enumGISMapWheelingStop:
		//stop wheeling action
		if(m_pGISDisplay)
		{
			double dZoom = 1;
			if(m_nFactor < 0)
				dZoom = fabs(1.0 / (m_nFactor - 1));
			else if(m_nFactor > 0)
				dZoom = 1 + m_nFactor;

			OGREnvelope Env = CreateEnvelopeFromZoomFactor(dZoom);
			if(Env.IsInit())//set new bounds
				Do(Env);
			m_nDrawingState = enumGISMapDrawing;
		}
		m_nFactor = 0;
		m_timer.Stop();
		return;
    break;
    case enumGISMapFlashing:
        if(m_staFlashGeoms.empty())
        {
            m_nDrawingState = enumGISMapDrawing;
            m_pGISDisplay->SetDrawCache(m_pGISDisplay->GetLastCacheID(), true);
		    m_timer.Stop();
        }
        else
        {
            Flash(m_eFlashStyle);
        }
    break;
    case enumGISMapDrawing:
        break;//not stop timer
    case enumGISMapNone:
    default:
		m_timer.Stop();
    break;
    };
	Refresh();
}
Esempio n. 23
0
void CLife::Save()
{
    Stabilize();
    Flash();
    LifeGrid->toFile(OutFile);
}
Esempio n. 24
0
void main() // no need of given args, use self pid as semaphore key
{
    int c_row, c_col, r_row, r_col;
    int the_pipe[2];                 // 1 pipe for both children
    sem_t *sem_video, *sem_c, *sem_r;
    char str[20];                     // str for common usage
    char row_str[3], col_str[3], pipe_str[3], symbol_str[3]; // child's argv

// prep video semaphore, start value 1, make it like a mutex
    sprintf( str, "%d", getpid() );        // build key str out of pid
    sem_video = sem_open( str, O_CREAT, 0600, 1 );

// prep Chaser semaphore, start value 0
    sprintf( str, "%d", 'C'+getpid() );    // key str out of pid + 'C'
    sem_c = sem_open( str, O_CREAT, 0600, 1 );

// prep Runner semaphore, start value 0
    sprintf( str, "%d", 'R'+getpid() );    // key str out of pid + 'R'
    sem_r = sem_open( str, O_CREAT, 0600, 1 );

    if(sem_video == SEM_FAILED) // erred in sys call sem_open
    {
        perror("Error opening semaphore: ");
        return;
    }

    if( -1 == pipe(the_pipe) ) // 1 pipe for both children
    {
        perror("Error making pipe: ");
        return;
    }

    InitScr( sem_video );           // starting screen

// prep argv for Chaser, starts at upper-left corner
    sprintf(row_str, "%d", 0);    // starting row pos, packing info into str
    sprintf(col_str, "%d", 0);    // starting col pos, packing info into str
    sprintf(pipe_str, "%d", the_pipe[1]);   // pipe end for it to write back
    sprintf(symbol_str, "%c", 'C'); // Chaser's char symbol

    switch( fork() )                // launch Chaser child
    {
    case -1:
        perror("fork C: ");
        return;   // error in fork
    case 0:
        execl( "./child", "./child",   // start child proc with argv
               row_str, col_str, pipe_str, symbol_str, 0 );
    }

// prep argv for Runner, starts at lower-right corner
    sprintf(row_str, "%d", MAX_ROW);
    sprintf(col_str, "%d", MAX_COL);
//   sprintf(pipe_str, "%d", ...); // same pipe_str as above
    sprintf(symbol_str, "%c", 'R');

    switch( fork() )                // launch Runner child
    {
    case -1:
        perror("fork R: ");
        return;
    case 0:
        execl( "./child", "./child",
               row_str, col_str, pipe_str, symbol_str, 0 );
    }

    while(1) //  let them play forever
    {
        sem_post( sem_c ); // allow Chaser 1 play move (loop once, see child.c)

        read( the_pipe[0], &c_row, sizeof(int) ); // read pos info row from Chaser
        read( the_pipe[0], &c_col, sizeof(int) ); // read pos info col from Chaser

        if(c_row == r_row && c_col == r_col) break; // collision occurred?

        sem_post( sem_r ); // allow Runner 1 play move (loop once, see child.c)

        read( the_pipe[0], &r_row, sizeof(int) ); // read pos info from Runner
        read( the_pipe[0], &r_col, sizeof(int) ); // read pos info from Runner

        if(c_row == r_row && c_col == r_col) break; // collision occurred?
    }

    sem_wait(sem_video); // since children are still running, hold till end

    Flash();      // flash screen, restore cursor

    sprintf(str, "%c[%d;%dH", 27, MAX_ROW+3, 1);  // move cursor to bottom
    write(1, str, strlen(str));
    printf("\n*** Chaser got Runner! *** \n");         // OK to use printf since
    printf("Chaser at row %d col %d\n", c_row, c_col); // we're all done with
    printf("Runner at row %d col %d\n", r_row, r_col); // moving around symbols

// if not removed, same filename remains in /dev/shm/sem.<pid>
    sprintf( str, "%d", getpid() );     // build key str out of pid
    sem_unlink( str );
    sprintf( str, "%d", 'C'+getpid() ); // build key str out of pid+'C'
    sem_unlink( str );
    sprintf( str, "%d", 'R'+getpid() ); // build key str out of pid+'R'
    sem_unlink( str );

    kill(0, SIGHUP); // shutdown all processes, include this
}
Esempio n. 25
0
void c_main(char *blockBase, u32 blockSize)
{
	int numRead = 0;
	char commandline[128];
	blobStatus status;
	int i;
	int retval = 0;
	
	/* We really want to be able to communicate, so initialise the
	 * serial port at 9k6 (which works good for terminals)
	 */
	SerialInit(baud9k6);
	TimerInit();
	
	/* initialise status */
	status.kernelSize = 0;
	status.kernelType = fromFlash;
	status.ramdiskSize = 0;
	status.ramdiskType = fromFlash;
	status.blockSize = blockSize;
	status.downloadSpeed = baud115k2;
	
	/* Load kernel and ramdisk from flash to RAM */
	Reload("kernel", &status);
	Reload("ramdisk", &status);

	/* Print the required GPL string */
	SerialOutputString("\r" PACKAGE " version " VERSION  "\r"
			   "Copyright (C) 1999 2000 "
			   "Jan-Derk Bakker and Erik Mouw\r"
			   "Copyright (C) 2000 "
			   "Johan Pouwelse.\r");
	SerialOutputString(PACKAGE " comes with ABSOLUTELY NO WARRANTY; "
			   "read the GNU GPL for details.\r");
	SerialOutputString("This is free software, and you are welcome "
			   "to redistribute it\r");
	SerialOutputString("under certain conditions; "
			   "read the GNU GPL for details.\r\r");

	/* and some information */
#ifdef BLOB_DEBUG
	SerialOutputString("Running from ");
	if(RunningFromInternal())
		SerialOutputString("internal flash\r");
	else
		SerialOutputString("external flash\r");

	SerialOutputString("blockBase = 0x");
	SerialOutputHex((int) blockBase);
	SerialOutputString(", blockSize = 0x");
	SerialOutputHex(blockSize);
	SerialOutputByte('\r');
#endif
	/* wait 10 seconds before starting autoboot */
	SerialOutputString("Autoboot in progress, press any key to stop ");
	for(i = 0; i < 10; i++) {
		SerialOutputByte('.');

 		retval = SerialInputBlock(commandline, 1, 1); 

		if(retval > 0)
			break;
	}

	/* no key was pressed, so proceed booting the kernel */
	if(retval == 0) {
		commandline[0] = '\0';
		BootKernel(commandline);
	}

	SerialOutputString("\rAutoboot aborted\r");
	SerialOutputString("Type \"help\" to get a list of commands\r");

	/* the command loop. endless, of course */
	for(;;) {
		DisplayPrompt(NULL);

		/* wait an hour to get a command */
		numRead = GetCommand(commandline, 128, 3600);

		if(numRead > 0) {
			if(MyStrNCmp(commandline, "boot", 4) == 0) {
				BootKernel(commandline + 4);
			} else if(MyStrNCmp(commandline, "clock", 5) == 0) {
				SetClock(commandline + 5);
			} else if(MyStrNCmp(commandline, "download ", 9) == 0) {
				Download(commandline + 9, &status);
			} else if(MyStrNCmp(commandline, "flash ", 6) == 0) {
				Flash(commandline + 6, &status);
			} else if(MyStrNCmp(commandline, "help", 4) == 0) {
				PrintHelp();
			} else if(MyStrNCmp(commandline, "reload ", 7) == 0) {
				Reload(commandline + 7, &status);
			} else if(MyStrNCmp(commandline, "reset", 5) == 0) {
				ResetTerminal();
			} else if(MyStrNCmp(commandline, "speed ", 6) == 0) {
				SetDownloadSpeed(commandline + 6, &status);
			}
			else if(MyStrNCmp(commandline, "status", 6) == 0) {
				PrintStatus(&status);
			} else {
				SerialOutputString("*** Unknown command: ");
				SerialOutputString(commandline);
				SerialOutputByte('\r');
			}
		}
	}
} /* c_main */