//---------------------------------------------------------------------- //Render::Render(GLuint pos, GLuint col, int n, CL* cli, RTPSettings& _settings) : //settings(_settings) //{ //} //---------------------------------------------------------------------- Render::Render(GLuint pos, GLuint col, int n, CL* cli, RTPSettings* _settings) { this->settings = _settings; shader_source_dir = settings->GetSettingAs<string>("rtps_path"); shader_source_dir += "/shaders"; printf("SHADER SOURCE DIR\n", shader_source_dir.c_str()); rtype = POINTS; pos_vbo = pos; col_vbo = col; this->cli=cli; num = n; window_height=600; window_width=800; near_depth=0.; far_depth=1.; write_framebuffers = false; GLubyte col1[] = {0,0,0,255}; GLubyte col2[] = {255,255,255,255}; generateCheckerBoardTex(col1,col2,8,640); printf("GL VERSION %s\n", glGetString(GL_VERSION)); //blending = settings.GetSettingAs<bool>("Render: Blending"); //blending = settings->getUseAlphaBlending(); blending = settings->GetSettingAs<bool>("render_use_alpha"); setupTimers(); }
int main(void) { DO_TEST_HARNESS_SETUP(); WD_DISABLE(); setupIO(); readTestMode(); setupTimers(); smIndex = setupStateMachine(); TS_Setup(); Threshold_Init(); Filter_Init(); Flush_Reset(); COMMS_Init(); sei(); runNormalApplication(); }
void setupAttiny() { DDRB set(LED); PORTB clr(LED); cli(); setupTimers(); sei(); }
void TimerController::checkForStart(unsigned char channel) { Duration duration; if(_stateMachine->isStartTimer()) { _stateMachine->clearStartTimer(); switch (_stateMachine->getState()) { case TEST: colour = 0; if (DEBUG) Serial.println("TimerController - Starting Timer - State: TEST"); duration.duration = 0; duration.t2_prescaler_pointer = (unsigned long) WAIT_T2_PRESCALER_POINTER; duration.t2_comparator = (unsigned long) WAIT_T2_COMPARATOR; duration.t1_comparator = (unsigned long) WAIT_T1_COMPARATOR; setupTimers(duration); break; case WAIT: colour = 0; if (DEBUG) Serial.println("TimerController - Starting Timer - State: WAIT"); duration.duration = 0; duration.t2_prescaler_pointer = (unsigned long) WAIT_T2_PRESCALER_POINTER; duration.t2_comparator = (unsigned long) WAIT_T2_COMPARATOR; duration.t1_comparator = (unsigned long) WAIT_T1_COMPARATOR; setupTimers(duration); break; case DISPLAY_COLOUR: colour = _stateMachine->getColour() + 2; if (DEBUG) { Serial.print("TimerController: Starting Timer: DISPLAY_COLOUR : Channel "); Serial.println(channel, HEX); Serial.print("Colour: "); Serial.println(_stateMachine->getColour(), HEX); } duration = _durations[channel][_stateMachine->getColour()]; setupTimers(duration); break; default: if (DEBUG) Serial.println("TimerController - State: DEFAULT"); } } }
ProjectSettings::ProjectSettings(int argc, char** argv, int mpi_rank): cwd(".") { setupTimers(); this->default_config(); this->parseCommandLineArgs(argc, argv, mpi_rank); this->ParseFile(cli_filename); }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); setupUSB(); boardInit(); }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); // usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); boardInit(); }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); // setupUSB(); #if !defined(BOARD_STM32VLD) setupUSB(); #endif boardInit(); }
int main(void) { // Call setup functions setupSerial(); setupTimers(); setupADC(); // Set external interrupts sei(); while (1) { // Infinite loop } return 0; }
void init(void) { setupFlash(); // ok setupClocks(); // ok setupNVIC(); // ok systick_init(SYSTICK_RELOAD_VAL); // ok gpio_init_all(); // ok afio_init(); // ok setupADC(); // adcs increase mA! setupTimers(); }
void MainWindow::realAddTorrent(QString torrentFile, QString torrentPath, QString mountPath) { if (!QFile::exists(torrentFile) && !isMagnet(torrentFile)) die("torrent file not found"); standartText = ("Torrent file: " + torrentFile + "\nDownload path: " + torrentPath + "\nMount path: " + mountPath + "\n").toLocal8Bit(); standartTextLen = standartText.size(); updateStandartText(); if (torrentPath[torrentPath.length() - 1] != QChar('/')) torrentPath += "/"; if (mountPath[mountPath.length() - 1] != QChar('/')) mountPath += "/"; resumeSavePath = torrentPath; add_torrent_params p; p.storage_mode = libtorrent::storage_mode_allocate; if (isMagnet(torrentFile)) { int i; for (i = 1; torrentFile[i] != '='; i++); for (i = i + 1; torrentFile[i] != '='; i++); QString url; for (i = i + 1; torrentFile[i] != '&'; i++) url += torrentFile[i]; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QString name = QUrl(url).toString().replace("+", " "); #else QString name = QUrl(url).toString(QUrl::PreferLocalFile).replace("+", " "); #endif p.save_path = (torrentPath + name + "/").toStdString(); const torrent_handle h = libtorrent::add_magnet_uri(*session, torrentFile.toStdString(), p); main = new Torrent(torrentPath + QString::fromStdString(h.name()), mountPath + QString::fromStdString(h.name()), h, this); } else { torrent_info *inf = new libtorrent::torrent_info(torrentFile.toStdString()); p.ti = inf; p.save_path = (torrentPath + QString::fromStdString(inf->name()) + "/").toStdString(); main = new Torrent(torrentPath + QString::fromStdString(inf->name()), mountPath + QString::fromStdString(inf->name()), session->add_torrent(p), this); } setupTimers(); }
//---------------------------------------------------------------------- System::System(RTPSSettings* set, CL* c) { dout<<"settings "<<set<<endl; settings = set; cli = c; acquiredGL=false; max_num = settings->GetSettingAs<unsigned int>("max_num_particles"); num = settings->GetSettingAs<unsigned int>("num_particles"); maxGravSources=settings->GetSettingAs<unsigned int>("max_gravity_sources"); activeParticle = 0; // I should be able to not specify this, but GPU restrictions ... //seed random srand ( time(NULL) ); grid = Domain(settings->GetSettingAs<float4>("domain_min"),settings->GetSettingAs<float4>("domain_max")); setupTimers(); //*** end Initialization #ifdef CPU dout<<"RUNNING ON THE CPU"<<endl; #endif #ifdef GPU dout<<"RUNNING ON THE GPU"<<endl; prepareSorted(); //dout<<"Here"<<endl; //should be more cross platform string common_source_dir = settings->GetSettingAs<string>("rtps_path") + "/" + std::string(COMMON_CL_SOURCE_DIR); cli->addIncludeDir(common_source_dir); //dout<<common_source_dir.c_str()<<endl; hash = Hash(common_source_dir, cli, timers["hash_gpu"]); gravity = Gravity(common_source_dir, cli); bitonic = Bitonic<unsigned int>(common_source_dir, cli ); //radix = Radix<unsigned int>(common_source_dir, cli, max_num, 128); cellindices = CellIndices(common_source_dir, cli, timers["ci_gpu"] ); permute = Permute( common_source_dir, cli, timers["perm_gpu"] ); m2p = MeshToParticles(common_source_dir, cli, timers["meshtoparticles_gpu"]); marchingcubes = MarchingCubes(common_source_dir, cli, timers["marchingcubes_gpu"],settings->GetSettingAs<unsigned int>("color_field_res","2")); #endif }
/* * @brief stm32 board specific init * @param none * @return none * @note none */ void stm32utils_system_init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); setupUSART(USARTx, SERIAL_BAUDRATE); gpio_set_mode(GPIOA, 0, GPIO_OUTPUT_PP); gpio_write_bit(GPIOA, 0, 0); gpio_set_mode(GPIOA, 1, GPIO_OUTPUT_PP); gpio_write_bit(GPIOA, 1, 0); gpio_set_mode(GPIOA, 12, GPIO_OUTPUT_PP); gpio_write_bit(GPIOA, 12, 0); }
SSEffect::SSEffect(ShaderLibrary* lib, GLuint width, GLuint height)://, GLfloat pointRadius,bool blending): ParticleEffect(lib,width,height)//,pointRadius,blending) { //cout<<"Shaderlib size = "<<m_shaderLibrary.shaders.size()<<endl; m_fbos.resize(1); glGenFramebuffersEXT(1,&m_fbos[0]); createFramebufferTextures(); currentDepthBuffer="depth"; glEnable(GL_TEXTURE_2D); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,m_fbos[0]); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,m_glFramebufferTexs["thickness1"],0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D,m_glFramebufferTexs["depth"],0); dout<<"fbo[0] = "<<m_fbos[0]<<" status complete? "<<((glCheckFramebufferStatus(GL_FRAMEBUFFER)==GL_FRAMEBUFFER_COMPLETE)?"yes":"no")<<" "<<glCheckFramebufferStatus(GL_FRAMEBUFFER)<<endl; glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); glDisable(GL_TEXTURE_2D); setupTimers(); }
//---------------------------------------------------------------------- FLOCK::FLOCK(RTPSSettings* set, CL* c):System(set,c) { //seed random srand ( time(NULL) ); std::vector<FLOCKParameters> vparams(0); vparams.push_back(flock_params); cl_FLOCKParameters= Buffer<FLOCKParameters>(cli, vparams); calculate(); updateParams(); spacing = settings->GetSettingAs<float>("spacing"); dout<<"spacing ="<<spacing<<endl; //set up the grid setupDomain(flock_params.smoothing_distance/flock_params.simulation_scale,flock_params.simulation_scale); //set up the timers setupTimers(); //setup the sorted and unsorted arrays prepareSorted(); #ifdef CPU dout<<"RUNNING ON THE CPU"<<endl; #endif #ifdef GPU dout<<"RUNNING ON THE GPU"<<endl; //should be more cross platform string flock_source_dir = settings->GetSettingAs<string>("rtps_path") + "/" + std::string(FLOCK_CL_SOURCE_DIR); cli->addIncludeDir(flock_source_dir); rules = Rules(flock_source_dir, cli, timers["rules_gpu"]); euler_integration = EulerIntegration(flock_source_dir, cli, timers["euler_gpu"]); #endif //renderer->setParticleRadius(spacing); }
void init(void) { setupFlash(); setupClocks(); setupNVIC(); systick_init(SYSTICK_RELOAD_VAL); gpio_init_all(); afio_init(); setupADC(); setupTimers(); setupUSB(); boardInit(); //for debug gpio_set_mode(GPIOA, 2, GPIO_AF_OUTPUT_PP); gpio_set_mode(GPIOA, 3, GPIO_INPUT_FLOATING); usart_init(USART2); usart_set_baud_rate(USART2, STM32_PCLK1, 57600); usart_enable(USART2); /*delay(1000); TxDString("hello pandora\r\n");*/ }
void * processQueries(void * QSptr) { setupTimers(); defineTimer(setupSecs); defineTimer(findDiagonals); defineTimer(findClumps); defineTimer(filterClumps); defineTimer(processClumps); defineTimer(printClumpss); defineTimer(totalTimer); // Use skipDist of 1 for query, regardless of what was used to create the hash table. int skipDist = 1; // Cache the wordLen on the stack to speed loop access. QueryState_t * QS = (QueryState_t *) QSptr; AlignmentArgs_t * AAs = QS->AAs; int wordLen = AAs->wordLen; int maxHits = AAs->maxHits; ROFF *startingOffs = AAs->startingOffs; #ifdef STATS // Let's keep some statistics about the queries we process. int queryCount = 0; int totalQueryLength = 0; uint64_t totalTotalCount = 0; int minQLength = 1000000000; int maxQLength = 0; int minTotalCount = 1000000000; int maxTotalCount = 0; uint64_t totalClumpsOut = 0; int minClumpsPerQuery = 1000000000; int maxClumpsPerQuery = -1; int totalNonAlignedQueries = 0; #endif ///// // Now we are ready to go into the main query read loop. ///// // Calculate some masks for use later. UINT hashMask = ((UINT)0xFFFFFFFF) >> (32 - 2*wordLen); int hashSaveLength = wordLen - skipDist; startTime(); // To get started, make sure we have read a first query. // This is a partial unwind of the first time through the loop. // It allows the main thread to read the first query to get a query length estimate to use to create the other threads. if (QS->queryLen == 0) readNextQuery(AAs, QS); while (QS->queryLen > 0) { /////// // First Phase. Read in the query, reverse it, and do the initial hashing. /////// // See if we need to reallocate the query length dependent structures. if (QS->queryLen > QS->maxQueryLength) reallocNewMaxQueryLength(QS); QOFF qbaseCount = QS->queryLen; #ifdef STATS fprintQueryId(QS, stderr); #endif #ifdef QUERYSTATS struct timeval starttime, endtime; if (AAs->queryStats) { QS->alignCount = 0; QS->alignOutCount = 0; QS->DPCount = 0; QS->usec = 0; QS->seedMatches = 0; QS->diagRegionCount = 0; QS->diagRegionTotal = 0; gettimeofday(&starttime, NULL); } #endif ///// // Now match the query against both the reference DNA and its reverse-complement strand. // Therefore the bases in the reversed query are also complemented. ///// // Do the forward query first. int offsetCount = ((qbaseCount - wordLen)/skipDist) + 1; for (int rev=0; rev<=1; rev++) { QS->reversed = (BOOL)rev; if (QS->reversed) { QS->queryCodeBuf = QS->reverseCodeBuf; QS->queryBuf = QS->reverseBuf; } else { QS->queryCodeBuf = QS->forwardCodeBuf; QS->queryBuf = QS->forwardBuf; } ///// // Find the hash seeds, filter overhits, and fill in structures from the hash table. ///// #ifdef STATS UINT maxHitsOverCount = 0; #endif // The loop complication is because we want to both encode each base once, and skip over non-ACGT codes. UINT totalCount = 0; int baseOff = 0; int endingOffset = qbaseCount - wordLen; UINT hashCode = 0; UINT partialHashCode = 0; int badOffset = generateMatches4UNPto2Fast(QS->queryCodeBuf, baseOff, wordLen, &hashCode); while (TRUE) { if (badOffset != 0) { // Get rid of all the bad ones in a row. while (badOffset <= endingOffset && QS->queryCodeBuf[badOffset] > 3) badOffset += 1; // Make sure the ones we skipped over have their count set to zero. // We need to handle the case where the above has gone too far. badOffset = MIN(badOffset, endingOffset + 1); // fprintf(stderr, "After throwing away bases, badOffset %d baseOff %d endingOffset %d \n", badOffset, baseOff, endingOffset); for (int i=baseOff; i<badOffset; i++) QS->offsetCounts[i].count = 0; // Move forward on the query. baseOff = badOffset; if (baseOff > endingOffset) break; // Try to load entire word. badOffset = generateMatches4UNPto2Fast(QS->queryCodeBuf, baseOff, wordLen, &hashCode); continue; } // The previous read was good, so process it. // Max out before we overflow. UINT count = startingOffs[hashCode+1] - startingOffs[hashCode]; if (count <= maxHits) { totalCount += count; QS->offsetCounts[baseOff].count = count; QS->offsetCounts[baseOff].sOffset = startingOffs[hashCode]; QS->offsetCounts[baseOff].newCount = 0; } else { #ifdef STATS maxHitsOverCount += 1; #endif QS->offsetCounts[baseOff].count = 0; } // and just get the next skipDist worth baseOff += 1; if (baseOff > endingOffset) break; badOffset = generateMatches4UNPto2Fast(QS->queryCodeBuf, baseOff + hashSaveLength, 1, &partialHashCode); // and tack it on to the rest from the previous get. hashCode = ((hashCode << 2) | partialHashCode) & hashMask; } #ifdef STATS fprintf(stderr, "K-mers above maxHits %u\n", maxHitsOverCount); totalTotalCount += totalCount; if (totalCount > 0 && totalCount < minTotalCount) minTotalCount = totalCount; if (totalCount > maxTotalCount) maxTotalCount = totalCount; #endif #ifdef QUERYSTATS if (AAs->queryStats)QS->seedMatches += totalCount; #endif addToTimer(setupSecs); // If the totalCount is zero, we have no hits to process. if (totalCount == 0) continue; ///// // Second Phase. Go through all hash matches, and look for diagonal fragments. ///// int fragCount = findFragmentsSort(AAs, QS, offsetCount); addToTimer(findDiagonals); ///// // Third Phase. Put Fragments into potential alignments (clumps). ///// processFragmentsGapped(AAs, QS, fragCount); addToTimer(findClumps); } // Align and Score clumps, filtering those that don't meet thresholds. postProcessClumps(QS, AAs); addToTimer(processClumps); // Run OQC algorithm if requested. // If not, at least get rid of duplicates. if (AAs->OQC) postFilterBySimilarity(AAs, QS); else postFilterRemoveDups(AAs, QS); addToTimer(filterClumps); // The file lock and unlock here act as the thread synchromization mechanism. // This will ensure that all alignments for a given query are in contiguous lines in the output file. // Otherwise, many downstream tools such as samtools will be unhappy. flockfile(AAs->outFile); // This is to avoid compiler warning when STATS not on. #ifdef STATS int tempClumpsPerQuery = printClumps(QS, AAs); #else printClumps(QS, AAs); #endif funlockfile(AAs->outFile); addToTimer(printClumpss); #ifdef STATS queryCount += 1; totalQueryLength += qbaseCount; if (qbaseCount < minQLength) minQLength = qbaseCount; if (qbaseCount > maxQLength) maxQLength = qbaseCount; totalClumpsOut += tempClumpsPerQuery; if (tempClumpsPerQuery > maxClumpsPerQuery) maxClumpsPerQuery = tempClumpsPerQuery; if (tempClumpsPerQuery > 0 && tempClumpsPerQuery < minClumpsPerQuery) minClumpsPerQuery = tempClumpsPerQuery; if (tempClumpsPerQuery == 0) totalNonAlignedQueries += 1; #endif #ifdef QUERYSTATS if (AAs->queryStats) { gettimeofday(&endtime, NULL); QS->usec = ((endtime.tv_sec - starttime.tv_sec) * 1000000 + (endtime.tv_usec - starttime.tv_usec)); printChars(AAs->qsFile, QS->queryID, 0, QS->queryIDLen); double avgDiagRegionSize = (QS->diagRegionCount > 0) ? (((double)QS->diagRegionTotal/(double)QS->diagRegionCount)+0.0) : 0; fprintf(AAs->qsFile, "\t%u\t%u\t%f\t%u\t%u\t%u\t%u\n", QS->queryLen, QS->seedMatches, avgDiagRegionSize, QS->alignCount, QS->DPCount, QS->alignOutCount, QS->usec); } #endif // Clear query state to get ready for next query. resetQueryState(QS); // Read the next query to setup for next iteration. readNextQuery(AAs, QS); } ////////////////////// // Done with processing the query file. // Close files and clean up storage. ///////////////////// #ifdef TIMING addToTimer(setupSecs); endTime(totalTimer); flockfile(stderr); // if (AAs->threadCount > 1) fprintf(stderr, "Thread %d statistics.\n", QS->threadNum); fprintTimerWithTotalPercent(stderr, "Query setup and hashing took: ", setupSecs, totalTimer); fprintTimerWithTotalPercent(stderr, "Sorting k-mers and forming fragments took: ", findDiagonals, totalTimer); fprintTimerWithTotalPercent(stderr, "Collecting fragments into clumps (using graph) took: ", findClumps, totalTimer); fprintTimerWithTotalPercent(stderr, "Aligning and scoring clumps took: ", processClumps, totalTimer); fprintTimerWithTotalPercent(stderr, "Filtering clumps took: ", filterClumps, totalTimer); fprintTimerWithTotalPercent(stderr, "Printing clumps took: ", printClumpss, totalTimer); funlockfile(stderr); #endif #ifdef STATS if (AAs->verbose) { fprintf(stderr, "%d queries processed.\n", queryCount); fprintf(stderr, "Query Lengths vary from %d to %d with average %d.\n", minQLength, maxQLength, (totalQueryLength/queryCount)); fprintf(stderr, "Total Counts vary from %d to %d with average %"PRIu64".\n", minTotalCount, maxTotalCount, (totalTotalCount/(2 * queryCount))); fprintf(stderr, "There were %d queries with no Alignment.\n", totalNonAlignedQueries); if (totalClumpsOut <= 0) fprintf(stderr, "No Alignments found.\n"); else { fprintf(stderr, "Total Alignments Output = %"PRIu64", average %4.2f per non-zero query.\n", totalClumpsOut, ((double)totalClumpsOut/(queryCount-totalNonAlignedQueries))); fprintf(stderr, "Of those queries with an alignment, the min number of alignments was %d.\n", minClumpsPerQuery); fprintf(stderr, "The max number of alignments per query was %d.\n", maxClumpsPerQuery); } } #endif // Deallocate thread local structures. finalizeQueries(QS); disposeQueryState(QS); return NULL; }
int main(int argc, char* argv[]) { DDRC = 0x0f; DDRD = 0xf0; DDRB = 0xC3; PORTB = 0; PORTC = 0; PORTD = 0; serial_init(); send_string_serial("Starting up...\n"); _delay_ms(500); speed1 = 4000; speed2 = 4000; speed3 = 4000; speed4 = 1250; counter1 = 1; counter2 = 1; counter3 = 1; counter4 = 1; needState1 = FALSE; needState2 = FALSE; needState3 = FALSE; movingForward1 = FALSE; movingForward2 = FALSE; movingForward3 = FALSE; currentState1 = 0; currentState2 = 0; currentState3 = 0; motorState1 = getMotorState(currentState1); motorState2 = getMotorState(currentState2) << 4; unsigned char state = getMotorState(currentState3); motorState3 = ((state & 0x0C) << 4) | (state & 0x03); setupTimers(); char index = 0; int speeds[3]; char* buffer = (char*) speeds; while (1) { if (UCSRA & (1<<RXC)) { buffer[index++] = UDR; if (index == 6) { // do something with the buffer setSpeed1(speeds[0]); setSpeed2(speeds[1]); setSpeed3(speeds[2]); index = 0; send_string_serial("Received full message\n\r"); } } checkSerialSend(); if (needState1) { currentState1 = getNextState(currentState1, movingForward1); motorState1 = getMotorState(currentState1); needState1 = FALSE; } if (needState2) { currentState2 = getNextState(currentState2, movingForward2); motorState2 = getMotorState(currentState2) << 4; needState2 = FALSE; } if (needState3) { currentState3 = getNextState(currentState3, movingForward3); state = getMotorState(currentState3); motorState3 = ((state & 0x0C) << 4) | (state & 0x03); needState3 = FALSE; } /* if (needsNewSpeed) { currentSpeedIndex = (currentSpeedIndex + 1); if (currentSpeedIndex == 0x40) { currentSpeedIndex = 0; send_string_serial("Loop...\n"); } setSpeed1(speed[0][currentSpeedIndex]); setSpeed2(speed[1][currentSpeedIndex]); setSpeed3(speed[2][currentSpeedIndex]); needsNewSpeed = FALSE; } */ } return 0; }
Common::Error KyraEngine_v1::init() { // Setup mixer syncSoundSettings(); if (!_flags.useDigSound) { if (_flags.platform == Common::kPlatformFMTowns) { if (_flags.gameID == GI_KYRA1) _sound = new SoundTowns(this, _mixer); else _sound = new SoundTownsPC98_v2(this, _mixer); } else if (_flags.platform == Common::kPlatformPC98) { if (_flags.gameID == GI_KYRA1) _sound = new SoundPC98(this, _mixer); else _sound = new SoundTownsPC98_v2(this, _mixer); } else if (_flags.platform == Common::kPlatformAmiga) { _sound = new SoundAmiga(this, _mixer); } else { // In Kyra 1 users who have specified a default MT-32 device in the launcher settings // will get MT-32 music, otherwise AdLib. In Kyra 2 and LoL users who have specified a // default GM device in the launcher will get GM music, otherwise AdLib. Users who want // MT-32 music in Kyra2 or LoL have to select this individually (since we assume that // most users rather have a GM device than a MT-32 device). // Users who want PC speaker sound always have to select this individually for all // Kyra games. MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_PCSPK | MDT_MIDI | MDT_ADLIB | ((_flags.gameID == GI_KYRA2 || _flags.gameID == GI_LOL) ? MDT_PREFER_GM : MDT_PREFER_MT32)); if (MidiDriver::getMusicType(dev) == MT_ADLIB) { _sound = new SoundAdLibPC(this, _mixer); } else { Sound::kType type; const MusicType midiType = MidiDriver::getMusicType(dev); if (midiType == MT_PCSPK || midiType == MT_NULL) type = Sound::kPCSpkr; else if (midiType == MT_MT32 || ConfMan.getBool("native_mt32")) type = Sound::kMidiMT32; else type = Sound::kMidiGM; MidiDriver *driver = 0; if (MidiDriver::getMusicType(dev) == MT_PCSPK) { driver = new MidiDriver_PCSpeaker(_mixer); } else { driver = MidiDriver::createMidi(dev); if (type == Sound::kMidiMT32) driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); } assert(driver); SoundMidiPC *soundMidiPc = new SoundMidiPC(this, _mixer, driver, type); _sound = soundMidiPc; assert(_sound); // Unlike some SCUMM games, it's not that the MIDI sounds are // missing. It's just that at least at the time of writing they // are decidedly inferior to the AdLib ones. if (ConfMan.getBool("multi_midi")) { SoundAdLibPC *adlib = new SoundAdLibPC(this, _mixer); assert(adlib); _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib); } } } assert(_sound); } if (_sound) _sound->updateVolumeSettings(); _res = new Resource(this); assert(_res); _res->reset(); if (_flags.isDemo) { // HACK: check whether this is the HOF demo or the LOL demo. // The LOL demo needs to be detected and run as KyraEngine_HoF, // but the static resource loader and the sequence player will // need correct IDs. if (_res->exists("scene1.cps")) #ifdef ENABLE_LOL _flags.gameID = GI_LOL; #else error("Lands of Lore demo is not supported in this build"); #endif // !ENABLE_LOL } _staticres = new StaticResource(this); assert(_staticres); if (!_staticres->init()) error("_staticres->init() failed"); if (!screen()->init()) error("screen()->init() failed"); _timer = new TimerManager(this, _system); assert(_timer); setupTimers(); _emc = new EMCInterpreter(this); assert(_emc); setupOpcodeTable(); readSettings(); if (ConfMan.hasKey("save_slot")) { _gameToLoad = ConfMan.getInt("save_slot"); if (!saveFileLoadable(_gameToLoad)) _gameToLoad = -1; } setupKeyMap(); // Prevent autosave on game startup _lastAutosave = _system->getMillis(); return Common::kNoError; }
// short_init is used by safecast to do a quick power-on // it's special cased to shorten the "ON" duty-cycle void short_init(void) { setupFlash(); setupClocks(); setupNVIC(); setupTimers(); }
// Read the file and add settings to the settings map ProjectSettings::ProjectSettings(const std::string filename) { setupTimers(); this->ParseFile(filename); }
/****************************************************************** * Main-function */ int main(void) { /************************************** * Set the clock to run at 80 MHz */ SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); /************************************** * Enable the floating-point-unit */ FPUEnable(); // We also want Lazystacking, so enable that too FPULazyStackingEnable(); // We also want to put numbers close to zero to zero FPUFlushToZeroModeSet(FPU_FLUSH_TO_ZERO_EN); /************************************** * Init variables */ uint16_t mapData[MAP_DATA_SIZE]; uint8_t stepDir = 0; /************************************** * Init peripherals used */ bluetooth_init(); init_stepper(); // Init the GPIOs used for the stepper and loading LED InitI2C1(); // Init the communication with the lidar-unit through I2C InitPWM(); setupTimers(); /************************************** * State 2 */ // Disable the timers that are used disableTimer(TIMER1_BASE); disableTimer(TIMER2_BASE); // Enable all interrupts IntMasterEnable(); /************************************** * State 3 */ // Indicate we should start with a scan regardless of what other things we have already got // from UART-interrupt // This means setting the appropriate bit in the status vector stat_vec |= TAKE_MEAS; /************************************** * State 4 */ // Contains main-loop where decisions should be made for ( ; ; ) { /********************************** * Decision tree */ // Highest priority case first // Check both interrupts at each iteration in the loop if ( int_vec & UART_INT ) { // Reset the indication int_vec &= ~UART_INT; // Remove drive-stop flag to enable movement stat_vec &= ~DRIVE_STOP; // Init data array uint8_t dataArr[MAX_UART_MSG_SIZE]; // Collect the message if ( readUARTMessage(dataArr, MAX_UART_MSG_SIZE) < SUCCESS ) { // If we have recieved more data than fits in the vector we should simply // go in here again and grab data int_vec |= UART_INT; } // We have gathered a message // and now need to determine what the message is parseMsg(dataArr, MAX_UART_MSG_SIZE); } // Checking drive (movement) interrupt if ( int_vec & TIMER2_INT ) { int_vec &= ~TIMER2_INT; // Disable TIMER2 disableTimer(TIMER2_BASE); // Set drive-stop in status vector stat_vec |= DRIVE_STOP; } // Checking measure interrupt if ( int_vec & TIMER1_INT ) { int_vec &= ~TIMER1_INT; // Disable TIMER1 disableTimer(TIMER1_BASE); // Take reading from LIDAR mapData[stepCount++] = readLidar(); SysCtlDelay(2000); // Take step // Note: We need to take double meas at randvillkor (100) !!!!! if ( stepCount > 0 && stepCount < 100 ) { stepDir = 1; } else if ( stepCount >= 100 && stepCount < 200) { stepDir = 0; } else { stepDir = 1; stepCount = 0; // Reset busy-flag stat_vec &= ~TAKE_MEAS; } step = takeStep(step, stepDir); // Request reading from LIDAR reqLidarMeas(); if ( stat_vec & TAKE_MEAS ) { // Restart TIMER1 enableTimer(TIMER1_BASE, (SYSCLOCK / MEASUREMENT_DELAY)); } else { sendUARTDataVector(mapData, MAP_DATA_SIZE); stat_vec &= ~BUSY; } } // Check the drive_stop flag, which always should be set unless we should move if ( stat_vec & DRIVE_STOP ) { // Stop all movement SetPWMLevel(0,0); halt(); // MAKE SURE all drive-flags are not set stat_vec &= ~(DRIVE_F | DRIVE_L | DRIVE_R | DRIVE_LL | BUSY); } // Should we drive? else if ( stat_vec & DRIVE ) { // Remove drive flag stat_vec &= ~DRIVE; // Increase PWM increase_PWM(0,MAX_FORWARD_SPEED,0,MAX_FORWARD_SPEED); if ( stat_vec & DRIVE_F ) { enableTimer(TIMER2_BASE, DRIVE_FORWARD_TIME); } else if ( stat_vec & DRIVE_LL ) { enableTimer(TIMER2_BASE, DRIVE_TURN_180_TIME); } else { enableTimer(TIMER2_BASE, DRIVE_TURN_TIME); } } if ( !(stat_vec & BUSY) ) { // Tasks switch ( stat_vec ) { case ((uint8_t)DRIVE_F) : // Call drive function go_forward(); // Set the drive flag & BUSY stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_L) : // Call drive-left function go_left(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_R) : // Call drive-right function go_right(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_LL) : // Call turn 180-degrees function go_back(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)TAKE_MEAS) : // Request reading from LIDAR reqLidarMeas(); // Start TIMER1 enableTimer(TIMER1_BASE, (SYSCLOCK / MEASUREMENT_DELAY)); // if sysclock = 1 s, 1/120 = 8.3 ms // We are busy stat_vec |= BUSY; break; default: break; } } } }