+ if (state[2]) begin
+ out <= ~mb[`MAXOUTN] + colorofs;
+ end
+
+ if (state[1]) begin // PnR0 in, PnR2 out
+ stagex[2] <= xprop[`MAXOUTN];
+ stagey[2] <= yprop[`MAXOUTN];
+ stager[2] <= mr[`MAXOUTN];
+ stagei[2] <= mi[`MAXOUTN];
+ stagexs[2] <= xsprop[`MAXOUTN];
+ stageys[2] <= ysprop[`MAXOUTN];
+ stagers[2] <= mrs[`MAXOUTN];
+ stageis[2] <= mis[`MAXOUTN];
+ stageb[2] <= mb[`MAXOUTN];
+ stageci[2] <= curiter[`MAXOUTN];
+ end
+
+ if (state[0]) begin // PnR2 in, PnR1 out
+ stagex[1] <= xprop[`MAXOUTN];
+ stagey[1] <= yprop[`MAXOUTN];
+ stager[1] <= mr[`MAXOUTN];
+ stagei[1] <= mi[`MAXOUTN];
+ stagexs[1] <= xsprop[`MAXOUTN];
+ stageys[1] <= ysprop[`MAXOUTN];
+ stagers[1] <= mrs[`MAXOUTN];
+ stageis[1] <= mis[`MAXOUTN];
+ stageb[1] <= mb[`MAXOUTN];
+ stageci[1] <= curiter[`MAXOUTN];
+ end
+
+ if (statekick) // If a pixclk has happened, the state should be reset.
+ state <= 3'b010;
+ else // Otherwise, just poke it forward.
+ state <= {state[1], state[0], state[2]};