added live cart reloading #374
This commit is contained in:
parent
f4808d40d4
commit
31929e5550
|
@ -731,6 +731,25 @@ static bool loadProject(Console* console, const char* data, s32 size, tic_cartri
|
|||
return done;
|
||||
}
|
||||
|
||||
static void updateProject(Console* console)
|
||||
{
|
||||
tic_mem* tic = console->tic;
|
||||
|
||||
if(strlen(console->romName))
|
||||
{
|
||||
s32 size = 0;
|
||||
void* data = fsLoadFile(console->fs, console->romName, &size);
|
||||
|
||||
if(data)
|
||||
{
|
||||
loadProject(console, data, size, &tic->cart);
|
||||
SDL_free(data);
|
||||
|
||||
studioRomLoaded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool hasExt(const char* name, const char* ext)
|
||||
{
|
||||
return strcmp(name + strlen(name) - strlen(ext), ext) == 0;
|
||||
|
@ -2721,10 +2740,11 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
|
|||
|
||||
#if defined(TIC80_PRO)
|
||||
.loadProject = loadProject,
|
||||
.updateProject = updateProject,
|
||||
#else
|
||||
.loadProject = NULL,
|
||||
.updateProject = NULL,
|
||||
#endif
|
||||
|
||||
.error = error,
|
||||
.trace = trace,
|
||||
.tick = tick,
|
||||
|
|
|
@ -92,6 +92,7 @@ struct Console
|
|||
|
||||
void(*load)(Console*, const char* name);
|
||||
bool(*loadProject)(Console*, const char* data, s32 size, tic_cartridge* dst);
|
||||
void(*updateProject)(Console*);
|
||||
void(*error)(Console*, const char*);
|
||||
void(*trace)(Console*, const char*, u8 color);
|
||||
void(*tick)(Console*);
|
||||
|
|
27
src/studio.c
27
src/studio.c
|
@ -760,6 +760,8 @@ void exitFromGameMenu()
|
|||
{
|
||||
setStudioMode(TIC_CONSOLE_MODE);
|
||||
}
|
||||
|
||||
studio.console.showGameMenu = false;
|
||||
}
|
||||
|
||||
void setStudioMode(EditorMode mode)
|
||||
|
@ -1680,6 +1682,12 @@ static void processMouseInput()
|
|||
studio.tic->ram.vram.input.gamepad.pressed = studio.mouse.state->down ? 1 : 0;
|
||||
}
|
||||
|
||||
static void reloadConfirm(bool yes, void* data)
|
||||
{
|
||||
if(yes)
|
||||
studio.console.updateProject(&studio.console);
|
||||
}
|
||||
|
||||
SDL_Event* pollEvent()
|
||||
{
|
||||
static SDL_Event event;
|
||||
|
@ -1721,6 +1729,25 @@ SDL_Event* pollEvent()
|
|||
{
|
||||
case SDL_WINDOWEVENT_RESIZED: updateGamepadParts(); break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
|
||||
#if defined(TIC80_PRO)
|
||||
|
||||
if(studio.mode != TIC_START_MODE && studioCartChanged())
|
||||
{
|
||||
static const char* Rows[] =
|
||||
{
|
||||
"",
|
||||
"CART HAS CHANGED!",
|
||||
"",
|
||||
"DO YOU WANT",
|
||||
"TO RELOAD IT?"
|
||||
};
|
||||
|
||||
showDialog(Rows, COUNT_OF(Rows), reloadConfirm, NULL);
|
||||
}
|
||||
else studio.console.updateProject(&studio.console);
|
||||
|
||||
#endif
|
||||
{
|
||||
studio.console.codeLiveReload.reload(&studio.console,studio.code.data);
|
||||
if(studio.code.update)
|
||||
|
|
Loading…
Reference in New Issue