36static int console_width, console_height,
43static unsigned char *console_fb = 0LL;
45static int cursor_x, cursor_y, max_x, max_y, offset_x, offset_y, pixel_max_x, pixel_max_y;
57static inline void console_pset32(
int x,
int y,
int color)
59#define fbint ((uint32_t*)console_fb)
60#define base (((y >> 5)*32*console_width + ((x >> 5)<<10) \
61 + (x&3) + ((y&1)<<2) + (((x&31)>>2)<<3) + (((y&31)>>1)<<6)) ^ ((y&8)<<2))
67void console_pset(
int x,
int y,
unsigned char r,
unsigned char g,
unsigned char b) {
68 console_pset32(x + offset_x, y + offset_y, (b<<24) + (g<<16) + (r<<8));
74 console_pset32(pixel_max_x - x, y + offset_y, (b<<24) + (g<<16) + (r<<8));
79static void console_draw_char(
const int x,
const int y,
const unsigned char c) {
80#define font_pixel(ch, x, y) ((fontdata_8x16[ch*16+y]>>(7-x))&1)
82 for (ly=0; ly < 16; ly++)
83 for (lx=0; lx < 8; lx++) {
89 unsigned int *fb = (
unsigned int*)console_fb;
90 int count = console_width * console_height;
94 memdcbst(console_fb, console_size*4);
105 char sp[max_x - startpos];
106 memset(sp,
' ', max_x - startpos);
107 sp[max_x - startpos - 1]=
'\0';
114static void console_scroll32(
const unsigned int lines) {
116 bs = console_width*32*4;
118 for (l=lines; l*32 < console_height; l++) {
119 memcpy(console_fb + bs*(l-lines),
130 memdcbst(console_fb, console_size*4);
136 while (cursor_x*8 < console_width) {
137 console_draw_char(cursor_x*8, cursor_y*16,
' ');
145 if (cursor_y >= max_y) {
157 }
else if (
c ==
'\n') {
160 console_draw_char(cursor_x*8 + offset_x, cursor_y*16 + offset_y,
c);
162 if (cursor_x >= max_x)
165 memdcbst(console_fb, console_size*4);
168static void console_stdout_hook(
const char *buf,
int len)
174extern void (*
stdout_hook)(
const char *buf,
int len);
179 console_fb = (
unsigned char*)(
long)(ai->
base | 0x80000000);
181 console_width = ((ai->
width+31)>>5)<<5;
182 console_height = ((ai->
height+31)>>5)<<5;
183 console_size = console_width*console_height;
185 offset_x = offset_y = 0;
188 offset_x = (ai->
width/28);
189 offset_y = (ai->
height/28);
192 cursor_x = cursor_y = 0;
193 pixel_max_x = ai->
width - offset_x * 2;
194 max_x = pixel_max_x / 8;
195 pixel_max_y = ai->
height - offset_y * 2;
196 max_y = pixel_max_y / 16;
202 printf(
" * Xenos FB with %dx%d (%dx%d) at %p initialized.\n",
void console_clear_to_eol(int startpos)
int console_get_cursor_max_x(void)
int console_get_cursor_y(void)
void console_pset_right(int x, int y, unsigned char r, unsigned char g, unsigned char b)
void(* stdout_hook)(const char *buf, int len)
void console_set_colors(unsigned int background, unsigned int foreground)
int console_get_cursor_x(void)
int console_get_cursor_max_y(void)
void console_get_dimensions(unsigned int *width, unsigned int *height)
void console_set_cursor(int x, int y)
#define font_pixel(ch, x, y)
uint32_t console_color[2]
void console_putch(const char c)
void console_pset(int x, int y, unsigned char r, unsigned char g, unsigned char b)
void memdcbst(void *addr, int len)
unsigned int __mf_uintptr_t __attribute__((__mode__(__pointer__)))
struct detailed_data_wpindex color