altos: Switch all tick variables to AO_TICK_TYPE/AO_TICK_SIGNED
[fw/altos] / src / kernel / ao_pyro.c
index 07a8278d560a85f4d913ccf7a735645131d31cc6..c9db061bfcf5f2bd74336b44f4afa16b821b2a71 100644 (file)
@@ -161,14 +161,14 @@ ao_pyro_ready(struct ao_pyro *pyro)
 #endif
 
                case ao_pyro_time_less:
-                       if ((int32_t) (ao_time() - ao_launch_tick) <= pyro->time_less)
+                       if ((AO_TICK_SIGNED) (ao_time() - ao_launch_tick) <= pyro->time_less)
                                continue;
-                       DBG("time %d > %d\n", (int32_t)(ao_time() - ao_launch_tick), pyro->time_less);
+                       DBG("time %d > %d\n", (AO_TICK_SIGNED)(ao_time() - ao_launch_tick), pyro->time_less);
                        break;
                case ao_pyro_time_greater:
-                       if ((int32_t) (ao_time() - ao_launch_tick) >= pyro->time_greater)
+                       if ((AO_TICK_SIGNED) (ao_time() - ao_launch_tick) >= pyro->time_greater)
                                continue;
-                       DBG("time %d < %d\n", (int32_t)(ao_time() - ao_launch_tick), pyro->time_greater);
+                       DBG("time %d < %d\n", (AO_TICK_SIGNED)(ao_time() - ao_launch_tick), pyro->time_greater);
                        break;
 
                case ao_pyro_ascending:
@@ -316,7 +316,7 @@ ao_pyro_check(void)
                                continue;
                        }
 
-                       if ((int32_t) (ao_time() - pyro->delay_done) < 0)
+                       if ((AO_TICK_SIGNED) (ao_time() - pyro->delay_done) < 0)
                                continue;
                }
 
@@ -640,18 +640,22 @@ ao_pyro_update_version(void)
 
                /* First, move all of the config bits that follow the pyro data */
 
-               char    *pyro_base = (void *) &ao_config.pyro;
-               char    *after_pyro_new = pyro_base + AO_PYRO_NUM * sizeof (struct ao_pyro);
-               char    *after_pyro_1_24 = pyro_base + AO_PYRO_NUM * sizeof (struct ao_pyro_1_24);
-               char    *config_end = (void *) (&ao_config + 1);
-               size_t  to_move = config_end - after_pyro_new;
+               struct ao_config_1_24 *ao_config_1_24 = (void *) &ao_config;
+               struct ao_pyro          *pyro_1_25 = &ao_config.pyro[0];
+               struct ao_pyro_1_24     *pyro_1_24 = &(ao_config_1_24->pyro)[0];
 
-               memmove(after_pyro_new, after_pyro_1_24, to_move);
 
-               /* Now, adjust all of the pyro entries */
+               char    *pyro_base_1_25 = (void *) pyro_1_25;
+               char    *pyro_base_1_24 = (void *) pyro_1_24;
+               char    *after_pyro_1_25 = pyro_base_1_25 + AO_PYRO_NUM * sizeof (struct ao_pyro);
+               char    *after_pyro_1_24 = pyro_base_1_24 + AO_PYRO_NUM * sizeof (struct ao_pyro_1_24);
+
+               char    *config_end_1_25 = (void *) (&ao_config + 1);
+               size_t  to_move = config_end_1_25 - after_pyro_1_25;
 
-               struct ao_pyro          *pyro_new = ao_config.pyro;
-               struct ao_pyro_1_24     *pyro_old = (void *) ao_config.pyro;
+               memmove(after_pyro_1_25, after_pyro_1_24, to_move);
+
+               /* Now, adjust all of the pyro entries */
 
                int p = AO_PYRO_NUM;
 
@@ -664,15 +668,15 @@ ao_pyro_update_version(void)
                        struct ao_pyro  tmp;
 
                        memset(&tmp, '\0', sizeof(tmp));
-                       tmp.flags = pyro_old[p].flags;
+                       tmp.flags = pyro_1_24[p].flags;
 
                        for (v = 0; v < NUM_PYRO_VALUES; v++)
                        {
-                               value = ao_pyro_get_1_24(&pyro_old[v], ao_pyro_values[v].flag);
+                               value = ao_pyro_get_1_24(&pyro_1_24[p], ao_pyro_values[v].flag);
                                ao_pyro_put(&tmp, ao_pyro_values[v].offset,
                                            ao_pyro_size(ao_pyro_values[v].flag), value);
                        }
-                       memcpy(&pyro_new[p], &tmp, sizeof(tmp));
+                       memcpy(&pyro_1_25[p], &tmp, sizeof(tmp));
                }
        }
 }