summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-12-13 10:13:58 -0500
committerSøren Sandmann Pedersen <ssp@l3000.localdomain>2010-12-20 10:48:52 -0500
commit634415aceeb0e296abe5990bbf79f2c5fb342494 (patch)
treee28c5849a526bf56cb293304f0d72b8b33dceb32
parentfb5c9190c889c3ed7ad37ffe9646207812635e3a (diff)
Compute fixed_Max_int
-rw-r--r--dda.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/dda.c b/dda.c
index 37eedbe..796b08d 100644
--- a/dda.c
+++ b/dda.c
@@ -4,19 +4,20 @@
#include <stdint.h>
#include "testdata.c"
-typedef uint32_t fixed_t;
+typedef int32_t fixed_t;
+#define FIXED_BITS (8)
#define fixed_e ((fixed_t) 1)
#define fixed_1 (int_to_fixed(1))
#define fixed_1_minus_e (fixed_1 - fixed_e)
-#define fixed_to_int(f) ((int) ((f) >> 8))
-#define int_to_fixed(i) ((fixed_t) ((i) << 8))
+#define fixed_to_int(f) ((int) ((f) >> FIXED_BITS))
+#define int_to_fixed(i) ((fixed_t) ((i) << FIXED_BITS))
#define fixed_frac(f) ((f) & fixed_1_minus_e)
#define fixed_floor(f) ((f) & ~fixed_1_minus_e)
#define fixed_ceil(f) fixed_floor ((f) + fixed_1_minus_e)
#define fixed_mod_2(f) ((f) & (fixed1 | fixed_1_minus_e))
-#define fixed_max_int (0x7fffff)
+#define fixed_max_int ((fixed_t)((0xffffffff << FIXED_BITS) & ~0x80000000))
#define fixed_to_double(f) ((double) ((f) * (1 / (double) fixed_1)))
#define double_to_fixed(d) ((fixed_t) ((d) * fixed_1))
@@ -195,7 +196,14 @@ edge_step (edge_t *edge, test_data_t *testdata, int i, int *yi)
printf ("Pos: %f %f\n",
fixed_to_double (sample_to_pos_x (edge->xi)),
fixed_to_double (sample_to_pos_y (*yi)));
+#endif
+ printf ("Pos: %x %x\n", edge->xi, *yi);
+#if 0
+ fixed_to_double (sample_to_pos_x (edge->xi)),
+ fixed_to_double (sample_to_pos_y (*yi)));
+#endif
+#if 0
if (testdata->points[i++] != sample_to_pos (edge->xi) ||
testdata->points[i++] != sample_to_pos (*yi))
{
@@ -252,7 +260,7 @@ dda (test_data_t *testdata)
int
main ()
{
- test_data_t td = { { 0.5, 0.5, 3.5, 7.033 } };
+ test_data_t td = { { 0.5, 0.5, 3.5, 10.733 } };
dda (&td);