.ticp project loads from command line
This commit is contained in:
parent
e741a0d0e0
commit
46e62e4eb2
|
@ -1564,9 +1564,11 @@ static void onConsoleExportCommand(Console* console, const char* param)
|
||||||
|
|
||||||
#if defined(TIC80_PRO)
|
#if defined(TIC80_PRO)
|
||||||
|
|
||||||
|
static const char ProjectExt[] = ".ticp";
|
||||||
|
|
||||||
static const char* getProjectName(const char* name)
|
static const char* getProjectName(const char* name)
|
||||||
{
|
{
|
||||||
return getName(name, ".ticp");
|
return getName(name, ProjectExt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buf2str(const void* data, s32 size, char* ptr, bool flip)
|
static void buf2str(const void* data, s32 size, char* ptr, bool flip)
|
||||||
|
@ -1802,7 +1804,7 @@ static void loadBinarySection(const char* project, const char* tag, s32 count, v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool loadProject(Console* console, const char* data, s32 size)
|
static bool loadProject(Console* console, const char* data, s32 size, tic_cartridge* dst)
|
||||||
{
|
{
|
||||||
tic_mem* tic = console->tic;
|
tic_mem* tic = console->tic;
|
||||||
|
|
||||||
|
@ -1838,7 +1840,7 @@ static bool loadProject(Console* console, const char* data, s32 size)
|
||||||
|
|
||||||
loadBinarySection(project, "COVER", 1, &cart->cover, -1, true);
|
loadBinarySection(project, "COVER", 1, &cart->cover, -1, true);
|
||||||
|
|
||||||
SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge));
|
SDL_memcpy(dst, cart, sizeof(tic_cartridge));
|
||||||
|
|
||||||
SDL_free(cart);
|
SDL_free(cart);
|
||||||
|
|
||||||
|
@ -1853,6 +1855,8 @@ static bool loadProject(Console* console, const char* data, s32 size)
|
||||||
|
|
||||||
static void onConsoleLoadProjectCommandConfirmed(Console* console, const char* param)
|
static void onConsoleLoadProjectCommandConfirmed(Console* console, const char* param)
|
||||||
{
|
{
|
||||||
|
tic_mem* tic = console->tic;
|
||||||
|
|
||||||
if(param)
|
if(param)
|
||||||
{
|
{
|
||||||
s32 size = 0;
|
s32 size = 0;
|
||||||
|
@ -1860,7 +1864,7 @@ static void onConsoleLoadProjectCommandConfirmed(Console* console, const char* p
|
||||||
|
|
||||||
void* data = fsLoadFile(console->fs, name, &size);
|
void* data = fsLoadFile(console->fs, name, &size);
|
||||||
|
|
||||||
if(data && loadProject(console, data, size))
|
if(data && loadProject(console, data, size, &tic->cart))
|
||||||
{
|
{
|
||||||
strcpy(console->romName, name);
|
strcpy(console->romName, name);
|
||||||
|
|
||||||
|
@ -2666,7 +2670,17 @@ static void cmdLoadCart(Console* console, const char* name)
|
||||||
|
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
loadCart(console->tic, &embed.file, data, size, true);
|
#if defined(TIC80_PRO)
|
||||||
|
if(strstr(name, ProjectExt) == name + strlen(name) - strlen(ProjectExt))
|
||||||
|
{
|
||||||
|
loadProject(console, data, size, &embed.file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
loadCart(console->tic, &embed.file, data, size, true);
|
||||||
|
}
|
||||||
|
|
||||||
embed.yes = true;
|
embed.yes = true;
|
||||||
|
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
|
|
Loading…
Reference in New Issue