mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-26 17:32:40 +00:00
A2V2 save format also saves timing information
This commit is contained in:
parent
37df740fd3
commit
1be2c6fd27
@ -122,6 +122,10 @@ bool emulator_saveState(const char * const path) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!timing_saveState(&helper)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!video_saveState(&helper)) {
|
||||
break;
|
||||
}
|
||||
@ -200,6 +204,10 @@ bool emulator_loadState(const char * const path) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!timing_loadState(&helper)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!video_loadState(&helper)) {
|
||||
break;
|
||||
}
|
||||
|
61
src/timing.c
61
src/timing.c
@ -570,6 +570,67 @@ void timing_checkpoint_cycles(void) {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool timing_saveState(StateHelper_s *helper) {
|
||||
bool saved = false;
|
||||
int fd = helper->fd;
|
||||
|
||||
do {
|
||||
long lVal = 0;
|
||||
|
||||
lVal = (long)(cpu_scale_factor * 100.);
|
||||
if (!helper->save(fd, (uint8_t *)&lVal, sizeof(lVal))) {
|
||||
break;
|
||||
}
|
||||
|
||||
lVal = (long)(cpu_altscale_factor * 100.);
|
||||
if (!helper->save(fd, (uint8_t *)&lVal, sizeof(lVal))) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t bVal = alt_speed_enabled ? 1 : 0;
|
||||
if (!helper->save(fd, &bVal, sizeof(bVal))) {
|
||||
break;
|
||||
}
|
||||
|
||||
saved = true;
|
||||
} while (0);
|
||||
|
||||
return saved;
|
||||
}
|
||||
|
||||
bool timing_loadState(StateHelper_s *helper) {
|
||||
bool loaded = false;
|
||||
int fd = helper->fd;
|
||||
|
||||
do {
|
||||
long lVal = 0;
|
||||
|
||||
if (!helper->load(fd, (uint8_t *)&lVal, sizeof(lVal))) {
|
||||
break;
|
||||
}
|
||||
cpu_scale_factor = lVal / 100.;
|
||||
|
||||
if (!helper->load(fd, (uint8_t *)&lVal, sizeof(lVal))) {
|
||||
break;
|
||||
}
|
||||
cpu_altscale_factor = lVal / 100.;
|
||||
|
||||
uint8_t bVal = 0;
|
||||
if (!helper->load(fd, &bVal, sizeof(bVal))) {
|
||||
break;
|
||||
}
|
||||
alt_speed_enabled = !!bVal;
|
||||
|
||||
timing_initialize();
|
||||
|
||||
loaded = true;
|
||||
} while (0);
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static void vm_prefsChanged(const char *domain) {
|
||||
(void)domain;
|
||||
|
||||
|
@ -118,4 +118,11 @@ bool cpu_isPaused(void);
|
||||
*/
|
||||
void timing_checkpoint_cycles(void);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool timing_saveState(StateHelper_s *helper);
|
||||
|
||||
bool timing_loadState(StateHelper_s *helper);
|
||||
|
||||
|
||||
#endif // whole file
|
||||
|
Loading…
x
Reference in New Issue
Block a user