X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fcart.c;h=d86af41eaec738c4320e3736c1675a12a96738dc;hb=4c2e35547fd6f849648234989419a4a02d2546b4;hp=42d081721160c267921691193e7a532c6bbd23cc;hpb=a2b8c5a54568093b247ced39f0754cbb30324830;p=picodrive.git diff --git a/pico/cart.c b/pico/cart.c index 42d0817..d86af41 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -1,11 +1,11 @@ -// This is part of Pico Library - -// (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. - +/* + * PicoDrive + * (c) Copyright Dave, 2004 + * (C) notaz, 2006-2010 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include "pico_int.h" #include "../zlib/zlib.h" @@ -23,6 +23,8 @@ void (*PicoCartMemSetup)(void); void (*PicoCartLoadProgressCB)(int percent) = NULL; void (*PicoCDLoadProgressCB)(const char *fname, int percent) = NULL; // handled in Pico/cd/cd_file.c +int PicoGameLoaded; + static void PicoCartDetect(const char *carthw_cfg); /* cso struct */ @@ -439,6 +441,9 @@ static unsigned char *PicoCartAlloc(int filesize, int is_sms) if (filesize > (1 << s)) s++; rom_alloc_size = 1 << s; + // be sure we can cover all address space + if (rom_alloc_size < 0x10000) + rom_alloc_size = 0x10000; } else { // make alloc size at least sizeof(mcd_state), @@ -455,7 +460,7 @@ static unsigned char *PicoCartAlloc(int filesize, int is_sms) // Allocate space for the rom plus padding // use special address for 32x dynarec - rom = plat_mmap(0x02000000, rom_alloc_size); + rom = plat_mmap(0x02000000, rom_alloc_size, 0, 0); return rom; } @@ -589,6 +594,18 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_ else PicoPower(); + PicoGameLoaded = 1; + return 0; +} + +int PicoCartResize(int newsize) +{ + void *tmp = plat_mremap(Pico.rom, rom_alloc_size, newsize); + if (tmp == NULL) + return -1; + + Pico.rom = tmp; + rom_alloc_size = newsize; return 0; } @@ -607,6 +624,7 @@ void PicoCartUnload(void) plat_munmap(Pico.rom, rom_alloc_size); Pico.rom = NULL; } + PicoGameLoaded = 0; } static unsigned int rom_crc32(void) @@ -809,6 +827,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram) carthw_realtec_startup(); else if (strcmp(p, "radica_mapper") == 0) carthw_radica_startup(); + else if (strcmp(p, "piersolar_mapper") == 0) + carthw_pier_startup(); else if (strcmp(p, "prot_lk3") == 0) carthw_prot_lk3_startup(); else {