📄 scr_quasarosd.c
字号:
unsigned short Rc,Gc,Bc; Rc=compute_f(START,END,PRECISION,powertwodottwotable,R); Gc=compute_f(START,END,PRECISION,powertwodottwotable,G); Bc=compute_f(START,END,PRECISION,powertwodottwotable,B); gammacorrectedrgbtoyuv(Rc,Gc,Bc,y,u,v);}void tvyuvtovgargb(unsigned short y,unsigned short u,unsigned short v,unsigned short *R,unsigned short *G,unsigned short *B){ unsigned short Ruc,Guc,Buc; yuvtorgbgammacorrected(y,u,v,&Ruc,&Guc,&Buc); *R=compute_f(START,END,PRECISION,invertofpowertwodottwotable,Ruc); *G=compute_f(START,END,PRECISION,invertofpowertwodottwotable,Guc); *B=compute_f(START,END,PRECISION,invertofpowertwodottwotable,Buc);}/* convert Microwindows palette to Quasar format and set it*/static voidqosd_setpalette(PSD psd,int first, int count, MWPALENTRY *palette){ int i; unsigned char *pal=osd_buffer_addr+8;#undef TRACE#define TRACE printf("In %s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__); TRACE#undef TRACE#define TRACE pal+=first*4; /* convert palette to quasar format*/ for(i=0; i < count; i++) { MWPALENTRY *p = &palette[i]; unsigned short Y,U,V; unsigned short R,G,B; // RGB->YUVe computation: R = RANGE8TO16(p->r); G = RANGE8TO16(p->g); B = RANGE8TO16(p->b); gammacorrectedrgbtoyuv(R,G,B,&Y,&U,&V);// vgargbtotvyuv(R,G,B,&Y,&U,&V);// printf("[%3d] RGB= %5d , %5d , %5d\t",i+first,R,G,B);// printf("[%3d] YUV= %5d , %5d , %5d\n",i+first,Y,U,V); // hardcode alpha blending values if (i==0) pal[0] = 0x00; else if (i == 6) pal[0] = 0x66; else if (i == 15) pal[0] = 0x80; else if (i == 242) pal[0] = 0x80; else pal[0] = 0xff; pal[1] = (unsigned char)(Y >> 8); pal[2] = (unsigned char)(U >> 8); pal[3] = (unsigned char)(V >> 8); pal+=4; }}static voidgen_getscreeninfo(PSD psd,PMWSCREENINFO psi){ TRACE psi->rows = psd->yvirtres; psi->cols = psd->xvirtres; psi->planes = psd->planes; psi->bpp = psd->bpp; psi->ncolors = psd->ncolors; psi->fonts = NUMBER_FONTS; psi->portrait = psd->portrait; psi->fbdriver = FALSE; /* not running fb driver, can direct map*/ psi->pixtype = psd->pixtype; switch (psd->pixtype) { case MWPF_TRUECOLOR0888: case MWPF_TRUECOLOR888: psi->rmask = 0xff0000; psi->gmask = 0x00ff00; psi->bmask = 0x0000ff; break; case MWPF_TRUECOLOR565: psi->rmask = 0xf800; psi->gmask = 0x07e0; psi->bmask = 0x001f; break; case MWPF_TRUECOLOR555: psi->rmask = 0x7c00; psi->gmask = 0x03e0; psi->bmask = 0x001f; break; case MWPF_TRUECOLOR332: psi->rmask = 0xe0; psi->gmask = 0x1c; psi->bmask = 0x03; break; case MWPF_PALETTE: default: psi->rmask = 0xff; psi->gmask = 0xff; psi->bmask = 0xff; break; } if(psd->yvirtres > 480) { /* SVGA 800x600*/ psi->xdpcm = 33; /* assumes screen width of 24 cm*/ psi->ydpcm = 33; /* assumes screen height of 18 cm*/ } else if(psd->yvirtres > 350) { /* VGA 640x480*/ psi->xdpcm = 27; /* assumes screen width of 24 cm*/ psi->ydpcm = 27; /* assumes screen height of 18 cm*/ } else if(psd->yvirtres <= 240) { /* half VGA 640x240 */ psi->xdpcm = 14; /* assumes screen width of 24 cm*/ psi->ydpcm = 5; } else { /* EGA 640x350*/ psi->xdpcm = 27; /* assumes screen width of 24 cm*/ psi->ydpcm = 19; /* assumes screen height of 18 cm*/ }}static void qosd_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c){ ADDR8 addr = psd->addr; TRACE assert (addr != 0); assert (x >= 0 && x < psd->xres); assert (y >= 0 && y < psd->yres); assert (c < psd->ncolors); DRAWON; if(gr_mode == MWMODE_COPY) addr[x + y * psd->linelen] = c; else applyOp(gr_mode, c, &addr[ x + y * psd->linelen], ADDR8); DRAWOFF;}/* Read pixel at x, y*/static MWPIXELVAL qosd_readpixel(PSD psd, MWCOORD x, MWCOORD y){ ADDR8 addr = psd->addr; TRACE assert (addr != 0); assert (x >= 0 && x < psd->xres); assert (y >= 0 && y < psd->yres); return addr[x + y * psd->linelen];}/* Draw horizontal line from x1,y to x2,y including final point*/static void qosd_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c){ ADDR8 addr = psd->addr; TRACE assert (addr != 0); assert (x1 >= 0 && x1 < psd->xres); assert (x2 >= 0 && x2 < psd->xres); assert (x2 >= x1); assert (y >= 0 && y < psd->yres); assert (c < psd->ncolors); DRAWON; addr += x1 + y * psd->linelen; if(gr_mode == MWMODE_COPY) memset(addr, c, x2 - x1 + 1); else { while(x1++ <= x2) { applyOp(gr_mode, c, addr, ADDR8); ++addr; } } DRAWOFF;}/* Draw a vertical line from x,y1 to x,y2 including final point*/static void qosd_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c){ ADDR8 addr = psd->addr; int linelen = psd->linelen; TRACE assert (addr != 0); assert (x >= 0 && x < psd->xres); assert (y1 >= 0 && y1 < psd->yres); assert (y2 >= 0 && y2 < psd->yres); assert (y2 >= y1); assert (c < psd->ncolors); DRAWON; addr += x + y1 * linelen; if(gr_mode == MWMODE_COPY) { while(y1++ <= y2) { *addr = c; addr += linelen; } } else { while(y1++ <= y2) { applyOp(gr_mode, c, addr, ADDR8); addr += linelen; } } DRAWOFF;}/*void qosd_fillrect(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2, MWPIXELVAL c){ gen_fillrect(psd, x1, y1, x2, y2, c);}*//* srccopy bitblt*/static void qosd_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op){ ADDR8 dst; ADDR8 src; int dlinelen = dstpsd->linelen; int slinelen = srcpsd->linelen;#if 0 //ALPHABLEND unsigned int srcalpha, dstalpha;#endif TRACE assert (dstpsd->addr != 0); assert (dstx >= 0 && dstx < dstpsd->xres); assert (dsty >= 0 && dsty < dstpsd->yres); assert (w > 0); assert (h > 0); assert (srcpsd->addr != 0); assert (srcx >= 0 && srcx < srcpsd->xres); assert (srcy >= 0 && srcy < srcpsd->yres); assert (dstx+w <= dstpsd->xres); assert (dsty+h <= dstpsd->yres); assert (srcx+w <= srcpsd->xres); assert (srcy+h <= srcpsd->yres); DRAWON; dst = dstpsd->addr + dstx + dsty * dlinelen; src = srcpsd->addr + srcx + srcy * slinelen;#if 0 //XXX ALPHABLEND if((op & MWROP_EXTENSION) != MWROP_BLENDCONSTANT) goto stdblit; srcalpha = op & 0xff; /* FIXME create lookup table after palette is stabilized...*/ if(!rgb_to_palindex || !alpha_to_rgb) { init_alpha_lookup(); if(!rgb_to_palindex || !alpha_to_rgb) goto stdblit; } /* Create 5 bit alpha value index for 256 color indexing*/ /* destination alpha is (1 - source) alpha*/ dstalpha = ((srcalpha>>3) ^ 31) << 8; srcalpha = (srcalpha>>3) << 8; while(--h >= 0) { int i; for(i=0; i<w; ++i) { /* Get source RGB555 value for source alpha value*/ unsigned short s = alpha_to_rgb[srcalpha + *src++]; /* Get destination RGB555 value for dest alpha value*/ unsigned short d = alpha_to_rgb[dstalpha + *dst]; /* Add RGB values together and get closest palette index to it*/ *dst++ = rgb_to_palindex[s + d]; } dst += dlinelen - w; src += slinelen - w; } DRAWOFF; return;stdblit:#endif if (op == MWROP_COPY) { /* copy from bottom up if dst in src rectangle*/ /* memmove is used to handle x case*/ if (srcy < dsty) { src += (h-1) * slinelen; dst += (h-1) * dlinelen; slinelen *= -1; dlinelen *= -1; } while(--h >= 0) { /* a _fast_ memcpy is a _must_ in this routine*/ memmove(dst, src, w); dst += dlinelen; src += slinelen; } } else { while (--h >= 0) { int i; for (i=0; i<w; i++) { applyOp(MWROP_TO_MODE(op), *src, dst, ADDR8); ++src; ++dst; } dst += dlinelen - w; src += slinelen - w; } } DRAWOFF;}/* srccopy stretchblt*/static void qosd_stretchblit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw, MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, MWCOORD srcw, MWCOORD srch, long op){ ADDR8 dst; ADDR8 src; int dlinelen = dstpsd->linelen; int slinelen = srcpsd->linelen; int i, ymax; int row_pos, row_inc; int col_pos, col_inc; unsigned char pixel = 0; TRACE assert (dstpsd->addr != 0); assert (dstx >= 0 && dstx < dstpsd->xres); assert (dsty >= 0 && dsty < dstpsd->yres); assert (dstw > 0); assert (dsth > 0); assert (srcpsd->addr != 0); assert (srcx >= 0 && srcx < srcpsd->xres); assert (srcy >= 0 && srcy < srcpsd->yres); assert (srcw > 0); assert (srch > 0); assert (dstx+dstw <= dstpsd->xres); assert (dsty+dsth <= dstpsd->yres); assert (srcx+srcw <= srcpsd->xres); assert (srcy+srch <= srcpsd->yres); DRAWON; row_pos = 0x10000; row_inc = (srch << 16) / dsth; /* stretch blit using integer ratio between src/dst height/width*/ for (ymax = dsty+dsth; dsty<ymax; ++dsty) { /* find source y position*/ while (row_pos >= 0x10000L) { ++srcy; row_pos -= 0x10000L; } dst = dstpsd->addr + dstx + dsty*dlinelen; src = srcpsd->addr + srcx + (srcy-1)*slinelen; /* copy a row of pixels*/ col_pos = 0x10000; col_inc = (srcw << 16) / dstw; for (i=0; i<dstw; ++i) { /* get source x pixel*/ while (col_pos >= 0x10000L) { pixel = *src++; col_pos -= 0x10000L; } *dst++ = pixel; col_pos += col_inc; } row_pos += row_inc; } DRAWOFF;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -