diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-08-09 12:04:04 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-08-09 12:04:04 +0000 |
commit | 0f87f8fd366b0869c001a7d4e8ca6b2e27065e7b (patch) | |
tree | a7085c5810dd8a33456caaf2319c729eb1f8012a /apps/plugins | |
parent | 8d642c302d6eb9d7f94eb8ac6d8388c056c3087e (diff) | |
download | rockbox-0f87f8fd366b0869c001a7d4e8ca6b2e27065e7b.tar.gz rockbox-0f87f8fd366b0869c001a7d4e8ca6b2e27065e7b.zip |
Mandelbrot: * Asm optimisation for arm targets. * Proper aspect for all LCD resolutions. * Keep proper aspect when zooming on targets where LCD_WIDTH and/or LCD_HEIGHT is not an integer multiple of 8.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10498 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/mandelbrot.c | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c index 20baca71db..ba0235b406 100644 --- a/apps/plugins/mandelbrot.c +++ b/apps/plugins/mandelbrot.c | |||
@@ -135,7 +135,7 @@ PLUGIN_HEADER | |||
135 | 135 | ||
136 | static struct plugin_api* rb; | 136 | static struct plugin_api* rb; |
137 | 137 | ||
138 | /* Fixed point format: 6 bits integer part incl. sign, 26 bits fractional part */ | 138 | /* Fixed point format s5.26: sign, 5 bits integer part, 26 bits fractional part */ |
139 | static long x_min; | 139 | static long x_min; |
140 | static long x_max; | 140 | static long x_max; |
141 | static long x_step; | 141 | static long x_step; |
@@ -291,10 +291,30 @@ static inline long muls32_asr26(long a, long b) | |||
291 | return r; | 291 | return r; |
292 | } | 292 | } |
293 | 293 | ||
294 | #elif defined CPU_ARM | ||
295 | |||
296 | #define MULS32_ASR26(a, b) muls32_asr26(a, b) | ||
297 | static inline long muls32_asr26(long a, long b) | ||
298 | { | ||
299 | long r, t1; | ||
300 | asm ( | ||
301 | "smull %[r], %[t1], %[a], %[b] \n" | ||
302 | "mov %[r], %[r], lsr #26 \n" | ||
303 | "orr %[r], %[r], %[t1], lsl #6 \n" | ||
304 | : /* outputs */ | ||
305 | [r] "=&r"(r), | ||
306 | [t1]"=&r"(t1) | ||
307 | : /* inputs */ | ||
308 | [a] "r" (a), | ||
309 | [b] "r" (b) | ||
310 | ); | ||
311 | return r; | ||
312 | } | ||
313 | |||
294 | #endif /* CPU */ | 314 | #endif /* CPU */ |
295 | 315 | ||
296 | /* default macros */ | 316 | /* default macros */ |
297 | #ifndef MULS16_ASR10 | 317 | #ifndef MULS16_ASR10 |
298 | #define MULS16_ASR10(a, b) ((short)(((long)(a) * (long)(b)) >> 10)) | 318 | #define MULS16_ASR10(a, b) ((short)(((long)(a) * (long)(b)) >> 10)) |
299 | #endif | 319 | #endif |
300 | #ifndef MULS32_ASR26 | 320 | #ifndef MULS32_ASR26 |
@@ -327,24 +347,36 @@ int ilog2_fp(long value) /* calculate integer log2(value_fp_6.26) */ | |||
327 | void recalc_parameters(void) | 347 | void recalc_parameters(void) |
328 | { | 348 | { |
329 | x_step = (x_max - x_min) / LCD_WIDTH; | 349 | x_step = (x_max - x_min) / LCD_WIDTH; |
330 | x_delta = x_step * (LCD_WIDTH/8); | 350 | x_delta = (x_step * LCD_WIDTH) / 8; |
331 | y_step = (y_max - y_min) / LCD_HEIGHT; | 351 | y_step = (y_max - y_min) / LCD_HEIGHT; |
332 | y_delta = y_step * (LCD_HEIGHT/8); | 352 | y_delta = (y_step * LCD_HEIGHT) / 8; |
333 | step_log2 = ilog2_fp(MIN(x_step, y_step)); | 353 | step_log2 = ilog2_fp(MIN(x_step, y_step)); |
334 | max_iter = MAX(15, -15 * step_log2 - 45); | 354 | max_iter = MAX(15, -15 * step_log2 - 45); |
335 | } | 355 | } |
336 | 356 | ||
357 | #if CONFIG_LCD == LCD_SSD1815 | ||
358 | /* Recorder, Ondio: pixel_height == 1.25 * pixel_width */ | ||
359 | #define MB_HEIGHT (LCD_HEIGHT*5/4) | ||
360 | #else | ||
361 | /* square pixels */ | ||
362 | #define MB_HEIGHT LCD_HEIGHT | ||
363 | #endif | ||
364 | |||
365 | #define MB_XOFS (-0x03000000L) /* -0.75 (s5.26) */ | ||
366 | #if 3000*MB_HEIGHT/LCD_WIDTH >= 2400 /* width is limiting factor */ | ||
367 | #define MB_XFAC (0x06000000LL) /* 1.5 (s5.26) */ | ||
368 | #define MB_YFAC (MB_XFAC*MB_HEIGHT/LCD_WIDTH) | ||
369 | #else /* height is limiting factor */ | ||
370 | #define MB_YFAC (0x04cccccdLL) /* 1.2 (s5.26) */ | ||
371 | #define MB_XFAC (MB_YFAC*LCD_WIDTH/MB_HEIGHT) | ||
372 | #endif | ||
373 | |||
337 | void init_mandelbrot_set(void) | 374 | void init_mandelbrot_set(void) |
338 | { | 375 | { |
339 | #if CONFIG_LCD == LCD_SSD1815 /* Recorder, Ondio. */ | 376 | x_min = MB_XOFS-MB_XFAC; |
340 | x_min = -38L<<22; /* -2.375<<26 */ | 377 | x_max = MB_XOFS+MB_XFAC; |
341 | x_max = 15L<<22; /* 0.9375<<26 */ | 378 | y_min = -MB_YFAC; |
342 | #else /* all others (square pixels) */ | 379 | y_max = MB_YFAC; |
343 | x_min = -36L<<22; /* -2.25<<26 */ | ||
344 | x_max = 12L<<22; /* 0.75<<26 */ | ||
345 | #endif | ||
346 | y_min = -19L<<22; /* -1.1875<<26 */ | ||
347 | y_max = 19L<<22; /* 1.1875<<26 */ | ||
348 | recalc_parameters(); | 380 | recalc_parameters(); |
349 | } | 381 | } |
350 | 382 | ||