mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
pico, added detection by extension
This commit is contained in:
parent
d4a08748fa
commit
4fc85c80af
5 changed files with 28 additions and 31 deletions
18
pico/media.c
18
pico/media.c
|
@ -36,6 +36,7 @@ static int detect_media(const char *fname)
|
|||
static const short sms_offsets[] = { 0x7ff0, 0x3ff0, 0x1ff0 };
|
||||
static const char *sms_exts[] = { "sms", "gg", "sg" };
|
||||
static const char *md_exts[] = { "gen", "smd" };
|
||||
static const char *pico_exts[] = { "pco" };
|
||||
char buff0[512], buff[32];
|
||||
unsigned short *d16;
|
||||
pm_file *pmf;
|
||||
|
@ -78,8 +79,12 @@ static int detect_media(const char *fname)
|
|||
goto extension_check;
|
||||
}
|
||||
|
||||
/* MD header? Act as TMSS BIOS here */
|
||||
if (pm_seek(pmf, 0x100, SEEK_SET) == 0x100 && pm_read(buff, 16, pmf) == 16) {
|
||||
/* PICO header? Almost always appropriately marked */
|
||||
buff[16] = '\0';
|
||||
if (strstr(buff, " PICO "))
|
||||
goto looks_like_pico;
|
||||
/* MD header? Act as TMSS BIOS here */
|
||||
if (strncmp(buff, "SEGA", 4) == 0 || strncmp(buff, " SEG", 4) == 0)
|
||||
goto looks_like_md;
|
||||
}
|
||||
|
@ -105,6 +110,10 @@ extension_check:
|
|||
if (strcasecmp(pmf->ext, sms_exts[i]) == 0)
|
||||
goto looks_like_sms;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(pico_exts); i++)
|
||||
if (strcasecmp(pmf->ext, pico_exts[i]) == 0)
|
||||
goto looks_like_pico;
|
||||
|
||||
/* If everything else fails, make a guess on the reset vector */
|
||||
d16 = (unsigned short *)(buff0 + 4);
|
||||
if ((((d16[0] << 16) | d16[1]) & 0xffffff) >= pmf->size) {
|
||||
|
@ -124,6 +133,10 @@ looks_like_md:
|
|||
looks_like_sms:
|
||||
pm_close(pmf);
|
||||
return PM_MARK3;
|
||||
|
||||
looks_like_pico:
|
||||
pm_close(pmf);
|
||||
return PM_PICO;
|
||||
}
|
||||
|
||||
/* checks if fname points to valid MegaCD image */
|
||||
|
@ -250,6 +263,9 @@ enum media_type_e PicoLoadMedia(const char *filename,
|
|||
else if (media_type == PM_MARK3) {
|
||||
PicoIn.AHW = PAHW_SMS;
|
||||
}
|
||||
else if (media_type == PM_PICO) {
|
||||
PicoIn.AHW = PAHW_PICO;
|
||||
}
|
||||
|
||||
rom = pm_open(rom_fname);
|
||||
if (rom == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue