diff options
Diffstat (limited to 'apps/abrepeat.c')
-rw-r--r-- | apps/abrepeat.c | 56 |
1 files changed, 23 insertions, 33 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 | ||