diff --git a/src/console.c b/src/console.c index f145c07..1f0d090 100644 --- a/src/console.c +++ b/src/console.c @@ -2061,9 +2061,8 @@ static void onConsoleResumeCommand(Console* console, const char* param) commandDone(console); console->tic->api.resume(console->tic); - console->tic->api.sync(console->tic, 0, 0, false); - setStudioMode(TIC_RUN_MODE); + resumeRunMode(); } static void onAddFile(const char* name, AddResult result, void* data) diff --git a/src/machine.h b/src/machine.h index bb7f3d4..0fc71b7 100644 --- a/src/machine.h +++ b/src/machine.h @@ -125,9 +125,13 @@ typedef struct struct { MachineState state; - tic_sound_register registers[TIC_SOUND_CHANNELS]; - tic_music_pos music_pos; - tic_vram vram; + tic_ram ram; + + struct + { + u64 start; + u64 paused; + } time; } pause; } tic_machine; diff --git a/src/studio.c b/src/studio.c index 4288cbe..fd769ed 100644 --- a/src/studio.c +++ b/src/studio.c @@ -929,6 +929,11 @@ void exitFromGameMenu() studio.console->showGameMenu = false; } +void resumeRunMode() +{ + studio.mode = TIC_RUN_MODE; +} + void setStudioMode(EditorMode mode) { if(mode != studio.mode) diff --git a/src/studio.h b/src/studio.h index 67288b9..97dc34f 100644 --- a/src/studio.h +++ b/src/studio.h @@ -148,6 +148,7 @@ void studioRomSaved(); void studioConfigChanged(); void setStudioMode(EditorMode mode); +void resumeRunMode(); EditorMode getStudioMode(); void exitStudio(); u32 unzip(u8** dest, const u8* source, size_t size); diff --git a/src/tic.c b/src/tic.c index b8773ca..5623691 100644 --- a/src/tic.c +++ b/src/tic.c @@ -506,21 +506,25 @@ static void api_reset(tic_mem* memory) static void api_pause(tic_mem* memory) { tic_machine* machine = (tic_machine*)memory; + memcpy(&machine->pause.state, &machine->state, sizeof(MachineState)); - memcpy(&machine->pause.registers, &memory->ram.registers, sizeof memory->ram.registers); - memcpy(&machine->pause.music_pos, &memory->ram.music_pos, sizeof memory->ram.music_pos); - memcpy(&machine->pause.vram, &memory->ram.vram, sizeof memory->ram.vram); + memcpy(&machine->pause.ram, &memory->ram, sizeof(tic_ram)); + + machine->pause.time.start = machine->data->start; + machine->pause.time.paused = machine->data->counter(); } static void api_resume(tic_mem* memory) { - api_reset(memory); - tic_machine* machine = (tic_machine*)memory; - memcpy(&machine->state, &machine->pause.state, sizeof(MachineState)); - memcpy(&memory->ram.registers, &machine->pause.registers, sizeof memory->ram.registers); - memcpy(&memory->ram.music_pos, &machine->pause.music_pos, sizeof memory->ram.music_pos); - memcpy(&memory->ram.vram, &machine->pause.vram, sizeof memory->ram.vram); + + if (machine->data) + { + memcpy(&machine->state, &machine->pause.state, sizeof(MachineState)); + memcpy(&memory->ram, &machine->pause.ram, sizeof(tic_ram)); + + machine->data->start = machine->pause.time.start + machine->data->counter() - machine->pause.time.paused; + } } void tic_close(tic_mem* memory)