const char* Hacklace::printString(const char* st) { // print zero-terminated string stored in RAM return( printStr(st, RAM) ); }
DWORD WINAPI FolderUpdater::watching(void *params) { FolderUpdater *thisFolderUpdater = (FolderUpdater *)params; generic_string dir2Watch = (thisFolderUpdater->_rootFolder)._rootPath; if (dir2Watch[dir2Watch.length() - 1] != '\\') dir2Watch += TEXT("\\"); // CReadDirectoryChanges will add another '\' so we will get "\\" as a separator (of monitored root) in the notification const DWORD dwNotificationFlags = FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_FILE_NAME; // Create the monitor and add directory to watch. CReadDirectoryChanges changes; changes.AddDirectory(dir2Watch.c_str(), true, dwNotificationFlags); HANDLE changeHandles[] = { thisFolderUpdater->_EventHandle, changes.GetWaitHandle() }; bool toBeContinued = true; while (toBeContinued) { DWORD waitStatus = ::WaitForMultipleObjects(_countof(changeHandles), changeHandles, FALSE, INFINITE); switch (waitStatus) { case WAIT_OBJECT_0 + 0: // Mutex was signaled. User removes this folder or file browser is closed toBeContinued = false; break; case WAIT_OBJECT_0 + 1: // We've received a notification in the queue. { DWORD dwAction; CStringW wstrFilename; if (changes.CheckOverflow()) printStr(L"Queue overflowed."); else { changes.Pop(dwAction, wstrFilename); static generic_string oldName; static std::vector<generic_string> file2Change; file2Change.clear(); switch (dwAction) { case FILE_ACTION_ADDED: file2Change.push_back(wstrFilename.GetString()); //thisFolderUpdater->updateTree(dwAction, file2Change); ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_ADDFILE, (WPARAM)nullptr, (LPARAM)&file2Change); oldName = TEXT(""); break; case FILE_ACTION_REMOVED: file2Change.push_back(wstrFilename.GetString()); //thisFolderUpdater->updateTree(dwAction, file2Change); ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RMFILE, (WPARAM)nullptr, (LPARAM)&file2Change); oldName = TEXT(""); break; case FILE_ACTION_MODIFIED: oldName = TEXT(""); break; case FILE_ACTION_RENAMED_OLD_NAME: oldName = wstrFilename.GetString(); break; case FILE_ACTION_RENAMED_NEW_NAME: if (not oldName.empty()) { file2Change.push_back(oldName); file2Change.push_back(wstrFilename.GetString()); //thisFolderUpdater->updateTree(dwAction, file2Change); ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RNFILE, (WPARAM)nullptr, (LPARAM)&file2Change); } oldName = TEXT(""); break; default: oldName = TEXT(""); break; } } } break; case WAIT_IO_COMPLETION: // Nothing to do. break; } } // Just for sample purposes. The destructor will // call Terminate() automatically. changes.Terminate(); //printStr(L"Quit watching thread"); return EXIT_SUCCESS; }
int printText(char** text, int count, int key) { FILE* fout; errno_t err = fopen_s(&fout, "output.txt", "w"); int num = 0, k = 0; int a = 0, b = 0; if (key == 2) { srand(time(0)); a = rand() % (count - 1); printStr(fout, text[a]); b = rand() % (count - 1); printStr(fout, text[b]); a += rand() % (5) + 1; printStr(fout, text[a]); b += rand() % (5) + 1; printStr(fout, text[b]); a = rand() % (count - 1); printStr(fout, text[a]); a -= rand() % (5) + 1; printStr(fout, text[a]); b = rand() % (count - 1); printStr(fout, text[b]); b += rand() % (5) + 1; printStr(fout, text[b]); a = rand() % (count - 1); printStr(fout, text[a]); b = rand() % (count - 1); printStr(fout, text[b]); b -= rand() % (5) + 1; printStr(fout, text[b]); a += rand() % (5) + 1; printStr(fout, text[a]); a = rand() % (count - 1); printStr(fout, text[a]); a -= rand() % (5) + 1; fprintf(fout, "\n"); } else while (num < count) { printStr(fout, text[num]); num++; } fclose(fout); return Ok; }
void VerilatedVcd::printQuad (vluint64_t n) { char buf [100]; sprintf(buf,"%" VL_PRI64 "u", n); printStr(buf); }
void VerilatedVcd::dumpHeader () { printStr("$version Generated by VerilatedVcd $end\n"); time_t time_str = time(NULL); printStr("$date "); printStr(ctime(&time_str)); printStr(" $end\n"); printStr("$timescale "); printStr(doubleToTimescale(m_timeRes).c_str()); printStr(" $end\n"); makeNameMap(); // Signal header assert (m_modDepth==0); printIndent(1); printStr("\n"); // We detect the spaces in module names to determine hierarchy. This // allows signals to be declared without fixed ordering, which is // required as Verilog signals might be separately declared from // "SP_TRACE" signals. // Print the signal names const char* lastName = ""; for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) { const char* hiername = (*it).first.c_str(); const char* decl = (*it).second.c_str(); // Determine difference between the old and new names const char* lp = lastName; const char* np = hiername; lastName = hiername; // Skip common prefix, it must break at a space or tab for (; *np && (*np == *lp); np++, lp++) {} while (np!=hiername && *np && *np!=' ' && *np!='\t') { np--; lp--; } //printf("hier %s\n lp=%s\n np=%s\n",hiername,lp,np); // Any extra spaces in last name are scope ups we need to do bool first = true; for (; *lp; lp++) { if (*lp==' ' || (first && *lp!='\t')) { printIndent(-1); printStr("$upscope $end\n"); } first = false; } // Any new spaces are scope downs we need to do while (*np) { if (*np==' ') np++; if (*np=='\t') break; // tab means signal name starts printIndent(1); printStr("$scope module "); for (; *np && *np!=' ' && *np!='\t'; np++) { if (*np=='[') printStr("("); else if (*np==']') printStr(")"); else *m_writep++=*np; } printStr(" $end\n"); } printIndent(0); printStr(decl); } while (m_modDepth>1) { printIndent(-1); printStr("$upscope $end\n"); } printIndent(-1); printStr("$enddefinitions $end\n\n\n"); assert (m_modDepth==0); // Reclaim storage delete m_namemapp; }
void CInventory::Update() { if (m_bOpen) { GRAPHICS->RenderText(L"Inventory", { -300.0f, 650.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.85f, 0.8f }); GRAPHICS->RenderText(L"Resources", { -700.0f, 475.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }); GRAPHICS->RenderText(L"Items", { -640.0f, -135.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }); string enumSzItem[NUM_ITEMS] = { "Bones", "Wood Log", "Herb", "Gunpowder", "Bomb", "Wood Plank", "Health Potion" }; string numBones = enumSzItem[m_nCursor]; wstring wBones(numBones.begin(), numBones.end()); GRAPHICS->RenderText(wBones.c_str(), { -100.0f, 300.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, { 0.7f, 0.65f }); float fStockY = 365.0f; for (size_t i = 0; i < NUM_ITEMS; i++) { string strAmmount = "x" + to_string(m_CurrentStock[i]); wstring printStr(strAmmount.begin(), strAmmount.end()); GRAPHICS->RenderText(printStr.c_str(), { -500.0f, fStockY }, { 1.0f, 1.0f, 1.0f, 1.0f }, { 0.4f, 0.3f }); fStockY -= 127.5f; if (i == 3) { fStockY -= 115.0f; } } #pragma region Check Cursor for Craftability //bomb = 2 bone and 2 gunpowder //wood plank = 2 wood //health potion = 1 bone and 2 herb if (CInputManager::GetInstance()->GetControllerBeingUsed() == true) { m_cpInputImgs[0]->SetTexture(L"../Game/Assets/Art/2D/Inventory/UpDPad_Controller.dds"); m_cpInputImgs[1]->SetTexture(L"../Game/Assets/Art/2D/Inventory/DownDPad_Controller.dds"); m_cpInputImgs[2]->SetTexture(L"../Game/Assets/Art/2D/Inventory/AButton_Controller.dds"); m_cpInputImgs[3]->SetTexture(L"../Game/Assets/Art/2D/Inventory/XButton_Controller.dds"); //scale down the button images for crafting m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[0] = 0.15f;//top-right X m_cpInputImgs[2]->GetVertex2DArr()[2].m_fPosition[0] = 0.15f;//bottom-right X m_cpInputImgs[2]->GetVertex2DArr()[0].m_fPosition[1] = 0.0f;//top left Y m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[1] = 0.0f;//top-right Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[0] = 0.15f;//top-right X m_cpInputImgs[3]->GetVertex2DArr()[2].m_fPosition[0] = 0.15f;//bottom-right X m_cpInputImgs[3]->GetVertex2DArr()[0].m_fPosition[1] = 0.0f;//top left Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[1] = 0.0f;//top-right Y m_cpInputImgs[2]->SetPosition(XMFLOAT3{ -0.3f, -0.45f, m_cpInputImgs[2]->GetPosition().z}); m_cpInputImgs[3]->SetPosition(XMFLOAT3{ 0.125f, -0.45f, m_cpInputImgs[3]->GetPosition().z }); } else { m_cpInputImgs[0]->SetTexture(L"../Game/Assets/Art/2D/Inventory/UpArrow_Keyboard.dds"); m_cpInputImgs[1]->SetTexture(L"../Game/Assets/Art/2D/Inventory/DownArrow_Keyboard.dds"); m_cpInputImgs[2]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Enter_Keyboard.dds"); m_cpInputImgs[3]->SetTexture(L"../Game/Assets/Art/2D/Inventory/SpaceBar_Keyboard.dds"); //scale up the keyboard images for crafting m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[0] = 0.2f;//top-right X m_cpInputImgs[2]->GetVertex2DArr()[2].m_fPosition[0] = 0.2f;//bottom-right X m_cpInputImgs[2]->GetVertex2DArr()[0].m_fPosition[1] = 0.1f;//top left Y m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[1] = 0.1f;//top-right Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[0] = 0.2f;//top-right X m_cpInputImgs[3]->GetVertex2DArr()[2].m_fPosition[0] = 0.2f;//bottom-right X m_cpInputImgs[3]->GetVertex2DArr()[0].m_fPosition[1] = 0.1f;//top left Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[1] = 0.1f;//top-right Y m_cpInputImgs[2]->SetPosition(XMFLOAT3{ -0.35f, -0.5f, m_cpInputImgs[2]->GetPosition().z }); m_cpInputImgs[3]->SetPosition(XMFLOAT3{ 0.05f, -0.5f, m_cpInputImgs[3]->GetPosition().z }); } switch ((eItems)m_nCursor) { case CInventory::Bones: case CInventory::Wood: case CInventory::Herb: case CInventory::Gunpowder: { m_bAbleToCraft = false; for (unsigned int i = 0; i < 2; i++) m_cpInputImgs[i]->GetRender() = true; m_cpInputImgs[2]->GetRender() = false; m_cpInputImgs[3]->GetRender() = false; } break; case CInventory::Bomb: { if (GetStock(Gunpowder) >= 2 && GetStock(Bones) >= 2) { m_bAbleToCraft = true; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); } else { m_bAbleToCraft = false; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); GRAPHICS->RenderText(L"Not Enough Resources", { 250.0f, -225.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }, (eTextMod)1); } for (unsigned int i = 0; i < 4; i++) m_cpInputImgs[i]->GetRender() = true; GRAPHICS->RenderText(L"Craft One", { -175.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }); unsigned int unCraftAllAmount = 0; if (GetStock(Bones) / 2 < GetStock(Gunpowder) / 2) unCraftAllAmount = GetStock(Bones) / 2; else unCraftAllAmount = GetStock(Gunpowder) / 2; string szCraftAll = "Craft All (" + to_string(unCraftAllAmount) + ")"; wstring wszCraftAll(szCraftAll.begin(), szCraftAll.end()); GRAPHICS->RenderText(wszCraftAll.c_str(), { 375.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }, (eTextMod)1); } break; case CInventory::Bridge: { if (GetStock(Wood) >= 1) { m_bAbleToCraft = true; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); } else { m_bAbleToCraft = false; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); GRAPHICS->RenderText(L"Not Enough Resources", { 250.0f, -225.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }, (eTextMod)1); } for (unsigned int i = 0; i < 4; i++) m_cpInputImgs[i]->GetRender() = true; GRAPHICS->RenderText(L"Craft One", { -175.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }); unsigned int unCraftAllAmount = GetStock(Wood) * 2; string szCraftAll = "Craft All (" + to_string(unCraftAllAmount) + ")"; wstring wszCraftAll(szCraftAll.begin(), szCraftAll.end()); GRAPHICS->RenderText(wszCraftAll.c_str(), { 375.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }, (eTextMod)1); } break; case CInventory::HealthPotion: { if (GetStock(Herb) >= 2 && GetStock(Bones) >= 1) { m_bAbleToCraft = true; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); } else { m_bAbleToCraft = false; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); GRAPHICS->RenderText(L"Not Enough Resources", { 250.0f, -225.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }, (eTextMod)1); } for (unsigned int i = 0; i < 4; i++) m_cpInputImgs[i]->GetRender() = true; GRAPHICS->RenderText(L"Craft One", { -175.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }); unsigned int unCraftAllAmount = 0; if (GetStock(Bones) / 2 < GetStock(Herb)) unCraftAllAmount = GetStock(Bones) / 2; else unCraftAllAmount = GetStock(Herb); string szCraftAll = "Craft All (" + to_string(unCraftAllAmount) + ")"; wstring wszCraftAll(szCraftAll.begin(), szCraftAll.end()); GRAPHICS->RenderText(wszCraftAll.c_str(), { 375.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }, (eTextMod)1); } break; default: break; } #pragma endregion #pragma region Input if (CInputManager::GetInstance()->IsKeyPressed("Down") || CInputManager::GetInstance()->IsButtonPressed("Cursor Down")) { AudioSystemWwise::Get()->PostEvent(AK::EVENTS::LOOT); m_vcBoarder[m_nCursor]->GetRender() = true; m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Normal.dds"); if (m_nCursor++ >= (NUM_ITEMS - 1)) { m_nCursor = 0; } m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Selected.dds"); m_cpCurrentItem->SetTexture(m_vIconPaths[m_nCursor]); } if (CInputManager::GetInstance()->IsKeyPressed("Up") || CInputManager::GetInstance()->IsButtonPressed("Cursor Up")) { AudioSystemWwise::Get()->PostEvent(AK::EVENTS::LOOT); m_vcBoarder[m_nCursor]->GetRender() = true; m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Normal.dds"); if (m_nCursor-- <= 0) { m_nCursor = NUM_ITEMS - 1; } m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Selected.dds"); m_cpCurrentItem->SetTexture(m_vIconPaths[m_nCursor]); } if ((CInputManager::GetInstance()->IsKeyPressed("Craft") || CInputManager::GetInstance()->IsButtonPressed("Jump Action")) && m_bAbleToCraft == true) { m_bCrafting = true; m_bCraftAll = false; } if ((CInputManager::GetInstance()->IsKeyPressed("CraftAll") || CInputManager::GetInstance()->IsButtonPressed("Health Potion")) && m_bAbleToCraft == true) { m_bCrafting = true; m_bCraftAll = true; } #pragma endregion #pragma region Input Option text Display string szTooltip[NUM_ITEMS] = { "Dropped by Skeletons", "Dropped from Trees", "Dropped from Bushes", "Dropped by Orcs", "Craftable Item\nRequires: ", "Craftable Item\nRequires: ", "Craftable Item\nRequires: ", }; wstring wToolTip(szTooltip[m_nCursor].begin(), szTooltip[m_nCursor].end()); GRAPHICS->RenderText(wToolTip.c_str(), { -300.0f, 100.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.55f, 0.5f }); if (m_nCursor > eItems::Gunpowder) { if (m_nCursor == eItems::Bomb) { XMFLOAT4 f2Color1 = { 1.0f, 0.0f, 0.0f, 1.0f }; XMFLOAT4 f2Color2 = { 1.0f, 0.0f, 0.0f, 1.0f }; string szRequirement1 = "2 Bones"; string szRequirement2 = "2 Gunpowder"; if (GetStock(eItems::Bones) >= 2) { f2Color1 = { 0.0f, 1.0f, 0.0f, 1.0f }; } if (GetStock(eItems::Gunpowder) >= 2) { f2Color2 = { 0.0f, 1.0f, 0.0f, 1.0f }; } wstring wInfo1(szRequirement1.begin(), szRequirement1.end()); wstring wInfo2(szRequirement2.begin(), szRequirement2.end()); GRAPHICS->RenderText(wInfo1.c_str(), { 0.0f, 0.0f }, f2Color1, { 0.55f, 0.5f }); GRAPHICS->RenderText(wInfo2.c_str(), { 0.0f, -60.0f }, f2Color2, { 0.55f, 0.5f }); } else if (m_nCursor == eItems::HealthPotion) { XMFLOAT4 f2Color1 = { 1.0f, 0.0f, 0.0f, 1.0f }; XMFLOAT4 f2Color2 = { 1.0f, 0.0f, 0.0f, 1.0f }; string szRequirement1 = "2 Herbs"; string szRequirement2 = "1 Bone"; if (GetStock(eItems::Herb) >= 2) { f2Color1 = { 0.0f, 1.0f, 0.0f, 1.0f }; } if (GetStock(eItems::Bones) >= 1) { f2Color2 = { 0.0f, 1.0f, 0.0f, 1.0f }; } wstring wInfo1(szRequirement1.begin(), szRequirement1.end()); wstring wInfo2(szRequirement2.begin(), szRequirement2.end()); GRAPHICS->RenderText(wInfo1.c_str(), { 0.0f, 0.0f }, f2Color1, { 0.55f, 0.5f }); GRAPHICS->RenderText(wInfo2.c_str(), { 0.0f, -60.0f }, f2Color2, { 0.55f, 0.5f }); } else if (m_nCursor == eItems::Bridge) { XMFLOAT4 f2Color = { 1.0f, 0.0f, 0.0f, 1.0f }; string szRequirement1 = "1 Wood Log"; if (GetStock(eItems::Wood) >= 1) { f2Color = { 0.0f, 1.0f, 0.0f, 1.0f }; } wstring wInfo1(szRequirement1.begin(), szRequirement1.end()); GRAPHICS->RenderText(wInfo1.c_str(), { 0.0f, 0.0f }, f2Color, { 0.55f, 0.5f }); } } #pragma endregion #pragma region Crafting //user is in the process of crafting if (m_bCrafting == true) { m_cpCraftingBar->GetRender() = true; m_fCraftTime += DELTA_TIME(); if (m_fCraftTime >= CRAFT_TIME) { m_bCrafting = false; m_fCraftTime = 0.0f; m_cpCraftingBar->GetRender() = false; AudioSystemWwise::Get()->PostEvent(AK::EVENTS::CRAFT); #pragma region Removing and Adding Items from Inventory if (m_bCraftAll == true) { switch ((eItems)m_nCursor) { case CInventory::Bomb: { unsigned int numBones = GetStock(Bones); unsigned int numGunpowder = GetStock(Gunpowder); if (numBones % 2 != 0) numBones -= 1; if (numGunpowder % 2 != 0) numGunpowder -= 1; unsigned int totalAdded = 0; if (numBones / 2 < numGunpowder / 2) totalAdded = numBones / 2; else totalAdded = numGunpowder / 2; for (unsigned int i = 0; i < totalAdded; i++) { RemoveFromInventory(Bones, 2); RemoveFromInventory(Gunpowder, 2); AddToInventory(Bomb, 1); } } break; case CInventory::Bridge://wood plank { unsigned int numWood = GetStock(Wood); for (unsigned int i = 0; i < numWood; i++) { RemoveFromInventory(Wood, 1); AddToInventory(Bridge, 2); } } break; case CInventory::HealthPotion: { unsigned int numBones = GetStock(Bones); unsigned int numHerbs = GetStock(Herb); if (numHerbs % 2 != 0) numHerbs -= 1; unsigned int totalAdded = 0; if (numHerbs / 2 < numBones) totalAdded = numHerbs / 2; else totalAdded = numBones; for (unsigned int i = 0; i < totalAdded; i++) { RemoveFromInventory(Bones, 1); RemoveFromInventory(Herb, 2); AddToInventory(HealthPotion, 1); } } break; default: break; } } else { switch ((eItems)m_nCursor) { case CInventory::Bomb: { RemoveFromInventory(Bones, 2); RemoveFromInventory(Gunpowder, 2); AddToInventory(Bomb, 1); } break; case CInventory::Bridge://wood plank { RemoveFromInventory(Wood, 1); AddToInventory(Bridge, 2); } break; case CInventory::HealthPotion: { RemoveFromInventory(Bones, 1); RemoveFromInventory(Herb, 2); AddToInventory(HealthPotion, 1); } break; default: break; } } #pragma endregion m_cpCraftingBar->GetVertex2DArr()[1].m_fPosition[0] = m_fCraftBarStartX; m_cpCraftingBar->GetVertex2DArr()[2].m_fPosition[0] = m_fCraftBarStartX; } // update index 1 and 2 of 2dVert float fRatio = m_fCraftTime / CRAFT_TIME; m_cpCraftingBar->GetVertex2DArr()[1].m_fPosition[0] = m_fCraftBarStartX + (m_fCraftBarSize * fRatio); m_cpCraftingBar->GetVertex2DArr()[2].m_fPosition[0] = m_fCraftBarStartX + (m_fCraftBarSize * fRatio); } #pragma endregion if (CInputManager::GetInstance()->IsKeyPressed("Escape")) Close(); } }
void WordStyleDlg::setVisualFromStyleList() { showGlobalOverrideCtrls(false); Style & style = getCurrentStyler(); // Global override style if (style._styleDesc == TEXT("Global override")) { showGlobalOverrideCtrls(true); } //--Warning text //bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE; COLORREF color = RGB(0x00, 0x00, 0xFF); TCHAR str[256]; str[0] = '\0'; int i = ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) return; ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETTEXT, i, (LPARAM)str); i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) return; TCHAR styleName[64]; ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName); lstrcat(lstrcat(str, TEXT(" : ")), styleName); // PAD for fix a display glitch lstrcat(str, TEXT(" ")); _colourHooker->setColour(color); ::SetWindowText(_hStyleInfoStaticText, str); //-- 2 couleurs : fg et bg bool isEnable = false; if (HIBYTE(HIWORD(style._fgColor)) != 0xFF) { assert(_pFgColour); _pFgColour->setColour(style._fgColor); _pFgColour->setEnabled((style._colorStyle & COLORSTYLE_FOREGROUND) != 0); isEnable = true; } enableFg(isEnable); isEnable = false; if (HIBYTE(HIWORD(style._bgColor)) != 0xFF) { assert(_pBgColour); _pBgColour->setColour(style._bgColor); _pBgColour->setEnabled((style._colorStyle & COLORSTYLE_BACKGROUND) != 0); isEnable = true; } enableBg(isEnable); //-- font name isEnable = true; int iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, (LPARAM)style._fontName.c_str()); if (iFontName == CB_ERR) iFontName = 0; ::SendMessage(_hFontNameCombo, CB_SETCURSEL, iFontName, 0); enableFontName(isEnable); //-- font size isEnable = false; TCHAR intStr[5] = TEXT(""); int iFontSize = 0; if (style._fontSize != -1) { wsprintf(intStr, TEXT("%d"), style._fontSize); iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, (LPARAM)intStr); isEnable = true; } ::SendMessage(_hFontSizeCombo, CB_SETCURSEL, iFontSize, 0); enableFontSize(isEnable); //-- font style : bold et italic isEnable = false; int isBold, isItalic, isUnderline; if (style._fontStyle != -1) { isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?BST_CHECKED:BST_UNCHECKED; isUnderline = (style._fontStyle & FONTSTYLE_UNDERLINE)?BST_CHECKED:BST_UNCHECKED; ::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0); isEnable = true; } else // -1 est comme 0 { ::SendMessage(_hCheckBold, BM_SETCHECK, BST_UNCHECKED, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, BST_UNCHECKED, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, BST_UNCHECKED, 0); } enableFontStyle(isEnable); //-- Default Keywords bool shouldBeDisplayed = style._keywordClass != -1; if (shouldBeDisplayed) { LexerStyler & lexerStyler = _lsArray.getLexerFromIndex(_currentLexerIndex - 1); LangType lType = NppParameters::getLangIDFromStr(lexerStyler.getLexerName()); if (lType == L_TXT) { generic_string str = lexerStyler.getLexerName(); str += TEXT(" is not defined in NppParameters::getLangIDFromStr()"); printStr(str.c_str()); } NppParameters *pNppParams = NppParameters::getInstance(); const TCHAR *kws = pNppParams->getWordList(lType, style._keywordClass); if (!kws) kws = TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_DEF_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(kws)); const TCHAR *ckwStr = (style._keywords)?style._keywords->c_str():TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(ckwStr)); } int showOption = shouldBeDisplayed?SW_SHOW:SW_HIDE; ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT), showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_EDIT),showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_STATIC), showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_STATIC),showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_PLUSSYMBOL_STATIC),showOption); redraw(); }
static void usi_print(void){ userText[sizeof(PIN_str)-1+userTextIndex] = pgm_read_byte(&USI_keys[UIF_userInputIndex]); userText[sizeof(PIN_str)-1+userTextIndex+1] = 0; printStr(userText,RAM); }
void UIF_Init(void){ printStr((void*)uif_initStr, FLASH); return; }
/* Main Function */ int main( int argc, char *argv[] ) { //Color constants' initilizations BLACK = makeColour( 0, 0, 0 ); WHITE = makeColour(63,63,63 ); RED = makeColour(63, 0, 0 ); GREEN = makeColour( 0,63, 0 ); BLUE = makeColour( 0, 0,63 ); //Initializations initInterrupts(); initScreen(); initChars(); //Enable Interrupts enableBalloonIRQ(1000*ONE_MS, balloonISR ); int keys_to_watch = 0x04 | 0x02 ; enableKeyIRQ( keys_to_watch, keyISR ); // fillScreen(BLACK); int i = 0; welcomeMessage(); mouse_status = resetPS2(); int left, right; int lastTime; while(1) { //in case of losing (past 20 misses) if(missed >= MAX_MISS) { disableInterrupt(IRQ_COUNTER); fillScreen(RED); emptyScreen(); printStr(10, 10, "Too many misses..."); printStr(14, 13, "GAME OVER!"); printStr(8, 16, "Press KEY2 to restart"); for(i = 0; i < 30000000; i++); // while(missed >= 20); // printStr(8, 20, "HOOOOOORAY"); enableInterrupt(IRQ_COUNTER); printStr(10, 10, " "); printStr(14, 13, " "); printStr(8, 16, " "); } drawChar (1, 6, ' '); disableInterrupt(IRQ_COUNTER); if (*pSWITCH != 0) { if (*pSWITCH&1) { increment = 1; circleRad = 30; } else if (*pSWITCH&2) { increment = 2; circleRad = 20; } else if (*pSWITCH&4) { increment = 3; circleRad = 15; } } else { increment = 1; circleRad = 30; } enableInterrupt(IRQ_COUNTER); /// MUSIC PLAYER /// // drawChar (1, 5, 16); if(musicCounter == 0) { left = 0; right = 1; } if(musicCounter < musicLength/4) { i = musicCounter; for(i; i<musicCounter+200; i++) { playMusic(music[left], music[right]); left+=2; right+=2; } musicCounter += 200; } else { musicCounter = 0; left = 0; right = 1; } /// MUSIC /// if ( mouse_status == PS2_MOUSE ) { // drawChar (1, 5, 22); if( getMouseMotion( &dxMouse, &dyMouse, &mouse_button ) ) { if( mouse_button & MOUSE_BUTTON1 ) { if(getColor(xMouse+1, yMouse) == RED) { score += increment; drawCircle(xCircle, yCircle, 30, BLACK); /// SOUND EFFECT /// int sleft = 0; int sright = 1; int i; for(i=0; i<effectLength/4; i++) { playMusic(effect[sleft], effect[sright]); sleft+=2; sright+=2; } sleft = 0; sright = 1; /// SOUND EFFECT /// } else { if(time != lastTime) { missed++; time = lastTime; } } } /* if( mouse_button & MOUSE_BUTTON2 ) fillScreen( BLACK ); if( mouse_button & MOUSE_BUTTON3 ) { printStr(17, 13, "PAUSED!"); disableInterrupts(IRQ_COUNTER); while( 1 ) { if( mouse_button & MOUSE_BUTTON2 ) { enableInterrupts(IRQ_COUNTER); printStr(17, 13, " "); break; } } } */ if(getColor(xMouse+1, yMouse) == RED) dragColor = RED; else dragColor = BLACK; drawPixel( xMouse, yMouse, dragColor ); xMouse += dxMouse; yMouse -= dyMouse; xMouse = max( 0, min( xMouse, MAX_X_PIXELS-1 ) ); yMouse = max( 0, min( yMouse, MAX_Y_PIXELS-1 ) ); drawPixel( xMouse, yMouse, WHITE ); //drawCursor(xMouse, yMouse); } } } return 0; }
void printInt(uint32_t num){ char buf[10]; itoa(num,buf,10); printStr(buf); }
/* This ISR gets called whenever a KEY is pressed down: KEY1 restarts the program KEY2 starts a new game after a GAME OVER */ void keyISR() { /* remember: no waiting in an ISR */ int keypress = *pKEY_EDGECAPTURE; int i = 0; int x, y; //Reset Key if( keypress & 0x02 ) { score = 0; missed = 0; time = 0; emptyScreen(); fillScreen(BLUE); printStr(12, 15, "GAME RESTARTED!"); for(i = 0; i < 30000000; i++); printStr(12, 15, " "); } //New game key if( keypress & 0x04 && missed >= MAX_MISS) { score = 0; missed = 0; time = 0; emptyScreen(); fillScreen(BLUE); printStr(7, 15, "Good Luck in the new game!"); for(i = 0; i < 30000000; i++); printStr(7, 15, " "); } /* clear source of KEY interrupt before returning */ *pKEY_EDGECAPTURE = 0; }
/* This function clears the GUI variables from the screen */ void emptyScreen() { int i; for(i = 0; i < 5; i++) printStr(1, i, " "); }
//Draw 'ready' void drawReady() { resetText(); moveToD(-22, 0); printStr("READY?\x80"); }
const char* Hacklace::printString_P(const char* st) { // print zero-terminated string stored in flash memory return( printStr(st, FLASH) ); }
int go_burnin_thread(void *pdata) { extern lua_State *L; extern char *radios[]; extern int burnin_run; FR_THD_PARG *data = (FR_THD_PARG *)pdata; int r; int x, y, x_start, y_start, y_print; int x_num, y_num; int x_range, y_range; int isprint = 0; char buf[128] = {0}; SDL_Widget *label = NULL; x_num = getTableNumElement(L, "con", "BURNIN_SPLIT_X_NUM"); y_num = getTableNumElement(L, "con", "BURNIN_SPLIT_Y_NUM"); x_range = getTableNumElement(L, "con", "BURNIN_SPLIT_X"); y_range = getTableNumElement(L, "con", "BURNIN_SPLIT_Y"); x_start = 0; y_start = getTableNumElement(L, "con", "BURNIN_SPLIT_Y_START"); x = 0; y = 0; y_print = 0; //printStr( "hello world!!", 200, 200); refreshWin(); if( x_num * y_num > data->flow_number) { isprint = 1; x = x_range * ( data->flow_number % x_num); y = y_start + y_range * ( data->flow_number / x_num); y_print = getTableNumElement(L, "con", "BURNIN_SPLIT_PRINT"); } printf( "x %d, y %d, y_pint %d \n", x, y, y_print); if( isprint) { sprintf(buf, "%s TEST is running.", radios[ data->flow_number]); label = printStr( buf, x, y); y += y_print; refreshWin(); } char run_file[1024] = {0}; char *path = (char *)getTableElement(L, "con", "PATH"); sprintf( run_file, "%sburnin/%s/run.lua",path,radios[ data->flow_number]); printf( "go-run.lua: %s\n", run_file); /* printf( "go_burnin_thread: %d, %s \n", data->flow_number, radios[ data->flow_number]); char path[128] = {0}; sprintf( path, "./%s/run.lua", radios[ data->flow_number]); printf( "go_burnin_thread: %s \n", path); */ while(burnin_run) { /* r = run( L, path);*/ r = run( L, run_file); if( r) { if ( isprint && burnin_run) { sprintf( buf, "%s TEST ....Error.", radios[ data->flow_number]); printStr( buf, x, y); y += y_print; refreshWin(); } break; } } /* if( isprint ) { sprintf( buf, "%s TEST ....OK.", radios[ data->flow_number]); printStr( buf, x, y); y += y_print; refreshWin(); } */ data->ret_value = r; return 0; }
const char* Hacklace::printString_EE(const char* st) { // print zero-terminated string stored in EEPROM return( printStr(st, EEPROM) ); }
void SpTraceVcd::printQuad (uint64_t n) { char buf [100]; sprintf(buf,"%llu",(long long unsigned)n); printStr(buf); }
unsigned char initClasses(void) { unsigned short numberOfclasses; unsigned short count; uint16 classDataSize; uint16 inheritanceMatrixSize; numberOfclasses = readShort(); printStr("deserializing "); printShort(numberOfclasses); printStr(" classes"); classes = _malloc_(sizeof(ClassInfo) * numberOfclasses); if (!classes) { return 0; } for (count = 0; count < numberOfclasses; count++) { ClassInfo *current = &classes[count]; printStr("."); current->superClass = readShort(); current->dimension = readByte(); current->hasLock = readByte(); current->dobjectSize = readShort(); current->pobjectSize = readShort(); { unsigned short length; length = readShort(); if (length) { current->interfaces = readClassInterfaces(length); } } current->name = readName(); } printStr("done\n"); classDataSize = readShort(); printStr("Allocating class data ["); printShort(classDataSize); printStr("]\n"); classData = _malloc_(classDataSize); if (!classData) { return 0; } inheritanceMatrixSize = readShort(); printStr("Allocating inheritanceMatrix ["); printShort(inheritanceMatrixSize); printStr("]\n"); inheritanceMatrix = _malloc_(inheritanceMatrixSize); for (count = 0; count < inheritanceMatrixSize; count++) { inheritanceMatrix[count] = readByte(); } printStr("deserializing class store configuration variables\n"); tupac = readByte(); JAVA_LANG_STRING_var = readShort(); JAVA_LANG_OBJECT_var = readShort(); JAVA_LANG_INTEGER_var = readShort(); JAVA_LANG_BYTE_var = readShort(); JAVA_LANG_SHORT_var = readShort(); JAVA_LANG_BOOLEAN_var = readShort(); JAVA_LANG_LONG_var = readShort(); JAVA_LANG_CLASS_var = readShort(); JAVA_LANG_CLASSCASTEXCEPTION_var = readShort(); JAVA_LANG_OUTOFMEMORYERROR_var = readShort(); JAVA_LANG_THROWABLE_var = readShort(); JAVA_LANG_ARITHMETICEXCEPTION_var = readShort(); VM_HARDWAREOBJECT_var = readShort(); JAVA_LANG_NULLPOINTEREXCEPTION_var = readShort(); _C_var = readShort(); _I_var = readShort(); VM_MEMORY_var = readShort(); printStr("done\n"); closeIO(); printStr("deserialized "); printShort(getByteCount()); printStr(" bytes from "); printStr(getOutputFile()); printStr("\n"); return 1; }
void SpTraceVcd::dumpPrep (uint64_t timeui) { printStr("#"); printTime(timeui); printStr("\n"); }
void setup(void) { watchdogConfig(WATCHDOG_OFF); setupSPI(); #ifdef SDN_pin pinMode(SDN_pin, OUTPUT); //SDN digitalWrite(SDN_pin, 0); #endif //LED and other interfaces pinMode(Red_LED, OUTPUT); //RED LED pinMode(Green_LED, OUTPUT); //GREEN LED #ifdef Red_LED2 pinMode(Red_LED2, OUTPUT); //RED LED pinMode(Green_LED2, OUTPUT); //GREEN LED #endif // pinMode(BTN, INPUT); //Button pinMode(SLAVE_SELECT, INPUT); digitalWrite(SLAVE_SELECT, HIGH); // enable pullup for TX:s with open collector output buzzerInit(); serialInit(115200,SERIAL_8N1); checkOperatingMode(); printStr("OpenLRSng DL starting "); printVersion(version); printStr(" on HW "); printUL(BOARD_TYPE); printStr(" ("); printUL(RFMTYPE); printStr("MHz) MDOE="); buzzerOn(BZ_FREQ); digitalWrite(BTN, HIGH); Red_LED_ON ; sei(); delay(50); if (!slaveMode) { printStrLn("MASTER"); if (!bindReadEeprom()) { printStrLn("eeprom bogus reinit...."); bindInitDefaults(); bindWriteEeprom(); } if (!digitalRead(BTN)) { bindMode(); } } else { printStrLn("SLAVE"); if (!digitalRead(BTN) || !bindReadEeprom()) { bindRX(false); } else { bindRX(true); } } packetInterval = getInterval(&bind_data); printStrLn("Entering normal mode"); serialFlush(); serialInit(bind_data.serial_baudrate, bind_data.serial_mode); Red_LED_OFF; buzzerOff(); init_rfm(0); rfmSetChannel(RF_channel); rx_reset(); if (slaveMode) { to_rx_mode(); RF_Mode = Receive; } watchdogConfig(WATCHDOG_2S); lastReceived=micros(); }
static void readLog(EventProc proc) { EventCode c; Word bucketLimit = bucketSize; char *styleConv = NULL; /* suppress uninit warning */ /* Print event count header. */ if (reportEvents) { if (style == '\0') { printf(" bucket:"); for(c = 0; c <= EventCodeMAX; ++c) if (eventEnabled[c]) printf(" %04X", (unsigned)c); printf(" all\n"); } } /* Init event counts. */ for(c = 0; c <= EventCodeMAX; ++c) totalEventCount[c] = 0; clearBucket(); /* Init style. */ switch (style) { case '\0': styleConv = " %8lX"; break; case 'C': styleConv = ", %lu"; break; case 'L': styleConv = " %lX"; break; default: error("Unknown style code '%c'", style); } while (TRUE) { /* loop for each event */ char *eventFormat; int argCount, i; Event event; EventCode code; Res res; /* Read and parse event. */ res = EventRead(&event, proc); if (res == ResFAIL) break; /* eof */ if (res != ResOK) error("Truncated log"); eventTime = event->any.clock; code = EventGetCode(event); /* Output bucket, if necessary, and update counters */ if (bucketSize != 0 && eventTime >= bucketLimit) { reportBucketResults(bucketLimit-1); clearBucket(); do { bucketLimit += bucketSize; } while (eventTime >= bucketLimit); } if (reportEvents) { ++bucketEventCount[code]; ++totalEventCount[code]; } /* Output event. */ if (verbose) { eventFormat = EventCode2Format(code); argCount = strlen(eventFormat); if (eventFormat[0] == '0') argCount = 0; if (style == 'L') putchar('('); switch (style) { case '\0': case 'L': { printf("%-19s", EventCode2Name(code)); } break; case 'C': printf("%u", (unsigned)code); break; } switch (style) { case '\0': printf(" %8lu", (ulong)eventTime); break; case 'C': printf(", %lu", (ulong)eventTime); break; case 'L': printf(" %lX", (ulong)eventTime); break; } switch (event->any.code) { case EventLabel: { switch (style) { case '\0': case 'C': { EventString sym = LabelText(proc, event->aw.w1); printf((style == '\0') ? " %08lX " : ", %lu, ", (ulong)event->aw.a0); if (sym != NULL) { printStr(sym, (style == 'C')); } else { printf((style == '\0') ? "sym %05lX" : "sym %lX\"", (ulong)event->aw.w1); } } break; case 'L': { printf(" %lX %lX", (ulong)event->aw.a0, (ulong)event->aw.w1); } break; } } break; case EventMeterValues: { switch (style) { case '\0': { if (event->pddwww.w3 == 0) { printf(" %08lX 0 N/A N/A N/A N/A", (ulong)event->pddwww.p0); } else { double mean = event->pddwww.d1 / (double)event->pddwww.w3; /* .stddev: stddev = sqrt(meanSquared - mean^2), but see */ /* <code/meter.c#limitation.variance>. */ double stddev = sqrt(fabs(event->pddwww.d2 - (mean * mean))); printf(" %08lX %8u %8u %8u %#8.3g %#8.3g", (ulong)event->pddwww.p0, (uint)event->pddwww.w3, (uint)event->pddwww.w4, (uint)event->pddwww.w5, mean, stddev); } printAddr(proc, (Addr)event->pddwww.p0); } break; case 'C': { putchar(','); printAddr(proc, (Addr)event->pddwww.p0); printf(", %.10G, %.10G, %u, %u, %u", event->pddwww.d1, event->pddwww.d2, (uint)event->pddwww.w3, (uint)event->pddwww.w4, (uint)event->pddwww.w5); } break; case 'L': { printf(" %lX %#.10G %#.10G %X %X %X", (ulong)event->pddwww.p0, event->pddwww.d1, event->pddwww.d2, (uint)event->pddwww.w3, (uint)event->pddwww.w4, (uint)event->pddwww.w5); } break; } } break; case EventPoolInit: { /* pool, arena, class */ printf(styleConv, (ulong)event->ppp.p0); printf(styleConv, (ulong)event->ppp.p1); /* class is a Pointer, but we label them, so call printAddr */ if (style != 'L') { if (style == 'C') putchar(','); printAddr(proc, (Addr)event->ppp.p2); } else printf(styleConv, (ulong)event->ppp.p2); } break; default: for (i = 0; i < argCount; ++i) { switch(code) { #include "eventdef.h" #undef RELATION } } } if (style == 'L') putchar(')'); putchar('\n'); fflush(stdout); } processEvent(proc, event, eventTime); EventDestroy(proc, event); } /* while(!feof(input)) */ /* report last bucket (partial) */ if (bucketSize != 0) { reportBucketResults(eventTime); } if (reportEvents) { /* report totals */ switch (style) { case '\0': { printf("\n run:"); } break; case 'L': { printf("(t"); } break; case 'C': { printf("%lu", eventTime+1); } break; } reportEventResults(totalEventCount); /* explain event codes */ if (style == '\0') { printf("\n"); for(c = 0; c <= EventCodeMAX; ++c) if (eventEnabled[c]) printf(" %04X %s\n", (unsigned)c, EventCode2Name(c)); if (bucketSize == 0) printf("\nevent clock stopped at %lu\n", (ulong)eventTime); } } }
void VerilatedVcd::printIndent (int level_change) { if (level_change<0) m_modDepth += level_change; assert(m_modDepth>=0); for (int i=0; i<m_modDepth; i++) printStr(" "); if (level_change>0) m_modDepth += level_change; }
int main(int argc,char* argv[]) { int n; scanf("%d",&n); int i; char s[128]; char tmp[8]; node nodeVec[MAX]; int num=0; node nd; nd.count=1; for(i=0;i<n;i++) { scanf("%s",s); int j,k; for(j=0,k=0;j<strlen(s);j++) { if(s[j]>='A'&&s[j]<='Z') { tmp[k]=char2int(s[j])+'0'; k++; } else if(s[j]>='0'&&s[j]<='9') { tmp[k]=s[j]; k++; } else continue; } strcpy(nd.str,tmp); if(!binInsert(nodeVec,0,num,nd))num++; /* //dump node printf("\n\n\n"); int q; for(q=0;q<num;q++) { printf("%s %d\n",nodeVec[q].str,nodeVec[q].count); } */ } /* printf("final\n\n\n"); */ bool has=false; //if(num==0)printf("No duplicates.\n"); //else //{ for(i=0;i<num;i++) { //printf("test i %d\n",i); if(nodeVec[i].count>1) { has=true; printStr(nodeVec[i].str); printf(" %d\n",nodeVec[i].count); } } //} if(has==false)printf("No duplicates.\n"); return 0; }
void VerilatedVcd::dumpPrep (vluint64_t timeui) { printStr("#"); printTime(timeui); printStr("\n"); }
int printText(Text_t *text, int StringCount, int key) { FILE* fout; errno_t err = fopen_s(&fout, "output.txt", "w"); int numStr = 0; int a = 0, b = 0; /*! Using for rhyme*/ if (key == 2) { for (int i = 0; i < 1; i++) { srand(time(0)); a = rand() % (StringCount - 1); printStr(fout, text[a].StringPos); b = rand() % (StringCount - 1); printStr(fout, text[b].StringPos); a += rand() % (5) + 1; printStr(fout, text[a].StringPos); b += rand() % (5) + 1; printStr(fout, text[b].StringPos); a = rand() % (StringCount - 1); printStr(fout, text[a].StringPos); a += rand() % (5) + 1; printStr(fout, text[a].StringPos); b = rand() % (StringCount - 1); printStr(fout, text[b].StringPos); b += rand() % (5) + 1; printStr(fout, text[b].StringPos); a = rand() % (StringCount - 1); printStr(fout, text[a].StringPos); b = rand() % (StringCount - 1); printStr(fout, text[b].StringPos); b += rand() % (5) + 1; printStr(fout, text[b].StringPos); a += rand() % (5) + 1; printStr(fout, text[a].StringPos); a = rand() % (StringCount - 1); printStr(fout, text[a].StringPos); a += rand() % (5) + 1; printStr(fout, text[a].StringPos); fprintf(fout, "\n"); } } else while (numStr < StringCount - 1) { printStr(fout, text[numStr].StringPos); numStr++; } fclose(fout); return 1; }
void PreAgiEngine::printStrXOR(char *szMsg) { XOR80(szMsg); printStr(szMsg); }
int main (void) { int countCiclos = 100; //iniciçao da pic initPIC32 (); closedLoopControl( true ); setVel2(0, 0); printStr(__FILE__); // para saber o nome do ficheiro que esta a correr no robot printf("\r battery: %d ", batteryVoltage()); if(batteryVoltage() <94){ printf("_Bateria fraca, MUDAR Bateria\n"); } printStr("\n"); while(1) { while(!tick40ms); tick40ms=0; readAnalogSensors(); //state buttons if(startButton() == 1) // Botao start(preto) primido { estado = 1; enableObstSens(); leds(0x0); //leds off countCiclos = 100; } else if(stopButton() == 1) //Botao stop(vermelho) primido { printf("Red button pressed!!! \n"); estado = 0; disableObstSens(); } if(estado == 1) { TimeOut(); // timeOut => tb devia ir para uma inturrupcao Chegada_Farol(); if(countCiclos++ >= 100) { Ver_Farol(); countCiclos = 0; } Run_Beacon(); } if(estado == 2) { leds(0x1); Stop_robot(); } if(estado == 3) Fim(); else if(stopButton() == 1 || estado == 0) // deslica o funcionamento, nenhum led activo { Stop_robot(); } } return (0); }