static void gp2x_intro_screen(void) {
	char name[256];
	FILE *f;
	gp2x_video_flip();
	sprintf(name,get_documents_path("skins/splash.bmp"));
	f=fopen(name,"rb");
	if (f) {
		fread(gp2xsplash_bmp,1,77878,f);
		fclose(f);
	}

	while(1)
	{
		load_bmp_8bpp(gp2x_screen8,gp2xsplash_bmp);
		gp2x_video_flip();
		int ExKey=gp2x_joystick_read(0);
		if(ExKey!=0)break;
		gp2x_timer_delay(50);
	}
	sprintf(name,get_documents_path("skins/menu.bmp"));
	f=fopen(name,"rb");
	if (f) {
		fread(gp2xmenu_bmp,1,77878,f);
		fclose(f);
	}
}
static void game_list_init(void)
{
	int i;
	DIR *d=opendir(get_documents_path("roms"));
	char game[32];
	if (d)
	{
		struct dirent *actual=readdir(d);
		while(actual)
		{
			for (i=0;i<NUMGAMES;i++)
			{
				if (_drivers[i].available==0)
				{
					sprintf(game,"%s.zip",_drivers[i].name);
					if (strcmp(actual->d_name,game)==0)
					{
						_drivers[i].available=1;
						game_num_avail++;
						break;
					}
				}
			}
			actual=readdir(d);
		}
		closedir(d);
	}
}
Exemplo n.º 3
0
static void favorites_read(void)
{
    //SQ: Read the favorites list from the favorites.ini file
    FILE *file;
    char filename[1024];
    int counter=0;
    int startread=0;
    
    favarray[0][0] = '\0';
    
    sprintf(filename,get_documents_path("folders/Favorites.ini"));
    
    file = fopen (filename, "r");
    if ( file != NULL )
    {
        char line[256]; /* or other suitable maximum line size */

        while ( fgets(line, sizeof line, file) != NULL ) /* read a line */
        {
            if (line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = '\0';
            if (line[strlen(line) - 1] == '\r') line[strlen(line) - 1] = '\0';

            if (line[0] == '[' || line[0] == '\0' || strlen(line) > 8) continue;

            //Everything checks out so stick the line in the array
            strcpy(favarray[counter++], line);
			if(counter == MAXFAVS-2) break;
        }
        fclose ( file );
		favarray[counter][0] = '\0';
    }
}
Exemplo n.º 4
0
void get_rom_sample_path (int argc, char **argv, int game_index)
{
	int i;

	alternate_name = 0;
	mame_argc = argc;
	mame_argv = argv;
	game = game_index;
    
	//rompath    = get_string ("directory", "rompath",    NULL, IMAMEBASEPATH "/roms");
    strcpy(romPathBuffer, get_documents_path("."));
    rompath = romPathBuffer;
	//samplepath = get_string ("directory", "samplepath", NULL, IMAMEBASEPATH "/samples");
    strcpy(samplePathBuffer, get_resource_path("samples"));
    samplepath = samplePathBuffer;
    
	/* handle '-romdir' hack. We should get rid of this BW */
	alternate_name = 0;
	for (i = 1; i < argc; i++)
	{
		if (strcasecmp (argv[i], "-romdir") == 0)
		{
			i++;
			if (i < argc) alternate_name = argv[i];
		}
	}

	/* decompose paths into components (handled by fileio.c) */
	decompose_rom_sample_path (rompath, samplepath);
}
Exemplo n.º 5
0
static void favorites_add(char *game) 
{
    //SQ:Add the game to the favorites file
    FILE *file;
    char filename[1024];
    
    //SQ:Make sure the directory exists before creating a new file
    mkdir(get_documents_path("folders"), 0777);
    
    sprintf(filename,get_documents_path("folders/Favorites.ini"));
    file = fopen(filename, "a");
    if (file != NULL) {
        fputs(game, file);
        fputc('\n', file);
        fclose(file);
    }
    
    //SQ:All done so re-read the favorites array
    favorites_read();
}
Exemplo n.º 6
0
static void favorites_remove(char *game) 
{
    //SQ: Scan through the favorites file and remove
    //the requested line, creating a new file.
    FILE *file, *file2;
    char filename[1024], filename2[1024];
    int counter=0;
    int startread=0;

    sprintf(filename,get_documents_path("folders/Favorites.ini"));
    sprintf(filename2, "%s.new", filename);
    
    file = fopen (filename, "r");
    file2 = fopen (filename2, "w");
    if ( file != NULL && file2 != NULL) {
        char line[256]; 
        char line2[256];
        
        while ( fgets(line, sizeof line, file) != NULL ) { /* read a line */
            strcpy(line2, line);
            
            if (line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = '\0';
            if (line[strlen(line) - 1] == '\r') line[strlen(line) - 1] = '\0';
            
            if (line[0] != '[' && line[0] != '\0' && strlen(line) <= 8) {
                if (strcmp(line, game) == 0) {
                    continue;
                }                     
            }
            fputs(line2, file2); 
            
        }
        fclose (file);
        fclose (file2);
        
        //Move the new file over the old one.
        rename(filename2, filename);
    }
    
    //SQ:All done so re-read the favorites array
    favorites_read();
} 
extern "C" int android_main  (int argc, char **argv)
{
	FILE *f;

	__android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "init iOS frontend");
	//printf("init iOS frontend\n");
/*
	mkdir(get_documents_path("iOS"), 0755);
	mkdir(get_documents_path("cfg"), 0755);
	mkdir(get_documents_path("hi"), 0755);
*/
	__android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "creados directorios");

	/* GP2X Initialization */
	gp2x_init(1000,8,22050,16,0,60);

	//hack: por defecto lentos van a 11000
	m4all_sound = 4;
	m4all_video_depth = 16;

	if(m4all_HiSpecs)
	{
		m4all_clock_cpu= 100;
		m4all_clock_sound= 100;
		m4all_buttons=2;
		m4all_sound=12;
	}

	/* Show intro screen */
	gp2x_intro_screen();

	/* Initialize list of available games */
	game_list_init(argc);

	/*
	if (game_num_avail==0)
	{   while(true){
		gp2x_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND");
		gp2x_video_flip();
		gp2x_joystick_press(0);
		//gp2x_exit();
		sleep(1);}
		exit(0);
	}
    */

	while(true)
	{
	/* Read default configuration */
	f=fopen(get_documents_path("frontend/mame_v2.cfg"),"r");
	if (f) {
		fscanf(f,"%d",&last_game_selected);
		fclose(f);
	}
	
	/* Select Game */
	select_game(playemu,playgame); 

	/* Write default configuration */
	f=fopen(get_documents_path("frontend/mame_v2.cfg"),"w");
	if (f) {
		fprintf(f,"%d",last_game_selected);
		fclose(f);
		sync();
	}
	
	/* Execute Game */
	execute_game (playemu,playgame);


	}
	exit (0);
}
void execute_game (char *playemu, char *playgame)
{
	char *args[255];
	char str[8][64];
	int n=0;
	int i=0;
	
	/* executable */
	args[n]=playemu; n++;

	/* playgame */
	args[n]=playgame; n++;
/*
	args[n]="-depth"; n++;
	if(!safe_render_path)
		args[n]="8";
	else
		args[n]="16";
	n++;
	*/

	/* gp2x_video_depth */
	if (m4all_video_depth==8)
	{
		args[n]="-depth"; n++;
		args[n]="8"; n++;
	}
	if (m4all_video_depth==16)
	{
		args[n]="-depth"; n++;
		args[n]="16"; n++;
	}

	/* iOS_video_aspect */
	m4all_aspectRatio = m4all_cropVideo = m4all_fixedRes = 0;
    if (m4all_video_aspect==0)
	{
    	m4all_aspectRatio = 1;
    }else if(m4all_video_aspect==1){
		m4all_cropVideo = 1;
    }else if(m4all_video_aspect==2){
		m4all_cropVideo = 2;
    }else if(m4all_video_aspect==3){
		m4all_fixedRes = 1;
		//printf("fixed %d,%d,%d\n",iOS_aspectRatio,iOS_cropVideo,iOS_320x240);
    }else if(m4all_video_aspect==4){
		m4all_fixedRes = 2;
    }else if(m4all_video_aspect==5){
		m4all_fixedRes = 3;
    }else if(m4all_video_aspect==6){
		m4all_fixedRes = 4;
    }

	/* iOS_video_rotate */
	if ((m4all_video_rotate>=1) && (m4all_video_rotate<=2))
	{
		args[n]="-ror"; n++;
	}

	if ((m4all_video_rotate>=2) && (m4all_video_rotate<=2))
	{
		args[n]="-rotatecontrols"; n++;
	}
	
	/* iOS_video_sync */
    if (m4all_video_sync==1)
	{
		args[n]="-nodirty"; n++;
	}
	else if (m4all_video_sync==-1)
	{
		args[n]="-nothrottle"; n++;
	}
	
	/* iOS_frameskip */
	if (m4all_frameskip>=0)
	{
		args[n]="-frameskip"; n++;
		sprintf(str[i],"%d",m4all_frameskip);
		args[n]=str[i]; i++; n++;
	}

	/* iOS_sound */
	if (m4all_sound==0)
	{
		args[n]="-soundcard"; n++;
		args[n]="0"; n++;
	}
	if ((m4all_sound==1) || (m4all_sound==5) || (m4all_sound==9))
	{
		args[n]="-samplerate"; n++;
		args[n]="11025"; n++;
	}
	if ((m4all_sound==2) || (m4all_sound==6) || (m4all_sound==10))
	{
		args[n]="-samplerate"; n++;
		args[n]="22050"; n++;
	}
	if ((m4all_sound==3) || (m4all_sound==7) || (m4all_sound==11))
	{
		args[n]="-samplerate"; n++;
		args[n]="32000"; n++;
	}
	if ((m4all_sound==4) || (m4all_sound==8) || (m4all_sound==12))
	{
		args[n]="-samplerate"; n++;
		args[n]="44100"; n++;
	}

	if ((m4all_sound>=1) && (m4all_sound<=4))
	{
		args[n]="-fastsound"; n++;
	}
	if (m4all_sound>=9)
	{
		args[n]="-stereo"; n++;
	}

	/* iOS_clock_cpu */
	if (m4all_clock_cpu!=100)
	{
		args[n]="-uclock"; n++;
		sprintf(str[i],"%d",100-m4all_clock_cpu);
		args[n]=str[i]; i++; n++;
	}

	/* iOS_clock_sound */
	if (m4all_clock_cpu!=100)
	{
		args[n]="-uclocks"; n++;
		sprintf(str[i],"%d",100-m4all_clock_sound);
		args[n]=str[i]; i++; n++;
	}

	__android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "ASM CORES %d %d\n",m4all_ASMCores,m4all_cpu_cores);

	/* cpu_cores */
	if(m4all_ASMCores)
	{
		if ((m4all_cpu_cores==1) || (m4all_cpu_cores==3) || (m4all_cpu_cores==5) || (m4all_cpu_cores==6))
		{
			args[n]="-cyclone"; n++;
		}

		if ((m4all_cpu_cores==2) || (m4all_cpu_cores==3) || (m4all_cpu_cores==6))
		{
			args[n]="-drz80"; n++;
		}

		if ((m4all_cpu_cores==4) || (m4all_cpu_cores==5) || (m4all_cpu_cores==6))
		{
			args[n]="-drz80_snd"; n++;
		}
	}

	if (m4all_cheat)
	{
		args[n]="-cheat"; n++;
	}

	if (0)
	{
		args[n]="-romdir"; n++;
		sprintf(str[i],"%s",get_documents_path("roms"));
		args[n]=str[i]; i++; n++;
	}

	args[n]=NULL;
	
	for (i=0; i<n; i++)
	{
		printf("%s ",args[i]);
		__android_log_print(ANDROID_LOG_DEBUG, "libMAME4all.so", "arg: %s\n",args[i]);
	}
	printf("\n");
	
	m4all_inGame = 1;
	m4all_exitGame=0;
	m4all_hide_LR = m4all_buttons!=6;
	m4all_BplusX = m4all_buttons==3;
	m4all_landscape_buttons = m4all_buttons <= 3 ? m4all_buttons : (m4all_buttons - 1) ;
	//gp2x_set_video_mode(16,320,240);

	my_android_main(n, args);

	if(m4all_HiSpecs)
		m4all_buttons=2;
	else
		m4all_buttons=2;

	m4all_hide_LR = 0;
	m4all_BplusX = 0;

	m4all_exitGame=0;
	m4all_inGame = 0;
	m4all_landscape_buttons = 2;
	emulated_width = 320;
	emulated_height = 240;
	gp2x_set_video_mode(16,320,240);

}
static int show_options(char *game)
{
	unsigned long ExKey=0;
	int selected_option=0;
	int x_Pos = 41;
	int y_Pos = 43;
	int options_count = 12;
	char text[256];
	FILE *f;
	int i=0;

	while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){
		gp2x_video_flip();
		gp2x_timer_delay(1);
	};

	/* Read game configuration */
	sprintf(text,get_documents_path("frontend/%s_v5.cfg"),game);
	f=fopen(text,"r");
	if (f) {
		fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&m4all_video_aspect,&m4all_video_rotate,&m4all_video_sync,
		&m4all_frameskip,&m4all_sound,&m4all_buttons,&m4all_clock_cpu,&m4all_clock_sound,&i,&m4all_cheat,&m4all_video_depth,&m4all_waysStick,&m4all_cpu_cores);
		fclose(f);
	}

	while(1)
	{
		/* Draw background image */
		load_bmp_8bpp(gp2x_screen8,gp2xmenu_bmp);

		/* Draw the options */
		gp2x_gamelist_text_out(x_Pos,y_Pos,"Selected Game:\0");
		strncpy (text,game_list_description(last_game_selected),33);
		text[32]='\0';
		gp2x_gamelist_text_out(x_Pos,y_Pos+10,text);

		/* (1) Video Aspect */
		switch (m4all_video_aspect)
		{
			case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Original"); break;
			/*
			case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Ratio Not Kept"); break;
			*/
			case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Cropping 4/3"); break;
			case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Cropping 3/4"); break;

			case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Fixed 320x240"); break;
			case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Fixed 240x320"); break;
			case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Fixed 640x480"); break;
			case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Fixed 480x640"); break;
		}

		/* (2) Video Rotation */
		switch (m4all_video_rotate)
		{
			case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate  No"); break;
			case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate  Yes"); break;
			case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate  TATE"); break;
		}
		
		/* (3) Video Depth */
		switch (m4all_video_depth)
		{
			case -1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Video Depth   Auto"); break;
			case 8:  gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Video Depth   8 bit"); break;
			case 16: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+50,"Video Depth   16 bit"); break;
		}

		/* (4) Video Sync */
		switch (m4all_video_sync)
		{
			case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+60, "Video Sync    Normal"); break;
			case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+60, "Video Sync    DblBuf"); break;
			case -1: gp2x_gamelist_text_out(x_Pos,y_Pos+60,"Video Sync    OFF"); break;
		}
		
		/* (5) Frame-Skip */
		if(m4all_frameskip==-1) {
			gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70, "Frame-Skip    Auto");
		}
		else{
			gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Frame-Skip    %d",m4all_frameskip);
		}

		/* (6) Sound */
		switch(m4all_sound)
		{
			case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","OFF"); break;

			case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (11 KHz fast)"); break;
			case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (22 KHz fast)"); break;
			case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (33 KHz fast)"); break;
			case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (44 KHz fast)"); break;

			case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (11 KHz)"); break;
			case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (22 KHz)"); break;
			case 7: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (33 KHz)"); break;
			case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (44 KHz)"); break;

			case 9: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (11 KHz stereo)"); break;
			case 10: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (22 KHz stereo)"); break;
			case 11: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (33 KHz stereo)"); break;
			case 12: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+80,"Sound         %s","ON (44 KHz stereo)"); break;

		}

		/* (7) Landscape Num Buttons */
		switch (m4all_waysStick)
		{
			case 8: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "Stick         8-way"); break;
			case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "Stick         4-way"); break;
			case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+90, "Stick         2-way"); break;
		}

		/* (8) Landscape Num Buttons */
		switch (m4all_buttons)
		{
		    case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons   0 Button"); break;
		    case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons   1 Button"); break;
			case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons   2 Buttons"); break;
			case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons   3 Buttons (A=B+X)"); break;
			case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons   3 Buttons"); break;
			case 5: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons   4 Buttons"); break;
			case 6: gp2x_gamelist_text_out(x_Pos,y_Pos+100, "Num Buttons   All Buttons"); break;
		}

		/* (9) CPU Clock */
		gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+110,"CPU Clock     %d%%",m4all_clock_cpu);

		/* (10) Audio Clock */
		gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+120,"Audio Clock   %d%%",m4all_clock_sound);

		/* (11) CPU ASM Cores */

		if(m4all_ASMCores)
		{
			switch (m4all_cpu_cores)
			{
				case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores None"); break;
				case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores Cyclone"); break;
				case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores DrZ80"); break;
				case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores Cyclone+DrZ80"); break;
				case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores DrZ80(snd)"); break;
				case 5: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores Cyclone+DrZ80(snd)"); break;
				case 6: gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores All"); break;
			}
		}
		else
		{
			gp2x_gamelist_text_out(x_Pos,y_Pos+130, "CPU ASM cores None");
		}

		/* (12) Cheats */
		if (m4all_cheat)
			gp2x_gamelist_text_out(x_Pos,y_Pos+140,"Cheats        ON");
		else
			gp2x_gamelist_text_out(x_Pos,y_Pos+140,"Cheats        OFF");

	
		gp2x_gamelist_text_out(x_Pos,y_Pos+160,"Press B to confirm, X to return\0");

		/* Show currently selected item */
		gp2x_gamelist_text_out(x_Pos-16,y_Pos+(selected_option*10)+30," >");

		gp2x_video_flip();

		gp2x_timer_delay(150);
		ExKey=gp2x_joystick_read(0)&0x8c0ff55;

		if(ExKey & GP2X_DOWN){
			selected_option++;
			selected_option = selected_option % options_count;
		}
		else if(ExKey & GP2X_UP){
			selected_option--;
			if(selected_option<0)
				selected_option = options_count - 1;
		}
		else if(ExKey & GP2X_R || ExKey & GP2X_L || ExKey & GP2X_RIGHT || ExKey & GP2X_LEFT)
		{
			switch(selected_option) {
			case 0:
				if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT))
				{
					m4all_video_aspect++;
					if (m4all_video_aspect>6)
						m4all_video_aspect=0;
				}
				else
				{

					m4all_video_aspect--;
					if (m4all_video_aspect<0)
						m4all_video_aspect=6;
				}
				break;
			case 1:
				if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT))
				{
					m4all_video_rotate++;
					if (m4all_video_rotate>2)
						m4all_video_rotate=0;
				}
				else
				{
					m4all_video_rotate--;
					if (m4all_video_rotate<0)
						m4all_video_rotate=2;
				}
				break;
			case 2:
				switch (m4all_video_depth)
				{
					case -1: m4all_video_depth=8; break;
					case 8: m4all_video_depth=16; break;
					case 16: m4all_video_depth=-1; break;
				}
				break;
			case 3:
				m4all_video_sync=m4all_video_sync+1;
				if (m4all_video_sync>1)
					m4all_video_sync=-1;
				break;
			case 4:
				/* "Frame-Skip" */
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT )
				{
					m4all_frameskip ++;
					if (m4all_frameskip>11)
						m4all_frameskip=-1;
				}
				else
				{
					m4all_frameskip--;
					if (m4all_frameskip<-1)
						m4all_frameskip=11;
				}
				break;
			case 5:
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					m4all_sound ++;
					if (m4all_sound>12)
						m4all_sound=0;
				}
				else
				{
					m4all_sound--;
					if (m4all_sound<0)
						m4all_sound=12;
				}
				break;
			case 6:
				switch (m4all_waysStick)
				{
					case 8: m4all_waysStick=4; break;
					case 4: m4all_waysStick=2; break;
					case 2: m4all_waysStick=8; break;
				}
				break;
			case 7:
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					m4all_buttons ++;
					if (m4all_buttons>6)
						m4all_buttons=0;
				}
				else
				{
					m4all_buttons--;
					if (m4all_buttons<0)
						m4all_buttons=6;
				}
				break;
			case 8:
				/* "CPU Clock" */
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					m4all_clock_cpu += 10; /* Add 10% */
					if (m4all_clock_cpu > 200) /* 200% is the max */
						m4all_clock_cpu = 200;
				}
				else
				{
					m4all_clock_cpu -= 10; /* Subtract 10% */
					if (m4all_clock_cpu < 10) /* 10% is the min */
						m4all_clock_cpu = 10;
				}
				break;
			case 9:
				/* "Audio Clock" */
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					m4all_clock_sound += 10; /* Add 10% */
					if (m4all_clock_sound > 200) /* 200% is the max */
						m4all_clock_sound = 200;
				}
				else{
					m4all_clock_sound -= 10; /* Subtract 10% */
					if (m4all_clock_sound < 10) /* 10% is the min */
						m4all_clock_sound = 10;
				}
				break;
			case 10:
				m4all_cpu_cores=(m4all_cpu_cores+1)%7;
				break;
			case 11:
				m4all_cheat=!m4all_cheat;
				break;
			}
		}

		if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START))
		{
			/* Write game configuration */
			sprintf(text,get_documents_path("frontend/%s_v5.cfg"),game);
			f=fopen(text,"w");
			if (f) {
				fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",m4all_video_aspect,m4all_video_rotate,m4all_video_sync,
				m4all_frameskip,m4all_sound,m4all_buttons,m4all_clock_cpu,m4all_clock_sound,i,m4all_cheat,m4all_video_depth,m4all_waysStick,m4all_cpu_cores);
				fclose(f);
				sync();
			}

			/* Selected game will be run */
			return 1;
		}
		else if ((ExKey & GP2X_X) || (ExKey & GP2X_Y) || (ExKey & GP2X_SELECT))
		{
			/* Return To Menu */
			return 0;
		}
	}
}
Exemplo n.º 10
0
static void game_list_init(void)
{
	int i, j;
    int skipflag=0;
    int counter;
	int check_neogeo=0, check_other=0;

	//SQ: read the favorites
    favorites_read();	

    //SQ: Read the directory rom listing into memory to cache it for later filtering
	//We only cache the game index not the actual rom name
    if(!game_list_num) {
        DIR *d=opendir(get_documents_path("."));
        game_num_avail=0;
        if (d)
        {
			char tempstr[50];
            struct dirent *actual=readdir(d);
            while(actual)
            {
                if(strlen(actual->d_name) > 5) {
				    strcpy(tempstr, actual->d_name);
                    tempstr[(strlen(tempstr) - 4)] = '\0';	//remove .zip to compare in loop
                    for (i=0;i<NUMGAMES;i++) {
                        if (strcmp(tempstr, _drivers[i].name)==0) {
    						game_list_array[game_list_num++] = i;
                            break;
                        }
                    }
				}
                actual=readdir(d);
			}
            closedir(d);
		}
        local_game_list_num=game_list_num;
	}

    //SQ: Reset list, may happen if filter changes
    for (i=0;i<NUMGAMES;i++) {
        _drivers[i].available=0;
    }

	//SQ: Set these flags to save many string comparisons in loop below
	if (strcmp(manufact_array[global_manufacturer], "NeoGeo") == 0) check_neogeo=1;
    if (strcmp(manufact_array[global_manufacturer], "Other") == 0) check_other=1;
    
    game_num_avail=0;
    
	//SQ:game_list_array contains a list of all the ROMS in the /roms directory
    for(j=0;j<game_list_num;j++) {
        for (i=0;i<NUMGAMES;i++)
        {                
            if (!_drivers[i].available)
            {
                if (game_list_array[j] == i)     //Found a matching game
                {
                    skipflag=0;

                    //SQ:Are clones to be displayed
                    if (!global_clones && !skipflag) {
                        if (_drivers[i].clone) skipflag=1;
                    }

                    //SQ:If manufacturers is filtered, only display the relevant games
                    if (global_manufacturer && !skipflag) {
                        skipflag=1;

						//SQ:Check for Neogeo games if Neogeo selected, special case as its driver specific
                		if (check_neogeo) {
                        	if (strcmp(_drivers[i].exe, "neomame") == 0) skipflag=0;   
						} 
                		else if (check_other) {	//SQ:find all manufacturers that aren't in the list
							int x=0, mfound=0;
							while(true) {
							    if (strstr(_drivers[i].manufacturer, manufact_array[x])) {
									mfound=1;
									break;
								}
								x++;
								if(manufact_array[x][0] == '\0') break;
							}
							if(!mfound) skipflag=0;
						}
                        else if (strstr(_drivers[i].manufacturer, manufact_array[global_manufacturer])) skipflag=0;
                    }        

                    //SQ:Check category filter
                    if (global_category && !skipflag) {
                        if (!strstr(_drivers[i].category, category_array[global_category])) skipflag=1;
                    }        
                    
					//SQ:Filter by year
					if(global_year && !skipflag) {
						if((global_year + 1974) != _drivers[i].year) skipflag=1;
					}
                    
                    //SQ:Show only favorites
                    if(global_filter == 1 && !skipflag) {	
                        skipflag=1;
                        counter=0;
                        while(true) {
                            if (favarray[counter][0] == '\0') break;	//Null is the array terminator
                            if (strcasecmp(favarray[counter], _drivers[i].name) == 0) {
                                skipflag=0;
                                break;
                            }
                            counter++;
                        }
                    }

                    //SQ:Everything matches so add to list
                    if(!skipflag) {                       
                        _drivers[i].available=1;
                        game_num_avail++;
                    }
                    break;
                }
            }
        }
	}
    
}
Exemplo n.º 11
0
extern "C" int mimain (int argc, char **argv)
{
	FILE *f;


	printf("init iOS frontend\n");
	/* GP2X Initialization */
	gp2x_init(1000,8,22050,16,0,60);

	//hack: por defecto lentos van a 11000
	if(!safe_render_path)
	{
		iOS_sound = global_sound;
		iOS_video_depth = 8;
	}
	else
	{
		iOS_sound = global_sound;
		iOS_video_depth = 16;
	}

	if(isIpad)
	{
		iOS_clock_cpu= 100;
		iOS_clock_sound= 100;
		iOS_buttons=2;
		iOS_sound=global_sound;
	}

	/* Show intro screen */
	gp2x_intro_screen();

    local_manufacturer = global_manufacturer;
    local_clones = global_clones;
    local_filter = global_filter;
    local_category = global_category;
    local_year = global_year;
    
	/* Initialize list of available games */
	game_list_init(argc);

	/*
	if (game_num_avail==0)
	{   while(true){
		gp2x_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND");
		gp2x_video_flip();
		gp2x_joystick_press(0);
		//gp2x_exit();
		sleep(1);}
		exit(0);
	}
    */

	while(true)
	{
	/* Read default configuration */
	f=fopen(get_documents_path("iOS/mame_v2.cfg"),"r");
	if (f) {
		fscanf(f,"%d",&last_game_selected);
		fclose(f);
	}
	
	/* Select Game */
	select_game(playemu,playgame); 

	/* Write default configuration */
	f=fopen(get_documents_path("iOS/mame_v2.cfg"),"w");
	if (f) {
		fprintf(f,"%d",last_game_selected);
		fclose(f);
		sync();
	}
	
	/* Execute Game */
	execute_game (playemu,playgame);



	}
	exit (0);
}
Exemplo n.º 12
0
void execute_game (char *playemu, char *playgame)
{
	char *args[255];
	char str[8][64];
	int n=0;
	int i=0;
	
	/* executable */
	args[n]=playemu; n++;

	/* playgame */
	args[n]=playgame; n++;
/*
	args[n]="-depth"; n++;
	if(!safe_render_path)
		args[n]="8";
	else
		args[n]="16";
	n++;
	*/

	/* gp2x_video_depth */
	if (iOS_video_depth==8)
	{
		args[n]="-depth"; n++;
		args[n]="8"; n++;
	}
	if (iOS_video_depth==16)
	{
		args[n]="-depth"; n++;
		args[n]="16"; n++;
	}

	/* iOS_video_aspect */
	iOS_aspectRatio = iOS_cropVideo = iOS_fixedRes = 0;
    if (iOS_video_aspect==0)
	{
    	iOS_aspectRatio = 1;
    }else if(iOS_video_aspect==1){
		iOS_cropVideo = 1;
    }else if(iOS_video_aspect==2){
		iOS_cropVideo = 2;
    }else if(iOS_video_aspect==3){
		iOS_fixedRes = 1;
		//printf("fixed %d,%d,%d\n",iOS_aspectRatio,iOS_cropVideo,iOS_320x240);
    }else if(iOS_video_aspect==4){
		iOS_fixedRes = 2;
    }else if(iOS_video_aspect==5){
		iOS_fixedRes = 3;
    }else if(iOS_video_aspect==6){
		iOS_fixedRes = 4;
    }

	/* iOS_video_rotate */
	if ((iOS_video_rotate>=1) && (iOS_video_rotate<=2))
	{
		args[n]="-ror"; n++;
	}

	if ((iOS_video_rotate>=2) && (iOS_video_rotate<=2))
	{
		args[n]="-rotatecontrols"; n++;
	}
	
	/* iOS_video_sync */
    if (iOS_video_sync==1)
	{
		args[n]="-nodirty"; n++;
	}
	else if (iOS_video_sync==-1)
	{
		args[n]="-nothrottle"; n++;
	}
	
	/* iOS_frameskip */
	if (iOS_frameskip>=0)
	{
		args[n]="-frameskip"; n++;
		sprintf(str[i],"%d",iOS_frameskip);
		args[n]=str[i]; i++; n++;
	}

	/* iOS_sound */
	if (iOS_sound==0)
	{
		args[n]="-soundcard"; n++;
		args[n]="0"; n++;
	}
	if ((iOS_sound==1) || (iOS_sound==5) || (iOS_sound==9))
	{
		args[n]="-samplerate"; n++;
		args[n]="11025"; n++;
	}
	if ((iOS_sound==2) || (iOS_sound==6) || (iOS_sound==10))
	{
		args[n]="-samplerate"; n++;
		args[n]="22050"; n++;
	}
	if ((iOS_sound==3) || (iOS_sound==7) || (iOS_sound==11))
	{
		args[n]="-samplerate"; n++;
		args[n]="32000"; n++;
	}
	if ((iOS_sound==4) || (iOS_sound==8) || (iOS_sound==12))
	{
		args[n]="-samplerate"; n++;
		args[n]="44100"; n++;
	}

	if ((iOS_sound>=1) && (iOS_sound<=4))
	{
		args[n]="-fastsound"; n++;
	}
	if (iOS_sound>=9)
	{
		args[n]="-stereo"; n++;
	}

	/* iOS_clock_cpu */
	if (iOS_clock_cpu!=100)
	{
		args[n]="-uclock"; n++;
		sprintf(str[i],"%d",100-iOS_clock_cpu);
		args[n]=str[i]; i++; n++;
	}

	/* iOS_clock_sound */
	if (iOS_clock_cpu!=100)
	{
		args[n]="-uclocks"; n++;
		sprintf(str[i],"%d",100-iOS_clock_sound);
		args[n]=str[i]; i++; n++;
	}

	if (iOS_cheat)
	{
		args[n]="-cheat"; n++;
	}

	if (0)
	{
		args[n]="-romdir"; n++;
		sprintf(str[i],"%s",get_documents_path("roms"));
		args[n]=str[i]; i++; n++;
	}

	args[n]=NULL;
	
	for (i=0; i<n; i++)
	{
		printf("%s ",args[i]);
	}
	printf("\n");
	
	iOS_inGame = 1;
	iOS_exitGame=0;
	iOS_hide_LR = iOS_buttons!=6;
	iOS_BplusX = iOS_buttons==3;
	iOS_landscape_buttons = iOS_buttons <= 3 ? iOS_buttons : (iOS_buttons - 1) ;
	//gp2x_set_video_mode(16,320,240);
	iphone_main(n, args);

	if(isIpad)
		iOS_buttons=2;
	else
		iOS_buttons=2;

	iOS_hide_LR = 0;
	iOS_BplusX = 0;

	iOS_exitGame=0;
	iOS_inGame = 0;
	iOS_landscape_buttons = 2;
	emulated_width = 320;
	emulated_height = 240;
	gp2x_set_video_mode(16,320,240);

}
Exemplo n.º 13
0
void parse_cmdline (int argc, char **argv, int game_index)
{
	static float f_beam, f_flicker;
	char *resolution;
	char *joyname;
	char tmpres[10];
	int i;
	char *tmpstr;

	mame_argc = argc;
	mame_argv = argv;
	game = game_index;

	/* read graphic configuration */
	options.use_artwork = get_bool   ("config", "artwork",	NULL,  1);
	options.use_samples = get_bool   ("config", "samples",	NULL,  1);
	video_sync  = get_bool   ("config", "vsync",        NULL,  0);
	wait_vsync  = get_bool   ("config", "waitvsync",    NULL,  0);
	use_dirty	= get_bool	 ("config", "dirty",	NULL,	-1);
	options.antialias   = get_bool   ("config", "antialias",    NULL,  1);
	options.translucency = get_bool    ("config", "translucency", NULL, 1);

	tmpstr             = get_string ("config", "depth", NULL, "auto");
	options.color_depth = atoi(tmpstr);
	if (options.color_depth != 8 && options.color_depth != 16) options.color_depth = 0;	/* auto */

	skiplines   = get_int    ("config", "skiplines",    NULL, 0);
	skipcolumns = get_int    ("config", "skipcolumns",  NULL, 0);
	f_beam      = get_float  ("config", "beam",         NULL, 1.5);//TODO
	if (f_beam < 1.0) f_beam = 1.0;
	if (f_beam > 16.0) f_beam = 16.0;
	f_flicker   = get_float  ("config", "flicker",      NULL, 0.0);
	if (f_flicker < 0.0) f_flicker = 0.0;
	if (f_flicker > 100.0) f_flicker = 100.0;
	osd_gamma_correction = get_float ("config", "gamma",   NULL, 1.0);
	if (osd_gamma_correction < 0.5) osd_gamma_correction = 0.5;
	if (osd_gamma_correction > 2.0) osd_gamma_correction = 2.0;

	tmpstr = get_string ("config", "frameskip", "fs", "auto");
	if (!strcasecmp(tmpstr,"auto"))
	{
		frameskip = 0;
		autoframeskip = 1;
	}
	else
	{
		frameskip = atoi(tmpstr);
		autoframeskip = 0;
	}
	options.norotate  = get_bool ("config", "norotate",  NULL, 0);
	options.ror       = get_bool ("config", "ror",       NULL, 0);
	options.rol       = get_bool ("config", "rol",       NULL, 0);
	options.flipx     = get_bool ("config", "flipx",     NULL, 0);
	options.flipy     = get_bool ("config", "flipy",     NULL, 0);

	/* read sound configuration */
	soundcard           = get_int  ("config", "soundcard",  NULL, -1);

	options.use_emulated_ym3812 = !get_bool ("config", "ym3812opl",  NULL,  0);
	options.samplerate = get_int  ("config", "samplerate", "sr", 22050);
	if (options.samplerate < 5000) options.samplerate = 5000;
	if (options.samplerate > 44100) options.samplerate = 44100;
	usestereo           = get_bool ("config", "stereo",  NULL,  0);
	attenuation         = get_int  ("config", "volume",  NULL,  0);
	if (attenuation < -32) attenuation = -32;
	if (attenuation > 0) attenuation = 0;

	/* read input configuration */
	use_mouse = get_bool   ("config", "mouse",   NULL,  1);
	joyname   = get_string ("config", "joystick", "joy", "standard");

	/* misc configuration */
	options.cheat      = get_bool ("config", "cheat", NULL, 0);
	options.mame_debug = get_bool ("config", "debug", NULL, 0);

	cheatfile  = get_string ("config", "cheatfile", "cf", "cheat.dat");

 	history_filename  = get_string ("config", "historyfile", NULL, "history.dat");    /* JCK 980917 */

	mameinfo_filename  = get_string ("config", "mameinfofile", NULL, "mameinfo.dat");    /* JCK 980917 */

	/* get resolution */
	resolution  = get_string ("config", "resolution", NULL, "auto");

	/* set default subdirectories */
	/* no jailbreak - Les Bird
	nvdir      = get_string ("directory", "nvram",   NULL, IMAMEBASEPATH "/nvram" );
	hidir      = get_string ("directory", "hi",      NULL, IMAMEBASEPATH "/hi");
	cfgdir     = get_string ("directory", "cfg",     NULL, IMAMEBASEPATH "/cfg");
	screenshotdir = get_string ("directory", "snap",     NULL, IMAMEBASEPATH "/snap");
	memcarddir = get_string ("directory", "memcard", NULL, IMAMEBASEPATH "/memcard");
	stadir     = get_string ("directory", "sta",     NULL, IMAMEBASEPATH "/sta");
	artworkdir = get_string ("directory", "artwork", NULL, IMAMEBASEPATH "/artwork");
	cheatdir = get_string ("directory", "cheat", NULL, IMAMEBASEPATH);
	 */
	// no jailbreak - Les Bird
	char tmp[1024];
	sprintf(tmp, "%s/nvram", get_iOS_BundlePath());
	nvdir = strdup(tmp);
	hidir = strdup(get_documents_path("hi"));
	cfgdir = strdup(get_documents_path("cfg"));
	screenshotdir = strdup(get_documents_path("snap"));
	memcarddir = strdup(get_documents_path("memcard"));
	stadir = strdup(get_documents_path("sta"));
	sprintf(tmp, "%s/artwork", get_iOS_BundlePath());
	artworkdir = strdup(tmp);
	sprintf(tmp, "%s/cheat", get_iOS_BundlePath());
	cheatdir = strdup(tmp);
	//
	
	logerror("cheatfile = %s - cheatdir = %s\n",cheatfile,cheatdir);

	//printf("cheatfile = %s - cheatdir = %s\n",cheatfile,cheatdir);
	//printf("cfgdir = %s\n",cfgdir);

	tmpstr = get_string ("config", "language", NULL, "english");
	options.language_file = osd_fopen(0,tmpstr,OSD_FILETYPE_LANGUAGE,0);

	/* this is handled externally cause the audit stuff needs it, too */
	get_rom_sample_path (argc, argv, game_index);

	/* process some parameters */
	options.beam = (int)(f_beam * 0x00010000);
	if (options.beam < 0x00010000)
		options.beam = 0x00010000;
	if (options.beam > 0x00100000)
		options.beam = 0x00100000;

	options.flicker = (int)(f_flicker * 2.55);
	if (options.flicker < 0)
		options.flicker = 0;
	if (options.flicker > 255)
		options.flicker = 255;

	/* any option that starts with a digit is taken as a resolution option */
	/* this is to handle the old "-wxh" commandline option. */
	for (i = 1; i < argc; i++)
	{
		if (argv[i][0] == '-' && isdigit(argv[i][1]) &&
				(strstr(argv[i],"x") || strstr(argv[i],"X")))
			resolution = &argv[i][1];
	}

	/* break up resolution into gfx_width and gfx_height */
	gfx_height = gfx_width = 0;
	if (strcasecmp (resolution, "auto") != 0)
	{
		char *tmp;
		strncpy (tmpres, resolution, 10);
		tmp = strtok (tmpres, "xX");
		gfx_width = atoi (tmp);
		tmp = strtok (0, "xX");
		if (tmp)
			gfx_height = atoi (tmp);

		options.vector_width = gfx_width;
		options.vector_height = gfx_height;
	}

	/* convert joystick name into an Allegro-compliant joystick signature */
	joystick = -2; /* default to invalid value */

	for (i = 0; joy_table[i].name != NULL; i++)
	{
		if (strcasecmp (joy_table[i].name, joyname) == 0)
		{
			joystick = joy_table[i].id;
			logerror("using joystick %s = %08x\n",
						joyname,joy_table[i].id);
			break;
		}
	}

	if (joystick == -2)
	{
		logerror("%s is not a valid entry for a joystick\n",
					joyname);
		joystick = JOY_TYPE_NONE;
	}

	/* Underclock settings */
	underclock_sound = get_int ("config", "uclocks",   NULL, 0);
	underclock_cpu   = get_int ("config", "uclock",    NULL, 0);

	/* Fast sound setting */
	fast_sound       = get_bool("config", "fastsound", NULL, 0);

	/* Rotate controls */
	rotate_controls       = get_bool("config", "rotatecontrols", NULL, 0);
}
Exemplo n.º 14
0
static int show_options(char *game)
{
	unsigned long ExKey=0;
	int selected_option=0;
	int x_Pos = 41;
	int y_Pos = 58;
	int options_count = 9;
	char text[256];
	FILE *f;
	int i=0;

	if(!safe_render_path)
	  while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){};

	/* Read game configuration */
	sprintf(text,get_documents_path("iOS/%s_v2.cfg"),game);
	f=fopen(text,"r");
	if (f) {
		fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&iOS_video_aspect,&iOS_video_rotate,&iOS_video_sync,
		&iOS_frameskip,&iOS_sound,&iOS_landscape_buttons,&iOS_clock_cpu,&iOS_clock_sound,&i,&iOS_cheat);
		fclose(f);
	}

	if(!safe_render_path)
	{
	   iOS_video_aspect=3;
	}

	while(1)
	{
		/* Draw background image */
		load_bmp_8bpp(gp2x_screen8,gp2xmenu_bmp);

		/* Draw the options */
		gp2x_gamelist_text_out(x_Pos,y_Pos,"Selected Game:\0");
		strncpy (text,game_list_description(last_game_selected),33);
		text[32]='\0';
		gp2x_gamelist_text_out(x_Pos,y_Pos+10,text);

		/* (1) Video Aspect */
		switch (iOS_video_aspect)
		{
			case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Original"); break;
			case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Ratio Not Kept"); break;
			case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  With Cropping"); break;
			case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+30,"Video Aspect  Fixed 320x240"); break;
		}

		/* (2) Video Rotation */
		switch (iOS_video_rotate)
		{
			case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate  No"); break;
			case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate  Yes"); break;
			case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+40,"Video Rotate  TATE"); break;
		}
		
		/* (3) Video Sync */
		switch (iOS_video_sync)
		{
			case 0: gp2x_gamelist_text_out(x_Pos,y_Pos+50, "Video Sync    Normal"); break;
			case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+50, "Video Sync    DblBuf"); break;
			case -1: gp2x_gamelist_text_out(x_Pos,y_Pos+50,"Video Sync    OFF"); break;
		}
		
		/* (4) Frame-Skip */
		if(iOS_frameskip==-1) {
			gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60, "Frame-Skip    Auto");
		}
		else{
			gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+60,"Frame-Skip    %d",iOS_frameskip);
		}

		/* (5) Sound */
		switch(iOS_sound)
		{
			case 0: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","OFF"); break;

			case 1: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (11 KHz fast)"); break;
			case 2: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (22 KHz fast)"); break;
			case 3: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (33 KHz fast)"); break;
			case 4: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (44 KHz fast)"); break;

			case 5: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (11 KHz)"); break;
			case 6: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (22 KHz)"); break;
			case 7: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (33 KHz)"); break;
			case 8: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (44 KHz)"); break;

			case 9: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (11 KHz stereo)"); break;
			case 10: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (22 KHz stereo)"); break;
			case 11: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (33 KHz stereo)"); break;
			case 12: gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+70,"Sound         %s","ON (44 KHz stereo)"); break;

		}

		/* (6) Landscape Num Buttons */
		switch (iOS_landscape_buttons)
		{
			case 1: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape     1 Button"); break;
			case 2: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape     2 Buttons"); break;
			case 3: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape     3 Buttons"); break;
			case 4: gp2x_gamelist_text_out(x_Pos,y_Pos+80, "Landscape     4 Buttons"); break;
		}

		/* (7) CPU Clock */
		gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+90,"CPU Clock     %d%%",iOS_clock_cpu);

		/* (8) Audio Clock */
		gp2x_gamelist_text_out_fmt(x_Pos,y_Pos+100,"Audio Clock   %d%%",iOS_clock_sound);


		/* (9) Cheats */
		if (iOS_cheat)
			gp2x_gamelist_text_out(x_Pos,y_Pos+110,"Cheats        ON");
		else
			gp2x_gamelist_text_out(x_Pos,y_Pos+110,"Cheats        OFF");
	
		gp2x_gamelist_text_out(x_Pos,y_Pos+140,"Press B to confirm, X to return\0");

		/* Show currently selected item */
		gp2x_gamelist_text_out(x_Pos-16,y_Pos+(selected_option*10)+30," >");

		gp2x_video_flip();

		if(safe_render_path)
		{
		   while(gp2x_joystick_read(0)&0x8c0ff55) { gp2x_timer_delay(150); }
		   while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55)) { }
		}
		else
		{
		   //ExKey=gp2x_joystick_read(0);
		   //gp2x_timer_delay(150);
		   gp2x_timer_delay(150);
		   ExKey=gp2x_joystick_read(0)&0x8c0ff55;
		}

		if(ExKey & GP2X_DOWN){
			selected_option++;
			selected_option = selected_option % options_count;
		}
		else if(ExKey & GP2X_UP){
			selected_option--;
			if(selected_option<0)
				selected_option = options_count - 1;
		}
		else if(ExKey & GP2X_R || ExKey & GP2X_L || ExKey & GP2X_RIGHT || ExKey & GP2X_LEFT)
		{
			switch(selected_option) {
			case 0:
				if(!safe_render_path)
				{
					iOS_video_aspect=3;
					break;
				}
				if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT))
				{
					iOS_video_aspect++;
					if (iOS_video_aspect>3)
						iOS_video_aspect=0;
				}
				else
				{
					iOS_video_aspect--;
					if (iOS_video_aspect<0)
						iOS_video_aspect=3;
				}
				break;
			case 1:
				if((ExKey & GP2X_R) || (ExKey & GP2X_RIGHT))
				{
					iOS_video_rotate++;
					if (iOS_video_rotate>2)
						iOS_video_rotate=0;
				}
				else
				{
					iOS_video_rotate--;
					if (iOS_video_rotate<0)
						iOS_video_rotate=2;
				}
				break;
			case 2:
				iOS_video_sync=iOS_video_sync+1;
				if (iOS_video_sync>1)
					iOS_video_sync=-1;
				break;
			case 3:
				/* "Frame-Skip" */
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT )
				{
					iOS_frameskip ++;
					if (iOS_frameskip>11)
						iOS_frameskip=-1;
				}
				else
				{
					iOS_frameskip--;
					if (iOS_frameskip<-1)
						iOS_frameskip=11;
				}
				break;
			case 4:
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					iOS_sound ++;
					if (iOS_sound>12)
						iOS_sound=0;
				}
				else
				{
					iOS_sound--;
					if (iOS_sound<0)
						iOS_sound=12;
				}
				break;
			case 5:
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					iOS_landscape_buttons ++;
					if (iOS_landscape_buttons>4)
						iOS_landscape_buttons=1;
				}
				else
				{
					iOS_landscape_buttons--;
					if (iOS_landscape_buttons<1)
						iOS_landscape_buttons=4;
				}
				break;
			case 6:
				/* "CPU Clock" */
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					iOS_clock_cpu += 10; /* Add 10% */
					if (iOS_clock_cpu > 200) /* 200% is the max */
						iOS_clock_cpu = 200;
				}
				else
				{
					iOS_clock_cpu -= 10; /* Subtract 10% */
					if (iOS_clock_cpu < 10) /* 10% is the min */
						iOS_clock_cpu = 10;
				}
				break;
			case 7:
				/* "Audio Clock" */
				if(ExKey & GP2X_R || ExKey & GP2X_RIGHT)
				{
					iOS_clock_sound += 10; /* Add 10% */
					if (iOS_clock_sound > 200) /* 200% is the max */
						iOS_clock_sound = 200;
				}
				else{
					iOS_clock_sound -= 10; /* Subtract 10% */
					if (iOS_clock_sound < 10) /* 10% is the min */
						iOS_clock_sound = 10;
				}
				break;
			case 8:
				iOS_cheat=!iOS_cheat;
				break;
			}
		}

		if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START))
		{
			/* Write game configuration */
			sprintf(text,get_documents_path("iOS/%s_v2.cfg"),game);
			f=fopen(text,"w");
			if (f) {
				fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",iOS_video_aspect,iOS_video_rotate,iOS_video_sync,
				iOS_frameskip,iOS_sound,iOS_landscape_buttons,iOS_clock_cpu,iOS_clock_sound,i,iOS_cheat);
				fclose(f);
				sync();
			}

			/* Selected game will be run */
			return 1;
		}
		else if ((ExKey & GP2X_X) || (ExKey & GP2X_Y) || (ExKey & GP2X_SELECT))
		{
			/* Return To Menu */
			return 0;
		}
	}
}