1 # ======================================================================
3 # Copyright 2003, Sony Online Entertainment
5 # ======================================================================
10 # ======================================================================
11 # Setup variables that can be imported by Exporter into user modules.
12 # ======================================================================
14 use vars
qw(@ISA @EXPORT_OK $VERSION);
19 # These symbols are okay to export if specifically requested.
20 @EXPORT_OK = qw(&getEntryCount);
22 # ======================================================================
26 # ======================================================================
30 # Get the full pathname for the palette.
31 my $fullPathName = shift;
32 die "Invalid fullPathName arg" unless defined($fullPathName);
36 open($inputFile, '< ' . $fullPathName) or die "Failed to open palette file [$fullPathName] for reading: $!";
37 binmode($inputFile) or die "Failed to set file [$fullPathName] to binary mode: $!";
39 # Skip the first 22 bytes.
40 seek($inputFile, 22, 0) or die "Failed to seek to palette entry count position within [$fullPathName], bad palette file: $!";
42 # Collect the entry count (2 bytes starting 22 bytes in).
45 read($inputFile, $byteAsChar, 1) or die "Failed to read entry count byte from [$fullPathName]: $!";
46 my $entryCount = ord($byteAsChar);
48 read($inputFile, $byteAsChar, 1) or die "Failed to read entry count byte from [$fullPathName]: $!";
49 $entryCount += (ord($byteAsChar) << 8);
52 close($inputFile) or die "Failed to close palette file [$fullPathName]: $!";
54 printf("palette entries: %5d; name=[%s]\n", $entryCount, $fullPathName) if $debug;
59 # ======================================================================