build carthw.cfg in

things like libretro don't want external files,
but we still look for one and prefer it if it's available
This commit is contained in:
notaz 2013-06-28 03:01:53 +03:00
parent c25d78eec1
commit 005651ce13
3 changed files with 319 additions and 5 deletions

View file

@ -709,21 +709,45 @@ static int is_expr(const char *expr, char **pr)
return 1; return 1;
} }
#include "carthw_cfg.c"
static void parse_carthw(const char *carthw_cfg, int *fill_sram) static void parse_carthw(const char *carthw_cfg, int *fill_sram)
{ {
int line = 0, any_checks_passed = 0, skip_sect = 0; int line = 0, any_checks_passed = 0, skip_sect = 0;
const char *s, *builtin = builtin_carthw_cfg;
int tmp, rom_crc = 0; int tmp, rom_crc = 0;
char buff[256], *p, *r; char buff[256], *p, *r;
FILE *f; FILE *f;
f = fopen(carthw_cfg, "r"); 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!"); elprintf(EL_STATUS, "couldn't open carthw.cfg!");
return;
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;
} }
while ((p = fgets(buff, sizeof(buff), f)))
{
line++; line++;
p = sskip(p); p = sskip(p);
if (*p == 0 || *p == '#') if (*p == 0 || *p == '#')
@ -934,6 +958,8 @@ no_checks:
skip_sect = 1; skip_sect = 1;
continue; continue;
} }
if (f != NULL)
fclose(f); fclose(f);
} }
@ -999,3 +1025,4 @@ static void PicoCartDetect(const char *carthw_cfg)
*(int *) (Pico.rom + 0x1f0) = 0x20204520; *(int *) (Pico.rom + 0x1f0) = 0x20204520;
} }
// vim:shiftwidth=2:expandtab

225
pico/carthw_cfg.c Normal file
View file

