static int detect_media(const char *fname)\r
{\r
static const short sms_offsets[] = { 0x7ff0, 0x3ff0, 0x1ff0 };\r
+ static const char *sms_exts[] = { "sms", "gg", "sg" };\r
+ static const char *md_exts[] = { "gen", "bin", "smd" };\r
+ char buff0[32], buff[32];\r
+ unsigned short *d16;\r
pm_file *pmf;\r
- char buff[32];\r
char ext[5];\r
int i;\r
\r
if (pmf == NULL)\r
return PM_BAD;\r
\r
- if (pm_read(buff, 32, pmf) != 32) {\r
+ if (pm_read(buff0, 32, pmf) != 32) {\r
pm_close(pmf);\r
return PM_BAD;\r
}\r
\r
- if (strncasecmp("SEGADISCSYSTEM", buff + 0x00, 14) == 0 ||\r
- strncasecmp("SEGADISCSYSTEM", buff + 0x10, 14) == 0) {\r
+ if (strncasecmp("SEGADISCSYSTEM", buff0 + 0x00, 14) == 0 ||\r
+ strncasecmp("SEGADISCSYSTEM", buff0 + 0x10, 14) == 0) {\r
pm_close(pmf);\r
return PM_CD;\r
}\r
\r
+ /* check for SMD evil */\r
+ if (pmf->size >= 0x4200 && (pmf->size & 0x3fff) == 0x200) {\r
+ if (pm_seek(pmf, sms_offsets[0] + 0x200, SEEK_SET) == sms_offsets[0] + 0x200 &&\r
+ pm_read(buff, 16, pmf) == 16 &&\r
+ strncmp("TMR SEGA", buff, 8) == 0)\r
+ goto looks_like_sms;\r
+\r
+ /* could parse further but don't bother */\r
+ goto extension_check;\r
+ }\r
+\r
+ /* MD header? Act as TMSS BIOS here */\r
+ if (pm_seek(pmf, 0x100, SEEK_SET) == 0x100 && pm_read(buff, 16, pmf) == 16) {\r
+ if (strncmp(buff, "SEGA", 4) == 0 || strncmp(buff, " SEG", 4) == 0)\r
+ goto looks_like_md;\r
+ }\r
+\r
for (i = 0; i < array_size(sms_offsets); i++) {\r
if (pm_seek(pmf, sms_offsets[i], SEEK_SET) != sms_offsets[i])\r
- goto not_mark3; /* actually it could be but can't be detected */\r
+ continue;\r
\r
if (pm_read(buff, 16, pmf) != 16)\r
- goto not_mark3;\r
+ continue;\r
\r
- if (strncasecmp("TMR SEGA", buff, 8) == 0) {\r
- pm_close(pmf);\r
- return PM_MARK3;\r
- }\r
+ if (strncmp("TMR SEGA", buff, 8) == 0)\r
+ goto looks_like_sms;\r
+ }\r
+\r
+extension_check:\r
+ /* probably some headerless thing. Maybe check the extension after all. */\r
+ for (i = 0; i < array_size(md_exts); i++)\r
+ if (strcasecmp(pmf->ext, md_exts[i]) == 0)\r
+ goto looks_like_md;\r
+\r
+ for (i = 0; i < array_size(sms_exts); i++)\r
+ if (strcasecmp(pmf->ext, sms_exts[i]) == 0)\r
+ goto looks_like_sms;\r
+\r
+ /* If everything else fails, make a guess on the reset vector */\r
+ d16 = (unsigned short *)(buff0 + 4);\r
+ if ((((d16[0] << 16) | d16[1]) & 0xffffff) >= pmf->size) {\r
+ lprintf("bad MD reset vector, assuming SMS\n");\r
+ goto looks_like_sms;\r
}\r
\r
-not_mark3:\r
+looks_like_md:\r
pm_close(pmf);\r
- /* the main emu function is to emulate MD, so assume MD */\r
return PM_MD_CART;\r
+\r
+looks_like_sms:\r
+ pm_close(pmf);\r
+ return PM_MARK3;\r
}\r
\r
static int extract_text(char *dest, const unsigned char *src, int len, int swab)\r
\r
shutdown_MCD();\r
PicoPatchUnload();\r
+ PicoAHW = 0;\r
\r
if (media_type == PM_CD)\r
{\r
OBJS += ../../picoAll.o\r
else\r
OBJS += pico/area.o pico/cart.o pico/memory.o pico/misc.o pico/pico.o pico/sek.o pico/z80if.o \\r
- pico/videoport.o pico/draw2.o pico/draw.o pico/patch.o pico/debug.o\r
+ pico/videoport.o pico/draw2.o pico/draw.o pico/mode4.o pico/sms.o pico/patch.o pico/debug.o\r
# Pico - CD\r
OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \\r
pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \\r
all: mkdirs PicoDrive\r
\r
include ../common/common_arm.mak\r
-\r
-platform/common/menu.o : revision.h\r
-\r
-revision.h:\r
- @echo "#define REVISION \"`svn info | grep Revision | cut -c 11-`\"" > /tmp/r.tmp\r
- @diff -q $@ /tmp/r.tmp > /dev/null 2>&1 || mv -f /tmp/r.tmp $@\r
+include ../common/revision.mak\r
\r
# partial linking helps profiled builds due to section merging\r
PicoDrive.o : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a\r
\r
static int EmuScanBegin16(unsigned int num)\r
{\r
- if (!(Pico.video.reg[1]&8)) num += 8;\r
DrawLineDest = (unsigned short *) g_screen_ptr + g_screen_width * num;\r
\r
return 0;\r
\r
static int EmuScanBegin8(unsigned int num)\r
{\r
- if (!(Pico.video.reg[1]&8)) num += 8;\r
DrawLineDest = (unsigned char *) g_screen_ptr + g_screen_width * num;\r
\r
return 0;\r
{\r
if ((num & 3) != 3)\r
return 0;\r
- if (!(Pico.video.reg[1] & 8))\r
- num += 8;\r
rotated_blit16(g_screen_ptr, rot_buff, num + 1,\r
!(Pico.video.reg[12] & 1) && !(PicoOpt & POPT_EN_SOFTSCALE));\r
return 0;\r
{\r
if ((num & 3) != 3)\r
return 0;\r
- if (!(Pico.video.reg[1] & 8))\r
- num += 8;\r
rotated_blit8(g_screen_ptr, rot_buff, num + 1,\r
!(Pico.video.reg[12] & 1));\r
return 0;\r
}\r
else if (currentConfig.EmuOpt & EOPT_16BPP) {\r
PicoDrawSetColorFormat(1);\r
- PicoDrawSetColorFormatMode4(1);\r
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
gp2x_video_changemode(-16);\r
PicoScanBegin = EmuScanBegin16_rot;\r