pico, added detection by extension

This commit is contained in:
kub 2022-02-10 22:06:47 +00:00
parent d4a08748fa
commit 4fc85c80af
5 changed files with 28 additions and 31 deletions

View file

@ -837,7 +837,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
}
pdb_cleanup();
PicoIn.AHW &= PAHW_MCD|PAHW_SMS;
PicoIn.AHW &= PAHW_MCD|PAHW_SMS|PAHW_PICO;
PicoCartMemSetup = NULL;
PicoDmaHook = NULL;
@ -846,9 +846,9 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
PicoLoadStateHook = NULL;
carthw_chunks = NULL;
if (!(PicoIn.AHW & (PAHW_MCD|PAHW_SMS)))
if (!(PicoIn.AHW & (PAHW_MCD|PAHW_SMS|PAHW_PICO)))
PicoCartDetect(carthw_cfg);
else if (PicoIn.AHW & PAHW_SMS)
if (PicoIn.AHW & PAHW_SMS)
PicoCartDetectMS();
// setup correct memory map for loaded ROM

View file

@ -42,24 +42,13 @@ check_str = 0x150, "VIRTUA RACING"
check_str = 0x810, "OHMP"
hw = svp
[Pico]
check_str = 0x100, "SEGA PICO"
[Soreike! Anpanman no Game de Asobou Anpanman - Pico]
check_str = 0x100, "SEGA IAC "
hw = pico
[Pico]
check_str = 0x100, "SEGATOYS PICO"
hw = pico
[Pico]
check_str = 0x100, "SEGA TOYS PICO"
hw = pico
[Pico]
check_str = 0x100, "SAMSUNG PICO"
hw = pico
[Pico]
check_str = 0x100, "IMA IKUNOUJYUKU"
# Unou Kaihatsu Series: IMA IKUNO[U]JYUKU
[Unou Kaihatsu Series - Pico]
check_str = 0x100, "IMA IKUNO"
hw = pico
# sram emulation triggers some protection for this one

View file

@ -9,19 +9,10 @@ static const char builtin_carthw_cfg[] =
"check_str=0x810,\"OHMP\"\n"
"hw=svp\n"
"[]\n"
"check_str=0x100,\"SEGA PICO\"\n"
"check_str=0x100,\"SEGA IAC \"\n"
"hw=pico\n"
"[]\n"
"check_str=0x100,\"SEGATOYS PICO\"\n"
"hw=pico\n"
"[]\n"
"check_str=0x100,\"SEGA TOYS PICO\"\n"
"hw=pico\n"
"[]\n"
"check_str=0x100,\"SAMSUNG PICO\"\n"
"hw=pico\n"
"[]\n"
"check_str=0x100,\"IMA IKUNOUJYUKU\"\n"
"check_str=0x100,\"IMA IKUNO\"\n"
"hw=pico\n"
"[]\n"
"check_str=0x120,\"PUGGSY\"\n"

View file

@ -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) {

View file

@ -264,6 +264,7 @@ enum media_type_e {
PM_BAD_CD_NO_BIOS = -4,
PM_MD_CART = 1, /* also 32x */
PM_MARK3,
PM_PICO,
PM_CD,
};