Skip to content

Commit

Permalink
[Core/MD] reduced savestate size when both Mega CD and MegaSD hardwar…
Browse files Browse the repository at this point in the history
…e are detected (fixes savestates with MSU-MD games that have "SEGA MEGASD" in ROM header)
  • Loading branch information
ekeeke committed Aug 31, 2022
1 parent 47d2026 commit eef172a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
Binary file modified builds/genesis_plus_gx_libretro.dll
Binary file not shown.
Binary file modified builds/genplus_cube.dol
Binary file not shown.
Binary file modified builds/genplus_wii.dol
Binary file not shown.
39 changes: 24 additions & 15 deletions core/cart_hw/megasd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 */
pcm_reset();
cdd_reset();
scd.regs[0x36>>1].byte.h = 0x01;
/* 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));
bufferptr += cdd_context_save(&state[bufferptr]);
bufferptr += pcm_context_save(&state[bufferptr]);
save_param(&scd.regs[0x36>>1].byte.h, 1);

/* 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;
}
Expand All @@ -114,9 +122,14 @@ int megasd_context_load(uint8 *state)
int bufferptr = 0;

load_param(&megasd_hw, sizeof(megasd_hw));
bufferptr += cdd_context_load(&state[bufferptr], STATE_VERSION);
bufferptr += pcm_context_load(&state[bufferptr]);
load_param(&scd.regs[0x36>>1].byte.h, 1);

/* 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;
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/cart_hw/megasd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit eef172a

Please sign in to comment.