X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=Pico%2FCart.c;h=7c3f36d49e52d4d6c53403744287b8405b898fae;hb=f8ef8ff7100baa0ac0ecfcacb47aea3a9e24bc38;hp=6f97a4231f85b9f053396277a47312e903b2414c;hpb=ff6b7429bb03e37e2d44eabcd0d86bd5713d2fc1;p=picodrive.git diff --git a/Pico/Cart.c b/Pico/Cart.c index 6f97a42..7c3f36d 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -400,7 +400,6 @@ static int DecodeSmd(unsigned char *data,int len) static unsigned char *cd_realloc(void *old, int filesize) { unsigned char *rom; - dprintf("sizeof(mcd_state): %i", sizeof(mcd_state)); rom=realloc(old, sizeof(mcd_state)); if (rom) memset(rom+0x20000, 0, sizeof(mcd_state)-0x20000); return rom; @@ -418,7 +417,6 @@ static unsigned char *PicoCartAlloc(int filesize) alloc_size&=~0x7ffff; // use alloc size of multiples of 512K, so that memhandlers could be set up more efficiently if((filesize&0x3fff)==0x200) alloc_size+=0x200; else if(alloc_size-filesize < 4) alloc_size+=4; // padding for out-of-bound exec protection - //dprintf("alloc_size: %x\n", alloc_size); // Allocate space for the rom plus padding rom=(unsigned char *)malloc(alloc_size); @@ -483,7 +481,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize) return 0; } -// Insert/remove a cartridge: +// Insert a cartridge: int PicoCartInsert(unsigned char *rom,unsigned int romsize) { // notaz: add a 68k "jump one op back" opcode to the end of ROM. @@ -495,15 +493,19 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize) Pico.rom=rom; Pico.romsize=romsize; + PicoMemResetHooks(); + PicoDmaHook = NULL; + PicoResetHook = NULL; + + if (!(PicoMCD & 1)) + PicoCartDetect(); + // setup correct memory map for loaded ROM if (PicoMCD & 1) PicoMemSetupCD(); else PicoMemSetup(); PicoMemReset(); - if (!(PicoMCD & 1)) - PicoCartDetect(); - return PicoReset(1); } @@ -548,10 +550,12 @@ void PicoCartDetect(void) Pico.m.sram_reg |= 4; } else { // normal SRAM - SRam.start = PicoRead32(0x1B4) & 0xFFFF00; + SRam.start = PicoRead32(0x1B4) & ~0xff; SRam.end = PicoRead32(0x1B8) | 1; sram_size = SRam.end - SRam.start + 1; } + SRam.start &= ~0xff000000; + SRam.end &= ~0xff000000; Pico.m.sram_reg |= 0x10; // SRAM was detected } if (sram_size <= 0) @@ -632,5 +636,11 @@ void PicoCartDetect(void) // Unusual region 'code' if (rom_strcmp(0x1f0, "EUROPE") == 0) *(int *) (Pico.rom+0x1f0) = 0x20204520; + + // SVP detection + if (name_cmp("Virtua Racing") == 0) + { + PicoSVPInit(); + } }