From bf8c3056f94e2a7951d0e53d247f8d3b2aca2d84 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Tue, 20 Apr 2004 23:11:12 +0000 Subject: Overflow error fix git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4531 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/mandelbrot.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'apps') diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c index 3585af80f9..3c948e8130 100644 --- a/apps/plugins/mandelbrot.c +++ b/apps/plugins/mandelbrot.c @@ -38,10 +38,10 @@ static int delta; static int max_iter; void init_mandelbrot_set(void){ - x_min = -5<<27; // -2.5<<28 - x_max = 1<<28; // 1.0<<28 - y_min = -1<<28; // -1.0<<28 - y_max = 1<<28; // 1.0<<28 + x_min = -5<<25; // -2.5<<26 + x_max = 1<<26; // 1.0<<26 + y_min = -1<<26; // -1.0<<26 + y_max = 1<<26; // 1.0<<26 delta = (x_max - x_min) >> 3; // /8 max_iter = 25; } @@ -71,12 +71,12 @@ void calc_mandelbrot_set(void){ n_iter = 0; while (++n_iter<=max_iter) { - x >>= 14; - y >>= 14; + x >>= 13; + y >>= 13; x2 = x * x; y2 = y * y; - if (x2 + y2 > (4<<28)) break; + if (x2 + y2 > (4<<26)) break; y = 2 * x * y + b; x = x2 - y2 + a; @@ -114,7 +114,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb = api; init_mandelbrot_set(); - lcd_aspect_ratio = ((LCD_WIDTH<<14) / LCD_HEIGHT)<<14; + lcd_aspect_ratio = ((LCD_WIDTH<<13) / LCD_HEIGHT)<<13; /* main loop */ while (true){ @@ -132,8 +132,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) return PLUGIN_OK; case BUTTON_ON: - x_min -= ((delta>>14)*(lcd_aspect_ratio>>14)); - x_max += ((delta>>14)*(lcd_aspect_ratio>>14)); + x_min -= ((delta>>13)*(lcd_aspect_ratio>>13)); + x_max += ((delta>>13)*(lcd_aspect_ratio>>13)); y_min -= delta; y_max += delta; delta = (x_max - x_min) >> 3; @@ -141,8 +141,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) case BUTTON_PLAY: - x_min += ((delta>>14)*(lcd_aspect_ratio>>14)); - x_max -= ((delta>>14)*(lcd_aspect_ratio>>14)); + x_min += ((delta>>13)*(lcd_aspect_ratio>>13)); + x_max -= ((delta>>13)*(lcd_aspect_ratio>>13)); y_min += delta; y_max -= delta; delta = (x_max - x_min) >> 3; -- cgit v1.2.3