示例#1
0
文件: scsi.c 项目: robertsami/proj
int scsi_init(struct scsi_ifc *ifc) {
    int rc;
    scsi = kzalloc(sizeof(struct scsi_dev));
    if (scsi == NULL)
        return ERR_NO_MEM;

    /* Copy the driver interface */
    scsi->driver = ifc->driver;
    scsi->read = ifc->read;
    scsi->write = ifc->write;
    spinlock_init(&scsi->lock);

    rc = scsi_read_capacity();
    DEBUG("Reading device capacity parameters %s", DEBUG_STATUS(rc));

    if(rc < 0) {
        kfree(scsi);
        return -1;
    }

    DEBUG("Device block size %d, block count %d",
          scsi->block_size, scsi->total_block_count);

    scsi->op_status = OPERATING;

    return 0;
}
示例#2
0
/**
 * Initialize compass module.
 */
void init_compass(void)
{
	DEBUG_STATUS(DEBUG_INIT_COMPASS);

	compass_set(COMPASS_RAMP);
	init_single_compass();
	compass_set(COMPASS_FLAT);
	init_single_compass();

//	for(ms_timer = 0; ms_timer < (40/MS_TIMER_PER););	// Wait for compass to stabilize
	while(! compass_read(&compass_north));

	DEBUG_CLEAR_STATUS();
}
示例#3
0
	int main(int argc, char* argv[])
#endif
{
	DEBUG_STATUS("started main");

	FileSystem filesys(argv[0]);
	setupPHYSFS();

	DEBUG_STATUS("physfs initialised");

	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);

	DEBUG_STATUS("SDL initialised");

	atexit(SDL_Quit);
	srand(SDL_GetTicks());
	// Default is OpenGL and false
	// choose renderer
	RenderManager *rmanager = 0;
	SoundManager *smanager = 0;


	// Test Version Startup Warning
	#ifdef TEST_VERSION
	struct tm* ptm;
	time_t time = std::time(0);
	ptm = gmtime ( &time );

	if( ptm->tm_year > (2014-1900) || ptm->tm_mon >= 4 )
	{
		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "TEST VERISON OUTDATED",
									(std::string("This is a test version of ") + AppTitle + " which expired on "
									"1.04.2014. Please visit blobby.sourceforge.net for a newer version").c_str(), 0);
		return -1;
	}

	SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "TEST VERISON WARNING",
								(std::string("This is a test version of ") + AppTitle + " for testing only.\n"
								"It might be unstable and/or incompatible to the current release. "
								"Use of this version is limited to 1.04.2014.\nUntil then, "
								"the final version will most likely be released and you should update to that one.\n"
								"Visit blobby.sourceforge.net for more information or bug reporting.").c_str(), 0);
	#endif

	try
	{
		UserConfig gameConfig;
		gameConfig.loadFile("config.xml");

		TextManager::createTextManager(gameConfig.getString("language"));

		if(gameConfig.getString("device") == "SDL")
			rmanager = RenderManager::createRenderManagerSDL();
		/*else if (gameConfig.getString("device") == "GP2X")
			rmanager = RenderManager::createRenderManagerGP2X();*/
#ifndef __ANDROID__
	#ifndef __APPLE__
		else if (gameConfig.getString("device") == "OpenGL")
			rmanager = RenderManager::createRenderManagerGL2D();
		else
		{
			std::cerr << "Warning: Unknown renderer selected!";
			std::cerr << "Falling back to OpenGL" << std::endl;
			rmanager = RenderManager::createRenderManagerGL2D();
		}
	#else
		#if MAC_OS_X
			else if (gameConfig.getString("device") == "OpenGL")
				rmanager = RenderManager::createRenderManagerGL2D();
			else
			{
				std::cerr << "Warning: Unknown renderer selected!";
				std::cerr << "Falling back to OpenGL" << std::endl;
				rmanager = RenderManager::createRenderManagerGL2D();
			}
		#endif
	#endif
#endif

		// fullscreen?
		if(gameConfig.getString("fullscreen") == "true")
			rmanager->init(BASE_RESOLUTION_X, BASE_RESOLUTION_Y, true);
		else
			rmanager->init(BASE_RESOLUTION_X, BASE_RESOLUTION_Y, false);

		if(gameConfig.getString("show_shadow") == "true")
			rmanager->showShadow(true);
		else
			rmanager->showShadow(false);

		SpeedController scontroller(gameConfig.getFloat("gamefps"));
		SpeedController::setMainInstance(&scontroller);
		scontroller.setDrawFPS(gameConfig.getBool("showfps"));

		smanager = SoundManager::createSoundManager();
		smanager->init();
		smanager->setVolume(gameConfig.getFloat("global_volume"));
		smanager->setMute(gameConfig.getBool("mute"));
		/// \todo play sound is misleading. what we actually want to do is load the sound
		smanager->playSound("sounds/bums.wav", 0.0);
		smanager->playSound("sounds/pfiff.wav", 0.0);

		std::string bg = std::string("backgrounds/") + gameConfig.getString("background");
		if ( FileSystem::getSingleton().exists(bg) )
			rmanager->setBackground(bg);

		InputManager* inputmgr = InputManager::createInputManager();
		int running = 1;

		DEBUG_STATUS("starting mainloop");

		while (running)
		{
			inputmgr->updateInput();
			running = inputmgr->running();

			IMGUI::getSingleton().begin();
			State::step();
			rmanager = &RenderManager::getSingleton(); //RenderManager may change
			//draw FPS:
			static int lastfps = 0;
			if (scontroller.getDrawFPS())
			{
				// We need to ensure that the title bar is only set
				// when the framerate changed, because setting the
				// title can ne quite resource intensive on some
				// windows manager, like for example metacity.
				int newfps = scontroller.getFPS();
				if (newfps != lastfps)
				{
					std::stringstream tmp;
					tmp << AppTitle << "	FPS: " << newfps;
					rmanager->setTitle(tmp.str());
				}
				lastfps = newfps;
			}
			// Dirty workarround for hiding fps in title
			if (!scontroller.getDrawFPS() && (lastfps != -1))
			{
				std::stringstream tmp;
				tmp << AppTitle;
				rmanager->setTitle(tmp.str());

				lastfps = -1;
			}

			if (!scontroller.doFramedrop())
			{
				rmanager->draw();
				IMGUI::getSingleton().end();
				BloodManager::getSingleton().step();
				rmanager->refresh();
			}
			scontroller.update();
		}
	}