added 12-in-1 mapper to carthw

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@369 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-03-05 18:50:28 +00:00
parent 48df6e9e54
commit 757f8dae1a
7 changed files with 87 additions and 22 deletions

View file

@ -640,20 +640,29 @@ void PicoCartDetect(void)
SRam.eeprom_bit_out= 7;
}
// SVP detection
else if (name_cmp("Virtua Racing") == 0 ||
name_cmp("VIRTUA RACING") == 0)
{
PicoSVPStartup();
}
// Detect 4-in-1 and 12-in-1
else if ((name_cmp("ROBOCOP 3") && Pico.romsize == 0x200000) ||
(rom_strcmp(0x160, "FLICKY") && Pico.romsize == 0x200000))
{
carthw_12in1_startup();
}
// Some games malfunction if SRAM is not filled with 0xff
if (name_cmp("DINO DINI'S SOCCER") == 0 ||
name_cmp("MICRO MACHINES II") == 0)
{
memset(SRam.data, 0xff, sram_size);
}
// Unusual region 'code'
if (rom_strcmp(0x1f0, "EUROPE") == 0)
*(int *) (Pico.rom+0x1f0) = 0x20204520;
// SVP detection
if (name_cmp("Virtua Racing") == 0 ||
name_cmp("VIRTUA RACING") == 0)
{
PicoSVPStartup();
}
}

View file

@ -303,19 +303,8 @@ static void OtherWrite8End(u32 a,u32 d,int realsize)
#endif
elprintf(EL_UIO, "strange w%i: %06x, %08x @%06x", realsize, a&0xffffff, d, SekPc);
if(a >= 0xA13004 && a < 0xA13040) {
// dumb 12-in-1 or 4-in-1 banking support
int len;
a &= 0x3f; a <<= 16;
len = Pico.romsize - a;
if (len <= 0) return; // invalid/missing bank
if (len > 0x200000) len = 0x200000; // 2 megs
memcpy(Pico.rom, Pico.rom+a, len); // code which does this is in RAM so this is safe.
return;
}
// for games with simple protection devices, discovered by Haze
else if ((a>>22) == 1)
if ((a>>22) == 1)
Pico.m.prot_bytes[(a>>2)&1] = (u8)d;
}

52
Pico/carthw/carthw.c Normal file
View file

@ -0,0 +1,52 @@
#include "../PicoInt.h"
/* 12-in-1 */
static unsigned int carthw_12in1_read16(unsigned int a, int realsize)
{
// ??
elprintf(EL_UIO, "12-in-1: read [%06x] @ %06x", a, SekPc);
return 0;
}
static void carthw_12in1_write8(unsigned int a, unsigned int d, int realsize)
{
int len;
if (a < 0xA13000 || a >= 0xA13040) {
elprintf(EL_ANOMALY, "12-in-1: unexpected write [%06x] %02x @ %06x", a, d, SekPc);
}
a &= 0x3f; a <<= 16;
len = Pico.romsize - a;
if (len <= 0) {
elprintf(EL_ANOMALY, "12-in-1: missing bank @ %06x", a);
return;
}
memcpy(Pico.rom, Pico.rom + 0x200000 + a, len);
}
static void carthw_12in1_reset(void)
{
carthw_12in1_write8(0xA13000, 0, 0);
}
void carthw_12in1_startup(void)
{
void *tmp;
elprintf(EL_STATUS, "12-in-1 mapper detected");
tmp = realloc(Pico.rom, 0x200000 + 0x200000);
if (tmp == NULL)
{
elprintf(EL_STATUS, "OOM");
return;
}
memcpy(Pico.rom + 0x200000, Pico.rom, 0x200000);
PicoRead16Hook = carthw_12in1_read16;
PicoWrite8Hook = carthw_12in1_write8;
PicoResetHook = carthw_12in1_reset;
}

View file

@ -17,3 +17,6 @@ unsigned int PicoSVPRead16(unsigned int a, int realsize);
void PicoSVPWrite8 (unsigned int a, unsigned int d, int realsize);
void PicoSVPWrite16(unsigned int a, unsigned int d, int realsize);
/* 12-in-1 */
void carthw_12in1_startup(void);