/* * print xboot's character logo. */ void xboot_char_logo(struct console * console, u32_t x0, u32_t y0) { u32_t i, len; s32_t w, h; char buf[64]; if(!console) return; if(!console_getwh(console, &w, &h)) return; if(x0 + 1 > w || y0 + 1 > h) return; for(i = 0; i < 6; i++) { len = strlen(&xboot[i][0]); if( len <= w - x0 ) sprintf(buf, "%s", &xboot[i][0]); else { strncpy(buf, &xboot[i][0], w - x0); buf[w - x0] = 0; } console_gotoxy(console, x0, y0 + i); console_print(console, (const char *)buf); } }
/* * refresh game area */ static void refresh(void) { struct console * con = get_console_stdout(); s32_t w, h; s32_t x, y, xp, yp; if(!con) return; for(y=0; y < GAME_AREA_HEIGHT; y++) { if(map.dirty[y] == FALSE) continue; for(x=0; x < GAME_AREA_WIDTH; x++) { console_getwh(con, &w, &h); xp = (w - GAME_AREA_WIDTH) / 2; yp = (h - GAME_AREA_HEIGHT) / 2; console_gotoxy(con, xp + x, yp + y); if(map.screen[x][y] != TCOLOR_BLACK) console_setcolor(con, TCOLOR_BLACK, map.screen[x][y]); else console_setcolor(con, TCOLOR_WHITE, TCOLOR_BLACK); console_putcode(con, UNICODE_SPACE); } map.dirty[y] = FALSE; } }
bool_t console_vline(struct console * console, u32_t code, u32_t x0, u32_t y0, u32_t y) { s32_t w, h; s32_t i; if(console && console->putcode) { if(!console_getwh(console, &w, &h)) return FALSE; if(x0 >= w || y0 >= h) return FALSE; if(y0 + y >= h) y = h - y0; for(i = 0; i < y; i++) { console->gotoxy(console, x0, y0 + i); console->putcode(console, code); } return TRUE; } return FALSE; }
bool_t console_hline(struct console * console, u32_t code, u32_t x0, u32_t y0, u32_t x) { s32_t w, h; s32_t i; if(console && console->putcode) { if(!console_getwh(console, &w, &h)) return FALSE; if(x0 >= w || y0 >= h) return FALSE; if(x0 + x >= w) x = w - x0; if(!console_gotoxy(console, x0, y0)) return FALSE; for(i = 0; i < x; i++) console->putcode(console, code); return TRUE; } return FALSE; }
bool_t console_rect(struct console * console, u32_t hline, u32_t vline, u32_t lt, u32_t rt, u32_t lb, u32_t rb, u32_t x, u32_t y, u32_t w, u32_t h) { s32_t width, height; if(console && console->putcode) { if(!console_getwh(console, &width, &height)) return FALSE; if(x < 0 || y < 0 || w < 2 || h < 2) return FALSE; if(x >= width || y >= height) return FALSE; if(x + w - 1 >= width) return FALSE; if(y + h - 1 >= height) return FALSE; console_gotoxy(console, x, y); console_putcode(console, lt); console_gotoxy(console, x + w - 1, y); console_putcode(console, rt); console_gotoxy(console, x, y + h - 1); console_putcode(console, lb); console_gotoxy(console, x + w - 1, y + h - 1); console_putcode(console, rb); console_hline(console, hline, x + 1, y, w - 1 - 1); console_hline(console, hline, x + 1, y + h - 1, w - 1 - 1); console_vline(console, vline, x, y + 1, h - 1 - 1); console_vline(console, vline, x + w - 1, y + 1, h - 1 - 1); return TRUE; } return FALSE; }