int ui_init(int *fd_keyboard, int *fd_mouse) { int dac_shift, i, mouse_type, force_red; if (vga_init() == 0) { old_mode = vga_getcurrentmode(); vga_setmode(G640x480x256); /*vga_setlinearaddressing();*/ if (vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_FLAGS) & VGA_CLUT8) { vga_ext_set(VGA_EXT_SET, VGA_CLUT8); dac_shift = 0; } else dac_shift = 2; force_red = 0xFF; for (i = 0; i < 255; i++) vga_setpalette(i, i >> dac_shift, (i & force_red) >> dac_shift, (i & force_red) >> dac_shift); vga_setpalette(UI_LO_COLOR, 127 >> dac_shift, 0, 0); /* Save dim red for UI */ vga_setpalette(UI_HI_COLOR, 255 >> dac_shift, 0, 0); /* Save bright red for UI */ vga = vga_getmodeinfo(vga_getcurrentmode()); }
void SetVideoMode(short mode) { _mode_ = mode; vga_init (); if (!(vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_SET) & (1 << VGA_EXT_PAGE_OFFSET))) { puts("You need at least svgalib 1.2.10 to run this program!\n"); exit(1); } if (!vga_hasmode (_mode_)) { fprintf (stderr, "Mode not available.\n"); exit (-1); } vga_setmode (_mode_); _ginfo_ = vga_getmodeinfo (_mode_); dX = _ginfo_->width; dY = _ginfo_->height; }