コード例 #1
0
ファイル: main.c プロジェクト: sakya/pcsx_rearmed
int main(int argc, char **argv)
{
	if (argc == 1 || (argc == 2 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-help") || !strcmp(argv[1], "-h")))) {
		PrintHelp();
		return 0;
	}

	emu_core_preinit();
	ChangeWorkingDirectory("c");
	char file[MAXPATHLEN] = "";
	char path[MAXPATHLEN];
	const char *cdfile = NULL;
	int loadst = 0;
	int i;
	int getst = -1;
	int discNumber = 0;

	g_menuscreen_w = 800;
	g_menuscreen_h = 480;

	strcpy(Config.Gpu, "builtin_gpu");
	strcpy(Config.Spu, "builtin_spu");
	strcpy(Config.BiosDir, "/home/user/MyDocs");
	strcpy(Config.PluginsDir, "/opt/maemo/usr/games/plugins");
	snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "/opt/maemo/usr/games" PATCHES_DIR);
	Config.PsxAuto = 1;
	pl_rearmed_cbs.frameskip = -1;
	strcpy(Config.Bios, "HLE");
    iUseReverb = 0;
    iUseInterpolation = 0;

	in_type1 = PSE_PAD_TYPE_STANDARD;
	in_type2 = PSE_PAD_TYPE_STANDARD;

	accelOptions.sens     = 150;
	accelOptions.y_def	  = 500;
	accelOptions.maxValue = 500.0;

	// read command line options
	for (i = 1; i < argc; i++) {
		     if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
		else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
		else if (!strcmp(argv[i], "-cdfile")) {
			char isofilename[MAXPATHLEN];
			if (i+1 >= argc) break;
			strncpy(isofilename, argv[++i], MAXPATHLEN);
			if (isofilename[0] != '/') {
				getcwd(path, MAXPATHLEN);
				if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
					strcat(path, "/");
					strcat(path, isofilename);
					strcpy(isofilename, path);
				} else
					isofilename[0] = 0;
			}
			cdfile = isofilename;
		}
		else if (!strcmp(argv[i],"-frameskip")) {
			int tv_reg = atol(argv[++i]);
			if (tv_reg < -1)
				pl_rearmed_cbs.frameskip = -1;
			else
				pl_rearmed_cbs.frameskip = tv_reg;
		}
		else if (!strcmp(argv[i],"-region")) {
			int psx_reg = atol(argv[++i]);
			if (psx_reg == 0 || psx_reg == 1){
				Config.PsxAuto = 0;
				Config.PsxType = psx_reg;
			}
		}

		else if (!strcmp(argv[i],"-get_sstatename")) getst = atol(argv[++i]);

		else if (!strcmp(argv[i], "-fullscreen"))	        g_maemo_opts |= 2;
		else if (!strcmp(argv[i], "-accel"))				g_maemo_opts |= 4;
		else if (!strcmp(argv[i], "-nosound"))		        strcpy(Config.Spu, "spunull.so");
		else if (!strcmp(argv[i], "-bdir"))			sprintf(Config.BiosDir, "%s", argv[++i]);
		else if (!strcmp(argv[i], "-pdir"))			        sprintf(Config.PluginsDir, "%s", argv[++i]);
		else if (!strcmp(argv[i], "-bios"))			sprintf(Config.Bios, "%s", argv[++i]);
		else if (!strcmp(argv[i], "-gles"))			        { strcpy(Config.Gpu, "gpu_gles.so"); g_maemo_opts |= 8 ;}
		else if (!strcmp(argv[i], "-oldgpu"))		        strcpy(Config.Gpu, "gpu_peops.so");
		else if (!strcmp(argv[i], "-unai"))		            strcpy(Config.Gpu, "gpu_unai.so");
		else if (!strcmp(argv[i], "-cdda"))		Config.Cdda = 1;
		else if (!strcmp(argv[i], "-xa"))		Config.Xa = 1;
		else if (!strcmp(argv[i], "-rcnt"))		Config.RCntFix = 1 ;
		else if (!strcmp(argv[i], "-sio"))		Config.Sio = 1;
		else if (!strcmp(argv[i], "-spuirq"))	Config.SpuIrq = 1;
		else if (!strcmp(argv[i], "-vsync"))	Config.VSyncWA = 1;
		else if (!strcmp(argv[i], "-fps")) 		            g_opts |=OPT_SHOWFPS;
		else if (!strcmp(argv[i], "-cpu")) 		            g_opts |=OPT_SHOWCPU;
		else if (!strcmp(argv[i], "-spu")) 		            g_opts |=OPT_SHOWSPU;
		else if (!strcmp(argv[i], "-nofl")) 		        g_opts |=OPT_NO_FRAMELIM;
		else if (!strcmp(argv[i], "-mcd1")) 	            sprintf(Config.Mcd1, "%s", argv[++i]);
		else if (!strcmp(argv[i], "-mcd2")) 	            sprintf(Config.Mcd2, "%s", argv[++i]);

		else if (!strcmp(argv[i], "-cpuclock")) 	        cycle_multiplier = 10000 / atol(argv[++i]);
		else if (!strcmp(argv[i], "-guncon")) 	            in_type1 = PSE_PAD_TYPE_GUNCON;
		else if (!strcmp(argv[i], "-gunnotrigger")) 		g_opts |= OPT_TSGUN_NOTRIGGER;
		else if (!strcmp(argv[i], "-analog")) 	            in_type1 = PSE_PAD_TYPE_ANALOGPAD;
		else if (!strcmp(argv[i], "-vibration")) 	        { in_type1 = PSE_PAD_TYPE_ANALOGPAD; in_enable_vibration = 1; }
		else if (!strcmp(argv[i], "-sens")) 				accelOptions.sens = atol(argv[++i]);
		else if (!strcmp(argv[i], "-ydef")) 				accelOptions.y_def = atol(argv[++i]);
		else if (!strcmp(argv[i], "-max")) 				    accelOptions.maxValue = atol(argv[++i]);
		else if (!strcmp(argv[i], "-displayon")) 		    bKeepDisplayOn = TRUE;
		else if (!strcmp(argv[i], "-keys")) 				sprintf(keys_config_file, "%s", argv[++i]);
		else if (!strcmp(argv[i], "-autosave")) 		    bAutosaveOnExit = TRUE;
		else if (!strcmp(argv[i], "-disc")) 		        discNumber = atol(argv[++i]);
		else if (!strcmp(argv[i], "-corners")){
			int j = 0;
			i++;
			char num[2];
			for (j=0; j<strlen(argv[i]); j++){
				strncpy(num, argv[i] + j, 1);
				cornerActions[j] = atoi(num);
			}
	}

		else if (!strcmp(argv[i], "-spu_reverb"))           { if (atol(argv[++i]) > 0) iUseReverb = 2; }
		else if (!strcmp(argv[i], "-spu_interpolation")) 	iUseInterpolation = atol(argv[++i]);

		else if (!strcmp(argv[i],"-interlace")) {
			int interlace = atol(argv[++i]);
			if (interlace >= 0 && interlace <= 2)
				pl_rearmed_cbs.gpu_neon.allow_interlace = interlace;
		}
		else if (!strcmp(argv[i], "-enhance")) 			pl_rearmed_cbs.gpu_neon.enhancement_enable = 1;
		else if (!strcmp(argv[i], "-enhancehack")) 		pl_rearmed_cbs.gpu_neon.enhancement_no_main = 1;

		else if (!strcmp(argv[i], "-gles_dithering")) 	pl_rearmed_cbs.gpu_peopsgl.bDrawDither = atol(argv[++i]);
		else if (!strcmp(argv[i], "-gles_mask")) 	    pl_rearmed_cbs.gpu_peopsgl.iUseMask = atol(argv[++i]);
		else if (!strcmp(argv[i], "-gles_filtering")) 	pl_rearmed_cbs.gpu_peopsgl.iFilterType = atol(argv[++i]);
		else if (!strcmp(argv[i], "-gles_fbtex")) 	    pl_rearmed_cbs.gpu_peopsgl.iFrameTexType = atol(argv[++i]);
		else if (!strcmp(argv[i], "-gles_vram")) 	    pl_rearmed_cbs.gpu_peopsgl.iVRamSize = atol(argv[++i]);
		else if (!strcmp(argv[i], "-gles_fastmdec")) 	pl_rearmed_cbs.gpu_peopsgl.bUseFastMdec = atol(argv[++i]);
        else if (!strcmp(argv[i], "-gles_advblend")) 	pl_rearmed_cbs.gpu_peopsgl.bAdvancedBlend = atol(argv[++i]);
        else if (!strcmp(argv[i], "-gles_opaque")) 	    pl_rearmed_cbs.gpu_peopsgl.bOpaquePass = atol(argv[++i]);

		else {
			fprintf(stderr, "Unknown option: %s\n", argv[i]);
			return 1;
		}
	}
	
	pl_init();
	if (emu_core_init() == -1)
		return 1;
	
	if (cdfile) {
		set_cd_image(cdfile);
		strcpy(file_name, strrchr(cdfile,'/'));
	}

	if (LoadPlugins() == -1) {
		SysMessage("Failed loading plugins!");
		return 1;
	}

	if (discNumber > 0)
		cdrIsoMultidiskSelect = discNumber - 1;

	if (OpenPlugins() == -1) {
		return 1;
	}
	plugin_call_rearmed_cbs();

	CheckCdrom();

	if (getst >= 0){
		char fname[MAXPATHLEN];

		get_state_filename(fname, sizeof(fname), getst);
		printf("SAVESTATE: %s\n", fname);
		if (cdrIsoMultidiskCount > 1){
			int i = 0;
			for (i=1; i<cdrIsoMultidiskCount; i++){
				cdrIsoMultidiskSelect = i;
				CdromId[0] = '\0';
				CdromLabel[0] = '\0';

				CDR_close();
				if (CDR_open() == 0){
					CheckCdrom();
					get_state_filename(fname, sizeof(fname), getst);
					printf("SAVESTATE: %s\n", fname);
				}
			}
		}
		return 0;
	}

	SysReset();

	if (file[0] != '\0') {
		if (Load(file) != -1)
			ready_to_go = 1;
	} else {
		if (cdfile) {
			if (LoadCdrom() == -1) {
				ClosePlugins();
				printf(_("Could not load CD-ROM!\n"));
				return -1;
			}
			emu_on_new_cd(0);
			ready_to_go = 1;
		}
	}

	if (!ready_to_go) {
		printf ("something goes wrong, maybe you forgot -cdfile ? \n");
		return 1;
	}

	if (cdrIsoMultidiskCount > 1)
		printf ("Loaded a multidisc image: %i discs.\n", cdrIsoMultidiskCount);

	// If a state has been specified, then load that
	if (loadst) {
		int ret = emu_load_state(loadst - 1);
		printf("%s state %d\n", ret ? "Failed to load" : "Loaded", loadst);
		state_slot = loadst - 1;
	}

	if (maemo_init(&argc, &argv))
		return 1;

	if (GPU_open != NULL) {
		int ret = GPU_open(&gpuDisp, "PCSX", NULL);
		if (ret){
			fprintf(stderr, "Warning: GPU_open returned %d\n", ret);
			gpuDisp=ret;
		}
	}

	if (Config.HLE)
		printf("Note: running without BIOS, expect compatibility problems\n");

	dfinput_activate();
	pl_timing_prepare(Config.PsxType);

	while (1)
	{
		stop = 0;
		emu_action = SACTION_NONE;

		psxCpu->Execute();
		if (emu_action != SACTION_NONE)
			do_emu_action();
	}

	maemo_finish();
	return 0;
}
コード例 #2
0
ファイル: sdl.cpp プロジェクト: a-detiste/stratagus
/**
**  Initialize the video part for SDL.
*/
void InitVideoSdl()
{
	Uint32 flags = 0;

	if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
#ifndef USE_WIN32
		// Fix tablet input in full-screen mode
		SDL_putenv(strdup("SDL_MOUSE_RELATIVE=0"));
#endif
		int res = SDL_Init(
#ifdef DEBUG
					  SDL_INIT_NOPARACHUTE |
#endif
					  SDL_INIT_AUDIO | SDL_INIT_VIDEO |
					  SDL_INIT_TIMER);
		if (res < 0) {
			fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
			exit(1);
		}

		// Clean up on exit
		atexit(SDL_Quit);

#ifdef USE_MAEMO
		maemo_init();
#endif

		// If debug is enabled, Stratagus disable SDL Parachute.
		// So we need gracefully handle segfaults and aborts.
#if defined(DEBUG) && !defined(USE_WIN32)
		signal(SIGSEGV, CleanExit);
		signal(SIGABRT, CleanExit);
#endif
		// Set WindowManager Title
		if (!FullGameName.empty()) {
			SDL_WM_SetCaption(FullGameName.c_str(), FullGameName.c_str());
		} else if (!Parameters::Instance.applicationName.empty()) {
			SDL_WM_SetCaption(Parameters::Instance.applicationName.c_str(), Parameters::Instance.applicationName.c_str());
		} else {
			SDL_WM_SetCaption("Stratagus", "Stratagus");
		}

#if ! defined(USE_WIN32) && ! defined(USE_MAEMO)

#if defined(USE_OPENGL) || defined(USE_GLES)
		// Make sure, that we not create OpenGL textures (and do not call OpenGL functions), when creating icon surface
		bool UseOpenGL_orig = UseOpenGL;
		UseOpenGL = false;
#endif

		SDL_Surface *icon = NULL;
		CGraphic *g = NULL;
		struct stat st;

		std::string FullGameNameL = FullGameName;
		for (size_t i = 0; i < FullGameNameL.size(); ++i) {
			FullGameNameL[i] = tolower(FullGameNameL[i]);
		}

		std::string ApplicationName = Parameters::Instance.applicationName;
		std::string ApplicationNameL = ApplicationName;
		for (size_t i = 0; i < ApplicationNameL.size(); ++i) {
			ApplicationNameL[i] = tolower(ApplicationNameL[i]);
		}

		std::vector <std::string> pixmaps;
		pixmaps.push_back(std::string() + PIXMAPS + "/" + FullGameName + ".png");
		pixmaps.push_back(std::string() + PIXMAPS + "/" + FullGameNameL + ".png");
		pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + FullGameName + ".png");
		pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + FullGameNameL + ".png");
		pixmaps.push_back(std::string() + PIXMAPS + "/" + ApplicationName + ".png");
		pixmaps.push_back(std::string() + PIXMAPS + "/" + ApplicationNameL + ".png");
		pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + ApplicationName + ".png");
		pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + ApplicationNameL + ".png");
		pixmaps.push_back(std::string() + PIXMAPS + "/" + "Stratagus" + ".png");
		pixmaps.push_back(std::string() + PIXMAPS + "/" + "stratagus" + ".png");
		pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + "Stratagus" + ".png");
		pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + "stratagus" + ".png");

		for (size_t i = 0; i < pixmaps.size(); ++i) {
			if (stat(pixmaps[i].c_str(), &st) == 0) {
				if (g) { CGraphic::Free(g); }
				g = CGraphic::New(pixmaps[i].c_str());
				g->Load();
				icon = g->Surface;
				if (icon) { break; }
			}
		}

		if (icon) {
			SDL_WM_SetIcon(icon, 0);
		}

		if (g) {
			CGraphic::Free(g);
		}

