X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fcart.c;h=db742a8b684f2c175912a209a6610d6ae80f9c4d;hb=7fd5d17b31f3ccdbc3eaf7e9761ddb41fa994863;hp=debb8a2c048142a63b8ae3468806b3def92f3a02;hpb=30f0fdd42279a99893034a5d21b64439536c60aa;p=picodrive.git diff --git a/pico/cart.c b/pico/cart.c index debb8a2..db742a8 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -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 */ @@ -592,6 +594,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_ else PicoPower(); + PicoGameLoaded = 1; return 0; } @@ -621,6 +624,7 @@ void PicoCartUnload(void) plat_munmap(Pico.rom, rom_alloc_size); Pico.rom = NULL; } + PicoGameLoaded = 0; } static unsigned int rom_crc32(void) @@ -705,21 +709,45 @@ static int is_expr(const char *expr, char **pr) return 1; } +#include "carthw_cfg.c" + static void parse_carthw(const char *carthw_cfg, int *fill_sram) { int line = 0, any_checks_passed = 0, skip_sect = 0; + const char *s, *builtin = builtin_carthw_cfg; int tmp, rom_crc = 0; char buff[256], *p, *r; FILE *f; f = fopen(carthw_cfg, "r"); - if (f == NULL) { + if (f == NULL) + f = fopen("pico/carthw.cfg", "r"); + if (f == NULL) elprintf(EL_STATUS, "couldn't open carthw.cfg!"); - return; - } - while ((p = fgets(buff, sizeof(buff), f))) + for (;;) { + if (f != NULL) { + p = fgets(buff, sizeof(buff), f); + if (p == NULL) + break; + } + else { + if (*builtin == 0) + break; + for (s = builtin; *s != 0 && *s != '\n'; s++) + ; + while (*s == '\n') + s++; + tmp = s - builtin; + if (tmp > sizeof(buff) - 1) + tmp = sizeof(buff) - 1; + memcpy(buff, builtin, tmp); + buff[tmp] = 0; + p = buff; + builtin = s; + } + line++; p = sskip(p); if (*p == 0 || *p == '#') @@ -930,7 +958,9 @@ no_checks: skip_sect = 1; continue; } - fclose(f); + + if (f != NULL) + fclose(f); } /* @@ -995,3 +1025,4 @@ static void PicoCartDetect(const char *carthw_cfg) *(int *) (Pico.rom + 0x1f0) = 0x20204520; } +// vim:shiftwidth=2:expandtab