X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=fce.c;h=bec2511fe8e69dbae2f2a9ce29a774157f3b4097;hp=64bb8dcdde29626b1cd1b66ee6b49ce83dee24c3;hb=5a2aa426410ad21d332ff75b58e7f4ed8459d86a;hpb=92e249b10ad9e479eddb18974555366dba725ef3 diff --git a/fce.c b/fce.c index 64bb8dc..bec2511 100644 --- a/fce.c +++ b/fce.c @@ -48,6 +48,8 @@ #include "crc32.h" #include "ppu.h" +#include "movie.h" + #define Pal (PALRAM) @@ -1026,28 +1028,54 @@ void ResetGameLoaded(void) FCEUGameInfo.inputfc=-1; } +char lastLoadedGameName [2048]; + FCEUGI *FCEUI_LoadGame(char *name) { + char name2[512]; + int have_movie = 0; int fp; Exit=1; ResetGameLoaded(); - fp=FCEU_fopen(name,"rb"); + strncpy(name2, name, sizeof(name2)); + name2[sizeof(name2)-1] = 0; + + fp=FCEU_fopen(name2,"rb"); if(!fp) { FCEU_PrintError("Error opening \"%s\"!",name); return 0; } - GetFileBase(name); - if(iNESLoad(name,fp)) + { + char *p = name2 + strlen(name2) - 4; + if (strcmp(p, ".fcm") == 0) + { + // movie detected + printf("movie detected\n"); + FCEU_fclose(fp); + *p = 0; + fp=FCEU_fopen(name2,"rb"); + if (!fp) { + printf("no ROM for movie\n"); + return 0; + } + have_movie = 1; + } + } + + strcpy(lastLoadedGameName, name2); + + GetFileBase(name2); + if(iNESLoad(name2,fp)) goto endlseq; if(NSFLoad(fp)) goto endlseq; - if(FDSLoad(name,fp)) + if(FDSLoad(name2,fp)) goto endlseq; - if(UNIFLoad(name,fp)) + if(UNIFLoad(name2,fp)) goto endlseq; FCEU_PrintError("An error occurred while loading the file."); @@ -1076,6 +1104,9 @@ FCEUGI *FCEUI_LoadGame(char *name) FCEU_ResetPalette(); Exit=0; + + if (have_movie) + FCEUI_LoadMovie(name, 1); return(&FCEUGameInfo); } @@ -1336,8 +1367,6 @@ void PowerNES(void) GeniePower(); -printf("X.DB offs: %02x\n", (int)&X.DB - (int)&X); - memset(RAM,0x00,0x800); ResetMapping(); GameInterface(GI_POWER);