diff options
author | Jens Arnold <amiconn@rockbox.org> | 2004-06-16 20:51:05 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2004-06-16 20:51:05 +0000 |
commit | 58f17cd082d813dafe5839dc00f80d18649cf654 (patch) | |
tree | d664f0ac07758f9a671e6e07af326d0b2eaf8249 /apps/plugins/mandelbrot.c | |
parent | c05b7d722ad15fe3720f86b21af05e9a9cd18b8f (diff) | |
download | rockbox-58f17cd082d813dafe5839dc00f80d18649cf654.tar.gz rockbox-58f17cd082d813dafe5839dc00f80d18649cf654.zip |
Mandelbrot didn't yield() at all, leading to playback problems when heavily calculating mandelbrots
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4759 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mandelbrot.c')
-rw-r--r-- | apps/plugins/mandelbrot.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c index 450a4ebfee..786e31dc40 100644 --- a/apps/plugins/mandelbrot.c +++ b/apps/plugins/mandelbrot.c | |||
@@ -48,14 +48,14 @@ void init_mandelbrot_set(void){ | |||
48 | 48 | ||
49 | void calc_mandelbrot_set(void){ | 49 | void calc_mandelbrot_set(void){ |
50 | 50 | ||
51 | unsigned int start_tick; | 51 | unsigned int start_tick, last_yield; |
52 | int n_iter; | 52 | int n_iter; |
53 | int x_pixel, y_pixel; | 53 | int x_pixel, y_pixel; |
54 | int x, x2, y, y2, a, b; | 54 | int x, x2, y, y2, a, b; |
55 | int x_fact, y_fact; | 55 | int x_fact, y_fact; |
56 | int brightness; | 56 | int brightness; |
57 | 57 | ||
58 | start_tick = *rb->current_tick; | 58 | start_tick = last_yield = *rb->current_tick; |
59 | 59 | ||
60 | gray_clear_display(); | 60 | gray_clear_display(); |
61 | 61 | ||
@@ -63,9 +63,9 @@ void calc_mandelbrot_set(void){ | |||
63 | y_fact = (y_max - y_min) / LCD_HEIGHT; | 63 | y_fact = (y_max - y_min) / LCD_HEIGHT; |
64 | 64 | ||
65 | for (x_pixel = 0; x_pixel<LCD_WIDTH; x_pixel++){ | 65 | for (x_pixel = 0; x_pixel<LCD_WIDTH; x_pixel++){ |
66 | a = (x_pixel * x_fact) + x_min; | 66 | a = (x_pixel * x_fact) + x_min; |
67 | for(y_pixel = LCD_HEIGHT-1; y_pixel>=0; y_pixel--){ | 67 | for(y_pixel = LCD_HEIGHT-1; y_pixel>=0; y_pixel--){ |
68 | b = (y_pixel * y_fact) + y_min; | 68 | b = (y_pixel * y_fact) + y_min; |
69 | x = 0; | 69 | x = 0; |
70 | y = 0; | 70 | y = 0; |
71 | n_iter = 0; | 71 | n_iter = 0; |
@@ -89,9 +89,15 @@ void calc_mandelbrot_set(void){ | |||
89 | } else { | 89 | } else { |
90 | brightness = 255 - (31 * (n_iter & 7)); | 90 | brightness = 255 - (31 * (n_iter & 7)); |
91 | } | 91 | } |
92 | graybuffer[y_pixel]=brightness; | 92 | graybuffer[y_pixel]=brightness; |
93 | /* be nice to other threads: | ||
94 | * if at least one tick has passed, yield */ | ||
95 | if (*rb->current_tick > last_yield){ | ||
96 | rb->yield(); | ||
97 | last_yield = *rb->current_tick; | ||
98 | } | ||
93 | } | 99 | } |
94 | gray_drawgraymap(graybuffer, x_pixel, 0, 1, LCD_HEIGHT, 1); | 100 | gray_drawgraymap(graybuffer, x_pixel, 0, 1, LCD_HEIGHT, 1); |
95 | } | 101 | } |
96 | } | 102 | } |
97 | 103 | ||