#if defined(USE_OPENGL) || defined(USE_GLES)
		UseOpenGL = UseOpenGL_orig;
#endif

#endif
#ifdef USE_WIN32
		HWND hwnd = NULL;
		HICON hicon = NULL;
		SDL_SysWMinfo info;
		SDL_VERSION(&info.version);

		if (SDL_GetWMInfo(&info)) {
			hwnd = info.window;
		}

		if (hwnd) {
			hicon = ExtractIcon(GetModuleHandle(NULL), Parameters::Instance.applicationName.c_str(), 0);
		}

		if (hicon) {
			SendMessage(hwnd, (UINT)WM_SETICON, ICON_SMALL, (LPARAM)hicon);
			SendMessage(hwnd, (UINT)WM_SETICON, ICON_BIG, (LPARAM)hicon);
		}
#endif
	}

	// Initialize the display

#ifdef USE_MAEMO
	// TODO: Support window mode and portrait mode resolution on Maemo - Nokia N900
	Video.FullScreen = 1;
	Video.Width = 800;
	Video.Height = 480;
#endif

#if !defined(USE_OPENGL) && !defined(USE_GLES)
	flags = SDL_HWSURFACE | SDL_HWPALETTE;
#endif

	// Sam said: better for windows.
	/* SDL_HWSURFACE|SDL_HWPALETTE | */
	if (Video.FullScreen) {
		flags |= SDL_FULLSCREEN;
	}

