bool CTitaniaSpeech::ActMsg(CActMsg *msg) { CSetFrameMsg frameMsg; CVisibleMsg visibleMsg; CActMsg actMsg; if (msg->_action == "TitaniaSpeech") { switch (_paraNum) { case 0: movieSetAudioTiming(true); loadSound("a#12.wav"); sleep(1000); playMovie(0, 187, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); movieEvent(0); break; case 1: loadSound("a#11.wav"); addTimer(0); startAnimTimer("Para2", 300); addTimer(6000); addTimer(12000); addTimer(18000); addTimer(24000); startAnimTimer("NextPara", 30000); break; case 2: visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#10.wav"); playMovie(585, 706, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); playSound("a#10.wav"); break; case 3: visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#9.wav"); playMovie(707, 905, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); playSound("a#9.wav"); break; case 4: visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#8.wav"); playMovie(906, 938, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); playSound("a#8.wav"); break; default: sleep(3000); actMsg._action = "SleepTitania"; actMsg.execute(this); } } return true; }
int main() { int i,k,n; char *text; unsigned char *trans; FILE *f; initTimer(); // Open file f = fopen("/tmp/dbtss", "r"); if(f == 0) { printf("File not found.\n"); return 0; } // Obtain file size. fseek (f, 0 , SEEK_END); n = ftell (f); rewind (f); printf("File size: %d\n", n); text = malloc(sizeof(char)*(n)); k = fread(text, 1, n, f); printf("Read size: %d\n", k); fclose(f); addTimer("End reading"); // Translate trans = malloc(sizeof(char)*(n+50)); translate(trans, text, n, "ACGT|"); addTimer("End translating"); free(text); // Initialize tail for(i=n; i<n+50; i++) trans[i]=5; addTimer("End initialize tail"); // Sort int *result = malloc(sizeof(int)*n); count_radix(trans, result, n, 5); addTimer("End sorting"); printTimer(); freeTimer(); // for(i=0; i<n; i++){ // for(k=0; k<3; k++) // printf("%i", trans[result[i]+k]); // printf("\n"); // } return 0; }
void DrumSet::addDrumByBeat() { QFile fin(":/note.txt"); if (!fin.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&fin); if(!in.atEnd()) { QString line = in.readLine(); Time = line.toInt(); } if(!in.atEnd()) { QString line = in.readLine(); Speed = line.toInt(); } if(!in.atEnd()) { QString line = in.readLine(); DelayTime = line.toInt(); } bool startflag = true; int tim = 0; while (!in.atEnd()) { QString line = in.readLine(); int val = Speed*4/line.size(); for(int i = 0; i < line.size(); i++) { if(line[i].digitValue() != 0) { if(!startflag) addTimer(tim); startflag = false; switch (line[i].digitValue()) { case 1: drum.append(new RedBigDrum(callparent,callparent,RLabel,RMovie)); break; case 2: drum.append(new BlueBigDrum(callparent,callparent,LLabel,LMovie)); break; case 3: drum.append(new RedSmallDrum(callparent,callparent,RLabel,RMovie)); break; case 4: drum.append(new BlueSmallDrum(callparent,callparent,LLabel,LMovie)); break; default: drum.append(new RedBigDrum(callparent,callparent,RLabel,RMovie)); break; } tim = val; connect(drum[drum.size()-1],SIGNAL(next()),this,SLOT(nextFront())); } else if(!startflag) tim+=val; } } addTimer(tim); }
int FocusClient::init () { rts2core::Configuration *config; int ret; ret = rts2core::Client::init (); if (ret) return ret; setupterm (NULL, 2, NULL); signal (SIGWINCH, signal_winch); config = rts2core::Configuration::instance (); ret = config->loadFile (configFile); if (ret) { std::cerr << "Cannot load configuration file '" << (configFile ? configFile : "/etc/rts2/rts2.ini") << ")" << std::endl; return ret; } addTimer (CHECK_TIMER, new rts2core::Event (EVENT_EXP_CHECK)); return 0; }
void DrumSet::addDrum() { QFile fin(":/recordnote.txt"); if (!fin.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&fin); if(!in.atEnd()) { QString line = in.readLine(); Time = line.toInt(); } if(!in.atEnd()) { QString line = in.readLine(); DelayTime = line.toInt()-3150; } while (!in.atEnd()) { QString line = in.readLine(); QTextStream filein(&line); int dr,ti; filein>>dr>>ti; switch (dr) { case Qt::Key_I: drum.append(new RedBigDrum(callparent,callparent,RLabel,RMovie)); break; case Qt::Key_E: drum.append(new BlueBigDrum(callparent,callparent,LLabel,LMovie)); break; case Qt::Key_J: drum.append(new RedSmallDrum(callparent,callparent,RLabel,RMovie)); break; case Qt::Key_F: drum.append(new BlueSmallDrum(callparent,callparent,LLabel,LMovie)); break; } connect(drum[drum.size()-1],SIGNAL(next()),this,SLOT(nextFront())); addTimer(ti-11); } }
void initOpponentRobot() { // Timer for detector addTimer(OPPONENT_ROBOT_TIMER_INDEX, TIME_DIVIDER_2_HERTZ, &opponentRobotCallbackFunc, "OPPONENT"); }
Timer *TimerManager::createIndefinite(TimerObserver *pObs, float interval) { Timer *pTimer = new Timer(generateID(), 0, 0.0f, interval); pTimer->registerObserver(pObs); addTimer(pTimer); return pTimer; }
Timer *TimerManager::createShotLimitedFreq(TimerObserver *pObs, float frequency, float shots) { Timer *pTimer = new Timer(generateID(), shots, 0.0f, 1.0f / frequency); pTimer->registerObserver(pObs); addTimer(pTimer); return pTimer; }
Timer *TimerManager::createShotLimited(TimerObserver *pObs, float interval, float shots) { Timer *pTimer = new Timer(generateID(), shots, 0.0f, interval); pTimer->registerObserver(pObs); addTimer(pTimer); return pTimer; }
Timer *TimerManager::createTimeLimited(TimerObserver *pObs, int shotCount, float time) { Timer *pTimer = new Timer(generateID(), 0, time, time / (float)shotCount); pTimer->registerObserver(pObs); addTimer(pTimer); return pTimer; }
Timer *TimerManager::createOneShot(TimerObserver *pObs, float time) { Timer *pTimer = new Timer(generateID(), 1, 0.0f, time); pTimer->registerObserver(pObs); addTimer(pTimer); return pTimer; }
bool CBarbot::EnterRoomMsg(CEnterRoomMsg *msg) { // I think this is a remnant of early debugging code if (getName() != "Barbot") addTimer(g_vm->getRandomNumber(20000)); return true; }
void AbstractNetworkJob::adoptRequest(QNetworkReply *reply) { addTimer(reply); setReply(reply); setupConnections(reply); newReplyHook(reply); }
void TimerQueue::runTimer(const Timestamp& now) { if(timers_.empty()) return; callingTimesFunctor_ = true; cancelTimers_.clear(); // just for saving cancel timers when runTimer std::vector<Entry> expired = getExpiredTimers(now); for (std::vector<Entry>::iterator it = expired.begin(); it != expired.end(); ++it) { it->second->trigger(); } callingTimesFunctor_ = false; for (std::vector<Entry>::iterator it = expired.begin(); it != expired.end(); ++it) { Timer *timer = it->second; if(timer->repeat() && cancelTimers_.find(timer->id()) == cancelTimers_.end()) { timer->restart(now); addTimer(timer); } else // timer just run once or has already being canceled { delete timer; } } expired.clear(); assert(timers_.size() == activeTimers_.size()); }
bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { if (CParrot::_v4 != 3) { moveToView(); setPosition(Point(0, 0)); setVisible(true); playClip("Pick Up", 2); playClip("Flapping", 1); stopTimer(_timerId); _timerId = addTimer(1000, 1000); _freeCounter = 0; CParrot::_v4 = 1; msg->_value3 = 1; return CCarry::PassOnDragStartMsg(msg); } CTrueTalkNPC *npc = dynamic_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); if (npc) startTalking(npc, 0x446BF); _fieldE0 = 0; playSound("z#475.wav"); moveUnder(findRoom()); msg->_value4 = 1; return true; }
Timer *TimerManager::createIndefiniteFreq(TimerObserver *pObs, float frequency) { Timer *pTimer = new Timer(generateID(), 0, 0.0f, 1.0f / frequency); pTimer->registerObserver(pObs); addTimer(pTimer); return pTimer; }
MyProxy(ISocketHandler &h) : ProxyClient(h) { setServer("evocraft.net"); addTimer(NULL, 1.0f, 0); }
void callTimers() { const LockType::ScopedLockType sl (lock); while (firstTimer != nullptr && firstTimer->countdownMs <= 0) { Timer* const t = firstTimer; t->countdownMs = t->periodMs; removeTimer (t); addTimer (t); const LockType::ScopedUnlockType ul (lock); JUCE_TRY { t->timerCallback(); } JUCE_CATCH_EXCEPTION } /* This is needed as a memory barrier to make sure all processing of current timers is done before the boolean is set. This set should never fail since if it was false in the first place, we wouldn't get a message (so it can't be changed from false to true from under us), and if we get a message then the value is true and the other thread can only set it to true again and we will get another callback to set it to false. */ callbackNeeded.set (0); }
void C_IRQ_Handler() { printf("In C_IRQ_Handler\n"); uint32_t next_time; // unsigned int icpInt = reg_read(INT_ICIP_ADDR); // printf("icpInt: %x\n", icpInt); uint32_t OSCR = reg_read(OSTMR_OSCR_ADDR); // uint32_t OSMR = reg_read(OSTMR_OSMR_ADDR(0)); // uint32_t OSSR = reg_read(OSTMR_OSSR_ADDR); // printf("OSCR: %d, OSMR: %d, OSSR: %d\n", OSCR, OSMR, OSSR); if(reg_read(OSTMR_OSSR_ADDR) == 1) { // printf("\n\n\n\ndo you get here???\n\n\n\n"); //Incrementing by 10 milliseconds addTimer(1); //Increment Match Register next_time = OSCR + (OSTMR_FREQ_VERDEX); // printf("New OSMR: %d\n", next_time); //Store incremented value reg_write(OSTMR_OSMR_ADDR(0), next_time); //irq reg_set(OSTMR_OSSR_ADDR, OSTMR_OSSR_M0); } //return; printf("\n leaving C_IRQ_handler\n"); I_Handler_Cleanup(); return; }
void Server::doScore(Side side) { if (ballouttimer == -1) { // we didn't process it already if (side == BACK) { score[0]++; output.updateScore(FRONT, score[0]); output.addMessage(Interface::FLASH_YOU_WIN); } else { score[1]++; output.updateScore(BACK, score[1]); output.addMessage(Interface::FLASH_YOU_LOST); } if (state == RUNNING) { Buffer sbuf(SCORE); sbuf.pushSide(side); if (side == BACK) sbuf.pushInt(score[0]); else sbuf.pushInt(score[1]); sendPacket(sbuf, true); } output.updateRound(++round); if (state == RUNNING) { Buffer sbuf(ROUND); sbuf.pushInt(round); sendPacket(sbuf, true); } ballouttimer = addTimer(1000, BALLOUT, this); ball[0].shrink(1000); } }
bool CPhonographEar::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { if (_field140) { _field140 = false; addTimer(1000); } return CEar::PETGainedObjectMsg(msg); }
void gameOver() { removeAllTimers(); draw_string("GAME OVER", GAME_OVER_COLOR, (point_t){GAMEBUFFER_WIDTH/2-(9/2*FONT_COLS_OFFSET), GAMEBUFFER_HEIGHT/2}, false); isNewGame = true; gameLevel = 1; addTimer(10000, false, &initGameScreen); }
bool CUpLighter::TimerMsg(CTimerMsg *msg) { if (_isSpring && _inRoom & !_hosePumping) { CActMsg actMsg("Sneeze"); actMsg.execute(findRoom()->findByName("NoseHolder")); addTimer(1000 + getRandomNumber(19000), 0); } return true; }
bool CBarbot::TimerMsg(CTimerMsg *msg) { if (!_fieldC4 && compareRoomNameTo("Bar")) { CParrotSpeakMsg speakMsg("Barbot", "AskForDrink"); speakMsg.execute("PerchedParrot"); addTimer(10000 + getRandomNumber(20000)); } return true; }
bool CAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) { if (!_isRepeated) { CRoomItem *room = findRoom(); if (msg->_newRoom == room) addTimer(2000); } return true; }
//------------------------------------------------------------------------------ tOplkError timeru_setTimer(tTimerHdl* pTimerHdl_p, ULONG timeInMs_p, tTimerArg argument_p) { tTimeruData* pData; struct itimerspec relTime; tHrtimerSig sig; if (pTimerHdl_p == NULL) return kErrorTimerInvalidHandle; pData = (tTimeruData*)OPLK_MALLOC(sizeof(tTimeruData)); if (pData == NULL) { DEBUG_LVL_ERROR_TRACE("error allocating user timer memory!\n"); return kErrorNoResource; } OPLK_MEMCPY(&pData->timerArg, &argument_p, sizeof(tTimerArg)); addTimer(pData); sig.sigType = kHrtimerSigMsgQueue; sig.sigParam.m_signalMq.msgQueue = timeruInstance_l.msgQueue; sig.sigParam.m_signalMq.m_sigData = (ULONG)pData; if (hrtimer_create(CLOCK_MONOTONIC, &sig, &pData->timer) != 0) { DEBUG_LVL_ERROR_TRACE("%s() Error hrtimer_create!\n", __func__); return kErrorNoResource; } if (timeInMs_p >= 1000) { relTime.it_value.tv_sec = (timeInMs_p / 1000); relTime.it_value.tv_nsec = (timeInMs_p % 1000) * 1000000; } else { relTime.it_value.tv_sec = 0; relTime.it_value.tv_nsec = timeInMs_p * 1000000; } relTime.it_interval.tv_sec = 0; relTime.it_interval.tv_nsec = 0; DEBUG_LVL_TIMERU_TRACE("%s() Set timer:%08x timeInMs_p=%ld\n", __func__, *pData, timeInMs_p); if (hrtimer_settime(pData->timer, 0, &relTime, NULL) < 0) { DEBUG_LVL_ERROR_TRACE("%s() Error hrtimer_settime!\n", __func__); return kErrorTimerNoTimerCreated; } *pTimerHdl_p = (tTimerHdl)pData; return kErrorOk; }
void FocusClient::postEvent (rts2core::Event *event) { switch (event->getType ()) { case EVENT_EXP_CHECK: addTimer (CHECK_TIMER, new rts2core::Event (event)); break; } rts2core::Client::postEvent (event); }
bool CBarShelfVisCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { if (!_flag) { CActMsg actMsg("ClickOnVision"); actMsg.execute("Barbot"); addTimer(3000); _flag = true; } return true; }
bool CTitaniaSpeech::MovieEndMsg(CMovieEndMsg *msg) { if (_paraNum == 5) { startAnimTimer("NextPara", 0); } else { if (_paraNum != 1) addTimer(0); startAnimTimer("NextPara", 3000); } return true; }
//------------------------------------------------------------------------------ tOplkError timeru_setTimer(tTimerHdl* pTimerHdl_p, ULONG timeInMs_p, tTimerArg argument_p) { tTimeruData* pData; struct itimerspec relTime; struct itimerspec curTime; struct sigevent sev; if (pTimerHdl_p == NULL) return kErrorTimerInvalidHandle; pData = (tTimeruData*)OPLK_MALLOC(sizeof(tTimeruData)); if (pData == NULL) return kErrorNoResource; OPLK_MEMCPY(&pData->timerArgument, &argument_p, sizeof(tTimerArg)); addTimer(pData); sev.sigev_notify = SIGEV_SIGNAL; sev.sigev_signo = SIGRTMIN; sev.sigev_value.sival_ptr = pData; if (timer_create(CLOCK_MONOTONIC, &sev, &pData->timer) == -1) { DEBUG_LVL_ERROR_TRACE("%s() Error creating timer!\n", __func__); OPLK_FREE(pData); return kErrorNoResource; } if (timeInMs_p >= 1000) { relTime.it_value.tv_sec = (timeInMs_p / 1000); relTime.it_value.tv_nsec = (timeInMs_p % 1000) * 1000000; } else { relTime.it_value.tv_sec = 0; relTime.it_value.tv_nsec = timeInMs_p * 1000000; } /*DEBUG_LVL_TIMERU_TRACE("%s() Set timer: %p, timeInMs_p=%ld\n", __func__, (void *)pData, timeInMs_p); */ relTime.it_interval.tv_sec = 0; relTime.it_interval.tv_nsec = 0; if (timer_settime(pData->timer, 0, &relTime, &curTime) < 0) { DEBUG_LVL_ERROR_TRACE("%s() Error timer_settime!\n", __func__); return kErrorTimerNoTimerCreated; } *pTimerHdl_p = (tTimerHdl)pData; return kErrorOk; }