diff options
Diffstat (limited to 'dda.c')
-rw-r--r-- | dda.c | 52 |
1 files changed, 21 insertions, 31 deletions
@@ -2,10 +2,11 @@ #include <stdio.h> #include <math.h> #include <stdint.h> -#include "testdata.c" typedef int32_t fixed_t; +#include "testdata.c" + #define FIXED_BITS (8) #define fixed_e ((fixed_t) 1) @@ -212,14 +213,14 @@ edge_step (edge_t *edge, int *yi, emitter_t emit, void *data) static void emit (sample_t xi, sample_t yi, void *data) { -#if 0 - double *points = data; -#endif + fixed_t *points = data; - printf ("sample %x %x (%f %f)\n", - xi, yi, - fixed_to_double (sample_to_pos_x (xi)), - fixed_to_double (sample_to_pos_y (yi))); + if (xi != points[0] || yi != points[1]) + { + printf ("0x%x, 0x%x - should be 0x%x 0x%x,\n", + xi, yi, points[0], points[1]); + exit (1); + } return; } @@ -227,16 +228,14 @@ emit (sample_t xi, sample_t yi, void *data) static void dda (test_data_t *testdata) { - fixed_t x0 = double_to_fixed (testdata->segment.x0); - fixed_t y0 = double_to_fixed (testdata->segment.y0); - fixed_t x1 = double_to_fixed (testdata->segment.x1); - fixed_t y1 = double_to_fixed (testdata->segment.y1); + fixed_t x0 = testdata->segment.x0; + fixed_t y0 = testdata->segment.y0; + fixed_t x1 = testdata->segment.x1; + fixed_t y1 = testdata->segment.y1; - printf ("f = = = %f %f %f %f = = = = \n", - fixed_to_double (x0), - fixed_to_double (y0), - fixed_to_double (x1), - fixed_to_double (y1)); +#if 0 + printf ("{\n{ 0x%x, 0x%x, 0x%x, 0x%x },\n{\n", x0, y0, x1, y1); +#endif edge_t edge; int i = 0; @@ -251,30 +250,21 @@ dda (test_data_t *testdata) i += 2; } +#if 0 + printf ("} \n},\n"); +#endif } -static test_data_t td[] = -{ - { -1.917969, 1.980469, -0.937500, 2.855469 } -}; - int main () { int i; - dda (&td[0]); - for (i = 0; i < 1000; ++i) { - test_data_t tt; - - tt.segment.x0 = 5 * (drand48() - 0.5); - tt.segment.y0 = 5 * (drand48() - 0.5); - tt.segment.x1 = tt.segment.x0 + (drand48() - 0.5) * 4; - tt.segment.y1 = tt.segment.y0 + drand48() * 4; + test_data_t *tt = &(testdata[i]); - dda (&tt); + dda (tt); } return 0; |