#if defined(USE_OPENGL) || defined(USE_GLES)
	if (UseOpenGL) {
#ifdef USE_GLES_NATIVE
		flags |= SDL_OPENGLES;
#endif
#ifdef USE_GLES_MAEMO
		if (SDL_GLES_Init(SDL_GLES_VERSION_1_1) < 0) {
			fprintf(stderr, "Couldn't initialize SDL_GLES: %s\n", SDL_GetError());
			exit(1);
		}

		// Clean up GLES on exit
		atexit(SDL_GLES_Quit);

		flags |= SDL_SWSURFACE;
#endif
#ifdef USE_OPENGL
		flags |= SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
#endif
	}
#endif

	if (!Video.Width || !Video.Height) {
		Video.Width = 640;
		Video.Height = 480;
	}

	if (!Video.Depth) {
		Video.Depth = 32;
	}

#if defined(USE_OPENGL) || defined(USE_GLES)
	if (!Video.ViewportWidth || !Video.ViewportHeight) {
		Video.ViewportWidth = Video.Width;
		Video.ViewportHeight = Video.Height;
	}
	TheScreen = SDL_SetVideoMode(Video.ViewportWidth, Video.ViewportHeight, Video.Depth, flags);
#else
	TheScreen = SDL_SetVideoMode(Video.Width, Video.Height, Video.Depth, flags);
