示例#1
0
 void KMBC0::setup()
 {
     lg::debug(TAG, "Setting up MBC0\n");
     
     assert(cart()->size());
     
     u16i len = cart()->size();
     for(u16i i = 0; i < len; i++)
     {
         mem()->wb(i, (*cart())[i]);
     }
     
     mem()->intercept(0, len, KMemory::WRITER_READ_ONLY);
 }
示例#2
0
      void CartController::handle_get(web::http::http_request request)
      {

        web::http::http_response response;

        granada::http::session::MapSession simple_session(request,response);
        business::Cart cart(&simple_session);

        auto paths = uri::split_path(uri::decode(request.relative_uri().path()));
        if (!paths.empty()){
          std::string name = utility::conversions::to_utf8string(paths[0]);

          if(name == "count"){

            // returns the number of products added to the cart.
            int count = cart.Count();
            response.set_body("{\"count\":\"" + std::to_string(count) + "\"}");

          }else if (name == "list"){

            // returns a list with the products added to the cart but only
            // if the user is logged in.
            if (simple_session.roles()->Is("USER")){
              response.set_body("{\"data\":" + cart.List() + "}");
            }else{
              response.set_body("{\"data\":[]}");
            }
          }
        }

        response.set_status_code(status_codes::OK);
        response.headers().add(U("Content-Type"), U("text/json; charset=utf-8"));

        request.reply(response);
      }
示例#3
0
void Nes_Emu::close()
{
	if ( cart() )
	{
		emu.close();
		private_cart.clear();
	}
}
示例#4
0
void Nes_Emu::reset( bool full_reset, bool erase_battery_ram )
{
    require( cart() );

    clear_sound_buf();
    set_timestamp( 0 );
    emu.reset( full_reset, erase_battery_ram );
}
示例#5
0
 int shoppingOffers(vector<int>& price, vector<vector<int>>& special, vector<int>& needs) {
     int len = price.size(), min_cost = dotproduct(price, needs);
     
     for (auto offer : special) sums.push_back(dotproduct(price, offer));
         
     vector<int> cart(len, 0);
     int cost = min_cost;
     dfs(min_cost, cost, cart, needs, special, price);
     return min_cost;
 }
示例#6
0
void Nes_Emu::set_equalizer( equalizer_t const& eq )
{
	equalizer_ = eq;
	if ( cart() )
	{
		blip_eq_t blip_eq( eq.treble, 0, sound_buf->sample_rate() );
		emu.impl->apu.treble_eq( blip_eq );
		emu.mapper->set_treble( blip_eq );
		sound_buf->bass_freq( equalizer_.bass );
	}
}
示例#7
0
/*
 * The main function for this NES emulator.
 * Needs a path to a NES game in order to run the game.
 */
