Rev 1871 | Rev 1888 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1871 | Rev 1875 | ||
---|---|---|---|
Line 58... | Line 58... | ||
58 | static unsigned int xres = 0; |
58 | static unsigned int xres = 0; |
59 | static unsigned int yres = 0; |
59 | static unsigned int yres = 0; |
60 | static unsigned int scanline = 0; |
60 | static unsigned int scanline = 0; |
61 | static unsigned int bitspp = 0; |
61 | static unsigned int bitspp = 0; |
62 | static unsigned int pixelbytes = 0; |
62 | static unsigned int pixelbytes = 0; |
- | 63 | #ifdef FB_INVERT_COLORS |
|
- | 64 | static bool invert_colors = true; |
|
- | 65 | #else |
|
- | 66 | static bool invert_colors = false; |
|
- | 67 | #endif |
|
63 | 68 | ||
64 | static unsigned int position = 0; |
69 | static unsigned int position = 0; |
65 | static unsigned int columns = 0; |
70 | static unsigned int columns = 0; |
66 | static unsigned int rows = 0; |
71 | static unsigned int rows = 0; |
67 | 72 | ||
68 | - | ||
69 | #define COL_WIDTH 8 |
73 | #define COL_WIDTH 8 |
70 | #define ROW_BYTES (scanline * FONT_SCANLINES) |
74 | #define ROW_BYTES (scanline * FONT_SCANLINES) |
71 | 75 | ||
72 | #define BGCOLOR 0x000080 |
76 | #define BGCOLOR 0x000080 |
73 | #define FGCOLOR 0xffff00 |
77 | #define FGCOLOR 0xffff00 |
Line 83... | Line 87... | ||
83 | /* Pixel specific fuctions */ |
87 | /* Pixel specific fuctions */ |
84 | 88 | ||
85 | static void (*rgb2scr)(void *, int); |
89 | static void (*rgb2scr)(void *, int); |
86 | static int (*scr2rgb)(void *); |
90 | static int (*scr2rgb)(void *); |
87 | 91 | ||
- | 92 | static inline int COLOR(int color) |
|
- | 93 | { |
|
- | 94 | return invert_colors ? ~color : color; |
|
- | 95 | } |
|
- | 96 | ||
88 | /* Conversion routines between different color representations */ |
97 | /* Conversion routines between different color representations */ |
89 | static void rgb_4byte(void *dst, int rgb) |
98 | static void rgb_4byte(void *dst, int rgb) |
90 | { |
99 | { |
91 | *(int *)dst = rgb; |
100 | *(int *)dst = rgb; |
92 | } |
101 | } |
Line 157... | Line 166... | ||
157 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
166 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
158 | } |
167 | } |
159 | 168 | ||
160 | static void putpixel(unsigned int x, unsigned int y, int color) |
169 | static void putpixel(unsigned int x, unsigned int y, int color) |
161 | { |
170 | { |
162 | (*rgb2scr)(&fbaddress[POINTPOS(x,y)],color); |
171 | (*rgb2scr)(&fbaddress[POINTPOS(x,y)], COLOR(color)); |
163 | 172 | ||
164 | if (dbbuffer) { |
173 | if (dbbuffer) { |
165 | int dline = (y + dboffset) % yres; |
174 | int dline = (y + dboffset) % yres; |
166 | (*rgb2scr)(&dbbuffer[POINTPOS(x,dline)],color); |
175 | (*rgb2scr)(&dbbuffer[POINTPOS(x,dline)], COLOR(color)); |
167 | } |
176 | } |
168 | } |
177 | } |
169 | 178 | ||
170 | /** Get pixel from viewport */ |
179 | /** Get pixel from viewport */ |
171 | static int getpixel(unsigned int x, unsigned int y) |
180 | static int getpixel(unsigned int x, unsigned int y) |
172 | { |
181 | { |
173 | if (dbbuffer) { |
182 | if (dbbuffer) { |
174 | int dline = (y + dboffset) % yres; |
183 | int dline = (y + dboffset) % yres; |
175 | return (*scr2rgb)(&dbbuffer[POINTPOS(x,dline)]); |
184 | return COLOR((*scr2rgb)(&dbbuffer[POINTPOS(x,dline)])); |
176 | } |
185 | } |
177 | return (*scr2rgb)(&fbaddress[POINTPOS(x,y)]); |
186 | return COLOR((*scr2rgb)(&fbaddress[POINTPOS(x,y)])); |
178 | } |
187 | } |
179 | 188 | ||
180 | 189 | ||
181 | /** Fill screen with background color */ |
190 | /** Fill screen with background color */ |
182 | static void clear_screen(void) |
191 | static void clear_screen(void) |
Line 272... | Line 281... | ||
272 | for (y = 0; y < helenos_height; y++) |
281 | for (y = 0; y < helenos_height; y++) |
273 | for (x = 0; x < helenos_width; x++) { |
282 | for (x = 0; x < helenos_width; x++) { |
274 | byte = helenos_bits[rowbytes * y + x / 8]; |
283 | byte = helenos_bits[rowbytes * y + x / 8]; |
275 | byte >>= x % 8; |
284 | byte >>= x % 8; |
276 | if (byte & 1) |
285 | if (byte & 1) |
277 | putpixel(startx + x, starty + y, LOGOCOLOR); |
286 | putpixel(startx + x, starty + y, COLOR(LOGOCOLOR)); |
278 | } |
287 | } |
279 | } |
288 | } |
280 | 289 | ||
281 | /***************************************************************/ |
290 | /***************************************************************/ |
282 | /* Stdout specific functions */ |
291 | /* Stdout specific functions */ |
Line 395... | Line 404... | ||
395 | sysinfo_set_item_val("fb.height", NULL, yres); |
404 | sysinfo_set_item_val("fb.height", NULL, yres); |
396 | sysinfo_set_item_val("fb.bpp", NULL, bpp); |
405 | sysinfo_set_item_val("fb.bpp", NULL, bpp); |
397 | sysinfo_set_item_val("fb.bpp-align", NULL, align); |
406 | sysinfo_set_item_val("fb.bpp-align", NULL, align); |
398 | sysinfo_set_item_val("fb.scanline", NULL, scan); |
407 | sysinfo_set_item_val("fb.scanline", NULL, scan); |
399 | sysinfo_set_item_val("fb.address.physical", NULL, addr); |
408 | sysinfo_set_item_val("fb.address.physical", NULL, addr); |
- | 409 | sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors); |
|
400 | 410 | ||
401 | /* Allocate double buffer */ |
411 | /* Allocate double buffer */ |
402 | int totsize = scanline * yres; |
412 | int totsize = scanline * yres; |
403 | int pages = SIZE2FRAMES(totsize); |
413 | int pages = SIZE2FRAMES(totsize); |
404 | int order; |
414 | int order; |
Line 414... | Line 424... | ||
414 | 424 | ||
415 | /* Initialized blank line */ |
425 | /* Initialized blank line */ |
416 | blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC); |
426 | blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC); |
417 | if (!blankline) |
427 | if (!blankline) |
418 | panic("Failed to allocate blank line for framebuffer."); |
428 | panic("Failed to allocate blank line for framebuffer."); |
419 | for (y=0; y < FONT_SCANLINES; y++) |
429 | for (y=0; y < FONT_SCANLINES; y++) { |
420 | for (x=0; x < xres; x++) |
430 | for (x=0; x < xres; x++) { |
421 | (*rgb2scr)(&blankline[POINTPOS(x,y)],BGCOLOR); |
431 | (*rgb2scr)(&blankline[POINTPOS(x,y)], COLOR(BGCOLOR)); |
- | 432 | } |
|
- | 433 | } |
|
422 | 434 | ||
423 | clear_screen(); |
435 | clear_screen(); |
424 | 436 | ||
425 | /* Update size of screen to match text area */ |
437 | /* Update size of screen to match text area */ |
426 | yres = rows * FONT_SCANLINES; |
438 | yres = rows * FONT_SCANLINES; |