Commit 30d522cc authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Indenting changes

parent 5f0d1260
Pipeline #58003 passed with stages
in 9 minutes and 27 seconds
......@@ -30,10 +30,8 @@ static bool is_gme_allowed_ext(char *ext)
for(i=0;i<arr_length;i++)
{
if(strcmp(ext,gme_allowed_exts[i])==0)
{
return true;
}
}
return false;
}
......@@ -173,22 +171,15 @@ bool get_file_data(const char *path,file_data ***dest_files, int *dest_numfiles)
{
//local variables
FILE *fp;
const char *bname;
char *ext;
file_data *fd;
file_data **files;
//get file name and extension
bname = path_basename(path);
ext = strrchr(path,'.') +1;
const char *bname = path_basename(path);
char *ext = strrchr(path,'.') +1;
//get file data
if(strcmp(ext,"zip")==0)
{
return get_files_from_zip(path,dest_files,dest_numfiles);
}
else
{
file_data *fd;
fp = fopen(path,"rb");
if (!fp)
if (!(fp = fopen(path,"rb")))
return false;
files = malloc(sizeof(file_data*));
fd = malloc(sizeof(file_data));
......@@ -211,5 +202,4 @@ bool get_file_data(const char *path,file_data ***dest_files, int *dest_numfiles)
*dest_files = files;
*dest_numfiles = 1;
return true;
}
}
#ifndef GME_LIBRETRO_FILEFORMAT_H__
#define GME_LIBRETRO_FILEFORMAT_H__
typedef struct {
typedef struct
{
char* name;
char* data;
int length;
......
......@@ -13,14 +13,16 @@ unsigned short get_color(char r, char g, char b)
surface *create_surface(unsigned int width, unsigned int height, unsigned int bpp)
{
surface *newsurf = malloc(sizeof(surface));
if(newsurf==NULL)
if (!newsurf)
return NULL;
newsurf->pixel_data = malloc(width*height*bpp);
if(newsurf->pixel_data==NULL)
if (!newsurf->pixel_data)
{
free(newsurf);
return NULL;
}
memset(newsurf->pixel_data,0,width*height*bpp);
newsurf->width = width;
newsurf->height = height;
......@@ -30,7 +32,8 @@ surface *create_surface(unsigned int width, unsigned int height, unsigned int bp
void free_surface(surface *surf)
{
if(surf != NULL) {
if (surf)
{
free(surf->pixel_data);
free(surf);
}
......@@ -42,7 +45,10 @@ surface *clip_surface(surface *src_surf, int x_src, int y_src, int x0, int y0, i
int lx,ly,lw,lh; //local coord
surface *clipped_surf = NULL;
//check if completely out of bounds
if( (x_src+src_surf->width) <x0 || x_src > x1 || (y_src+src_surf->height) < y0 || y_src > y1)
if( (x_src+src_surf->width) <x0
|| (x_src > x1)
|| (y_src+src_surf->height) < y0
|| (y_src > y1))
return clipped_surf;
wx0 = MAX(x_src,x0);
wy0 = MAX(y_src,y0);
......@@ -95,7 +101,8 @@ void draw_line(surface *surf, unsigned short color, int start_x, int start_y, in
for(;;)
{
set_pixel(surf,x,y,color);
if (x==end_x && y==end_y) break;
if (x==end_x && y==end_y)
break;
e2 = err;
if (e2 >-dx) { err -= dy; x += sx; }
if (e2 < dy) { err += dx; y += sy; }
......@@ -124,13 +131,10 @@ void draw_shape(surface *surf, unsigned short color, int pos_x, int pos_y, int w
void draw_letter(surface *surf, unsigned short color, char letter, int pos_x, int pos_y)
{
int y, x;
int charx = 0;
int chary = 0;
//calculate letter offset
charx = (letter % 16);
chary = (letter >> 4);
charx *= 8;
chary *= 8;
int charx = (letter % 16) * 8;
int chary = (letter >> 4) * 8;
for(y=0;y<8;y++)
{
for(x=0;x<8;x++)
......@@ -166,7 +170,8 @@ void draw_string(surface *surf, unsigned short color, char* text, int pos_x, int
}
clipped_surface = clip_surface(temp_surface,pos_x-x_offset,pos_y,21,21,299,219);
if(clipped_surface !=NULL)
if (clipped_surface)
{
copy_surface(clipped_surface,surf,0,0,pos_x,pos_y,clipped_surface->width,clipped_surface->height);
free_surface(clipped_surface);
......
......@@ -8,7 +8,8 @@
#define get_pixel(surf,x,y) ((unsigned short *)surf->pixel_data)[(x)+((y)*surf->width)]
#define is_font_pixel(x,y) (((unsigned short *)font.pixel_data)[(x)+((y)*font.width)] == 0 ? 1 : 0)
typedef struct {
typedef struct
{
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
......@@ -26,8 +27,6 @@ void draw_letter(surface *surf, unsigned short color, char letter, int pos_x, in
void draw_string(surface *surf, unsigned short color, char* text, int pos_x, int pos_y, unsigned int framecounter);
int get_string_length(char* text);
/* GIMP RGBA C-Source image dump (font.c) */
static const surface font = {
128, 128, 2,
......
......@@ -178,7 +178,6 @@ bool retro_load_game(const struct retro_game_info *info)
if(open_file(info->path,sample_rate))
return true;
else
return false;
}
......@@ -191,5 +190,3 @@ void retro_unload_game(void)
{
close_file();
}
......@@ -19,7 +19,8 @@ void init_log(retro_environment_t environ_cb)
void handle_error( const char* error )
{
char str [256];
if(error) {
if(error)
{
sprintf( str, "Error: %s", error );
log_cb(RETRO_LOG_ERROR, str );
}
......@@ -28,7 +29,8 @@ void handle_error( const char* error )
void handle_info( const char* info )
{
char str [256];
if(info) {
if(info)
{
sprintf( str, "Info: %s\n", info );
log_cb(RETRO_LOG_INFO, str );
}
......
......@@ -26,12 +26,12 @@ bool open_file(const char *path, long sample_rate)
sample_rate_ = sample_rate;
current_track = 0;
prev_fileid = -1;
if(get_playlist(path,&plist))
{
start_track(current_track);
return true;
}
else
return false;
}
......@@ -57,7 +57,7 @@ void start_track(int tracknr)
is_playing_ = false;
file = plist->files[track->file_id];
prev_fileid = track->file_id;
if(emu !=NULL)
if (emu)
gme_delete (emu);
emu = gme_new_emu(file->file_type,sample_rate_);
gme_load_data(emu,file->data,file->length);
......@@ -81,40 +81,28 @@ short *play(void)
if(gme_track_ended(emu))
{
if(current_track< (plist->num_tracks-1))
{
start_track(++current_track);
}
else
{
is_playing_ = false;
}
}
else
{
gme_play( emu, 2048, audio_buffer );
}
}
else
{
memset(audio_buffer,0,8192 * sizeof(short));
}
return audio_buffer;
}
void next_track(void)
{
if(current_track< (plist->num_tracks-1))
{
start_track(++current_track);
}
}
void prev_track(void)
{
if(current_track > 0)
{
start_track(--current_track);
}
}
char *get_game_name(char *buf)
......
......@@ -5,17 +5,29 @@
#include "gme.h"
bool is_emu_loaded(void);
bool open_file(const char *path, long sample_rate);
void close_file(void);
void start_track(int track);
short *play(void);
void next_track(void);
void prev_track(void);
char *get_game_name(char *buf);
char *get_track_count(char *buf);
char *get_song_name(char *buf);
char *get_track_position(char *buf);
int get_track_elapsed_frames(void);
void play_pause(void);
#endif
......@@ -14,9 +14,8 @@ bool get_playlist(const char *path, playlist **dest_pl)
Music_Emu *temp_emu = NULL;
gme_file_data *gfd = NULL;
gme_err_t err_msg;
playlist *pl = NULL;
//init playlist
pl = (playlist *)calloc(1, sizeof(playlist));
playlist *pl = (playlist *)calloc(1, sizeof(playlist));
//load libretro content file
if(get_playlist_gme_files(path,&(pl->files),&(pl->num_files),&(pl->num_tracks)))
{
......@@ -27,18 +26,16 @@ bool get_playlist(const char *path, playlist **dest_pl)
gfd = pl->files[i];
temp_emu = gme_new_emu(gfd->file_type,gme_info_only);
err_msg = gme_load_data(temp_emu,gfd->data,gfd->length);
if(err_msg==NULL)
{
if (err_msg)
goto error;
for(j=0;j<gfd->num_tracks;j++)
{
if(get_track_data(temp_emu,i,j,gfd->name,&(pl->tracks[position])))
{
if(get_track_data(temp_emu,i,j,gfd->name,
&(pl->tracks[position])))
position++;
}
}
}
else
goto error;
gme_delete(temp_emu);
temp_emu = NULL;
......@@ -69,7 +66,8 @@ bool get_playlist_gme_files(const char *path,gme_file_data ***dest_files,int *de
int num_files = 0;
int num_tracks = 0;
if(get_file_data(path,&files,&num_files)) {
if(get_file_data(path,&files,&num_files))
{
gme_files = malloc(sizeof(gme_file_data*) * num_files);
for(i=0;i< num_files;i++)
{
......@@ -101,11 +99,9 @@ bool get_gme_file_data(file_data *fd,gme_file_data **dest_gfd)
{
Music_Emu* temp_emu;
gme_err_t err_msg;
char *ext;
gme_file_data *gfd;
gfd = malloc(sizeof(gme_file_data));
gme_file_data *gfd = malloc(sizeof(gme_file_data));
//set playlist type
ext = strrchr(fd->name,'.') +1;
char *ext = strrchr(fd->name,'.') +1;
//check extension to determine player type
if(strcmp(ext,"ay")==0 || strcmp(ext,"AY")==0)
gfd->file_type = gme_ay_type;
......@@ -154,8 +150,7 @@ bool get_gme_file_data(file_data *fd,gme_file_data **dest_gfd)
bool get_track_data(Music_Emu* emu, int fileid, int trackid, char *filename,gme_track_data **dest_gtd)
{
gme_info_t* ti;
gme_track_data *gtd;
gtd = malloc(sizeof(gme_track_data));
gme_track_data *gtd = malloc(sizeof(gme_track_data));
gtd->file_id = fileid;
gtd->track_id = trackid;
gme_track_info(emu, &ti,trackid);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment