📄 cg.c
字号:
CG_map_color(2, color2); CG_map_color(3, color3);}/************************************************************************ Change*************************************************************************/void ICON_color_array_mapping(int color1, int color2, int color3){ ICON_color_mapping(1, color1); ICON_color_mapping(2, color2); ICON_color_mapping(3, color3);}/************************************************************************ Change*************************************************************************/void CG_map_color_array(int color1, int color2, int color3){ if (current_charset<VWENGLISH_FONTS) CG_color_array_mapping(color1, color2, color3); else ICON_color_array_mapping(color1, color2, color3);}/************************************************************************ Change the default 2 bit to 4 bit mapping. Delayed action..delay by "how_much" characters. ( 0 <= how_much <= 15 )*************************************************************************/void CG_map_color_delayed(int how_much, int color2, int color4){ if (color2 == 1) cg_map_color_array.delayed_color1 = color4; else if (color2 == 2) cg_map_color_array.delayed_color2 = color4; else /* color2 == 3 */ cg_map_color_array.delayed_color3 = color4; cg_map_color_array.how_much = how_much;}/************************************************************************ Check for delayed color map change.*************************************************************************/void check_map_color_delayed(){ int i; char colors[4]; colors[1] = cg_map_color_array.delayed_color1; colors[2] = cg_map_color_array.delayed_color2; colors[3] = cg_map_color_array.delayed_color3; for (i=1; i<4; i++) { CG_map_color(i, colors[i]); }}void CG_set_palette(void){ int i; for (i=0; i<16; i++) OSD_set_palette(i, osd_pal3d[i], ((i==15)?1:0));}/************************************************************************ Set CG window*************************************************************************/int CG_set_window(int first, int last) { int i, j; int x, y, dx, dy; char *p; /* wrong setting ? */ if ( first < 0 || last < 0 || first > last ) { assert(0); EPRINTF(("Please check your CG window setting!\n")); return -1; } /*If we support multi cg windows, we should plus cg_windows.*/ cg_windows = 1; icon_on_screen = 0; /* keep active windows */ cg_act.ystart = first; cg_act.yend = last; CG_set_palette(); OSD_init(CG_SCREEN_XSTART, CG_SCREEN_YSTART, CG_FONT_WIDTH * CG_LINE_WIDTH, CG_LINES * CG_LINE_HEIGHT+8, CG_BITS_PER_PIXEL, OP_OSD_START, (OP_OSD_START + OP_OSD_LENGTH /2), 0,2); return 0;}/************************************************************************ Function: Set display area for osd.*************************************************************************/int cg_set_area(int y, int screen_y, int dy){ OSD_set_window(CG_SCREEN_XSTART, screen_y * CG_LINE_HEIGHT + CG_SCREEN_YSTART, CG_FONT_WIDTH * CG_LINE_WIDTH, dy * CG_LINE_HEIGHT); return 0;}/************************************************************************ Function: Returns the current screen mode mode 0 CG_FULL_SCR 1 CG_SETUP_MENU 2 CG_PLAY_MODE*************************************************************************/int CG_get_scr_mode(void){ return( cg_curr_scr_mode );}/************************************************************************ Function: Set screen mode. mode 0 CG_FULL_SCR 1 CG_SETUP_MENU 2 CG_PLAY_MODE*************************************************************************/int CG_set_scr(int mode){ cg_curr_scr_mode = mode; switch(mode) { case CG_FULL_SCR: case CG_SETUP_MENU: CG_set_window(0, CG_LINES -1); OSD_set_window(CG_SCREEN_XSTART, CG_SCREEN_YSTART, CG_FONT_WIDTH * CG_LINE_WIDTH, CG_LINES * CG_LINE_HEIGHT + 8); break;#if NOT_USED case CG_PLAY_MODE: CG_set_window(0, 4); /* 5 Lines */ cg_set_area(0, 0, 3); cg_set_area(3, 6, 2); break;#endif#ifdef EQUALIZER case CG_EQPLAY_MODE: CG_set_window(0, 5); /* 6 Lines */ cg_set_area(0, 0, 6); /* 1st line reserved for time/track/mode OSD */ /* 2nd to 6th lines for equalizer/spectrum */ break;#endif#ifdef KARASC case CG_KSC_MODE: CG_set_window(0, 9); /* 9 Lines */ cg_set_area(0, 0, 9); /* 1st line reserved for time/track/mode OSD */ /* 2nd to 4th lines for vocal spectrum */ /* 5th line for "MUSIC" */ /* 6th to 8th lines for mic spectrum */ /* 9th line for "MIC" */ break;#endif default: assert( 0 ); break; } return 0;}/************************************************************************ int osd parameters*************************************************************************/void CG_init(int reset){ OSD_init(CG_SCREEN_XSTART, CG_SCREEN_YSTART, CG_FONT_WIDTH*CG_LINE_WIDTH, CG_LINES * CG_LINE_HEIGHT+8, CG_BITS_PER_PIXEL, OP_OSD_START, OP_OSD_START+(OP_OSD_LENGTH>>1), 0, reset);}/************************************************************************ To clear the current message.*************************************************************************/void CG_clear_message(int x, int y, int dx){ int px = x; int py = y; cg_ch2pixel( &px, &py ); OSD_area_fill(px, py, px+dx*CG_FONT_WIDTH, py+CG_FONT_HEIGHT, icon_back_color); return;}/************************************************************************ To copy the messge to OSD memory. If the immed is set to 1, we finish it right now, otherwise we do it later.*************************************************************************/#ifdef NOT_USEDint CG_show_message(int immed, uchar *msg, int x, int y, int dt, int hli_s, int hli_e){ return CGI_msg_show(immed, msg, x, y, dt, hli_s, hli_e);}/************************************************************************ The difference between this function and CG_show_message is that this function will clear the rest part of the line.*************************************************************************/int CG_show_line(int immed, uchar *msg, int x, int y, int dt, int hli_s, int hli_e){#if 1 CGI_msg_show(immed, msg, x, y, dt, hli_s, hli_e);#else int i; uchar line_buf[CG_LINE_WIDTH + 1]; /* clear */ for (i = 0; i < CG_LINE_WIDTH; i++) line_buf[i] = FONT_BLANK; line_buf[CG_LINE_WIDTH] = 0;#if 0 /* show line only overwrite the space after message */ i = 0; while(*msg && i < CG_LINE_WIDTH) line_buf[i++] = *msg++; return CG_show_message(immed, line_buf, x, y, dt, hli_s, hli_e);#else /* show line overwrite the space before and after message */ i = x; while(*msg && i < CG_LINE_WIDTH) line_buf[i++] = *msg++; return CG_show_message(immed, line_buf, 0, y, dt, hli_s, hli_e);#endif #endif}/************************************************************************ Turn on/off*************************************************************************/void GI_on_forced(int on){ if(on) { OSD_on(1); icon_on_screen++; } else if (icon_on_screen>0) icon_on_screen--;}/************************************************************************ return cg display state*************************************************************************/#ifdef EQUALIZERint CG_state(void){ return (icon_on_screen);}#endif/************************************************************************ Return 1 to indicate the last message is still pending.*************************************************************************/int CG_is_busy(){ return cg_msg_valid;}#endif/************************************************************************ CG_service*************************************************************************/void CG_service(int mode){ int i, j, k; char *p; /* MODE 0: time out check */ if ( mode == 0) { /* checking validation */ if (!icon_on_screen) return; if (gi_msg_number) { for (i=0; i<MAX_MESSAGE_NUMBER; i++) { if (gi_msg[i].state==STATE_ERASE&&gi_msg[i].time>0) gi_msg[i].time--;#ifdef NOT_USED if (gi_msg[i].speed&&gi_msg[i].ani_time>0) gi_msg[i].ani_time--;#endif } } return ; }#ifdef EQUALIZER if (EQ_refresh()) return;#endif /* MODE 1: To show/erase message to/from screen */ if (mode == 1) { if (gi_msg_number) { for (i=0; i<MAX_MESSAGE_NUMBER; i++) if (gi_msg[i].state==STATE_DISPLAY) { if (gi_msg_display(i, 0)==1) break; } } /* check window validation */ if (!icon_on_screen) return; if (gi_msg_number) {#ifdef NOT_USED for (i=0; i<MAX_MESSAGE_NUMBER; i++) if (gi_msg[i].state==STATE_ERASE&&gi_msg[i].speed&& (!gi_msg[i].ani_time)) { gi_msg_animate(i); }#endif for (i=0; i<MAX_MESSAGE_NUMBER; i++) if (gi_msg[i].state==STATE_ERASE&&(!gi_msg[i].time)) { for(j=1;j<=OSD_MAX_REGIONS;j++){ if( msg_in_region(i,j) ) OSD_displayed_regions &= ~(ptrLshift[j-1]); } if (gi_msg_remove(i, 1)==1) break; } } } return;}/*************************************************************************************************************************************************/static void icon_screen_check(void){ if (icon_on_screen>0) { icon_on_screen--; if (!icon_on_screen) OSD_on(0); }}/*************************************************************************************************************************************************/#ifdef BILINGUAL_OSDint GI_msg_show(int immed, uchar *emsg, uchar *cmsg, int x, int y, int align,#elseint GI_msg_show(int immed, uchar *msg, int x, int y, int align, #endif int display_time, int hli_s, int hli_e, int area_control, int animation_speed){ GI_MSG *pmsg; uchar *p, text[MAX_TEXT_LENGTH]; int i, j;#ifdef BILINGUAL_OSD uchar *msg,*bmsg; if ( osd_lang == CHINESE_OSD ) { msg = cmsg; bmsg = emsg; } else { msg = emsg; bmsg = cmsg; }#endif for (i=0; i<MAX_MESSAGE_NUMBER; i++) { pmsg = (GI_MSG *) &gi_msg[i]; if (pmsg->state == STATE_INVALID) break; } if (i==MAX_MESSAGE_NUMBER) { cg_overflow++; return -1; } if (*msg==0) return -2; pmsg->x = x; pmsg->y = y; pmsg->align = (align&0xf)+((current_charset&0xf)<<4); pmsg->area = (area_control&0xf)+((icon_auto_mapping&0xf)<<4); pmsg->time = display_time*2;#ifdef NOT_USED pmsg->speed = animation_speed; pmsg->ani_time = animation_speed; pmsg->ani_index = 0; #endif pmsg->state = STATE_DISPLAY;#ifdef ZORDER pmsg->z = z_start++;#endif p = (current_charset<VWENGLISH_FONTS) ? (uchar *)&cg_map_color_array : icon_mapping; for (j=0; j<4; j++) pmsg->colormap[j] = p[j]; pmsg->colormap[4] = icon_back_color; p=hli_insert(text, msg, MAX_TEXT_LENGTH, hli_s, hli_e); j= 0; while(*p && j < MAX_TEXT_LENGTH) { pmsg->msg[j++] = *p++; } if (j< MAX_TEXT_LENGTH) pmsg->msg[j] = 0; else pmsg->msg[MAX_TEXT_LENGTH-1] = 0;#ifdef BILINGUAL_OSD p=hli_insert(text, bmsg, MAX_TEXT_LENGTH, hli_s, hli_e); j= 0; while(*p && j < MAX_TEXT_LENGTH) { pmsg->bmsg[j++] = *p++; } if (j< MAX_TEXT_LENGTH) pmsg->bmsg[j] = 0; else pmsg->bmsg[MAX_TEXT_LENGTH-1] = 0;#endif pmsg->rect.xstart = -1; if (immed) { if (gi_msg_display(i, 1)<=0) return -2; } gi_msg_number++; return i;}/*************************************************************************************************************************************************/static int gi_msg_display(int entry, int immed){ int k; if (gi_msg[entry].state==STATE_DISPLAY&&entry>=0 &&entry<MAX_MESSAGE_NUMBER) { if (gi_msg[entry].rect.xstart<0) { if (!(k=gi_msg_info(entry))) { gi_msg[entry].state=STATE_INVALID; return k; } else if (!immed) return k; } k = gi_msg_manage(entry); if (k<0) return 0; else if (k>0&&!immed) return 1; gi_msg_out(entry); if (gi_msg[entry].time) { gi_msg[entry].state = STATE_ERASE; } else gi_msg[entry].state = STATE_INVALID;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -