summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/abrepeat.c56
-rw-r--r--apps/abrepeat.h16
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 @@
27unsigned int ab_A_marker IDATA_ATTR = AB_MARKER_NONE; 27unsigned int ab_A_marker IDATA_ATTR = AB_MARKER_NONE;
28unsigned int ab_B_marker IDATA_ATTR = AB_MARKER_NONE; 28unsigned int ab_B_marker IDATA_ATTR = AB_MARKER_NONE;
29 29
30static inline bool ab_A_marker_set(void)
31{
32 return ab_A_marker != AB_MARKER_NONE;
33}
34
35static 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)
31void ab_end_of_track_report(void) 41void 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 */
85unsigned int ab_get_A_marker(void)
86{
87 return ab_A_marker;
88}
89
90unsigned 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;
97intended for use in handling the jump NEXT and PREV commands */ 95intended for use in handling the jump NEXT and PREV commands */
98bool ab_before_A_marker(unsigned int song_position) 96bool 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
165static inline int ab_calc_mark_x_pos(int mark, int capacity, 163static 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
171static inline void ab_draw_vertical_line_mark(struct screen * screen, 169static 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
181static inline void ab_draw_arrow_mark(struct screen * screen, 179static 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,
196void ab_draw_markers(struct screen * screen, int capacity, 194void 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
33void ab_repeat_init(void); 33void ab_repeat_init(void);
34#if 0 /* Currently unused */
35unsigned int ab_get_A_marker(void);
36unsigned int ab_get_B_marker(void);
37#endif /* if 0 */
38bool ab_before_A_marker(unsigned int song_position); 34bool ab_before_A_marker(unsigned int song_position);
39bool ab_after_A_marker(unsigned int song_position); 35bool ab_after_A_marker(unsigned int song_position);
40void ab_jump_to_A_marker(void); 36void ab_jump_to_A_marker(void);
@@ -54,16 +50,6 @@ void ab_draw_markers(struct screen * screen, int capacity,
54extern unsigned int ab_A_marker; 50extern unsigned int ab_A_marker;
55extern unsigned int ab_B_marker; 51extern unsigned int ab_B_marker;
56 52
57static inline bool ab_A_marker_set(void)
58{
59 return ab_A_marker != AB_MARKER_NONE;
60}
61
62static inline bool ab_B_marker_set(void)
63{
64 return ab_B_marker != AB_MARKER_NONE;
65}
66
67static inline bool ab_repeat_mode_enabled(void) 53static 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;