X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fcart.c;h=a5c563d63db55163a956a590eb92b4610dda4024;hb=274fcc35aa20e9777a8e09630a94088757384329;hp=d86af41eaec738c4320e3736c1675a12a96738dc;hpb=4c2e35547fd6f849648234989419a4a02d2546b4;p=picodrive.git diff --git a/pico/cart.c b/pico/cart.c index d86af41..a5c563d 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -157,7 +157,7 @@ zip_failed: if (f == NULL) goto cso_failed; -#ifndef __EPOC32__ +#ifdef __GP2X__ /* we use our own buffering */ setvbuf(f, NULL, _IONBF, 0); #endif @@ -227,7 +227,7 @@ cso_failed: strncpy(file->ext, ext, sizeof(file->ext) - 1); fseek(f, 0, SEEK_SET); -#ifndef __EPOC32__ // makes things worse on Symbian +#ifdef __GP2X__ if (file->size > 0x400000) /* we use our own buffering */ setvbuf(f, NULL, _IONBF, 0); @@ -643,6 +643,8 @@ static int rom_strcmp(int rom_offset, const char *s1) { int i, len = strlen(s1); const char *s_rom = (const char *)Pico.rom; + if (rom_offset + len > Pico.romsize) + return 0; for (i = 0; i < len; i++) if (s1[i] != s_rom[(i + rom_offset) ^ 1]) return 1; @@ -709,21 +711,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 == '#') @@ -873,10 +899,13 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram) SRam.flags &= ~SRF_EEPROM; else if (strcmp(p, "filled_sram") == 0) *fill_sram = 1; + else if (strcmp(p, "force_6btn") == 0) + PicoQuirks |= PQUIRK_FORCE_6BTN; else { elprintf(EL_STATUS, "carthw:%d: unsupported prop: %s", line, p); goto bad_nomsg; } + elprintf(EL_STATUS, "game prop: %s", p); continue; } else if (is_expr("eeprom_type", &p)) { @@ -934,7 +963,9 @@ no_checks: skip_sect = 1; continue; } - fclose(f); + + if (f != NULL) + fclose(f); } /* @@ -999,3 +1030,4 @@ static void PicoCartDetect(const char *carthw_cfg) *(int *) (Pico.rom + 0x1f0) = 0x20204520; } +// vim:shiftwidth=2:expandtab