⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osd.c

📁 ESS3890+SL原代码(1*16内存)
💻 C
📖 第 1 页 / 共 2 页
字号:
	    if (d>=0) {		y += sy;		d -= dx;	    }	    x += sx;	    d += dy;	}    } else {	d = dx - (dy>>1);	while (1) {	    OSD_dot(x, y, color);	    if (y==y1) return;	    if (d>=0) {		x += sx;		d -= dy;	    }	    y += sy;	    d += dx;	}    }}/************************************************************************  Copy a bitmap from *addr to OSD memory. The position and the size of   the bitmap must be specified by parameters.*************************************************************************/int osd_bitblt( int x, int y, int dx, int dy, uchar *addr, int mode){    int xstart, xend;    int good_xstart, good_xend;    int xstart_offset, xend_offset;    int dx_in_bytes;    int mem, src;    int dest0, dest1;    int *dptr0, *dptr1;    int i, j, k, dwords, tmp;    int bug = 0;   /* for the hardware bug */    int temp;    if( x           < osd_canvas.xstart ||       (dx + x )    > osd_canvas.xend   ||        y           < osd_canvas.ystart ||       (dy + y - 1) > osd_canvas.yend ) {	/* out of canvas */	EPRINTF((" Your bitmap is out of canvas!\n"));	EPRINTF(("The bitmap you want to setup is "));	EPRINTF(("x=%d y=%d dx=%d dy=%d\n", x, y, dx, dy));	return -1;    }    CPRINTF(("->x=%d y=%d dx=%d dy=%d\n", x, y, dx, dy));#ifndef C256    /* Special Restrictions */    if ((dx % pixels_per_byte) || ((x - osd_canvas.xstart) % pixels_per_byte) ) {	/* we can't handle the bitmap is not start/end at a BYTE boundray */	CPRINTF(("Your bitmap should start/end at a BYTE bounary !\n"));	return -1;    }#endif    dx_in_bytes = dx / pixels_per_byte;    xstart = x;    xend   = xstart + dx - 1; 		    CPRINTF(("1: xstart = %d xend = %d \n", xstart, xend));      /* Since the region does not start/end at DWORD boundary, we have to enlarge it       before using */      xstart_offset = (xstart - osd_canvas.xstart) % pixels_per_dword;    xend_offset = (xend - osd_canvas.xstart + 1) % pixels_per_dword;    if ( xend_offset )   xend_offset = pixels_per_dword - xend_offset;       good_xstart = xstart - xstart_offset;        good_xend = xend + xend_offset;    CPRINTF(("2:  good_xstart = %d good_xend = %d \n", good_xstart, good_xend));    if(good_xstart == osd_canvas.xstart) osd_bug = 1;    else osd_bug = 0;    xstart_offset = xstart_offset / pixels_per_byte;    xend_offset = xend_offset / pixels_per_byte;    CPRINTF(("xstart_offset = %d \n", xstart_offset));    CPRINTF(("xend_offset = %d \n", xend_offset));    /* Copy bitmap */    #ifdef PROG_OSD    dest0 = OSD_START0 +	(good_xstart - osd_canvas.xstart) * osd_bits_per_pixel / 32 +	((y - osd_canvas.ystart) * osd_canvas.xsize);#else    dest0 = OSD_START0 +	(good_xstart - osd_canvas.xstart) * osd_bits_per_pixel / 32 +	((y - osd_canvas.ystart) / 2 * osd_canvas.xsize);    dest1 = OSD_START1 + (dest0 - OSD_START0);    CPRINTF(("dest0 = %d  dest1 = %d \n", dest0, dest1));#endif    dwords = (good_xend - good_xstart + 1) * osd_bits_per_pixel / 32 ;    CPRINTF(("dwords = %d \n", dwords));#ifdef R4438    VP_xfer_wait();#endif    LOW_set_buscon_dma_width3(osd_canvas.xsize);    osd_copy_data(dwords, dx_in_bytes, dy, xstart_offset, xend_offset, 		  addr, dest0, mode);#ifndef PROG_OSD    osd_copy_data(dwords, dx_in_bytes, dy, xstart_offset, xend_offset, 		  addr + dx_in_bytes, dest1, mode);#endif        CPRINTF(("Memory has been filled \n"));    return 0;}/************************************************************************  Copy data to OSD memory*************************************************************************/int osd_copy_data(int dwords,		  int dx_in_bytes,		  int dy,		  int xstart_offset, 		  int xend_offset, 		  uchar *addr,		  int dest,		  int mode){    uint mem, src;    uint i, j, k, tmp;    int *dptr;    uchar data;    dptr = (int *) dram(dest);#ifndef PROG_OSD    dy /= 2;#endif    /* setup buscon transfer */    buscon_wait(r2b);    buscon_xfer(r2b, BDMA_WIDTH3, dest, dwords, dy);    for( i = 0;  i < dy; i++) {	for( j = 0; j < dwords; j++) {	    mem = 0;	    src = *dptr;	    if ( j == 0 && xstart_offset) {		int shift = 4 - xstart_offset;		/* the first dword of this line */		for (k = 0; k < shift; k++) {		    if(!mode)			mem = (mem << 8 ) | *(addr++);		    else			mem = (mem << 8) | osd_byte_cell;		}		CPRINTF(("First DWORD src = 0x%8X, mem = 0x%8X ", src, mem));		src  = src & (0xffffffff << ( 8 * shift));		CPRINTF(("=> 0x%8X\n", (src | mem)));	    }	    else if (j == dwords -1 && xend_offset) {		int shift = 4 - xend_offset;		/* the last dword of this line */		for (k = 0; k < shift; k++) {		    if(!mode)			mem = (mem << 8 ) | *(addr++);		    else			mem = (mem << 8) | osd_byte_cell;		}		mem = mem << ( 8 * xend_offset );		src  = src & (0xffffffff >> ( 8 * shift));		CPRINTF(("Last DWORD src = 0x%8X, mem = 0x%8X \n", src, mem));	    }	    else {		if (!mode) {		    for (k = 0; k < 4; k++) {			mem = (mem << 8) | *(addr++);					    }		}		else 		    mem = osd_dw_cell;		src = 0;	    }	    tmp = src | mem;	    if (osd_bug && !j) tmp &= osd_bug_patch;	    CPRINTF(("%08X ", tmp));	    put_riscfifo(tmp);       	    dptr++;	}	CPRINTF(("\n"));#ifdef TWO_FIELDS_OSD#ifndef PROG_OSD	if(!mode) addr += dx_in_bytes;#endif#endif	tmp = osd_canvas.xsize - dwords;	dptr += tmp;    }    mvd[gate_control] = flush_r2b;    buscon_wait(r2b);    mvd[gate_control] = gbl_gate_control;  }/************************************************************************  Function:  Description:*************************************************************************/#if 0int OSD_line_to(int x, int y, int dx, int dy, int color){    int i;    if (color > 0xf) 	return -1;    else {	for (i = 0; i < 16; i++)	    osd_dw_cell = (osd_dw_cell << 4) | color;	for (i = 0; i < 2; i++)	    osd_byte_cell = (osd_byte_cell << 4) | color;    }    osd_bitblt(x, y, dx, dy, (uchar *) &osd_dw_cell, 1);    return 1;}#endif/************************************************************************  Function:  Description:*************************************************************************/int OSD_bitblt( int x, int y, int dx, int dy, uchar *addr){    osd_bitblt(x, y, dx, dy, addr, 0);}/************************************************************************  Function:  Description:*************************************************************************/#if 0int get_osd_pixel_mode(){    return( osd_pixel_mode );}#endif/************************************************************************  Function:  Description:*************************************************************************/#if 0void OSD_rect(int start_x, int start_y, int end_x, int end_y, int color){    OSD_line(start_x, start_y, end_x, start_y, color);    OSD_line(end_x, start_y, end_x, end_y, color);    OSD_line(start_x, start_y, start_x, end_y, color);    OSD_line(start_x, end_y, end_x, end_y, color);    OSD_line_to(start_x, start_y, end_x-start_x, end_y-start_y, color);}#endif/************************************************************************   Function:  Description:*************************************************************************/void OSD_frame(int start_x, int start_y, int end_x, int end_y, int mode){    int lt0, lt1, lt2, rb0, rb1, rb2;    if (mode==0) {        lt0=13; lt1=15; lt2=13; rb0=2; rb1=7; rb2=2;    } else if (mode == 1) {        lt0=2; lt1=7; lt2=2; rb0=13; rb1=15; rb2=13;    } else if (mode == -1) {        lt0 = lt1 = lt2 = rb0 = rb1 = rb2 = 10;    } else        return ;    OSD_line(start_x, start_y, end_x, start_y, lt0);    OSD_line(start_x, start_y, start_x, end_y, lt0);    OSD_line(end_x, start_y, end_x, end_y, rb0);    OSD_line(start_x, end_y, end_x, end_y, rb0);    OSD_line(start_x+1, start_y+1, end_x-1, start_y+1, lt1);    OSD_line(start_x+1, start_y+1, start_x+1, end_y-1, lt1);    OSD_line(end_x-1, start_y+1, end_x-1, end_y-1, rb1);    OSD_line(start_x+1, end_y-1, end_x-1, end_y-1, rb1);    OSD_line(start_x+2, start_y+2, start_x+2, end_y-2, lt2);    OSD_line(start_x+2, start_y+2, end_x-2, start_y+2, lt2);    OSD_line(end_x-2, start_y+2, end_x-2, end_y-2, rb2);    OSD_line(start_x+2, end_y-2, end_x-2, end_y-2, rb2);}/************************************************************************   Function:    Description:*************************************************************************/void OSD_border(int start_x, int start_y, int end_x, int end_y, int mode){    int left_top, right_bottom;    if (mode==0) {	left_top = 15; right_bottom = 7;    } else {	left_top = 7; right_bottom = 15;    }    OSD_line(start_x, start_y, end_x, start_y, left_top);    OSD_line(start_x, start_y, start_x, end_y, left_top);    OSD_line(end_x, start_y, end_x, end_y, right_bottom);    OSD_line(start_x, end_y, end_x, end_y, right_bottom);     OSD_line(start_x+1, start_y+1, end_x-1, start_y+1, left_top);    OSD_line(start_x+1, start_y+1, start_x+1, end_y-1, left_top);    OSD_line(end_x-1, start_y+1, end_x-1, end_y-1, right_bottom);    OSD_line(start_x+1, end_y-1, end_x-1, end_y-1, right_bottom);     OSD_line(start_x+2, start_y+2, end_x-2, start_y+2, 2);    OSD_line(start_x+2, start_y+2, start_x+2, end_y-2, 2);    OSD_line(end_x-2, start_y+2, end_x-2, end_y-2, 2);    OSD_line(start_x+2, end_y-2, end_x-2, end_y-2, 2);}/************************************************************************  Function:  Description:*************************************************************************/void OSD_border_head(int start_x, int start_y, int end_x, int end_y,int mode, int backcolor, int direction){    int left_top, right_bottom, x, y, x1, y1;    if (mode==0) {  	left_top = 15; right_bottom = 7;    } else {	left_top = 7; right_bottom = 15;    }    if (!direction) {	OSD_line(start_x, start_y, end_x, start_y, left_top);	OSD_line(start_x, start_y, start_x, end_y-1, left_top);	OSD_line(end_x, start_y, end_x, end_y-1, right_bottom);	OSD_line(start_x+3, end_y, end_x-3, end_y, backcolor);    } else {	OSD_line(start_x, start_y, end_x-1, start_y, left_top);	OSD_line(start_x, start_y, start_x, end_y, left_top);	OSD_line(end_x, start_y+3, end_x, end_y-3, backcolor);	OSD_line(start_x, end_y, end_x, end_y, right_bottom);    }    if (!direction) {	OSD_line(start_x+1, start_y+1, end_x-1, start_y+1, left_top);	OSD_line(start_x+1, start_y+1, start_x+1, end_y-1, left_top);	OSD_line(end_x-1, start_y+1, end_x-1, end_y-1, right_bottom);	OSD_line(start_x+3, end_y-1, end_x-3, end_y-1, backcolor);    } else {	OSD_line(start_x+1, start_y+1, end_x, start_y+1, left_top);	OSD_line(start_x+1, start_y+1, start_x+1, end_y, left_top);	OSD_line(end_x-1, start_y+3, end_x-1, end_y-3, backcolor);	OSD_line(start_x+1, end_y-1, end_x-1, end_y-1, right_bottom);    }    if (!direction) {	OSD_line(start_x+2, start_y+2, end_x-2, start_y+2, 2);	OSD_line(start_x+2, start_y+2, start_x+2, end_y-1, 2);	OSD_line(end_x-2, start_y+2, end_x-2, end_y-1, 2);	OSD_line(start_x+3, end_y-2, end_x-3, end_y-2, backcolor);    } else {	OSD_line(start_x+2, start_y+2, end_x-1, start_y+2, 2);	OSD_line(start_x+2, start_y+2, start_x+2, end_y-2, 2);	OSD_line(end_x-2, start_y+3, end_x-2, end_y-3, backcolor);	OSD_line(start_x+2, end_y-2, end_x-2, end_y-2, 2);    }}/************************************************************************  Function:  Description:*************************************************************************/void OSD_window(int start_x, int start_y, int end_x, int end_y,int mode, int depth, int color){    OSD_border(start_x, start_y, end_x, end_y, mode);    OSD_border(start_x+depth+2, start_y+depth+2, end_x-depth-2, end_y-depth-2, !mode);    OSD_line(end_x, start_y, end_x-depth, start_y+depth, 7);    OSD_line(end_x, start_y+1, end_x-depth, start_y+depth+1, 7);    OSD_line(start_x, end_y, start_x+depth, end_y-depth, 7);    OSD_line(start_x+1, end_y, start_x+depth+1, end_y-depth, 7);}/************************************************************************  Function:  Description:*************************************************************************/void OSD_window_head(int start_x, int start_y, int end_x, int end_y,int mode, int depth, int color){    OSD_border_head(start_x, start_y, end_x, end_y-3, mode, 10, 0);    OSD_border_head(start_x+depth+2, start_y+depth+2, end_x-depth-2,        end_y, !mode, 10, 0);    OSD_line(end_x, start_y, end_x-depth, start_y+depth, 7);    OSD_line(end_x, start_y+1, end_x-depth, start_y+depth+1, 7);}/************************************************************************  Function:  Description:*************************************************************************/ int OSD_area_check(int x1, int y1, int x2, int y2){    if ((x1<osd_canvas.xstart)||(x2>osd_canvas.xend)                ||(y1<osd_canvas.ystart)||(y2>osd_canvas.yend))        return 0;    return 1;} /************************************************************************  Function:  Description:*************************************************************************//* we have the limitation for both dx and dy.*//* dx must be less than 0x200, and dy must be less than 0x100 *//* looks like the limitation of dx has been fixed 2001/12/3 05:13PM *//* dy still has limitation, but what the value is?! *//* dy is restricted by 127, and it must be even.  2001/12/3 06:43PM */#define MAX_HEIGHT  126int OSD_area_fill(int x1, int y1, int x2, int y2, int color){    int i,j;    int new_y1;    int dx,dy;    osd_dw_cell = color;    if (osd_pixel_mode == 3)        osd_dw_cell |= (color<<24)+(color<<16)+(color<<8);    else {        for (i=0; i<3; i++)            osd_dw_cell |= (osd_dw_cell<<(4<<i));    }    osd_byte_cell = osd_dw_cell;    j = (y2 -y1) / MAX_HEIGHT + 2;    dx = x2 -x1;    new_y1 = y1;    for (i = 0; i < j;i++) {        dy = y2 - new_y1;        if (dy <= 0)            break;        dy = dy < MAX_HEIGHT ? dy : MAX_HEIGHT;        osd_bitblt(x1, new_y1, dx, dy, (uchar*)&color, 1);        if (dy < MAX_HEIGHT)            break;        else            new_y1 += dy;    }    return 0;}/************************************************************************  Function:  Description:*************************************************************************/#ifdef SCR_SAVERint CUST_style_scrsaver(int *x0, int *x1, int *y0, int *y1);int OSD_saver_setup(int dx){    osaver.xsize =  osd_canvas.xsize = dx / pixels_per_dword;    osaver.xend = dx;    osd_setup_saver = osd_pixel_mode;    return 0;}int OSD_saver_exit(void){    CG_init(0);    osd_setup_saver = 0;}static int osd_saver_setup(int field){    int addr, odd, ystart, ysize, xend;    if (field<0||!osd_setup_saver) return 0;    if (osd_setup_saver==4) return 1;    xend = osaver.xstart+osaver.xend;    CUST_style_scrsaver(&osaver.xstart, &xend, &osaver.ystart, &osaver.yend);    odd = osaver.xstart&1; /* to fix hardware bug about uv switching */    /* Set region */    mvd[vid_scn_osd_hstart]    = osaver.xstart-odd;    mvd[vid_scn_osd_hend]      = osaver.xstart-odd + osaver.xend;    ystart = osaver.ystart>>1;    mvd[vid_scn_osd_vstart]    = ystart;    ysize = osaver.ysize;    mvd[vid_scn_osd_vend]      = ystart+ysize-2;    /* OSD DMA */    mvd[vid_scn_osd_startstop] = org_osd_startstop;#ifdef PROG_OSD    mvd[buscon_dma_width0] = osaver.xsize;    addr = OSD_START0;    if (field) addr += osaver.xsize;    buscon_xfer(ysn, BDMA_WIDTH0|BDMA_INC2, addr, osaver.xsize, 0);#else    addr = (field) ? osaver.addr1 : osaver.addr0;    buscon_xfer(ysn, BDMA_USEDX, addr, osaver.ysize, osaver.xsize);#endif    mvd[vid_scn_osd_misc]      = osd_setup_saver;    return 1;}#endifvoid OSD_contrast_change(int contrast){#ifdef SCR_SAVER    int i, pal = 16;#ifdef PROG_OSD    pal = 256;#endif    contrast &= 0xf;    mvd[vid_scn_osd_misc] = 0x4;    for (i=1; i<pal; i++)        mvd[vid_scn_osd_palette+i] = (osd_palette[i]&0xfff0)|contrast;    mvd[vid_scn_osd_misc] = osd_pixel_mode;#endif}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -