static void gfxconsole_putc(char c) { static enum { NORMAL, ESCAPE } state = NORMAL; static uint32_t p_num = 0; switch (state) { case NORMAL: { if(c == '\n' || c == '\r') { gfxconsole.x = 0; gfxconsole.y++; } else if (c == 0x1b) { p_num = 0; state = ESCAPE; } else { font_draw_char(gfxconsole.surface, c, gfxconsole.x * FONT_X, gfxconsole.y * FONT_Y, gfxconsole.front_color); gfxconsole.x++; } break; } case ESCAPE: { if (c >= '0' && c <= '9') { p_num = (p_num * 10) + (c - '0'); } else if (c == 'D') { if (p_num <= gfxconsole.x) gfxconsole.x -= p_num; state = NORMAL; } else if (c == '[') { // eat this character } else { font_draw_char(gfxconsole.surface, c, gfxconsole.x * FONT_X, gfxconsole.y * FONT_Y, gfxconsole.front_color); gfxconsole.x++; state = NORMAL; } break; } } if(gfxconsole.x >= gfxconsole.columns) { gfxconsole.x = 0; gfxconsole.y++; } if(gfxconsole.y >= gfxconsole.rows) { // scroll up gfx_copyrect(gfxconsole.surface, 0, FONT_Y, gfxconsole.surface->width, gfxconsole.surface->height - FONT_Y - gfxconsole.extray, 0, 0); gfxconsole.y--; gfx_fillrect(gfxconsole.surface, 0, gfxconsole.surface->height - FONT_Y - gfxconsole.extray, gfxconsole.surface->width, FONT_Y, gfxconsole.back_color); gfx_flush(gfxconsole.surface); } }
int main() { int i; gfx_rect_t rect; uint32_t color; uint16_t fbuff[320*240]; key_data_t keys, no_keys; // setup function pointers dprintf = FUNC(0x04); gfx_init = FUNC(0x38); gfx_set_framebuffer = FUNC(0x90); gfx_set_display_screen= FUNC(0x54); gfx_set_cammmode = FUNC(0x8c); gfx_set_colorrop = FUNC(0x3c); gfx_set_fgcolor = FUNC(0x44); gfx_get_fgcolor = FUNC(0x48); gfx_fillrect = FUNC(0xc4); gfx_enable_feature = FUNC(0x7c); gfx_flush = FUNC(0xc); gfx_paint = FUNC(0x10); get_time = FUNC(0x124); get_keys = FUNC(0x100); // dprintf("Hello World!\n"); gfx_init(fbuff, sizeof(fbuff)); rect.x = 0; rect.y = 0; rect.width = 320; rect.height = 240; gfx_set_framebuffer(320, 240); gfx_set_display_screen(&rect);//320, 240); color = MAKE_RGB(255,0,0); gfx_enable_feature(3); gfx_set_fgcolor(&color); gfx_set_colorrop(COLOR_ROP_NOP); gfx_fillrect(&rect); rect.x = 30; rect.y = 30; rect.width = 260; rect.height = 180; color = MAKE_RGB(0,255,0); gfx_set_fgcolor(&color); gfx_set_colorrop(COLOR_ROP_NOP); gfx_fillrect(&rect); rect.x = 60; rect.y = 60; rect.width = 200; rect.height = 120; color = MAKE_RGB(0,0,255); gfx_set_fgcolor(&color); gfx_set_colorrop(COLOR_ROP_NOP); gfx_fillrect(&rect); /* // is it used at all ? for (i=0; i<320; i++) fbuff[(100*320)+i] = 0; */ gfx_set_colorrop(COLOR_ROP_NOP); gfx_flush(); gfx_paint(); get_keys(&no_keys); // no_keys.key2 &= ~0x5ff0; while (1) { get_keys(&keys); // keys.key2 &= ~0x5ff0; if (keys.key2 != no_keys.key2) break; } return 0; }