[Core/MD] reduced savestate size when both Mega CD and MegaSD hardware are detected (fixes savestates with MSU-MD games that have "SEGA MEGASD" in ROM header)

This commit is contained in:
ekeeke 2022-08-31 18:01:39 +02:00
parent 47d20265c9
commit eef172acf3
5 changed files with 25 additions and 16 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 4.0 MiB

View File

@ -2,7 +2,7 @@
* Genesis Plus
* MegaSD flashcart CD hardware interface overlay & enhanced ROM mappers
*
* Copyright (C) 2020-2021 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2020-2022 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -91,20 +91,28 @@ void megasd_reset(void)
m68k.memory_map[0x03].write16 = megasd_ctrl_write_word;
zbank_memory_map[0x03].read = megasd_ctrl_read_byte;
/* reset CD hardware */
/* reset CD hardware (only if not already emulated) */
if (system_hw != SYSTEM_MCD)
{
pcm_reset();
cdd_reset();
scd.regs[0x36>>1].byte.h = 0x01;
}
}
int megasd_context_save(uint8 *state)
{
int bufferptr = 0;
save_param(&megasd_hw, sizeof(megasd_hw));
/* save needed CD hardware state (only if not already saved) */
if (system_hw != SYSTEM_MCD)
{
bufferptr += cdd_context_save(&state[bufferptr]);
bufferptr += pcm_context_save(&state[bufferptr]);
save_param(&scd.regs[0x36>>1].byte.h, 1);
}
return bufferptr;
}
@ -114,9 +122,14 @@ int megasd_context_load(uint8 *state)
int bufferptr = 0;
load_param(&megasd_hw, sizeof(megasd_hw));
/* load needed CD hardware state (only if not already loaded) */
if (system_hw != SYSTEM_MCD)
{
bufferptr += cdd_context_load(&state[bufferptr], STATE_VERSION);
bufferptr += pcm_context_load(&state[bufferptr]);
load_param(&scd.regs[0x36>>1].byte.h, 1);
}
return bufferptr;
}
@ -314,10 +327,6 @@ void megasd_rom_mapper_w(unsigned int address, unsigned int data)
m68k.memory_map[i].write16 = m68k_unused_16_w;
zbank_memory_map[i].write = zbank_unused_w;
}
/* enable CD hardware overlay access */
m68k.memory_map[0x03].write8 = megasd_ctrl_write_byte;
m68k.memory_map[0x03].write16 = megasd_ctrl_write_word;
}
}
else

View File

@ -2,7 +2,7 @@
* Genesis Plus
* MegaSD flashcart CD hardware interface overlay & enhanced ROM mappers
*
* Copyright (C) 2020-2021 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2020-2022 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: