Changeset 95c7526 in mainline
- Timestamp:
- 2006-02-14T10:48:52Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fcbca14f
- Parents:
- fe050b7
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/mips32/src/console.c
rfe050b7 r95c7526 43 43 msim_console(); 44 44 #ifdef CONFIG_FB 45 fb_init(0xb2000000, 640, 480 );45 fb_init(0xb2000000, 640, 480, 3); // gxemul framebuffer 46 46 #endif 47 47 } -
genarch/include/fb/fb.h
rfe050b7 r95c7526 33 33 #include <arch/types.h> 34 34 35 void fb_init(__address addr, int x, int y );35 void fb_init(__address addr, int x, int y, int bytes); 36 36 37 37 #endif -
genarch/src/fb/fb.c
rfe050b7 r95c7526 35 35 SPINLOCK_INITIALIZE(fb_lock); 36 36 37 static unsigned char*fbaddress=NULL;37 static __u8 *fbaddress=NULL; 38 38 static int xres,yres; 39 39 static int position=0; 40 40 static int columns=0; 41 41 static int rows=0; 42 static int pixelbytes=0; 42 43 43 44 #define COL_WIDTH 8 44 45 #define ROW_HEIGHT (FONT_SCANLINES) 45 #define ROW_PIX (xres*ROW_HEIGHT* 3)46 #define ROW_PIX (xres*ROW_HEIGHT*pixelbytes) 46 47 47 48 #define BGCOLOR 0x000080 48 49 #define FGCOLOR 0xffff00 49 50 50 #define RED(x) ((x >> 16) & 0xff) 51 #define GREEN(x) ((x >> 8) & 0xff) 52 #define BLUE(x) (x & 0xff) 53 54 #define POINTPOS(x,y,colidx) ((y*xres+x)*3+colidx) 51 #define RED(x,bits) ((x >> (16+8-bits)) & ((1<<bits)-1)) 52 #define GREEN(x,bits) ((x >> (8+8-bits)) & ((1<<bits)-1)) 53 #define BLUE(x,bits) ((x >> (8-bits)) & ((1<<bits)-1)) 54 55 #define POINTPOS(x,y) ((y*xres+x)*pixelbytes) 56 57 /***************************************************************/ 58 /* Pixel specific fuctions */ 55 59 56 60 /** Draw pixel of given color on screen */ 57 61 static inline void putpixel(int x,int y,int color) 58 62 { 59 fbaddress[POINTPOS(x,y,0)] = RED(color); 60 fbaddress[POINTPOS(x,y,1)] = GREEN(color); 61 fbaddress[POINTPOS(x,y,2)] = BLUE(color); 62 } 63 64 /** Fill line with color BGCOLOR */ 65 static void clear_line(int y) 66 { 67 int x; 68 for (x=0; x<xres;x++) 69 putpixel(x,y,BGCOLOR); 70 } 71 72 /** Fill screen with background color */ 73 static void clear_screen(void) 74 { 75 int y; 76 77 for (y=0; y<yres;y++) 78 clear_line(y); 79 } 80 81 static void invert_pixel(int x, int y) 82 { 83 fbaddress[POINTPOS(x,y,0)] = ~fbaddress[POINTPOS(x,y,0)]; 84 fbaddress[POINTPOS(x,y,1)] = ~fbaddress[POINTPOS(x,y,1)]; 85 fbaddress[POINTPOS(x,y,2)] = ~fbaddress[POINTPOS(x,y,2)]; 86 } 87 63 int startbyte = POINTPOS(x,y); 64 65 if (pixelbytes == 3) { 66 fbaddress[startbyte] = RED(color,8); 67 fbaddress[startbyte+1] = GREEN(color,8); 68 fbaddress[startbyte+2] = BLUE(color,8); 69 } else if (pixelbytes == 4) { 70 *((__u32 *)(fbaddress+startbyte)) = color; 71 } else { 72 int compcolor; 73 /* 5-bit, 5-bits, 5-bits */ 74 compcolor = RED(color,5) << 10 \ 75 | GREEN(color,5) << 5 \ 76 | BLUE(color,5); 77 *((__u16 *)(fbaddress+startbyte)) = compcolor; 78 } 79 } 80 81 /** Return pixel color */ 82 static inline int getpixel(int x,int y) 83 { 84 int startbyte = POINTPOS(x,y); 85 int color; 86 int result; 87 88 if (pixelbytes == 3) { 89 result = fbaddress[startbyte] << 16 \ 90 | fbaddress[startbyte+1] << 8 \ 91 | fbaddress[startbyte+2]; 92 } else if (pixelbytes == 4) { 93 result = *((__u32 *)(fbaddress+startbyte)) & 0xffffff; 94 } else { 95 int red,green,blue; 96 color = *((__u16 *)(fbaddress+startbyte)); 97 red = (color >> 10) & 0x1f; 98 green = (color >> 5) & 0x1f; 99 blue = color & 0x1f; 100 result = (red << 16) | (green << 8) | blue; 101 } 102 return result; 103 } 104 105 static void clear_line(int y); 88 106 /** Scroll screen one row up */ 89 107 static void scroll_screen(void) … … 91 109 int i; 92 110 93 for (i=0;i < (xres*yres* 3)-ROW_PIX; i++)111 for (i=0;i < (xres*yres*pixelbytes)-ROW_PIX; i++) 94 112 fbaddress[i] = fbaddress[i+ROW_PIX]; 95 113 … … 99 117 100 118 } 119 120 121 /***************************************************************/ 122 /* Screen specific function */ 123 124 /** Fill line with color BGCOLOR */ 125 static void clear_line(int y) 126 { 127 int x; 128 for (x=0; x<xres;x++) 129 putpixel(x,y,BGCOLOR); 130 } 131 132 /** Fill screen with background color */ 133 static void clear_screen(void) 134 { 135 int y; 136 137 for (y=0; y<yres;y++) 138 clear_line(y); 139 } 140 141 static void invert_pixel(int x, int y) 142 { 143 putpixel(x,y, ~getpixel(x,y)); 144 } 145 101 146 102 147 /** Draw one line of glyph at a given position */ … … 112 157 } 113 158 159 /***************************************************************/ 160 /* Character-console functions */ 161 114 162 /** Draw character at given position */ 115 static void draw_glyph( unsigned charglyph, int col, int row)163 static void draw_glyph(__u8 glyph, int col, int row) 116 164 { 117 165 int y; … … 138 186 } 139 187 188 /***************************************************************/ 189 /* Stdout specific functions */ 190 140 191 static void invert_cursor(void) 141 192 { … … 162 213 if (position % columns) 163 214 position--; 215 } else if (ch == '\t') { 216 invert_cursor(); 217 do { 218 draw_char(' '); 219 position++; 220 } while (position % 8); 164 221 } else { 165 222 draw_char(ch); … … 185 242 * @param x X resolution 186 243 * @param y Y resolution 244 * @param bytes Bytes per pixel (2,3,4) 187 245 */ 188 void fb_init(__address addr, int x, int y )246 void fb_init(__address addr, int x, int y, int bytes) 189 247 { 190 248 fbaddress = (unsigned char *)addr; … … 192 250 xres = x; 193 251 yres = y; 252 pixelbytes = bytes; 194 253 195 254 rows = y/ROW_HEIGHT;
Note:
See TracChangeset
for help on using the changeset viewer.