# 6 bits moveable feature and position
# each moveable feature has an unambiguous prefix
# 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)
+# the feature all-bits-0 (0b000000) is for fixed track
+# (so every moveable feature prefix must contain at least one 1)
# BUT all of the bits are in the reverse order (so the
# MSbit of GREEN is the LSbit of the moveable feature position)
#
our ($segnum) = 1;
-our ($conf,$posbit,$posbiti,$nextfree);
+our ($conf,$posbit,$posbiti,$abovenext);
foreach $seg (sort keys %seg) {
$si= $seg{$seg};
$si->{Num}= $segnum++;
die if $si->{Num} >= 1024;
- $nextfree= 0;
+ $abovenext= 0x40;
printf("S %s 0x%x\n",
$seg, $si->{Num})
or die $!;
- cssnmap($seg,'', $si->{Num}, 0x3f);
+ cssnmap($seg,'', $si->{Num}, 0x00);
foreach $movfeat (sort {
$si->{Feat}{$b}{Max} <=> $si->{Feat}{$a}{Max};
} keys %{ $si->{Feat} }) {
for ($posbit=1,$posbiti=0;
$posbit<=$fi->{Max};
$posbit<<=1,$posbiti++) { }
- $fi->{Prefix}= $nextfree;
+ $abovenext -= $posbit;
+ die "too many $seg" if $abovenext <= 0;
+ $fi->{Prefix}= $abovenext;
$fi->{ConfigMask}= $posbit-1;
$fi->{ConfigBits}= $posbiti;
- $nextfree += $posbit;
printf("F %s 0x%x %s 0x%x %d 0x%x\n",
$seg, $si->{Num},
$movfeat, $fi->{Prefix}, $fi->{ConfigBits}, $fi->{Max});
cssnmap($seg, $movfeat.$conf, $si->{Num}, $fi->{Prefix}+$conf);
}
}
- die "too many $seg" if $nextfree > 0x03f;
}
STDIN->error and die $!;