#!/usr/bin/perl # Sept 6, 2004 - program to OR all the yellow bear bits to the white bear image, so that it doesn't flicker as much # one array for each bear image my @yellow; my @white; my @bearbits = ( \@yellow, \@white ); $section = 0; $offset = 0; # the scanline the data represent $scanline = $offset; open(BEAR, 'bear.txt'); while () { if ( ( $left, $data, $comment ) = ( /^([A-Za-z]*|)\s*\.byte\s*\%([01]{8})\s*(?:;\s*(.*))?$/ ) ) { if ( $left eq 'BearWhiteA' ) { $section = 0; $scanline = $offset; } elsif ( $left eq 'BearYellowA' ) { $section = 1; $scanline = $offset; } $data = uc( $data ); if ( $section == 0 ) # yellow copy { push( @{$bearbits[ $section ]}, $data ); } elsif ( $section == 1 ) # white copy - merge yellow's 1s into our 0s { push( @{$bearbits[ $section ]}, "$left\t.byte\t\%" . merge($bearbits[ 0 ][$scanline], $data) . ( $comment ? '; ' : '' ) . "$comment\r\n" ); } $scanline++; } elsif ( $section == 1 ) { push( @{$bearbits[ 1 ]}, $_ ); } } print $_ foreach ( @white ); #print "\nmerge('11110000','00000111') = ", merge('11110000','00000111'), "\n"; #print "\nmerge('10000000','00000001') = ", merge('10000000','00000001'), "\n"; #print "\nmerge('00000000','00000000') = ", merge('00000000','00000000'), "\n"; #print "\nmerge('11111111','00000111') = ", merge('11111111','00000111'), "\n"; #print "\nmerge('00000111','11111111') = ", merge('00000111','11111111'), "\n"; #print "\nmerge('00000001','00000000') = ", merge('00000001','00000000'), "\n"; sub merge() { my $source=shift; my $target=shift; $source = pack( "b8", $source ); print "[source: $source]"; $target = pack( "b8", $target ); print "[target: $target]"; return( unpack( "b8", $source | $target ) ); }