#endif
	if (TheScreen && (TheScreen->format->BitsPerPixel != 16
					  && TheScreen->format->BitsPerPixel != 32)) {
		// Only support 16 and 32 bpp, default to 16
#if defined(USE_OPENGL) || defined(USE_GLES)
		TheScreen = SDL_SetVideoMode(Video.ViewportWidth, Video.ViewportHeight, 16, flags);
#else
		TheScreen = SDL_SetVideoMode(Video.Width, Video.Height, 16, flags);
#endif
	}
	if (TheScreen == NULL) {
		fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
				Video.Width, Video.Height, Video.Depth, SDL_GetError());
		exit(1);
	}

	Video.FullScreen = (TheScreen->flags & SDL_FULLSCREEN) ? 1 : 0;
	Video.Depth = TheScreen->format->BitsPerPixel;

#if defined(USE_TOUCHSCREEN) && defined(USE_WIN32)
	// Must not allow SDL to switch to relative mouse coordinates
	// with touchscreen when going fullscreen. So we don't hide the
	// cursor, but instead set a transparent 1px cursor
	Uint8 emptyCursor[] = {'\0'};
	Video.blankCursor = SDL_CreateCursor(emptyCursor, emptyCursor, 1, 1, 0, 0);
	SDL_SetCursor(Video.blankCursor);
