#!/usr/bin/perl # program to rewrite my data table as a parallel array rather than a C-like data structure (whoopsie!) # three arrays in here; 0 is foreground, 1 is background, and 2 is hole memory location (or 0 if not a wall) my @fg; my @bg; my @holes; my @wallmemory = ( \@fg, \@bg, \@holes ); $index = 0; $offset = 37; # realized this would be easier with software around row 37 ;) open(WALLDATA, 'walldata.txt'); while () { if ( ( $data, $comment ) = ( /\.byte \$([0-9A-Fa-f]{2})\s*(?:;\s*(.*))?$/ ) ) { #print "row ", int( $index / 3 + $offset ), ": putting $data ($comment) into array ", $index % 3, "!\n"; push( @{$wallmemory[ $index % 3 ]}, "\t.byte \$$data ; row " . sprintf( "%03d", int( $index / 3 + $offset ) ) . " $comment\r\n" ); $index++; } } # print the foreground color array print "\r\n\r\n; foreground colors for playfield\r\n"; print $_ foreach ( @fg ); # print the background color array print "\r\n\r\n; background colors for playfield\r\n"; print $_ foreach ( @bg ); # print the wall hole memory offset array print "\r\n\r\n; memory offsets for playfield holes in walls\r\n"; print $_ foreach ( @holes );