X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fmainboard%2Fstrat_db.c;fp=projects%2Fmicrob2010%2Fmainboard%2Fstrat_db.c;h=015379488b6ddfb61899ffb5486da207aae9bc5c;hp=c3608d640897d5e00cf5db2fa14ce55ac2244235;hb=03e4f34e90f71a08b671193c8a3ac9e587f83cd6;hpb=28da5858ac871c626153f47566e968ecb05ff52b diff --git a/projects/microb2010/mainboard/strat_db.c b/projects/microb2010/mainboard/strat_db.c index c3608d6..0153794 100644 --- a/projects/microb2010/mainboard/strat_db.c +++ b/projects/microb2010/mainboard/strat_db.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -174,7 +175,7 @@ int8_t xycoord_to_ijcoord(int16_t *xp, int16_t *yp, uint8_t *ip, uint8_t *jp) x += (STEP_CORN_X/2); i = x / STEP_CORN_X; - y = COLOR_Y(y); + y = COLOR_Y(y); /* Y depends on color */ y -= OFFSET_CORN_Y; if ((i & 1) == 1) { j = y / STEP_CORN_Y; @@ -206,8 +207,7 @@ int8_t xycoord_to_ijcoord(int16_t *xp, int16_t *yp, uint8_t *ip, uint8_t *jp) /******** CORN */ -/* return the index of a corn given its i,j coords. */ -int8_t ijcoord_to_corn_idx(uint8_t i, uint8_t j) +static int8_t early_ijcoord_to_corn_idx(uint8_t i, uint8_t j) { uint8_t n; for (n = 0; n < CORN_NB; n ++) { @@ -218,6 +218,14 @@ int8_t ijcoord_to_corn_idx(uint8_t i, uint8_t j) return -1; } +/* return the index of a corn given its i,j coords. */ +int8_t ijcoord_to_corn_idx(uint8_t i, uint8_t j) +{ + if (strat_db.wp_table[i][j].type != WP_TYPE_CORN) + return -1; + return strat_db.wp_table[i][j].corn.idx; +} + /* return the i,j coords of a corn given its index */ int8_t corn_idx_to_ijcoord(uint8_t idx, uint8_t *i, uint8_t *j) { @@ -492,7 +500,7 @@ void strat_db_init(void) } /* corn */ - idx = ijcoord_to_corn_idx(i, j); + idx = early_ijcoord_to_corn_idx(i, j); if (idx >= 0) { wp->type = WP_TYPE_CORN; wp->present = 1;