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; }
static char * header_hunk(const struct grid_info grid) { char *s = NULL; asprintf(&s, "#version 150\n" "#extension GL_ARB_shader_image_load_store : enable\n" "#define W %d\n" "#define H %d\n" "#define N %d\n" "#define GRID_T %s\n" "#define RET_IMAGE_T layout(%s) %s2D\n", grid.size.x, grid.size.y, product(grid.size), image_vector_type_name(grid.format), grid.format->name, image_type_name(grid.format)); return s; }
void game_sel_draw( void ) { if( idle_counter && !game_sel_busy() ) { idle_counter--; if( idle_counter == 0 && game_tile_current->game ) { bg_set( game_media_get( game_tile_current->game, MEDIA_IMAGE, image_type_name(IMAGE_BACKGROUND) ) ); snap_set( game_tile_current->game ); } } if( visible ) { if( scroll_direction != 0 ) { step += scroll_direction; if( step > steps-1 ) { game_sel_shuffle_forward( 1 ); if( game_tile_current->next ) game_tile_current = game_tile_current->next; step = 0; } game_sel_draw_step( step ); if( step == 0 ) { scroll_direction = 0; idle_counter = idle_time; } } else { step += -hide_direction; game_sel_draw_step( step ); if( step > steps-1 || step == 0 ) { if( hide_direction < 0 ) { visible = 0; game_sel_free_textures(); } hide_direction = 0; if( skipping != 0 ) { game_sel_do_skip(); idle_counter = idle_time; } } } } }
char * image_hunk(const struct image_info img, const char *prefix) { char *s = NULL; asprintf(&s, "#define %sBASE_T %s\n" "#define %sDATA_T %s\n" "#define %sSCALE vec4(%.8e, %.8e, %.8e, %.8e)\n" "#define %sIMAGE_ADDR_(addr_t, ext, i) %s\n" "#define %sIMAGE_ADDR(idx)" " %sIMAGE_ADDR_(%s, ivec4(%d, %d, %d, %d)," " ((idx).x + W * (idx).y))\n" "#define %sIMAGE_LAYOUT_Q layout(%s)\n" "#define %sIMAGE_BARE_T %s%s\n" "#define %sIMAGE_T %sIMAGE_LAYOUT_Q %sIMAGE_BARE_T\n", prefix, image_scalar_type_name(img.format), prefix, image_vector_type_name(img.format), prefix, image_format_scale(img.format).x, image_format_scale(img.format).y, image_format_scale(img.format).z, image_format_scale(img.format).w, prefix, (image_target_samples(img.target) > 1 ? "addr_t(ivec3(i / ext.x % ext.y," " i / ext.x / ext.y % ext.z," " i / ext.x / ext.y / ext.z))," "(i % ext.x)" : "addr_t(ivec3(i % ext.x," " i / ext.x % ext.y," " i / ext.x / ext.y))"), prefix, prefix, img.target->addr_type_name, img.size.x, img.size.y, img.size.z, img.size.w, prefix, img.format->name, prefix, image_type_name(img.format), img.target->name, prefix, prefix, prefix); return s; }
int game_list_create( void ) { struct game *game = NULL; struct game *prev = NULL; struct config_game *config_game = config_get()->games; if( !config_game ) platform_add_unknown(); game_image_type = (char*)image_type_name( IMAGE_LOGO ); while( config_game ) { game = malloc(sizeof(struct game)); if( game == NULL ) { return -1; } else { struct config_game_category *config_game_category = config_game->categories; struct category *category = category_first(); int i = 0; memset( game, 0, sizeof(struct game) ); game->name = config_game->name; game->texture = NULL; game->rom_path = config_game->rom_image; game->params = config_game->params; if( config_game->platform ) { game->platform = platform_get( config_game->platform->name ); } else { platform_add_unknown(); game->platform = platform_get( NULL ); } if( config_game->emulator && config_game->emulator[0] ) { game->emulator = emulator_get_by_name( config_game->emulator ); if( !game->emulator ) fprintf( stderr, "Warning: Emulator '%s' defined for game '%s' not found\n", config_game->emulator, game->name ); } if( !game->emulator && config_game->platform ) { game->emulator = emulator_get_by_platform( config_game->platform->name ); } if( !game->emulator ) { game->emulator = emulator_get_default(); } if( !game->emulator ) { fprintf( stderr, "Warning: No emulator found for game '%s'\n", game->name ); free( game ); continue; } /* Add game categories. */ game->categories = NULL; while( config_game_category ) { if( config_game_category->category->id == 0 ) game_add_category( game, (char*)config_get()->iface.labels.label_lists, config_game_category->value->name ); else game_add_category( game, config_game_category->category->name, (char*)lookup_category( config_game_category->category, (const char*)config_game_category->value->name ) ); config_game_category = config_game_category->next; } game->media = NULL; for( i = 0 ; i < NUM_IMAGE_TYPES ; i++ ) { struct game_media *image = malloc( sizeof(struct game_media) ); if( image ) { struct config_image *config_game_image = config_game->images; memset( image, 0, sizeof(struct game_media) ); image->type = MEDIA_IMAGE; while( config_game_image ) { if( strcasecmp( config_game_image->type->name, image_type_name(i) ) == 0 ) { image->subtype = config_game_image->type->name; location_get_path( image->subtype, config_game_image->file_name, image->file_name ); break; } config_game_image = config_game_image->next; } if( image->file_name[0] == '\0' ) { image->subtype = (char*)image_type_name(i); location_get_match( image->subtype, game->rom_path, image->file_name ); } if( image->file_name[0] == '\0' ) { free( image ); } else { image->next = game->media; game->media = image; } } else { fprintf( stderr, "Warning: Couldn't allocate game image object for '%s'\n", game->name ); } } { struct game_media *video = malloc( sizeof(struct game_media) ); if( video ) { memset( video, 0, sizeof(struct game_media) ); video->type = MEDIA_VIDEO; location_get_path( media_type_name(MEDIA_VIDEO), config_game->video, video->file_name ); if( video->file_name[0] == '\0' ) { location_get_match( media_type_name(MEDIA_VIDEO), game->rom_path, video->file_name ); } if( video->file_name[0] == '\0' ) { free( video ); } else { video->next = game->media; game->media = video; } } else { fprintf( stderr, "Warning: Couldn't allocate game video object for '%s'\n", game->name ); } } /* Fill in "unknown" values for categories undefined for this game. */ if( category ) { do { struct game_category *gc = game->categories; while( gc ) { if( gc->name == category->name ) { break; } gc = gc->next; } if( gc == NULL ) { /* Category undefine for this game */ category_value_add_unknown( category ); game_add_category( game, category->name, NULL ); } category = category->next; } while( category != category_first() ); } /* insert into list (sort by name) */ prev = game_start; if( game_start ) { prev = game_start->all_prev; while( strcasecmp( prev->name, game->name ) > 0 ) { prev = prev->all_prev; if( prev == game_start->all_prev ) break; } } game_add( game, prev ); if( !game_start || strcasecmp( game->name, game_start->name ) < 0 ) { game_start = game; } game->next = game->all_next; game->prev = game->all_prev; } config_game = config_game->next; } game_list_unfilter(); /* if( game_start ) { struct game *g = game_start; while( g ) { struct game_media *gm = g->media; struct game_category *gc = g->categories; printf("Game: %s\n", g->name ); while( gm ) { printf(" '%d/%s' = '%s'\n", gm->type, gm->subtype, gm->file_name ); gm = gm->next; } while( gc ) { printf(" '%s' = '%s'\n", gc->name, gc->value ); gc = gc->next; } g = g->all_next; if( g == game_start ) break; } }*/ return 0; }