コード例 #1
0
ファイル: file.c プロジェクト: dilraj45/pegit
int filespec_init(struct filespec *fs, const char *name, const char *mode)
{
    /* set name and directory subfield of the directory */
    filespec_setname_and_dir(fs, name);
    fs->file = fopen(name, mode);
    if (!fs->file) {
        fprintf(stderr, "%s: file doesn't exists.\n", name);
        clean_on_error(fs); /* remove the memory allocated */
        exit(EXIT_FAILURE);
        return -1;
    }

    if (filespec_stat(fs, name) == -1) {
        clean_on_error(fs);
        return -1;
    }

    fs->last_modified = fs->st.st_mtime;
    fs->length = file_length(fs->file);

    /* postpone the file caching until call to filespec read takes place */
    filecache_init(&fs->cache);
    fs->cached = 0;
    return 0;
}
コード例 #2
0
ファイル: gp2x.cpp プロジェクト: cyberkni/276in1JAMMA
int main(int argc,char **argv)
{
#ifdef PSP
	pspDebugScreenInit();
	#ifdef PSP_USERMODE
		SetupCallbacks();
	#endif
	#ifdef WIFI 
		net_io_init();
	#endif
#endif
	char text[64];
	int res, i, game_index;

	/* GP2X Video Init */
	gp2x_video_init();

#ifdef GP2X
	{
		/* Border TV-Out */
		#define BORDERTVOUTSTRUCTURE "--border_tvout %d --border_tvout_width %d --border_tvout_height %d"
		extern char gp2x_path_mame[24];
		extern int gp2x_bordertvout;
		extern int gp2x_bordertvout_width;
		extern int gp2x_bordertvout_height;
		char name[256];
		FILE *f;
		sprintf(name,"%scfg/mame_tvout.cfg",gp2x_path_mame);
		f=fopen(name,"rb");
		if (f) {
			fscanf(f,BORDERTVOUTSTRUCTURE,&gp2x_bordertvout,&gp2x_bordertvout_width,&gp2x_bordertvout_height);
			fclose(f);
		
			if (gp2x_bordertvout) {
				printf("Border TV-Out Activated\r\n");
			} else {
				printf("Border TV-Out Disabled\r\n");
			}
		}
	}
#endif

	/* Set Video Mode */
#ifdef PSP_RES
	SetVideoScaling(480,480,272);
#else
	SetVideoScaling(320,320,240);
#endif

#ifdef GP2X
	/* Zaq121 07/05/2006 Alternative frontend support -> */
	/* Check for command line arguments */
	parse_cmdline (argc, argv, &options, game_index);
	if (no_selector==0)
	/* <- end mod */
#endif
	/* Intro screen */
	gp2x_intro_screen();

	/* Initialize Game Listings */
 	game_list_init();

	while(1) {

#ifdef GP2X
		/* Disable Scaling / Stretching */
		{ extern int gp2x_text_width; gp2x_text_width=320; }
		SetVideoScaling(320,320,240);
		gp2x_rotate=0;
		/* Mute Sound */
		gp2x_sound_thread_mute();
#endif
		
#ifdef GP2X
		/* Zaq121 07/05/2006 Alternative frontend support -> */
		if (no_selector==0)
		/* <- end mod */
#endif
		/* Select Game */
		select_game(playgame); 
#ifdef GP2X
		/* Zaq121 07/05/2006 Alternative frontend support -> */
   		else {
   			extern int gp2x_freq;   /* 9/5/06 Zaq, clock speed was never getting set */
      			int show_options(char *game);
      			int set_last_game_selected(char *game);
      			if(set_last_game_selected(playgame) == -1) break;  /* game not available */
      			if(!show_options(playgame)) break;   /* return back to external menu */
      			SetGP2XClock(gp2x_freq); /* 9/5/06 Zaq, clock speed was never getting set */
    		}
		/* <- end mod */
#endif
		/* Initialize the audio library */
		msdos_init_seal();
		
		/* Restore MAME Palette */
		gp2x_mame_palette();
		
		/* Set Log Messages start at row 0 */
		gp2x_gamelist_zero();

		/* Single Video Buffer for Log Messages */
		gp2x_clear_screen();

		game_index = -1;

		/* do we have a driver for this? */
		for (i = 0; drivers[i] && (game_index == -1); i++)
		{
			if (strcasecmp(playgame,drivers[i]->name) == 0)
			{
				game_index = i;
				break;
			}
		}
	
		if (game_index == -1)
		{
			sprintf(text,"Game \"%s\" not supported\0",playgame);
			gp2x_text_log(text);
			while(1); /* MAME never ends xD */
		}

		/* parse generic (os-independent) options */
		parse_cmdline (argc, argv, &options, game_index);
	
		{	/* Mish:  I need sample rate initialised _before_ rom loading for optional rom regions */
			extern int soundcard;

			if (soundcard == 0) {    /* silence, this would be -1 if unknown in which case all roms are loaded */
				Machine->sample_rate = 0; /* update the Machine structure to show that sound is disabled */
				options.samplerate=0;
			}
		}

		sprintf(text,"Loading \"%s\"...",drivers[game_index]->description);
		gp2x_text_log(text);
	
		/* go for it */
		filecache_init();
		res = run_game (game_index , &options);
		
#if !defined(GP2X) && defined(USE_FILECACHE)
		if ( res != 0)
		{
			gp2x_text_log("Retrying without filecache...");
			filecache_disable();
			res = run_game (game_index , &options);
		}
#endif
		/* Error? */
		if( res != 0 )
		{
#ifdef PSP
			gp2x_text_log("LOAD FAILED: Press [] button...");
#else
			gp2x_text_log("LOAD FAILED: Press A button...");
#endif
			while (!(gp2x_joystick_read()&GP2X_A));
			while ((gp2x_joystick_read()&GP2X_A));
		}

#ifdef GP2X
		/* Zaq121 07/05/2006 Alternative frontend support -> */
    		if(no_selector) break;
		/* <- end mod */
#endif

	} /* MAME never ends xD */
}