Ejemplo n.º 1
0
void snap_test_get_reset_state()
{
    snap_t snap;
    snap_init( &snap );

    SNAP_ASSERT( snap_is_ready( &snap ) );

    snap.last_error = SNAP_ERROR_BOUND;
    SNAP_ASSERT( !snap_is_ready( &snap ) );

    snap.packet.size = 1;
    SNAP_ASSERT( !snap_is_ready( &snap ) );

    snap.last_error = SNAP_ERROR_NONE;
    SNAP_ASSERT( !snap_is_ready( &snap ) );

    snap_clear( &snap );
    SNAP_ASSERT( snap_is_ready( &snap ) );

    snap.packet.size = 1;
    SNAP_ASSERT( !snap_is_ready( &snap ) );

    snap_clear( &snap );
    SNAP_ASSERT( snap_is_ready( &snap ) );
}
Ejemplo n.º 2
0
void game_sel_skip_back( void ) {
	if( visible && !game_sel_busy() ) {
		snap_clear();
		sound_play( SOUND_BLIP );
		game_sel_hide( HIDE_TARGET_SELECTED );
		skipping = -1;
	}
}
Ejemplo n.º 3
0
int snap_set( struct game *game ) {
	const struct config_snap *config = &config_get()->iface.theme.snap;
	char *filename;

	snap_clear();
	texture = NULL;
	video = 0;
	
	platform_texture = game->platform->texture;
	
	filename = game_media_get( game, MEDIA_VIDEO, NULL );
	if( filename && filename[0] ) {
		if( video_open( filename ) == 0 ) {
			video = 1;
			texture = video_texture();
		}
	}
	
	if( !texture ) {
		filename = game_media_get( game, MEDIA_IMAGE, image_type_name(IMAGE_SCREENSHOT) );
		if( filename && filename[0] ) {
			texture = sdl_create_texture( filename );
		}
		else {
			return -1;
		}
	}

	if( texture ) {
		if( config->fix_aspect_ratio ) {
			if( texture->width > texture->height ) {
				/* Landscape */
				width = MAX_SIZE;
				height = MAX_SIZE / ogl_aspect_ratio();
			}
			else {
				/* Portrait */
				height = MAX_SIZE;
				width = MAX_SIZE / ogl_aspect_ratio();
			}				
		}
		else {
			if( texture->width > texture->height ) {
				/* Landscape */
				height = (int)(float)texture->height/((float)texture->width/MAX_SIZE);
				width = MAX_SIZE;
			}
			else {
				/* Portrait */
				width = (int)(float)texture->width/((float)texture->height/MAX_SIZE);
				height = MAX_SIZE;
			}
		}
		return 0;
	}

	return -1;
}
Ejemplo n.º 4
0
void game_sel_advance( void ) {
	if( visible && !game_sel_busy() ) {
		snap_clear();
		sound_play( SOUND_BLIP );
		game_sel_shuffle_back( 1 );
		scroll_direction = -1;
		step = steps-1;
	}
}
Ejemplo n.º 5
0
void snap_free( void ) {
	int i;

	snap_clear();
	
	for( i = 0 ; i < NUM_NOISE ; i++ ) {
		ogl_free_texture( noise[i] );
		noise[i] = NULL;
	}
}
Ejemplo n.º 6
0
void game_sel_retreat( void ) {
	if( visible && !game_sel_busy() ) {
		snap_clear();
		sound_play( SOUND_BLIP );
		if( game_tile_current->prev )
			game_tile_current = game_tile_current->prev;
		scroll_direction = 1;
		step = 1;
	}
}
Ejemplo n.º 7
0
int game_sel_event( int event ) {
	int o = config_get()->iface.theme.game_sel.orientation;
	switch( event ) {
		case EVENT_UP:
			if( o == CONFIG_LANDSCAPE )
				game_sel_skip_back();
			else
				game_sel_retreat();
			break;
		case EVENT_DOWN:
			if( o == CONFIG_LANDSCAPE )
				game_sel_skip_forward();
			else
				game_sel_advance();
			break;
		case EVENT_LEFT:
			if( o == CONFIG_LANDSCAPE )
				game_sel_retreat();
			else
				game_sel_skip_back();
			break;
		case EVENT_RIGHT:
			if( o == CONFIG_LANDSCAPE )
				game_sel_advance();
			else
				game_sel_skip_forward();
			break;
		case EVENT_SELECT:
			snap_clear();
			emulator_run( game_sel_current() );
			break;
		case EVENT_BACK:
			snap_clear();
			sound_play( SOUND_BACK );
			focus_set( FOCUS_SUBMENU );
			break;
		default:
			break;
	}
	return 0;
}
Ejemplo n.º 8
0
void snap_draw( void ) {
	const struct config_snap *config = &config_get()->iface.theme.snap;
	
	if( visible ) {
		struct texture *t = texture;
		GLfloat xfactor = ogl_xfactor();
		GLfloat yfactor = ogl_yfactor();
		GLfloat xsize, ysize, hide_offset;
		
		if( video )
			t = video_get_frame();
				
		if( t == NULL )
			t = noise[frame/noise_skip];
		
		xsize = (width/2) * scale * xfactor;
		ysize = (height/2) * scale * xfactor;
		
		hide_offset = (((hidden_offset - config->offset1) / (GLfloat)steps) * (GLfloat)step);

		ogl_load_alterego();
		if( hide_direction == -1 ) {
			if( config_get()->iface.theme.game_sel.orientation == CONFIG_PORTRAIT )
				glTranslatef( (hidden_offset - hide_offset) * xfactor, config->offset2 * yfactor, DEPTH );
			else
				glTranslatef( config->offset2 * xfactor, (hidden_offset - hide_offset) * yfactor, DEPTH );
		}
		else {
			if( config_get()->iface.theme.game_sel.orientation == CONFIG_PORTRAIT )
				glTranslatef( (config->offset1 + hide_offset) * xfactor, config->offset2 * yfactor, DEPTH );
			else
				glTranslatef( config->offset2 * xfactor, (config->offset1 + hide_offset) * yfactor, DEPTH );
		}
		glRotatef( config->angle_x, 1.0, 0.0, 0.0 );
		glRotatef( config->angle_y, 0.0, 1.0, 0.0 );
		glRotatef( config->angle_z, 0.0, 0.0, 1.0 );
		glColor4f( 1.0, 1.0, 1.0, 1.0 );
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_TEXTURE_2D);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
	
		glBindTexture( GL_TEXTURE_2D, t->id );		
		glBegin( GL_QUADS );
			glTexCoord2f(0.0, 0.0); glVertex3f(-xsize,  ysize, 0.0);
			glTexCoord2f(0.0, 1.0); glVertex3f(-xsize, -ysize, 0.0);
			glTexCoord2f(1.0, 1.0); glVertex3f( xsize, -ysize, 0.0);
			glTexCoord2f(1.0, 0.0); glVertex3f( xsize,  ysize, 0.0);	
		glEnd();

		if( config->platform_icons && platform_count() > 1 && platform_texture ) {
			GLfloat platform_xsize = platform_texture->width;
			GLfloat platform_ysize = platform_texture->height; 

			if( platform_xsize > platform_ysize ) {
				platform_ysize = platform_scale * platform_ysize/platform_xsize;
				platform_xsize = platform_scale;
			}
			else {
				platform_xsize = platform_scale * platform_xsize/platform_ysize;
				platform_ysize = platform_scale;
			}

			glTranslatef( xsize * 0.8, -ysize * 0.9, 0.1 );
			glRotatef( -config->angle_z, 0.0, 0.0, 1.0 );
			glBindTexture( GL_TEXTURE_2D, platform_texture->id );
			glBegin( GL_QUADS );
				glTexCoord2f(0.0, 0.0); glVertex3f(-platform_xsize,  platform_ysize, 0.0);
				glTexCoord2f(0.0, 1.0); glVertex3f(-platform_xsize, -platform_ysize, 0.0);
				glTexCoord2f(1.0, 1.0); glVertex3f( platform_xsize, -platform_ysize, 0.0);
				glTexCoord2f(1.0, 0.0); glVertex3f( platform_xsize,  platform_ysize, 0.0);	
			glEnd();
		}
		
		if( ++frame >= NUM_NOISE * noise_skip )
			frame = 0;
			
		if( step && --step == 0 ) {
			if( hide_direction < 0 ) {
				visible = 0;
				snap_clear();
			}
			else {
				visible = 1;
			}
			hide_direction = 0;
		}
	}
}