Skip to content

Commit

Permalink
mcd, fix regression when reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Sep 28, 2024
1 parent 8f0952a commit f4ab264
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ At present, most development activity occurs in
[irixxxx's fork](https://github.com/irixxxx/picodrive);
[notaz's repo](https://github.com/notaz/picodrive) is updated less frequently.

### Using MSU, MD+/32X+, and Mode 1 on Sega/Mega CD

PicoDrive supports using CD audio enhanced cartridge games in all 3 formats.
To start an enhanced cartridge, the "cue" or "chd" file of the audio CD must be
selected. Further instructions can be found in `platform/base_readme.txt`.

### Sega Pico and Storyware Pages

PicoDrive can use Storyware pages and pad overlays in png format in the same
Expand Down
7 changes: 6 additions & 1 deletion pico/cd/mcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ PICO_INTERNAL void PicoCreateMCD(unsigned char *bios_data, int bios_size)
{
if (!Pico_mcd) {
Pico_mcd = plat_mmap(0x05000000, sizeof(mcd_state), 0, 0);
memset(Pico_mcd, 0, sizeof(mcd_state));
if (Pico_mcd == NULL) {
elprintf(EL_STATUS, "OOM");
return;
}
}
memset(Pico_mcd, 0, sizeof(mcd_state));

if (bios_data && bios_size > 0) {
if (bios_size > sizeof(Pico_mcd->bios))
bios_size = sizeof(Pico_mcd->bios);
Expand Down
28 changes: 15 additions & 13 deletions pico/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,21 +303,23 @@ enum media_type_e PicoLoadMedia(const char *filename,
goto out;
}

ret = PicoCartLoad(rom_file, NULL, 0, &rom_data, &rom_size, 0);
if (ret != 0) {
lprintf("reading BIOS failed\n");
media_type = PM_ERROR;
goto out;
if (rom_file != NULL) {
ret = PicoCartLoad(rom_file, NULL, 0, &rom_data, &rom_size, 0);
if (ret != 0) {
lprintf("reading BIOS failed\n");
media_type = PM_ERROR;
goto out;
}

// copy BIOS and close file
PicoCreateMCD(rom_data, rom_size);

PicoCartUnload();
pm_close(rom_file);
rom_file = NULL;
rom_size = 0;
}

// copy BIOS and close file
PicoCreateMCD(rom_data, rom_size);

PicoCartUnload();
pm_close(rom_file);
rom_file = NULL;
rom_size = 0;

// if there is an MSU ROM, it's name is now in rom_fname for loading
PicoIn.AHW |= PAHW_MCD;
}
Expand Down
7 changes: 4 additions & 3 deletions platform/base_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ Just copy the .pnd to <sd card>/pandora/menu or <sd card>/pandora/desktop.
Then load a ROM and enjoy! Cartridge ROMs can be in various common formats and
can be zipped, one ROM file per zip. Certain extensions are used to detect the
console the ROM is for (.sg, .sc, .sms, .gg, .smd, .md, .gen, .32x, .pco).
For MSU games, load the .cue file and make sure the cartridge ROM has the same
name and is in the same directory.
For MSU or MD+ games, load the .cue file and make sure the cartridge ROM has the
same name and is in the same directory. MD+ use extensions in the .cue file,
hence don't try to convert it to any other format.
Sega/Mega CD images can be in CHD, CUE+BIN/ISO or ISO/CSO+MP3/WAV format (read
below for more details).

Expand All @@ -48,7 +49,7 @@ option.
How to run Sega/Mega CD games
-----------------------------

To play any non-MSU CD game you need BIOS files. These files must be copied to
To play any non-MSU/MD+ CD game you need BIOS files. These must be copied to
#ifdef PANDORA
<sd card>/pandora/appdata/picodrive/ directory
(if you run PicoDrive once it will create that directory for you).
Expand Down

0 comments on commit f4ab264

Please sign in to comment.