Subversion Repositories HelenOS-historic

Rev

Rev 1366 | Rev 1404 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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