예제 #1
0
파일: run.c 프로젝트: samjohnduke/DragonOS
int
main(void)
{
	
	//initialise the graphics
	GraphicsInit();
	
	//initialise eventedness
	EventInit();
	
	//controller initialisation
	ControllerInit();	
	
	TCCR1B |= (1 << WGM12);

	TIMSK1 = (1 << OCIE1A);
	sei();
	
	OCR1A   = 200;
	
	TCCR1B |= (1 << CS10);
	
	//initialise the users game code
	setup();
	
	//This is the event loop. It should be always spinning. 
	while(1) {	
		loop();
		UpdateBtnState();
	}
	
}
예제 #2
0
int __stdcall wWinMain( HINSTANCE hInstance, HINSTANCE, LPWSTR, int )
{
	// Start networkserver first.
	Game* game = new Game();
	ConnectionListener* cl = new ConnectionListener(10000, game);
	cl->Start();

	MaloW::ClearDebug();
	if ( !GraphicsInit(hInstance) )
		MaloW::Debug("Failed Creating Graphics Engine!");
#if defined(DEBUG) || defined(_DEBUG)
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	MaloW::Debug("(DEBUG): ModelViewer: Debug flag set to: _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF). ");
#ifdef INCLUDE_MODEL_VIEWER
	MaloW::Debug("(DEBUG): ModelViewer: vld.h included.");
#endif
#endif
	
	game->Play();

	game->Close(); 
	cl->Close();
	delete cl;
	delete game;

	FreeGraphics();
	return 0;
}
예제 #3
0
//Pre-written Draw Function
void Player_Gl_Window::draw() 
{
  // Upon setup of the window (or when Fl_Gl_Window->invalidate is called), 
  // the set of functions inside the if block are executed.
  if (!valid()) 
  {
    GraphicsInit();   
  }

  // Redisplay the screen then put the proper buffer on the screen.
  Redisplay();
}
예제 #4
0
파일: main.cpp 프로젝트: Crant/Game_Project
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int) 
{
	MaloW::ClearDebug();
#ifdef INCLUDE_MODEL_VIEWER
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	MaloW::Debug("(DEBUG): Client: Debug flag set to: _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF). ");
	MaloW::Debug("(DEBUG): Client: vld.h included.");
#endif

	if ( !GraphicsInit(hInstance) )
	{
		MaloW::Debug("Failed Initializing Graphics!");
		return 1;
	}
	if ( !PlayerSettingsInit() )
	{
		MaloW::Debug("Failed Initializing PlayerSettings!");
		return 1;
	}
	AudioManager* am = AudioManager::GetInstance();

	// IMPLEMENT MAIN PROGRAM HERE.
	MainMenu* menu = new MainMenu();
	menu->Init();
	menu->Run();
	SAFE_DELETE(menu);

	am->ReleaseInstance();
	am = NULL;

	// Free Graphics
	FreeGraphics();

	// Save and Free Settings
	SavePlayerSettings();
	FreePlayerSettings();
	//_CrtDumpMemoryLeaks();
	MaloW::Debug("Quit Game.");
	return 0;
}
JNIEXPORT void JNICALL Java_cookbook_gles_GLESNativeLib_init( JNIEnv *env, jobject obj, jstring FilePath )
{
	setenv( "FILESYSTEM", env->GetStringUTFChars( FilePath, NULL ), 1 );
	GraphicsInit();
}
예제 #6
0
int main()
{
    InitCPU();
    InitEmulator();
    GraphicsInit();

#ifndef SDL
    //setvbuf(stdout, NULL, _IONBF, 0);
    printf("Try the following commands:\n");
    printf("'2 3 + .'\n");
    printf("'mountb bank-ov d@balance d.'\n");
    printf("'mounta PM-OV PORT-PIC'\n");
    printf("'mounta music-OV 141 cscr>ega'\n");
    printf("'mounta u-b'\n");
    printf("'mountb\n 1234 mercator-gen'\n");
    printf("'SCI-OV 32 .READINGS'\n"); // 32 is the planet class

    EnableInterpreter();
    //FillKeyboardBufferString("STARTER\nMOUNTA\nLDFONTS\nMOUNTB\n?EGA ON\nSET.COLORS\nLOAD-CO\nSETDBUF\n>DISPLAY\n");
    FillKeyboardBufferString("STARTER\n");
    Continue();
    //FillKeyboardBufferString("RELAXTIME ON\n");
    //Continue();

    FillKeyboardBufferString("MOUNTA\nLDFONTS\n");
    Continue();

    //FillKeyboardBufferString("RELAXTIME OFF\n");
    //Continue();
    FillKeyboardBufferString("GAME-OV\nMOUNTB\n?EGA ON\nGDE\n");
    Continue();

#endif

// Load Compound
/*
FillKeyboardBufferString("130 FILE# ! 40 RECORD# !\n");
Continue();
FillKeyboardBufferString("SCI-OV WE696 @ .\n");
Continue();
*/
/*
FillKeyboardBufferString("SCI-OV WE696 @ .\n");
Continue();
*/
/*
// planet data earth
FillKeyboardBufferString("32 FILE# ! 18 RECORD# !\n");
Continue();

// Load mass
FillKeyboardBufferString("SCI-OV WE676 @ .\n");
Continue();
*/
/*
FillKeyboardBufferString("(SYSTEM) 1.5@ >C+S @INST-SPECIES\n");
Continue();
*/
/*
// Load one element from a starsystem
FillKeyboardBufferString("4195 0 >C+S @INST-SPECIES\n");
Continue();
*/



    /*
    // default interrupt vector
    Write16Long(0, 0x1C*4+2, 0xF000);
    Write16Long(0, 0x1C*4+0, 0x1280);
    */
    enum RETURNCODE ret;
    do
    {
       ret = Step();
       if (ret == INPUT)
       {
            // 1. either low byte ascii, high byte 0
            // 2. or low byte scancode, high byte 1
#ifdef SDL
            FillKeyboardBufferKey(GraphicsGetChar());
#else
            char input[256];
            input[0] = 0;
            printf("input: ");
            fflush(stdout);
            int n = 0;
            int c;
            do {
                c = getchar();
                input[n] = c;
                input[n+1] = 0;
                n++;
            } while(c != '\n');
            input[n+1] = 0;
            FillKeyboardBufferString(input);
#endif
        }

    } while (ret == OK || ret == INPUT);

    //GraphicsWait();
    GraphicsQuit();
    return 0;
}
int main()
{
  InitCPU();
  InitEmulator();
  GraphicsInit();
  EnableInterpreter();
  Continue();

  FillKeyboardBufferString("CCLR\n");
  Continue();
  FillKeyboardBufferString("STARTER\n");
  Continue();
  FillKeyboardBufferString("MOUNTA\nLDFONTS\n");
  Continue();
  FillKeyboardBufferString("GAME-OV\nMOUNTB\n?EGA ON\nGDE\n");
  Continue();

  int idx = 0;
  for(;;)
  {
      if (planets[idx].species == -1) return 0;

      printf("=== Generate planet %i x=%3i y=%3i orbit=%i species=%i ===\n",
        idx,
        planets[idx].x,
        planets[idx].y,
        planets[idx].orbit,
        planets[idx].species
      );

    char str[1024];
/*
    sprintf(str, "CDEPTH .\n", planets[idx].seed);
    FillKeyboardBufferString(str);
    Continue();
*/
    sprintf(str, "%i GLOBALSEED !\n", planets[idx].seed);
    FillKeyboardBufferString(str);
    Continue();

    sprintf(str, "%i %i (SYSTEM) 1.5!\n",
      planets[idx].starsystemoffset&0xFFFF, planets[idx].starsystemoffset>>16
    );
    FillKeyboardBufferString(str);
    Continue();

    sprintf(str, "%i %i (PLANET) 1.5!\n",
      planets[idx].instanceoffset&0xFFFF, planets[idx].instanceoffset>>16
    );
    FillKeyboardBufferString(str);
    Continue();

    // 123 101 1 (ORBIT) 0x1dc1 0x6502
    // 123 101 2 (ORBIT) 0x1dae 0x6502
    // 123 101 3 (ORBIT) 0x1d9b 0x6502
    // 123 101 4 (ORBIT) 0x1d88 0x6502
    // 125 100 5 (ORBIT) 0x1d9b 0x6502
    // 123 101 6 (ORBIT) 0x1d75 0x6502
    // 123 101 7 (ORBIT) 0x1dd4 0x6502
    // 123 101 8 (ORBIT) 0x1de7 0x6502

    FillKeyboardBufferString("7541 25858 (ORBIT) 1.5!\n");
    Continue();

    sprintf(str, "(ORBIT) @>C+S %i INST-QTY !_3 ICLOSE\n", planets[idx].orbit);
    FillKeyboardBufferString(str);
    Continue();
    //PrintCStack();
    //exit(1);

/*
    FillKeyboardBufferString("(ORBIT) @>C+S INST-QTY @ . ICLOSE\n");
    Continue();

    still needs, because it doesn't work
    // random generator if (ORBIT)=0
    FillKeyboardBufferString("PLSET-OV (PLANET) @>C+S WEC62\n");
    Continue();
*/

    FillKeyboardBufferString("SET-PLANET\n");
    Continue();


/*
    GetAtmosphericActivity();
    exit(1);
*/
    //GetAtmosphere(idx);
    GetScienceAndSensorReading(idx);
    GetRegions();
/*
    FillKeyboardBufferString("MAPS- WF4F4\n");
    Continue();
    exit(1);
*/
/*
    FillKeyboardBufferString("?POPULA\n");
    Continue();
*/
/*
FillKeyboardBufferString("POPULA\n");
Continue();
*/

/*
    FillKeyboardBufferString("BIO\n");
    Continue();

    FillKeyboardBufferString("0. THIS-REGION 1.5!\n");
    Continue();

    FillKeyboardBufferString("POPULA\n");
    Continue();
    */
/*
    FillKeyboardBufferString("?POPULA\n");
    Continue();
*/
/*
    FillKeyboardBufferString("32 RECORD# ! 68 SAYIT\n");
    Continue();

    exit(1);

    FillKeyboardBufferString("DPART-OV WF166 OTHER-DELETE\n");
    Continue();
*/
/*
    FillKeyboardBufferString("SAVE-BUFFERS\n");
    Continue();
*/
/*
    FillKeyboardBufferString("POPULA\n");
    Continue();
    */
/*
    FillKeyboardBufferString("0 RECORD# !\n");
    Continue();

    FillKeyboardBufferString("OTHER-PAR\n"); // LP-OV
    Continue();
*/
    //exit(1);

    idx++;
  }
  return 0;
}
예제 #8
0
int main(int argc, char *argv[])
{
	int i;
	int loaded = 0;

	printf("C-Dogs SDL Editor\n");

	debug(D_NORMAL, "Initialising SDL...\n");
	if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO) != 0)
	{
		printf("Failed to start SDL!\n");
		return -1;
	}
	SDL_EnableUNICODE(SDL_ENABLE);

	printf("Data directory:\t\t%s\n",	GetDataFilePath(""));
	printf("Config directory:\t%s\n\n",	GetConfigFilePath(""));

	EditorBrushInit(&brush);

	ConfigLoadDefault(&gConfig);
	ConfigLoad(&gConfig, GetConfigFilePath(CONFIG_FILE));
	gConfig.Graphics.IsEditor = 1;
	if (!PicManagerTryInit(
		&gPicManager, "graphics/cdogs.px", "graphics/cdogs2.px"))
	{
		exit(0);
	}
	memcpy(origPalette, gPicManager.palette, sizeof origPalette);
	BuildTranslationTables(gPicManager.palette);
	TextManagerInit(&gTextManager, GetDataFilePath("graphics/font.px"));
	GraphicsInit(&gGraphicsDevice);
	// Hardcode config settings
	gConfig.Graphics.ScaleMode = SCALE_MODE_NN;
	gConfig.Graphics.ScaleFactor = 2;
	gConfig.Graphics.Res.x = 400;
	gConfig.Graphics.Res.y = 300;
	GraphicsInitialize(
		&gGraphicsDevice, &gConfig.Graphics, gPicManager.palette, 0);
	if (!gGraphicsDevice.IsInitialized)
	{
		printf("Video didn't init!\n");
		exit(EXIT_FAILURE);
	}
	TextManagerGenerateOldPics(&gTextManager, &gGraphicsDevice);
	PicManagerLoadDir(&gPicManager, GetDataFilePath("graphics"));

	BulletInitialize();
	WeaponInitialize(&gGunDescriptions, GetDataFilePath("guns.json"));
	CampaignInit(&gCampaign);
	MissionInit(&lastMission);
	MissionInit(&currentMission);

	PlayerDataInitialize();
	MapInit(&gMap);

	// initialise UI collections
	// Note: must do this after text init since positions depend on text height
	sObjs = CreateMainObjs(&gCampaign, &brush, Vec2iNew(320, 240));
	memset(&sDrawObjs, 0, sizeof sDrawObjs);
	DrawBufferInit(&sDrawBuffer, Vec2iNew(X_TILES, Y_TILES), &gGraphicsDevice);

	// Reset campaign (graphics init may have created dummy campaigns)
	CampaignSettingTerminate(&gCampaign.Setting);
	CampaignSettingInit(&gCampaign.Setting);

	EventInit(&gEventHandlers, NULL, false);

	for (i = 1; i < argc; i++)
	{
		if (!loaded)
		{
			debug(D_NORMAL, "Loading map %s\n", argv[i]);
			memset(lastFile, 0, sizeof(lastFile));
			strncpy(lastFile, argv[i], sizeof(lastFile) - 1);
			if (strchr(lastFile, '.') == NULL &&
				sizeof lastFile - strlen(lastFile) > 3)
			{
				strcat(lastFile, ".CPN");
			}
			if (MapNewLoad(lastFile, &gCampaign.Setting) == 0)
			{
				loaded = 1;
			}
			debug(D_NORMAL, "Loaded map %s\n", argv[i]);
		}
	}

	debug(D_NORMAL, "Starting editor\n");
	EditCampaign();

	MapTerminate(&gMap);
	WeaponTerminate(&gGunDescriptions);
	CampaignTerminate(&gCampaign);
	MissionTerminate(&lastMission);
	MissionTerminate(&currentMission);

	DrawBufferTerminate(&sDrawBuffer);
	GraphicsTerminate(&gGraphicsDevice);
	PicManagerTerminate(&gPicManager);
	TextManagerTerminate(&gTextManager);

	UIObjectDestroy(sObjs);
	CArrayTerminate(&sDrawObjs);
	EditorBrushTerminate(&brush);

	SDL_Quit();

	exit(EXIT_SUCCESS);
}
예제 #9
0
파일: cdogs.c 프로젝트: flags/cdogs-sdl
int main(int argc, char *argv[])
{
	int wait = 0;
	int controllerFlag = SDL_INIT_GAMECONTROLLER;
	credits_displayer_t creditsDisplayer;
	memset(&creditsDisplayer, 0, sizeof creditsDisplayer);
	custom_campaigns_t campaigns;
	memset(&campaigns, 0, sizeof campaigns);
	int forceResolution = 0;
	int err = 0;
	const char *loadCampaign = NULL;
	ENetAddress connectAddr;
	memset(&connectAddr, 0, sizeof connectAddr);

	srand((unsigned int)time(NULL));
	LogInit();

	PrintTitle();

	if (getenv("DEBUG") != NULL)
	{
		debug = true;
		char *dbg;
		if ((dbg = getenv("DEBUG_LEVEL")) != NULL)
		{
			debug_level = CLAMP(atoi(dbg), D_NORMAL, D_MAX);
		}
	}

	SetupConfigDir();
	gConfig = ConfigLoad(GetConfigFilePath(CONFIG_FILE));
	LoadCredits(&creditsDisplayer, colorPurple, colorDarker);
	AutosaveInit(&gAutosave);
	AutosaveLoad(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE));

	if (enet_initialize() != 0)
	{
		LOG(LM_MAIN, LL_ERROR, "An error occurred while initializing ENet.");
		err = EXIT_FAILURE;
		goto bail;
	}
	NetClientInit(&gNetClient);

	// Print command line
	char buf[CDOGS_PATH_MAX];
	buf[0] = '\0';
	for (int i = 0; i < argc; i++)
	{
		strcat(buf, " ");
		// HACK: for OS X, blank out the -psn_XXXX argument so that it doesn't
		// break arg parsing
	#ifdef __APPLE__
		if (strncmp(argv[i], "-psn", strlen("-psn")) == 0)
		{
			argv[i] = "";
		}
	#endif
		strcat(buf, argv[i]);
	}
	LOG(LM_MAIN, LL_INFO, "Command line (%d args):%s", argc, buf);
	{
		struct option longopts[] =
		{
			{"fullscreen",	no_argument,		NULL,	'f'},
			{"scale",		required_argument,	NULL,	's'},
			{"screen",		required_argument,	NULL,	'c'},
			{"forcemode",	no_argument,		NULL,	'o'},
			{"nosound",		no_argument,		NULL,	'n'},
			{"nojoystick",	no_argument,		NULL,	'j'},
			{"wait",		no_argument,		NULL,	'w'},
			{"shakemult",	required_argument,	NULL,	'm'},
			{"connect",		required_argument,	NULL,	'x'},
			{"debug",		required_argument,	NULL,	'd'},
			{"log",			required_argument,	NULL,	1000},
			{"help",		no_argument,		NULL,	'h'},
			{0,				0,					NULL,	0}
		};
		int opt = 0;
		int idx = 0;
		while ((opt = getopt_long(argc, argv, "fs:c:onjwm:xd\0h", longopts, &idx)) != -1)
		{
			switch (opt)
			{
			case 'f':
				ConfigGet(&gConfig, "Graphics.Fullscreen")->u.Bool.Value = true;
				break;
			case 's':
				ConfigSetInt(&gConfig, "Graphics.ScaleFactor", atoi(optarg));
				break;
			case 'c':
				sscanf(optarg, "%dx%d",
					&ConfigGet(&gConfig, "Graphics.ResolutionWidth")->u.Int.Value,
					&ConfigGet(&gConfig, "Graphics.ResolutionHeight")->u.Int.Value);
				LOG(LM_MAIN, LL_DEBUG, "Video mode %dx%d set...",
					ConfigGetInt(&gConfig, "Graphics.ResolutionWidth"),
					ConfigGetInt(&gConfig, "Graphics.ResolutionHeight"));
				break;
			case 'o':
				forceResolution = 1;
				break;
			case 'n':
				LOG(LM_MAIN, LL_INFO, "Sound to 0 volume");
				ConfigGet(&gConfig, "Sound.SoundVolume")->u.Int.Value = 0;
				ConfigGet(&gConfig, "Sound.MusicVolume")->u.Int.Value = 0;
				break;
			case 'j':
				debug(D_NORMAL, "nojoystick\n");
				controllerFlag = 0;
				break;
			case 'w':
				wait = 1;
				break;
			case 'm':
				{
					ConfigGet(&gConfig, "Graphics.ShakeMultiplier")->u.Int.Value =
						MAX(atoi(optarg), 0);
					printf("Shake multiplier: %d\n",
						ConfigGetInt(&gConfig, "Graphics.ShakeMultiplier"));
				}
				break;
			case 'h':
				PrintHelp();
				goto bail;
			case 'd':
				// Set debug level
				debug = true;
				debug_level = CLAMP(atoi(optarg), D_NORMAL, D_MAX);
				break;
			case 1000:
				{
					char *comma = strchr(optarg, ',');
					if (comma)
					{
						// Set logging level for a single module
						// The module and level are comma separated
						*comma = '\0';
						const LogLevel ll = StrLogLevel(comma + 1);
						LogModuleSetLevel(StrLogModule(optarg), ll);
						printf("Logging %s at %s\n", optarg, LogLevelName(ll));
					}
					else
					{
						// Set logging level for all modules
						const LogLevel ll = StrLogLevel(optarg);
						for (int i = 0; i < (int)LM_COUNT; i++)
						{
							LogModuleSetLevel((LogModule)i, ll);
						}
						printf("Logging everything at %s\n", LogLevelName(ll));
					}
				}
				break;
			case 'x':
				if (enet_address_set_host(&connectAddr, optarg) != 0)
				{
					printf("Error: unknown host %s\n", optarg);
				}
				break;
			default:
				PrintHelp();
				// Ignore unknown arguments
				break;
			}
		}
		if (optind < argc)
		{
			// non-option ARGV-elements
			for (; optind < argc; optind++)
			{
				// Load campaign
				loadCampaign = argv[optind];
			}
		}
	}

	debug(D_NORMAL, "Initialising SDL...\n");
	const int sdlFlags =
		SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_HAPTIC;
	if (SDL_Init(sdlFlags | controllerFlag) != 0)
	{
		LOG(LM_MAIN, LL_ERROR, "Could not initialise SDL: %s", SDL_GetError());
		err = EXIT_FAILURE;
		goto bail;
	}
	if (SDLJBN_Init() != 0)
	{
		LOG(LM_MAIN, LL_ERROR, "Could not initialise SDLJBN: %s",
			SDLJBN_GetError());
		err = EXIT_FAILURE;
		goto bail;
	}
	SDL_EventState(SDL_DROPFILE, SDL_DISABLE);

	GetDataFilePath(buf, "");
	LOG(LM_MAIN, LL_INFO, "data dir(%s)", buf);
	LOG(LM_MAIN, LL_INFO, "config dir(%s)", GetConfigFilePath(""));

	SoundInitialize(&gSoundDevice, "sounds");
	if (!gSoundDevice.isInitialised)
	{
		LOG(LM_MAIN, LL_ERROR, "Sound initialization failed!");
	}

	LoadHighScores();

	debug(D_NORMAL, "Loading song lists...\n");
	LoadSongs();

	MusicPlayMenu(&gSoundDevice);

	EventInit(&gEventHandlers, NULL, NULL, true);
	NetServerInit(&gNetServer);

	if (wait)
	{
		printf("Press the enter key to continue...\n");
		getchar();
	}
	if (!PicManagerTryInit(
		&gPicManager, "graphics/cdogs.px", "graphics/cdogs2.px"))
	{
		LOG(LM_MAIN, LL_ERROR, "Failed to initialize graphics");
		err = EXIT_FAILURE;
		goto bail;
	}
	memcpy(origPalette, gPicManager.palette, sizeof(origPalette));
	GraphicsInit(&gGraphicsDevice, &gConfig);
	GraphicsInitialize(&gGraphicsDevice, forceResolution);
	if (!gGraphicsDevice.IsInitialized)
	{
		LOG(LM_MAIN, LL_WARN, "Cannot initialise video; trying default config");
		ConfigResetDefault(ConfigGet(&gConfig, "Graphics"));
		GraphicsInit(&gGraphicsDevice, &gConfig);
		GraphicsInitialize(&gGraphicsDevice, forceResolution);
	}
	if (!gGraphicsDevice.IsInitialized)
	{
		LOG(LM_MAIN, LL_ERROR, "Video didn't init!");
		err = EXIT_FAILURE;
		goto bail;
	}
	FontLoadFromJSON(&gFont, "graphics/font.png", "graphics/font.json");
	PicManagerLoadDir(&gPicManager, "graphics");

	ParticleClassesInit(&gParticleClasses, "data/particles.json");
	AmmoInitialize(&gAmmo, "data/ammo.json");
	BulletAndWeaponInitialize(
		&gBulletClasses, &gGunDescriptions,
		"data/bullets.json", "data/guns.json");
	CharacterClassesInitialize(&gCharacterClasses, "data/character_classes.json");
	LoadPlayerTemplates(
		&gPlayerTemplates, &gCharacterClasses, PLAYER_TEMPLATE_FILE);
	PickupClassesInit(
		&gPickupClasses, "data/pickups.json", &gAmmo, &gGunDescriptions);
	MapObjectsInit(&gMapObjects, "data/map_objects.json");
	CollisionSystemInit(&gCollisionSystem);
	CampaignInit(&gCampaign);
	LoadAllCampaigns(&campaigns);
	PlayerDataInit(&gPlayerDatas);

	GrafxMakeRandomBackground(
		&gGraphicsDevice, &gCampaign, &gMission, &gMap);

	debug(D_NORMAL, ">> Entering main loop\n");
	// Attempt to pre-load campaign if requested
	if (loadCampaign != NULL)
	{
		LOG(LM_MAIN, LL_INFO, "Loading campaign %s...", loadCampaign);
		gCampaign.Entry.Mode =
			strstr(loadCampaign, "/" CDOGS_DOGFIGHT_DIR "/") != NULL ?
			GAME_MODE_DOGFIGHT : GAME_MODE_NORMAL;
		CampaignEntry entry;
		if (!CampaignEntryTryLoad(&entry, loadCampaign, GAME_MODE_NORMAL) ||
			!CampaignLoad(&gCampaign, &entry))
		{
			LOG(LM_MAIN, LL_ERROR, "Failed to load campaign %s", loadCampaign);
		}
	}
	else if (connectAddr.host != 0)
	{
		if (NetClientTryScanAndConnect(&gNetClient, connectAddr.host))
		{
			ScreenWaitForCampaignDef();
		}
		else
		{
			printf("Failed to connect\n");
		}
	}
	LOG(LM_MAIN, LL_INFO, "Starting game");
	MainLoop(&creditsDisplayer, &campaigns);