#else
	// Turn cursor off, we use our own.
	SDL_ShowCursor(SDL_DISABLE);
#endif

	// Make default character translation easier
	SDL_EnableUNICODE(1);

#if defined(USE_OPENGL) || defined(USE_GLES)
	if (UseOpenGL) {
#ifdef USE_GLES_MAEMO
		SDL_GLES_Context *context = SDL_GLES_CreateContext();
		if (!context) {
			fprintf(stderr, "Couldn't initialize SDL_GLES_CreateContext: %s\n", SDL_GetError());
			exit(1);
		}
		if (SDL_GLES_MakeCurrent(context) < 0) {
			fprintf(stderr, "Couldn't initialize SDL_GLES_MakeCurrent: %s\n", SDL_GetError());
			exit(1);
		}
		// atexit(GLES_DeleteContext(context));
#endif
#ifdef USE_GLES_EGL
		// Get the SDL window handle
		SDL_SysWMinfo sysInfo; //Will hold our Window information
		SDL_VERSION(&sysInfo.version); //Set SDL version
		if (SDL_GetWMInfo(&sysInfo) <= 0) {
			fprintf(stderr, "Unable to get window handle\n");
			exit(1);
		}

		eglDisplay = eglGetDisplay((EGLNativeDisplayType)sysInfo.info.x11.display);
		if (!eglDisplay) {
			fprintf(stderr, "Couldn't open EGL Display\n");
			exit(1);
		}

		if (!eglInitialize(eglDisplay, NULL, NULL)) {
			fprintf(stderr, "Couldn't initialize EGL Display\n");
			exit(1);
		}

		// Find a matching config
		EGLint configAttribs[] = {EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE};
		EGLint numConfigsOut = 0;
		EGLConfig eglConfig;
		if (eglChooseConfig(eglDisplay, configAttribs, &eglConfig, 1, &numConfigsOut) != EGL_TRUE || numConfigsOut == 0) {
			fprintf(stderr, "Unable to find appropriate EGL config\n");
			exit(1);
		}

		eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, (EGLNativeWindowType)sysInfo.info.x11.window, 0);
		if (eglSurface == EGL_NO_SURFACE) {
			fprintf(stderr, "Unable to create EGL surface\n");
			exit(1);
		}

		// Bind GLES and create the context
		eglBindAPI(EGL_OPENGL_ES_API);
		EGLint contextParams[] = {EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE};
		EGLContext eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);
		if (eglContext == EGL_NO_CONTEXT) {
			fprintf(stderr, "Unable to create GLES context\n");
			exit(1);
		}

		if (eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) == EGL_FALSE) {
			fprintf(stderr, "Unable to make GLES context current\n");
			exit(1);
		}
