int main(int argc, char *argv[]) { const int port = 8888; QApplication app(argc, argv); app.setApplicationName("TrikServer"); trikKernel::ApplicationInitHelper initHelper(app); if (!initHelper.parseCommandLine()) { return 0; } initHelper.init(); QLOG_INFO() << "TrikServer started on port" << port; qDebug() << "Running TrikServer on port" << port; QScopedPointer<trikControl::BrickInterface> brick(trikControl::BrickFactory::create( initHelper.configPath(), trikKernel::Paths::mediaPath())); trikKernel::Configurer configurer( initHelper.configPath() + "/system-config.xml" , initHelper.configPath() + "/model-config.xml" ); QScopedPointer<trikNetwork::MailboxInterface> mailbox(trikNetwork::MailboxFactory::create(configurer)); trikCommunicator::TrikCommunicator communicator(*brick, mailbox.data()); communicator.startServer(port); return app.exec(); }
void TestTest::test_brick() { int length = 3; int width = 3; int height = 3; int hole_length = 5; int hole_width = 5; brick(length, width, height, hole_length, hole_width); }
void CBricks::show() { for (int row = 0; row < m_size; ++row) { QString rowStr; for (int col = 0; col < m_size; ++col) { rowStr.append(QString::number(brick(col, row))); } qDebug() << rowStr; } }
bool CBricks::hasClulsterAt(int x, int y, int w, int h) { for (int cx = x; cx < x + w; ++cx) { for (int cy = y; cy < y + h; ++cy){ if (brick(cx, cy) < 1) { return false; } } } return true; }
int draw::shapeL(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(col, row, -15.0f); glRotatef(rotate, 0.0f, 0.0f, 1.0f); // Rotate on the Z axis glColor3f(1.0f, 0.0f, 0.0f); // Red brick(0.0f, 0.0f); glColor3f(0.0f, 1.0f, 0.0f); // Green brick(2.0f, 0.0f); glColor3f(0.0f, 0.0f, 1.0f); // Blue brick(0.0f, 2.0f); glColor3f(1.0f, 1.0f, 0.0f); // Yellow brick(-4.0f, -2.0f); return TRUE; // Everything Went OK }
BrickSet::BrickSet(void) { for (float i=-4.5; i<6.0; i+=4.5) //create 3*5 bricks { for (float j=-5.0; j<6.0; j+=2.5) { Brick brick(i,j,-45.0); bricks.push_back(brick); } } //Brick brick(0,0,-45.0); //bricks.push_back(brick); }
int main(int argc, char* argv[]) { QApplication app(argc, argv); QScopedPointer<trikControl::BrickInterface> brick(trikControl::BrickFactory::create(".", ".")); cppExample::Gyroscope gyroscope(*brick); QTimer timer; timer.setInterval(100); timer.setSingleShot(false); QObject::connect(&timer, SIGNAL(timeout()), &gyroscope, SLOT(showGyroscopeReading())); QObject::connect(brick->keys(), SIGNAL(buttonPressed(int,int)), QCoreApplication::instance(), SLOT(quit())); timer.start(); return app.exec(); }
int main(int argc, char *argv[]) { Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); // To declare a field, you first need to set up a layout. This requires // knowing the physical vertex-domain and the number of external guard // cell layers. Vertex domains contain enough points to hold all of the // rectilinear centerings that POOMA is likely to support for quite // awhile. Also, it means that the same layout can be used for all // fields, regardless of centering. Interval<2> physicalVertexDomain(14, 14); Loc<2> blocks(3, 3); GridLayout<2> layout1(physicalVertexDomain, blocks, GuardLayers<2>(1), LayoutTag_t()); GridLayout<2> layout0(physicalVertexDomain, blocks, GuardLayers<2>(0), LayoutTag_t()); Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim); Centering<2> vert = canonicalCentering<2>(VertexType, Continuous, AllDim); Centering<2> yedge = canonicalCentering<2>(EdgeType, Continuous, YDim); Vector<2> origin(0.0); Vector<2> spacings(1.0, 2.0); // First basic test verifies that we're assigning to the correct areas // on a brick. typedef Field<UniformRectilinearMesh<2>, double, MultiPatch<GridTag, BrickTag_t> > Field_t; Field_t b0(cell, layout1, origin, spacings); Field_t b1(vert, layout1, origin, spacings); Field_t b2(yedge, layout1, origin, spacings); Field_t b3(yedge, layout1, origin, spacings); Field_t bb0(cell, layout0, origin, spacings); Field_t bb1(vert, layout0, origin, spacings); Field_t bb2(yedge, layout0, origin, spacings); b0.all() = 0.0; b1.all() = 0.0; b2.all() = 0.0; b0 = 1.0; b1 = 1.0; b2 = 1.0; bb0.all() = 0.0; bb1.all() = 0.0; bb2.all() = 0.0; bb0 = 1.0; bb1 = 1.0; bb2 = 1.0; // SPMD code follows. // Note, SPMD code will work with the evaluator if you are careful // to perform assignment on all the relevant contexts. The patchLocal // function creates a brick on the local context, so you can just perform // the assignment on that context. int i; for (i = 0; i < b0.numPatchesLocal(); ++i) { Patch<Field_t>::Type_t patch = b0.patchLocal(i); // tester.out() << "context " << Pooma::context() << ": assigning to patch " << i // << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since b1 and b2 are built with the same layout. for (i = 0; i < b1.numPatchesLocal(); ++i) { b1.patchLocal(i) += 1.5; b2.patchLocal(i) += 1.5; } for (i = 0; i < bb0.numPatchesLocal(); ++i) { Patch<Field_t>::Type_t patch = bb0.patchLocal(i); // tester.out() << "context " << Pooma::context() << ": assigning to patch on bb0 " << i // << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since bb1 and bb2 are built with the same layout. for (i = 0; i < bb1.numPatchesLocal(); ++i) { bb1.patchLocal(i) += 1.5; bb2.patchLocal(i) += 1.5; } tester.check("cell centered field is 2.5", all(b0 == 2.5)); tester.check("vert centered field is 2.5", all(b1 == 2.5)); tester.check("edge centered field is 2.5", all(b2 == 2.5)); tester.out() << "b0.all():" << std::endl << b0.all() << std::endl; tester.out() << "b1.all():" << std::endl << b1.all() << std::endl; tester.out() << "b2.all():" << std::endl << b2.all() << std::endl; tester.check("didn't write into b0 boundary", sum(b0.all()) == 2.5 * b0.physicalDomain().size()); tester.check("didn't write into b1 boundary", sum(b1.all()) == 2.5 * b1.physicalDomain().size()); tester.check("didn't write into b2 boundary", sum(b2.all()) == 2.5 * b2.physicalDomain().size()); tester.check("cell centered field is 2.5", all(bb0 == 2.5)); tester.check("vert centered field is 2.5", all(bb1 == 2.5)); tester.check("edge centered field is 2.5", all(bb2 == 2.5)); tester.out() << "bb0:" << std::endl << bb0 << std::endl; tester.out() << "bb1:" << std::endl << bb1 << std::endl; tester.out() << "bb2:" << std::endl << bb2 << std::endl; typedef Field<UniformRectilinearMesh<2>, double, MultiPatch<GridTag, CompressibleBrickTag_t> > CField_t; CField_t c0(cell, layout1, origin, spacings); CField_t c1(vert, layout1, origin, spacings); CField_t c2(yedge, layout1, origin, spacings); CField_t cb0(cell, layout0, origin, spacings); CField_t cb1(vert, layout0, origin, spacings); CField_t cb2(yedge, layout0, origin, spacings); c0.all() = 0.0; c1.all() = 0.0; c2.all() = 0.0; c0 = 1.0; c1 = 1.0; c2 = 1.0; cb0.all() = 0.0; cb1.all() = 0.0; cb2.all() = 0.0; cb0 = 1.0; cb1 = 1.0; cb2 = 1.0; // SPMD code follows. // Note, SPMD code will work with the evaluator if you are careful // to perform assignment on all the relevant contexts. The patchLocal // function creates a brick on the local context, so you can just perform // the assignment on that context. for (i = 0; i < c0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t patch = c0.patchLocal(i); tester.out() << "context " << Pooma::context() << ": assigning to patch " << i << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since c1 and c2 are built with the same layout. for (i = 0; i < c1.numPatchesLocal(); ++i) { c1.patchLocal(i) += 1.5; c2.patchLocal(i) += 1.5; } for (i = 0; i < cb0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t patch = cb0.patchLocal(i); tester.out() << "context " << Pooma::context() << ": assigning to patch on cb0 " << i << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since cb1 and cb2 are cuilt with the same layout. for (i = 0; i < cb1.numPatchesLocal(); ++i) { cb1.patchLocal(i) += 1.5; cb2.patchLocal(i) += 1.5; } tester.check("cell centered field is 2.5", all(c0 == 2.5)); tester.check("vert centered field is 2.5", all(c1 == 2.5)); tester.check("edge centered field is 2.5", all(c2 == 2.5)); tester.out() << "c0.all():" << std::endl << c0.all() << std::endl; tester.out() << "c1.all():" << std::endl << c1.all() << std::endl; tester.out() << "c2.all():" << std::endl << c2.all() << std::endl; tester.check("didn't write into c0 boundary", sum(c0.all()) == 2.5 * c0.physicalDomain().size()); tester.check("didn't write into c1 boundary", sum(c1.all()) == 2.5 * c1.physicalDomain().size()); tester.check("didn't write into c2 boundary", sum(c2.all()) == 2.5 * c2.physicalDomain().size()); tester.check("cell centered field is 2.5", all(cb0 == 2.5)); tester.check("vert centered field is 2.5", all(cb1 == 2.5)); tester.check("edge centered field is 2.5", all(cb2 == 2.5)); tester.out() << "cb0:" << std::endl << cb0 << std::endl; tester.out() << "cb1:" << std::endl << cb1 << std::endl; tester.out() << "cb2:" << std::endl << cb2 << std::endl; //------------------------------------------------------------------ // Scalar code example: // c0 = iota(c0.domain()).comp(0); c1 = iota(c1.domain()).comp(1); // Make sure all the data-parallel are done: Pooma::blockAndEvaluate(); for (i = 0; i < c0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t local0 = c0.patchLocal(i); Patch<CField_t>::Type_t local1 = c1.patchLocal(i); Patch<CField_t>::Type_t local2 = c2.patchLocal(i); Interval<2> domain = local2.domain(); // physical domain of local y-edges // -------------------------------------------------------------- // I believe the following is probably the most efficient approach // for sparse computations. For data-parallel computations, the // evaluator will uncompress the patches and take brick views, which // provide the most efficient access. If you are only performing // the computation on a small portion of cells, then the gains would // be outweighed by the act of copying the compressed value to all the // cells. // // The read function is used on the right hand side, because // operator() is forced to uncompress the patch just in case you want // to write to it. for(Interval<2>::iterator pos = domain.begin(); pos != domain.end(); ++pos) { Loc<2> edge = *pos; Loc<2> rightCell = edge; // cell to right is same cell Loc<2> leftCell = edge - Loc<2>(1,0); Loc<2> topVert = edge + Loc<2>(0, 1); Loc<2> bottomVert = edge; local2(edge) = local0.read(rightCell) + local0.read(leftCell) + local1.read(topVert) + local1.read(bottomVert); } // This statement is optional, it tries to compress the patch after // we're done computing on it. Since I used .read() for the local0 and 1 // they remained in their original state. compress() can be expensive, so // it may not be worth trying unless space is really important. compress(local2); } tester.out() << "c0" << std::endl << c0 << std::endl; tester.out() << "c1" << std::endl << c1 << std::endl; tester.out() << "c2" << std::endl << c2 << std::endl; //------------------------------------------------------------------ // Interfacing with a c-function: // // This example handles the corner cases, where the patches from a // cell centered field with no guard layers actually contain some // extra data. Pooma::blockAndEvaluate(); for (i = 0; i < cb0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t local0 = cb0.patchLocal(i); Interval<2> physicalDomain = local0.physicalDomain(); double *data; int size = physicalDomain.size(); if (physicalDomain == local0.totalDomain()) { uncompress(local0); data = &local0(physicalDomain.firsts()); nonsense(data, size); } else { // In this case, the engine has extra storage even though the // field has the right domain. We copy it to a brick engine, // call the function and copy it back. No uncompress is required, // since the assignment will copy the compressed value into the // brick. // arrayView is a work-around. Array = Field doesn't work at // the moment. Array<2, double, Brick> brick(physicalDomain); Array<2, double, CompressibleBrick> arrayView(local0.engine()); brick = arrayView(physicalDomain); Pooma::blockAndEvaluate(); data = &brick(Loc<2>(0)); nonsense(data, size); arrayView(physicalDomain) = brick; // Note that we don't need a blockAndEvaluate here, since an iterate has // been spawned to perform the copy. } // If you want to try compress(local0) here, you should do blockAndEvaluate // first in case the local0 = brick hasn't been executed yet. } tester.out() << "cb0.all()" << std::endl << cb0 << std::endl; b2 = positions(b2).comp(0); RefCountedBlockPtr<double> block = pack(b2); // The following functions give you access to the raw data from pack. // Note that the lifetime of the data is managed by the RefCountedBlockPtr, // so when "block" goes out of scope, the data goes away. (i.e. Don't write // a function where you return block.beginPointer().) double *start = block.beginPointer(); // start of the data double *end = block.endPointer(); // one past the end int size = block.size(); // size of the data tester.out() << Pooma::context() << ":" << block.size() << std::endl; unpack(b3, block); tester.out() << "b2" << std::endl << b2 << std::endl; tester.out() << "b3" << std::endl << b3 << std::endl; tester.check("pack, unpack", all(b2 == b3)); int ret = tester.results("LocalPatch"); Pooma::finalize(); return ret; }
int CBricks::brick(int col, int row) { return brick(col + m_size * row); }
int main(int argc, char *argv[]) { QStringList params; for (int i = 1; i < argc; ++i) { params << QString(argv[i]); } QScopedPointer<QCoreApplication> app; if (params.contains("--no-display") || params.contains("-no-display")) { app.reset(new QCoreApplication(argc, argv)); } else { app.reset(new QApplication(argc, argv)); } app->setApplicationName("TrikRun"); // RAII-style code to ensure that after brick gets destroyed there will be an event loop that cleans it up. trikKernel::DeinitializationHelper helper; Q_UNUSED(helper); trikKernel::ApplicationInitHelper initHelper(*app); initHelper.commandLineParser().addPositionalArgument("file", QObject::tr("File with script to execute") + " " + QObject::tr("(optional of -js or -py option is specified)")); initHelper.commandLineParser().addOption("js", "js-script" , QObject::tr("JavaScript script to be executed directly from command line.") + "\n\t" + QObject::tr("Example:") + " ./trikRun -js \"brick.smile(); script.wait(2000);\""); initHelper.commandLineParser().addOption("py", "py-script" , QObject::tr("Python script to be executed directly from command line.") + "\n\t" + QObject::tr("Example:") + " ./trikRun -py \"" "brick.display().showImage('media/trik_smile_normal.png'); " "script.wait(2000)\""); initHelper.commandLineParser().addFlag("no-display", "no-display" , QObject::tr("Disable display support. When this flag is active, trikRun can work without QWS or even " "physical display")); initHelper.commandLineParser().addApplicationDescription(QObject::tr("Runner of JavaScript and Python files.")); if (!initHelper.parseCommandLine()) { return 0; } initHelper.init(); QLOG_INFO() << "TrikRun started"; const auto run = [&](const QString &script, const QString &fileName, trikScriptRunner::ScriptType stype) { QScopedPointer<trikControl::BrickInterface> brick( trikControl::BrickFactory::create(initHelper.configPath(), trikKernel::Paths::mediaPath()) ); trikKernel::Configurer configurer(initHelper.configPath() + "/system-config.xml" , initHelper.configPath() + "/model-config.xml"); QScopedPointer<trikNetwork::MailboxInterface> mailbox(trikNetwork::MailboxFactory::create(configurer)); trikScriptRunner::TrikScriptRunner result(*brick, mailbox.data()); QObject::connect(&result, SIGNAL(completed(QString, int)), app.data(), SLOT(quit())); if (fileName.isEmpty()) { // from command line result.run(script, stype); } else { // from file result.run(script, fileName); } return app->exec(); }; if (initHelper.commandLineParser().isSet("js")) { return run(initHelper.commandLineParser().value("js"), "", trikScriptRunner::ScriptType::JAVASCRIPT); } else if (initHelper.commandLineParser().isSet("py")) { return run(initHelper.commandLineParser().value("py"), "", trikScriptRunner::ScriptType::PYTHON); } else { const QStringList positionalArgs = initHelper.commandLineParser().positionalArgs(); if (positionalArgs.size() == 1) { return run(trikKernel::FileUtils::readFromFile(positionalArgs[0]), positionalArgs[0], trikScriptRunner::ScriptType::JAVASCRIPT); } else { initHelper.commandLineParser().showHelp(); return 1; } } }
void ending() { /* ************************* * WIN THE GAME SEQUENCE * ************************* 0 LINK at ZELDA's side 288 begin WIPE (8px per side per step, each 5 frames) 363 WIPE complete, DOT out, A/B items out QMisc.colors.link_dot = 255; show_subscreen_items = false; 365 first MESSAGE character in 371 next character in 407 last character in 668 LINK out, ZELDA out 669 LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead) 733 BLUE flash bg 734 RED 735 GREEN 736 BLACK ... 860 BLACK, LINK out, ZELDA out 861 LINK in, ZELDA in 927 first MSG character in 935 next character in 1335 last character in 1461 LINK out, ZELDA out 1493 begin SCROLL */ //get rid off all sprites but Link and Zelda items.clear(); Ewpns.clear(); Lwpns.clear(); Sitems.clear(); chainlinks.clear(); decorations.clear(); music_stop(); kill_sfx(); sfx(WAV_ZELDA); Quit=0; game->set_cheat(game->get_cheat() | (cheat>1)?1:0); draw_screen_clip_rect_x1=0; draw_screen_clip_rect_x2=255; draw_screen_clip_rect_y1=0; draw_screen_clip_rect_y2=223; //draw_screen_clip_rect_show_link=true; //draw_screen_clip_rect_show_guys=false; for(int f=0; f<365; f++) { if(f==363) { //363 WIPE complete, DOT out, A/B items out QMisc.colors.link_dot = 255; show_subscreen_items = false; for(int i = guys.Count() - 1; i >= 0; i--) { if(guys.spr(i)->id > gDUMMY9) { guys.del(i); } } guys.draw(framebuf,true); Link.draw(framebuf); } if(f>=288 && ((f-288)%5 == 0)) { //288 begin WIPE (8px per side per step, each 5 frames) //TODO:: draw_screen_clip_rect_x1+=8; draw_screen_clip_rect_x2-=8; //draw_screen_clip_rect_show_guys=true; } draw_screen(tmpscr); advanceframe(true); if(Quit) return; } clear_bitmap(msgdisplaybuf); draw_screen(tmpscr); advanceframe(true); draw_screen_clip_rect_x1=0; draw_screen_clip_rect_x2=255; //draw_screen_clip_rect_show_guys=false; char tmpmsg[6][25]; for(int x=0; x<3; x++) { sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x)); // sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x)); // strncpy(tmpmsg[x], MsgStrings[QMisc.endstring].s+(24*x), 24); } for(int x=0; x<3; x++) { sprintf(tmpmsg[x+3], "%.24s", MsgStrings[QMisc.endstring+1].s+(24*x)); // strncpy(tmpmsg[x+3], MsgStrings[QMisc.endstring+1].s+(24*x), 24); } if(QMisc.endstring==0) { putendmsg("THANKS LINK,YOU'RE",32,96,6,noproc); putendmsg("THE HERO OF HYRULE.",32,112,6,noproc); } else { putendmsg(tmpmsg[0],32,80,6,noproc); putendmsg(tmpmsg[1],32,96,6,noproc); putendmsg(tmpmsg[2],32,112,6,noproc); } for(int f=408; f<927; f++) { /* 668 LINK out, ZELDA out 669 LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead) 733 BLUE flash bg 734 RED 735 GREEN 736 BLACK ... 860 BLACK, LINK out, ZELDA out 861 LINK in, ZELDA in */ if(f==668) { rectfill(framebuf,120,129,152,145,0); blit(framebuf, tmp_bmp, 120,113, 0,0, 32,32); } if(f==860) { blit(tmp_bmp, framebuf, 0,0, 120,113, 32,32); } if(f==669 || f==861) { overtile16(framebuf,36,120,129,6,0);//draw Zelda two-handed overhead overtile16(framebuf,BSZ?32:29,136,129,6,0);//draw Link two-handed overhead } if(f==733) { blit(framebuf,scrollbuf,0,playing_field_offset!=0?168:0,0,0,256,passive_subscreen_height); for(int y=0; y<224; y++) { for(int x=0; x<256; x++) { if(!(framebuf->line[y][x]&15)) { framebuf->line[y][x]=16; } } } } if(f>=733 && f<861) { static byte flash[4] = {0x12,0x16,0x2A,0x0F}; RAMpal[16] = NESpal(flash[(f-733)&3]); refreshpal=true; } if(f==861) { blit(scrollbuf,framebuf,0,0,0,playing_field_offset!=0?168:0,256,passive_subscreen_height); try_zcmusic((char*)"zelda.nsf", 1, ZC_MIDI_ENDING); for(int y=0; y<224; y++) { for(int x=0; x<256; x++) { if(framebuf->line[y][x]==16) { framebuf->line[y][x]=0; } } } } if(f>668 && f!=860) { put_triforce(); } advanceframe(true); if(Quit) { return; } } if(QMisc.endstring==0) { putendmsg("FINALLY,",96,160,8,put_triforce); putendmsg("PEACE RETURNS TO HYRULE.",32,176,8,put_triforce); putendmsg("THIS ENDS THE STORY.",48,200,8,put_triforce); } else { putendmsg(tmpmsg[3],32,160,6,noproc); putendmsg(tmpmsg[4],32,176,6,noproc); putendmsg(tmpmsg[5],32,200,6,noproc); } for(int f=1336; f<1492; f++) { if(f<1461) { put_triforce(); } if(f==1461) { blit(tmp_bmp,framebuf,0,0,120,113,32,32); } advanceframe(true); if(Quit) { return; } } clear_bitmap(scrollbuf); blit(framebuf,scrollbuf,0,0,0,0,256,224); endingpal(); // draw the brick puttile16(scrollbuf,3,256,0,csBOSS,0); int len=600*2; if(game->get_quest()>1) { len=720*2; } int creditsLine=0; int endTextLine=0; const EndingTextLine* endText; int numEndTextLines=0; int deathsYPos=-1; int timeYPos=-1; switch(game->get_quest()) { case 1: endText=quest1End; numEndTextLines=numQuest1EndLines; break; case 2: endText=quest2End; numEndTextLines=numQuest2EndLines; deathsYPos=792; break; case 3: case 4: endText=quest34End; numEndTextLines=numQuest34EndLines; deathsYPos=792; break; default: endText=customQuestEnd; numEndTextLines=numCustomQuestEndLines; deathsYPos=784; timeYPos=800; break; } for(int f=0; f<len; f++) { if(!(f&15)) { int y=(f>>1)+224; if(y>240 && y<584) { brick(24,224); brick(224,224); } if(y==240 || y==584) { for(int x=24; x<=224; x+=8) { brick(x,224); } } if(creditsLine<numCreditsLines) { if(y==credits[creditsLine].yPos) { textout_ex(scrollbuf, zfont, credits[creditsLine].text, credits[creditsLine].xPos, 224, credits[creditsLine].color, 0); creditsLine++; } } else { if(endTextLine<numEndTextLines && y==endText[endTextLine].yPos) { textout_ex(scrollbuf, zfont, endText[endTextLine].text, endText[endTextLine].xPos, 224, endText[endTextLine].color, 0); endTextLine++; } else if(y==deathsYPos) textprintf_ex(scrollbuf, zfont, 72, 224, red, 0, "%-8s -%3d", game->get_name(), game->get_deaths()); else if(y==timeYPos) { if(game->get_timevalid() && !game->get_cheat()) textout_centre_ex(scrollbuf, zfont, time_str_med(game->get_time()), 128, 224, blue, 0); } } } if(f==112) // after subscreen has scrolled away { init_NES_mode(); loadpalset(9,pSprite(spPILE)); endingpal(); } if(f&1) { blit(scrollbuf,scrollbuf,0,1,0,0,256,232); } blit(scrollbuf,framebuf,0,0,0,0,256,224); advanceframe(true); if(Quit) { return; } load_control_state(); rSbtn(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QStringList args = app.arguments(); if (args.count() < 2) { printUsage(); return 1; } QString configPath = "./"; if (app.arguments().contains("-c")) { int const index = app.arguments().indexOf("-c"); if (app.arguments().count() <= index + 1) { printUsage(); return 1; } configPath = app.arguments()[index + 1]; if (configPath.right(1) != "/") { configPath += "/"; } } QString startDirPath = QDir::currentPath(); if (app.arguments().contains("-d")) { int const index = app.arguments().indexOf("-d"); if (app.arguments().count() <= index + 1) { printUsage(); return 1; } startDirPath = app.arguments()[index + 1]; } if (startDirPath.right(1) != "/") { startDirPath += "/"; } #ifdef Q_WS_QWS QWSServer * const server = QWSServer::instance(); if (server) { server->setCursorVisible(false); } #endif trikControl::Brick brick(*app.thread(), configPath, startDirPath); trikScriptRunner::TrikScriptRunner runner(brick, startDirPath); QObject::connect(&runner, SIGNAL(completed(QString)), &app, SLOT(quit())); if (app.arguments().contains("-s")) { runner.run(args[app.arguments().indexOf("-s") + 1]); } else { args.removeAll("-qws"); if (args.contains("-c")) { args.removeAt(args.indexOf("-c") + 1); args.removeAll("-c"); } if (args.contains("-d")) { args.removeAt(args.indexOf("-d") + 1); args.removeAll("-d"); } if (args.count() != 2) { printUsage(); return 1; } runner.run(trikKernel::FileUtils::readFromFile(args[1])); } return app.exec(); }
int main(int argc, char* argv[]) { double init_time, brick_time, lod_time; double start_time = 0; MPI_Init(&argc,&argv); int size,rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); if(rank==0) { start_time = MPI_Wtime(); } if(argc!=7 || strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0) { if(rank==0) PrintHelp(); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } char *endptr = NULL; /* Size of the volume {x,y,z} */ size_t *VOLUME = malloc(sizeof(size_t)*3); VOLUME[0]=(size_t)strtol(argv[1], &endptr, 10); VOLUME[1]=(size_t)strtol(argv[2], &endptr, 10); VOLUME[2]=(size_t)strtol(argv[3], &endptr, 10); /* Dimension of the brick excl. Ghostcells */ const size_t BRICKSIZE = (size_t)strtol(argv[4], &endptr, 10); if(BRICKSIZE<1) { printf("BRICKSIZE is smaller than 1!\n"); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } /* Size of ghost cells for later subtraction */ const size_t GHOSTCELLDIM = (size_t)strtol(argv[5], &endptr, 10); /* # bricks per dimension */ size_t bricks_per_dimension[3]; /* number of bricks? */ size_t numberofbricks = NBricks(VOLUME, BRICKSIZE, bricks_per_dimension); if(numberofbricks == 0) { printf("ERROR determining number of bricks!\n"); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } /* INITIALIZATION */ size_t *myoffsets = malloc(sizeof(size_t)*3); size_t mybricks; size_t bricks[size]; size_t starting_brick[size]; size_t mystart; size_t GBSIZE=BRICKSIZE+2*GHOSTCELLDIM; if(Init_MPI(rank, size, &mybricks, &mystart, myoffsets, bricks, starting_brick, numberofbricks, VOLUME, BRICKSIZE) != 0) { printf("ERROR @ Init_MPI\n"); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } if(rank==0) { init_time = MPI_Wtime(); init_time -= start_time; start_time = MPI_Wtime(); } /* BRICKING START */ /* input file stream */ MPI_File fpi; int err; err = MPI_File_open(MPI_COMM_WORLD, argv[6], MPI_MODE_RDONLY, MPI_INFO_NULL, &fpi); if(err) { printf("ERROR opening file %s\n", argv[6]); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } /* output file stream */ MPI_File fpo; char fn[256]; sprintf(fn, "b_%zu_%zu_%zu_%zu^3.raw", VOLUME[0], VOLUME[1], VOLUME[2], GBSIZE); err = MPI_File_open(MPI_COMM_WORLD, fn, MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fpo); if(err) { printf("ERROR opening file %s\n", fn); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } /* read from input file, reorganize data and write into output file */ if(brick(fpi, fpo, mystart, mybricks, GBSIZE, GHOSTCELLDIM, BRICKSIZE, VOLUME, bricks_per_dimension) != 0) { printf("ERROR @ Rank %d: brick() failed \n", rank); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } MPI_File_close(&fpi); MPI_File_close(&fpo); if(rank==0) { brick_time = MPI_Wtime(); brick_time -= start_time; start_time = MPI_Wtime(); } /* END OF BRICKING */ size_t lod = 1; /* TODO set finished correct */ bool finished = false; while(!finished) { /* read from */ MPI_File fin; MPI_File fout; if(lod==1) { err = MPI_File_open(MPI_COMM_WORLD, fn, MPI_MODE_RDONLY, MPI_INFO_NULL, &fin); if(err) { printf("Rank %d: ERROR opening file %s\n", rank, fn); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } } else { char filename_read[256]; sprintf(filename_read, "xmulti_%zu.raw", lod-1); err = MPI_File_open(MPI_COMM_WORLD, filename_read, MPI_MODE_RDONLY, MPI_INFO_NULL, &fin); if(err) { printf("Rank %d: ERROR opening file %s\n", rank, fn); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } } /* write to */ char filename_write[256]; sprintf(filename_write, "xmulti_%zu.raw", lod); err = MPI_File_open(MPI_COMM_WORLD, filename_write, MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fout); if(err) { printf("Rank %d: ERROR opening file %s\n", rank, filename_write); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); } size_t new_no_b=0; size_t *new_bpd = malloc(sizeof(size_t)*3); new_bpd[0] = 0; new_bpd[1] = 0; new_bpd[2] = 0; size_t *old_bpd = malloc(sizeof(size_t)*3); old_bpd[0] = bricks_per_dimension[0]; old_bpd[1] = bricks_per_dimension[1]; old_bpd[2] = bricks_per_dimension[2]; for(size_t i=0; i<lod; i++) { new_no_b = NBricks(old_bpd, 2, new_bpd); old_bpd[0] = new_bpd[0]; old_bpd[1] = new_bpd[1]; old_bpd[2] = new_bpd[2]; } /* Calculate next LOD */ if(GetNewLOD(fin, fout, bricks_per_dimension, new_bpd, new_no_b,BRICKSIZE,GHOSTCELLDIM,lod,rank,size) != 0) { printf("ERROR: Rank %d @ GetNewLOD()\n",rank); MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE); } lod++; free(new_bpd); free(old_bpd); MPI_File_close(&fin); MPI_File_close(&fout); if(new_no_b<2) finished=true; } if(rank==0) { lod_time = MPI_Wtime(); lod_time -= start_time; printf("Initialization: %1.3f || Bricking: %1.3f || LOD: %1.3f\n",init_time, brick_time, lod_time); } free(myoffsets); free(VOLUME); MPI_Finalize(); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { qsrand(QDateTime::currentMSecsSinceEpoch()); QApplication app(argc, argv); QStringList args = app.arguments(); if (args.count() < 2) { printUsage(); return 1; } QString configPath = "./"; if (app.arguments().contains("-c")) { const int index = app.arguments().indexOf("-c"); if (app.arguments().count() <= index + 1) { printUsage(); return 1; } configPath = app.arguments()[index + 1]; if (configPath.right(1) != "/") { configPath += "/"; } } QString startDirPath = QDir::currentPath(); if (app.arguments().contains("-d")) { const int index = app.arguments().indexOf("-d"); if (app.arguments().count() <= index + 1) { printUsage(); return 1; } startDirPath = app.arguments()[index + 1]; } if (startDirPath.right(1) != "/") { startDirPath += "/"; } trikKernel::coreDumping::initCoreDumping(startDirPath); #ifdef Q_WS_QWS QWSServer * const server = QWSServer::instance(); if (server) { server->setCursorVisible(false); } #endif trikKernel::LoggingHelper loggingHelper(startDirPath); Q_UNUSED(loggingHelper); QLOG_INFO() << "TrikRun started"; QScopedPointer<trikControl::BrickInterface> brick(trikControl::BrickFactory::create(configPath, startDirPath)); trikKernel::Configurer configurer(configPath + "/system-config.xml", configPath + "/model-config.xml"); QScopedPointer<trikNetwork::GamepadInterface> gamepad(trikNetwork::GamepadFactory::create(configurer)); QScopedPointer<trikNetwork::MailboxInterface> mailbox(trikNetwork::MailboxFactory::create(configurer)); trikScriptRunner::TrikScriptRunner runner(*brick, mailbox.data(), gamepad.data(), startDirPath); QObject::connect(&runner, SIGNAL(completed(QString, int)), &app, SLOT(quit())); if (app.arguments().contains("-s")) { runner.run(args[app.arguments().indexOf("-s") + 1]); } else { args.removeAll("-qws"); if (args.contains("-c")) { args.removeAt(args.indexOf("-c") + 1); args.removeAll("-c"); } if (args.contains("-d")) { args.removeAt(args.indexOf("-d") + 1); args.removeAll("-d"); } if (args.count() != 2) { printUsage(); return 1; } runner.run(trikKernel::FileUtils::readFromFile(args[1])); } return app.exec(); }