diff --git a/src/emu.h b/src/emu.h index 72e9ba5..591efd0 100644 --- a/src/emu.h +++ b/src/emu.h @@ -150,7 +150,7 @@ void neogeo_reset(void); //#define GNGEO_LOG printf #define TRUE 1 -#define FALSE 1 +#define FALSE 0 #endif diff --git a/src/main.c b/src/main.c index b351da4..6be5f9e 100644 --- a/src/main.c +++ b/src/main.c @@ -145,7 +145,7 @@ static void catch_me(int signo) { int main(int argc, char *argv[]) { char *rom_name; - + int rc; #ifdef __AMIGA__ @@ -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; diff --git a/src/menu.c b/src/menu.c index d5b7129..90eb0fe 100644 --- a/src/menu.c +++ b/src/menu.c @@ -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); @@ -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"); @@ -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; diff --git a/src/resfile.c b/src/resfile.c index 67ca28f..ce87c9c 100644 --- a/src/resfile.c +++ b/src/resfile.c @@ -1,8 +1,9 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif - +#include #include "SDL.h" +#include "emu.h" #include "roms.h" #include "resfile.h" #include "unzip.h" @@ -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 @@ -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 diff --git a/src/resfile.h b/src/resfile.h index e17e8df..1808640 100644 --- a/src/resfile.h +++ b/src/resfile.h @@ -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);