#endif
		InitOpenGL();
	}
#endif

	InitKey2Str();

	ColorBlack = Video.MapRGB(TheScreen->format, 0, 0, 0);
	ColorDarkGreen = Video.MapRGB(TheScreen->format, 48, 100, 4);
	ColorLightBlue = Video.MapRGB(TheScreen->format, 52, 113, 166);
	ColorBlue = Video.MapRGB(TheScreen->format, 0, 0, 252);
	ColorOrange = Video.MapRGB(TheScreen->format, 248, 140, 20);
	ColorWhite = Video.MapRGB(TheScreen->format, 252, 248, 240);
	ColorLightGray = Video.MapRGB(TheScreen->format, 192, 192, 192);
	ColorGray = Video.MapRGB(TheScreen->format, 128, 128, 128);
	ColorDarkGray = Video.MapRGB(TheScreen->format, 64, 64, 64);
	ColorRed = Video.MapRGB(TheScreen->format, 252, 0, 0);
	ColorGreen = Video.MapRGB(TheScreen->format, 0, 252, 0);
	ColorYellow = Video.MapRGB(TheScreen->format, 252, 252, 0);

	UI.MouseWarpPos.x = UI.MouseWarpPos.y = -1;
}
コード例 #3
0
ファイル: main.c プロジェクト: tigerking/pcsx_rearmed
int main(int argc, char **argv)
{
	char file[MAXPATHLEN] = "";
	char path[MAXPATHLEN];
	const char *cdfile = NULL;
	int loadst = 0;
	int i;

	emu_core_preinit();
	ChangeWorkingDirectory("c");

	strcpy(Config.BiosDir, "/home/user/MyDocs");
	strcpy(Config.PluginsDir, "/opt/maemo/usr/games/plugins");
	snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "/opt/maemo/usr/games" PATCHES_DIR);
	Config.PsxAuto = 1;

	g_menuscreen_w = 800;
	g_menuscreen_h = 480;

	pl_init();

	emu_core_init();

	// read command line options
	for (i = 1; i < argc; i++) {
		     if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
		else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
		else if (!strcmp(argv[i], "-cdfile")) {
			char isofilename[MAXPATHLEN];
			if (i+1 >= argc) break;
			strncpy(isofilename, argv[++i], MAXPATHLEN);
			if (isofilename[0] != '/') {
				getcwd(path, MAXPATHLEN);
				if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
					strcat(path, "/");
					strcat(path, isofilename);
					strcpy(isofilename, path);
				} else
					isofilename[0] = 0;
			}
			cdfile = isofilename;
		}
		else if (!strcmp(argv[i],"-frameskip")) {
			int tv_reg = atol(argv[++i]);
			if (tv_reg > 0)
				pl_rearmed_cbs.frameskip = -1;
		}
		else if (!strcmp(argv[i],"-fullscreen"))		g_maemo_opts |= 2;
		else if (!strcmp(argv[i],"-accel"))				g_maemo_opts |= 4;
		else if (!strcmp(argv[i],"-nosound"))		strcpy(Config.Spu, "spunull.so");
		else if (!strcmp(argv[i], "-bdir"))			sprintf(Config.BiosDir, "%s", argv[++i]);
		else if (!strcmp(argv[i], "-bios"))			sprintf(Config.Bios, "%s", argv[++i]);
		else if (!strcmp(argv[i], "-gles"))			strcpy(Config.Gpu, "gpuGLES.so");
		else if (!strcmp(argv[i], "-cdda"))		Config.Cdda = 1;
		else if (!strcmp(argv[i], "-xa"))		Config.Xa = 1;
		else if (!strcmp(argv[i], "-rcnt"))		Config.RCntFix = 1 ;
		else if (!strcmp(argv[i], "-sio"))		Config.Sio = 1;
		else if (!strcmp(argv[i], "-spuirq"))	Config.SpuIrq = 1;
		else if (!strcmp(argv[i], "-vsync"))	Config.VSyncWA = 1;
	}

	hildon_init(&argc, &argv);
	
	if (cdfile) {
		set_cd_image(cdfile);
		strcpy(file_name, strrchr(cdfile,'/'));
	}

	if (LoadPlugins() == -1) {
		SysMessage("Failed loading plugins!");
		return 1;
	}

	if (OpenPlugins() == -1) {
		return 1;
	}
	plugin_call_rearmed_cbs();

	CheckCdrom();
	SysReset();

	if (file[0] != '\0') {
		if (Load(file) != -1)
			ready_to_go = 1;
	} else {
		if (cdfile) {
			if (LoadCdrom() == -1) {
				ClosePlugins();
				printf(_("Could not load CD-ROM!\n"));
				return -1;
			}
			emu_on_new_cd(0);
			ready_to_go = 1;
		}
	}

	if (!ready_to_go) {
		printf ("something goes wrong, maybe you forgot -cdfile ? \n");
		return 1;
	}

	// If a state has been specified, then load that
	if (loadst) {
		int ret = emu_load_state(loadst - 1);
		printf("%s state %d\n", ret ? "failed to load" : "loaded", loadst);
	}

	maemo_init(&argc, &argv);

	if (GPU_open != NULL) {
		int ret = GPU_open(&gpuDisp, "PCSX", NULL);
		if (ret)
			fprintf(stderr, "Warning: GPU_open returned %d\n", ret);
	}

	dfinput_activate();
	pl_timing_prepare(Config.PsxType);

	while (1)
	{
		stop = 0;
		emu_action = SACTION_NONE;

		psxCpu->Execute();
		if (emu_action != SACTION_NONE)
			do_emu_action();
	}

	return 0;
}
コード例 #4
0
ファイル: main.c プロジェクト: psykix/pcsx-rearmed
int maemo_main(int argc, char **argv)
{
	ChangeWorkingDirectory("c");
	char file[MAXPATHLEN] = "";
	char path[MAXPATHLEN];
	const char *cdfile = NULL;
	int loadst = 0;
	int i;

	strcpy(Config.BiosDir, "/home/user/MyDocs");
	strcpy(Config.PluginsDir, "/opt/maemo/usr/games/plugins");
	snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "/opt/maemo/usr/games" PATCHES_DIR);
	Config.PsxAuto = 1;
	
	// read command line options
	for (i = 1; i < argc; i++) {
		     if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
		else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
		else if (!strcmp(argv[i], "-cdfile")) {
			char isofilename[MAXPATHLEN];

			if (i+1 >= argc) break;
			strncpy(isofilename, argv[++i], MAXPATHLEN);
			if (isofilename[0] != '/') {
				getcwd(path, MAXPATHLEN);
				if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
					strcat(path, "/");
					strcat(path, isofilename);
					strcpy(isofilename, path);
				} else
					isofilename[0] = 0;
			}

			cdfile = isofilename;
		}
		else if (!strcmp(argv[i],"-frameskip")){
		
		int tv_reg=atol(argv[++i]);
		if (tv_reg>0){
		UseFrameSkip=1;
		fFrameRateHz = (tv_reg==1)?50.0f:  59.94f;
		dwFrameRateTicks = (100000*100 / (unsigned long)(fFrameRateHz*100));
		}
		}
		else if (!strcmp(argv[i],"-sputhreaded")){
			iUseTimer=1;
		}
		else if (!strcmp(argv[i],"-nosound")){
				strcpy(Config.Spu, "spunull.so");
		}
		else if(!strcmp(argv[i], "-bdir"))	sprintf(Config.BiosDir, "%s", argv[++i]);
		else if(!strcmp(argv[i], "-bios"))	sprintf(Config.Bios, "%s", argv[++i]);
		else if (!strcmp(argv[i],"-gles")){
		strcpy(Config.Gpu, "gpuGLES.so");
		}
		else if (!strcmp(argv[i], "-cdda"))		Config.Cdda = 1;
		else if (!strcmp(argv[i], "-xa"))		Config.Xa = 1;
		else if (!strcmp(argv[i], "-rcnt"))		Config.RCntFix = 1 ;
		else if (!strcmp(argv[i], "-sio"))		Config.Sio = 1;
		else if (!strcmp(argv[i], "-spuirq"))	Config.SpuIrq = 1;
		else if (!strcmp(argv[i], "-vsync"))	Config.VSyncWA = 1;
		else if (!strcmp(argv[i], "-h") ||
			 !strcmp(argv[i], "-help") ||
			 !strcmp(argv[i], "--help")) {
			 printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
			 printf("%s\n", _(
							" pcsx [options] [file]\n"
							"\toptions:\n"
							"\t-cdfile FILE\tRuns a CD image file\n"
							"\t-psxout\t\tEnable PSX output\n"
							"\t-nosound\t\tDisable sound using spunull plugin\n"
							"\t-sputhreaded\t\tMove sound to separate thread\n"
							"\t-frameskip\t\tEnable frameskip\n"
							"\t-load STATENUM\tLoads savestate STATENUM (1-5)\n"
							"\t-h -help\tDisplay this message\n"
							"\tfile\t\tLoads file\n"));
			 return 0;
		} else {
			strncpy(file, argv[i], MAXPATHLEN);
			if (file[0] != '/') {
				getcwd(path, MAXPATHLEN);
				if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
					strcat(path, "/");
					strcat(path, file);
					strcpy(file, path);
				} else
					file[0] = 0;
			}
		}
	}

	hildon_init(&argc, &argv);
	
	if (cdfile)
		set_cd_image(cdfile);

	if (SysInit() == -1)
		return 1;

	if (LoadPlugins() == -1) {
		SysMessage("Failed loading plugins!");
		return 1;
	}

	if (OpenPlugins() == -1) {
		return 1;
	}
	plugin_call_rearmed_cbs();

	CheckCdrom();
	SysReset();

	if (file[0] != '\0') {
		if (Load(file) != -1)
			ready_to_go = 1;
	} else {
		if (cdfile) {
			if (LoadCdrom() == -1) {
				ClosePlugins();
				printf(_("Could not load CD-ROM!\n"));
				return -1;
			}
			ready_to_go = 1;
		}
	}

	// If a state has been specified, then load that
	if (loadst) {
		int ret = emu_load_state(loadst - 1);
		printf("%s state %d\n", ret ? "failed to load" : "loaded", loadst);
	}

	if (ready_to_go)
		maemo_init();
	else
	{
		printf ("somethings goes wrong, maybe you forgot -cdfile ? \n");
		return 0;
	}

	while (1)
	{
		stop = 0;
		emu_action = SACTION_NONE;

		psxCpu->Execute();
		if (emu_action != SACTION_NONE)
			do_emu_action();
	}

	return 0;
}