This repository was archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathpsikyo_tile_func.pl
More file actions
executable file
·95 lines (69 loc) · 2.4 KB
/
Copy pathpsikyo_tile_func.pl
File metadata and controls
executable file
·95 lines (69 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/perl -w
use strict;
my $OutfileFun;
my $OutfileTab;
# Process command line arguments
if ( $ARGV[0] =~ /^-o/i ) {
if ( $ARGV[0] =~ /^-o$/i ) {
$OutfileFun = $ARGV[1];
} else {
$ARGV[0] =~ /(?<=-o)(.*)/i;
$OutfileFun = $1;
}
}
unless ( $OutfileFun ) {
die "Usage: $0 -o <output file>\n\n";
}
$OutfileTab = $OutfileFun;
$OutfileTab =~ s/(\.\w+)/_table$1/;
open( OUTFILEFUN, ">$OutfileFun" ) or die "\nError: Couldn't open OUTPUT file $OutfileFun: $!";
open( OUTFILETAB, ">$OutfileTab" ) or die "\nError: Couldn't open OUTPUT file $OutfileTab: $!";
print "Generating $OutfileFun & $OutfileTab...\n";
# Generate optimized functions and a table with the function names
my @TransFun = ( 0, 15, -1 );
my @TransTab = ( "_TRANS0", "_TRANS15", "_SOLID" );
my $RowScroll;
my $Clip;
print OUTFILEFUN "#define ROT 0\n";
print OUTFILEFUN "#define BPP 16\n";
print OUTFILEFUN "#define FLIP 0\n";
print OUTFILEFUN "#define ZOOM 0\n";
print OUTFILEFUN "#define ZBUFFER 0\n";
print OUTFILEFUN "\n";
print OUTFILETAB "// Table with all function addresses.\n";
print OUTFILETAB "static RenderTileFunction RenderTile[] = {\n";
for ( my $Function = 0; $Function < 6; $Function++ ) {
my $FunctionName = "&RenderTile16" . $TransTab[($Function & 6) / 2] . "_NOFLIP_ROT0";
if ( ($Function & 1) == 0 ) {
$RowScroll = "_NOROWSCROLL";
print OUTFILEFUN "#define TRANS " . $TransFun[($Function & 6) / 2] . "\n\n";
} else {
$RowScroll = "_ROWSCROLL";
}
print OUTFILEFUN "#define ROWSCROLL " . (($Function & 1) / 1) . "\n";
print OUTFILETAB "\t";
print OUTFILEFUN "#define DOCLIP 0\n";
print OUTFILEFUN "#include \"psikyo_render.h\"\n";
print OUTFILEFUN "#undef DOCLIP\n";
print OUTFILETAB $FunctionName . $RowScroll . "_NOZOOM_NOZBUFFER_NOCLIP, ";
print OUTFILEFUN "#define DOCLIP 1\n";
print OUTFILEFUN "#include \"psikyo_render.h\"\n";
print OUTFILEFUN "#undef DOCLIP\n";
print OUTFILETAB $FunctionName . $RowScroll . "_NOZOOM_NOZBUFFER_CLIP, ";
print OUTFILEFUN "#undef ROWSCROLL\n";
if ( ($Function & 1) == 1 ) {
print OUTFILEFUN "\n#undef TRANS\n";
}
print OUTFILETAB "\n";
}
print OUTFILEFUN "#undef ZBUFFER\n";
print OUTFILEFUN "#undef ZOOM\n";
print OUTFILEFUN "#undef FLIP\n";
print OUTFILEFUN "#undef BPP\n";
print OUTFILEFUN "#undef ROT\n";
print OUTFILEFUN "\n";
print OUTFILETAB "};\n\n";
$OutfileTab =~ /(?:.*[\\\/])(.*)/;
print OUTFILEFUN "#include \"$1\"\n";
close( OUTFILETAB );
close( OUTFILEFUN );