"resume" command resets time() #476

This commit is contained in:
BADIM-PC\Vadim 2017-12-19 14:02:56 +03:00
parent ebb2e8646a
commit 8a87df5a8b
5 changed files with 27 additions and 14 deletions

View File

@ -2061,9 +2061,8 @@ static void onConsoleResumeCommand(Console* console, const char* param)
commandDone(console); commandDone(console);
console->tic->api.resume(console->tic); 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) static void onAddFile(const char* name, AddResult result, void* data)

View File

@ -125,9 +125,13 @@ typedef struct
struct struct
{ {
MachineState state; MachineState state;
tic_sound_register registers[TIC_SOUND_CHANNELS]; tic_ram ram;
tic_music_pos music_pos;
tic_vram vram; struct
{
u64 start;
u64 paused;
} time;
} pause; } pause;
} tic_machine; } tic_machine;

View File

@ -929,6 +929,11 @@ void exitFromGameMenu()
studio.console->showGameMenu = false; studio.console->showGameMenu = false;
} }
void resumeRunMode()
{
studio.mode = TIC_RUN_MODE;
}
void setStudioMode(EditorMode mode) void setStudioMode(EditorMode mode)
{ {
if(mode != studio.mode) if(mode != studio.mode)

View File

@ -148,6 +148,7 @@ void studioRomSaved();
void studioConfigChanged(); void studioConfigChanged();
void setStudioMode(EditorMode mode); void setStudioMode(EditorMode mode);
void resumeRunMode();
EditorMode getStudioMode(); EditorMode getStudioMode();
void exitStudio(); void exitStudio();
u32 unzip(u8** dest, const u8* source, size_t size); u32 unzip(u8** dest, const u8* source, size_t size);

View File

@ -506,21 +506,25 @@ static void api_reset(tic_mem* memory)
static void api_pause(tic_mem* memory) static void api_pause(tic_mem* memory)
{ {
tic_machine* machine = (tic_machine*)memory; tic_machine* machine = (tic_machine*)memory;
memcpy(&machine->pause.state, &machine->state, sizeof(MachineState)); memcpy(&machine->pause.state, &machine->state, sizeof(MachineState));
memcpy(&machine->pause.registers, &memory->ram.registers, sizeof memory->ram.registers); memcpy(&machine->pause.ram, &memory->ram, sizeof(tic_ram));
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); machine->pause.time.start = machine->data->start;
machine->pause.time.paused = machine->data->counter();
} }
static void api_resume(tic_mem* memory) static void api_resume(tic_mem* memory)
{ {
api_reset(memory);
tic_machine* machine = (tic_machine*)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); if (machine->data)
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); 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) void tic_close(tic_mem* memory)