summaryrefslogtreecommitdiff
path: root/src/core/ao_convert_pa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ao_convert_pa.c')
-rw-r--r--src/core/ao_convert_pa.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/core/ao_convert_pa.c b/src/core/ao_convert_pa.c
index 0c93caea..55fe6e7d 100644
--- a/src/core/ao_convert_pa.c
+++ b/src/core/ao_convert_pa.c
@@ -19,14 +19,22 @@
#include "ao.h"
#endif
-static const int32_t altitude_table[] = {
+#ifndef AO_CONST_ATTRIB
+#define AO_CONST_ATTRIB
+#endif
+
+static const alt_t altitude_table[] AO_CONST_ATTRIB = {
#include "altitude-pa.h"
};
+#ifndef FETCH_ALT
+#define FETCH_ALT(o) altitude_table[o]
+#endif
+
#define ALT_SCALE (1 << ALT_SHIFT)
#define ALT_MASK (ALT_SCALE - 1)
-int32_t
+alt_t
ao_pa_to_altitude(int32_t pa)
{
int16_t o;
@@ -40,11 +48,12 @@ ao_pa_to_altitude(int32_t pa)
o = pa >> ALT_SHIFT;
part = pa & ALT_MASK;
- low = (int32_t) altitude_table[o] * (ALT_SCALE - part);
- high = (int32_t) altitude_table[o+1] * part + (ALT_SCALE >> 1);
+ low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part);
+ high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
return (low + high) >> ALT_SHIFT;
}
+#ifdef AO_CONVERT_TEST
int32_t
ao_altitude_to_pa(int32_t alt)
{
@@ -70,3 +79,4 @@ ao_altitude_to_pa(int32_t alt)
pa = 0;
return pa;
}
+#endif