@ -0,0 +1,225 @@
/* generated by ./tools/make_carthw_c, do not modify */
static const char builtin_carthw_cfg[] =
"[]\n"
"check_str=0x150,\"Virtua Racing\"\n"
"hw=svp\n"
"[]\n"
"check_str=0x150,\"VIRTUA RACING\"\n"
"hw=svp\n"
"[]\n"
"check_str=0x100,\"SEGA PICO\"\n"
"hw=pico\n"
"[]\n"
"check_str=0x100,\"IMA IKUNOUJYUKU\"\n"
"hw=pico\n"
"[]\n"
"check_str=0x120,\"PUGGSY\"\n"
"prop=no_sram\n"
"[]\n"
"check_str=0x150,\"DINO DINI'S SOCCER\"\n"
"prop=filled_sram\n"
"[]\n"
"check_str=0x150,\"MICRO MACHINES II\"\n"
"prop=filled_sram\n"
"[]\n"
"check_str=0x150,\"SUPER STREET FIGHTER2 The New Challengers\"\n"
"hw=ssf2_mapper\n"
"prop=no_sram\n"
"[]\n"
"check_str=0x150,\"PIER SOLAR™&THE GREAT ARCHITECTS© WaterMelon™\"\n"
"hw=piersolar_mapper\n"
"sram_range=0xa13009,0xa1300b\n"
"eeprom_type=3\n"
"eeprom_lines=2,1,0\n"
"[]\n"
"check_str=0x120,\"FLICKY\"\n"
"check_size_gt=0x020000\n"
"hw=x_in_1_mapper\n"
"[]\n"
"check_str=0x150,\"ROBOCOP 3\"\n"
"check_size_gt=0x080000\n"
"hw=x_in_1_mapper\n"
"[]\n"
"check_str=0x150,\"ALIEN 3\"\n"
"check_size_gt=0x080000\n"
"hw=x_in_1_mapper\n"
"[]\n"
"check_str=0x150,\" SHOVE IT!\"\n"
"check_size_gt=0x020000\n"
"hw=x_in_1_mapper\n"
"[]\n"
"check_str=0x150,\"MS PACMAN\"\n"
"check_size_gt=0x020000\n"
"hw=x_in_1_mapper\n"
"[]\n"
"check_str=0x150,\"KID CHAMELEON\"\n"
"check_size_gt=0x100000\n"
"hw=radica_mapper\n"
"[]\n"
"check_str=0x94,\"THE EARTH DEFEND\"\n"
"hw=realtec_mapper\n"
"[]\n"
"check_str=0xfe,\"WISEGAME 11-03-1993\"\n"
"hw=realtec_mapper\n"
"[]\n"
"check_str=0x95,\"MALLET LEGEND\"\n"
"hw=realtec_mapper\n"
"[]\n"
"check_str=0x150,\"COLLEGE SLAM\"\n"
"eeprom_type=3\n"
"eeprom_lines=8,0,0\n"
"[]\n"
"check_str=0x150,\"FRANK THOMAS BIGHURT BASEBAL\"\n"
"eeprom_type=3\n"
"eeprom_lines=8,0,0\n"
"[]\n"
"check_str=0x150,\"MICRO MACHINES II\"\n"
"sram_range=0x300000,0x380001\n"
"eeprom_type=2\n"
"eeprom_lines=9,8,7\n"
"[]\n"
"check_str=0x150,\" \"\n"
"check_csum=0x165e\n"
"sram_range=0x300000,0x380001\n"
"eeprom_type=2\n"
"eeprom_lines=9,8,7\n"
"[]\n"
"check_str=0x150,\" \"\n"
"check_csum=0x2c41\n"
"sram_range=0x300000,0x380001\n"
"eeprom_type=2\n"
"eeprom_lines=9,8,7\n"
"[]\n"
"check_str=0x150,\" \"\n"
"check_csum=0x168b\n"
"sram_range=0x300000,0x380001\n"
"eeprom_type=2\n"
"eeprom_lines=9,8,7\n"
"[]\n"
"check_str=0x150,\" \"\n"
"check_csum=0xcee0\n"
"sram_range=0x300000,0x380001\n"
"eeprom_type=2\n"
"eeprom_lines=9,8,7\n"
"[]\n"
"check_str=0x150,\"NBA JAM \"\n"
"eeprom_type=2\n"
"eeprom_lines=1,0,1\n"
"[]\n"
"check_str=0x150,\"NBA JAM TOURNAMENT EDITION\"\n"
"sram_range=0x200000,0x200001\n"
"eeprom_type=2\n"
"eeprom_lines=8,0,0\n"
"[]\n"
"check_str=0x150,\"NFL QUARTERBACK CLUB\"\n"
"eeprom_type=2\n"
"eeprom_lines=8,0,0\n"
"[]\n"
"check_str=0x150,\"NHLPA Hockey '93\"\n"
"sram_range=0x200000,0x200001\n"
"eeprom_type=1\n"
"eeprom_lines=6,7,7\n"
"[]\n"
"check_str=0x150,\"NHLPA HOCKEY '93\"\n"
"sram_range=0x200000,0x200001\n"
"eeprom_type=1\n"
"eeprom_lines=6,7,7\n"
"[]\n"
"check_str=0x150,\"RINGS OF POWER\"\n"
"sram_range=0x200000,0x200001\n"
"eeprom_type=1\n"
"eeprom_lines=6,7,7\n"
"[]\n"
"check_str=0x104,\" \"\n"
"check_crc32=0x10458e09\n"
"hw=prot\n"
"prot_ro_value16=0xa13000,0xffff00,0x28\n"
"[]\n"
"check_str=0x172,\"GAME : ELF WOR\"\n"
"hw=prot\n"
"prot_ro_value16=0x400000,-2,0x5500\n"
"prot_ro_value16=0x400002,-2,0xc900#checkisdoneiftheaboveonefails\n"
"prot_ro_value16=0x400004,-2,0x0f00\n"
"prot_ro_value16=0x400006,-2,0x1800#similartoabove\n"
"[]\n"
"check_str=0x104,\" \"\n"
"check_crc32=0xcbc38eea\n"
"hw=prot\n"
"prot_ro_value16=0x480000,0xff0000,0xaa00\n"
"prot_ro_value16=0x4a0000,0xff0000,0x0a00\n"
"prot_ro_value16=0x4c0000,0xff0000,0xf000\n"
"prot_ro_value16=0x400000,0xc00000,0x0000#defaultfor400000-7f0000\n"
"[]\n"
"check_str=0x104,\" are Registered Trademarks\"\n"
"check_crc32=0xc004219d\n"
"hw=prot_lk3\n"
"[]\n"
"check_str=0x104,\" are Registered Trademarks\"\n"
"check_crc32=0xaff46765\n"
"hw=prot\n"
"prot_rw_value16=0x400000,0xc00004,0\n"
"prot_rw_value16=0x400004,0xc00004,0\n"
"[]\n"
"check_str=0x118,\"CREATON. \"\n"
"check_crc32=0xddd02ba4\n"
"hw=prot\n"
"prot_ro_value16=0x400000,-2,0x9000\n"
"prot_ro_value16=0x401000,-2,0xd300\n"
"[]\n"
"check_str=0x104,\" \"\n"
"check_crc32=0xf68f6367\n"
"hw=prot\n"
"prot_ro_value16=0xa13002,-2,0x01\n"
"prot_ro_value16=0xa1303e,-2,0x1f\n"
"[]\n"
"check_str=0x104,\" \"\n"
"check_crc32=0xfb176667\n"
"hw=prot\n"
"prot_ro_value16=0xa13000,-2,0x14\n"
"prot_ro_value16=0xa13002,-2,0x01\n"
"prot_ro_value16=0xa1303e,-2,0x1f\n"
"[]\n"
"check_csum=0\n"
"check_crc32=0x3ee639f0\n"
"hw=prot\n"
"prot_ro_value16=0xa13000,-2,0x0c\n"
"[]\n"
"check_csum=0\n"
"check_crc32=0xdecdf740\n"
"hw=prot\n"
"prot_ro_value16=0x400000,-2,0x5500\n"
"prot_ro_value16=0x400002,-2,0x0f00\n"
"prot_ro_value16=0x400004,-2,0xaa00\n"
"prot_ro_value16=0x400006,-2,0xf000\n"
"[]\n"
"check_str=0x104,\" \"\n"
"check_crc32=0xf26f88d1\n"
"hw=prot\n"
"prot_ro_value16=0x400002,-2,0x9800\n"
"prot_ro_value16=0x400004,-2,0xaa00#or0xc900\n"
"prot_ro_value16=0x400006,-2,0xf000\n"
"[]\n"
"check_str=0x104,\" are Registered Trademarks\"\n"
"check_crc32=0x4820a161\n"
"hw=prot\n"
"prot_ro_value16=0x400000,-2,0x5500\n"
"prot_ro_value16=0x400002,-2,0x0f00\n"
"[]\n"
"check_str=0x104,\" are Registered Trademarks\"\n"
"check_crc32=0x413dfee2\n"
"hw=prot_lk3\n"
"[]\n"
"check_str=0x140,\"SUPER MARIO BROS \"\n"
"hw=prot\n"
"prot_ro_value16=0xa13000,-2,0x0c\n"
"[]\n"
"check_str=0x104,\" are Registered Trademarks\"\n"
"check_crc32=0xf7e1b3e1\n"
"hw=prot\n"
"prot_ro_value16=0xa13000,-2,0x0a\n"
"[]\n"
"check_str=0x104,\" are Registered Trademarks\"\n"
"check_crc32=0xb8261ff5\n"
"hw=prot\n"
"prot_rw_value16=0x400000,0xc00000,0\n"
;

62
tools/make_carthw_c.c Normal file
View file

@ -0,0 +1,62 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
FILE *fi, *fo;
char buf[256];
if (argc != 3) {
printf("usage:\n%s <carthw.cfg> <carthw.c>\n", argv[0]);
return 1;
}
fi = fopen(argv[1], "r");
fo = fopen(argv[2], "w");
if (fi == NULL || fo == NULL) {
printf("fopen failed\n");
return 1;
}
fprintf(fo, "/* generated by %s, do not modify */\n", argv[0]);
fprintf(fo, "static const char builtin_carthw_cfg[] =\n");
while ((fgets(buf, sizeof(buf), fi)))
{
char bufd[256];
char *d = bufd, *p = buf;
int quote = 0;
while (*p && isspace(*p))
p++;
if (*p == 0 || *p == '#')
continue;
/* section names not needed */
if (*p == '[')
strcpy(p, "[]");
for (; *p != 0; p++) {
if (!quote && isspace(*p))
continue;
if (*p == '"') {
quote = !quote;
*d++ = '\\';
}
*d++ = *p;
}
*d = 0;
fprintf(fo, " \"%s\\n\"\n", bufd);
}
fprintf(fo, ";\n");
fclose(fi);
fclose(fo);
return 0;
}