cmd cart open fix

This commit is contained in:
Nesbox 2017-11-24 12:09:25 +03:00
parent 8f4dae83a4
commit f136ea4c73
1 changed files with 10 additions and 6 deletions

View File

@ -507,13 +507,13 @@ static void onCartLoaded(Console* console, const char* name)
} }
#if defined(TIC80_PRO)
static bool hasExt(const char* name, const char* ext) static bool hasExt(const char* name, const char* ext)
{ {
return strcmp(name + strlen(name) - strlen(ext), ext) == 0; return strcmp(name + strlen(name) - strlen(ext), ext) == 0;
} }
#if defined(TIC80_PRO)
static bool hasProjectExt(const char* name) static bool hasProjectExt(const char* name)
{ {
return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT); return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT);
@ -2627,15 +2627,19 @@ static void cmdLoadCart(Console* console, const char* name)
if(hasProjectExt(name)) if(hasProjectExt(name))
{ {
loadProject(console, name, data, size, &embed.file); loadProject(console, name, data, size, &embed.file);
strcpy(console->romName, fsFilename(name));
embed.yes = true;
embed.fast = true; embed.fast = true;
} }
else else
#endif #endif
loadCart(console->tic, &embed.file, data, size, true);
strcpy(console->romName, fsFilename(name)); if(hasExt(name, CART_EXT))
{
embed.yes = true; loadCart(console->tic, &embed.file, data, size, true);
strcpy(console->romName, fsFilename(name));
embed.yes = true;
}
SDL_free(data); SDL_free(data);
} }