+ int16_t x, y;
+ uint8_t i, j;
+
+ x = position_get_x_s16(&mainboard.pos);
+ y = position_get_y_s16(&mainboard.pos);
+
+ if (xycoord_to_ijcoord(&x, &y, &i, &j) < 0)
+ return;
+
+ if (strat_db.wp_table[i][j].type != WP_TYPE_TOMATO)
+ return;
+
+ strat_db.wp_table[i][j].present = 0;
+}
+
+/* mark corn as not present and give correct commands to the cobboard
+ * for spickles */
+static void check_corn(void)
+{
+ uint8_t flags;
+ int8_t lcob_near, rcob_near;
+ uint8_t lcob, rcob;
+ uint8_t lidx, ridx;
+
+ /* read sensors from ballboard */
+ IRQ_LOCK(flags);
+ lcob = ballboard.lcob;
+ ballboard.lcob = I2C_COB_NONE;
+ rcob = ballboard.rcob;
+ ballboard.rcob = I2C_COB_NONE;
+ IRQ_UNLOCK(flags);
+
+/* if (lcob != I2C_COB_NONE) */
+/* DEBUG(E_USER_STRAT, "XXX lcob %s", */
+/* lcob == I2C_COB_WHITE ? "white" : "black"); */
+/* if (rcob != I2C_COB_NONE) */
+/* DEBUG(E_USER_STRAT, "XXX rcob %s", */
+/* rcob == I2C_COB_WHITE ? "white" : "black"); */
+ /* XXX take opponent position into account */
+
+#ifdef HOST_VERSION
+ if (time_get_s() == 15)
+ cobboard.cob_count = 5;
+ if (time_get_s() == 16)
+ cobboard.cob_count = 0;
+#endif
+
+ /* detect cob on left side */
+ lcob_near = corn_is_near(&lidx, I2C_LEFT_SIDE);
+ if (lcob_near && lcob != I2C_COB_NONE) {
+ if (strat_db.corn_table[lidx]->corn.color == I2C_COB_UNKNOWN)
+ DEBUG(E_USER_STRAT, "lcob %s %d",
+ lcob == I2C_COB_WHITE ? "white" : "black", lidx);
+ corn_set_color(strat_db.corn_table[lidx], lcob);
+ }
+
+ /* detect cob on right side */
+ rcob_near = corn_is_near(&ridx, I2C_RIGHT_SIDE);
+ if (rcob_near && rcob != I2C_COB_NONE) {
+ if (strat_db.corn_table[ridx]->corn.color == I2C_COB_UNKNOWN)
+ DEBUG(E_USER_STRAT, "rcob %s %d",
+ rcob == I2C_COB_WHITE ? "white" : "black", ridx);
+ corn_set_color(strat_db.corn_table[ridx], rcob);
+ }
+
+ /* control the cobboard mode for left spickle */
+ if (lcob_near && strat_db.corn_table[lidx]->present) {
+ if (get_cob_count() >= 5 || strat_want_pack || strat_lpack60) {
+ /* nothing */
+ }
+ else {
+ /* deploy spickle and harvest white ones */
+ if (strat_db.corn_table[lidx]->corn.color == I2C_COB_WHITE) {
+ i2c_cobboard_autoharvest_nomove(I2C_LEFT_SIDE);
+ if (cobboard.status == I2C_COBBOARD_STATUS_LBUSY)
+ strat_db.corn_table[lidx]->present = 0;
+ }