Ejemplo n.º 1
0
void Quit(const char *msg)
{
	if (!msg || !(*msg))
	{
		// Avoid trying to re-print the order screen if caching it failed.
		static bool quitting = false;
		if (US_TerminalOk() && !quitting)
		{
			quitting = true;
			CA_CacheGrChunk(EXTERN_ORDERSCREEN);
			// There is a 7-byte BSAVE header at the start of the
			// chunk, and we don't want to print the last row, as
			// originally it would be overwritten by DOS anyway.
			US_PrintB8000Text((uint8_t *)(ca_graphChunks[EXTERN_ORDERSCREEN]) + 7, 2000 - 80);
		}
		else
			CK_Cross_LogMessage(CK_LOG_MSG_NORMAL, "Thanks for playing Commander Keen!\n");
		CK_ShutdownID();
		exit(0);
	}
	else
	{
		//__asm__("int $3");
		CK_Cross_puts(msg);
		CK_ShutdownID();
		exit(-1);
	}
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	// Send the cmd-line args to the User Manager.
	us_argc = argc;
	us_argv = (const char **) argv;

	// Default to the first episode with all files present.
	// If no episodes are found, we default to Keen 4, in order
	// to show the file not found messages.
	ck_currentEpisode = &ck4_episode;
	for (int i = 0; ck_episodes[i]; ++i)
	{
		if (ck_episodes[i]->isPresent())
		{
			ck_currentEpisode = ck_episodes[i];
			break;
		}
	}

	bool isFullScreen = false;
	bool isAspectCorrected = true;
#ifdef CK_ENABLE_PLAYLOOP_DUMPER
	const char *dumperFilename = NULL;
#endif

	for (int i = 1; i < argc; ++i)
	{
		if (!CK_Cross_strcasecmp(argv[i], "/EPISODE"))
		{
			// A bit of stuff from the usual demo loop
			if (argc >= i+1)
			{
				if (!strcmp(argv[i+1], "4"))
					ck_currentEpisode = &ck4_episode;
				else if (!strcmp(argv[i+1], "5"))
					ck_currentEpisode = &ck5_episode;
				else if (!strcmp(argv[i+1], "6"))
					ck_currentEpisode = &ck6_episode;
				else
					Quit("Unsupported episode!");
			}
		}
		else if (!CK_Cross_strcasecmp(argv[i], "/FULLSCREEN"))
		{
			isFullScreen = true;
		}
		else if (!CK_Cross_strcasecmp(argv[i], "/FILLED"))
		{
			isAspectCorrected = false;
		}
#ifdef CK_ENABLE_PLAYLOOP_DUMPER
		else if (!CK_Cross_strcasecmp(argv[i], "/DUMPFILE"))
		{
			if (i < argc+1)
				dumperFilename = argv[++i]; // Yes, we increment i twice
		}
#endif
	}

#ifdef CK_ENABLE_PLAYLOOP_DUMPER
	extern FILE *ck_dumperFile;
	if (dumperFilename != NULL)
	{
		ck_dumperFile = fopen(dumperFilename, "wb");
		if (ck_dumperFile == NULL)
		{
			fprintf(stderr, "Couldn't open dumper file for writing.\n");
			return 1;
		}
		printf("Writing to dump file %s\n", dumperFilename);
	}
#endif

	VL_SetParams(isFullScreen, isAspectCorrected);

	ck_currentEpisode->defineConstants();

	CK_InitGame();

	for (int i = 1; i < argc; ++i)
	{
		if (!CK_Cross_strcasecmp(argv[i], "/DEMOFILE"))
		{
			// A bit of stuff from the usual demo loop
			ck_gameState.levelState = 0;

			CK_PlayDemoFile(argv[i + 1]);
			Quit(0);
		}
	}

	if (us_noWait || us_tedLevel)
		ck_debugActive = true;

	// Draw the ANSI "Press Key When Ready Screen" here
	CK_DemoLoop();
	CK_ShutdownID();
#ifdef CK_ENABLE_PLAYLOOP_DUMPER
	if (ck_dumperFile)
		fclose(ck_dumperFile);
#endif
}