From: kub Date: Thu, 10 Feb 2022 22:06:47 +0000 (+0000) Subject: pico, added detection by extension X-Git-Tag: v2.00~346 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fc85c80af2009eb07f0fe4ec62e474f8fecff4e;p=picodrive.git pico, added detection by extension --- diff --git a/pico/cart.c b/pico/cart.c index 39d697c8..2e4f500c 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -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 diff --git a/pico/carthw.cfg b/pico/carthw.cfg index 650f9404..b9c8db9c 100644 --- a/pico/carthw.cfg +++ b/pico/carthw.cfg @@ -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 diff --git a/pico/carthw_cfg.c b/pico/carthw_cfg.c index 55c779e5..76de4a00 100644 --- a/pico/carthw_cfg.c +++ b/pico/carthw_cfg.c @@ -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" diff --git a/pico/media.c b/pico/media.c index c944f989..ae878f92 100644 --- a/pico/media.c +++ b/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) { diff --git a/pico/pico.h b/pico/pico.h index 807ec492..c7e4aa2a 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -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, };