our ($maxptixln2) = 5;
-our ($nextboardnum,@boardtype,%numboards,$nreverses,@sensesin,@sensesbase);
-our (@objkinds,%pin_used);
-# @boardtype[$boardnum]
-# $numboards{$type}
-# $nreverses
+our ($nextboardnum,@boardtype,@sensesin,$maxreverseobjnum);
+our (@reversersboardnum,@sensesbase,@objkinds,%pin_used);
+# $boardtype[$boardnum]
# $sensesin[$page]
+# $maxreverseobjnum
+# $reversersboardnum[$boardnum] # undef => none; -1 => not yet determined
# $sensesbase[$boardnum]= ($page << 7) | $baselsbyte
-# %pin_used{$objkind}[$objnum] = [ $boardnum, $pin_info, $objonboard ]
+# $pin_used{$objkind}[$objnum] = [ $boardnum, $pin_info, $objonboard ]
$nextboardnum= 0;
-$nreverses= 0;
$sensesin[0]= 0;
@objkinds= qw(pt sense reverse);
m/^\s+(\w+)\s+(\d+\.\d+)$/ or return syntaxerror();
($seg,$boob)=($1,$2);
mistake("duplicate topology for $seg") if exists $segs{$seg};
+ $boob= pa_boob($boob);
$segs{$seg}= {
- BoOb => pa_boob($boob),
+ BoOb => $boob,
Inv => $invertible,
Posns => 1,
Feats => { },
FeatCount => 0
};
+ &{"line_segment_".($invertible?'invertible':'vanilla')}($boob);
}
sub begin_endwiring () {
$nextboardnum++;
$boardtype[$num]= $type;
- $numboards{$type}++;
require "./$type.pin-info";
my ($sense_count, $page);
&{"line_boards_$type"}($num);
}
-sub line_boards_reversers {
- my ($num) = @_;
- my ($i,$objnum);
- for ($i=0; $i<6; $i++) {
- $objnum= boob2objnum($num,$i,'reverse',0);
- fixme nreverses seems unused
- $nreverses= $objnum+1 if $objnum >= $nreverses;
- }
-}
+sub line_boards_reversers { }
sub line_boards_detectors { }
+sub line_segment_vanilla ($) { }
+sub line_segment_invertible ($) {
+ my ($boob) = @_;
+ $reversersboardnum[$boob->[0]]= -1;
+}
sub mistake ($) {
my ($m) = @_;
}
sub boob2objnum_reverse {
- my ($boardnum,$obj,$boardtype)=@_;
-fixme need to map board num for reversers to
-
+ my ($orgboardnum,$obj,$boardtype)=@_;
# Converts board and object number (in canonical pic number plus
# and reverse0...reverse5 as seen on pinout diagrams), to the
# segment number for POLARITY command numbered as shown in
#
# * We invert the on-board mapping; ie, we untangle the
# tangling between the message from master to slave pic
- # and the actual pins (see reverse.asm, polarity_do_here)
+ # and the actual pins (see reverse.asm, polarity_local_do)
#
# * We figure out which bit of which message byte the
- # object corresponds to. (see reverse.asm, polarity_decode_message)
+ # object corresponds to. (see reverse.asm, command_polarity)
#
# * We compute the README.protocol segment number.
- my ($cycle,$boardincycle,$cyclebasebyte,$byte,$bit);
+ my ($cycle,$boardincycle,$cyclebasebyte,$byte,$bit,$boardnum,$rv);
+ $boardnum= $reversersboardnum[$orgboardnum];
+ die "$orgboardnum $boardnum" unless defined $boardnum;
+ die "$orgboardnum $boardnum" unless $boardnum >= 0;
die unless $boardtype eq 'reversers';
die $obj if $obj > 5;
+#print STDERR "data2safety $boardnum.$obj ";
$obj = sprintf '%d', $obj;
$obj =~ y/302154/543210/; # mapping due to polarity_do_here
+#print STDERR " obj=$obj";
$cycle= int(($boardnum+3) / 7);
+#print STDERR " cycle=$cycle";
$boardincycle= ($boardnum+3) - $cycle*7;
+#print STDERR " boardin=$boardincycle";
$cyclebasebyte= $cycle*6 - 2;
+#print STDERR " baseby=$cyclebasebyte";
if ($boardnum==2 && $obj > 2) {
$byte= 0; $bit= $obj-3;
- return 3 - $bit; # only these three in byte 0, a special case
+ $rv= 3 - $bit; # only these three in byte 0, a special case;
+#print STDERR " special bit=$bit => $rv\n";
+ return $rv;
} elsif ($boardincycle<5) {
- $byte= $cyclebasebyte + $boardincycle; $bit= $obj;
+ $byte= $cyclebasebyte + $boardincycle; $bit= $obj + 1;
} elsif ($boardincycle==6) {
- $byte= $cyclebasebyte + 5; $bit= $obj;
+ $byte= $cyclebasebyte + 5; $bit= $obj + 1;
} elsif ($boardincycle==5) {
- $byte= $cyclebasebyte + 5 - $bit; $bit= 6;
+ $byte= $cyclebasebyte + 5 - $bit; $bit= 0;
} else {
die;
}
- return $byte*7 + 3 - $bit;
+ $rv= $byte*7 + 3 - $bit;
+#print STDERR " ordinary byte=$byte bit=$bit => $rv\n";
+ return $rv;
}
sub boob2objnum_sense {
}
sub redaction () {
+ my ($num,$mappednum,$i,$objnum);
+ $maxreverseobjnum= 0;
for ($num=0, $mappednum=0; $num<@boardtype; $num++) {
- next if $boardtype[$num] eq 'detectors';
-
+ next unless defined $reversersboardnum[$num];
+ die if $reversersboardnum[$num] != -1;
+ $reversersboardnum[$num]= $mappednum;
+ for ($i=0; $i<6; $i++) {
+ $objnum= boob2objnum($mappednum,$i,'reverse',0);
+ $maxreverseobjnum= $objnum+1 if $objnum >= $maxreverseobjnum;
+ }
+ $mappednum++;
+ }
+}
sub nummap ($) {
my ($p) = @_;
$delim= ',';
}
o("\n};\n");
+ o("const BoardObject info_maxreverse=$maxreverseobjnum;\n");
}
# writeasm_KIND()