diff options
Diffstat (limited to 'apps/abrepeat.c')
-rw-r--r-- | apps/abrepeat.c | 65 |
1 files changed, 8 insertions, 57 deletions
diff --git a/apps/abrepeat.c b/apps/abrepeat.c index a149069709..999d9dcf38 100644 --- a/apps/abrepeat.c +++ b/apps/abrepeat.c | |||
@@ -27,6 +27,7 @@ | |||
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 | |||
30 | static inline bool ab_A_marker_set(void) | 31 | static inline bool ab_A_marker_set(void) |
31 | { | 32 | { |
32 | return ab_A_marker != AB_MARKER_NONE; | 33 | return ab_A_marker != AB_MARKER_NONE; |
@@ -37,6 +38,7 @@ static inline bool ab_B_marker_set(void) | |||
37 | return ab_B_marker != AB_MARKER_NONE; | 38 | return ab_B_marker != AB_MARKER_NONE; |
38 | } | 39 | } |
39 | 40 | ||
41 | |||
40 | #if (CONFIG_CODEC == SWCODEC) | 42 | #if (CONFIG_CODEC == SWCODEC) |
41 | void ab_end_of_track_report(void) | 43 | void ab_end_of_track_report(void) |
42 | { | 44 | { |
@@ -158,67 +160,16 @@ void ab_set_B_marker(unsigned int song_position) | |||
158 | ab_A_marker = AB_MARKER_NONE; | 160 | ab_A_marker = AB_MARKER_NONE; |
159 | } | 161 | } |
160 | 162 | ||
161 | #ifdef HAVE_LCD_BITMAP | 163 | bool ab_get_A_marker(unsigned *song_position) |
162 | |||
163 | static int ab_calc_mark_x_pos(int mark, int capacity, | ||
164 | int offset, int size) | ||
165 | { | ||
166 | return offset + ( (size * mark) / capacity ); | ||
167 | } | ||
168 | |||
169 | static void ab_draw_vertical_line_mark(struct screen * screen, | ||
170 | int x, int y, int h) | ||
171 | { | 164 | { |
172 | screen->set_drawmode(DRMODE_COMPLEMENT); | 165 | *song_position = ab_A_marker; |
173 | screen->vline(x, y, y+h-1); | 166 | return ab_A_marker_set(); |
174 | } | ||
175 | |||
176 | #define DIRECTION_RIGHT 1 | ||
177 | #define DIRECTION_LEFT -1 | ||
178 | |||
179 | static void ab_draw_arrow_mark(struct screen * screen, | ||
180 | int x, int y, int h, int direction) | ||
181 | { | ||
182 | /* draw lines in decreasing size until a height of zero is reached */ | ||
183 | screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
184 | while( h > 0 ) | ||
185 | { | ||
186 | screen->vline(x, y, y+h-1); | ||
187 | h -= 2; | ||
188 | y++; | ||
189 | x += direction; | ||
190 | screen->set_drawmode(DRMODE_COMPLEMENT); | ||
191 | } | ||
192 | } | 167 | } |
193 | 168 | ||
194 | void ab_draw_markers(struct screen * screen, int capacity, | 169 | bool ab_get_B_marker(unsigned *song_position) |
195 | int x, int y, int w, int h) | ||
196 | { | 170 | { |
197 | int xa = ab_calc_mark_x_pos(ab_A_marker, capacity, x, w); | 171 | *song_position = ab_B_marker; |
198 | int xb = ab_calc_mark_x_pos(ab_B_marker, capacity, x, w); | 172 | return ab_B_marker_set(); |
199 | /* if both markers are set, determine if they're far enough apart | ||
200 | to draw arrows */ | ||
201 | if ( ab_A_marker_set() && ab_B_marker_set() ) | ||
202 | { | ||
203 | int arrow_width = (h+1) / 2; | ||
204 | if ( (xb-xa) < (arrow_width*2) ) | ||
205 | { | ||
206 | ab_draw_vertical_line_mark(screen, xa, y, h); | ||
207 | ab_draw_vertical_line_mark(screen, xb, y, h); | ||
208 | return; | ||
209 | } | ||
210 | } | ||
211 | |||
212 | if (ab_A_marker_set()) | ||
213 | { | ||
214 | ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT); | ||
215 | } | ||
216 | if (ab_B_marker_set()) | ||
217 | { | ||
218 | ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT); | ||
219 | } | ||
220 | } | 173 | } |
221 | 174 | ||
222 | #endif /* HAVE_LCD_BITMAP */ | ||
223 | |||
224 | #endif /* AB_REPEAT_ENABLE */ | 175 | #endif /* AB_REPEAT_ENABLE */ |