#include "cc_config.h" #include "cc_type.h" #include "cc_def.h" #include "cc_private.h" #if 0 __GRAPHIC_BASE__() {} #endif static UINT16 p_resolution_table[eDCC_R_NUM][2]= { {720, 480}, {1280, 720}, {1920, 1080}, {960, 540} }; static UINT16 p_font_size_table[eDCC_R_NUM][3]= { CC_F_480, CC_F_720, CC_F_1080, CC_F_540 }; static UINT16 p_font_size_table_kor[eDCC_R_NUM][3]= { CC_F_480_KOR, CC_F_720_KOR, CC_F_1080_KOR, CC_F_540_KOR }; static struct { UINT8 service; BOOL is_cc_wide; BOOL is_src_wide; BOOL is_korean; UINT8 resolution; tDCC_PenAttr font_attr; tDCC_ColorMap color_map; int scroll_slice; int scroll_delay; } p_display_info; #define INFO(i) p_display_info.i static void p_get_safe_area(tDCC_RECT *rect) { UINT8 r=INFO(resolution); if(INFO(service)>=eDCC_S_CC1 && INFO(service)<=eDCC_S_T4) { rect->x=SAFE_AREA_LX_608*p_resolution_table[r][0]/100; rect->y=SAFE_AREA_TY_608*p_resolution_table[r][1]/100; rect->w=p_resolution_table[r][0]-(SAFE_AREA_RX_608*p_resolution_table[r][0]/100)-rect->x; rect->h=p_resolution_table[r][1]-(SAFE_AREA_BY_608*p_resolution_table[r][1]/100)-rect->y; } else if(INFO(is_korean)==0) { rect->x=SAFE_AREA_LX*p_resolution_table[r][0]/100; rect->y=SAFE_AREA_TY*p_resolution_table[r][1]/100; rect->w=p_resolution_table[r][0]-(SAFE_AREA_RX*p_resolution_table[r][0]/100)-rect->x; rect->h=p_resolution_table[r][1]-(SAFE_AREA_BY*p_resolution_table[r][1]/100)-rect->y; } else { rect->x=SAFE_AREA_LX_KOR*p_resolution_table[r][0]/100; rect->y=SAFE_AREA_TY_KOR*p_resolution_table[r][1]/100; rect->w=p_resolution_table[r][0]-(SAFE_AREA_RX_KOR*p_resolution_table[r][0]/100)-rect->x; rect->h=p_resolution_table[r][1]-(SAFE_AREA_BY_KOR*p_resolution_table[r][1]/100)-rect->y; } if(!INFO(is_cc_wide) && INFO(is_src_wide)) { //width¸¦ Á¶ÀýÇØ¾ß ÇÔ. #if 0 if(INFO(service)>=eDCC_S_CS1 && INFO(service)<=eDCC_S_CS6) { rect->x+=(rect->w*SAFE_AREA_WIDE_NORMAL_GAP)/100; rect->w-=(rect->w*SAFE_AREA_WIDE_NORMAL_GAP*2)/100; } #else //608µµ µ¿ÀÏÇÏ°Ô Àû¿ëµÇ¾î¾ß ÇÒ °Í °°À½. rect->x+=(rect->w*SAFE_AREA_WIDE_NORMAL_GAP)/100; rect->w-=(rect->w*SAFE_AREA_WIDE_NORMAL_GAP*2)/100; #endif } } static int p_get_font_size(UINT8 size) { CCPRINT("fsize", "p_get_font_size(size(%d), resolution(%d)\n", size, INFO(resolution)); CCPRINT("fsize", "return %d\n", p_font_size_table[INFO(resolution)][size]); if(INFO(is_korean)) return p_font_size_table_kor[INFO(resolution)][size]; return p_font_size_table[INFO(resolution)][size]; } static UINT8 p_get_color(UINT8 c, UINT8 o) { UINT8 ret=0; UINT8 *color_map=(UINT8 *)&INFO(color_map); if(o==eDCC_O_SOLID) ret = c; else if(o==eDCC_O_FLASH) #if ENABLE_FLASH ret = eDCC_C_NONE; #else ret = c; #endif else if(o==eDCC_O_TRANSLUCENT) ret = c | 0x8; else if(o==eDCC_O_TRANSPARENT) ret = eDCC_C_TRANSPARENT; return color_map[ret]; } static void p_set_font_attr(tDCC_PenAttr *pattr) { tDCC_PenAttr *pfa=pattr; if(!pfa) pfa=&INFO(font_attr); else memcpy(&INFO(font_attr), pfa, sizeof(INFO(font_attr))); if(INFO(service)>=eDCC_S_CC1 && INFO(service)<=eDCC_S_T4) DCCDDI_SetFontAttr(p_get_font_size(pfa->s), pfa->i, /*pfa->u*/0, 3, pfa->et, pfa->p16); else DCCDDI_SetFontAttr(p_get_font_size(pfa->s), pfa->i, /*pfa->u*/0, pfa->fs, pfa->et, pfa->p16); } void DCCGrp_Init(BOOL is_cc_wide, BOOL is_src_wide, BOOL is_korean, int resolution, tDCC_ColorMap *color_map) { if(resolution>=eDCC_R_NUM) resolution=eDCC_R_480; INFO(is_cc_wide)=is_cc_wide; INFO(is_src_wide)=is_src_wide; INFO(is_korean)=is_korean; INFO(resolution)=resolution; INFO(scroll_slice)=CC_SCROLL_SLICE1; INFO(scroll_delay)=CC_SCROLL_DELAY1; if(color_map) { memcpy(&INFO(color_map), color_map, sizeof(INFO(color_map))); } } void DCCGrp_SetService(UINT8 service) { CCPRINT("grp_set", "Set Service : %d\n", service); INFO(service)=service; } void DCCGrp_SetKorean(BOOL is_korean) { CCPRINT("grp_set", "Set korean : %d\n", is_korean); INFO(is_korean)=is_korean; } void DCCGrp_Start() { CCPRINT("grp_set", "grp start : %d\n"); DCCDDI_GraphicStart(INFO(resolution)); } void DCCGrp_Stop() { CCPRINT("grp_set", "grp stop : %d\n"); DCCDDI_GraphicStop(); } void DCCGrp_DrawBox(int x, int y, int w, int h, int color) { tDCC_RECT r_safe; CCPRINT("grp_xy", "draw_box(%d,%d,%d,%d,%d)\n", x, y, w, h, color); p_get_safe_area(&r_safe); if(w>r_safe.w) w=r_safe.w; if(h>r_safe.h) h=r_safe.h; if(p_get_color(color, eDCC_O_SOLID)!=INFO(color_map).no) DCCDDI_DrawBox(r_safe.x+x, r_safe.y+y, w, h, p_get_color(color, eDCC_O_SOLID)); } void DCCGrp_EraseBox(int x, int y, int w, int h) { DCCGrp_DrawBox(x, y, w, h, eDCC_C_TRANSPARENT); } void DCCGrp_ClearScreen() { DCCGrp_EraseBox(0, 0, p_resolution_table[INFO(resolution)][0], p_resolution_table[INFO(resolution)][1]); } void DCCGrp_ScrollUp(int x, int y, int w, int h, int height, int bg_color) { tDCC_RECT r_safe; int i; CCPRINT("grp_scroll", "scroll_up(%d,%d,%d,%d,%d(height),%d(bg_color))\n", x, y, w, h, height, bg_color); p_get_safe_area(&r_safe); if(x+w>r_safe.w) w=r_safe.w-x; if(y+h>r_safe.h) h=r_safe.h-y; for(i=0; i<=height-INFO(scroll_slice); i+=INFO(scroll_slice)) { DCCDDI_BLT(r_safe.x+x, r_safe.y+y-height+INFO(scroll_slice), w, h+height-INFO(scroll_slice)-i, -1*INFO(scroll_slice)); DCCDDI_DrawBox(r_safe.x+x, r_safe.y+y-i+h-INFO(scroll_slice), w, INFO(scroll_slice), p_get_color(bg_color, eDCC_O_SOLID)); DCCDDI_Delay(INFO(scroll_delay)); } if(ir_safe.w) w=r_safe.w-x; if(y+h>r_safe.h) h=r_safe.h-y; for(i=0; i<=height-INFO(scroll_slice); i+=INFO(scroll_slice)) { DCCDDI_BLT(r_safe.x+x, r_safe.y+y+i, w, h+height-INFO(scroll_slice)-i, INFO(scroll_slice)); DCCDDI_DrawBox(r_safe.x+x, r_safe.y+y+i, w, INFO(scroll_slice), p_get_color(bg_color, eDCC_O_SOLID)); DCCDDI_Delay(INFO(scroll_delay)); } if(i±ÛÀÚ ¾Õ µÚ 3pixelÀ» ´õ ±×¸², 1->¾Õ 3, 2->µÚ 3, 3->Ãß°¡·Î ¾È±×¸². int DCCGrp_PrintCh(int x, int y, UINT16 ch, int draw_mode) { tDCC_RECT r_safe; int c_font, c_back, c_edge, size; int ch_width, ch_height; p_get_safe_area(&r_safe); ch_width=DCCGrp_GetChWidth(ch); ch_height=DCCGrp_GetMaxFontHeight(INFO(font_attr).s); if(x<0 || y<0 || x+ch_width>r_safe.w || y+ch_height>r_safe.h) { void get_cc_info(void); void get_def_win(void); CCPRINT("error", "!! print pos is bad(%d,%d), safe(%d,%d,%d,%d)\n", x, y, r_safe.x, r_safe.y, r_safe.w, r_safe.h); get_cc_info(); get_def_win(); //OS_Delay(OS_GetTicksPerSecond()*60*60*24); return 0; } c_font=p_get_color(INFO(font_attr).fc, INFO(font_attr).fo); c_back=p_get_color(INFO(font_attr).bc, INFO(font_attr).bo); c_edge=p_get_color(INFO(font_attr).ec, INFO(font_attr).fo); CCPRINT("grp_ch", "print_ch(char(0x%x) xy(%d,%d), w(%d), color(f:%d,b:%d,e:%d), fs(%d)\n", ch, x, y, ch_width, c_font, c_back, c_edge, INFO(font_attr).fs); if(c_back!=INFO(color_map).no && ch!=DCC_TRP_CODE) { //0x120À̸é trp·Î ó¸®ÇÔ. switch(draw_mode) { case ePRIV_CH_DRAW_TYPE_ALL: DCCDDI_DrawBox(r_safe.x+x-CC_CH_DRAW_ADDING_WIDTH, r_safe.y+y, ch_width+2*CC_CH_DRAW_ADDING_WIDTH, ch_height, c_back); break; case ePRIV_CH_DRAW_TYPE_LEFT: DCCDDI_DrawBox(r_safe.x+x-CC_CH_DRAW_ADDING_WIDTH, r_safe.y+y, ch_width+CC_CH_DRAW_ADDING_WIDTH, ch_height, c_back); break; case ePRIV_CH_DRAW_TYPE_RIGHT: DCCDDI_DrawBox(r_safe.x+x, r_safe.y+y, ch_width+CC_CH_DRAW_ADDING_WIDTH, ch_height, c_back); break; case ePRIV_CH_DRAW_TYPE_NONE: DCCDDI_DrawBox(r_safe.x+x, r_safe.y+y, ch_width, ch_height, c_back); break; } } size=p_get_font_size(INFO(font_attr).s); #if 0 p_set_font_attr(NULL); #endif //y°ª º¸Á¤ÇÔ. y+=(ch_height-size)/2+FONT_ALING_ADJ; if(c_font!=INFO(color_map).no && ch!=DCC_TRP_CODE) { int newx=x+(ch_width-DCCDDI_GetChWidth(ch))/2; if(INFO(font_attr).i) { if(INFO(font_attr).fs==eDCC_FS_CASUAL || INFO(font_attr).fs==eDCC_FS_CURSIVE) newx-=ch_height/4; else if(INFO(font_attr).fs==eDCC_FS_SMALLCAPITAL) newx-=ch_height/10; } //casual italicÀÎ °æ¿ì(jungle¿¡¼­) ¸¹ÀÌ ¾ÕÂÊÀ¸·Î ´ç°ÜÁà¾ß ÇÔ. //italic ó¸® ¶§¹®¿¡ ¿ìÃøÀ¸·Î 1¸¸Å­ ´õ À̵¿ÇÔ->italicÀÏ °æ¿ì width¸¦ ´õ Ű¿ì´Â °É·Î º¯°æ. DCCDDI_PrintCh(r_safe.x+newx, r_safe.y+y, ch, c_font, c_edge); } if(INFO(font_attr).u && ch != 0x20 && c_font!=INFO(color_map).no && ch!=DCC_TRP_CODE) { DCCDDI_DrawHLine(r_safe.x+x, r_safe.y+y+ch_height*8/10, ch_width, c_font); } CCPRINT("grp_xy", "print_ch(char(0x%x) xy(%d,%d), w(%d), color(f:%d,b:%d,e:%d), fs(%d)\n", ch, x, y, ch_width, c_font, c_back, c_edge, INFO(font_attr).fs); return ch_width; } int DCCGrp_GetChWidth(UINT16 ch) { int ch_width; //analogÀÏ °æ¿ì if(INFO(service)>=eDCC_S_CC1 && INFO(service)<=eDCC_S_T4) { tDCC_RECT r_safe; p_get_safe_area(&r_safe); return r_safe.w/(DCC_608_WIN_WIDTH+1); } //0x520Àº transparentÀÓ. °ø¹é°ú °°ÀÌ °£ÁÖÇÔ. if(ch==DCC_TRP_CODE) ch=0x20; ch_width=DCCDDI_GetChWidth(ch); ch_width=ch_width*FONT_WIDTH_FACTOR/10; //italicÀº ch_width¸¦ Á» Ű¿ö¾ß ÇÔ. if(INFO(font_attr).i) { if(INFO(font_attr).fs==eDCC_FS_CASUAL/* || INFO(font_attr).fs==eDCC_FS_CURSIVE*/) ch_width=ch_width*12/10; else ch_width=ch_width*11/10; //ÀÏ¹Ý italicÀÎ °æ¿ì ¾à 1.1¹è¸¦ ´õÇØÁÜ. } return ch_width; } int DCCGrp_GetStrWidth(UINT16 *str) { int i, sum; for(i=0, sum=0; str[i]; i++) sum+=DCCGrp_GetChWidth(str[i]); return sum; } int DCCGrp_GetStrNWidth(UINT16 *str, int n) { int i, sum; for(i=0, sum=0; str[i] && i edge, font styleÀÌ Áß°£¿¡ º¯ÇÒ ¼ö ÀÖÀ½ #else //±æÀÌ¿¡ ¿µÇâÀ» ÁÙ ¼ö ÀÖ´Â º¯¼ö´Â font style, size, italic, edgeÀÓ //±×·±µ¥, font style Áö¿ø ¾ÈÇÔ. edge Áö¿ø ¾ÈÇÔÀ̱⠶§¹®¿¡, size¿Í italic¸¸ °í·ÁÇÔ. static struct { UINT8 size; UINT8 max_ch_with; UINT8 italic; } font_buf[6]; int num_font=6; // 2012.11.02 megakiss ¹ÌÁÖÇâ ÆùÆ® °¹¼ö´Â 6°³ÀÓ int ret_val; INFO(font_attr).s=size; p_set_font_attr(NULL); #if 0 for(i=0; iw±âÁØ 10% ´õ Å« °ªÀ» ¼±ÅÃÇÔ. #if USE_KOR_CC ret_val=DCCGrp_GetChWidth('W')*11/10; #else //italic,edge µîÀ» °í·ÁÇϸé Å©°Ô Àâ¾Æ³õ´Â°Ô ÁÁÀ½. ret_val=DCCGrp_GetChWidth('W')*13/10; #endif if(num_font<6) { font_buf[num_font].size=size; font_buf[num_font].max_ch_with=ret_val; font_buf[num_font].italic=INFO(font_attr).i; num_font++; } return bhalf?ret_val*3/5:ret_val; #endif } int DCCGrp_GetMaxFontHeight(UINT8 size) { //¼¼·Î 15ÁÙÀ» ±âÁØÀ¸·Î Çϱ⠶§¹®¿¡ //safe area¸¦ 15·Î ³ª´« °ªÀ» ¸®ÅÏÇϵµ·Ï ÇÔ //tDCC_RECT r_safe; int height; if(INFO(service)>=eDCC_S_CC1 && INFO(service)<=eDCC_S_T4) { tDCC_RECT r_safe; p_get_safe_area(&r_safe); return r_safe.h/(DCC_608_WIN_HEIGHT+1); } #if 0 p_get_safe_area(&r_safe); height=r_safe.h/MAX_NUM_ROW; #elif 1 height=p_get_font_size(size)*FONT_HEIGHT_FACTOR/10; //¾à 1.2¹èÀÇ Å©±â. #else INFO(font_attr).s=size; p_set_font_attr(NULL); height=DCCDDI_GetChHeight('j'); #endif return height; } int DCCGrp_GetScrPosX(int cc_pos_x) { //anchor horizontal·Î À§Ä¡¸¦ ¸®ÅÏÇÔ //anchor horizontalÀº 0-99ÀÇ °ªÀ» °¡Áü tDCC_RECT r_safe; p_get_safe_area(&r_safe); return r_safe.w*cc_pos_x/100; } int DCCGrp_GetScrPosY(int cc_pos_y) { //anchor horizontal·Î À§Ä¡¸¦ ¸®ÅÏÇÔ //anchor horizontalÀº 0-99ÀÇ °ªÀ» °¡Áü tDCC_RECT r_safe; p_get_safe_area(&r_safe); return r_safe.h*cc_pos_y/100; } void DCCGrp_AdjustRect(tDCC_RECT *rect) { tDCC_RECT r_safe; p_get_safe_area(&r_safe); if(rect->w<0) rect->w=0; if(rect->h<0) rect->h=0; if(rect->w>r_safe.w) rect->w=r_safe.w; if(rect->h>r_safe.h) rect->h=r_safe.h; //ÃÖ¼ÒÇÑ w, h´Â 0ÀÌ µÇ¾î¼­´Â ¾ÈµÊ. safe areaº¸´Ù´Â ÀÛ¾Æ¾ß ÇÔ. #if USE_WIN_RECT_ADJ==1 //Å©±â °íÁ¤. ÁÂÇ¥ À̵¿ if(rect->x<0) rect->x=0; if(rect->y<0) rect->y=0; if(rect->x+rect->w>r_safe.w) rect->x=r_safe.w-rect->w; if(rect->y+rect->h>r_safe.h) rect->y=r_safe.h-rect->h; #elif USE_WIN_RECT_ADJ==2 //Å©±â º¯°æ. ÁÂÇ¥ °íÁ¤ if(rect->x<0) {rect->w+=rect->x; rect->x=0;} if(rect->y<0) {rect->h+=rect->y; rect->y=0;} if(rect->x+rect->w>r_safe.w) rect->w=r_safe.w-rect->x; if(rect->y+rect->h>r_safe.h) rect->h=r_safe.h-rect->y; #elif USE_WIN_RECT_ADJ==3 //°¡·Î´Â Å©±â º¯°æ/ÁÂÇ¥ °íÁ¤, ¼¼·Î´Â Å©±â °íÁ¤/ÁÂÇ¥ À̵¿ if(rect->x<0) {rect->w+=rect->x; rect->x=0;} if(rect->x+rect->w>r_safe.w) rect->w=r_safe.w-rect->x; if(rect->y<0) rect->y=0; if(rect->y+rect->h>r_safe.h) rect->y=r_safe.h-rect->h; #endif } #if 0 __WINDOW_DRAW__() {} #endif void cc_grp_info() { tDCC_PenAttr *pattr=&INFO(font_attr); printf("cc_wide(%d), src_wide(%d), korean(%d), resolution(%d)\n", INFO(is_cc_wide), INFO(is_src_wide), INFO(is_korean), INFO(resolution)); printf("Pen Attr...\n"); printf("s(%d),fs(%d),tt(%d), o(%d), u(%d), i(%d), et(%d)\n", pattr->s, pattr->fs, pattr->tt, pattr->o, pattr->u, pattr->i, pattr->et); printf("fc(%d), fo(%d), bc(%d), bo(%d), ec(%d)\n", pattr->fc, pattr->fo, pattr->bc, pattr->bo, pattr->ec); } void cc_safe_area() { tDCC_RECT r_safe; p_get_safe_area(&r_safe); printf("------------------------------------------\n"); printf("safe area(%d,%d,%d,%d)\n", r_safe.x, r_safe.y, r_safe.w, r_safe.h); printf("------------------------------------------\n"); }