X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FCart.c;h=f82c3252c7c866dd95396f1c8131e8a76fd0aa3c;hb=8e5427a06854695302a879dba5f0cbb3886e7253;hp=cf71f24f155daaf289918ab98cc63371099a71fb;hpb=71de3cd9bb3cad7630df5b1d2a0e56475995b025;p=picodrive.git diff --git a/Pico/Cart.c b/Pico/Cart.c index cf71f24..f82c325 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -250,7 +250,7 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream) if (block != cso->block_in_buff) { if (read_pos != cso->fpos_in) - { fseek(stream->file, read_pos, SEEK_SET); printf("seek %i\n", read_pos); } + fseek(stream->file, read_pos, SEEK_SET); rret = fread(cso->in_buff, 1, read_len, stream->file); cso->fpos_in = read_pos + rret; if (rret != read_len) { @@ -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,23 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize) Pico.rom=rom; Pico.romsize=romsize; + PicoMemResetHooks(); + PicoDmaHook = NULL; + PicoResetHook = NULL; + PicoLineHook = NULL; + + PicoMemReset(); + + if (!(PicoMCD & 1)) + PicoCartDetect(); + // setup correct memory map for loaded ROM + // call PicoMemReset again due to possible memmap change if (PicoMCD & 1) PicoMemSetupCD(); else PicoMemSetup(); PicoMemReset(); - if (!(PicoMCD & 1)) - PicoCartDetect(); - return PicoReset(1); } @@ -548,10 +554,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 +640,12 @@ 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 || + name_cmp("VIRTUA RACING") == 0) + { + PicoSVPInit(); + } }