megacd: don't reset the core and don't loose the save upon disks swap of the same game.
This commit is contained in:
20
menu.cpp
20
menu.cpp
@@ -1760,9 +1760,15 @@ void HandleUI(void)
|
||||
memcpy(Selected_tmp, Selected_S[ioctl_index & 3], sizeof(Selected_tmp));
|
||||
if (is_pce() || is_megacd())
|
||||
{
|
||||
fs_Options |= SCANO_NOENTER;
|
||||
char *p = strrchr(Selected_tmp, '/');
|
||||
if (p) *p = 0;
|
||||
int num = ScanDirectory(Selected_tmp, SCANF_INIT, fs_pFileExt, 0);
|
||||
memcpy(Selected_tmp, Selected_S[ioctl_index & 3], sizeof(Selected_tmp));
|
||||
|
||||
if (num == 1)
|
||||
{
|
||||
fs_Options |= SCANO_NOENTER;
|
||||
char *p = strrchr(Selected_tmp, '/');
|
||||
if (p) *p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (select) SelectFile(Selected_tmp, ext, fs_Options, fs_MenuSelect, fs_MenuCancel);
|
||||
@@ -1904,15 +1910,7 @@ void HandleUI(void)
|
||||
}
|
||||
else if (is_megacd())
|
||||
{
|
||||
uint32_t status = user_io_8bit_set_status(0, 0);
|
||||
if (!(status & 4))
|
||||
{
|
||||
user_io_8bit_set_status(1, 1);
|
||||
user_io_8bit_set_status(0, 1);
|
||||
mcd_reset();
|
||||
}
|
||||
mcd_set_image(ioctl_index, selPath);
|
||||
cheats_init(selPath, 0);
|
||||
}
|
||||
else if (is_pce())
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "../../spi.h"
|
||||
#include "../../hardware.h"
|
||||
#include "../../menu.h"
|
||||
#include "../../cheats.h"
|
||||
#include "megacd.h"
|
||||
|
||||
#define SAVE_IO_INDEX 5 // fake download to trigger save loading
|
||||
@@ -106,15 +107,31 @@ static int mcd_load_rom(const char *basename, const char *name, int sub_index)
|
||||
|
||||
void mcd_set_image(int num, const char *filename)
|
||||
{
|
||||
static char last_dir[1024] = {};
|
||||
|
||||
(void)num;
|
||||
|
||||
cdd.Unload();
|
||||
cdd.status = CD_STAT_OPEN;
|
||||
|
||||
mcd_mount_save("");
|
||||
sprintf(buf, "%s/boot.rom", HomeDir());
|
||||
int loaded = user_io_file_tx(buf);
|
||||
if (!loaded) Info("CD BIOS not found!", 4000);
|
||||
int same_game = *filename && *last_dir && !strncmp(last_dir, filename, strlen(last_dir));
|
||||
strcpy(last_dir, filename);
|
||||
char *p = strrchr(last_dir, '/');
|
||||
if (p) *p = 0;
|
||||
|
||||
int loaded = 1;
|
||||
if (!same_game)
|
||||
{
|
||||
mcd_mount_save("");
|
||||
|
||||
user_io_8bit_set_status(1, 1);
|
||||
user_io_8bit_set_status(0, 1);
|
||||
mcd_reset();
|
||||
|
||||
sprintf(buf, "%s/boot.rom", HomeDir());
|
||||
loaded = user_io_file_tx(buf);
|
||||
if (!loaded) Info("CD BIOS not found!", 4000);
|
||||
}
|
||||
|
||||
if (loaded && *filename)
|
||||
{
|
||||
@@ -124,9 +141,13 @@ void mcd_set_image(int num, const char *filename)
|
||||
cdd.latency = 10;
|
||||
cdd.SendData = mcd_send_data;
|
||||
|
||||
mcd_load_rom(filename, "cd_bios.rom", 0);
|
||||
mcd_load_rom(filename, "cart.rom", 1);
|
||||
mcd_mount_save(filename);
|
||||
if (!same_game)
|
||||
{
|
||||
mcd_load_rom(filename, "cd_bios.rom", 0);
|
||||
mcd_load_rom(filename, "cart.rom", 1);
|
||||
mcd_mount_save(filename);
|
||||
cheats_init(filename, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user