X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fcommon%2Femu.c;h=e916b3f27a9bd0e95033c7ebb2b3bd0bc90c7cc3;hb=b8a1c09ad1ef0b807c2eb1632d34e6bfae14b633;hp=370242dc951feb4ef5c5ca02f192bd5fbe087636;hpb=71f68165b6e50f58ddbc6e98a38c7dd4968ccca2;p=picodrive.git diff --git a/platform/common/emu.c b/platform/common/emu.c index 370242d..e916b3f 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -464,25 +464,25 @@ int emu_reload_rom(char *rom_fname) // check for both gmv and rom int dummy; FILE *movie_file = fopen(rom_fname, "rb"); - if(!movie_file) { + if (!movie_file) { me_update_msg("Failed to open movie."); return 0; } fseek(movie_file, 0, SEEK_END); movie_size = ftell(movie_file); fseek(movie_file, 0, SEEK_SET); - if(movie_size < 64+3) { + if (movie_size < 64+3) { me_update_msg("Invalid GMV file."); fclose(movie_file); return 0; } movie_data = malloc(movie_size); - if(movie_data == NULL) { + if (movie_data == NULL) { me_update_msg("low memory."); fclose(movie_file); return 0; } - fread(movie_data, 1, movie_size, movie_file); + dummy = fread(movie_data, 1, movie_size, movie_file); fclose(movie_file); if (strncmp((char *)movie_data, "Gens Movie TEST", 15) != 0) { me_update_msg("Invalid GMV file."); @@ -1008,13 +1008,16 @@ int emu_save_load_game(int load, int sram) sram_size = SRam.size; sram_data = SRam.data; } - if (!sram_data) return 0; // SRam forcefully disabled for this game + if (sram_data == NULL) + return 0; // SRam forcefully disabled for this game if (load) { sramFile = fopen(saveFname, "rb"); - if(!sramFile) return -1; - fread(sram_data, 1, sram_size, sramFile); + if (!sramFile) + return -1; + ret = fread(sram_data, 1, sram_size, sramFile); + ret = ret > 0 ? 0 : -1; fclose(sramFile); if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART)) memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);