void Map::UpdateNearBlocks(int i, int j) { UpdateBlock(i - 1, j); UpdateBlock(i, j - 1); UpdateBlock(i + 1, j); UpdateBlock(i, j + 1); }
void GoRegionBoard::OnExecutedUncodedMove(int move, SgBlackWhite moveColor) { if (DEBUG_REGION_BOARD) SgDebug() << "OnExecutedUncodedMove " << SgWritePoint(move) << '\n'; { m_stack.StartMoveInfo(); if (move != SG_PASS) { SG_ASSERT(! Board().LastMoveInfo(GO_MOVEFLAG_SUICIDE)); // can't handle yet, // should be forbidden anyway. @todo allowed in Chinese rules. bool fWasCapture = Board().LastMoveInfo(GO_MOVEFLAG_CAPTURING); UpdateBlock(move, moveColor); { GoRegion* r = PreviousRegionAt(move, moveColor); bool split = GoEyeUtil::IsSplitPt(move, r->Points()); r->OnAddStone(move); PushStone(r, move); SgPointSet points = r->Points(); // needed even after RemoveRegion(r). if (split || points.IsEmpty()) // must remove old region before generating new ones, // because removing clears m_anchor[] RemoveRegion(r); if (split) // find new regions { for (SgConnCompIterator it(points, Board().Size()); it; ++it) GenRegion(*it, moveColor); } } if (fWasCapture) { // FindNewNeighborRegions(move, moveColor); MergeAdjacentAndAddBlock(move, SgOppBW(moveColor)); } m_code = Board().GetHashCode(); if (HEAVYCHECK) CheckConsistency(); } } { for (SgBWIterator it; it; ++it) { SgBlackWhite color(*it); for (SgVectorIteratorOf<GoRegion> it(AllRegions(color)); it; ++it) { GoRegion* r1 = *it; if (! r1->IsValid()) r1->ComputeBasicFlags(); } } } }
void Map::SetWall(int i, int j, int id) { if (GetWall(i, j) == id || !ValidateBlock(i, j)) return; walls[i][j].Id = id; if (id == 0) { if (blocks[i][j].Id == 0) blocks[i][j].lightSource = MAX_LIGHT; } UpdateBlock(i, j); UpdateNearBlocks(i, j); lightDirty = true; }
void FIndirectLightingCache::UpdateBlocks(FScene* Scene, FViewInfo* DebugDrawingView, TMap<FIntVector, FBlockUpdateInfo>& BlocksToUpdate) { if (BlocksToUpdate.Num() > 0 && !IsInitialized()) { InitResource(); } INC_DWORD_STAT_BY(STAT_IndirectLightingCacheUpdates, BlocksToUpdate.Num()); for (TMap<FIntVector, FBlockUpdateInfo>::TIterator It(BlocksToUpdate); It; ++It) { UpdateBlock(Scene, DebugDrawingView, It.Value()); } }
void CTetrisDlg::Update() { RedrawBkgnd(CRect(0, 0, WIDTH + 320, HEIGHT)); UpdateBlock(); UpdateWindow(); if(m_gameParam & 0x04) { CDC gameoverMemDC; gameoverMemDC.CreateCompatibleDC(&m_memDC); gameoverMemDC.SelectObject(m_gameover); BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = 255; bf.AlphaFormat = AC_SRC_ALPHA; ::AlphaBlend(m_memDC, 0, 0, WIDTH + 320, HEIGHT, gameoverMemDC, 0, 0, WIDTH + 320, HEIGHT, bf); } m_pDC->BitBlt(0, 0, WIDTH + 320, HEIGHT, &m_memDC, 0, 0, SRCCOPY); }
void Map::SetBlock(int i, int j, int id) { if (GetBlock(i, j) == id || !ValidateBlock(i, j)) return; if (id == 0) { blocks[i][j].Id = 0; if (walls[i][j].Id == 0) blocks[i][j].lightSource = MAX_LIGHT; } else { Block* block = Block::GetBlockById(id); blocks[i][j].Id = (char) id; blocks[i][j].lightSource = block->GetLightEmit(); blocks[i][j].hardness = block->GetHardness(); UpdateBlock(i, j); } UpdateNearBlocks(i, j); lightDirty = true; }
BOOL HAL_CONFIG_BLOCK::UpdateBlockWithName( const char* Name, void* Data, size_t Length, BOOL isChipRO ) { #if defined(HAL_REDUCESIZE) return FALSE; #else if(Name == NULL) return FALSE; BOOL fRet = FALSE; BYTE* pXipConfigBuf = NULL; const HAL_CONFIG_BLOCK *pLastConfig = NULL; HAL_CONFIG_BLOCK_STORAGE_DATA blData; if(!GetConfigSectorAddress(blData)) return FALSE; if(g_ConfigurationSector.ConfigurationLength == 0xFFFFFFFF) { return FALSE; } const ConfigurationSector* pStaticCfg = NULL; const HAL_CONFIG_BLOCK *pConfig = NULL; GLOBAL_LOCK(irq); if(blData.isXIP) { pConfig = (const HAL_CONFIG_BLOCK*)(blData.ConfigAddress+ g_ConfigurationSector.ConfigurationLength); pStaticCfg = &g_ConfigurationSector; } else { pXipConfigBuf = (BYTE*)private_malloc(blData.BlockLength); if(pXipConfigBuf != NULL) { blData.Device->Read( blData.ConfigAddress, blData.BlockLength, pXipConfigBuf ); pConfig = (const HAL_CONFIG_BLOCK*)&pXipConfigBuf[g_ConfigurationSector.ConfigurationLength]; pStaticCfg = (const ConfigurationSector*)pXipConfigBuf; } else { return FALSE; } } if(pConfig != NULL) { pConfig = pConfig->Find(Name, FALSE, TRUE); pLastConfig = pConfig->Find("", FALSE, TRUE); } if(pConfig != NULL) { const void* physAddr; const void* physEnd; // try compacting the config block if the first attempt to update fails for(int i=0; i<2; i++) { // if we could not get the last config then we must be full if(pLastConfig != NULL) { if(blData.isXIP) { physAddr = (const void*)pConfig; physEnd = (const void*)pLastConfig; } else { physAddr = (const void*)(blData.ConfigAddress + ((size_t)pConfig - (size_t)pXipConfigBuf)); physEnd = (const void*)(blData.ConfigAddress + ((size_t)pLastConfig - (size_t)pXipConfigBuf)); private_free(pXipConfigBuf); pXipConfigBuf = NULL; } if(Data != NULL) { HAL_CONFIG_BLOCK header; header.Prepare( Name, Data, Length ); fRet = UpdateBlock( blData, physAddr, (const HAL_CONFIG_BLOCK*)&header, Data, Length, physEnd, isChipRO ); } else if(physAddr != physEnd) { fRet = UpdateBlock( blData, physAddr, NULL, NULL, 0, physEnd, isChipRO ); } else { fRet = TRUE; } if(fRet) break; } CompactBlock( blData, pStaticCfg, pLastConfig ); if(!blData.isXIP && pXipConfigBuf != NULL) { blData.Device->Read( blData.ConfigAddress, blData.BlockLength, pXipConfigBuf ); pConfig = (const HAL_CONFIG_BLOCK*)&pXipConfigBuf[g_ConfigurationSector.ConfigurationLength]; } else { pConfig = (const HAL_CONFIG_BLOCK*)(blData.ConfigAddress + g_ConfigurationSector.ConfigurationLength); } pConfig = pConfig->Find(Name, FALSE, TRUE); pLastConfig = pConfig->Find("", FALSE, TRUE); } } if(pXipConfigBuf != NULL) { private_free(pXipConfigBuf); } return fRet; #endif }
INTN EFIAPI ShellAppMain ( IN UINTN Argc, IN CHAR16 **Argv ) { EFI_STATUS Status; UINTN Index; UINT32 FileSize; UINT32 BufferSize; UINT8 *FileBuffer; UINT8 *Buffer; EFI_PHYSICAL_ADDRESS Address; UINTN CountOfBlocks; EFI_TPL OldTpl; BOOLEAN ResetRequired; BOOLEAN FlashError; Index = 0; FileSize = 0; BufferSize = 0; FileBuffer = NULL; Buffer = NULL; Address = 0; CountOfBlocks = 0; ResetRequired = FALSE; FlashError = FALSE; Status = EFI_SUCCESS; mInputData.FullFlashUpdate = TRUE; // // Publish our HII data. // HiiHandle = HiiAddPackages ( &gEfiCallerIdGuid, NULL, FirmwareUpdateStrings, NULL ); if (HiiHandle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } // // Locate the SPI protocol. // Status = gBS->LocateProtocol ( &gEfiSpiProtocolGuid, NULL, (VOID **)&mSpiProtocol ); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_SPI_NOT_FOUND), HiiHandle); return EFI_DEVICE_ERROR; } // // Parse the command line. // Status = ParseCommandLine (Argc, Argv); if (EFI_ERROR (Status)) { PrintHelpInfo (); Status = EFI_SUCCESS; goto Done; } // // Display sign-on information. // PrintToken (STRING_TOKEN (STR_FWUPDATE_FIRMWARE_VOL_UPDATE), HiiHandle); PrintToken (STRING_TOKEN (STR_FWUPDATE_VERSION), HiiHandle); PrintToken (STRING_TOKEN (STR_FWUPDATE_COPYRIGHT), HiiHandle); // // Test to see if the firmware needs to be updated. // if (mInputData.UpdateFromFile) { // // Get the file to use in the update. // PrintToken (STRING_TOKEN (STR_FWUPDATE_READ_FILE), HiiHandle, mInputData.FileName); Status = ReadFileData (mInputData.FileName, &FileBuffer, &FileSize); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_FWUPDATE_READ_FILE_ERROR), HiiHandle, mInputData.FileName); goto Done; } // // Check that the file and flash sizes match. // if (FileSize != PcdGet32 (PcdFlashChipSize)) { PrintToken (STRING_TOKEN (STR_FWUPDATE_SIZE), HiiHandle); Status = EFI_UNSUPPORTED; goto Done; } // // Display flash update information. // PrintToken (STRING_TOKEN (STR_FWUPDATE_UPDATING_FIRMWARE), HiiHandle); // // Update it. // Buffer = FileBuffer; BufferSize = FileSize; Address = PcdGet32 (PcdFlashChipBase); CountOfBlocks = (UINTN) (BufferSize / BLOCK_SIZE); // // Raise TPL to TPL_NOTIFY to block any event handler, // while still allowing RaiseTPL(TPL_NOTIFY) within // output driver during Print(). // OldTpl = gBS->RaiseTPL (TPL_NOTIFY); for (Index = 0; Index < CountOfBlocks; Index++) { // // Handle block based on address and contents. // if (!UpdateBlock (Address)) { DEBUG((EFI_D_INFO, "Skipping block at 0x%lx\n", Address)); } else if (!EFI_ERROR (InternalCompareBlock (Address, Buffer))) { DEBUG((EFI_D_INFO, "Skipping block at 0x%lx (already programmed)\n", Address)); } else { // // Display a dot for each block being updated. // Print (L"."); // // Flag that the flash image will be changed and the system must be rebooted // to use the change. // ResetRequired = TRUE; // // Make updating process uninterruptable, // so that the flash memory area is not accessed by other entities // which may interfere with the updating process. // Status = InternalEraseBlock (Address); ASSERT_EFI_ERROR(Status); if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); FlashError = TRUE; goto Done; } Status = InternalWriteBlock ( Address, Buffer, (BufferSize > BLOCK_SIZE ? BLOCK_SIZE : BufferSize) ); if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); FlashError = TRUE; goto Done; } } // // Move to next block to update. // Address += BLOCK_SIZE; Buffer += BLOCK_SIZE; if (BufferSize > BLOCK_SIZE) { BufferSize -= BLOCK_SIZE; } else { BufferSize = 0; } } gBS->RestoreTPL (OldTpl); // // Print result of update. // if (!FlashError) { if (ResetRequired) { Print (L"\n"); PrintToken (STRING_TOKEN (STR_FWUPDATE_UPDATE_SUCCESS), HiiHandle); } else { PrintToken (STRING_TOKEN (STR_FWUPDATE_NO_RESET), HiiHandle); } } else { goto Done; } } // // All flash updates are done so see if the system needs to be reset. // if (ResetRequired && !FlashError) { // // Update successful. // for (Index = 5; Index > 0; Index--) { PrintToken (STRING_TOKEN (STR_FWUPDATE_SHUTDOWN), HiiHandle, Index); gBS->Stall (1000000); } gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL); PrintToken (STRING_TOKEN (STR_FWUPDATE_MANUAL_RESET), HiiHandle); CpuDeadLoop (); } Done: // // Print flash update failure message if error detected. // if (FlashError) { PrintToken (STRING_TOKEN (STR_FWUPDATE_UPDATE_FAILED), HiiHandle, Index); } // // Do cleanup. // if (HiiHandle != NULL) { HiiRemovePackages (HiiHandle); } if (FileBuffer) { gBS->FreePool (FileBuffer); } return Status; }