From: adam Date: Sat, 24 Feb 2007 19:21:15 +0000 (+0100) Subject: fix bugs in software implementation of Choice ship X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=d7bcbeee8e4be20cc539c9d5c6b0a6155a99e1de;p=fleet.git fix bugs in software implementation of Choice ship --- diff --git a/ships/Choice.ship b/ships/Choice.ship index 28fcd96..2aa8129 100644 --- a/ships/Choice.ship +++ b/ships/Choice.ship @@ -72,7 +72,7 @@ public void service() { if (port.startsWith("mux") && (!box_in1.dataReadyForShip() || !box_in2.dataReadyForShip())) return; if (port.startsWith("deMux") && (!box_in1.dataReadyForShip())) return; - long val = box_in.removeDataForShip(); + long val = selector.value; boolean condition = false; if (port.endsWith("IfZero")) condition = val==0; if (port.endsWith("IfNonZero")) condition = val!=0; @@ -84,14 +84,18 @@ public void service() { if (condition) { box_out1.addDataFromShip(box_in2.removeDataForShip()); box_out2.addDataFromShip(box_in1.removeDataForShip()); + selector = null; } else { box_out1.addDataFromShip(box_in1.removeDataForShip()); box_out2.addDataFromShip(box_in2.removeDataForShip()); + selector = null; } } else if (port.startsWith("mux")) { box_out1.addDataFromShip(condition ? box_in2.removeDataForShip() : box_in1.removeDataForShip()); + selector = null; } else if (port.startsWith("deMux")) { (condition ? box_out2 : box_out1).addDataFromShip(box_in1.removeDataForShip()); + selector = null; } }