diff --git a/src/burn/burn.cpp b/src/burn/burn.cpp index 5c32e9296d..e46cdd05ce 100644 --- a/src/burn/burn.cpp +++ b/src/burn/burn.cpp @@ -723,6 +723,19 @@ extern "C" INT32 BurnDrvGetFamilyFlags() return pDriver[nBurnDrvActive]->Family; } +// Return sourcefile +extern "C" char* BurnDrvGetSourcefile() +{ + char* szShortName = pDriver[nBurnDrvActive]->szShortName; + for (INT32 i = 0; sourcefile_table[i].game_name[0] != '\0'; i++) { + if (!strcmp(sourcefile_table[i].game_name, szShortName)) { + return sourcefile_table[i].sourcefile; + break; + } + } + return ""; +} + // Save Aspect & Screensize in BurnDrvInit(), restore in BurnDrvExit() // .. as games may need to change modes, etc. static INT32 DrvAspectX, DrvAspectY; diff --git a/src/burn/burn.h b/src/burn/burn.h index a720f82a49..7deffd2856 100644 --- a/src/burn/burn.h +++ b/src/burn/burn.h @@ -433,6 +433,7 @@ INT32 BurnDrvGetSampleInfo(struct BurnSampleInfo *pri, UINT32 i); INT32 BurnDrvGetSampleName(char** pszName, UINT32 i, INT32 nAka); INT32 BurnDrvGetHDDInfo(struct BurnHDDInfo *pri, UINT32 i); INT32 BurnDrvGetHDDName(char** pszName, UINT32 i, INT32 nAka); +char* BurnDrvGetSourcefile(); void Reinitialise(); diff --git a/src/burner/dat.cpp b/src/burner/dat.cpp index dc0fbe1b03..ea6548b4ed 100644 --- a/src/burner/dat.cpp +++ b/src/burner/dat.cpp @@ -159,6 +159,7 @@ INT32 write_datfile(INT32 bType, FILE* fDat) char spbName[32]; char sbName[32]; char ssName[32]; + char sfName[32]; UINT32 i, j=0; INT32 nPass=0; @@ -247,6 +248,7 @@ INT32 write_datfile(INT32 bType, FILE* fDat) } strcpy(sgName, BurnDrvGetTextA(DRV_NAME)); + strcpy(sfName, BurnDrvGetSourcefile()); strcpy(spName, ""); // make sure this string is empty before we start strcpy(sbName, ""); // make sure this string is empty before we start strcpy(ssName, ""); // make sure this string is empty before we start @@ -344,9 +346,9 @@ INT32 write_datfile(INT32 bType, FILE* fDat) if (nParentSelect!=nGameSelect && nParentSelect!=-1U) { if (!strcmp(ssName, "") || !strcmp(ssName, sgName)) { - fprintf(fDat, "\t\n", sgName, spName, spName); + fprintf(fDat, "\t\n", sgName, spName, spName, sfName); } else { - fprintf(fDat, "\t\n", sgName, spName, spName, ssName); + fprintf(fDat, "\t\n", sgName, spName, spName, ssName, sfName); } } else @@ -354,12 +356,12 @@ INT32 write_datfile(INT32 bType, FILE* fDat) // Add "romof" (but not 'cloneof') line for games that have boardROMs if (nBoardROMSelect!=nGameSelect && nBoardROMSelect!=-1U) { - fprintf(fDat, "\t\n", sgName, sbName); + fprintf(fDat, "\t\n", sgName, sbName, sfName); } else { if (!strcmp(ssName, "") || !strcmp(ssName, sgName)) { - fprintf(fDat, "\t\n", sgName); + fprintf(fDat, "\t\n", sgName, sfName); } else { - fprintf(fDat, "\t\n", sgName, ssName); + fprintf(fDat, "\t\n", sgName, ssName, sfName); } } } @@ -612,6 +614,7 @@ INT32 write_datfile(INT32 bType, FILE* fDat) char sgName[32]; char spName[32]; char sbName[32]; + char sfName[32]; INT32 i, nPass; if (!(BurnDrvGetFlags() & BDF_BOARDROM)) { @@ -697,6 +700,7 @@ INT32 write_datfile(INT32 bType, FILE* fDat) } strcpy(sgName, BurnDrvGetTextA(DRV_NAME)); + strcpy(sfName, BurnDrvGetSourcefile()); #ifdef DAT_DEBUG bprintf(PRINT_IMPORTANT, _T("DAT(BOARDROMS): Processing %S.\n"), sgName); @@ -717,7 +721,7 @@ INT32 write_datfile(INT32 bType, FILE* fDat) remove_driver_leader(HARDWARE_SNK_NGP, 4, 0) remove_driver_leader(HARDWARE_CHANNELF, 4, 0) - fprintf(fDat, "\t\n", sgName); + fprintf(fDat, "\t\n", sgName, sfName); char szGameDecoration[255]; memset(szGameDecoration, 0, 255); strcpy(szGameDecoration, GameDecoration(nBurnDrvActive)); diff --git a/src/dep/scripts/gamelist.pl b/src/dep/scripts/gamelist.pl index e49aae92f0..7a27bfa08d 100755 --- a/src/dep/scripts/gamelist.pl +++ b/src/dep/scripts/gamelist.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl -w use strict; +use File::Basename; my $Outfile; my $Listfile; @@ -146,7 +147,7 @@ } else { $Drivers{$name}[8] = ""; } - $Drivers{$name}[9] = "$filename"; # Filename + $Drivers{$name}[9] = basename($filename); # Filename # Convert NULL/null/0 to empty string or remove quotes foreach $line ( @{$Drivers{$name}} ) { @@ -318,6 +319,30 @@ print OUTFILE "};\n"; +print OUTFILE << "CPPEND"; + +// Lookup table containing sourcefiles of all drivers +struct game_sourcefile_entry { + char game_name[32]; + char sourcefile[32]; +}; + +static game_sourcefile_entry sourcefile_table[] = { +CPPEND + + +foreach my $name ( @Driverlist ) { + if ( $Drivers{$name}[1] ne "" ) { + print OUTFILE " { \"$Drivers{$name}[1]\", \"$Drivers{$name}[9]\"},\n"; + } +} + +print OUTFILE << "CPPEND"; + { "\\0", "\\0"} +}; +CPPEND + + close( OUTFILE ); if ( $Listfile ) {