bail:
	debug(D_NORMAL, ">> Shutting down...\n");
	MapTerminate(&gMap);
	PlayerDataTerminate(&gPlayerDatas);
	MapObjectsTerminate(&gMapObjects);
	PickupClassesTerminate(&gPickupClasses);
	ParticleClassesTerminate(&gParticleClasses);
	AmmoTerminate(&gAmmo);
	WeaponTerminate(&gGunDescriptions);
	BulletTerminate(&gBulletClasses);
	CharacterClassesTerminate(&gCharacterClasses);
	MissionOptionsTerminate(&gMission);
	NetClientTerminate(&gNetClient);
	atexit(enet_deinitialize);
	EventTerminate(&gEventHandlers);
	GraphicsTerminate(&gGraphicsDevice);

	PicManagerTerminate(&gPicManager);
	FontTerminate(&gFont);
	AutosaveSave(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE));
	AutosaveTerminate(&gAutosave);
	ConfigSave(&gConfig, GetConfigFilePath(CONFIG_FILE));
	SavePlayerTemplates(&gPlayerTemplates, PLAYER_TEMPLATE_FILE);
	CArrayTerminate(&gPlayerTemplates);
	FreeSongs(&gMenuSongs);
	FreeSongs(&gGameSongs);
	SaveHighScores();
	UnloadCredits(&creditsDisplayer);
	UnloadAllCampaigns(&campaigns);
	CampaignTerminate(&gCampaign);
	SoundTerminate(&gSoundDevice, true);
	ConfigDestroy(&gConfig);

	SDLJBN_Quit();
	SDL_Quit();

	return err;
}
예제 #10
0
파일: main.c 프로젝트: DMeyer/Color-LCD
int main(void) {

	char * s = "abcdefghijklmnopqrstuvwxyz";
	char * s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char * s3 = "~!@#$%^&*()_+-=1234567890";
	char adc_str[30];

	unsigned int adc_data;
	unsigned int last_adc = 0;
	unsigned int dcolor = 0;
	unsigned int adc_avg = 0;

	int i = 0;

	GraphicsInit();

	drawScreen( BLACK );
	drawBox( 30, 30, 80, 80, BLUE );
	drawCircle( 100, 100, 10, YELLOW );
	drawTriangle( 20, 150, 10, 290, 200, 200, ORANGE );

	drawString( 0, 0, s, GREEN );
	drawString( 0, 8, s2, YELLOW );
	drawString( 0, 16, s3, RED );


	Touch_Init();


	//read adc5
	// Power-up GPIO
	LPC_SC->PCONP |= ( 1 << 12 );

	//clk is at cclk/8 = 15MHz
	LPC_SC->PCLKSEL0 |= (1 << 25);
	LPC_SC->PCLKSEL0 |= (1 << 24);

	//ADC mode
	LPC_PINCON->PINSEL3 |= ( 1 << 31 );
	LPC_PINCON->PINSEL3 |= ( 1 << 30 );

	// 10 no pul up or pull down
	LPC_PINCON->PINMODE3 |= ( 1 << 31 );
	LPC_PINCON->PINMODE3 |= ( 0 << 30 );





	while(1){
		// start adc conversion
		adc_avg = 0;
		/*for( i = 0; i < 10; i++){
			LPC_ADC->ADCR = ADC_START | ADC_WORK | ADC_AD5;

			//wait for it to finish
			while( (LPC_ADC->ADGDR & ADC_DONE) == 0 );

			//stop conversion
			LPC_ADC->ADCR = ~(ADC_START | ADC_WORK | ADC_AD5);

			//get result
			adc_data = (LPC_ADC->ADDR5 >> 4) & 0x0FFF;

			adc_avg += adc_data;

		}*/

		//adc_data = adc_avg / 10;
		adc_data = 2045;

		if( (adc_data > last_adc + 20) || (adc_data < last_adc - 20) ){
			last_adc = adc_data;

			if( adc_data < 500 ){
				dcolor = BLACK;
			}else if( adc_data > 500 && adc_data < 1000 ){
				dcolor = GREY;
			}else if( adc_data > 100 && adc_data < 1500 ){
				dcolor = BLUE;
			}else if( adc_data > 1500 && adc_data < 2000 ){
				dcolor = CYAN;
			}else if( adc_data > 2000 && adc_data < 2500 ){
				dcolor = GREEN;
			}else if( adc_data > 2500 && adc_data < 3000 ){
				dcolor = YELLOW;
			}else if( adc_data > 3000 && adc_data < 3500 ){
				dcolor = BROWN;
			}else if( adc_data > 3500 && adc_data < 4000 ){
				dcolor = ORANGE;
			}else{
				dcolor = RED;
			}


			drawScreen( dcolor );
			itoa(adc_data, adc_str, 10);
			drawString( 0, 0, adc_str, BLACK );
		}
	}

	return 0 ;
}