diff options
author | Tomer Shalev <shalev.tomer@gmail.com> | 2010-01-15 05:53:15 +0000 |
---|---|---|
committer | Tomer Shalev <shalev.tomer@gmail.com> | 2010-01-15 05:53:15 +0000 |
commit | 7719d297f2a1da0e45fd39cad21e99e23fd695c8 (patch) | |
tree | ae2b97d1b372340627ca3537554cd45310bace92 /apps/plugins/fractals/cpu_sh7043.c | |
parent | 51630cbac1dcb04345fb1384812f1576f0ea29db (diff) | |
download | rockbox-7719d297f2a1da0e45fd39cad21e99e23fd695c8.tar.gz rockbox-7719d297f2a1da0e45fd39cad21e99e23fd695c8.zip |
FS#10911 - Plugins: Fractals (formerly Mandelbrot)
- Rename the mandelbrot plugin to fractals
- Update manual accordingly
- Separate plugin's functionality into separate files
- Lay the ground for having fractals sets other than the Mandelbrot set.
For that the following will need to be implemented:
- Create a new file for the new fracral set
- Provide key mapping to switch between sets
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24230 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/fractals/cpu_sh7043.c')
-rw-r--r-- | apps/plugins/fractals/cpu_sh7043.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/apps/plugins/fractals/cpu_sh7043.c b/apps/plugins/fractals/cpu_sh7043.c new file mode 100644 index 0000000000..1bce37d654 --- /dev/null +++ b/apps/plugins/fractals/cpu_sh7043.c | |||
@@ -0,0 +1,94 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 Tomer Shalev | ||
11 | * | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | #include "cpu_sh7043.h" | ||
23 | |||
24 | inline short muls16_asr10(short a, short b) | ||
25 | { | ||
26 | short r; | ||
27 | asm ( | ||
28 | "muls %[a],%[b] \n" | ||
29 | "sts macl,%[r] \n" | ||
30 | "shlr8 %[r] \n" | ||
31 | "shlr2 %[r] \n" | ||
32 | : /* outputs */ | ||
33 | [r]"=r"(r) | ||
34 | : /* inputs */ | ||
35 | [a]"r"(a), | ||
36 | [b]"r"(b) | ||
37 | ); | ||
38 | return r; | ||
39 | } | ||
40 | |||
41 | inline long muls32_asr26(long a, long b) | ||
42 | { | ||
43 | long r, t1, t2, t3; | ||
44 | asm ( | ||
45 | /* Signed 32bit * 32bit -> 64bit multiplication. | ||
46 | Notation: xxab * xxcd, where each letter represents 16 bits. | ||
47 | xx is the 64 bit sign extension. */ | ||
48 | "swap.w %[a],%[t1] \n" /* t1 = ba */ | ||
49 | "mulu %[t1],%[b] \n" /* a * d */ | ||
50 | "swap.w %[b],%[t3] \n" /* t3 = dc */ | ||
51 | "sts macl,%[t2] \n" /* t2 = a * d */ | ||
52 | "mulu %[t1],%[t3] \n" /* a * c */ | ||
53 | "sts macl,%[r] \n" /* hi = a * c */ | ||
54 | "mulu %[a],%[t3] \n" /* b * c */ | ||
55 | "clrt \n" | ||
56 | "sts macl,%[t3] \n" /* t3 = b * c */ | ||
57 | "addc %[t2],%[t3] \n" /* t3 += t2, carry -> t2 */ | ||
58 | "movt %[t2] \n" | ||
59 | "mulu %[a],%[b] \n" /* b * d */ | ||
60 | "mov %[t3],%[t1] \n" /* t1t3 = t2t3 << 16 */ | ||
61 | "xtrct %[t2],%[t1] \n" | ||
62 | "shll16 %[t3] \n" | ||
63 | "sts macl,%[t2] \n" /* lo = b * d */ | ||
64 | "clrt \n" /* hi.lo += t1t3 */ | ||
65 | "addc %[t3],%[t2] \n" | ||
66 | "addc %[t1],%[r] \n" | ||
67 | "cmp/pz %[a] \n" /* ab >= 0 ? */ | ||
68 | "bt 1f \n" | ||
69 | "sub %[b],%[r] \n" /* no: hi -= cd (sign extension of ab is -1) */ | ||
70 | "1: \n" | ||
71 | "cmp/pz %[b] \n" /* cd >= 0 ? */ | ||
72 | "bt 2f \n" | ||
73 | "sub %[a],%[r] \n" /* no: hi -= ab (sign extension of cd is -1) */ | ||
74 | "2: \n" | ||
75 | /* Shift right by 26 and return low 32 bits */ | ||
76 | "shll2 %[r] \n" /* hi <<= 6 */ | ||
77 | "shll2 %[r] \n" | ||
78 | "shll2 %[r] \n" | ||
79 | "shlr16 %[t2] \n" /* (unsigned)lo >>= 26 */ | ||
80 | "shlr8 %[t2] \n" | ||
81 | "shlr2 %[t2] \n" | ||
82 | "or %[t2],%[r] \n" /* combine result */ | ||
83 | : /* outputs */ | ||
84 | [r] "=&r"(r), | ||
85 | [t1]"=&r"(t1), | ||
86 | [t2]"=&r"(t2), | ||
87 | [t3]"=&r"(t3) | ||
88 | : /* inputs */ | ||
89 | [a] "r" (a), | ||
90 | [b] "r" (b) | ||
91 | ); | ||
92 | return r; | ||
93 | } | ||
94 | |||