static void ensure_size( ) { int w = minsize.width, h = minsize.height; getmaxyx(stdscr, Term.height, Term.width); if (Term.height < h || Term.width < w) { getmaxyx(stdscr, Term.height, Term.width); nodelay(stdscr, FALSE); while (Term.height < h || Term.width < w) { erase(); attrset(COLOR_ATTR(7)); mvprintw(1,0,"Brogue needs a terminal window that is at least [%d x %d]", w, h); attrset(COLOR_ATTR(15)); mvprintw(2,0,"If your terminal can be resized, resize it now.\n"); attrset(COLOR_ATTR(7)); mvprintw(3,0,"Press ctrl-c at any time to quit.\n"); #ifdef BROGUE_TCOD mvprintw(5,0,"To use libtcod, start the game with the -gl or --SDL.\n\n"); #endif printw("Width: %d/%d\n", Term.width, w); printw("Height: %d/%d\n", Term.height, h); mvprintw(10, 0, "Colors (pairs): %d (%d)\n", COLORS, COLOR_PAIRS); getch(); getmaxyx(stdscr, Term.height, Term.width); } nodelay(stdscr, TRUE); erase(); refresh(); } }
static void term_mvaddch(int x, int y, int ch, fcolor *fg, fcolor *bg) { if (x < 0 || y < 0 || x >= minsize.width || y >= minsize.height) return; if (colormode == coerce_16) { int c = best(fg, bg); attrset(COLOR_ATTR(c)); mvaddch(y, x, ch); } else { buffer_plot(ch, x, y, fg, bg); } }
#include <vga.h> uint16_t* video_memory; uint8_t terminal_color = COLOR_ATTR(LGRAY, BLACK); size_t terminal_row = 0; size_t terminal_column = 0; void init_video(){ video_memory = (uint16_t*) VIDEO_MEMORY; clear(); } void update_cursor(){ uint16_t pos = (terminal_row*VGA_COLS) + terminal_column; outb(0x3D4, 0x0F); outb(0x3D5, (uint8_t)(pos & 0xFF)); outb(0x3D4, 0x0E); outb(0x3D5, (uint8_t)((pos >> 8) & 0xFF)); } void clear(){ uint16_t blank = 0x20 | (terminal_color << 8); memsetw(video_memory, blank, VGA_COLS*VGA_ROWS); terminal_row = 0; terminal_column = 0; update_cursor();