mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
more sms wip, better ROM detect, line callback change
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@762 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
9569ea52ed
commit
86c1049d1f
8 changed files with 69 additions and 43 deletions
67
common/emu.c
67
common/emu.c
|
@ -245,8 +245,11 @@ static int emu_cd_check(int *pregion, const char *fname_in)
|
|||
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", "bin", "smd" };
|
||||
char buff0[32], buff[32];
|
||||
unsigned short *d16;
|
||||
pm_file *pmf;
|
||||
char buff[32];
|
||||
char ext[5];
|
||||
int i;
|
||||
|
||||
|
@ -264,34 +267,69 @@ static int detect_media(const char *fname)
|
|||
if (pmf == NULL)
|
||||
return PM_BAD;
|
||||
|
||||
if (pm_read(buff, 32, pmf) != 32) {
|
||||
if (pm_read(buff0, 32, pmf) != 32) {
|
||||
pm_close(pmf);
|
||||
return PM_BAD;
|
||||
}
|
||||
|
||||
if (strncasecmp("SEGADISCSYSTEM", buff + 0x00, 14) == 0 ||
|
||||
strncasecmp("SEGADISCSYSTEM", buff + 0x10, 14) == 0) {
|
||||
if (strncasecmp("SEGADISCSYSTEM", buff0 + 0x00, 14) == 0 ||
|
||||
strncasecmp("SEGADISCSYSTEM", buff0 + 0x10, 14) == 0) {
|
||||
pm_close(pmf);
|
||||
return PM_CD;
|
||||
}
|
||||
|
||||
/* check for SMD evil */
|
||||
if (pmf->size >= 0x4200 && (pmf->size & 0x3fff) == 0x200) {
|
||||
if (pm_seek(pmf, sms_offsets[0] + 0x200, SEEK_SET) == sms_offsets[0] + 0x200 &&
|
||||
pm_read(buff, 16, pmf) == 16 &&
|
||||
strncmp("TMR SEGA", buff, 8) == 0)
|
||||
goto looks_like_sms;
|
||||
|
||||
/* could parse further but don't bother */
|
||||
goto extension_check;
|
||||
}
|
||||
|
||||
/* MD header? Act as TMSS BIOS here */
|
||||
if (pm_seek(pmf, 0x100, SEEK_SET) == 0x100 && pm_read(buff, 16, pmf) == 16) {
|
||||
if (strncmp(buff, "SEGA", 4) == 0 || strncmp(buff, " SEG", 4) == 0)
|
||||
goto looks_like_md;
|
||||
}
|
||||
|
||||
for (i = 0; i < array_size(sms_offsets); i++) {
|
||||
if (pm_seek(pmf, sms_offsets[i], SEEK_SET) != sms_offsets[i])
|
||||
goto not_mark3; /* actually it could be but can't be detected */
|
||||
continue;
|
||||
|
||||
if (pm_read(buff, 16, pmf) != 16)
|
||||
goto not_mark3;
|
||||
continue;
|
||||
|
||||
if (strncasecmp("TMR SEGA", buff, 8) == 0) {
|
||||
if (strncmp("TMR SEGA", buff, 8) == 0)
|
||||
goto looks_like_sms;
|
||||
}
|
||||
|
||||
extension_check:
|
||||
/* probably some headerless thing. Maybe check the extension after all. */
|
||||
for (i = 0; i < array_size(md_exts); i++)
|
||||
if (strcasecmp(pmf->ext, md_exts[i]) == 0)
|
||||
goto looks_like_md;
|
||||
|
||||
for (i = 0; i < array_size(sms_exts); i++)
|
||||
if (strcasecmp(pmf->ext, sms_exts[i]) == 0)
|
||||
goto looks_like_sms;
|
||||
|
||||
/* 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) {
|
||||
lprintf("bad MD reset vector, assuming SMS\n");
|
||||
goto looks_like_sms;
|
||||
}
|
||||
|
||||
looks_like_md:
|
||||
pm_close(pmf);
|
||||
return PM_MD_CART;
|
||||
|
||||
looks_like_sms:
|
||||
pm_close(pmf);
|
||||
return PM_MARK3;
|
||||
}
|
||||
}
|
||||
|
||||
not_mark3:
|
||||
pm_close(pmf);
|
||||
/* the main emu function is to emulate MD, so assume MD */
|
||||
return PM_MD_CART;
|
||||
}
|
||||
|
||||
static int extract_text(char *dest, const unsigned char *src, int len, int swab)
|
||||
|
@ -450,6 +488,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
|
||||
shutdown_MCD();
|
||||
PicoPatchUnload();
|
||||
PicoAHW = 0;
|
||||
|
||||
if (media_type == PM_CD)
|
||||
{
|
||||
|
|
|
@ -1803,7 +1803,7 @@ static void debug_menu_loop(void)
|
|||
{
|
||||
case 0:
|
||||
if (inp & PBTN_MOK)
|
||||
SekStepM68k();
|
||||
PDebugCPUStep();
|
||||
if (inp & PBTN_MA3) {
|
||||
while (inp & PBTN_MA3)
|
||||
inp = in_menu_wait_any(-1);
|
||||
|
|
8
common/revision.mak
Normal file
8
common/revision.mak
Normal file
|
@ -0,0 +1,8 @@
|
|||
platform/common/menu.o : revision.h
|
||||
|
||||
revision.h: FORCE
|
||||
@echo "#define REVISION \"`svn info -r HEAD | grep Revision | cut -c 11-`\"" > /tmp/r.tmp
|
||||
@diff -q $@ /tmp/r.tmp > /dev/null 2>&1 || mv -f /tmp/r.tmp $@
|
||||
|
||||
FORCE:
|
||||
|
|
@ -65,7 +65,7 @@ ifeq "$(amalgamate)" "1"
|
|||
OBJS += ../../picoAll.o
|
||||
else
|
||||
OBJS += pico/area.o pico/cart.o pico/memory.o pico/misc.o pico/pico.o pico/sek.o pico/z80if.o \
|
||||
pico/videoport.o pico/draw2.o pico/draw.o pico/patch.o pico/debug.o
|
||||
pico/videoport.o pico/draw2.o pico/draw.o pico/mode4.o pico/sms.o pico/patch.o pico/debug.o
|
||||
# Pico - CD
|
||||
OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \
|
||||
pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \
|
||||
|
@ -120,12 +120,7 @@ DIRS = platform platform/gp2x platform/linux platform/common pico pico/cd pico/p
|
|||
all: mkdirs PicoDrive
|
||||
|
||||
include ../common/common_arm.mak
|
||||
|
||||
platform/common/menu.o : revision.h
|
||||
|
||||
revision.h:
|
||||
@echo "#define REVISION \"`svn info | grep Revision | cut -c 11-`\"" > /tmp/r.tmp
|
||||
@diff -q $@ /tmp/r.tmp > /dev/null 2>&1 || mv -f /tmp/r.tmp $@
|
||||
include ../common/revision.mak
|
||||
|
||||
# partial linking helps profiled builds due to section merging
|
||||
PicoDrive.o : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a
|
||||
|
|
|
@ -220,7 +220,6 @@ static void draw_pico_ptr(void)
|
|||
|
||||
static int EmuScanBegin16(unsigned int num)
|
||||
{
|
||||
if (!(Pico.video.reg[1]&8)) num += 8;
|
||||
DrawLineDest = (unsigned short *) g_screen_ptr + g_screen_width * num;
|
||||
|
||||
return 0;
|
||||
|
@ -228,7 +227,6 @@ static int EmuScanBegin16(unsigned int num)
|
|||
|
||||
static int EmuScanBegin8(unsigned int num)
|
||||
{
|
||||
if (!(Pico.video.reg[1]&8)) num += 8;
|
||||
DrawLineDest = (unsigned char *) g_screen_ptr + g_screen_width * num;
|
||||
|
||||
return 0;
|
||||
|
@ -247,8 +245,6 @@ static int EmuScanEnd16_rot(unsigned int num)
|
|||
{
|
||||
if ((num & 3) != 3)
|
||||
return 0;
|
||||
if (!(Pico.video.reg[1] & 8))
|
||||
num += 8;
|
||||
rotated_blit16(g_screen_ptr, rot_buff, num + 1,
|
||||
!(Pico.video.reg[12] & 1) && !(PicoOpt & POPT_EN_SOFTSCALE));
|
||||
return 0;
|
||||
|
@ -264,8 +260,6 @@ static int EmuScanEnd8_rot(unsigned int num)
|
|||
{
|
||||
if ((num & 3) != 3)
|
||||
return 0;
|
||||
if (!(Pico.video.reg[1] & 8))
|
||||
num += 8;
|
||||
rotated_blit8(g_screen_ptr, rot_buff, num + 1,
|
||||
!(Pico.video.reg[12] & 1));
|
||||
return 0;
|
||||
|
@ -439,7 +433,6 @@ static void vidResetMode(void)
|
|||
}
|
||||
else if (currentConfig.EmuOpt & EOPT_16BPP) {
|
||||
PicoDrawSetColorFormat(1);
|
||||
PicoDrawSetColorFormatMode4(1);
|
||||
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {
|
||||
gp2x_video_changemode(-16);
|
||||
PicoScanBegin = EmuScanBegin16_rot;
|
||||
|
|
|
@ -97,16 +97,13 @@ PicoDrive : $(OBJS) ../common/helix/helix_mp3_x86.a
|
|||
$(CC) $(CFLAGS) $^ $(LDFLAGS) -lm -lpng -Wl,-Map=PicoDrive.map -o $@
|
||||
|
||||
mkdirs:
|
||||
mkdir -p $(DIRS)
|
||||
@mkdir -p $(DIRS)
|
||||
|
||||
include ../common/revision.mak
|
||||
|
||||
pico/carthw/svp/compiler.o : ../../pico/carthw/svp/gen_arm.c
|
||||
pico/pico.o pico/cd/pico.o : ../../pico/pico_cmn.c ../../pico/pico_int.h
|
||||
pico/memory.o pico/cd/memory.o : ../../pico/memory_cmn.c ../../pico/pico_int.h
|
||||
platform/common/menu.o : revision.h
|
||||
|
||||
revision.h:
|
||||
@echo "#define REVISION \"`svn info | grep Revision | cut -c 11-`\"" > /tmp/r.tmp
|
||||
@diff -q $@ /tmp/r.tmp > /dev/null 2>&1 || mv -f /tmp/r.tmp $@
|
||||
|
||||
../../cpu/musashi/m68kops.c :
|
||||
@make -C ../../cpu/musashi
|
||||
|
|
|
@ -186,7 +186,6 @@ static void draw_pico_ptr(void)
|
|||
|
||||
static int EmuScanBegin16(unsigned int num)
|
||||
{
|
||||
if (!(Pico.video.reg[1]&8)) num += 8;
|
||||
DrawLineDest = (unsigned short *)g_screen_ptr + num*800 + 800/2 - 320/2;
|
||||
//int w = (Pico.video.reg[12]&1) ? 320 : 256;
|
||||
//DrawLineDest = (unsigned short *)g_screen_ptr + num*w;
|
||||
|
@ -204,7 +203,6 @@ static int EmuScanEnd16(unsigned int num)
|
|||
int sh = Pico.video.reg[0xC]&8;
|
||||
int len, mask = 0xff;
|
||||
|
||||
if (!(Pico.video.reg[1]&8)) num += 8;
|
||||
pd=(unsigned short *)g_screen_ptr + num*800*2 + 800/2 - 320*2/2;
|
||||
|
||||
if (Pico.m.dirtyPal)
|
||||
|
|
|
@ -261,8 +261,6 @@ static void EmuScanPrepare(void)
|
|||
|
||||
static int EmuScanSlowBegin(unsigned int num)
|
||||
{
|
||||
if (!(Pico.video.reg[1]&8)) num += 8;
|
||||
|
||||
if (!dynamic_palette)
|
||||
HighCol = (unsigned char *)VRAM_CACHED_STUFF + num * 512 + 8;
|
||||
|
||||
|
@ -271,8 +269,6 @@ static int EmuScanSlowBegin(unsigned int num)
|
|||
|
||||
static int EmuScanSlowEnd(unsigned int num)
|
||||
{
|
||||
if (!(Pico.video.reg[1]&8)) num += 8;
|
||||
|
||||
if (Pico.m.dirtyPal) {
|
||||
if (!dynamic_palette) {
|
||||
do_slowmode_lines(num);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue