Skip to content

Commit

Permalink
correctly report missing gngeo_data.zip
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone42 committed May 9, 2012
1 parent a1ec5c4 commit a8562bb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void neogeo_reset(void);
//#define GNGEO_LOG printf

#define TRUE 1
#define FALSE 1
#define FALSE 0


#endif
6 changes: 3 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void catch_me(int signo) {
int main(int argc, char *argv[])
{
char *rom_name;

int rc;


#ifdef __AMIGA__
Expand Down Expand Up @@ -182,11 +182,11 @@ int main(int argc, char *argv[])
#ifdef GP2X
gp2x_init();
#endif
if (gn_init_skin()!=SDL_TRUE) {
if ((rc=gn_init_skin())!=TRUE) {
printf("Can't load skin...\n");
exit(1);
}

printf("Plop! %d\n",(1==1));
reset_frame_skip();

if (conf.debug) conf.sound=0;
Expand Down
20 changes: 17 additions & 3 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,17 @@ void draw_string(SDL_Surface *dst, GNFONT *f, int x, int y, char *str) {
SDL_Rect srect, drect;
int i;

if (!f) {
if (x == ALIGN_LEFT) x = MENU_TEXT_X;
if (x == ALIGN_RIGHT) x = (MENU_TEXT_X_END - strlen(str)*8);
if (x == ALIGN_CENTER) x = (MENU_TEXT_X + (MENU_TEXT_X_END - MENU_TEXT_X - strlen(str)*8) / 2);
if (y == ALIGN_UP) y = MENU_TEXT_Y;
if (y == ALIGN_DOWN) y = (MENU_TEXT_Y_END - 8);
if (y == ALIGN_CENTER) y = (MENU_TEXT_Y + (MENU_TEXT_Y_END - MENU_TEXT_Y - 8) / 2);
SDL_textout(dst,x,y,str);
return;
}

if (x == ALIGN_LEFT) x = MENU_TEXT_X;
if (x == ALIGN_RIGHT) x = (MENU_TEXT_X_END - string_len(f, str));
if (x == ALIGN_CENTER) x = (MENU_TEXT_X + (MENU_TEXT_X_END - MENU_TEXT_X - string_len(f, str)) / 2);
Expand Down Expand Up @@ -516,7 +527,10 @@ int gn_init_skin(void) {
menu_buf = SDL_CreateRGBSurface(SDL_SWSURFACE, 352, 256, 16, 0xF800, 0x7E0, 0x1F, 0);
// menu_back= SDL_CreateRGBSurface(SDL_SWSURFACE, 352, 256, 32, 0xFF0000, 0xFF00, 0xFF, 0x0);
menu_back = SDL_CreateRGBSurface(SDL_SWSURFACE, 352, 256, 16, 0xF800, 0x7E0, 0x1F, 0);

if (res_verify_datafile(NULL)==FALSE) {
gn_popup_error("Datafile Not Found!","Gngeo could not find his \n datafile :( \n");
return FALSE;
}
back = res_load_stbi("skin/back.tga");
sfont = load_font("skin/font_small.tga");
mfont = load_font("skin/font_large.tga");
Expand All @@ -533,8 +547,8 @@ int gn_init_skin(void) {
init_back();

if (!back || !sfont || !mfont || !arrow_r || !arrow_l || !arrow_u || !arrow_d ||
!gngeo_logo || !menu_buf) return false;
return true;
!gngeo_logo || !menu_buf) return FALSE;
return TRUE;
}

static int pbar_y;
Expand Down
32 changes: 29 additions & 3 deletions src/resfile.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <sys/stat.h>
#include "SDL.h"
#include "emu.h"
#include "roms.h"
#include "resfile.h"
#include "unzip.h"
Expand Down Expand Up @@ -30,6 +31,33 @@ void zread_uint32le(ZFILE *gz, Uint32 *c) {
//printf("H32 %08x %d\n",*c,rc);
}


int res_verify_datafile(char *file) {
struct stat sb;

if (!file) file=CF_STR(cf_get_item_by_name("datafile"));

if (lstat(file,&sb)==-1) {
return FALSE;
}

/* if it's a dir, try to append gngeo_data.zip, and recheck */
if (S_ISDIR(sb.st_mode)) {
char *buf=malloc(strlen(file)+strlen("/gngeo_data.zip")+1);
snprintf(buf,254,"%s/%s",file,"gngeo_data.zip");
if(res_verify_datafile(buf)==TRUE) {
strncpy(CF_STR(cf_get_item_by_name("datafile")), buf, 254);
free(buf);
return TRUE;
} else {
free(buf);
return FALSE;
}
}
if (S_ISREG(sb.st_mode)) return TRUE;
return FALSE;
}

/*
* Load a rom definition file from gngeo.dat (rom/name.drv)
* return ROM_DEF*, NULL on error
Expand Down Expand Up @@ -80,8 +108,6 @@ ROM_DEF *res_load_drv(char *name) {
return drv;
}



/*
* Load a stb image from gngeo.dat
* return a SDL_Surface, NULL on error
Expand Down
2 changes: 1 addition & 1 deletion src/resfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "SDL.h"
#include "roms.h"

int res_verify_datafile(char *file);
ROM_DEF *res_load_drv(char *name);
SDL_Surface *res_load_bmp(char *bmp);
void *res_load_data(char *name);
Expand Down

0 comments on commit a8562bb

Please sign in to comment.