diff options
author | Nils Wallménius <nils@rockbox.org> | 2011-01-18 16:11:33 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2011-01-18 16:11:33 +0000 |
commit | 30918b8d52bd1e45921f0eedd6ffeb09d0aabf69 (patch) | |
tree | d74c54aced3bf37d61e4fb18bc77fd12c4ed12b8 | |
parent | a3591827add989da9ab48978f5d8cd6fae30d204 (diff) | |
download | rockbox-30918b8d52bd1e45921f0eedd6ffeb09d0aabf69.tar.gz rockbox-30918b8d52bd1e45921f0eedd6ffeb09d0aabf69.zip |
abrepeat: drop some inline's and rearrange code to save some size since this stuff is hardly speed critical.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29086 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/abrepeat.c | 56 | ||||
-rw-r--r-- | apps/abrepeat.h | 16 |
2 files changed, 24 insertions, 48 deletions
diff --git a/apps/abrepeat.c b/apps/abrepeat.c index aa37577644..a149069709 100644 --- a/apps/abrepeat.c +++ b/apps/abrepeat.c | |||
@@ -27,6 +27,16 @@ | |||
27 | unsigned int ab_A_marker IDATA_ATTR = AB_MARKER_NONE; | 27 | unsigned int ab_A_marker IDATA_ATTR = AB_MARKER_NONE; |
28 | unsigned int ab_B_marker IDATA_ATTR = AB_MARKER_NONE; | 28 | unsigned int ab_B_marker IDATA_ATTR = AB_MARKER_NONE; |
29 | 29 | ||
30 | static inline bool ab_A_marker_set(void) | ||
31 | { | ||
32 | return ab_A_marker != AB_MARKER_NONE; | ||
33 | } | ||
34 | |||
35 | static inline bool ab_B_marker_set(void) | ||
36 | { | ||
37 | return ab_B_marker != AB_MARKER_NONE; | ||
38 | } | ||
39 | |||
30 | #if (CONFIG_CODEC == SWCODEC) | 40 | #if (CONFIG_CODEC == SWCODEC) |
31 | void ab_end_of_track_report(void) | 41 | void ab_end_of_track_report(void) |
32 | { | 42 | { |
@@ -81,18 +91,6 @@ void ab_repeat_init(void) | |||
81 | } | 91 | } |
82 | } | 92 | } |
83 | 93 | ||
84 | #if 0 /* Currently unused */ | ||
85 | unsigned int ab_get_A_marker(void) | ||
86 | { | ||
87 | return ab_A_marker; | ||
88 | } | ||
89 | |||
90 | unsigned int ab_get_B_marker(void) | ||
91 | { | ||
92 | return ab_B_marker; | ||
93 | } | ||
94 | #endif /* if 0 */ | ||
95 | |||
96 | /* determines if the given song position is earlier than the A mark; | 94 | /* determines if the given song position is earlier than the A mark; |
97 | intended for use in handling the jump NEXT and PREV commands */ | 95 | intended for use in handling the jump NEXT and PREV commands */ |
98 | bool ab_before_A_marker(unsigned int song_position) | 96 | bool ab_before_A_marker(unsigned int song_position) |
@@ -162,13 +160,13 @@ void ab_set_B_marker(unsigned int song_position) | |||
162 | 160 | ||
163 | #ifdef HAVE_LCD_BITMAP | 161 | #ifdef HAVE_LCD_BITMAP |
164 | 162 | ||
165 | static inline int ab_calc_mark_x_pos(int mark, int capacity, | 163 | static int ab_calc_mark_x_pos(int mark, int capacity, |
166 | int offset, int size) | 164 | int offset, int size) |
167 | { | 165 | { |
168 | return offset + ( (size * mark) / capacity ); | 166 | return offset + ( (size * mark) / capacity ); |
169 | } | 167 | } |
170 | 168 | ||
171 | static inline void ab_draw_vertical_line_mark(struct screen * screen, | 169 | static void ab_draw_vertical_line_mark(struct screen * screen, |
172 | int x, int y, int h) | 170 | int x, int y, int h) |
173 | { | 171 | { |
174 | screen->set_drawmode(DRMODE_COMPLEMENT); | 172 | screen->set_drawmode(DRMODE_COMPLEMENT); |
@@ -178,7 +176,7 @@ static inline void ab_draw_vertical_line_mark(struct screen * screen, | |||
178 | #define DIRECTION_RIGHT 1 | 176 | #define DIRECTION_RIGHT 1 |
179 | #define DIRECTION_LEFT -1 | 177 | #define DIRECTION_LEFT -1 |
180 | 178 | ||
181 | static inline void ab_draw_arrow_mark(struct screen * screen, | 179 | static void ab_draw_arrow_mark(struct screen * screen, |
182 | int x, int y, int h, int direction) | 180 | int x, int y, int h, int direction) |
183 | { | 181 | { |
184 | /* draw lines in decreasing size until a height of zero is reached */ | 182 | /* draw lines in decreasing size until a height of zero is reached */ |
@@ -196,36 +194,28 @@ static inline void ab_draw_arrow_mark(struct screen * screen, | |||
196 | void ab_draw_markers(struct screen * screen, int capacity, | 194 | void ab_draw_markers(struct screen * screen, int capacity, |
197 | int x, int y, int w, int h) | 195 | int x, int y, int w, int h) |
198 | { | 196 | { |
197 | int xa = ab_calc_mark_x_pos(ab_A_marker, capacity, x, w); | ||
198 | int xb = ab_calc_mark_x_pos(ab_B_marker, capacity, x, w); | ||
199 | /* if both markers are set, determine if they're far enough apart | 199 | /* if both markers are set, determine if they're far enough apart |
200 | to draw arrows */ | 200 | to draw arrows */ |
201 | if ( ab_A_marker_set() && ab_B_marker_set() ) | 201 | if ( ab_A_marker_set() && ab_B_marker_set() ) |
202 | { | 202 | { |
203 | int xa = ab_calc_mark_x_pos(ab_A_marker, capacity, x, w); | ||
204 | int xb = ab_calc_mark_x_pos(ab_B_marker, capacity, x, w); | ||
205 | int arrow_width = (h+1) / 2; | 203 | int arrow_width = (h+1) / 2; |
206 | if ( (xb-xa) < (arrow_width*2) ) | 204 | if ( (xb-xa) < (arrow_width*2) ) |
207 | { | 205 | { |
208 | ab_draw_vertical_line_mark(screen, xa, y, h); | 206 | ab_draw_vertical_line_mark(screen, xa, y, h); |
209 | ab_draw_vertical_line_mark(screen, xb, y, h); | 207 | ab_draw_vertical_line_mark(screen, xb, y, h); |
210 | } | 208 | return; |
211 | else | ||
212 | { | ||
213 | ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT); | ||
214 | ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT); | ||
215 | } | 209 | } |
216 | } | 210 | } |
217 | else | 211 | |
212 | if (ab_A_marker_set()) | ||
218 | { | 213 | { |
219 | if (ab_A_marker_set()) | 214 | ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT); |
220 | { | 215 | } |
221 | int xa = ab_calc_mark_x_pos(ab_A_marker, capacity, x, w); | 216 | if (ab_B_marker_set()) |
222 | ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT); | 217 | { |
223 | } | 218 | ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT); |
224 | if (ab_B_marker_set()) | ||
225 | { | ||
226 | int xb = ab_calc_mark_x_pos(ab_B_marker, capacity, x, w); | ||
227 | ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT); | ||
228 | } | ||
229 | } | 219 | } |
230 | } | 220 | } |
231 | 221 | ||
diff --git a/apps/abrepeat.h b/apps/abrepeat.h index 8d5ea9dd66..49557a34b7 100644 --- a/apps/abrepeat.h +++ b/apps/abrepeat.h | |||
@@ -30,11 +30,7 @@ | |||
30 | 30 | ||
31 | #include "settings.h" | 31 | #include "settings.h" |
32 | 32 | ||
33 | void ab_repeat_init(void); | 33 | void ab_repeat_init(void); |
34 | #if 0 /* Currently unused */ | ||
35 | unsigned int ab_get_A_marker(void); | ||
36 | unsigned int ab_get_B_marker(void); | ||
37 | #endif /* if 0 */ | ||
38 | bool ab_before_A_marker(unsigned int song_position); | 34 | bool ab_before_A_marker(unsigned int song_position); |
39 | bool ab_after_A_marker(unsigned int song_position); | 35 | bool ab_after_A_marker(unsigned int song_position); |
40 | void ab_jump_to_A_marker(void); | 36 | void ab_jump_to_A_marker(void); |
@@ -54,16 +50,6 @@ void ab_draw_markers(struct screen * screen, int capacity, | |||
54 | extern unsigned int ab_A_marker; | 50 | extern unsigned int ab_A_marker; |
55 | extern unsigned int ab_B_marker; | 51 | extern unsigned int ab_B_marker; |
56 | 52 | ||
57 | static inline bool ab_A_marker_set(void) | ||
58 | { | ||
59 | return ab_A_marker != AB_MARKER_NONE; | ||
60 | } | ||
61 | |||
62 | static inline bool ab_B_marker_set(void) | ||
63 | { | ||
64 | return ab_B_marker != AB_MARKER_NONE; | ||
65 | } | ||
66 | |||
67 | static inline bool ab_repeat_mode_enabled(void) | 53 | static inline bool ab_repeat_mode_enabled(void) |
68 | { | 54 | { |
69 | return global_settings.repeat_mode == REPEAT_AB; | 55 | return global_settings.repeat_mode == REPEAT_AB; |