From 55240a2e8587f09d33a2594d90fde7f17b4a9266 Mon Sep 17 00:00:00 2001 From: Tomer Shalev Date: Sun, 17 Jan 2010 15:32:17 +0000 Subject: [PATCH] Fractals: Use constants for screen panning git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24258 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/fractals/fractal_rect.h | 3 --- apps/plugins/fractals/fractal_sets.h | 8 ++++++++ apps/plugins/fractals/mandelbrot_set.c | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/plugins/fractals/fractal_rect.h b/apps/plugins/fractals/fractal_rect.h index eca66556d3..9d57c29df6 100644 --- a/apps/plugins/fractals/fractal_rect.h +++ b/apps/plugins/fractals/fractal_rect.h @@ -23,9 +23,6 @@ #include "fractal_sets.h" -#define LCD_SHIFT_X (LCD_WIDTH / 8) -#define LCD_SHIFT_Y (LCD_HEIGHT / 8) - void rects_queue_init(void); void rects_calc_all(int (*calc)(struct fractal_rect *, int (*)(void *), void *), int (*button_yield_cb)(void *), void *ctx); diff --git a/apps/plugins/fractals/fractal_sets.h b/apps/plugins/fractals/fractal_sets.h index 2d0ff7d930..a41de45c14 100644 --- a/apps/plugins/fractals/fractal_sets.h +++ b/apps/plugins/fractals/fractal_sets.h @@ -24,6 +24,14 @@ #include "lib/grey.h" #include "lib/xlcd.h" +#define DELTA 8 /* Panning moves 1/DELTA of screen */ + +#define LCD_SHIFT_X (LCD_WIDTH / DELTA) +#define LCD_SHIFT_Y (LCD_HEIGHT / DELTA) + +#define X_DELTA(x) (((x) * LCD_WIDTH) / DELTA) +#define Y_DELTA(y) (((y) * LCD_HEIGHT) / DELTA) + struct fractal_rect { int px_min; diff --git a/apps/plugins/fractals/mandelbrot_set.c b/apps/plugins/fractals/mandelbrot_set.c index 53ac7f275d..b8a65d6787 100644 --- a/apps/plugins/fractals/mandelbrot_set.c +++ b/apps/plugins/fractals/mandelbrot_set.c @@ -139,8 +139,9 @@ static int ilog2_fp(long value) /* calculate integer log2(value_fp_6.26) */ static void recalc_parameters(void) { ctx.x_step = (ctx.x_max - ctx.x_min) / LCD_WIDTH; - ctx.x_delta = (ctx.x_step * LCD_WIDTH) / 8; + ctx.x_delta = X_DELTA(ctx.x_step); ctx.y_step = (ctx.y_max - ctx.y_min) / LCD_HEIGHT; + ctx.y_delta = Y_DELTA(ctx.y_step); ctx.y_delta = (ctx.y_step * LCD_HEIGHT) / 8; ctx.step_log2 = ilog2_fp(MIN(ctx.x_step, ctx.y_step)); ctx.max_iter = MAX(15, -15 * ctx.step_log2 - 45);