diff --git a/uisimulator/Makefile b/uisimulator/Makefile index 121c2b0a9f..858c1dafe0 100644 --- a/uisimulator/Makefile +++ b/uisimulator/Makefile @@ -29,7 +29,7 @@ LDFLAGS = -lX11 -lm -lXt -lXmu -lsocket -lnsl DEPEND = .depends OBJS= alpha.o hsv.o screenhack.o yarandom.o uibasic.o resources.o visual.o\ - usleep.o + usleep.o lcd.c lcd-x11.c SRCS = $(OBJS:%.o=%.c) HDRS = $(OBJS:%.o=%.h) diff --git a/uisimulator/lcd-recorder.c b/uisimulator/lcd-recorder.c index 37f4d3b142..f7623937c5 100644 --- a/uisimulator/lcd-recorder.c +++ b/uisimulator/lcd-recorder.c @@ -79,6 +79,7 @@ void lcd_update (void) } } +#if 0 /* * Display a string at current position */ @@ -107,42 +108,8 @@ void lcd_string (const char *text, BOOL invert) } } } +#endif -/* - * Display a character. - * This writes a 5x8 character within a 6x8 cell. - * The cell does not have to be aligned to a display byte. - * The top left of the cell is displayed at the current position. - * invert is TRUE to display in reverse video. - */ -void lcd_char (int ch, BOOL invert) -{ - uchar (*dp)[DISP_X] = (void *) &display[lcd_y/8][lcd_x]; - uint32 shift, mask, col; - - /* Limit to char generation table */ - if (ch < ASCII_MIN || ch > ASCII_MAX) - ch = ASCII_MAX; - - /* Calculate shift and masks for cell bit position */ - shift = (lcd_y & 0x7); - mask = ~(COL_MASK << shift); - if (invert) - invert = ~mask; - - /* Write each char column */ - for (col = 0; col < CHAR_X-1; col++) { - uint32 data = (char_gen[ch-ASCII_MIN][col] << shift) ^ invert; - dp[0][col] = (dp[0][col] & mask) | data; - if (lcd_y < DISP_Y-8) - dp[1][col] = (dp[1][col] & (mask >> 8)) | (data >> 8); - } - - /* Column after char */ - dp[0][CHAR_X-1] = (dp[0][CHAR_X-1] & mask) | invert; - if (lcd_y < DISP_Y-8) - dp[1][CHAR_X-1] = (dp[1][CHAR_X-1] & (mask >> 8)) | (invert >> 8); -} /* * Write a byte to LCD controller. diff --git a/uisimulator/lcd-x11.c b/uisimulator/lcd-x11.c index efd6c9e8bd..7655765137 100644 --- a/uisimulator/lcd-x11.c +++ b/uisimulator/lcd-x11.c @@ -17,7 +17,50 @@ * ****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "screenhack.h" + /* - * Specific implementations for X11, using the generic LCD functions and data. + * Specific implementations for X11, using the generic LCD API and data. */ +#include "lcd.h" + +extern unsigned char display[LCD_WIDTH/8][LCD_HEIGHT]; + +void lcd_update (void) +{ + int x, y; + int p=0; + int bit; + XPoint points[LCD_WIDTH * LCD_HEIGHT]; + + for(y=0; y= 0 && x < DISP_X && y >= 0 && y < DISP_Y) - { - lcd_x = x; - lcd_y = y; - } + if (x >= 0 && x < DISP_X && y >= 0 && y < DISP_Y) { + lcd_x = x; + lcd_y = y; + } } /* * Clear the display */ -void lcd_clear (void) +void lcd_clear(void) { lcd_x = 0; lcd_y = 0; memset (display, 0, sizeof display); } +/* + * Display a character at current position. + * This writes a 5x8 character within a 6x8 cell. + * The cell does not have to be aligned to a display byte. + * The top left of the cell is displayed at the current position. + * invert is TRUE to display in reverse video. + */ +void lcd_char (int ch, char invert) +{ + unsigned char (*dp)[DISP_X] = (void *) &display[lcd_y/8][lcd_x]; + unsigned long shift, mask, col; + + /* Limit to char generation table */ + if (ch < ASCII_MIN || ch > ASCII_MAX) + ch = ASCII_MAX; + + /* Calculate shift and masks for cell bit position */ + shift = (lcd_y & 0x7); + mask = ~(COL_MASK << shift); + if (invert) + invert = ~mask; + + /* Write each char column */ + for (col = 0; col < CHAR_X-1; col++) { + unsigned long data = (char_gen[ch-ASCII_MIN][col] << shift) ^ invert; + dp[0][col] = (dp[0][col] & mask) | data; + if (lcd_y < DISP_Y-8) + dp[1][col] = (dp[1][col] & (mask >> 8)) | (data >> 8); + } + + /* Column after char */ + dp[0][CHAR_X-1] = (dp[0][CHAR_X-1] & mask) | invert; + if (lcd_y < DISP_Y-8) + dp[1][CHAR_X-1] = (dp[1][CHAR_X-1] & (mask >> 8)) | (invert >> 8); +} + +/* + * Output a string at current position + */ +void lcd_string(const char *text, char invert) +{ + int ch; + + while ((ch = *text++) != '\0') { + if (lcd_y > DISP_Y-CHAR_Y) { + /* Scroll (8 pixels) */ + memcpy (display[0], display[1], DISP_X*(DISP_Y/8-1)); + lcd_y -= 8; + } + + if (ch == '\n') + lcd_x = DISP_X; + else { + lcd_char (ch, invert); + lcd_x += CHAR_X; + } + + if (lcd_x > DISP_X-CHAR_X) { + /* Wrap to next line */ + lcd_x = 0; + lcd_y += CHAR_Y; + } + } +} diff --git a/uisimulator/lcd.h b/uisimulator/lcd.h new file mode 100644 index 0000000000..0a099cb8c7 --- /dev/null +++ b/uisimulator/lcd.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Daniel Stenberg + * + * 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. + * + ****************************************************************************/ + +/* + * This file is meant for generic LCD defines + */ + +#define LCD_WIDTH 112 /* Display width in pixels */ +#define LCD_HEIGHT 64 /* Display height in pixels */ + diff --git a/uisimulator/uibasic.c b/uisimulator/uibasic.c index 4ea453c82e..74b09f7e9a 100644 --- a/uisimulator/uibasic.c +++ b/uisimulator/uibasic.c @@ -41,7 +41,7 @@ /* -- -- */ -static GC draw_gc, erase_gc; +GC draw_gc, erase_gc; static Colormap cmap; static XColor color_track, color_car; @@ -163,6 +163,27 @@ void drawline(int color, int x1, int y1, int x2, int y2) (int)(y2*track_zoom)); } +void drawdot(int color, int x, int y) +{ + if (color==0) { + XSetForeground(dpy, draw_gc, + get_pixel_resource("background", "Background", dpy, cmap)); + } + else + XSetForeground(dpy, draw_gc, + get_pixel_resource("foreground", "Foreground", dpy, cmap)); + + XDrawPoint(dpy, window, draw_gc, x, y); +} + +void drawdots(XPoint *points, int count) +{ + XSetForeground(dpy, draw_gc, + get_pixel_resource("foreground", "Foreground", dpy, cmap)); + + XDrawPoints(dpy, window, draw_gc, points, count, CoordModeOrigin); +} + void drawtext(int color, int x, int y, char *text) { if (color==0) { @@ -199,11 +220,10 @@ screenhack (Display *the_dpy, Window the_window) init_window(); - drawtext(1, 20, 20, PROGNAME); - drawline(1, 0, 0, 40, 50); - Logf("Rockbox will kill ya!"); + lcd_string( PROGNAME, 0); + while (1) { /* deal with input here */ @@ -214,7 +234,18 @@ screenhack (Display *the_dpy, Window the_window) void screen_redraw() { - /* does nothing yet */ - drawtext(1, 20, 20, PROGNAME); - drawline(1, 0, 0, 40, 50); + int y, x; + + lcd_update(); + +#if 0 + /* does nothing "real" yet */ + /* drawtext(1, 20, 20, PROGNAME);*/ + + for(y=0; y< 112; y++) + for(x=0; x<64; x++) + drawdot(1, x+16, y+16); + /* drawline(1, 0, 0, 40, 50); */ +#endif } +