Ejemplo n.º 1
0
static void gp2x_intro_screen(int first_run) {
	char name[256];
	FILE *f;
	BITMAPFILEHEADER h;

	FE_DisplayScreen();

	sprintf(name,"skins/rpisplash16.bmp");

	f=fopen(name,"rb");
	if (f) {
		//Read header to find where to skip to for bitmap
        fread(&h, sizeof(BITMAPFILEHEADER), 1, f); //reading the FILEHEADER
		fseek(f, h.bfOffBits, SEEK_SET);

		fread(gp2xsplash_bmp,1,1000000,f);
		fclose(f);
	} 	
	else {
		printf("\nERROR: Splash screen missing from skins directory\n");
		gp2x_exit();
	}

	if(first_run) {
		load_bmp_16bpp(gp2x_screen15,gp2xsplash_bmp);
		FE_DisplayScreen();
		sleep(1);
	}
	
	sprintf(name,"skins/rpimenu16.bmp");
	f=fopen(name,"rb");
	if (f) {
		//Read header to find where to skip to for bitmap
        fread(&h, sizeof(BITMAPFILEHEADER), 1, f); //reading the FILEHEADER
		fseek(f, h.bfOffBits+sizeof(h), SEEK_SET);

		fread(gp2xmenu_bmp,1,1000000,f);
		fclose(f);
	} 
	else {
		printf("\nERROR: Menu screen missing from skins directory\n");
		gp2x_exit();
	}
}
Ejemplo n.º 2
0
static void select_game(char *emu, char *game)
{

	unsigned long ExKey;

	/* No Selected game */
	strcpy(game,"builtinn");

	/* Clean screen */
	gp2x_video_flip();

	/* Wait until user selects a game */
	while(1)
	{
		game_list_view(&last_game_selected);
		gp2x_video_flip();

		if( (gp2x_joystick_read(0)&0x8c0ff55)) 
			gp2x_timer_delay(100); 
		while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55))
		{ 
			if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) { gp2x_exit(); }
		}

		if (ExKey & GP2X_UP) last_game_selected--;
		if (ExKey & GP2X_DOWN) last_game_selected++;
		if (ExKey & GP2X_L) last_game_selected-=21;
		if (ExKey & GP2X_R) last_game_selected+=21;
		if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) gp2x_exit();

		if ((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START))
		{
			/* Select the game */
			game_list_select(last_game_selected, game, emu);

			/* Emulation Options */
			if(show_options(game))
			{
				break;
			}
		}
	}
}
Ejemplo n.º 3
0
int main (int argc, char **argv)
{
	FILE *f;

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

	/* Show intro screen */
	gp2x_intro_screen();

	/* Initialize list of available games */
	game_list_init(argc);
	if (game_num_avail==0)
	{
		gp2x_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND");
		gp2x_video_flip();
		gp2x_joystick_press(0);
		gp2x_exit();
	}

	/* Read default configuration */
	f=fopen("frontend/mame.cfg","r");
	if (f) {
		fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&gp2x_freq,&gp2x_video_depth,&gp2x_video_aspect,&gp2x_video_sync,
		&gp2x_frameskip,&gp2x_sound,&gp2x_clock_cpu,&gp2x_clock_sound,&gp2x_cpu_cores,&gp2x_ramtweaks,&last_game_selected,&gp2x_cheat,&gp2x_volume);
		fclose(f);
	}
	
	/* Select Game */
	select_game(playemu,playgame); 

	/* Write default configuration */
	f=fopen("frontend/mame.cfg","w");
	if (f) {
		fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",gp2x_freq,gp2x_video_depth,gp2x_video_aspect,gp2x_video_sync,
		gp2x_frameskip,gp2x_sound,gp2x_clock_cpu,gp2x_clock_sound,gp2x_cpu_cores,gp2x_ramtweaks,last_game_selected,gp2x_cheat,gp2x_volume);
		fclose(f);
		sync();
	}
	
	/* Execute Game */
	execute_game (playemu,playgame);
	
	exit (0);
}
Ejemplo n.º 4
0
unsigned long gp2x_joystick_read()
{
	// Reset mouse incase there is no motion
	mouse_motion_process(0,0);

	SDL_Event event;
	while (SDL_PollEvent(&event) > 0) {
		switch(event.type)
		{
			case SDL_KEYDOWN:
				keyprocess(event.key.keysym.scancode, true);
				break;
			case SDL_KEYUP:
				keyprocess(event.key.keysym.scancode, false);
				break;
			case SDL_JOYBUTTONDOWN:
				joyprocess(event.jbutton.button, SDL_TRUE, event.jbutton.which);
				break;
			case SDL_JOYBUTTONUP:
				joyprocess(event.jbutton.button, SDL_FALSE, event.jbutton.which);
				break;
			case SDL_MOUSEMOTION:
				mouse_motion_process(event.motion.xrel, event.motion.yrel);
				break;
			case SDL_MOUSEBUTTONDOWN:
				mouse_button_process(event.button.button, SDL_TRUE);
				break;
			case SDL_MOUSEBUTTONUP:
				mouse_button_process(event.button.button, SDL_FALSE);
				break;
			case SDL_QUIT:
				gp2x_exit();
				break;
			default:
				break;
		}
	}
	return 0;
}
Ejemplo n.º 5
0
void frontend_gui (char *gamename, int first_run)
{
	FILE *f;

	/* GP2X Initialization */
	gp2x_frontend_init();

	gp2xmenu_bmp = (unsigned short*)calloc(1, 1000000);
	gp2xsplash_bmp = (unsigned short*)calloc(1, 1000000);

	/* Show load bitmaps and show intro screen */
    gp2x_intro_screen(first_run);

	/* Initialize list of available games */
	game_list_init(1);
	if (game_num_avail==0)
	{
		/* Draw background image */
    	load_bmp_16bpp(gp2x_screen15,gp2xmenu_bmp);
		gp2x_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND",gp2x_color15(255,255,255));
		FE_DisplayScreen();
		sleep(5);
		gp2x_exit();
	}

	/* Read default configuration */
	f=fopen("frontend/mame.cfg","r");
	if (f) {
		fscanf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&gp2x_freq,&gp2x_video_depth,&gp2x_video_aspect,&gp2x_video_sync,
		&gp2x_frameskip,&gp2x_sound,&gp2x_clock_cpu,&gp2x_clock_sound,&gp2x_cpu_cores,&gp2x_ramtweaks,&last_game_selected,&gp2x_cheat,&gp2x_volume);
		fclose(f);
	}

	//Read joystick configuration
	memset(pi_key, 0, NUMKEYS*2);
	memset(pi_joy, 0, NUMKEYS*2);
	open_config_file();	

	pi_key[START_1] = get_int("frontend", "K_START",    NULL, KEY_ENTER);
	pi_key[SELECT_1] = get_int("frontend", "K_SELECT",    NULL, KEY_5);
	pi_key[LEFT_1] = get_int("frontend", "K_LEFT",    NULL, KEY_LEFT);
	pi_key[RIGHT_1] = get_int("frontend", "K_RIGHT",    NULL, KEY_RIGHT);
	pi_key[UP_1] = get_int("frontend", "K_UP",    NULL, KEY_UP);
	pi_key[DOWN_1] = get_int("frontend", "K_DOWN",    NULL, KEY_DOWN);
	pi_key[A_1] = get_int("frontend", "K_A",    NULL, KEY_LCONTROL);
	pi_key[QUIT] = get_int("frontend", "K_QUIT",    NULL, KEY_ESC);

	pi_joy[START_1] = get_int("frontend", "J_START",    NULL, 9);
	pi_joy[SELECT_1] = get_int("frontend", "J_SELECT",    NULL, 8);
	pi_joy[A_1] = get_int("frontend", "J_A",    NULL, 3);

    //Read joystick axis to use, default to 0 & 1
    joyaxis_LR = get_int("frontend", "AXIS_LR", NULL, 0);
    joyaxis_UD = get_int("frontend", "AXIS_UD", NULL, 1);

	close_config_file();

	
	/* Select Game */
	select_game(playemu,playgame); 

	/* Write default configuration */
	f=fopen("frontend/mame.cfg","w");
	if (f) {
		fprintf(f,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",gp2x_freq,gp2x_video_depth,gp2x_video_aspect,gp2x_video_sync,
		gp2x_frameskip,gp2x_sound,gp2x_clock_cpu,gp2x_clock_sound,gp2x_cpu_cores,gp2x_ramtweaks,last_game_selected,gp2x_cheat,gp2x_volume);
		fclose(f);
		sync();
	}
	
    strcpy(gamename, playgame);
    
    gp2x_frontend_deinit();

	free(gp2xmenu_bmp);
	free(gp2xsplash_bmp);
	
}
Ejemplo n.º 6
0
static void select_game(char *emu, char *game)
{
	extern int kiosk_mode;

	unsigned long keytimer=0;
	int keydirection=0, last_keydirection=0;

	/* No Selected game */
	strcpy(game,"builtinn");

	/* Clean screen */
	FE_DisplayScreen();

	gp2x_joystick_clear();	

	/* Wait until user selects a game */
	while(1)
	{
		game_list_view(&last_game_selected);
		FE_DisplayScreen();
       	gp2x_timer_delay(70000);

		while(1)
		{
            usleep(10000);
			gp2x_joystick_read();	

			last_keydirection=keydirection;
			keydirection=0;

			//Any keyboard key pressed?
			if(osd_is_sdlkey_pressed(pi_key[LEFT_1]) || osd_is_sdlkey_pressed(pi_key[RIGHT_1]) ||
			   osd_is_sdlkey_pressed(pi_key[UP_1]) || osd_is_sdlkey_pressed(pi_key[DOWN_1]) )
			{
				keydirection=1;
				break;
			}

			if(osd_is_sdlkey_pressed(pi_key[START_1]) || osd_is_sdlkey_pressed(pi_key[A_1]) ||
			   osd_is_sdlkey_pressed(pi_key[QUIT]) || osd_is_sdlkey_pressed(pi_key[SELECT_1]) )
			{
				break;
			}

			//Any stick direction?
			if(is_joy_axis_pressed (joyaxis_LR, 1, 0) || is_joy_axis_pressed (joyaxis_LR, 2, 0) ||
			   is_joy_axis_pressed (joyaxis_UD, 1, 0) || is_joy_axis_pressed (joyaxis_UD, 2, 0) )
			{
				keydirection=1;
				break;
			}

			//Any joy buttons pressed?
			if (ExKey1)
			{
				break;
			}

			//Used to delay the initial key press, but 
			//once pressed and held the delay will clear
			keytimer = gp2x_timer_read() + (TICKS_PER_SEC/2);

		}

		//Key delay
		if(keydirection && last_keydirection && gp2x_timer_read() < keytimer) {
			continue;
		}

		int updown=0;
		if(is_joy_axis_pressed (joyaxis_UD, 1, 0)) {last_game_selected--; updown=1;};
		if(is_joy_axis_pressed (joyaxis_UD, 2, 0)) {last_game_selected++; updown=1;};

		// Stop diagonals on game selection
		if(!updown) {
			if(is_joy_axis_pressed (joyaxis_LR, 1, 0)) last_game_selected-=21;
			if(is_joy_axis_pressed (joyaxis_LR, 2, 0)) last_game_selected+=21;
		}

		if (osd_is_sdlkey_pressed(pi_key[UP_1])) last_game_selected--;
		if (osd_is_sdlkey_pressed(pi_key[DOWN_1])) last_game_selected++;
		if (osd_is_sdlkey_pressed(pi_key[LEFT_1])) last_game_selected-=21;
		if (osd_is_sdlkey_pressed(pi_key[RIGHT_1])) last_game_selected+=21;

		if (!kiosk_mode)
		{
			if( osd_is_sdlkey_pressed(pi_key[QUIT]) || 
			    	(is_joy_button_pressed(pi_joy[START_1], ExKey1) && is_joy_button_pressed(pi_joy[SELECT_1], ExKey1)) ) {
				gp2x_exit();
			}
		}

		if (is_joy_button_pressed(pi_joy[A_1], ExKey1) || 
			osd_is_sdlkey_pressed(pi_key[A_1]) || 
			osd_is_sdlkey_pressed(pi_key[START_1]) )
		{
			/* Select the game */
			game_list_select(last_game_selected, game, emu);

			break;
		}

		if (is_joy_button_pressed(pi_joy[SELECT_1], ExKey1) || osd_is_sdlkey_pressed(pi_key[SELECT_1]) )
		{
           //Check if the game is already a favorite
            game_list_select(last_game_selected, game, emu);

            int foundfav=0;
            int counter=0;
            while(true) {
                if (favarray[counter][0] == '\0') break;    //Null is the array terminator
                if (strcasecmp(favarray[counter], game) == 0) {
                    foundfav=1;
                    break;
                }
                counter++;
            }

            if(foundfav) {
                favorites_remove(game);
            } else {
                favorites_add(game);
            }

			//Redraw and pause slightly
	        game_list_view(&last_game_selected);
			FE_DisplayScreen();
			usleep(300000);
			gp2x_joystick_clear();

		}
	}
}
Ejemplo n.º 7
0
static void select_game(char *emu, char *game)
{

	unsigned long ExKey;

	/* No Selected game */
	strcpy(game,"builtinn");

	/* Clean screen */
	gp2x_video_flip();

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

	/* Wait until user selects a game */
	while(1)
	{
		game_list_view(&last_game_selected);
		gp2x_video_flip();

        if(safe_render_path)
        {
			if( (gp2x_joystick_read(0)&0x8c0ff55))
				gp2x_timer_delay(100);
			while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55))
			{
				if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) { gp2x_exit(); }
			}
        }
        else
        {
			gp2x_timer_delay(100);
        	ExKey=gp2x_joystick_read(0);
        }

		if (ExKey & GP2X_UP) last_game_selected--;
		else if (ExKey & GP2X_DOWN) last_game_selected++;
		else if ((ExKey & GP2X_L) || ExKey & GP2X_LEFT) last_game_selected-=21;
		else if ((ExKey & GP2X_R) || ExKey & GP2X_RIGHT) last_game_selected+=21;
		//if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) gp2x_exit();

		if (((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) && game_num_avail!=0)
		{
			/* Select the game */
			game_list_select(last_game_selected, game, emu);

			/* Emulation Options */
			//defaults!

			iOS_video_aspect=0;
			iOS_video_rotate=0;
			iOS_video_sync=0;
			iOS_frameskip=-1;
			iOS_cheat=0;

			if(!safe_render_path)
				iOS_sound = 1;
			else
				iOS_sound = 4;
			if(isIpad)
			{
				iOS_clock_cpu= 100;
				iOS_clock_sound= 100;
				iOS_landscape_buttons=2;
			}
			else
			{
				iOS_clock_cpu= 80;
				iOS_clock_sound= 80;
				iOS_landscape_buttons=2;
			}

			if(show_options(game))
			{
				break;
			}
		}

	}
}