/* int gr_mode=0; MWPIXELVAL gr_background=0; MWPALENTRY gr_palette[256]; int GdError(const char *fmt, ...) { syscall_puts(fmt); } */ int test_driver() { int x1,x2,y1,y2,c; MWSCREENINFO sinfo; MWPALENTRY *stdpal; psd = scrdev.Open(&scrdev); if(!psd) return NULL; GdGetScreenInfo(psd, &sinfo); sint2dec(sinfo.pixtype,s); display_puts("pixtype="); display_puts(s); display_puts("\nncolors="); sint2dec(sinfo.ncolors,s); display_puts(s); display_puts("\npsd.ncolors="); sint2dec((int)psd->ncolors,s); display_puts(s); display_puts("\n"); //gr_firstuserpalentry = FIRSTUSERPALENTRY; GdResetPalette(); stdpal = mwstdpal8; GdSetPalette(psd, 0, (int)psd->ncolors, stdpal); //scrdev.FillRect(&scrdev,0,0,639,479,0); //x1=100; x2=540; y1=100; y2= 380; c=7; //scrdev.DrawHorzLine(&scrdev,x1,x2,y1,c); //scrdev.DrawVertLine(&scrdev,x2,y1,y2,c); //scrdev.DrawHorzLine(&scrdev,x1,x2,y2,c); //scrdev.DrawVertLine(&scrdev,x1,y1,y2,c); //syscall_wait(100); scrdev.Close(&scrdev); return 0; }
/* * Initialize the graphics and mouse devices at startup. * Returns nonzero with a message printed if the initialization failed. */ int GsInitialize(void) { GR_WINDOW *wp; /* root window */ static IMAGEBITS cursorbits[16] = { 0xe000, 0x9800, 0x8600, 0x4180, 0x4060, 0x2018, 0x2004, 0x107c, 0x1020, 0x0910, 0x0988, 0x0544, 0x0522, 0x0211, 0x000a, 0x0004 }; static IMAGEBITS cursormask[16] = { 0xe000, 0xf800, 0xfe00, 0x7f80, 0x7fe0, 0x3ff8, 0x3ffc, 0x1ffc, 0x1fe0, 0x0ff0, 0x0ff8, 0x077c, 0x073e, 0x021f, 0x000e, 0x0004 }; wp = (GR_WINDOW *) malloc(sizeof(GR_WINDOW)); if (wp == NULL) { fprintf(stderr, "Cannot allocate root window\n"); return -1; } #if !NONETWORK if (GsOpenSocket() < 0) { perror("Cannot bind to named socket"); free(wp); return -1; } #endif if ((keyb_fd = GdOpenKeyboard()) < 0) { perror("Cannot initialise keyboard"); /*GsCloseSocket();*/ free(wp); return -1; } if (GdOpenScreen() < 0) { perror("Cannot initialise screen"); /*GsCloseSocket();*/ GdCloseKeyboard(); free(wp); return -1; } if ((mouse_fd = GdOpenMouse()) == -1) { /* -2 == mou_nul.c */ perror("Cannot initialise mouse"); /*GsCloseSocket();*/ GdCloseScreen(); GdCloseKeyboard(); free(wp); return -1; } /* * Get screen dimensions for our own and the client's use, * and the information about the default font. */ GdGetScreenInfo(&scrdev, &sinfo); GdGetFontInfo(&scrdev, FONT_OEM_FIXED, &curfont); GdGetModifierInfo(&sinfo.modifiers); GdGetButtonInfo(&sinfo.buttons); /* * Initialize the root window. */ wp->id = GR_ROOT_WINDOW_ID; wp->parent = wp; wp->children = NULL; wp->siblings = NULL; wp->next = NULL; wp->x = 0; wp->y = 0; wp->width = sinfo.cols; wp->height = sinfo.rows; wp->bordersize = 0; wp->background = BLACK; wp->bordercolor = BLACK; wp->nopropmask = 0; wp->eventclients = NULL; wp->cursor = NULL; wp->mapped = GR_TRUE; wp->unmapcount = 0; wp->output = GR_TRUE; listwp = wp; rootwp = wp; focuswp = wp; mousewp = wp; focusfixed = GR_FALSE; /* * Initialize and position the default cursor. */ curcursor = NULL; cursorx = -1; cursory = -1; GsMoveCursor(sinfo.cols / 2, sinfo.rows / 2); GsSetCursor(GR_ROOT_WINDOW_ID, 16, 16, 0, 0, WHITE, BLACK, cursorbits, cursormask); #if FRAMEBUFFER | BOGL fb_InitVt(); #endif scrdev.FillRect(&scrdev, 0, 0, sinfo.cols-1, sinfo.rows-1, GdFindColor(BLACK)); /* * Finally tell the mouse driver some things. */ curbuttons = 0; /*GdSetAccelMouse(5, 3);*/ GdRestrictMouse(0, 0, sinfo.cols - 1, sinfo.rows - 1); GdMoveMouse(sinfo.cols / 2, sinfo.rows / 2); GsFlush(); /* * All done. */ connectcount = 0; return 0; }
/* * Open low level graphics driver */ PSD GdOpenScreen(void) { PSD psd; MWPALENTRY * stdpal; MWSCREENINFO sinfo; psd = scrdev.Open(&scrdev); if (!psd) return NULL; GdGetScreenInfo(psd, &sinfo); gr_pixtype = sinfo.pixtype; gr_ncolors = sinfo.ncolors; /* assume no user changable palette entries*/ gr_firstuserpalentry = (int)psd->ncolors; /* set palette according to system colors and devpalX.c*/ switch((int)psd->ncolors) { #if !defined(NOSTDPAL1) /* don't require stdpal1 if not needed */ case 2: /* 1bpp*/ { extern MWPALENTRY mwstdpal1[2]; stdpal = mwstdpal1; } break; #endif #if !defined(NOSTDPAL2) /* don't require stdpal2 if not needed */ case 4: /* 2bpp*/ { extern MWPALENTRY mwstdpal2[4]; stdpal = mwstdpal2; } break; #endif #if !defined(NOSTDPAL4) /* don't require stdpal4 if not needed */ case 8: /* 3bpp - not fully supported*/ case 16: /* 4bpp*/ { extern MWPALENTRY mwstdpal4[16]; stdpal = mwstdpal4; } break; #endif #if !defined(NOSTDPAL8) /* don't require large stdpal8 if not needed */ case 256: /* 8bpp*/ { extern MWPALENTRY mwstdpal8[256]; #if xxxALPHABLEND /* don't change uniform palette if alpha blending*/ gr_firstuserpalentry = 256; #else /* start after last system-reserved color*/ gr_firstuserpalentry = FIRSTUSERPALENTRY; #endif stdpal = mwstdpal8; } break; #endif /* !defined(NOSTDPAL8)*/ default: /* truecolor*/ /* no palette*/ gr_firstuserpalentry = 0; stdpal = NULL; } /* reset next user palette entry, write hardware palette*/ GdResetPalette(); GdSetPalette(psd, 0, (int)psd->ncolors, stdpal); #if xxxALPHABLEND /* one-time create alpha lookup table for 8bpp systems (takes ~1 sec)*/ if(psd->ncolors == 256) init_alpha_lookup(); #endif #if !NOFONTSORCLIPPING /* init local vars*/ GdSetMode(MWMODE_COPY); GdSetForeground(GdFindColor(MWRGB(255, 255, 255))); /* WHITE*/ GdSetBackground(GdFindColor(MWRGB(0, 0, 0))); /* BLACK*/ GdSetUseBackground(TRUE); GdSetFont(GdCreateFont(psd, MWFONT_SYSTEM_VAR, 0, NULL)); #if DYNAMICREGIONS GdSetClipRegion(psd, GdAllocRectRegion(0, 0, psd->xvirtres, psd->yvirtres)); #else GdSetClipRects(psd, 0, NULL); #endif /* DYNAMICREGIONS*/ #endif /* NOFONTSORCLIPPING*/ /* fill black (actually fill to first palette entry or truecolor 0*/ psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1, 0); return psd; }