diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/fractals/mandelbrot_set.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/apps/plugins/fractals/mandelbrot_set.c b/apps/plugins/fractals/mandelbrot_set.c index 18fc746cfa..6e47527a20 100644 --- a/apps/plugins/fractals/mandelbrot_set.c +++ b/apps/plugins/fractals/mandelbrot_set.c | |||
@@ -58,20 +58,20 @@ static fb_data imgbuffer[LCD_HEIGHT]; | |||
58 | #define MB_HEIGHT LCD_HEIGHT | 58 | #define MB_HEIGHT LCD_HEIGHT |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | #define MB_XOFS (-0x03000000L) /* -0.75 (s5.26) */ | 61 | #define MB_XOFS (-0x03000000L) /* -0.75 (s5.26) */ |
62 | #if 3000*MB_HEIGHT/LCD_WIDTH >= 2400 /* width is limiting factor */ | 62 | #if (3000 * MB_HEIGHT / LCD_WIDTH) >= 2400 /* width is limiting factor */ |
63 | #define MB_XFAC (0x06000000LL) /* 1.5 (s5.26) */ | 63 | #define MB_XFAC (0x06000000LL) /* 1.5 (s5.26) */ |
64 | #define MB_YFAC (MB_XFAC*MB_HEIGHT/LCD_WIDTH) | 64 | #define MB_YFAC (MB_XFAC*MB_HEIGHT / LCD_WIDTH) |
65 | #else /* height is limiting factor */ | 65 | #else /* height is limiting factor */ |
66 | #define MB_YFAC (0x04cccccdLL) /* 1.2 (s5.26) */ | 66 | #define MB_YFAC (0x04cccccdLL) /* 1.2 (s5.26) */ |
67 | #define MB_XFAC (MB_YFAC*LCD_WIDTH/MB_HEIGHT) | 67 | #define MB_XFAC (MB_YFAC*LCD_WIDTH / MB_HEIGHT) |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | #ifndef USEGSLIB | 70 | #ifndef USEGSLIB |
71 | #define UPDATE_FREQ (HZ/50) | 71 | #define UPDATE_FREQ (HZ/50) |
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | /* Fixed point format s5.26: sign, 5 bits integer part, 26 bits fractional part */ | 74 | /* fixed point format s5.26: sign, 5 bits integer part, 26 bits fractional part */ |
75 | struct fractal_ops *ops; | 75 | struct fractal_ops *ops; |
76 | long x_min; | 76 | long x_min; |
77 | long x_max; | 77 | long x_max; |
@@ -127,7 +127,7 @@ static int ilog2_fp(long value) /* calculate integer log2(value_fp_6.26) */ | |||
127 | } | 127 | } |
128 | else | 128 | else |
129 | { | 129 | { |
130 | while (value < (1L<<26)) | 130 | while (value < (1L << 26)) |
131 | { | 131 | { |
132 | value <<= 1; | 132 | value <<= 1; |
133 | i--; | 133 | i--; |
@@ -147,7 +147,6 @@ static int recalc_parameters(void) | |||
147 | 147 | ||
148 | x_delta = X_DELTA(x_step); | 148 | x_delta = X_DELTA(x_step); |
149 | y_delta = Y_DELTA(y_step); | 149 | y_delta = Y_DELTA(y_step); |
150 | y_delta = (y_step * LCD_HEIGHT) / 8; | ||
151 | max_iter = MAX(15, -15 * step_log2 - 45); | 150 | max_iter = MAX(15, -15 * step_log2 - 45); |
152 | 151 | ||
153 | ops->calc = (step_log2 <= -10) ? | 152 | ops->calc = (step_log2 <= -10) ? |
@@ -363,15 +362,15 @@ static int mandelbrot_calc_high_prec(struct fractal_rect *rect, | |||
363 | return 0; | 362 | return 0; |
364 | } | 363 | } |
365 | 364 | ||
366 | static void mandelbrot_move(int dx, int dy) | 365 | static void mandelbrot_move(int x_factor, int y_factor) |
367 | { | 366 | { |
368 | long d_x = (long)dx * x_delta; | 367 | long dx = (long)x_factor * x_delta; |
369 | long d_y = (long)dy * y_delta; | 368 | long dy = (long)y_factor * y_delta; |
370 | 369 | ||
371 | x_min += d_x; | 370 | x_min += dx; |
372 | x_max += d_x; | 371 | x_max += dx; |
373 | y_min += d_y; | 372 | y_min += dy; |
374 | y_max += d_y; | 373 | y_max += dy; |
375 | } | 374 | } |
376 | 375 | ||
377 | static int mandelbrot_zoom(int factor) | 376 | static int mandelbrot_zoom(int factor) |
@@ -398,14 +397,14 @@ static int mandelbrot_precision(int d) | |||
398 | { | 397 | { |
399 | int changed = 0; | 398 | int changed = 0; |
400 | 399 | ||
401 | /* Precision increase */ | 400 | /* Increase precision */ |
402 | for (; d > 0; d--) | 401 | for (; d > 0; d--) |
403 | { | 402 | { |
404 | max_iter += max_iter / 2; | 403 | max_iter += max_iter / 2; |
405 | changed = 1; | 404 | changed = 1; |
406 | } | 405 | } |
407 | 406 | ||
408 | /* Precision decrease */ | 407 | /* Decrease precision */ |
409 | for (; d < 0 && max_iter >= 15; d++) | 408 | for (; d < 0 && max_iter >= 15; d++) |
410 | { | 409 | { |
411 | max_iter -= max_iter / 3; | 410 | max_iter -= max_iter / 3; |