dont crash when loading states into newppu which were taken on oldppu

This commit is contained in:
zeromus 2017-04-27 22:59:35 +00:00
parent 83275f30d7
commit 50c0c2e5e4
3 changed files with 10 additions and 0 deletions

View File

@ -289,6 +289,11 @@ struct PPUREGS {
int newppu_get_scanline() { return ppur.status.sl; } int newppu_get_scanline() { return ppur.status.sl; }
int newppu_get_dot() { return ppur.status.cycle; } int newppu_get_dot() { return ppur.status.cycle; }
void newppu_hacky_emergency_reset()
{
if(ppur.status.end_cycle == 0)
ppur.reset();
}
static void makeppulut(void) { static void makeppulut(void) {
int x; int x;

View File

@ -11,6 +11,7 @@ extern void (*GameHBIRQHook)(void), (*GameHBIRQHook2)(void);
int newppu_get_scanline(); int newppu_get_scanline();
int newppu_get_dot(); int newppu_get_dot();
void newppu_hacky_emergency_reset();
/* For cart.c and banksw.h, mostly */ /* For cart.c and banksw.h, mostly */
extern uint8 NTARAM[0x800], *vnapage[4]; extern uint8 NTARAM[0x800], *vnapage[4];

View File

@ -974,8 +974,12 @@ void FCEUI_LoadState(const char *fname, bool display_message)
loadStateFailed = 1; loadStateFailed = 1;
return; // state doesn't exist; exit cleanly return; // state doesn't exist; exit cleanly
} }
if (FCEUSS_Load(fname, display_message)) if (FCEUSS_Load(fname, display_message))
{ {
//in case we're loading a savestate made with old ppu, we need to make sure ppur's regs used for dividing are ready to go
newppu_hacky_emergency_reset();
//mbg todo netplay //mbg todo netplay
#if 0 #if 0
if(FCEUnetplay) if(FCEUnetplay)