int main(int argc, char *argv[])
{
	if (argc != NUM_ARGS) {
		std::cerr << "Invalid number of arguments. Please include a ROM file." 
			<< endl;
		return 1;
	}
	Cartridge cart(argv[1]);
	Console console(&cart);
	console.get_cpu()->set_PC(0xC000);
	console.power_on();
}
示例#8
0
文件: CountStat.c 项目: konsP/anuchem
int main(int argc, char *argv[]) {
    if (argc<2) {printf("Please specify output file.\n"); exit(1);} else strcpy(fname,argv[1]);

    // TALLY X PER CONTRACTED INTEGRAL
    init();
    while (!feof(fptr)) {
        read;
        w=(l+1)*(l+1)*cart(a)*cart(b);
        tally();
    }
    printstat("X statistics per CONTRACTED INTEGRAL");

    // TALLY X PER INTPACK CALL
    init(); w=1;
    while (!feof(fptr)) {
        read;
        tally();
    }
    printstat("X statistics per INTPACK CALL");

    printf("Total X = %e\n",S);
}
示例#9
0
int main( int iCount, char ** pchArgs )
{
  // Create an instance of the cgi script but DO NOT close the http header
  cgiScript script( "text/html", false);
  cgiTemplates htemplate;
  htemplate.load("Templates/ShoppingCart.html");
  
  // Create an instance of the shopping cart.
  uiShoppingCart cart( script );
  script.closeHeader();  
  
  // See what the user wants.
  cgiInput & args = script.ClientArguments (); 
  
  if( args.count("action") )
  {
    if( args["action"] == "add" )
    {
      string productId = args["id"].c_str();
      cart.AddProduct( productId );
    }
    else if( args["action"] == "remove" )
    {
      string productId = args["id"].c_str();
      cart.RemoveProduct( productId );
      script << "<script type='text/javascript'>"
                "var loco=parent.location;"
                "parent.location = loco"
                "</script>";
    }    
  }  
  cart.stats();
  
  ocString itemCount;
  itemCount.append(cart.items);
  if( cart.items != 1 )
  {
    itemCount += " items";
  }
  else
  {
    itemCount += " item";
  }  
  ocString qs = "?crtid=";
  qs.append(cart.Id);
  ocString content = htemplate. getUnparsedHtml();
  script << content. replace("O Items", itemCount.c_str())
                   . replace("$url",CHECKOUT)
                   . replace("?qs",qs.c_str() );
  return 0;
}
示例#10
0
static Eigen::Vector3f cartesian_vector(const char dim) {
  Eigen::Vector3f cart(0, 0, 0);
  switch (dim) {
    case 'x':
      cart = Eigen::Vector3f::UnitX();
      break;
    case 'y':
      cart = Eigen::Vector3f::UnitY();
      break;
    case 'z':
      cart = Eigen::Vector3f::UnitZ();
      break;
      throw std::runtime_error("Dimension unknown");
  }
  return cart;
}
int test_main(int argc, char* argv[])
{
  mpi::environment  env;
  mpi::communicator world;
  
  if (world.size() != 24)  return -1;
  mpi::cartesian_dimension dims[] = {cd(2, true), cd(3,true), cd(4,true)};
  mpi::cartesian_communicator cart(world, mpi::cartesian_topology(dims));
  for (int r = 0; r < cart.size(); ++r) {
    cart.barrier();
    if (r == cart.rank()) {
      std::vector<int> c = cart.coordinates(r);
      std::cout << "rk :" << r << " coords: " 
                << c[0] << ' ' << c[1] << ' ' << c[2] << '\n';
    }
  }
  return 0;
}
示例#12
0
      void CartController::handle_put(web::http::http_request request)
      {
        web::http::http_response response;
        granada::http::session::MapSession simple_session(request,response);
        business::Cart cart(&simple_session);

        std::string product_id = "";
        int quantity = 0;
        std::string body = request.extract_utf8string(true).get();
        std::unordered_map<std::string,std::string> parsed_query = granada::http::parser::ParseQueryString(body);

        auto it = parsed_query.find("id");
        if (it != parsed_query.end()){
          product_id.assign(it->second);
        }

        auto it2 = parsed_query.find("quantity");
        if (it2 != parsed_query.end()){
          quantity = std::atoi(it2->second.c_str());
        }

        int count = 0;
        if (product_id.empty()){

          // invalid product id, do not add the product,
          // just return the number of products already added.
          count = cart.Count();

        }else{

          // adds a product to the cart.
          count = cart.Add(product_id,quantity);

        }

        response.set_status_code(status_codes::OK);
        response.headers().add(U("Content-Type"), U("text/json; charset=utf-8"));
        response.set_body("{\"count\":\"" + std::to_string(count) + "\"}");
        request.reply(response);
      }
