summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/lcd-16bit-common.c42
-rw-r--r--firmware/drivers/lcd-1bit-vert.c43
-rw-r--r--firmware/drivers/lcd-2bit-horz.c46
-rw-r--r--firmware/drivers/lcd-2bit-vert.c47
-rw-r--r--firmware/drivers/lcd-2bit-vi.c46
-rw-r--r--firmware/drivers/lcd-bitmap-common.c48
6 files changed, 48 insertions, 224 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index 423ea183dc..f8673ec6db 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -68,48 +68,6 @@ void lcd_init(void)
lcd_init_device();
scroll_init();
}
-/*** Viewports ***/
-
-void lcd_set_viewport(struct viewport* vp)
-{
- if (vp == NULL)
- current_vp = &default_vp;
- else
- current_vp = vp;
-
-#if defined(SIMULATOR)
- /* Force the viewport to be within bounds. If this happens it should
- * be considered an error - the viewport will not draw as it might be
- * expected.
- */
- if((unsigned) current_vp->x > (unsigned) LCD_WIDTH
- || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT
- || current_vp->x + current_vp->width > LCD_WIDTH
- || current_vp->y + current_vp->height > LCD_HEIGHT)
- {
-#if !defined(HAVE_VIEWPORT_CLIP)
- DEBUGF("ERROR: "
-#else
- DEBUGF("NOTE: "
-#endif
- "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
- current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
- }
-
-#endif
-}
-
-void lcd_update_viewport(void)
-{
- lcd_update_rect(current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
-}
-
-void lcd_update_viewport_rect(int x, int y, int width, int height)
-{
- lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height);
-}
/* Clear the current viewport */
void lcd_clear_viewport(void)
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c
index 3a90856819..5cacf0a740 100644
--- a/firmware/drivers/lcd-1bit-vert.c
+++ b/firmware/drivers/lcd-1bit-vert.c
@@ -60,49 +60,6 @@ static struct viewport default_vp =
static struct viewport* current_vp = &default_vp;
-/*** Viewports ***/
-
-void LCDFN(set_viewport)(struct viewport* vp)
-{
- if (vp == NULL)
- current_vp = &default_vp;
- else
- current_vp = vp;
-
-#if defined(SIMULATOR)
- /* Force the viewport to be within bounds. If this happens it should
- * be considered an error - the viewport will not draw as it might be
- * expected.
- */
- if((unsigned) current_vp->x > (unsigned) LCDM(WIDTH)
- || (unsigned) current_vp->y > (unsigned) LCDM(HEIGHT)
- || current_vp->x + current_vp->width > LCDM(WIDTH)
- || current_vp->y + current_vp->height > LCDM(HEIGHT))
- {
-#if !defined(HAVE_VIEWPORT_CLIP)
- DEBUGF("ERROR: "
-#else
- DEBUGF("NOTE: "
-#endif
- "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
- current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
- }
-
-#endif
-}
-
-void LCDFN(update_viewport)(void)
-{
- LCDFN(update_rect)(current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
-}
-
-void LCDFN(update_viewport_rect)(int x, int y, int width, int height)
-{
- LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height);
-}
-
/* LCD init */
void LCDFN(init)(void)
{
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c
index 3870bac644..267a22db3f 100644
--- a/firmware/drivers/lcd-2bit-horz.c
+++ b/firmware/drivers/lcd-2bit-horz.c
@@ -77,52 +77,6 @@ void lcd_init(void)
scroll_init();
}
-/*** Viewports ***/
-
-void lcd_set_viewport(struct viewport* vp)
-{
- if (vp == NULL)
- current_vp = &default_vp;
- else
- current_vp = vp;
-
- fg_pattern = 0x55 * (~current_vp->fg_pattern & 3);
- bg_pattern = 0x55 * (~current_vp->bg_pattern & 3);
-
-#if defined(SIMULATOR)
- /* Force the viewport to be within bounds. If this happens it should
- * be considered an error - the viewport will not draw as it might be
- * expected.
- */
- if((unsigned) current_vp->x > (unsigned) LCD_WIDTH
- || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT
- || current_vp->x + current_vp->width > LCD_WIDTH
- || current_vp->y + current_vp->height > LCD_HEIGHT)
- {
-#if !defined(HAVE_VIEWPORT_CLIP)
- DEBUGF("ERROR: "
-#else
- DEBUGF("NOTE: "
-#endif
- "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
- current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
- }
-
-#endif
-}
-
-void lcd_update_viewport(void)
-{
- lcd_update_rect(current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
-}
-
-void lcd_update_viewport_rect(int x, int y, int width, int height)
-{
- lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height);
-}
-
/*** parameter handling ***/
void lcd_set_drawmode(int mode)
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c
index 89c2dc365b..08ec6cac79 100644
--- a/firmware/drivers/lcd-2bit-vert.c
+++ b/firmware/drivers/lcd-2bit-vert.c
@@ -79,53 +79,6 @@ void lcd_init(void)
scroll_init();
}
-/*** Viewports ***/
-
-void lcd_set_viewport(struct viewport* vp)
-{
- if (vp == NULL)
- current_vp = &default_vp;
- else
- current_vp = vp;
-
- fg_pattern = 0x55 * (~current_vp->fg_pattern & 3);
- bg_pattern = 0x55 * (~current_vp->bg_pattern & 3);
-
-#if defined(SIMULATOR)
- /* Force the viewport to be within bounds. If this happens it should
- * be considered an error - the viewport will not draw as it might be
- * expected.
- */
- if((unsigned) current_vp->x > (unsigned) LCD_WIDTH
- || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT
- || current_vp->x + current_vp->width > LCD_WIDTH
- || current_vp->y + current_vp->height > LCD_HEIGHT)
- {
-#if !defined(HAVE_VIEWPORT_CLIP)
- DEBUGF("ERROR: "
-#else
- DEBUGF("NOTE: "
-#endif
- "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
- current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
- }
-
-#endif
-}
-
-void lcd_update_viewport(void)
-{
- lcd_update_rect(current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
-}
-
-void lcd_update_viewport_rect(int x, int y, int width, int height)
-{
- lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height);
-}
-
-
/*** parameter handling ***/
void lcd_set_drawmode(int mode)
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c
index 8dc746f521..b0c41e4fa9 100644
--- a/firmware/drivers/lcd-2bit-vi.c
+++ b/firmware/drivers/lcd-2bit-vi.c
@@ -74,52 +74,6 @@ static struct viewport * current_vp IBSS_ATTR;
static unsigned fg_pattern IBSS_ATTR;
static unsigned bg_pattern IBSS_ATTR;
-/*** Viewports ***/
-
-void LCDFN(set_viewport)(struct viewport* vp)
-{
- if (vp == NULL)
- current_vp = &default_vp;
- else
- current_vp = vp;
-
- fg_pattern = patterns[current_vp->fg_pattern & 3];
- bg_pattern = patterns[current_vp->bg_pattern & 3];
-
-#if defined(SIMULATOR)
- /* Force the viewport to be within bounds. If this happens it should
- * be considered an error - the viewport will not draw as it might be
- * expected.
- */
- if((unsigned) current_vp->x > (unsigned) LCDM(WIDTH)
- || (unsigned) current_vp->y > (unsigned) LCDM(HEIGHT)
- || current_vp->x + current_vp->width > LCDM(WIDTH)
- || current_vp->y + current_vp->height > LCDM(HEIGHT))
- {
-#if !defined(HAVE_VIEWPORT_CLIP)
- DEBUGF("ERROR: "
-#else
- DEBUGF("NOTE: "
-#endif
- "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
- current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
- }
-
-#endif
-}
-
-void LCDFN(update_viewport)(void)
-{
- LCDFN(update_rect)(current_vp->x, current_vp->y,
- current_vp->width, current_vp->height);
-}
-
-void LCDFN(update_viewport_rect)(int x, int y, int width, int height)
-{
- LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height);
-}
-
/* LCD init */
void LCDFN(init)(void)
{
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index a149e8aaa9..a17ac51006 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -141,6 +141,54 @@ void LCDFN(fill_viewport)(void)
LCDFN(fillrect)(0, 0, current_vp->width, current_vp->height);
}
+
+/*** Viewports ***/
+
+void LCDFN(set_viewport)(struct viewport* vp)
+{
+ if (vp == NULL)
+ current_vp = &default_vp;
+ else
+ current_vp = vp;
+
+#if LCDM(DEPTH) > 1
+ LCDFN(set_foreground)(current_vp->fg_pattern);
+ LCDFN(set_background)(current_vp->bg_pattern);
+#endif
+
+#if defined(SIMULATOR)
+ /* Force the viewport to be within bounds. If this happens it should
+ * be considered an error - the viewport will not draw as it might be
+ * expected.
+ */
+ if((unsigned) current_vp->x > (unsigned) LCDM(WIDTH)
+ || (unsigned) current_vp->y > (unsigned) LCDM(HEIGHT)
+ || current_vp->x + current_vp->width > LCDM(WIDTH)
+ || current_vp->y + current_vp->height > LCDM(HEIGHT))
+ {
+#if !defined(HAVE_VIEWPORT_CLIP)
+ DEBUGF("ERROR: "
+#else
+ DEBUGF("NOTE: "
+#endif
+ "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
+ current_vp->x, current_vp->y,
+ current_vp->width, current_vp->height);
+ }
+#endif
+}
+
+void LCDFN(update_viewport)(void)
+{
+ LCDFN(update_rect)(current_vp->x, current_vp->y,
+ current_vp->width, current_vp->height);
+}
+
+void LCDFN(update_viewport_rect)(int x, int y, int width, int height)
+{
+ LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height);
+}
+
/* put a string at a given pixel position, skipping first ofs pixel columns */
static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{