"resume" command resets time() #476
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								src/tic.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user