static void testmode(int mode) { int xmax, ymax, i, x, y, yw, ys, c; vga_modeinfo *modeinfo; vga_setmode(mode); modeinfo = vga_getmodeinfo(mode); printf("Width: %d Height: %d Colors: %d\n", modeinfo->width, modeinfo->height, modeinfo->colors); printf("DisplayStartRange: %xh Maxpixels: %d Blit: %s\n", modeinfo->startaddressrange, modeinfo->maxpixels, modeinfo->haveblit ? "YES" : "NO"); #ifdef TEST_MODEX if (modeinfo->colors == 256) printf("Switching to ModeX ... %s\n", (vga_setmodeX()? "done" : "failed")); #endif vga_screenoff(); xmax = vga_getxdim() - 1; ymax = vga_getydim() - 1; vga_setcolor(vga_white()); vga_drawline(0, 0, xmax, 0); vga_drawline(xmax, 0, xmax, ymax); vga_drawline(xmax, ymax, 0, ymax); vga_drawline(0, ymax, 0, 0); /* Draw crosses */ for (i = 0; i <= 15; i++) { vga_setegacolor(i); vga_drawline(10 + i * 5, 10, 89 + i * 5, 89); } for (i = 0; i <= 15; i++) { vga_setegacolor(i); vga_drawline(89 + i * 5, 10, 10 + i * 5, 89); } vga_screenon(); ys = 100; yw = (ymax - 100) / 4; switch (vga_getcolors()) { case 256: /* Draw horizontal color bands using palette */ for (i = 0; i < 60; ++i) { c = (i * 64) / 60; vga_setpalette(i + 16, c, c, c); vga_setpalette(i + 16 + 60, c, 0, 0); vga_setpalette(i + 16 + (2 * 60), 0, c, 0); vga_setpalette(i + 16 + (3 * 60), 0, 0, c); } line[0] = line[xmax] = 15; line[1] = line[xmax - 1] = 0; for (x = 2; x < xmax - 1; ++x) line[x] = (((x - 2) * 60) / (xmax - 3)) + 16; for (y = ys; y < ys + yw; ++y) /* gray */ vga_drawscanline(y, line); for (x = 2; x < xmax - 1; ++x) line[x] += 60; ys += yw; for (y = ys; y < ys + yw; ++y) /* red */ vga_drawscanline(y, line); for (x = 2; x < xmax - 1; ++x) line[x] += 60; ys += yw; for (y = ys; y < ys + yw; ++y) /* green */ vga_drawscanline(y, line); for (x = 2; x < xmax - 1; ++x) line[x] += 60; ys += yw; for (y = ys; y < ys + yw; ++y) /* blue */ vga_drawscanline(y, line); break; case 1 << 15: case 1 << 16: case 1 << 24: /* Draw horizontal color bands in RGB */ for (x = 2; x < xmax - 1; ++x) { c = ((x - 2) * 255) / (xmax - 4); y = ys; vga_setrgbcolor(c, c, c); vga_drawline(x, y, x, y + yw - 1); y += yw; vga_setrgbcolor(c, 0, 0); vga_drawline(x, y, x, y + yw - 1); y += yw; vga_setrgbcolor(0, c, 0); vga_drawline(x, y, x, y + yw - 1); y += yw; vga_setrgbcolor(0, 0, c); vga_drawline(x, y, x, y + yw - 1); } drawSquares(xmax, ymax); break; default: /* Draw vertical color bars */ if (vga_getcolors() == 16) { for (i = 0; i < xmax - 1; i++) line[i] = (i + 2) % 16; line[0] = line[xmax] = 15; line[1] = line[xmax - 1] = 0; } if (vga_getcolors() == 2) { for (i = 0; i <= xmax; i++) line[i] = 0x11; line[0] = 0x91; } for (i = 100; i < ymax - 1; i++) vga_drawscanline(i, line); break; } if (getchar() == 'd') vga_dumpregs(); }
int vga_clear(void) { vga_screenoff(); #ifdef BACKGROUND __svgalib_dont_switch_vt_yet(); #endif if (MODEX) goto modeX; switch (CM) { case G320x200x256: case G320x240x256: case G320x400x256: case G360x480x256: modeX: #ifdef BACKGROUND if (vga_oktowrite()) { #endif /* write to all planes */ port_out(0x02, SEQ_I); port_out(0x0F, SEQ_D); /* clear video memory */ memset(GM, 0, 65536); #ifdef BACKGROUND } else { int i; for (i = 0; i < 4; i++) { /* save plane i */ __svgalib_fast_setpage(i); memset(GM, 0, GRAPH_SIZE); } } #endif break; default: switch (CI.colors) { case 2: case 16: vga_setcolor(0); #ifdef BACKGROUND if (vga_oktowrite()) { #endif /* write to all bits */ port_out(0x08, GRA_I); port_out(0xFF, GRA_D); #ifdef BACKGROUND } #endif default: { int i; int pages = (CI.ydim * CI.xbytes + 65535) >> 16; #if defined(CONFIG_ALPHA_JENSEN) int j; #endif #ifdef BACKGROUND if (!vga_oktowrite()) { switch (CI.colors) { case 2: case 16: pages*=4; } } #endif for (i = 0; i < pages; ++i) { vga_setpage(i); #if defined(CONFIG_ALPHA_JENSEN) for (j = 0; j < 65536; j += 2) gr_writew(0, j); #else /* clear video memory */ memset(GM, 0, 65536); #endif } } break; } break; } vga_setcolor(15); #ifdef BACKGROUND __svgalib_is_vt_switching_needed(); #endif vga_screenon(); return 0; }