示例#13
0
void ArmMap::learn(const YVector &head, const YVector &arm)
{
	// implement here learning
	// convert head to x,y,z
	_bottle.reset();
		
	_headKinematics.update(head);
	const Y3DVector &cart = _headKinematics.fixationPolar();

	/////////// prepare data
	// first three elements are cart position
	int i;
	for(i = 1; i <= 3; i++)
		_bottle.writeFloat(cart(i));
	
	// prepate data -- then there comes the arm position  
	for(i = 1; i <= 3; i++)
		_bottle.writeFloat(arm(i));
	
	_outPortRemoteLearn.Content() = _bottle;
	_outPortRemoteLearn.Write(1);
}
示例#14
0
void MainWindow::createActions() {
  printAct = new QAction(QIcon(":/images/print.png"), tr("&Print..."), this);
  //   printAct->setShortcut(QKeySequence::Print);
  printAct->setStatusTip(tr("Print the document"));
  connect(printAct, SIGNAL(triggered()), this, SLOT(printFile()));
  
  // Added by AiO to Open a new file
  openAct = new QAction(tr("&Open"), this);
  openAct->setShortcut(Qt::Key_O | Qt::CTRL);
  openAct->setStatusTip(tr("Open a new file"));
  connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
  
  saveAsAct = new QAction(tr("Save &As..."), this);
  //   saveAsAct->setShortcut(QKeySequence::SaveAs);
  saveAsAct->setStatusTip(tr("Save the document under a new name"));
  connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));

  exitAct = new QAction(tr("E&xit"), this);
  exitAct->setShortcut(Qt::Key_Escape);
  exitAct->setStatusTip(tr("Exit the application"));
  connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

  normalAct = new QAction(QIcon(":/images/normalView.png"), tr("Normal view"), this);
  normalAct->setCheckable(true);
  normalAct->setChecked(true);
  normalAct->setShortcut(Qt::Key_N);
  normalAct->setStatusTip(tr("Normal view"));
  connect(normalAct, SIGNAL(triggered()), this, SLOT(normal()));

  polarAct = new QAction(QIcon(":/images/polar.png"), tr("Polar fish eye"), this);
  polarAct->setCheckable(true);
  polarAct->setShortcut(Qt::Key_P | Qt::CTRL);
  polarAct->setStatusTip(tr("Polar fish eye"));
  connect(polarAct, SIGNAL(triggered()), this, SLOT(polar()));

  polarFixedAct = new QAction(QIcon(":/images/fixedPolar.png"), tr("Fixed radius polar fish eye"), this);
  polarFixedAct->setCheckable(true);
  polarFixedAct->setShortcut(Qt::Key_P);
  polarFixedAct->setStatusTip(tr("Fixed radius polar fish eye"));
  connect(polarFixedAct, SIGNAL(triggered()), this, SLOT(polarFixed()));

  cartAct = new QAction(QIcon(":/images/cartesian.png"), tr("Cartesian fish eye"), this);
  cartAct->setCheckable(true);
  cartAct->setShortcut(Qt::Key_C | Qt::CTRL);
  cartAct->setStatusTip(tr("Cartesian fish eye"));
  connect(cartAct, SIGNAL(triggered()), this, SLOT(cart()));

  cartFixedAct = new QAction(QIcon(":/images/fixedCartesian.png"), tr("Fixed radius cartesian fish eye"), this);
  cartFixedAct->setCheckable(true);
  cartFixedAct->setShortcut(Qt::Key_C);
  cartFixedAct->setStatusTip(tr("Fixed radius cartesian fish eye"));
  connect(cartFixedAct, SIGNAL(triggered()), this, SLOT(cartFixed()));

  showLabelsAct = new QAction(QIcon(":/images/labelEdges.png"), tr("Display edge labels"), this);
  showLabelsAct->setCheckable(true);
  showLabelsAct->setStatusTip(tr("Display edge labels"));
  connect(showLabelsAct, SIGNAL(triggered()), this, SLOT(showLabels()));
  //   connect(showLabelsAct, SIGNAL(toggled(bool)), this, SLOT(toggleShowLabels(bool)));

  zoomInAct = new QAction(QIcon(":/images/zoomIn.png"), tr("Zoom in"), this);
  zoomInAct->setShortcut(Qt::Key_Plus);
  zoomInAct->setStatusTip(tr("Zoom in"));
  connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));

  zoomOutAct = new QAction(QIcon(":/images/zoomOut.png"), tr("Zoom out"), this);
  zoomOutAct->setShortcut(Qt::Key_Minus);
  zoomOutAct->setStatusTip(tr("Zoom out"));
  connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));

  zoomNormalAct = new QAction(QIcon(":/images/zoomNormal.png"), tr("Zoom normal"), this);
  zoomNormalAct->setShortcut(Qt::Key_0);
  zoomNormalAct->setStatusTip(tr("Zoom normal (100%)"));
  connect(zoomNormalAct, SIGNAL(triggered()), this, SLOT(zoomNormal()));

  fitAllAct = new QAction(QIcon(":/images/fitAll.png"), tr("Fit all graph"), this);
  fitAllAct->setShortcut(Qt::Key_M);
  fitAllAct->setStatusTip(tr("Fit all graph"));
  connect(fitAllAct, SIGNAL(triggered()), this, SLOT(fitAll()));

  positOriginAct = new QAction(QIcon(":/images/positOrigin.png"), tr("Position on origin"), this);
  positOriginAct->setShortcut(Qt::Key_O);
  positOriginAct->setStatusTip(tr("Position on origin"));
  connect(positOriginAct, SIGNAL(triggered()), this, SLOT(positOrigin()));

  easyPanAct = new QAction(tr("Easy graph panning"), this);
  easyPanAct->setCheckable(true);
  easyPanAct->setStatusTip(tr("Easy graph panning"));
  connect(easyPanAct, SIGNAL(triggered()), this, SLOT(easyPan()));

  helpAct = new QAction(tr("Help"), this);
  helpAct->setShortcut(Qt::Key_F1);
  helpAct->setStatusTip(tr("Display help"));
  connect(helpAct, SIGNAL(triggered()), this /*qApp*/, SLOT(help()));

  aboutAct = new QAction(tr("&About..."), this);
  aboutAct->setStatusTip(tr("Show the About box"));
  connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
  
  //Added by AiO  new action for search window
  searchAct = new QAction(tr("&Search"), this);
  searchAct->setShortcut(Qt::Key_F5);
  searchAct->setStatusTip(tr("Search F5"));
  connect(searchAct, SIGNAL(triggered()), this, SLOT(showSearch()));

}