Commit d1cc63ba authored by jdgleaver's avatar jdgleaver
Browse files

Fix content loading

parent c587cfd9
......@@ -477,6 +477,10 @@ endif
CFLAGS += -Wall $(INCFLAGS) $(INCFLAGS_PLATFORM)
CXXFLAGS += -Wall $(INCFLAGS) $(INCFLAGS_PLATFORM)
ifeq ($(DEBUG),1)
CFLAGS += -O0 -g
endif
ifneq (,$(findstring msvc,$(platform)))
ifeq ($(DEBUG),1)
CFLAGS += -MTd
......
......@@ -187,9 +187,11 @@ bool get_file_data(const char *path,file_data ***dest_files, int *dest_numfiles)
else
{
file_data *fd;
fp = fopen(path,"rb");
if (!fp)
return false;
files = malloc(sizeof(file_data*));
fd = malloc(sizeof(file_data));
fp = fopen(path,"rb");
//get file length
fseek (fp,0,SEEK_END);
fd->length = ftell(fp);
......
......@@ -10,7 +10,7 @@
#include "log.h"
// Static globals
static surface *framebuffer = NULL;;
static surface *framebuffer = NULL;
static uint16_t previnput = 0;
// Callbacks
......@@ -87,7 +87,7 @@ void retro_get_system_info(struct retro_system_info *info)
memset(info, 0, sizeof(*info));
info->library_name = "Game Music Emulator";
info->library_version = "v0.6.1";
info->need_fullpath = false;
info->need_fullpath = true;
info->valid_extensions = "ay|gbs|gym|hes|kss|nsf|nsfe|sap|spc|vgm|vgz|zip";
info->block_extract = true;
}
......@@ -123,7 +123,9 @@ void retro_init(void)
// End of retrolib
void retro_deinit(void)
{
free(framebuffer);
if (framebuffer)
free_surface(framebuffer);
framebuffer = NULL;
}
// Reset gme
......@@ -171,8 +173,7 @@ bool retro_load_game(const struct retro_game_info *info)
{
long sample_rate = 44100;
// ensure there is ROM data
if (!info || !info->data)
if (!info)
return false;
if(open_file(info->path,sample_rate))
......
......@@ -37,7 +37,8 @@ bool open_file(const char *path, long sample_rate)
void close_file(void)
{
gme_delete( emu );
gme_delete(emu);
emu = NULL;
if(plist!=NULL)
cleanup_playlist(plist);
}
......
......@@ -9,23 +9,19 @@
bool get_playlist(const char *path, playlist **dest_pl)
{
//local variables
int i,j,position;
Music_Emu *temp_emu;
gme_file_data *gfd;
int i,j;
int position = 0;
Music_Emu *temp_emu = NULL;
gme_file_data *gfd = NULL;
gme_err_t err_msg;
playlist *pl;
playlist *pl = NULL;
//init playlist
pl = malloc(sizeof(playlist));
pl->num_files = 0;
pl->files = NULL;
pl->num_tracks = 0;
pl->tracks = NULL;
pl = (playlist *)calloc(1, sizeof(playlist));
//load libretro content file
if(get_playlist_gme_files(path,&(pl->files),&(pl->num_files),&(pl->num_tracks)))
{
pl->tracks = malloc(sizeof(gme_track_data*) * pl->num_tracks);
pl->tracks = (gme_track_data **)calloc(pl->num_tracks, sizeof(gme_track_data*));
//read tracks
position = 0;
for(i=0;i<pl->num_files;i++)
{
gfd = pl->files[i];
......@@ -42,13 +38,26 @@ bool get_playlist(const char *path, playlist **dest_pl)
}
}
else
return false;
goto error;
gme_delete(temp_emu);
temp_emu = NULL;
}
}
else
return false;
goto error;
*dest_pl = pl;
return true;
error:
if (temp_emu)
gme_delete(temp_emu);
if (pl)
cleanup_playlist(pl);
return false;
}
bool get_playlist_gme_files(const char *path,gme_file_data ***dest_files,int *dest_num_files, int *dest_num_tracks)
......
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