int center_menu(struct menu * m) { ggi_mode currmode; ggiGetMode(m->w.vis,&currmode); m->w.xorigin = (currmode.visible.x - m->w.xsize ) /2; m->w.yorigin = (currmode.visible.y - m->w.ysize ) /2; if ((m->w.xorigin < 0) || (m->w.yorigin < 0)) { return -1; } return 0; }
static int query_format(uint32_t format) { ggi_mode mode; uint32_t vfcap; vfcap = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_ACCEPT_STRIDE; if ((!vo_depthonscreen || !vo_dbpp) && ggi_conf.vis) { if (ggiGetMode(ggi_conf.vis, &mode) == 0) { vo_depthonscreen = GT_DEPTH(mode.graphtype); vo_dbpp = GT_SIZE(mode.graphtype); } if (GT_SCHEME(mode.graphtype) == GT_AUTO) { ggiCheckMode(ggi_conf.vis, &mode); } if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) { mode.graphtype = GT_32BIT; vo_depthonscreen = GT_DEPTH(mode.graphtype); vo_dbpp = GT_SIZE(mode.graphtype); } } if ((IMGFMT_IS_BGR(format) && (IMGFMT_BGR_DEPTH(format) == vo_dbpp)) || (IMGFMT_IS_RGB(format) && (IMGFMT_RGB_DEPTH(format) == vo_dbpp))) { return vfcap; } if (IMGFMT_IS_BGR(format) || IMGFMT_IS_RGB(format)) { set_graphtype(format, &mode); if (ggiCheckMode(ggi_conf.drawvis, &mode) < 0) { return 0; } else { return vfcap; } } return (0); }
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { ggi_mode mode = { 1, /* frames */ {width, height}, /* visible */ {GGI_AUTO, GGI_AUTO}, /* virt */ {GGI_AUTO, GGI_AUTO}, /* size */ GT_AUTO, /* graphtype */ {GGI_AUTO, GGI_AUTO} /* dots per pixel */ }; set_graphtype(format, &mode); #if 0 printf("[ggi] mode: "); ggiPrintMode(&mode); printf("\n"); #endif ggiCheckMode(ggi_conf.vis, &mode); if (ggiSetMode(ggi_conf.vis, &mode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set display mode\n"); return (-1); } if (ggiGetMode(ggi_conf.vis, &mode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get display mode\n"); return (-1); } if ((mode.graphtype == GT_INVALID) || (mode.graphtype == GT_AUTO)) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] not supported depth/bpp\n"); return (-1); } #if 0 printf("[ggi] mode: "); ggiPrintMode(&mode); printf("\n"); #endif #ifdef HAVE_GGIWMH ggiWmhSetTitle(ggi_conf.vis, title); if (vo_ontop) window_ontop(); #endif ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC); if (GT_SCHEME(mode.graphtype) == GT_PALETTE) ggiSetColorfulPalette(ggi_conf.vis); if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) { ggi_mode drawmode; ggi_conf.drawvis = ggiOpen("display-memory", NULL); if (ggi_conf.drawvis == NULL) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get backbuffer for conversion\n"); return -1; } memcpy(&drawmode, &mode, sizeof(ggi_mode)); drawmode.graphtype = GT_32BIT; drawmode.size.x = GGI_AUTO; drawmode.size.y = GGI_AUTO; ggiCheckMode(ggi_conf.drawvis, &drawmode); if (ggiSetMode(ggi_conf.drawvis, &drawmode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set backbuffer mode\n"); return -1; } mode.graphtype = drawmode.graphtype; ggiSetFlags(ggi_conf.drawvis, GGIFLAG_ASYNC); } vo_depthonscreen = GT_DEPTH(mode.graphtype); vo_screenwidth = mode.virt.x; vo_screenheight = mode.virt.y; vo_dwidth = width; vo_dheight = height; vo_dbpp = GT_SIZE(mode.graphtype); /* calculate top, left corner */ vo_dx = (vo_screenwidth - vo_dwidth) / 2; vo_dy = (vo_screenheight - vo_dheight) / 2; ggi_conf.srcwidth = width; ggi_conf.srcheight = height; ggi_conf.srcformat = format; ggi_conf.voflags = flags; if (IMGFMT_IS_RGB(ggi_conf.srcformat)) { ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat); } else if (IMGFMT_IS_BGR(ggi_conf.srcformat)) { ggi_conf.srcdepth = IMGFMT_BGR_DEPTH(ggi_conf.srcformat); } else { mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", vo_format_name(ggi_conf.srcformat)); return (-1); } mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d\n", ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth, mode.virt.x, mode.virt.y, vo_dbpp); ggi_conf.srcbpp = (ggi_conf.srcdepth + 7) / 8; ggi_conf.flushregion.x1 = vo_dx; ggi_conf.flushregion.y1 = vo_dy; ggi_conf.flushregion.x2 = vo_dwidth; ggi_conf.flushregion.y2 = vo_dheight; return (0); }
void resolution(ggi_visual_t vis) { int xmax, ymax; ggi_mode currmode; ggiGetMode(vis, &currmode); xmax = currmode.visible.x; ymax = currmode.visible.y; ggiSetGCForeground(vis, blue); ggiDrawBox(vis, 0, 0, xmax, ymax); stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 1); ggiFlush(vis); if (waitabit(vis)) return; stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 2); ggiFlush(vis); if (waitabit(vis)) return; stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 3); ggiFlush(vis); if (waitabit(vis)) return; stripevert(vis, 0, 0, xmax - 1, ymax - 1, black, white, 4); ggiFlush(vis); if (waitabit(vis)) return; stripehor(vis, 0, 0, xmax - 1, ymax - 1, black, white, 1); ggiFlush(vis); if (waitabit(vis)) return; stripehor(vis, 0, 0, xmax - 1, ymax - 1, black, white, 2); ggiFlush(vis); if (waitabit(vis)) return; starone(vis, 0, 0, xmax - 1, ymax - 1, black, white); ggiFlush(vis); if (waitabit(vis)) return; starfive(vis, 0, 0, xmax - 1, ymax - 1, white, black); ggiFlush(vis); if (waitabit(vis)) return; startwoten(vis, 0, 0, xmax - 1, ymax - 1, white, black); ggiFlush(vis); if (waitabit(vis)) return; ggiSetGCForeground(vis, black); ggiDrawBox(vis, 0, 0, xmax, ymax); stripevert(vis, 1 * xmax / 16, 2 * ymax / 8, 3 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 4); stripevert(vis, 3 * xmax / 16, 2 * ymax / 8, 5 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 3); stripevert(vis, 5 * xmax / 16, 2 * ymax / 8, 7 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 2); stripevert(vis, 7 * xmax / 16, 2 * ymax / 8, 9 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 1); stripevert(vis, 9 * xmax / 16, 2 * ymax / 8, 11 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 2); stripevert(vis, 11 * xmax / 16, 2 * ymax / 8, 13 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 3); stripevert(vis, 13 * xmax / 16, 2 * ymax / 8, 15 * xmax / 16 - 1, 3 * ymax / 8 - 1, black, red, 4); stripevert(vis, 1 * xmax / 16, 3 * ymax / 8, 3 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 4); stripevert(vis, 3 * xmax / 16, 3 * ymax / 8, 5 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 3); stripevert(vis, 5 * xmax / 16, 3 * ymax / 8, 7 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 2); stripevert(vis, 7 * xmax / 16, 3 * ymax / 8, 9 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 1); stripevert(vis, 9 * xmax / 16, 3 * ymax / 8, 11 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 2); stripevert(vis, 11 * xmax / 16, 3 * ymax / 8, 13 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 3); stripevert(vis, 13 * xmax / 16, 3 * ymax / 8, 15 * xmax / 16 - 1, 4 * ymax / 8 - 1, black, green, 4); stripevert(vis, 1 * xmax / 16, 4 * ymax / 8, 3 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 4); stripevert(vis, 3 * xmax / 16, 4 * ymax / 8, 5 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 3); stripevert(vis, 5 * xmax / 16, 4 * ymax / 8, 7 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 2); stripevert(vis, 7 * xmax / 16, 4 * ymax / 8, 9 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 1); stripevert(vis, 9 * xmax / 16, 4 * ymax / 8, 11 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 2); stripevert(vis, 11 * xmax / 16, 4 * ymax / 8, 13 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 3); stripevert(vis, 13 * xmax / 16, 4 * ymax / 8, 15 * xmax / 16 - 1, 5 * ymax / 8 - 1, black, blue, 4); stripevert(vis, 1 * xmax / 16, 5 * ymax / 8, 3 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 4); stripevert(vis, 3 * xmax / 16, 5 * ymax / 8, 5 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 3); stripevert(vis, 5 * xmax / 16, 5 * ymax / 8, 7 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 2); stripevert(vis, 7 * xmax / 16, 5 * ymax / 8, 9 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 1); stripevert(vis, 9 * xmax / 16, 5 * ymax / 8, 11 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 2); stripevert(vis, 11 * xmax / 16, 5 * ymax / 8, 13 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 3); stripevert(vis, 13 * xmax / 16, 5 * ymax / 8, 15 * xmax / 16 - 1, 6 * ymax / 8 - 1, black, white, 4); ggiFlush(vis); if (waitabit(vis)) return; }
void graphicsinit(char *svgamode) //initialization of graphics, mode according to X_LOPIF { const short cur[32] = { 0x9FFF, 0x0FFF, 0x07FF, 0x83FF, 0xC1FF, 0xE0FF, 0xF067, 0xF003, 0xF001, 0xF000, 0xF800, 0xF800, 0xF800, 0xFC00, 0xFC00, 0xFC00, 0x0000, 0x6000, 0x7000, 0x3800, 0x1C00, 0x0E00, 0x0700, 0x0018, 0x07EC, 0x07EE, 0x001E, 0x03EE, 0x03EE, 0x001E, 0x00EC, 0x0002 }; xg_256=MM_Hic; //set Hicolor flag... initpalette(); x_settextjusty(0,2); // always write text from upper left corner #ifdef GGI // printf("Initializing GGI visual target.\n"); ggiVis = ggiOpen (NULL); ggiGetMode (ggiVis, &origMode); ggiSetSimpleMode (ggiVis, 800, 600, 1, GT_16BIT); SVGAx=799; SVGAy=599; ggiAddFlags(ggiVis,GGIFLAG_ASYNC); #else strupr(svgamode); // printf("Console switched to graphics mode.\n"); if(strstr(svgamode,".I")) { vga_setmode(G640x480x64K); gl_setcontextvga(G640x480x64K); SVGAx=639; SVGAy=479; } else if(strstr(svgamode,".K")) { vga_setmode(G1024x768x64K); gl_setcontextvga(G1024x768x64K); SVGAx=1023; SVGAy=767; } else if(strstr(svgamode,".L")) { vga_setmode(G1280x1024x64K); gl_setcontextvga(G1280x1024x64K); SVGAx=1279; SVGAy=1023; } if(strstr(svgamode,".M")) { vga_setmode(G1600x1200x64K); gl_setcontextvga(G1600x1200x64K); SVGAx=1599; SVGAy=1199; } { vga_setmode(G800x600x64K); gl_setcontextvga(G800x600x64K); SVGAx=799; SVGAy=599; } vga_runinbackground(1); vga_oktowrite(); gl_setwritemode(FONT_COMPRESSED|WRITEMODE_MASKED); gl_setfontcolors(0,vga_white()); //gl_setfont(8,8,gl_font8x8); gl_setrgbpalette(); gl_enableclipping(); #endif x_defcurs( (short *)cur, (short *)&cur[16], 15); //mouse kursor }