gamelist.pl - output a list sorted by zip name with the index to the BurnDriver reference (this may well get reverted)

This commit is contained in:
Barry Harris 2018-05-09 15:20:59 +00:00
parent bd7ea839ab
commit da814a760f
4 changed files with 58 additions and 5 deletions

View File

@ -370,7 +370,7 @@ burn.o burn.d: driverlist.h
$(driverlist.h): $(drvsrc) $(srcdir)dep/scripts/gamelist.pl
ifdef PERL
@$(srcdir)dep/scripts/gamelist.pl -o $@ -l gamelist.txt \
@$(srcdir)dep/scripts/gamelist.pl -o $@ -z $(srcdir)dep/generated/driverlist_zip_sorted.h -l gamelist.txt \
$(filter %.cpp,$(foreach file,$(drvsrc:.o=.cpp),$(foreach dir,$(alldir), \
$(firstword $(wildcard $(srcdir)$(dir)/$(file))))))
else

View File

@ -501,7 +501,7 @@ burn.o burn.d: driverlist.h
$(driverlist.h): $(drvsrc) $(srcdir)dep/scripts/gamelist.pl
ifdef PERL
@$(srcdir)dep/scripts/gamelist.pl -o $@ -l gamelist.txt \
@$(srcdir)dep/scripts/gamelist.pl -o $@ -z $(srcdir)dep/generated/driverlist_zip_sorted.h -l gamelist.txt \
$(filter %.cpp,$(foreach file,$(drvsrc:.o=.cpp),$(foreach dir,$(alldir), \
$(firstword $(wildcard $(srcdir)$(dir)/$(file))))))
else

View File

@ -356,7 +356,7 @@ burn.o burn.d: driverlist.h
$(driverlist.h): $(drvsrc) $(srcdir)dep/scripts/gamelist.pl
ifdef PERL
@$(srcdir)dep/scripts/gamelist.pl -o $@ -l gamelist.txt \
@$(srcdir)dep/scripts/gamelist.pl -o $@ -z $(srcdir)dep/generated/driverlist_zip_sorted.h -l gamelist.txt \
$(filter %.cpp,$(foreach file,$(drvsrc:.o=.cpp),$(foreach dir,$(alldir), \
$(firstword $(wildcard $(srcdir)$(dir)/$(file))))))
else

View File

@ -3,11 +3,13 @@
use strict;
my $Outfile;
my $ZipOutFile;
my $Listfile;
my @Filelist;
my %Drivers;
my @Driverlist;
my @ZipDriverList;
# Process command line arguments
for ( my $i = 0; $i < scalar @ARGV; $i++ ) {{
@ -25,6 +27,20 @@ for ( my $i = 0; $i < scalar @ARGV; $i++ ) {{
}
next;
}
# Zip Output file
if ( $ARGV[$i] =~ /^-z/i ) {
if ( $ARGV[$i] =~ /^-z$/i ) {
$i++;
if ( $i < scalar @ARGV ) {
$ZipOutFile = $ARGV[$i];
}
} else {
$ARGV[$i] =~ /(?<=-z)(.*)/i;
$ZipOutFile = $1;
}
next;
}
# gamelist.txt
if ( $ARGV[$i] =~ /^-l/i ) {
@ -57,14 +73,17 @@ for ( my $i = 0; $i < scalar @ARGV; $i++ ) {{
}
}}
unless ( $Outfile and scalar @Filelist ) {
die "Usage: $0 -o <output file> [-l <gamelist>] <input file|dir> [<input file|dir>...]\n\n";
unless ( $Outfile and $ZipOutFile and scalar @Filelist ) {
die "Usage: $0 -o <output file> -z <zip name output file> [-l <gamelist>] <input file|dir> [<input file|dir>...]\n\n";
}
open( OUTFILE, ">$Outfile" ) or die "\nError: Couldn't open OUTPUT file $Outfile $!";
open( ZIPOUTFILE, ">$ZipOutFile" ) or die "\nError: Couldn't open ZIP SORT OUTPUT file $ZipOutFile $!";
print "Generating gamelist in $Outfile...\n";
my $burn_pos = 0;
# Build a list of all drivers
foreach my $filename ( @Filelist ) {
open( INFILE, $filename ) or die "\nError: Couldn't read $filename $!";
@ -181,6 +200,9 @@ foreach my $filename ( @Filelist ) {
if ( $struct =~ /BDF_PROTOTYPE/ || $struct =~ /BDF_BOOTLEG/ || $Drivers{$name}[3] ne "" ) {
$Drivers{$name}[10] = "$Drivers{$name}[10]" . "]";
}
$Drivers{$name}[11] = $burn_pos;
$burn_pos++;
}
}
close( INFILE );
@ -191,6 +213,11 @@ foreach my $filename ( @Filelist ) {
lc( $Drivers{$a}[10] ) cmp lc( $Drivers{$b}[10] );
} keys %Drivers;
# Sort the list of drivers using the zip name as the key
@ZipDriverList = sort {
lc( $Drivers{$a}[1] ) cmp lc( $Drivers{$b}[1] );
} keys %Drivers;
# first define needed constants and include needed files
print OUTFILE << "CPPEND";
// This file was generated by $0 (perl $])
@ -439,3 +466,29 @@ if ( $Listfile ) {
close( OUTFILE );
}
if ( $ZipOutFile ) {
print "Generating zip sorted gamelist in $ZipOutFile...\n";
print ZIPOUTFILE << "CPPEND";
// This file was generated by $0 (perl $])
struct ZipSortList {
\tconst char *DriverName;
\tunsigned int nBurnDrvID;
};
static const struct ZipSortList ZipSortListTable[] =
CPPEND
foreach my $name ( @ZipDriverList ) {
print ZIPOUTFILE "\t{ \"$Drivers{$name}[1]\", $Drivers{$name}[11]" . " }," . "\x0a";
}
print ZIPOUTFILE << "CPPEND";
\t{ 0, 0 }
};
CPPEND
close( ZIPOUTFILE );
}