summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Everton <dan@iocaine.org>2006-02-09 21:49:28 +0000
committerDan Everton <dan@iocaine.org>2006-02-09 21:49:28 +0000
commitb585e87b454917f0424541a34c0b41b1fe83f694 (patch)
treef93652b42b4791ce4f8b64421a1a063c58e511b0
parentf42f42e5543f18d11142bb98e3c8677a04b99318 (diff)
downloadrockbox-b585e87b454917f0424541a34c0b41b1fe83f694.tar.gz
rockbox-b585e87b454917f0424541a34c0b41b1fe83f694.zip
Refactor SDL sim source so drawing routines are written once. Split bitmap, remote, and charcell LCD in to their own files. Add zoom support, use --zoom factor (e.g. --zoom 2 for two times zoom) to use it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8645 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--uisimulator/common/lcd-playersim.c2
-rw-r--r--uisimulator/sdl/SOURCES8
-rw-r--r--uisimulator/sdl/lcd-bitmap.c79
-rw-r--r--uisimulator/sdl/lcd-bitmap.h29
-rw-r--r--uisimulator/sdl/lcd-charcell.c115
-rw-r--r--uisimulator/sdl/lcd-charcell.h29
-rw-r--r--uisimulator/sdl/lcd-remote.c57
-rw-r--r--uisimulator/sdl/lcd-remote.h29
-rw-r--r--uisimulator/sdl/lcd-sdl.c297
-rw-r--r--uisimulator/sdl/lcd-sdl.h18
-rw-r--r--uisimulator/sdl/thread-sdl.h7
-rw-r--r--uisimulator/sdl/uisdl.c38
-rw-r--r--uisimulator/sdl/uisdl.h9
13 files changed, 431 insertions, 286 deletions
diff --git a/uisimulator/common/lcd-playersim.c b/uisimulator/common/lcd-playersim.c
index ea5b1da2f4..156f83e639 100644
--- a/uisimulator/common/lcd-playersim.c
+++ b/uisimulator/common/lcd-playersim.c
@@ -35,7 +35,7 @@
#define CHAR_WIDTH 6
#define CHAR_HEIGHT 8
#define ICON_HEIGHT 24
-#define CHAR_PIXEL 4
+#define CHAR_PIXEL 2
#define BORDER_MARGIN 2
static int double_height=1;
diff --git a/uisimulator/sdl/SOURCES b/uisimulator/sdl/SOURCES
index cbb39a4e6a..41890048de 100644
--- a/uisimulator/sdl/SOURCES
+++ b/uisimulator/sdl/SOURCES
@@ -1,5 +1,13 @@
button.c
kernel.c
+#ifdef HAVE_LCD_BITMAP
+lcd-bitmap.c
+#elif HAVE_LCD_CHARCELLS
+lcd-charcell.c
+#endif
+#ifdef HAVE_REMOTE_LCD
+lcd-remote.c
+#endif
lcd-sdl.c
sound.c
thread-sdl.c
diff --git a/uisimulator/sdl/lcd-bitmap.c b/uisimulator/sdl/lcd-bitmap.c
new file mode 100644
index 0000000000..db4a98d823
--- /dev/null
+++ b/uisimulator/sdl/lcd-bitmap.c
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "uisdl.h"
+#include "lcd-sdl.h"
+
+SDL_Surface* lcd_surface;
+
+#if LCD_DEPTH <= 8
+SDL_Color lcd_color_zero = {UI_LCD_BGCOLORLIGHT, 0};
+SDL_Color lcd_color_max = {0, 0, 0, 0};
+#endif
+
+static inline Uint32 get_lcd_pixel(int x, int y)
+{
+#if LCD_DEPTH == 1
+ return ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
+#elif LCD_DEPTH == 2
+#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
+ return ((lcd_framebuffer[y][x/4] >> (2 * (x & 3))) & 3);
+#else
+ return ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
+#endif
+#elif LCD_DEPTH == 16
+#if LCD_PIXELFORMAT == RGB565SWAPPED
+ unsigned bits = lcd_framebuffer[y][x];
+ return (bits >> 8) | (bits << 8);
+#else
+ return lcd_framebuffer[y][x];
+#endif
+#endif
+}
+
+void lcd_update(void)
+{
+ /* update a full screen rect */
+ lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
+}
+
+void lcd_update_rect(int x_start, int y_start, int width, int height)
+{
+ sdl_update_rect(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, LCD_HEIGHT,
+ background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0,
+ get_lcd_pixel);
+}
+
+
+/* initialise simulator lcd driver */
+void sim_lcd_init(void)
+{
+#if LCD_DEPTH == 16
+ lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom,
+ LCD_HEIGHT * display_zoom, LCD_DEPTH, 0, 0, 0, 0);
+#else
+ lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom,
+ LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0);
+#endif
+
+#if LCD_DEPTH <= 8
+ sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, (1<<LCD_DEPTH));
+#endif
+}
+
diff --git a/uisimulator/sdl/lcd-bitmap.h b/uisimulator/sdl/lcd-bitmap.h
new file mode 100644
index 0000000000..514c4d3ffb
--- /dev/null
+++ b/uisimulator/sdl/lcd-bitmap.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __LCDBITMAP_H__
+#define __LCDBITMAP_H__
+
+#include "lcd.h"
+#include "SDL.h"
+
+void sim_lcd_init(void);
+
+#endif // #ifndef __LCDBITMAP_H__
+
diff --git a/uisimulator/sdl/lcd-charcell.c b/uisimulator/sdl/lcd-charcell.c
new file mode 100644
index 0000000000..5f51e44810
--- /dev/null
+++ b/uisimulator/sdl/lcd-charcell.c
@@ -0,0 +1,115 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "lcd.h"
+#include "lcd-playersim.h"
+#include "uisdl.h"
+#include "lcd-sdl.h"
+
+SDL_Surface* lcd_surface;
+SDL_Color lcd_color_zero = {UI_LCD_BGCOLORLIGHT, 0};
+SDL_Color lcd_color_max = {0, 0, 0, 0};
+
+/* Defined in lcd-playersim.c */
+extern void lcd_print_char(int x, int y);
+
+void lcd_update(void)
+{
+ int x, y;
+ SDL_Rect dest = {UI_LCD_POSX, UI_LCD_POSY, UI_LCD_WIDTH, UI_LCD_HEIGHT};
+
+ SDL_LockSurface(lcd_surface);
+
+ for (y=0; y<2; y++) {
+ for (x=0; x<11; x++) {
+ lcd_print_char(x, y);
+ }
+ }
+
+ SDL_UnlockSurface(lcd_surface);
+
+ if (!background) {
+ dest.x -= UI_LCD_POSX;
+ dest.y -= UI_LCD_POSY;
+ }
+
+ SDL_BlitSurface(lcd_surface, NULL, gui_surface, &dest);
+ SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
+ SDL_Flip(gui_surface);
+}
+
+void drawdots(int color, struct coordinate *points, int count)
+{
+ SDL_Rect dest;
+ Uint32 sdlcolor;
+
+ SDL_LockSurface(lcd_surface);
+
+ if (color == 1) {
+ sdlcolor = SDL_MapRGB(lcd_surface->format, lcd_color_max.r, lcd_color_max.g, lcd_color_max.b);
+ } else {
+ sdlcolor = SDL_MapRGB(lcd_surface->format, lcd_color_zero.r, lcd_color_zero.g, lcd_color_zero.b);
+ }
+
+ while (count--) {
+ dest.x = points[count].x * display_zoom;
+ dest.y = points[count].y * display_zoom;
+ dest.w = 1 * display_zoom;
+ dest.h = 1 * display_zoom;
+
+ SDL_FillRect(lcd_surface, &dest, sdlcolor);
+ }
+
+ SDL_UnlockSurface(lcd_surface);
+}
+
+void drawrectangles(int color, struct rectangle *points, int count)
+{
+ SDL_Rect dest;
+ Uint32 sdlcolor;
+
+ SDL_LockSurface(lcd_surface);
+
+ if (color == 1) {
+ sdlcolor = SDL_MapRGB(lcd_surface->format, lcd_color_max.r, lcd_color_max.g, lcd_color_max.b);
+ } else {
+ sdlcolor = SDL_MapRGB(lcd_surface->format, lcd_color_zero.r, lcd_color_zero.g, lcd_color_zero.b);
+ }
+
+ while (count--) {
+ dest.x = points[count].x * display_zoom;
+ dest.y = points[count].y * display_zoom;
+ dest.w = points[count].width * display_zoom;
+ dest.h = points[count].height * display_zoom;
+
+ SDL_FillRect(lcd_surface, &dest, sdlcolor);
+ }
+
+ SDL_UnlockSurface(lcd_surface);
+}
+
+/* initialise simulator lcd driver */
+void sim_lcd_init(void)
+{
+ lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom,
+ LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0);
+
+ sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, (1<<LCD_DEPTH));
+}
+
diff --git a/uisimulator/sdl/lcd-charcell.h b/uisimulator/sdl/lcd-charcell.h
new file mode 100644
index 0000000000..e82412f574
--- /dev/null
+++ b/uisimulator/sdl/lcd-charcell.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __LCDCHARCELL_H__
+#define __LCDCHARCELL_H__
+
+#include "lcd.h"
+#include "SDL.h"
+
+void sim_lcd_init(void);
+
+#endif // #ifndef __LCDCHARCELL_H__
+
diff --git a/uisimulator/sdl/lcd-remote.c b/uisimulator/sdl/lcd-remote.c
new file mode 100644
index 0000000000..4d592e67f5
--- /dev/null
+++ b/uisimulator/sdl/lcd-remote.c
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "uisdl.h"
+#include "lcd-sdl.h"
+#include "lcd-remote.h"
+
+SDL_Surface *remote_surface;
+
+SDL_Color remote_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0};
+SDL_Color remote_color_max = {0, 0, 0, 0};
+
+extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
+
+static inline Uint32 get_lcd_remote_pixel(int x, int y) {
+ return ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1);
+}
+
+void lcd_remote_update (void)
+{
+ lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
+}
+
+void lcd_remote_update_rect(int x_start, int y_start, int width, int height)
+{
+ sdl_update_rect(remote_surface, x_start, y_start, width, height,
+ LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, background ? UI_REMOTE_POSX : 0,
+ (background? UI_REMOTE_POSY : 0) + UI_LCD_HEIGHT, get_lcd_remote_pixel);
+}
+
+/* initialise simulator lcd remote driver */
+void sim_lcd_remote_init(void)
+{
+ remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ LCD_REMOTE_WIDTH * display_zoom, LCD_REMOTE_HEIGHT * display_zoom,
+ 8, 0, 0, 0, 0);
+
+ sdl_set_gradient(remote_surface, &remote_color_zero, &remote_color_max,
+ (1<<LCD_REMOTE_DEPTH));
+}
+
diff --git a/uisimulator/sdl/lcd-remote.h b/uisimulator/sdl/lcd-remote.h
new file mode 100644
index 0000000000..aebe304fb9
--- /dev/null
+++ b/uisimulator/sdl/lcd-remote.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __LCDREMOTE_H__
+#define __LCDREMOTE_H__
+
+#include "lcd.h"
+#include "SDL.h"
+
+void sim_lcd_remote_init(void);
+
+#endif // #ifndef __LCDREMOTE_H__
+
diff --git a/uisimulator/sdl/lcd-sdl.c b/uisimulator/sdl/lcd-sdl.c
index 1a6e8da8e8..4a0962dbec 100644
--- a/uisimulator/sdl/lcd-sdl.c
+++ b/uisimulator/sdl/lcd-sdl.c
@@ -17,296 +17,67 @@
*
****************************************************************************/
+#include "lcd-sdl.h"
#include "uisdl.h"
-#include "lcd.h"
-#include "lcd-playersim.h"
-SDL_Surface* lcd_surface;
+int display_zoom = 1;
-#if LCD_DEPTH == 16
-#else
-SDL_Color lcd_palette[(1<<LCD_DEPTH)];
-SDL_Color lcd_color_zero = {UI_LCD_BGCOLORLIGHT, 0};
-SDL_Color lcd_color_max = {0, 0, 0, 0};
-
-#endif
-
-#ifdef HAVE_LCD_BITMAP
-
-#ifdef HAVE_REMOTE_LCD
-SDL_Surface *remote_surface;
-SDL_Color remote_palette[(1<<LCD_REMOTE_DEPTH)];
-SDL_Color remote_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0};
-SDL_Color remote_color_max = {0, 0, 0, 0};
-
-#endif
-
-void lcd_update (void)
-{
- /* update a full screen rect */
- lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
-}
-
-void lcd_update_rect(int x_start, int y_start, int width, int height)
+void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
+ int height, int max_x, int max_y, int ui_x, int ui_y,
+ Uint32 (*getpixel)(int, int))
{
int x, y;
int xmax, ymax;
+ SDL_Rect dest;
ymax = y_start + height;
xmax = x_start + width;
- if(xmax > LCD_WIDTH)
- xmax = LCD_WIDTH;
- if(ymax >= LCD_HEIGHT)
- ymax = LCD_HEIGHT;
-
- SDL_LockSurface(lcd_surface);
+ if(xmax > max_x)
+ xmax = max_x;
+ if(ymax >= max_y)
+ ymax = max_y;
- int bpp = lcd_surface->format->BytesPerPixel;
+ SDL_LockSurface(surface);
- for (x = x_start; x < xmax; x++)
- {
- for (y = y_start; y < ymax; y++)
- {
- Uint8 *p = (Uint8 *)lcd_surface->pixels + y * lcd_surface->pitch + x * bpp;
+ dest.w = display_zoom;
+ dest.h = display_zoom;
+
+ for (x = x_start; x < xmax; x++) {
+ dest.x = x * display_zoom;
-#if LCD_DEPTH == 1
- *p = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
-#elif LCD_DEPTH == 2
-#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
- *p = ((lcd_framebuffer[y][x/4] >> (2 * (x & 3))) & 3);
-#else
- *p = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
-#endif
-#elif LCD_DEPTH == 16
-#if LCD_PIXELFORMAT == RGB565SWAPPED
- unsigned bits = lcd_framebuffer[y][x];
- *(Uint16 *)p = (bits >> 8) | (bits << 8);
-#else
- *(Uint16 *)p = lcd_framebuffer[y][x];
-#endif
-#endif
+ for (y = y_start; y < ymax; y++) {
+ dest.y = y * display_zoom;
+
+ SDL_FillRect(surface, &dest, getpixel(x, y));
}
}
- SDL_UnlockSurface(lcd_surface);
-
- SDL_Rect src = {x_start, y_start, xmax, ymax};
- SDL_Rect dest = {UI_LCD_POSX + x_start, UI_LCD_POSY + y_start, xmax, ymax};
+ SDL_UnlockSurface(surface);
- if (!background) {
- dest.x -= UI_LCD_POSX;
- dest.y -= UI_LCD_POSY;
- }
+ SDL_Rect src = {x_start * display_zoom, y_start * display_zoom, xmax * display_zoom, ymax * display_zoom};
+ dest.x = (ui_x + x_start) * display_zoom;
+ dest.y = (ui_y + y_start) * display_zoom;;
+ dest.w = xmax * display_zoom;
+ dest.h = ymax * display_zoom;
- SDL_BlitSurface(lcd_surface, &src, gui_surface, &dest);
+ SDL_BlitSurface(surface, &src, gui_surface, &dest);
SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
SDL_Flip(gui_surface);
-
}
-#ifdef HAVE_REMOTE_LCD
-
-extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
-
-void lcd_remote_update (void)
-{
- lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
-}
-
-void lcd_remote_update_rect(int x_start, int y_start,
- int width, int height)
-{
- int x, y;
- int xmax, ymax;
-
- ymax = y_start + height;
- xmax = x_start + width;
-
- if(xmax > LCD_REMOTE_WIDTH)
- xmax = LCD_REMOTE_WIDTH;
- if(ymax >= LCD_REMOTE_HEIGHT)
- ymax = LCD_REMOTE_HEIGHT;
-
- SDL_LockSurface(remote_surface);
-
- int bpp = remote_surface->format->BytesPerPixel;
-
- for (x = x_start; x < xmax; x++)
- for (y = y_start; y < ymax; y++)
- {
- Uint8 *p = (Uint8 *)remote_surface->pixels + y * remote_surface->pitch + x * bpp;
-
- *p = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1);
- }
-
- SDL_UnlockSurface(remote_surface);
-
- SDL_Rect src = {x_start, y_start, xmax, ymax};
- SDL_Rect dest = {UI_REMOTE_POSX + x_start, UI_REMOTE_POSY + y_start, xmax, ymax};
-
- if (!background) {
- dest.x -= UI_REMOTE_POSX;
- dest.y -= UI_REMOTE_POSY;
- dest.y += UI_LCD_HEIGHT;
- }
-
- SDL_BlitSurface(remote_surface, &src, gui_surface, &dest);
- SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
- SDL_Flip(gui_surface);
-
-}
-
-#endif /* HAVE_REMOTE_LCD */
-#endif /* HAVE_LCD_BITMAP */
-
-#ifdef HAVE_LCD_CHARCELLS
-/* Defined in lcd-playersim.c */
-extern void lcd_print_char(int x, int y);
-extern bool lcd_display_redraw;
-extern unsigned char hardware_buffer_lcd[11][2];
-static unsigned char lcd_buffer_copy[11][2];
-
-void lcd_update(void)
-{
- int x, y;
- bool changed = false;
- SDL_Rect dest = {UI_LCD_POSX, UI_LCD_POSY, UI_LCD_WIDTH, UI_LCD_HEIGHT};
-
- for (y = 0; y < 2; y++)
- {
- for (x = 0; x < 11; x++)
- {
- if (lcd_display_redraw ||
- lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
- {
- lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
- lcd_print_char(x, y);
- changed = true;
- }
- }
- }
-
- if (changed)
- {
- if (!background) {
- dest.x -= UI_LCD_POSX;
- dest.y -= UI_LCD_POSY;
- }
-
- SDL_BlitSurface(lcd_surface, NULL, gui_surface, &dest);
- SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
- SDL_Flip(gui_surface);
- }
-
- lcd_display_redraw = false;
-}
-
-void drawdots(int color, struct coordinate *points, int count)
-{
- int bpp = lcd_surface->format->BytesPerPixel;
-
- SDL_LockSurface(lcd_surface);
-
- while (count--)
- {
- Uint8 *p = (Uint8 *)lcd_surface->pixels + (points[count].y) * lcd_surface->pitch + (points[count].x) * bpp;
-
- *p = color;
- }
-
- SDL_UnlockSurface(lcd_surface);
-}
-
-void drawrectangles(int color, struct rectangle *points, int count)
-{
- int bpp = lcd_surface->format->BytesPerPixel;
-
- SDL_LockSurface(lcd_surface);
-
- while (count--)
- {
- int x;
- int y;
- int ix;
- int iy;
-
- for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
- {
- for (y = points[count].y, iy = 0; iy < points[count].height; y++, iy++)
- {
- Uint8 *p = (Uint8 *)lcd_surface->pixels + y * lcd_surface->pitch + x * bpp;
-
- *p = color;
- }
- }
- }
-
- SDL_UnlockSurface(lcd_surface);
-}
-#endif /* HAVE_LCD_CHARCELLS */
-
-#if LCD_DEPTH <= 8
/* set a range of bitmap indices to a gradient from startcolour to endcolour */
-void lcdcolors(int index, int count, SDL_Color *start, SDL_Color *end)
+void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, int steps)
{
int i;
+ SDL_Color palette[steps];
- count--;
- for (i = 0; i <= count; i++)
- {
- lcd_palette[i+index].r = start->r
- + (end->r - start->r) * i / count;
- lcd_palette[i+index].g = start->g
- + (end->g - start->g) * i / count;
- lcd_palette[i+index].b = start->b
- + (end->b - start->b) * i / count;
+ for (i = 0; i < steps; i++) {
+ palette[i].r = start->r + (end->r - start->r) * i / steps;
+ palette[i].g = start->g + (end->g - start->g) * i / steps;
+ palette[i].b = start->b + (end->b - start->b) * i / steps;
}
- SDL_SetPalette(lcd_surface, SDL_LOGPAL|SDL_PHYSPAL, lcd_palette, index, count);
+ SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, 0, steps);
}
-#endif
-#ifdef HAVE_REMOTE_LCD
-/* set a range of bitmap indices to a gradient from startcolour to endcolour */
-void lcdremotecolors(int index, int count, SDL_Color *start, SDL_Color *end)
-{
- int i;
-
- count--;
- for (i = 0; i <= count; i++)
- {
- remote_palette[i+index].r = start->r
- + (end->r - start->r) * i / count;
- remote_palette[i+index].g = start->g
- + (end->g - start->g) * i / count;
- remote_palette[i+index].b = start->b
- + (end->b - start->b) * i / count;
- }
-
- SDL_SetPalette(remote_surface, SDL_LOGPAL|SDL_PHYSPAL, remote_palette, index, count);
-}
-#endif
-
-/* initialise simulator lcd driver */
-void simlcdinit(void)
-{
-#if LCD_DEPTH == 16
- lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH, LCD_HEIGHT, 16,
- 0, 0, 0, 0);
-#else
- lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH, LCD_HEIGHT, 8,
- 0, 0, 0, 0);
-#endif
-
-#if LCD_DEPTH <= 8
- lcdcolors(0, (1<<LCD_DEPTH), &lcd_color_zero, &lcd_color_max);
-#endif
-
-#ifdef HAVE_REMOTE_LCD
- remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, 8,
- 0, 0, 0, 0);
-
- lcdremotecolors(0, (1<<LCD_REMOTE_DEPTH), &remote_color_zero, &remote_color_max);
-#endif
-}
diff --git a/uisimulator/sdl/lcd-sdl.h b/uisimulator/sdl/lcd-sdl.h
index 312ae0d01f..d371639a64 100644
--- a/uisimulator/sdl/lcd-sdl.h
+++ b/uisimulator/sdl/lcd-sdl.h
@@ -20,20 +20,18 @@
#ifndef __LCDSDL_H__
#define __LCDSDL_H__
-#include "uisdl.h"
#include "lcd.h"
+#include "SDL.h"
-extern SDL_Surface* lcd_surface;
-#if LCD_DEPTH <= 8
-extern SDL_Color lcd_palette[(1<<LCD_DEPTH)];
-#endif
+/* Default display zoom level */
+extern int display_zoom;
-#ifdef HAVE_REMOTE_LCD
-extern SDL_Surface* remote_surface;
-extern SDL_Color remote_palette[(1<<LCD_REMOTE_DEPTH)];
-#endif
+void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
+ int height, int max_x, int max_y, int ui_x, int ui_y,
+ Uint32 (*getpixel)(int, int));
-void simlcdinit(void);
+void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end,
+ int steps);
#endif // #ifndef __LCDSDL_H__
diff --git a/uisimulator/sdl/thread-sdl.h b/uisimulator/sdl/thread-sdl.h
index a661f582a4..30d0adae49 100644
--- a/uisimulator/sdl/thread-sdl.h
+++ b/uisimulator/sdl/thread-sdl.h
@@ -17,7 +17,14 @@
*
****************************************************************************/
+#ifndef __THREADSDL_H__
+#define __THREADSDL_H__
+
+#include "SDL_thread.h"
+
extern SDL_Thread* threads[256];
extern int threadCount;
extern SDL_mutex* mutex;
+#endif // #ifndef __THREADSDL_H__
+
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c
index 2dd6b93122..178090403f 100644
--- a/uisimulator/sdl/uisdl.c
+++ b/uisimulator/sdl/uisdl.c
@@ -20,14 +20,25 @@
#include <stdlib.h>
#include <string.h>
#include "autoconf.h"
-#include "uisdl.h"
#include "button.h"
#include "thread.h"
-#include "thread-sdl.h"
#include "kernel.h"
#include "sound.h"
+#include "uisdl.h"
+#include "lcd-sdl.h"
+#ifdef HAVE_LCD_BITMAP
+#include "lcd-bitmap.h"
+#elif HAVE_LCD_CHARCELLS
+#include "lcd-charcell.h"
+#endif
+#ifdef HAVE_REMOTE_LCD
+#include "lcd-remote.h"
+#endif
+#include "thread-sdl.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
-// extern functions
+/* extern functions */
extern void app_main (void *); // mod entry point
extern void new_key(int key);
extern void sim_tick_tasks(void);
@@ -43,8 +54,8 @@ SDL_TimerID tick_timer_id;
SDL_Thread *sound_thread;
#endif
-bool lcd_display_redraw=true; // Used for player simulator
-char having_new_lcd=true; // Used for player simulator
+bool lcd_display_redraw = true; /* Used for player simulator */
+char having_new_lcd=true; /* Used for player simulator */
long start_tick;
@@ -130,14 +141,17 @@ bool gui_startup()
}
- if ((gui_surface = SDL_SetVideoMode(width, height, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) {
+ if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) {
fprintf(stderr, "fatal: %s\n", SDL_GetError());
return false;
}
SDL_WM_SetCaption(UI_TITLE, NULL);
- simlcdinit();
+ sim_lcd_init();
+#ifdef HAVE_REMOTE_LCD
+ sim_lcd_remote_init();
+#endif
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
@@ -190,16 +204,26 @@ int main(int argc, char *argv[])
} else if (!strcmp("--old_lcd", argv[x])) {
having_new_lcd = false;
printf("Using old LCD layout.\n");
+ } else if (!strcmp("--zoom", argv[x])) {
+ x++;
+ display_zoom=atoi(argv[x]);
+ printf("Window zoom is %d\n", display_zoom);
} else {
printf("rockboxui\n");
printf("Arguments:\n");
printf(" --background \t Use background image of hardware\n");
printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n");
+ printf(" --zoom \t window zoom (will disable backgrounds)\n");
exit(0);
}
}
}
+ if (display_zoom > 1) {
+ background = false;
+ }
+
+
if (!gui_startup())
return -1;
diff --git a/uisimulator/sdl/uisdl.h b/uisimulator/sdl/uisdl.h
index 25e31040cd..989ca364d1 100644
--- a/uisimulator/sdl/uisdl.h
+++ b/uisimulator/sdl/uisdl.h
@@ -20,10 +20,8 @@
#ifndef __UISDL_H__
#define __UISDL_H__
-#include <SDL.h>
-#include <SDL_mutex.h>
-#include <SDL_thread.h>
-#include "lcd-sdl.h"
+#include <stdbool.h>
+#include "SDL.h"
/* colour definitions are R, G, B */
@@ -93,7 +91,7 @@
#define UI_REMOTE_WIDTH 128
#define UI_REMOTE_HEIGHT 64
-#elif defined(IRIVER_H300_SERIES)
+#elif defined(IRIVER_H300)
#define UI_TITLE "iriver H300"
#define UI_WIDTH 288 // width of GUI window
#define UI_HEIGHT 581 // height of GUI window
@@ -176,6 +174,7 @@
extern SDL_Surface *gui_surface;
extern bool background; /* True if the background image is enabled */
+extern int display_zoom;
#endif // #ifndef __UISDL_H__