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);
102 memset(sp,
' ', max_x);
107static void console_scroll32(
const unsigned int lines) {
109 bs = console_width*32*4;
111 for (l=lines; l*32 < console_height; l++) {
112 memcpy(console_fb + bs*(l-lines),
123 memdcbst(console_fb, console_size*4);
129 while (cursor_x*8 < console_width) {
130 console_draw_char(cursor_x*8, cursor_y*16,
' ');
138 if (cursor_y >= max_y) {
150 }
else if (
c ==
'\n') {
153 console_draw_char(cursor_x*8 + offset_x, cursor_y*16 + offset_y,
c);
155 if (cursor_x >= max_x)
158 memdcbst(console_fb, console_size*4);
161static void console_stdout_hook(
const char *buf,
int len)
167extern void (*
stdout_hook)(
const char *buf,
int len);
172 console_fb = (
unsigned char*)(
long)(ai->
base | 0x80000000);
174 console_width = ((ai->
width+31)>>5)<<5;
175 console_height = ((ai->
height+31)>>5)<<5;
176 console_size = console_width*console_height;
178 offset_x = offset_y = 0;
181 offset_x = (ai->
width/28);
182 offset_y = (ai->
height/28);
185 cursor_x = cursor_y = 0;
186 pixel_max_x = ai->
width - offset_x * 2;
187 max_x = pixel_max_x / 8;
188 pixel_max_y = ai->
height - offset_y * 2;
189 max_y = pixel_max_y / 16;
195 printf(
" * Xenos FB with %dx%d (%dx%d) at %p initialized.\n",
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)
void console_get_dimensions(unsigned int *width, unsigned int *height)
#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