Rev 1365 | Rev 1392 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1365 | Rev 1366 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2006 Jakub Vana |
2 | * Copyright (C) 2006 Jakub Vana |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <stdio.h> |
29 | #include <stdio.h> |
30 | #include <ddi.h> |
30 | #include <ddi.h> |
31 | #include <task.h> |
31 | #include <task.h> |
32 | #include <stdlib.h> |
32 | #include <stdlib.h> |
33 | #include <ddi.h> |
33 | #include <ddi.h> |
34 | #include <sysinfo.h> |
34 | #include <sysinfo.h> |
35 | #include <align.h> |
35 | #include <align.h> |
36 | #include <as.h> |
36 | #include <as.h> |
37 | #include <ipc/fb.h> |
37 | #include <ipc/fb.h> |
38 | 38 | ||
39 | 39 | ||
40 | #include <ipc/ipc.h> |
40 | #include <ipc/ipc.h> |
41 | #include <ipc/services.h> |
41 | #include <ipc/services.h> |
42 | #include <unistd.h> |
42 | #include <unistd.h> |
43 | #include <stdlib.h> |
43 | #include <stdlib.h> |
44 | #include <ipc/ns.h> |
44 | #include <ipc/ns.h> |
45 | 45 | ||
46 | #include <kernel/errno.h> |
46 | #include <kernel/errno.h> |
47 | 47 | ||
48 | 48 | ||
49 | #include "fb.h" |
49 | #include "fb.h" |
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | #define pl /*printf("FB:L:%d\n",(int)__LINE__);*/ |
53 | #define pl /*printf("FB:L:%d\n",(int)__LINE__);*/ |
54 | 54 | ||
55 | #define EFB (-1) |
55 | #define EFB (-1) |
56 | 56 | ||
57 | extern int __DONT_OPEN_STDIO__=1; |
- | |
58 | - | ||
59 | #define DEFAULT_BGCOLOR 0x000080 |
57 | #define DEFAULT_BGCOLOR 0x000080 |
60 | #define DEFAULT_FGCOLOR 0xffff00 |
58 | #define DEFAULT_FGCOLOR 0xffff00 |
61 | #define DEFAULT_LOGOCOLOR 0x0000ff |
59 | #define DEFAULT_LOGOCOLOR 0x0000ff |
62 | 60 | ||
63 | #define MAIN_BGCOLOR 0x404000 |
61 | #define MAIN_BGCOLOR 0x404000 |
64 | #define MAIN_FGCOLOR 0x000000 |
62 | #define MAIN_FGCOLOR 0x000000 |
65 | #define MAIN_LOGOCOLOR 0x404000 |
63 | #define MAIN_LOGOCOLOR 0x404000 |
66 | 64 | ||
67 | #define SPACING (2) |
65 | #define SPACING (2) |
68 | 66 | ||
69 | #define H_NO_VFBS 3 |
67 | #define H_NO_VFBS 3 |
70 | #define V_NO_VFBS 3 |
68 | #define V_NO_VFBS 3 |
71 | 69 | ||
72 | 70 | ||
73 | static void fb_putchar(int item,char ch); |
71 | static void fb_putchar(int item,char ch); |
74 | int create_window(int item,unsigned int x, unsigned int y,unsigned int x_size, unsigned int y_size, |
72 | int create_window(int item,unsigned int x, unsigned int y,unsigned int x_size, unsigned int y_size, |
75 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR); |
73 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR); |
76 | void fb_init(int item,__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, |
74 | void fb_init(int item,__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, |
77 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR); |
75 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR); |
78 | 76 | ||
79 | 77 | ||
80 | unsigned int mod_col(unsigned int col,int mod); |
78 | unsigned int mod_col(unsigned int col,int mod); |
81 | 79 | ||
82 | 80 | ||
83 | 81 | ||
84 | 82 | ||
85 | 83 | ||
86 | int main(int argc, char *argv[]) |
84 | int main(int argc, char *argv[]) |
87 | { |
85 | { |
88 | 86 | ||
89 | __address fb_ph_addr; |
87 | __address fb_ph_addr; |
90 | unsigned int fb_width; |
88 | unsigned int fb_width; |
91 | unsigned int fb_height; |
89 | unsigned int fb_height; |
92 | unsigned int fb_bpp; |
90 | unsigned int fb_bpp; |
93 | unsigned int fb_scanline; |
91 | unsigned int fb_scanline; |
94 | __address fb_addr; |
92 | __address fb_addr; |
95 | int a=0; |
93 | int a=0; |
96 | 94 | ||
97 | 95 | ||
98 | if(!sysinfo_value("fb")) return -1; |
96 | if(!sysinfo_value("fb")) return -1; |
99 | 97 | ||
100 | fb_ph_addr=sysinfo_value("fb.address.physical"); |
98 | fb_ph_addr=sysinfo_value("fb.address.physical"); |
101 | fb_width=sysinfo_value("fb.width"); |
99 | fb_width=sysinfo_value("fb.width"); |
102 | fb_height=sysinfo_value("fb.height"); |
100 | fb_height=sysinfo_value("fb.height"); |
103 | fb_bpp=sysinfo_value("fb.bpp"); |
101 | fb_bpp=sysinfo_value("fb.bpp"); |
104 | fb_scanline=sysinfo_value("fb.scanline"); |
102 | fb_scanline=sysinfo_value("fb.scanline"); |
105 | 103 | ||
106 | fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE); |
104 | fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE); |
107 | 105 | ||
108 | 106 | ||
109 | 107 | ||
110 | map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr, |
108 | map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr, |
111 | (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,1); |
109 | (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,1); |
112 | 110 | ||
113 | fb_init(0,fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, |
111 | fb_init(0,fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, |
114 | MAIN_BGCOLOR,MAIN_FGCOLOR,MAIN_LOGOCOLOR); |
112 | MAIN_BGCOLOR,MAIN_FGCOLOR,MAIN_LOGOCOLOR); |
115 | 113 | ||
116 | fb_putchar(0,'\n'); |
114 | fb_putchar(0,'\n'); |
117 | fb_putchar(0,' '); |
115 | fb_putchar(0,' '); |
118 | 116 | ||
119 | 117 | ||
120 | { |
118 | { |
121 | int i,j; |
119 | int i,j; |
122 | 120 | ||
123 | for(i=0;i<H_NO_VFBS;i++) |
121 | for(i=0;i<H_NO_VFBS;i++) |
124 | for(j=0;j<V_NO_VFBS;j++) |
122 | for(j=0;j<V_NO_VFBS;j++) |
125 | { |
123 | { |
126 | 124 | ||
127 | int w=create_window(0,(fb_width/H_NO_VFBS)*i+SPACING, |
125 | int w=create_window(0,(fb_width/H_NO_VFBS)*i+SPACING, |
128 | (fb_height/V_NO_VFBS)*j+SPACING,(fb_width/H_NO_VFBS)-2*SPACING , |
126 | (fb_height/V_NO_VFBS)*j+SPACING,(fb_width/H_NO_VFBS)-2*SPACING , |
129 | (fb_height/V_NO_VFBS)-2*SPACING,mod_col(DEFAULT_BGCOLOR,/*i+j*H_NO_VFBS*/0), |
127 | (fb_height/V_NO_VFBS)-2*SPACING,mod_col(DEFAULT_BGCOLOR,/*i+j*H_NO_VFBS*/0), |
130 | mod_col(DEFAULT_FGCOLOR,/*i+j*H_NO_VFBS*/0), |
128 | mod_col(DEFAULT_FGCOLOR,/*i+j*H_NO_VFBS*/0), |
131 | mod_col(DEFAULT_LOGOCOLOR,/*i+j*H_NO_VFBS)*/0)); |
129 | mod_col(DEFAULT_LOGOCOLOR,/*i+j*H_NO_VFBS)*/0)); |
132 | 130 | ||
133 | if(w==EFB) return -1; |
131 | if(w==EFB) return -1; |
134 | 132 | ||
135 | { |
133 | { |
136 | char text[]="Hello, World from\nHelenOS Framebuffer driver\non Virtual Framebuffer\nVFB "; |
134 | char text[]="Hello, World from\nHelenOS Framebuffer driver\non Virtual Framebuffer\nVFB "; |
137 | int i; |
135 | int i; |
138 | for(i=0;text[i];i++) fb_putchar(w,text[i]); |
136 | for(i=0;text[i];i++) fb_putchar(w,text[i]); |
139 | fb_putchar(w,w+'0'); |
137 | fb_putchar(w,w+'0'); |
140 | fb_putchar(w,'\n'); |
138 | fb_putchar(w,'\n'); |
141 | } |
139 | } |
142 | } |
140 | } |
143 | } |
141 | } |
144 | 142 | ||
145 | 143 | ||
146 | ipc_call_t call; |
144 | ipc_call_t call; |
147 | ipc_callid_t callid; |
145 | ipc_callid_t callid; |
148 | char connected = 0; |
146 | char connected = 0; |
149 | int res; |
147 | int res; |
150 | int c; |
148 | int c; |
151 | ipcarg_t phonead; |
149 | ipcarg_t phonead; |
152 | 150 | ||
153 | ipcarg_t retval, arg1, arg2; |
151 | ipcarg_t retval, arg1, arg2; |
154 | 152 | ||
155 | 153 | ||
156 | 154 | ||
157 | if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0) |
155 | if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0) |
158 | { |
156 | { |
159 | return -1; |
157 | return -1; |
160 | }; |
158 | }; |
161 | 159 | ||
162 | 160 | ||
163 | while (1) { |
161 | while (1) { |
164 | static int vfb_no=1; |
162 | static int vfb_no=1; |
165 | 163 | ||
166 | callid = ipc_wait_for_call(&call); |
164 | callid = ipc_wait_for_call(&call); |
167 | // printf("%s:Call phone=%lX..", NAME, call.in_phone_hash); |
165 | // printf("%s:Call phone=%lX..", NAME, call.in_phone_hash); |
168 | switch (IPC_GET_METHOD(call)&((1<<METHOD_WIDTH)-1)) { |
166 | switch (IPC_GET_METHOD(call)&((1<<METHOD_WIDTH)-1)) { |
169 | case IPC_M_PHONE_HUNGUP: |
167 | case IPC_M_PHONE_HUNGUP: |
170 | // fb_putchar(4,((a++)&15)+'A'); |
168 | // fb_putchar(4,((a++)&15)+'A'); |
171 | 169 | ||
172 | retval = 0; |
170 | retval = 0; |
173 | break; |
171 | break; |
174 | case IPC_M_CONNECT_ME_TO: |
172 | case IPC_M_CONNECT_ME_TO: |
175 | retval = 0; |
173 | retval = 0; |
176 | // fb_putchar(1,((a++)&15)+'A'); |
174 | // fb_putchar(1,((a++)&15)+'A'); |
177 | break; |
175 | break; |
178 | case FB_GET_VFB: |
176 | case FB_GET_VFB: |
179 | retval = 0; |
177 | retval = 0; |
180 | arg1 = vfb_no++; |
178 | arg1 = vfb_no++; |
181 | // fb_putchar(2,((a++)&15)+'A'); |
179 | // fb_putchar(2,((a++)&15)+'A'); |
182 | 180 | ||
183 | break; |
181 | break; |
184 | 182 | ||
185 | case FB_PUTCHAR: |
183 | case FB_PUTCHAR: |
186 | retval = 0; |
184 | retval = 0; |
187 | fb_putchar(IPC_GET_ARG1(call),IPC_GET_ARG2(call)); |
185 | fb_putchar(IPC_GET_ARG1(call),IPC_GET_ARG2(call)); |
188 | // fb_putchar(2,((a++)&15)+'A'); |
186 | // fb_putchar(2,((a++)&15)+'A'); |
189 | break; |
187 | break; |
190 | 188 | ||
191 | default: |
189 | default: |
192 | retval = ENOENT; |
190 | retval = ENOENT; |
193 | // fb_putchar(3,((a++)&15)+'A'); |
191 | // fb_putchar(3,((a++)&15)+'A'); |
194 | break; |
192 | break; |
195 | } |
193 | } |
196 | 194 | ||
197 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
195 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
198 | ipc_answer_fast(callid, retval, arg1, arg2); |
196 | ipc_answer_fast(callid, retval, arg1, arg2); |
199 | } |
197 | } |
200 | } |
198 | } |
201 | 199 | ||
202 | return 0; |
200 | return 0; |
203 | } |
201 | } |
204 | /* |
202 | /* |
205 | * Copyright (C) 2006 Ondrej Palkovsky |
203 | * Copyright (C) 2006 Ondrej Palkovsky |
206 | * All rights reserved. |
204 | * All rights reserved. |
207 | * |
205 | * |
208 | * Redistribution and use in source and binary forms, with or without |
206 | * Redistribution and use in source and binary forms, with or without |
209 | * modification, are permitted provided that the following conditions |
207 | * modification, are permitted provided that the following conditions |
210 | * are met: |
208 | * are met: |
211 | * |
209 | * |
212 | * - Redistributions of source code must retain the above copyright |
210 | * - Redistributions of source code must retain the above copyright |
213 | * notice, this list of conditions and the following disclaimer. |
211 | * notice, this list of conditions and the following disclaimer. |
214 | * - Redistributions in binary form must reproduce the above copyright |
212 | * - Redistributions in binary form must reproduce the above copyright |
215 | * notice, this list of conditions and the following disclaimer in the |
213 | * notice, this list of conditions and the following disclaimer in the |
216 | * documentation and/or other materials provided with the distribution. |
214 | * documentation and/or other materials provided with the distribution. |
217 | * - The name of the author may not be used to endorse or promote products |
215 | * - The name of the author may not be used to endorse or promote products |
218 | * derived from this software without specific prior written permission. |
216 | * derived from this software without specific prior written permission. |
219 | * |
217 | * |
220 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
218 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
221 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
219 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
222 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
220 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
223 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
221 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
224 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
222 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
225 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
223 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
226 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
224 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
227 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
225 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
228 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
226 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
229 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
227 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
230 | */ |
228 | */ |
231 | 229 | ||
232 | #include "font-8x16.h" |
230 | #include "font-8x16.h" |
233 | #include <string.h> |
231 | #include <string.h> |
234 | 232 | ||
235 | #include "helenos.xbm" |
233 | #include "helenos.xbm" |
236 | 234 | ||
237 | 235 | ||
238 | 236 | ||
239 | 237 | ||
240 | 238 | ||
241 | 239 | ||
242 | #define GRAPHICS_ITEMS 1024 |
240 | #define GRAPHICS_ITEMS 1024 |
243 | 241 | ||
244 | 242 | ||
245 | /***************************************************************/ |
243 | /***************************************************************/ |
246 | /* Pixel specific fuctions */ |
244 | /* Pixel specific fuctions */ |
247 | 245 | ||
248 | typedef void (*putpixel_fn_t)(int item,unsigned int x, unsigned int y, int color); |
246 | typedef void (*putpixel_fn_t)(int item,unsigned int x, unsigned int y, int color); |
249 | typedef int (*getpixel_fn_t)(int item,unsigned int x, unsigned int y); |
247 | typedef int (*getpixel_fn_t)(int item,unsigned int x, unsigned int y); |
250 | 248 | ||
251 | typedef struct framebuffer_descriptor |
249 | typedef struct framebuffer_descriptor |
252 | { |
250 | { |
253 | __u8 *fbaddress ; |
251 | __u8 *fbaddress ; |
254 | 252 | ||
255 | unsigned int xres ; |
253 | unsigned int xres ; |
256 | unsigned int yres ; |
254 | unsigned int yres ; |
257 | unsigned int scanline ; |
255 | unsigned int scanline ; |
258 | unsigned int pixelbytes ; |
256 | unsigned int pixelbytes ; |
259 | 257 | ||
260 | unsigned int position ; |
258 | unsigned int position ; |
261 | unsigned int columns ; |
259 | unsigned int columns ; |
262 | unsigned int rows ; |
260 | unsigned int rows ; |
263 | 261 | ||
264 | unsigned int BGCOLOR; |
262 | unsigned int BGCOLOR; |
265 | unsigned int FGCOLOR; |
263 | unsigned int FGCOLOR; |
266 | unsigned int LOGOCOLOR; |
264 | unsigned int LOGOCOLOR; |
267 | 265 | ||
268 | putpixel_fn_t putpixel; |
266 | putpixel_fn_t putpixel; |
269 | getpixel_fn_t getpixel; |
267 | getpixel_fn_t getpixel; |
270 | 268 | ||
271 | }framebuffer_descriptor_t; |
269 | }framebuffer_descriptor_t; |
272 | 270 | ||
273 | void * graphics_items[GRAPHICS_ITEMS+1]={NULL}; |
271 | void * graphics_items[GRAPHICS_ITEMS+1]={NULL}; |
274 | 272 | ||
275 | #define FB(__a__,__b__) (((framebuffer_descriptor_t*)(graphics_items[__a__]))->__b__) |
273 | #define FB(__a__,__b__) (((framebuffer_descriptor_t*)(graphics_items[__a__]))->__b__) |
276 | 274 | ||
277 | #define COL_WIDTH 8 |
275 | #define COL_WIDTH 8 |
278 | #define ROW_BYTES (FB(item,scanline) * FONT_SCANLINES) |
276 | #define ROW_BYTES (FB(item,scanline) * FONT_SCANLINES) |
279 | #define RED(x, bits) ((x >> (16 + 8 - bits)) & ((1 << bits) - 1)) |
277 | #define RED(x, bits) ((x >> (16 + 8 - bits)) & ((1 << bits) - 1)) |
280 | #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) |
278 | #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) |
281 | #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) |
279 | #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) |
282 | 280 | ||
283 | #define POINTPOS(x, y) (y * FB(item,scanline) + x * FB(item,pixelbytes)) |
281 | #define POINTPOS(x, y) (y * FB(item,scanline) + x * FB(item,pixelbytes)) |
284 | 282 | ||
285 | 283 | ||
286 | 284 | ||
287 | 285 | ||
288 | /** Put pixel - 24-bit depth, 1 free byte */ |
286 | /** Put pixel - 24-bit depth, 1 free byte */ |
289 | static void putpixel_4byte(int item,unsigned int x, unsigned int y, int color) |
287 | static void putpixel_4byte(int item,unsigned int x, unsigned int y, int color) |
290 | { |
288 | { |
291 | *((__u32 *)(FB(item,fbaddress) + POINTPOS(x, y))) = color; |
289 | *((__u32 *)(FB(item,fbaddress) + POINTPOS(x, y))) = color; |
292 | } |
290 | } |
293 | 291 | ||
294 | /** Return pixel color - 24-bit depth, 1 free byte */ |
292 | /** Return pixel color - 24-bit depth, 1 free byte */ |
295 | static int getpixel_4byte(int item,unsigned int x, unsigned int y) |
293 | static int getpixel_4byte(int item,unsigned int x, unsigned int y) |
296 | { |
294 | { |
297 | return *((__u32 *)(FB(item,fbaddress) + POINTPOS(x, y))) & 0xffffff; |
295 | return *((__u32 *)(FB(item,fbaddress) + POINTPOS(x, y))) & 0xffffff; |
298 | } |
296 | } |
299 | 297 | ||
300 | /** Put pixel - 24-bit depth */ |
298 | /** Put pixel - 24-bit depth */ |
301 | static void putpixel_3byte(int item,unsigned int x, unsigned int y, int color) |
299 | static void putpixel_3byte(int item,unsigned int x, unsigned int y, int color) |
302 | { |
300 | { |
303 | unsigned int startbyte = POINTPOS(x, y); |
301 | unsigned int startbyte = POINTPOS(x, y); |
304 | 302 | ||
305 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
303 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
306 | FB(item,fbaddress)[startbyte] = RED(color, 8); |
304 | FB(item,fbaddress)[startbyte] = RED(color, 8); |
307 | FB(item,fbaddress)[startbyte + 1] = GREEN(color, 8); |
305 | FB(item,fbaddress)[startbyte + 1] = GREEN(color, 8); |
308 | FB(item,fbaddress)[startbyte + 2] = BLUE(color, 8); |
306 | FB(item,fbaddress)[startbyte + 2] = BLUE(color, 8); |
309 | #else |
307 | #else |
310 | FB(item,fbaddress)[startbyte + 2] = RED(color, 8); |
308 | FB(item,fbaddress)[startbyte + 2] = RED(color, 8); |
311 | FB(item,fbaddress)[startbyte + 1] = GREEN(color, 8); |
309 | FB(item,fbaddress)[startbyte + 1] = GREEN(color, 8); |
312 | FB(item,fbaddress)[startbyte + 0] = BLUE(color, 8); |
310 | FB(item,fbaddress)[startbyte + 0] = BLUE(color, 8); |
313 | #endif |
311 | #endif |
314 | 312 | ||
315 | 313 | ||
316 | } |
314 | } |
317 | 315 | ||
318 | /** Return pixel color - 24-bit depth */ |
316 | /** Return pixel color - 24-bit depth */ |
319 | static int getpixel_3byte(int item,unsigned int x, unsigned int y) |
317 | static int getpixel_3byte(int item,unsigned int x, unsigned int y) |
320 | { |
318 | { |
321 | unsigned int startbyte = POINTPOS(x, y); |
319 | unsigned int startbyte = POINTPOS(x, y); |
322 | 320 | ||
323 | 321 | ||
324 | 322 | ||
325 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
323 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
326 | return FB(item,fbaddress)[startbyte] << 16 | FB(item,fbaddress)[startbyte + 1] << 8 | FB(item,fbaddress)[startbyte + 2]; |
324 | return FB(item,fbaddress)[startbyte] << 16 | FB(item,fbaddress)[startbyte + 1] << 8 | FB(item,fbaddress)[startbyte + 2]; |
327 | #else |
325 | #else |
328 | return FB(item,fbaddress)[startbyte + 2] << 16 | FB(item,fbaddress)[startbyte + 1] << 8 | FB(item,fbaddress)[startbyte + 0]; |
326 | return FB(item,fbaddress)[startbyte + 2] << 16 | FB(item,fbaddress)[startbyte + 1] << 8 | FB(item,fbaddress)[startbyte + 0]; |
329 | #endif |
327 | #endif |
330 | 328 | ||
331 | 329 | ||
332 | } |
330 | } |
333 | 331 | ||
334 | /** Put pixel - 16-bit depth (5:6:5) */ |
332 | /** Put pixel - 16-bit depth (5:6:5) */ |
335 | static void putpixel_2byte(int item,unsigned int x, unsigned int y, int color) |
333 | static void putpixel_2byte(int item,unsigned int x, unsigned int y, int color) |
336 | { |
334 | { |
337 | /* 5-bit, 6-bits, 5-bits */ |
335 | /* 5-bit, 6-bits, 5-bits */ |
338 | *((__u16 *)(FB(item,fbaddress) + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5); |
336 | *((__u16 *)(FB(item,fbaddress) + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5); |
339 | } |
337 | } |
340 | 338 | ||
341 | /** Return pixel color - 16-bit depth (5:6:5) */ |
339 | /** Return pixel color - 16-bit depth (5:6:5) */ |
342 | static int getpixel_2byte(int item,unsigned int x, unsigned int y) |
340 | static int getpixel_2byte(int item,unsigned int x, unsigned int y) |
343 | { |
341 | { |
344 | int color = *((__u16 *)(FB(item,fbaddress) + POINTPOS(x, y))); |
342 | int color = *((__u16 *)(FB(item,fbaddress) + POINTPOS(x, y))); |
345 | return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
343 | return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
346 | } |
344 | } |
347 | 345 | ||
348 | /** Put pixel - 8-bit depth (3:2:3) */ |
346 | /** Put pixel - 8-bit depth (3:2:3) */ |
349 | static void putpixel_1byte(int item,unsigned int x, unsigned int y, int color) |
347 | static void putpixel_1byte(int item,unsigned int x, unsigned int y, int color) |
350 | { |
348 | { |
351 | FB(item,fbaddress)[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3); |
349 | FB(item,fbaddress)[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3); |
352 | } |
350 | } |
353 | 351 | ||
354 | /** Return pixel color - 8-bit depth (3:2:3) */ |
352 | /** Return pixel color - 8-bit depth (3:2:3) */ |
355 | static int getpixel_1byte(int item,unsigned int x, unsigned int y) |
353 | static int getpixel_1byte(int item,unsigned int x, unsigned int y) |
356 | { |
354 | { |
357 | int color = FB(item,fbaddress)[POINTPOS(x, y)]; |
355 | int color = FB(item,fbaddress)[POINTPOS(x, y)]; |
358 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
356 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
359 | } |
357 | } |
360 | 358 | ||
361 | /** Fill line with color BGCOLOR */ |
359 | /** Fill line with color BGCOLOR */ |
362 | static void clear_line(int item,unsigned int y) |
360 | static void clear_line(int item,unsigned int y) |
363 | { |
361 | { |
364 | unsigned int x; |
362 | unsigned int x; |
365 | for (x = 0; x < FB(item,xres); x++) |
363 | for (x = 0; x < FB(item,xres); x++) |
366 | FB(item,putpixel)(item,x, y, FB(item,BGCOLOR)); |
364 | FB(item,putpixel)(item,x, y, FB(item,BGCOLOR)); |
367 | } |
365 | } |
368 | 366 | ||
369 | 367 | ||
370 | /** Fill screen with background color */ |
368 | /** Fill screen with background color */ |
371 | static void clear_screen(int item) |
369 | static void clear_screen(int item) |
372 | { |
370 | { |
373 | unsigned int y; |
371 | unsigned int y; |
374 | for (y = 0; y < FB(item,yres); y++) |
372 | for (y = 0; y < FB(item,yres); y++) |
375 | { |
373 | { |
376 | clear_line(item,y); pl |
374 | clear_line(item,y); pl |
377 | } |
375 | } |
378 | } |
376 | } |
379 | 377 | ||
380 | 378 | ||
381 | /** Scroll screen one row up */ |
379 | /** Scroll screen one row up */ |
382 | static void scroll_screen(int item) |
380 | static void scroll_screen(int item) |
383 | { |
381 | { |
384 | unsigned int i; |
382 | unsigned int i; |
385 | unsigned int j; |
383 | unsigned int j; |
386 | 384 | ||
387 | for(j=0;j<FB(item,yres)-FONT_SCANLINES;j++) |
385 | for(j=0;j<FB(item,yres)-FONT_SCANLINES;j++) |
388 | memcpy((void *) FB(item,fbaddress)+j*FB(item,scanline), |
386 | memcpy((void *) FB(item,fbaddress)+j*FB(item,scanline), |
389 | (void *) &FB(item,fbaddress)[ROW_BYTES+j*FB(item,scanline)], FB(item,pixelbytes)*FB(item,xres)); |
387 | (void *) &FB(item,fbaddress)[ROW_BYTES+j*FB(item,scanline)], FB(item,pixelbytes)*FB(item,xres)); |
390 | 388 | ||
391 | //memcpy((void *) FB(item,fbaddress), (void *) &FB(item,fbaddress)[ROW_BYTES], FB(item,scanline) * FB(item,yres) - ROW_BYTES); |
389 | //memcpy((void *) FB(item,fbaddress), (void *) &FB(item,fbaddress)[ROW_BYTES], FB(item,scanline) * FB(item,yres) - ROW_BYTES); |
392 | 390 | ||
393 | /* Clear last row */ |
391 | /* Clear last row */ |
394 | for (i = 0; i < FONT_SCANLINES; i++) |
392 | for (i = 0; i < FONT_SCANLINES; i++) |
395 | clear_line(item,(FB(item,rows) - 1) * FONT_SCANLINES + i); |
393 | clear_line(item,(FB(item,rows) - 1) * FONT_SCANLINES + i); |
396 | } |
394 | } |
397 | 395 | ||
398 | 396 | ||
399 | static void invert_pixel(int item,unsigned int x, unsigned int y) |
397 | static void invert_pixel(int item,unsigned int x, unsigned int y) |
400 | { |
398 | { |
401 | FB(item,putpixel)(item, x, y, ~FB(item,getpixel)(item, x, y)); |
399 | FB(item,putpixel)(item, x, y, ~FB(item,getpixel)(item, x, y)); |
402 | } |
400 | } |
403 | 401 | ||
404 | 402 | ||
405 | /** Draw one line of glyph at a given position */ |
403 | /** Draw one line of glyph at a given position */ |
406 | static void draw_glyph_line(int item,unsigned int glline, unsigned int x, unsigned int y) |
404 | static void draw_glyph_line(int item,unsigned int glline, unsigned int x, unsigned int y) |
407 | { |
405 | { |
408 | unsigned int i; |
406 | unsigned int i; |
409 | 407 | ||
410 | for (i = 0; i < 8; i++) |
408 | for (i = 0; i < 8; i++) |
411 | if (glline & (1 << (7 - i))) { |
409 | if (glline & (1 << (7 - i))) { |
412 | FB(item,putpixel)(item,x + i, y, FB(item,FGCOLOR)); |
410 | FB(item,putpixel)(item,x + i, y, FB(item,FGCOLOR)); |
413 | } else |
411 | } else |
414 | FB(item,putpixel)(item,x + i, y, FB(item,BGCOLOR)); |
412 | FB(item,putpixel)(item,x + i, y, FB(item,BGCOLOR)); |
415 | } |
413 | } |
416 | 414 | ||
417 | /***************************************************************/ |
415 | /***************************************************************/ |
418 | /* Character-console functions */ |
416 | /* Character-console functions */ |
419 | 417 | ||
420 | /** Draw character at given position */ |
418 | /** Draw character at given position */ |
421 | static void draw_glyph(int item,__u8 glyph, unsigned int col, unsigned int row) |
419 | static void draw_glyph(int item,__u8 glyph, unsigned int col, unsigned int row) |
422 | { |
420 | { |
423 | unsigned int y; |
421 | unsigned int y; |
424 | 422 | ||
425 | for (y = 0; y < FONT_SCANLINES; y++) |
423 | for (y = 0; y < FONT_SCANLINES; y++) |
426 | draw_glyph_line(item ,fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y); |
424 | draw_glyph_line(item ,fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y); |
427 | } |
425 | } |
428 | 426 | ||
429 | /** Invert character at given position */ |
427 | /** Invert character at given position */ |
430 | static void invert_char(int item,unsigned int col, unsigned int row) |
428 | static void invert_char(int item,unsigned int col, unsigned int row) |
431 | { |
429 | { |
432 | unsigned int x; |
430 | unsigned int x; |
433 | unsigned int y; |
431 | unsigned int y; |
434 | 432 | ||
435 | for (x = 0; x < COL_WIDTH; x++) |
433 | for (x = 0; x < COL_WIDTH; x++) |
436 | for (y = 0; y < FONT_SCANLINES; y++) |
434 | for (y = 0; y < FONT_SCANLINES; y++) |
437 | invert_pixel(item,col * COL_WIDTH + x, row * FONT_SCANLINES + y); |
435 | invert_pixel(item,col * COL_WIDTH + x, row * FONT_SCANLINES + y); |
438 | } |
436 | } |
439 | 437 | ||
440 | /** Draw character at default position */ |
438 | /** Draw character at default position */ |
441 | static void draw_char(int item,char chr) |
439 | static void draw_char(int item,char chr) |
442 | { |
440 | { |
443 | draw_glyph(item ,chr, FB(item,position) % FB(item,columns), FB(item,position) / FB(item,columns)); |
441 | draw_glyph(item ,chr, FB(item,position) % FB(item,columns), FB(item,position) / FB(item,columns)); |
444 | } |
442 | } |
445 | 443 | ||
446 | static void draw_logo(int item,unsigned int startx, unsigned int starty) |
444 | static void draw_logo(int item,unsigned int startx, unsigned int starty) |
447 | { |
445 | { |
448 | unsigned int x; |
446 | unsigned int x; |
449 | unsigned int y; |
447 | unsigned int y; |
450 | unsigned int byte; |
448 | unsigned int byte; |
451 | unsigned int rowbytes; |
449 | unsigned int rowbytes; |
452 | 450 | ||
453 | rowbytes = (helenos_width - 1) / 8 + 1; |
451 | rowbytes = (helenos_width - 1) / 8 + 1; |
454 | 452 | ||
455 | for (y = 0; y < helenos_height; y++) |
453 | for (y = 0; y < helenos_height; y++) |
456 | for (x = 0; x < helenos_width; x++) { |
454 | for (x = 0; x < helenos_width; x++) { |
457 | byte = helenos_bits[rowbytes * y + x / 8]; |
455 | byte = helenos_bits[rowbytes * y + x / 8]; |
458 | byte >>= x % 8; |
456 | byte >>= x % 8; |
459 | if (byte & 1) |
457 | if (byte & 1) |
460 | FB(item,putpixel)(item,startx + x, starty + y, FB(item,LOGOCOLOR)); |
458 | FB(item,putpixel)(item,startx + x, starty + y, FB(item,LOGOCOLOR)); |
461 | } |
459 | } |
462 | } |
460 | } |
463 | 461 | ||
464 | /***************************************************************/ |
462 | /***************************************************************/ |
465 | /* Stdout specific functions */ |
463 | /* Stdout specific functions */ |
466 | 464 | ||
467 | static void invert_cursor(int item) |
465 | static void invert_cursor(int item) |
468 | { |
466 | { |
469 | invert_char(item,FB(item,position) % FB(item,columns), FB(item,position) / FB(item,columns)); |
467 | invert_char(item,FB(item,position) % FB(item,columns), FB(item,position) / FB(item,columns)); |
470 | } |
468 | } |
471 | 469 | ||
472 | /** Print character to screen |
470 | /** Print character to screen |
473 | * |
471 | * |
474 | * Emulate basic terminal commands |
472 | * Emulate basic terminal commands |
475 | */ |
473 | */ |
476 | static void fb_putchar(int item,char ch) |
474 | static void fb_putchar(int item,char ch) |
477 | { |
475 | { |
478 | 476 | ||
479 | switch (ch) { |
477 | switch (ch) { |
480 | case '\n': |
478 | case '\n': |
481 | invert_cursor(item); |
479 | invert_cursor(item); |
482 | FB(item,position) += FB(item,columns); |
480 | FB(item,position) += FB(item,columns); |
483 | FB(item,position) -= FB(item,position) % FB(item,columns); |
481 | FB(item,position) -= FB(item,position) % FB(item,columns); |
484 | break; |
482 | break; |
485 | case '\r': |
483 | case '\r': |
486 | invert_cursor(item); |
484 | invert_cursor(item); |
487 | FB(item,position) -= FB(item,position) % FB(item,columns); |
485 | FB(item,position) -= FB(item,position) % FB(item,columns); |
488 | break; |
486 | break; |
489 | case '\b': |
487 | case '\b': |
490 | invert_cursor(item); |
488 | invert_cursor(item); |
491 | if (FB(item,position) % FB(item,columns)) |
489 | if (FB(item,position) % FB(item,columns)) |
492 | FB(item,position)--; |
490 | FB(item,position)--; |
493 | break; |
491 | break; |
494 | case '\t': |
492 | case '\t': |
495 | invert_cursor(item); |
493 | invert_cursor(item); |
496 | do { |
494 | do { |
497 | draw_char(item,' '); |
495 | draw_char(item,' '); |
498 | FB(item,position)++; |
496 | FB(item,position)++; |
499 | } while (FB(item,position) % 8); |
497 | } while (FB(item,position) % 8); |
500 | break; |
498 | break; |
501 | default: |
499 | default: |
502 | draw_char(item,ch); |
500 | draw_char(item,ch); |
503 | FB(item,position)++; |
501 | FB(item,position)++; |
504 | } |
502 | } |
505 | 503 | ||
506 | if (FB(item,position) >= FB(item,columns) * FB(item,rows)) { |
504 | if (FB(item,position) >= FB(item,columns) * FB(item,rows)) { |
507 | FB(item,position) -= FB(item,columns); |
505 | FB(item,position) -= FB(item,columns); |
508 | scroll_screen(item); |
506 | scroll_screen(item); |
509 | } |
507 | } |
510 | 508 | ||
511 | invert_cursor(item); |
509 | invert_cursor(item); |
512 | 510 | ||
513 | } |
511 | } |
514 | 512 | ||
515 | 513 | ||
516 | /** Initialize framebuffer as a chardev output device |
514 | /** Initialize framebuffer as a chardev output device |
517 | * |
515 | * |
518 | * @param addr Address of theframebuffer |
516 | * @param addr Address of theframebuffer |
519 | * @param x Screen width in pixels |
517 | * @param x Screen width in pixels |
520 | * @param y Screen height in pixels |
518 | * @param y Screen height in pixels |
521 | * @param bpp Bits per pixel (8, 16, 24, 32) |
519 | * @param bpp Bits per pixel (8, 16, 24, 32) |
522 | * @param scan Bytes per one scanline |
520 | * @param scan Bytes per one scanline |
523 | * |
521 | * |
524 | */ |
522 | */ |
525 | void fb_init(int item,__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, |
523 | void fb_init(int item,__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, |
526 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR) |
524 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR) |
527 | { |
525 | { |
528 | 526 | ||
529 | if( (graphics_items[item]=malloc(sizeof(framebuffer_descriptor_t))) ==NULL) |
527 | if( (graphics_items[item]=malloc(sizeof(framebuffer_descriptor_t))) ==NULL) |
530 | { |
528 | { |
531 | return; |
529 | return; |
532 | } |
530 | } |
533 | 531 | ||
534 | switch (bpp) { |
532 | switch (bpp) { |
535 | case 8: |
533 | case 8: |
536 | FB(item,putpixel) = putpixel_1byte; |
534 | FB(item,putpixel) = putpixel_1byte; |
537 | FB(item,getpixel) = getpixel_1byte; |
535 | FB(item,getpixel) = getpixel_1byte; |
538 | FB(item,pixelbytes) = 1; |
536 | FB(item,pixelbytes) = 1; |
539 | break; |
537 | break; |
540 | case 16: |
538 | case 16: |
541 | FB(item,putpixel) = putpixel_2byte; |
539 | FB(item,putpixel) = putpixel_2byte; |
542 | FB(item,getpixel) = getpixel_2byte; |
540 | FB(item,getpixel) = getpixel_2byte; |
543 | FB(item,pixelbytes) = 2; |
541 | FB(item,pixelbytes) = 2; |
544 | break; |
542 | break; |
545 | case 24: |
543 | case 24: |
546 | FB(item,putpixel) = putpixel_3byte; |
544 | FB(item,putpixel) = putpixel_3byte; |
547 | FB(item,getpixel) = getpixel_3byte; |
545 | FB(item,getpixel) = getpixel_3byte; |
548 | FB(item,pixelbytes) = 3; |
546 | FB(item,pixelbytes) = 3; |
549 | break; |
547 | break; |
550 | case 32: |
548 | case 32: |
551 | FB(item,putpixel) = putpixel_4byte; |
549 | FB(item,putpixel) = putpixel_4byte; |
552 | FB(item,getpixel) = getpixel_4byte; |
550 | FB(item,getpixel) = getpixel_4byte; |
553 | FB(item,pixelbytes) = 4; |
551 | FB(item,pixelbytes) = 4; |
554 | break; |
552 | break; |
555 | } |
553 | } |
556 | 554 | ||
557 | 555 | ||
558 | FB(item,fbaddress) = (unsigned char *) addr; pl |
556 | FB(item,fbaddress) = (unsigned char *) addr; pl |
559 | FB(item,xres) = x; pl |
557 | FB(item,xres) = x; pl |
560 | FB(item,yres) = y; pl |
558 | FB(item,yres) = y; pl |
561 | FB(item,scanline) = scan; pl |
559 | FB(item,scanline) = scan; pl |
562 | 560 | ||
563 | 561 | ||
564 | FB(item,rows) = y / FONT_SCANLINES; pl |
562 | FB(item,rows) = y / FONT_SCANLINES; pl |
565 | FB(item,columns) = x / COL_WIDTH; pl |
563 | FB(item,columns) = x / COL_WIDTH; pl |
566 | 564 | ||
567 | FB(item,BGCOLOR)=BGCOLOR; |
565 | FB(item,BGCOLOR)=BGCOLOR; |
568 | FB(item,FGCOLOR)=FGCOLOR; |
566 | FB(item,FGCOLOR)=FGCOLOR; |
569 | FB(item,LOGOCOLOR)=LOGOCOLOR; |
567 | FB(item,LOGOCOLOR)=LOGOCOLOR; |
570 | 568 | ||
571 | 569 | ||
572 | clear_screen(item); pl |
570 | clear_screen(item); pl |
573 | draw_logo(item,FB(item,xres) - helenos_width, 0); pl |
571 | draw_logo(item,FB(item,xres) - helenos_width, 0); pl |
574 | invert_cursor(item); pl |
572 | invert_cursor(item); pl |
575 | 573 | ||
576 | } |
574 | } |
577 | 575 | ||
578 | 576 | ||
579 | static int get_free_item() |
577 | static int get_free_item() |
580 | { |
578 | { |
581 | int item; |
579 | int item; |
582 | for(item=0;graphics_items[item]!=NULL;item++); |
580 | for(item=0;graphics_items[item]!=NULL;item++); |
583 | return (item==GRAPHICS_ITEMS)?EFB:item; |
581 | return (item==GRAPHICS_ITEMS)?EFB:item; |
584 | } |
582 | } |
585 | 583 | ||
586 | unsigned int mod_col(unsigned int col,int mod) |
584 | unsigned int mod_col(unsigned int col,int mod) |
587 | { |
585 | { |
588 | if(mod & 1) col^=0xff; |
586 | if(mod & 1) col^=0xff; |
589 | if(mod & 2) col^=0xff00; |
587 | if(mod & 2) col^=0xff00; |
590 | if(mod & 4) col^=0xff0000; |
588 | if(mod & 4) col^=0xff0000; |
591 | return col; |
589 | return col; |
592 | } |
590 | } |
593 | 591 | ||
594 | 592 | ||
595 | int create_window(int item,unsigned int x, unsigned int y,unsigned int x_size, unsigned int y_size, |
593 | int create_window(int item,unsigned int x, unsigned int y,unsigned int x_size, unsigned int y_size, |
596 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR) |
594 | unsigned int BGCOLOR,unsigned int FGCOLOR,unsigned int LOGOCOLOR) |
597 | { |
595 | { |
598 | int item_new; |
596 | int item_new; |
599 | 597 | ||
600 | if(EFB==(item_new=get_free_item()))return EFB; |
598 | if(EFB==(item_new=get_free_item()))return EFB; |
601 | 599 | ||
602 | 600 | ||
603 | if( (graphics_items[item_new]=malloc(sizeof(framebuffer_descriptor_t))) ==NULL) |
601 | if( (graphics_items[item_new]=malloc(sizeof(framebuffer_descriptor_t))) ==NULL) |
604 | { |
602 | { |
605 | return EFB; |
603 | return EFB; |
606 | } |
604 | } |
607 | 605 | ||
608 | 606 | ||
609 | 607 | ||
610 | FB(item_new,putpixel) = FB(item,putpixel); |
608 | FB(item_new,putpixel) = FB(item,putpixel); |
611 | FB(item_new,getpixel) = FB(item,getpixel); |
609 | FB(item_new,getpixel) = FB(item,getpixel); |
612 | FB(item_new,pixelbytes) = FB(item,pixelbytes); |
610 | FB(item_new,pixelbytes) = FB(item,pixelbytes); |
613 | 611 | ||
614 | FB(item_new,fbaddress) = FB(item,fbaddress) + POINTPOS(x, y) ; |
612 | FB(item_new,fbaddress) = FB(item,fbaddress) + POINTPOS(x, y) ; |
615 | FB(item_new,xres) = x_size; |
613 | FB(item_new,xres) = x_size; |
616 | FB(item_new,yres) = y_size; |
614 | FB(item_new,yres) = y_size; |
617 | FB(item_new,scanline) = FB(item,scanline); |
615 | FB(item_new,scanline) = FB(item,scanline); |
618 | 616 | ||
619 | 617 | ||
620 | FB(item_new,rows) = y_size / FONT_SCANLINES; |
618 | FB(item_new,rows) = y_size / FONT_SCANLINES; |
621 | FB(item_new,columns) = x_size / COL_WIDTH; |
619 | FB(item_new,columns) = x_size / COL_WIDTH; |
622 | 620 | ||
623 | FB(item_new,BGCOLOR)=BGCOLOR; |
621 | FB(item_new,BGCOLOR)=BGCOLOR; |
624 | FB(item_new,FGCOLOR)=FGCOLOR; |
622 | FB(item_new,FGCOLOR)=FGCOLOR; |
625 | FB(item_new,LOGOCOLOR)=LOGOCOLOR; |
623 | FB(item_new,LOGOCOLOR)=LOGOCOLOR; |
626 | 624 | ||
627 | 625 | ||
628 | clear_screen(item_new); |
626 | clear_screen(item_new); |
629 | draw_logo(item_new,FB(item_new,xres) - helenos_width, 0); |
627 | draw_logo(item_new,FB(item_new,xres) - helenos_width, 0); |
630 | invert_cursor(item_new); |
628 | invert_cursor(item_new); |
631 | 629 | ||
632 | return item_new; |
630 | return item_new; |
633 | } |
631 | } |
634 | 632 | ||
635 | 633 | ||
636 | 634 | ||
637 | 635 |