osd_16BDC.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:6k
- //for supporting 16bit OSD
- //created by jslin //20041022
- #include "memmap0.h" // 2004/11/05 yltseng
- #include "memcfg.h"
- void osd_16BDC_init_bitmap(UINT8 *hp, int w, int h);
- void osd_16BDC_set_region(t_osd_region *p);
- void osd_16BDC_create_region(t_osd_region *p, int X, int Y, t_osd_region *prev);//, int scanmd);
- void osd_16BDC_init(void);
- void osd_16BDC_draw_bitmap(UINT16 *ptr, int x, int y, int w, int h, UINT8 mask);
- void osd_16BDC_setbuf(void);
- void osd_16BDC_get_block(UINT8 *ptr, int x, int y, int w, int h);
- #define MONE_OSD_16BDC
- void osd_16BDC_setbuf()
- {
- //OSD Display Buffer pointer
- if(OSD_buffer_16bit==1) {
- REG_OSDYA = GP_REF1_LUMA + 64;
- REG_OSDYA2 = GP_REF1_LUMA + 64;//osdya_n;
- }
- }
- void osd_16BDC_init(void)
- {
- #ifdef MONE_OSD_16BDC
- osd_puts("nnosd init flashnn");
- #endif
-
- osd_16BDC_setbuf();
- #ifdef MONE_OSD_16BDC
- printf("nn>>>>>16bit OSD buffer ptr[%x] [%d]n", get_osdbuf_baseptr(), OSD_buffer_16bit);
- #endif
-
- osd_free = 0;
- region[0].osd_w = 360;
- if(p_scan) {
- region[0].osd_h = 480;
- } else {
- region[0].osd_h = 240;
- }
- region[0].osd_format = OSD_FORMAT_DIRECT16B; //A-RGB 1-555
- osd_16BDC_create_region(®ion[0], 0, 0, NULL);//, 0);
- osd_active_regions = 1;
- ENABLE_OSD();
- }
- void osd_16BDC_create_region(t_osd_region *p, int X, int Y, t_osd_region *prev)
- {
- int oW, oH;
- t_osdv2_header hdr;
- UINT16 lnkprev;
- UINT8 *hp;
- unsigned clut_type;
- int color_format;
- int hdr_size;
- unsigned clut_update;
-
- lnkprev = (prev!=NULL) ? prev->osd_header[0] : LINK_NULL;
- p->osd_header[0] = osd_free;
- p->osd_header[1] = osd_free;
- oW = p->osd_w/2;
- oH = p->osd_h;
- color_format = p->osd_format;
- clut_type = OSDV2_CLUT_32b;
- hdr_size = 16;
- clut_update =0;// 1;
- hp = (UINT8 *)get_osdbuf_baseptr() + (osd_free<<5);
- osd_free = osd_free + ((hdr_size+31)>>5);
- memset(&hdr,0,sizeof(hdr));
- hdr.config0 = ((clut_update & 0x01) << BIT_CU)
- | ((0x0) << BIT_FT)
- | ((0x1) << BIT_PR)
- | ((color_format & 0x07) << BIT_MD);
- hdr.config1 = ((0x00 & 0x0f) << BIT_SHD)
- | ((0x0f & 0x0f) << BIT_BLND);
- hdr.config2 = V2_CLUT_TYPE(clut_type)
- | V2_RGB_MODE
- | V2_SWAP_BYTE_OFF
- | V2_SHADE_MODE_A;
-
- hdr.v_size = SWAP16(oH);
- hdr.h_size = SWAP16(oW);
- hdr.x = SWAP16(X);
- hdr.y = SWAP16(Y);
- hdr.link_data = SWAP16(osd_free);
- hdr.link_next = SWAP16(lnkprev);
- memcpy(hp,&hdr,sizeof(hdr));
- // initialize bitmap
- hp = get_osdbuf_baseptr() + (osd_free<<5);
- osd_16BDC_init_bitmap(hp, oW, oH);
- }
- void osd_16BDC_init_bitmap(UINT8 *hp, int w, int h)
- {
- int i, j;
-
- unsigned a, R, G, B;
- unsigned v;
- R = 0x00;
- G = 0x00;
- B = 0x00;
- a = 0x0;
- #ifdef MONE_OSD_16BDC
- printf("w[%d] h[%d] [%x] [%x]n", w, h, REG_OSDYA, REG_OSDYA2);
- #endif
-
- v = ((a&0x1)<<15)|(((R>>3)&0x1f)<<10) | (((G>>3)&0x1f)<<5) | (((B>>3)&0x1f)<<0) ; // 1555
- if(p_scan)
- {
- for (i=0;i<h;i++)
- {
- for (j=0;j<w;j++)
- {
- *(UINT16 *)(&hp[0]) = SWAP16(v);
- *(UINT16 *)(&hp[2]) = SWAP16(v);
- hp+=(w*4);
- *(UINT16 *)(&hp[0]) = SWAP16(v);
- *(UINT16 *)(&hp[2]) = SWAP16(v);
- hp-=(w*4);
-
- hp+=4;
- }
- hp+=(w*4);
- i++;
- }
- }
- else
- {
- for (i=0;i<h;i++)
- {
- for (j=0;j<w;j++)
- {
- *(UINT16 *)(&hp[0]) = SWAP16(v);
- *(UINT16 *)(&hp[2]) = SWAP16(v);
- hp+=4;
- }
- }
- }
- }
- void osd_16BDC_draw_bitmap(UINT16 *ptr, int x, int y, int w, int h, UINT8 mask)
- {
- UINT8 *hp;
- UINT16 v, colorMask;
- int region_W;
- int i, j;//, Dcase;
- if(mask){
- colorMask = 0x0;
- } else {
- colorMask = 0xffff;
- }
-
- hp = get_osdbuf_baseptr() + (osd_free<<5);
- region_W = (region[0].osd_w/2)*4;
- if(p_scan)
- {
- hp = hp +(2*y*region_W) + (x*2);
- for (i=0; i<h; i++)
- {
- for(j=0; j<w; j++)
- {
- v=(UINT16)ptr[j+(i*w)];
- *(UINT16 *)(&hp[0]) = (v&colorMask);
- hp+=region_W;
- v=(UINT16)ptr[j+(i*w)];
- *(UINT16 *)(&hp[0]) = (v&colorMask);
- hp-=region_W;
- hp+=2;
- }
- hp+=region_W;
- hp+=(region_W-(w*2));
- }
- }
- else
- {
- hp = hp +(y*region_W) + (x*2);
- for (i=0; i<h; i++)
- {
- for(j=0; j<w; j++)
- {
- v=(UINT16)ptr[j+(i*w)];
- *(UINT16 *)(&hp[0]) = (v&colorMask);
- hp+=2;
- }
- hp+=(region_W-(w*2));
- }
- }
- }
- void osd_16BDC_get_block(UINT8 * ptr, int x, int y, int w, int h)
- {
- UINT8 *hp;
- int region_W;
- int i, j, Bpos;
- hp = get_osdbuf_baseptr() + (osd_free<<5);
- region_W = (region[0].osd_w/2)*4;
- if(p_scan)
- {
- hp = hp +(2*y*region_W) + (x*2);
- for(i=0; i<h; i++)
- {
- for(j=0; j<w; j++)
- {
- Bpos = (i*w*2)+(j*2);
- ptr[Bpos] = hp[0];
- ptr[Bpos+1] = hp[1];
- hp+=2;
- }
- hp+=(region_W-(w*2));
- hp+=region_W;
- }
- }
- else
- {
- hp = hp + (y*region_W) + (x*2);
- for(i=0; i<h; i++)
- {
- for(j=0; j<w; j++)
- {
- Bpos = (i*w*2)+(j*2);
- ptr[Bpos] = hp[0];
- ptr[Bpos+1] = hp[1];
- hp+=2;
- }
- hp+=(region_W-(w*2));
- }
- }
- }