summaryrefslogtreecommitdiffstats
path: root/tools/checkwps/checkwps.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-09-13 13:40:58 +0000
committerThomas Martitz <kugel@rockbox.org>2009-09-13 13:40:58 +0000
commitc0f1c49178b4c205e1c990ea2fb25a417305528c (patch)
tree637fdedd15f2119125cdaa257fbf7798e8687e74 /tools/checkwps/checkwps.c
parent541dd6fda5ae93073a0b9c499f62af2cf46f3529 (diff)
downloadrockbox-c0f1c49178b4c205e1c990ea2fb25a417305528c.tar.gz
rockbox-c0f1c49178b4c205e1c990ea2fb25a417305528c.tar.bz2
rockbox-c0f1c49178b4c205e1c990ea2fb25a417305528c.zip
Get rid of some of the code duplication from checkwps, it still duplicates a lot though.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22695 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/checkwps/checkwps.c')
-rw-r--r--tools/checkwps/checkwps.c120
1 files changed, 1 insertions, 119 deletions
diff --git a/tools/checkwps/checkwps.c b/tools/checkwps/checkwps.c
index 6e985195fb..079454def1 100644
--- a/tools/checkwps/checkwps.c
+++ b/tools/checkwps/checkwps.c
@@ -28,6 +28,7 @@
#include "wps.h"
#include "wps_internals.h"
#include "settings.h"
+#include "viewport.h"
bool debug_wps = true;
int wps_verbose_level = 0;
@@ -294,125 +295,6 @@ struct skin_viewport* find_viewport(char label, struct wps_data *data)
return NULL;
}
-/* From viewport.c & misc.h */
-#define LIST_VALUE_PARSED(setvals, position) ((setvals) & BIT_N(position))
-
-/*some short cuts for fg/bg/line selector handling */
-#ifdef HAVE_LCD_COLOR
-#define LINE_SEL_FROM_SETTINGS(vp) \
- do { \
- vp->lss_pattern = global_settings.lss_color; \
- vp->lse_pattern = global_settings.lse_color; \
- vp->lst_pattern = global_settings.lst_color; \
- } while (0)
-#define FG_FALLBACK global_settings.fg_color
-#define BG_FALLBACK global_settings.bg_color
-#else
-/* mono/greyscale doesn't have most of the above */
-#define LINE_SEL_FROM_SETTINGS(vp)
-#define FG_FALLBACK LCD_DEFAULT_FG
-#define BG_FALLBACK LCD_DEFAULT_BG
-#endif
-
-#ifdef HAVE_LCD_COLOR
-#define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc")
-#else
-#define ARG_STRING(_depth) "dddddgg"
-#endif
-
-extern const char* parse_list(const char *fmt, uint32_t *set_vals,
- const char sep, const char* str, ...);
-
-const char* viewport_parse_viewport(struct viewport *vp,
- enum screen_type screen,
- const char *bufptr,
- const char separator)
-{
- /* parse the list to the viewport struct */
- const char *ptr = bufptr;
- int depth;
- uint32_t set = 0;
-
- enum {
- PL_X = 0,
- PL_Y,
- PL_WIDTH,
- PL_HEIGHT,
- PL_FONT,
- PL_FG,
- PL_BG,
- };
-
- /* Work out the depth of this display */
- depth = screens[screen].depth;
-#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1)
- if (depth == 1)
- {
-#ifdef HAVE_LCD_BITMAP
- if (!(ptr = parse_list("ddddd", &set, separator, ptr,
- &vp->x, &vp->y, &vp->width, &vp->height, &vp->font)))
- return NULL;
-#endif
- }
- else
-#endif
-#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
- if (depth >= 2)
- {
- if (!(ptr = parse_list(ARG_STRING(depth), &set, separator, ptr,
- &vp->x, &vp->y, &vp->width, &vp->height, &vp->font,
- &vp->fg_pattern,&vp->bg_pattern)))
- return NULL;
- }
- else
-#endif
- {}
-#undef ARG_STRING
-
- /* X and Y *must* be set */
- if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y))
- return NULL;
-
- /* fix defaults */
- if (!LIST_VALUE_PARSED(set, PL_WIDTH))
- vp->width = screens[screen].lcdwidth - vp->x;
- if (!LIST_VALUE_PARSED(set, PL_HEIGHT))
- vp->height = screens[screen].lcdheight - vp->y;
-
-#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
- if (!LIST_VALUE_PARSED(set, PL_FG))
- vp->fg_pattern = FG_FALLBACK;
- if (!LIST_VALUE_PARSED(set, PL_BG))
- vp->bg_pattern = BG_FALLBACK;
-#endif /* LCD_DEPTH > 1 || LCD_REMOTE_DEPTH > 1 */
-
- LINE_SEL_FROM_SETTINGS(vp);
-
- /* Validate the viewport dimensions - we know that the numbers are
- non-negative integers, ignore bars and assume the viewport takes them
- * into account */
- if ((vp->x >= screens[screen].lcdwidth) ||
- ((vp->x + vp->width) > screens[screen].lcdwidth) ||
- (vp->y >= screens[screen].lcdheight) ||
- ((vp->y + vp->height) > screens[screen].lcdheight))
- {
- return NULL;
- }
-
-#ifdef HAVE_LCD_BITMAP
- /* Default to using the user font if the font was an invalid number or '-'*/
- if (((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI))
- || !LIST_VALUE_PARSED(set, PL_FONT)
- )
- vp->font = FONT_UI;
-
- /* Set the defaults for fields not user-specified */
- vp->drawmode = DRMODE_SOLID;
-#endif
-
- return ptr;
-}
-
int main(int argc, char **argv)
{
int res;