Skip to content

Commit

Permalink
dat: add sourcefile
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudreadmon committed Sep 10, 2023
1 parent 93317a4 commit 90d34af
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/burn/burn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

This comment has been minimized.

Copy link
@taoenwen

taoenwen Sep 10, 2023

Collaborator

@barbudreadmon This step seems to have no chance of being executed.

This comment has been minimized.

Copy link
@barbudreadmon

barbudreadmon Sep 10, 2023

Author Collaborator

The break ? Yes i know, that's something i forgot to cleanup, it doesn't hurt though, i'll probably remove it in some future commit.

}
}
return "";
}

// Save Aspect & Screensize in BurnDrvInit(), restore in BurnDrvExit()
// .. as games may need to change modes, etc.
static INT32 DrvAspectX, DrvAspectY;
Expand Down
1 change: 1 addition & 0 deletions src/burn/burn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
16 changes: 10 additions & 6 deletions src/burner/dat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -344,22 +346,22 @@ INT32 write_datfile(INT32 bType, FILE* fDat)
if (nParentSelect!=nGameSelect && nParentSelect!=-1U)
{
if (!strcmp(ssName, "") || !strcmp(ssName, sgName)) {
fprintf(fDat, "\t<game name=\"%s\" cloneof=\"%s\" romof=\"%s\">\n", sgName, spName, spName);
fprintf(fDat, "\t<game name=\"%s\" cloneof=\"%s\" romof=\"%s\" sourcefile=\"%s\">\n", sgName, spName, spName, sfName);
} else {
fprintf(fDat, "\t<game name=\"%s\" cloneof=\"%s\" romof=\"%s\" sampleof=\"%s\">\n", sgName, spName, spName, ssName);
fprintf(fDat, "\t<game name=\"%s\" cloneof=\"%s\" romof=\"%s\" sampleof=\"%s\" sourcefile=\"%s\">\n", sgName, spName, spName, ssName, sfName);
}
}
else
{
// Add "romof" (but not 'cloneof') line for games that have boardROMs
if (nBoardROMSelect!=nGameSelect && nBoardROMSelect!=-1U)
{
fprintf(fDat, "\t<game name=\"%s\" romof=\"%s\">\n", sgName, sbName);
fprintf(fDat, "\t<game name=\"%s\" romof=\"%s\" sourcefile=\"%s\">\n", sgName, sbName, sfName);
} else {
if (!strcmp(ssName, "") || !strcmp(ssName, sgName)) {
fprintf(fDat, "\t<game name=\"%s\">\n", sgName);
fprintf(fDat, "\t<game name=\"%s\" sourcefile=\"%s\">\n", sgName, sfName);
} else {
fprintf(fDat, "\t<game name=\"%s\" sampleof=\"%s\">\n", sgName, ssName);
fprintf(fDat, "\t<game name=\"%s\" sampleof=\"%s\" sourcefile=\"%s\">\n", sgName, ssName, sfName);
}
}
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand All @@ -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<game isbios=\"yes\" name=\"%s\">\n", sgName);
fprintf(fDat, "\t<game isbios=\"yes\" name=\"%s\" sourcefile=\"%s\">\n", sgName, sfName);
char szGameDecoration[255];
memset(szGameDecoration, 0, 255);
strcpy(szGameDecoration, GameDecoration(nBurnDrvActive));
Expand Down
27 changes: 26 additions & 1 deletion src/dep/scripts/gamelist.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/perl -w

use strict;
use File::Basename;

my $Outfile;
my $Listfile;
Expand Down Expand Up @@ -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}} ) {
Expand Down Expand Up @@ -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 ) {
Expand Down

1 comment on commit 90d34af

@dinkc64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barbudreadmon thanks for thinking outside-the-box :)

Please sign in to comment.