Пример #1
0
void Frodo::ReadyToRun(void)
{
	if (getcwd(AppDirPath, 256) == NULL)
		strcpy(AppDirPath, "");

	this->LoadFrodorc();
	if (network_server_connect)
		strncpy(ThePrefs.NetworkServer, network_server_connect,
				sizeof(ThePrefs.NetworkServer));
		
//Mount the floppy if passed as argument
if (floppy8)  
{	
	if (ext_matches_list(floppy8, game_exts))
	{
		strncpy(ThePrefs.DrivePath[0], floppy8, sizeof(ThePrefs.DrivePath[0]));
	
		if (ext_matches_list(floppy8, prg_exts)) {
					
                	char *tmp_filename;
                        FILE *src, *dst;

                        tmp_filename = (char *)xmalloc(strlen(TMP_ROOT_PATH) + 4);
                        sprintf(tmp_filename, "%s/ab", TMP_ROOT_PATH);

                        /* Clean temp dir first (we only want one file) */
                        unlink(tmp_filename);

                        src = fopen(ThePrefs.DrivePath[0], "r");
                        if (src != NULL)
                        {
                                snprintf(ThePrefs.DrivePath[0], sizeof(ThePrefs.DrivePath[0]),
                                		"%s", TMP_ROOT_PATH);

                                /* Special handling of .prg: Copy to TMP_PATH and
                                 * load that as a dir */
                                dst = fopen(tmp_filename, "w");
                                if (dst)
                                {
                                        Uint8 buf[1024];
                                        size_t v;

                                        do {
                                                v = fread(buf, 1, sizeof(buf), src);
                                                fwrite(buf, 1, v, dst);
                                        } while (v > 0);
                                        fclose(dst);
                                }
                                fclose(src);
                        }
                        free(tmp_filename);
			}
	}
}		
	panic_if (!init_graphics(),
			"Can't initialize graphics!\n");

	// Create and start C64
	TheC64 = new C64;
	DataStore::ds = new DataStore();
	TimerController::init();
	Gui::init();
	load_rom_files();
	TheC64->Run();

	delete TheC64;

}
Пример #2
0
	virtual void selectCallback(int which)
	{
		const char *fileName = this->pp_msgs[this->cur_sel];

		/* If we selected a directory, just take the next one */
		if (fileName[0] == '[')
		{
			this->pushDirectory(fileName);
			return;
		}

                snprintf(Gui::gui->np->DrivePath[0], sizeof(Gui::gui->np->DrivePath[0]),
                		"%s/%s", this->cur_path_prefix, fileName);

                if (ext_matches_list(fileName, prg_exts)) {
                	char *tmp_filename;
                        FILE *src, *dst;

                        tmp_filename = (char *)xmalloc(strlen(Gui::gui->tmp_path) + 4);
                        sprintf(tmp_filename, "%s/a", Gui::gui->tmp_path);

                        /* Clean temp dir first (we only want one file) */
                        unlink(tmp_filename);

                        src = fopen(Gui::gui->np->DrivePath[0], "r");
                        if (src != NULL)
                        {
                                snprintf(Gui::gui->np->DrivePath[0], sizeof(Gui::gui->np->DrivePath[0]),
                                		"%s", Gui::gui->tmp_path);

                                /* Special handling of .prg: Copy to TMP_PATH and
                                 * load that as a dir */
                                dst = fopen(tmp_filename, "w");
                                if (dst)
                                {
                                        Uint8 buf[1024];
                                        size_t v;

                                        do {
                                                v = fread(buf, 1, sizeof(buf), src);
                                                fwrite(buf, 1, v, dst);
                                        } while (v > 0);
                                        fclose(dst);
                                }
                                fclose(src);
                        }
                        free(tmp_filename);
                }

                TimerController::controller->disarm(this);
		Gui::gui->dv->loadGameInfo(fileName);

		if (Gui::gui->dv->gameInfo->gi)
			Gui::gui->updateGameInfo(Gui::gui->dv->gameInfo->gi);
		else
			Gui::gui->updateGameInfo(new GameInfo(fileName));

		Gui::gui->popView();

		if (this->runStartSequence)
		{
			/* Timeout and save the screenshot if there isn't one */
			new SaveScreenshot();
			/* And the start sequence */
			new StartGameListener();

			Gui::gui->exitMenu();
		}
	}