From b9b83ceb0661cb4884d4b83cc9d4a2a95f604e1c Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 22 Oct 2004 12:02:35 +0000 Subject: [PATCH] trying colour flipping; is broken atm --- layout/Makefile | 1 + layout/layout | 1 + layout/segcmapassign | 25 +++++++++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/layout/Makefile b/layout/Makefile index 3651f08..bfe1bd9 100644 --- a/layout/Makefile +++ b/layout/Makefile @@ -66,3 +66,4 @@ clean: -rm -f *.oprint-*.ps .PRECIOUS: $(OPRINTS) +.PRECIOUS: ours-g%.segcmap ours-g%.segcmapreq diff --git a/layout/layout b/layout/layout index 7d58e27..8249624 100755 --- a/layout/layout +++ b/layout/layout @@ -665,6 +665,7 @@ print DEBUG "ps $p0 $p1 $lenperp ($ppu)\n"; $red += 32 if $segments[0] =~ m/^\-/; $red %= 64; $red /= 64.0; + $red <<= 2; $red= sprintf("%f", $red); o(" $red $subsegcmap{$csegbare} setrgbcolor\n"); } else { diff --git a/layout/segcmapassign b/layout/segcmapassign index f25ec6d..f97d9c8 100755 --- a/layout/segcmapassign +++ b/layout/segcmapassign @@ -25,9 +25,9 @@ # Encoding is as follows (bits from MSbit to LSbit): # # RED +# 6 bits angle # 1 bit reserved (0) # 1 bit `edge or core' (currently 0 meaning `core') -# 6 bits angle # # GREEN # 2 bits segment overflow @@ -36,9 +36,11 @@ # the remainder of the bits are the position of that feature # the feature all-bits-1 (0b111111) is for fixed track # (so every moveable feature prefix must contain at least one 0) +# BUT all of the bits are in the reverse order (so the +# MSbit of GREEN is the LSbit of the moveable feature position) # # BLUE -# 8 bits segment main +# 8 bits segment main IN REVERSE ORDER use strict; use IO::Handle; @@ -66,18 +68,29 @@ while (<>) { } } +sub reverse_bits_in_byte ($) { + my ($b) = @_; + my ($c); + $c = (($b >> 1) & 0x55) | (($b << 1) & 0xaa); + $c |= (($b >> 2) & 0x33) | (($b << 2) & 0xcc); + $c |= (($b >> 4) & 0x0f) | (($b << 4) & 0xf0); + return $c; +} + sub cssnmap ($$$$) { my ($seg,$movfeatconf,$segnum,$posinfo) = @_; - my ($green,$blue); + my ($green,$blue,$greenr,$bluer); $green= (($segnum >> 8) & 0x03)<<6; $green |= $posinfo; $blue= $segnum & 0xff; + $greenr= reverse_bits_in_byte($green); + $bluer= reverse_bits_in_byte($blue); printf("C %s/%s %.10f %.10f\n". - "# %s/%s 0x%x 0x%x\n", + "# %s/%s 0x%x 0x%x 0x%x 0x%x\n", $seg,$movfeatconf, - $green/255, $blue/255, + $greenr/255, $bluer/255, $seg,$movfeatconf, - $green, $blue) + $green, $blue, $greenr, $bluer) or die $!; } -- 2.30.2