/* 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; }
/* * 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; }
/** * Open low level graphics driver. * * @return The screen drawing surface. */ PSD GdOpenScreen(void) { PSD psd; MWPALENTRY * stdpal; psd = scrdev.Open(&scrdev); if (!psd) return NULL; /* 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 UNIFORMPALETTE /* 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); /* init local vars*/ GdSetMode(MWROP_COPY); GdSetFillMode(MWFILL_SOLID); /* Set the fill mode to solid */ GdSetForegroundColor(psd, MWRGB(255, 255, 255)); /* WHITE*/ GdSetBackgroundColor(psd, MWRGB(0, 0, 0)); /* BLACK*/ GdSetUseBackground(TRUE); /* select first builtin font (usually MWFONT_SYSTEM_VAR)*/ //GdSetFont(GdCreateFont(psd, NULL, 0, 0, NULL)); GdSetDash(0, 0); /* No dashing to start */ GdSetStippleBitmap(0,0,0); /* No stipple to start */ #if !NOCLIPPING #if DYNAMICREGIONS GdSetClipRegion(psd, GdAllocRectRegion(0, 0, psd->xvirtres, psd->yvirtres)); #else GdSetClipRects(psd, 0, NULL); #endif /* DYNAMICREGIONS*/ #endif /* NOCLIPPING*/ /* 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; }