diff options
author | Robert Hak <adiamas@rockbox.org> | 2002-08-13 09:19:21 +0000 |
---|---|---|
committer | Robert Hak <adiamas@rockbox.org> | 2002-08-13 09:19:21 +0000 |
commit | 4db2ded56f1ebf5a617e82458ab5526541b92943 (patch) | |
tree | 2acaed2c1820ab9c60b290177dbb1c56c0902594 /uisimulator/common | |
parent | ccd10acb2014804c10d2758c36fc425ea359f598 (diff) | |
download | rockbox-4db2ded56f1ebf5a617e82458ab5526541b92943.tar.gz rockbox-4db2ded56f1ebf5a617e82458ab5526541b92943.zip |
similarities in the two branches joined
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1707 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common')
-rw-r--r-- | uisimulator/common/lcd-common.c | 162 | ||||
-rw-r--r-- | uisimulator/common/lcd-common.h | 71 |
2 files changed, 233 insertions, 0 deletions
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c new file mode 100644 index 0000000000..d55cd0baa8 --- /dev/null +++ b/uisimulator/common/lcd-common.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Robert E. Hak <rhak@ramapo.edu> | ||
11 | * | ||
12 | * Windows Copyright (C) 2002 by Felix Arends | ||
13 | * X11 Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
14 | * | ||
15 | * All files in this archive are subject to the GNU General Public License. | ||
16 | * See the file COPYING in the source tree root for full license agreement. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "lcd-common.h" | ||
24 | |||
25 | /*** Define our #includes ***/ | ||
26 | #ifdef WIN32 | ||
27 | #include <windows.h> | ||
28 | #include <process.h> | ||
29 | #include "uisw32.h" | ||
30 | #else | ||
31 | /* X11 */ | ||
32 | #include <stdio.h> | ||
33 | #include <string.h> | ||
34 | #include <stdarg.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <ctype.h> | ||
37 | #include <sys/types.h> | ||
38 | #include <sys/stat.h> | ||
39 | #include <fcntl.h> | ||
40 | |||
41 | #include <errno.h> | ||
42 | #include <ctype.h> | ||
43 | #include <time.h> | ||
44 | |||
45 | #include "screenhack.h" | ||
46 | #endif | ||
47 | /**** End #includes ****/ | ||
48 | |||
49 | |||
50 | /*** Start global variables ***/ | ||
51 | #ifdef WIN32 | ||
52 | |||
53 | /* Simulate the target ui display */ | ||
54 | char bitmap[LCD_HEIGHT][LCD_WIDTH]; | ||
55 | |||
56 | BITMAPINFO2 bmi = | ||
57 | { | ||
58 | { sizeof (BITMAPINFOHEADER), | ||
59 | LCD_WIDTH, -LCD_HEIGHT, 1, 8, | ||
60 | BI_RGB, 0, 0, 0, 2, 2, }, | ||
61 | { | ||
62 | /* green background color */ | ||
63 | {UI_LCD_BGCOLOR, 0}, | ||
64 | /* black color */ | ||
65 | {UI_LCD_BLACK, 0} | ||
66 | } | ||
67 | |||
68 | }; | ||
69 | |||
70 | #else | ||
71 | extern Display *dpy; | ||
72 | unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8]; | ||
73 | #endif | ||
74 | |||
75 | /* Both X11 and WIN32 use this */ | ||
76 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; | ||
77 | |||
78 | /*** End Global variables ***/ | ||
79 | |||
80 | |||
81 | /*** Externed functions ***/ | ||
82 | #ifndef WIN32 | ||
83 | extern void screen_resized(int width, int height); | ||
84 | |||
85 | /* From uibasic.c */ | ||
86 | extern void drawdots(int color, XPoint *points, int count); | ||
87 | #endif | ||
88 | |||
89 | /*** End Externed functions ***/ | ||
90 | |||
91 | |||
92 | |||
93 | /*** Begin Functions ***/ | ||
94 | void lcd_update() | ||
95 | { | ||
96 | #ifdef WIN32 | ||
97 | int x, y; | ||
98 | if(hGUIWnd == NULL) | ||
99 | _endthread (); | ||
100 | |||
101 | for(x = 0; x < LCD_WIDTH; x++) | ||
102 | for(y = 0; y < LCD_HEIGHT; y++) | ||
103 | bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1); | ||
104 | |||
105 | InvalidateRect (hGUIWnd, NULL, FALSE); | ||
106 | |||
107 | Sleep (50); | ||
108 | #else | ||
109 | int x, y, bit; | ||
110 | int p=0, cp=0; | ||
111 | |||
112 | XPoint points[LCD_WIDTH * LCD_HEIGHT]; | ||
113 | XPoint clearpoints[LCD_WIDTH * LCD_HEIGHT]; | ||
114 | |||
115 | for(y=0; y<LCD_HEIGHT; y+=8) { | ||
116 | for(x=0; x<LCD_WIDTH; x++) { | ||
117 | if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) { | ||
118 | /* one or more bits/pixels are changed */ | ||
119 | unsigned char diff = | ||
120 | lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8]; | ||
121 | |||
122 | for(bit=0; bit<8; bit++) { | ||
123 | if(lcd_framebuffer[x][y/8]&(1<<bit)) { | ||
124 | /* set a dot */ | ||
125 | points[p].x = x + MARGIN_X; | ||
126 | points[p].y = y+bit + MARGIN_Y; | ||
127 | p++; | ||
128 | } | ||
129 | else if(diff &(1<<bit)) { | ||
130 | /* clear a dot */ | ||
131 | clearpoints[cp].x = x + MARGIN_X; | ||
132 | clearpoints[cp].y = y+bit + MARGIN_Y; | ||
133 | cp++; /* increase the point counter */ | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | |||
140 | /* copy a huge block */ | ||
141 | memcpy(lcd_framebuffer_copy, lcd_framebuffer, sizeof(lcd_framebuffer)); | ||
142 | |||
143 | drawdots(0, &clearpoints[0], cp); | ||
144 | drawdots(1, &points[0], p); | ||
145 | XSync(dpy,False); | ||
146 | |||
147 | #endif /* end WIN32*/ | ||
148 | } | ||
149 | |||
150 | #ifdef WIN32 | ||
151 | void lcd_backlight(bool on) | ||
152 | { | ||
153 | if(on) { | ||
154 | RGBQUAD blon = {UI_LCD_BGCOLORLIGHT, 0}; | ||
155 | bmi.bmiColors[0] = blon; | ||
156 | } else { | ||
157 | RGBQUAD blon = {UI_LCD_BGCOLOR, 0}; | ||
158 | bmi.bmiColors[0] = blon; | ||
159 | } | ||
160 | InvalidateRect (hGUIWnd, NULL, FALSE); | ||
161 | } | ||
162 | #endif | ||
diff --git a/uisimulator/common/lcd-common.h b/uisimulator/common/lcd-common.h new file mode 100644 index 0000000000..08a5bbd3bb --- /dev/null +++ b/uisimulator/common/lcd-common.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Robert E. Hak <rhak@ramapo.edu> | ||
11 | * | ||
12 | * Windows Version Copyright (C) 2002 by Felix Arends | ||
13 | * X11 Version Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | ||
14 | * | ||
15 | * All files in this archive are subject to the GNU General Public License. | ||
16 | * See the file COPYING in the source tree root for full license agreement. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "lcd.h" | ||
24 | |||
25 | #ifdef WIN32 | ||
26 | #ifndef __LCDWIN32_H__ | ||
27 | #define __LCDWIN32_H__ | ||
28 | |||
29 | #include "uisw32.h" | ||
30 | #include "lcd.h" | ||
31 | |||
32 | typedef struct | ||
33 | { | ||
34 | BITMAPINFOHEADER bmiHeader; | ||
35 | RGBQUAD bmiColors[2]; | ||
36 | } BITMAPINFO2; | ||
37 | |||
38 | #ifdef HAVE_LCD_BITMAP | ||
39 | /* the display */ | ||
40 | extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; | ||
41 | #else | ||
42 | #define DISP_X 112 | ||
43 | #define DISP_Y 64 | ||
44 | #endif /* HAVE_LCD_BITMAP */ | ||
45 | |||
46 | /* the ui display */ | ||
47 | extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; | ||
48 | /* bitmap information */ | ||
49 | extern BITMAPINFO2 bmi; | ||
50 | #endif /* __LCDWIN32_H__ */ | ||
51 | |||
52 | #else | ||
53 | /* X11 */ | ||
54 | #define MARGIN_X 3 | ||
55 | #define MARGIN_Y 3 | ||
56 | |||
57 | #endif /* WIN32 */ | ||
58 | |||
59 | |||
60 | |||
61 | |||
62 | |||
63 | |||
64 | |||
65 | |||
66 | |||
67 | |||
68 | |||
69 | |||
70 | |||
71 | |||