Adding minimal set of changes to the savestate procedures to ensure full re-record sync

This commit is contained in:
SergioMartin86 2024-04-06 16:04:22 +02:00
parent 25a90c634d
commit 4002e2e302
6 changed files with 29 additions and 10 deletions

View File

@ -40,13 +40,7 @@
#include "shared.h"
#include "gamepad.h"
static struct
{
uint8 State;
uint8 Counter;
uint8 Timeout;
uint32 Latency;
} gamepad[MAX_DEVICES];
struct gamepad_t gamepad[MAX_DEVICES];
static struct
{
@ -56,7 +50,6 @@ static struct
static uint8 latch;
void gamepad_reset(int port)
{
/* default state (Gouketsuji Ichizoku / Power Instinct, Samurai Spirits / Samurai Shodown) */

View File

@ -40,6 +40,16 @@
#ifndef _GAMEPAD_H_
#define _GAMEPAD_H_
struct gamepad_t
{
uint8 State;
uint8 Counter;
uint8 Timeout;
uint32 Latency;
};
extern struct gamepad_t gamepad[MAX_DEVICES];
/* Function prototypes */
extern void gamepad_reset(int port);
extern void gamepad_refresh(int port);

View File

@ -21,6 +21,7 @@
#include "membnk.h"
#include "io_ctrl.h"
#include "input.h"
#include "gamepad.h"
#include "sound.h"
#include "psg.h"
#include "ym2413.h"

View File

@ -71,6 +71,9 @@ int state_load(unsigned char *state)
zbank_memory_map[i].write = zbank_write_vdp;
}
/* SYSTEM */
load_param(&pause_b, sizeof(pause_b));
/* GENESIS */
if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
{
@ -109,6 +112,9 @@ int state_load(unsigned char *state)
io_reg[0] = 0x80 | (region_code >> 1);
}
/* CONTROLLERS */
load_param(gamepad, sizeof(gamepad));
/* VDP */
bufferptr += vdp_context_load(&state[bufferptr]);
@ -152,6 +158,7 @@ int state_load(unsigned char *state)
load_param(&m68k.cycles, sizeof(m68k.cycles));
load_param(&m68k.int_level, sizeof(m68k.int_level));
load_param(&m68k.stopped, sizeof(m68k.stopped));
load_param(&m68k.refresh_cycles, sizeof(m68k.refresh_cycles));
}
/* Z80 */
@ -200,6 +207,9 @@ int state_save(unsigned char *state)
memcpy(version,STATE_VERSION,16);
save_param(version, 16);
/* SYSTEM */
save_param(&pause_b, sizeof(pause_b));
/* GENESIS */
if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
{
@ -215,7 +225,10 @@ int state_save(unsigned char *state)
/* IO */
save_param(io_reg, sizeof(io_reg));
/* CONTROLLERS */
save_param(gamepad, sizeof(gamepad));
/* VDP */
bufferptr += vdp_context_save(&state[bufferptr]);
@ -251,6 +264,7 @@ int state_save(unsigned char *state)
save_param(&m68k.cycles, sizeof(m68k.cycles));
save_param(&m68k.int_level, sizeof(m68k.int_level));
save_param(&m68k.stopped, sizeof(m68k.stopped));
save_param(&m68k.refresh_cycles, sizeof(m68k.refresh_cycles));
}
/* Z80 */

View File

@ -51,7 +51,7 @@ uint8 system_bios;
uint32 system_clock;
int16 SVP_cycles = 800;
static uint8 pause_b;
uint8 pause_b;
static EQSTATE eq[2];
static int16 llp,rrp;

View File

@ -103,6 +103,7 @@ extern int16 SVP_cycles;
extern uint8 system_hw;
extern uint8 system_bios;
extern uint32 system_clock;
extern uint8 pause_b;
/* Function prototypes */
extern int audio_init(int samplerate, double framerate);