📄 cg.c
字号:
/* Copyright 1997, ESS Technology, Inc. *//* SCCSID @(#)cg.c 4.19.1.2 11/10/04 *//* * $Log$ */#include "vcxi.h"#include "debug.h"#include "const.h"#include "memmap.h"#include "osd.h"#include "cg.h"#include "nav_menu.h"#include "timedef.h"#include "dsa.h"#include "panel.h"#include "echo.h"#include "cd.h"#include "filesys.h"#ifdef MP3#include "mp3.h"#endif#ifdef EQUALIZER #include "eq.h"#endif#ifdef CD_TEXT#include "cd_text.h"#endif#define YPRINTF(a) EPRINTF(a)#define CPRINTF(a)#define FULL_COMP 1 #define NORMAL_BACKGROUND 1#define HILIGHT_OFFSET 8#if 0 extern int bpt;#define BREAKPOINT(x) {bpt=x;while(bpt) VCX_service();}#else#define BREAKPOINT(x)#endif extern int newicon_decomp(uchar *out, uchar *in, uchar *codebook, int width, int height);/* OSD_OLD */OSD_pos OSD2CG_map[] = { {76,50}, {76,50}, {316,50}, {476,50}, {76,82}, {316,82}, {476,82}, {76,114},{316,114},{416,114}, {76,210},{136,210},{416,210},};unsigned int OSD_next_update; /* time next update allowed */ unsigned char OSD_update_time;unsigned char OSD_new_time[OSD_TIME_SIZE+1], OSD_new_track[OSD_TRACK_SIZE+1];#ifdef BILINGUAL_OSDOSD_Language osd_lang = CHINESE_OSD; /* 0 : English, 1 : other(Chinese) */#endif/* CG variables */static short osd_pal3d[] = { (OSD_CLEAR | 0x0), (OSD_BLACK | 0xb), (OSD_DARK | 0xf), (OSD_BRIGHT | 0xf), (OSD_MAGENTA | 0xf), (OSD_LIGHTORANGE | 0xf), (OSD_GREEN | 0xf), (OSD_BLACK | 0xf), (OSD_YELLOW | 0xf), (OSD_BLUE | 0xf), (OSD_LIGHTBLUE | 0xe), (OSD_DARKCYAN | 0xf), (OSD_RED | 0xf), (OSD_MIDDLE | 0xf), (OSD_CYAN | 0xf), (OSD_GRAY | 0xf)};static uchar n2h_color_mapping[8] = {8, 8, 10, 7, 10, 5, 14, 15 };/************************************************************************ Defination and Data Structure*************************************************************************/typedef struct { unsigned char how_much :4; unsigned char color0 :4; unsigned char delayed_color1:4; unsigned char color1 :4; unsigned char delayed_color2:4; unsigned char color2 :4; unsigned char delayed_color3:4; unsigned char color3 :4; } CG_COLOR_MAP;typedef struct { int ystart; int yend;} CG_WINDOW;typedef struct { uchar *comp_font; uchar *code_book; uint *offset_tbl; int index; int bytes; int width; int height; int start_offset; int max_char; int id_offset;} FONT_ATR;#define MAX_MSG_NUMBER 5static uchar cg_overflow=0;/************************************************************************ static varibles*************************************************************************/static int cg_curr_scr_mode = -1;static int cg_windows;static CG_WINDOW cg_act;static FONT_ATR cg_font_attr[FONT_LANGUAGES];/************************************************************************ Local Function:*************************************************************************/static int cg_copy_data(uchar *msg, int x, int y, int dt, int hli_s, int hli_e);static void cg_erase_font(int x, int y);void cg_ch2pixel(int *x, int *y);static void cg_copy_char_bitmap( uchar *addr, int hli, FONT_ATR *ptr);static int cg_check_window_timeout(int index);#define MAX_ICON_TABLE_LENGTH 300 #define MAX_DWORD_PER_ICON 1152 #define MAX_TEXT_LENGTH 40#define MAX_MESSAGE_NUMBER 10#define STATE_INVALID 0#define STATE_DISPLAY 1#define STATE_ERASE 2typedef struct { uchar width; /* pixel width of icon */ uchar height; /* pixel height of icon */ uchar base; /* display base line for icon: 0 - justifying with bottom line of icon; base>0 - bottom line of icon will down shift; base<0 - bottom line of icon will up-shift; */ uchar format; /* color format: 0-4bpp; 1-1bpp; 2-2bpp; */ uchar *color_mapping; /* color index convert table from 1 or 2 bpp to 4 bpp: if format==0 then no color_mapping exist if format==1 then *color_mapping is one byte, which indicate: color 0 -> (*color_mapping)>>4; color 1 -> (*color_mapping)&0xf; if format==2 then *color_mapping is two byte, which indicate: color 0 -> (*color_mapping)>>24; color 1 -> ((*color_mapping)>>16)&0xf; color 2 -> ((*color_mapping)>>8)&0xf; color 3 -> (*color_mapping)&0xf; */ uchar *data; /* the data of icon */} ICON_CHAR; static struct ICON_TABLE { short id; } icon_table[MAX_ICON_TABLE_LENGTH];typedef struct { short xstart; short ystart; short xend; short yend; } RECT;typedef struct { short time; uchar state; uchar align;#ifdef NOT_USED uchar speed; uchar ani_time; uchar ani_index; uchar dump0;#endif uchar area; uchar base;#ifdef ZORDER uchar z;#else uchar dumy;#endif uchar colormap[5]; ushort x; ushort y; RECT rect; uchar msg[MAX_TEXT_LENGTH];#ifdef BILINGUAL_OSD uchar bmsg[MAX_TEXT_LENGTH];#endif} GI_MSG;static GI_MSG gi_msg[MAX_MESSAGE_NUMBER];#ifdef ZORDER uchar z_start=0;#endifstatic uint current_charset;static uint icon_hli_flag;static uint icon_total_number; /* actual icon number in system */static uint icon_auto_mapping; /* 0 - system, 1-icon itself */static uint icon_back_color, icon_bcolor_sav; /* icon background color */static uint icon_back_erase; /* wrap rect erase flag */static uchar icon_mapping[16]={ /* default color mapping table */ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};static int icon_on_screen; /* flag to indicate if icon on screen */static int gi_msg_number; /* the number of current msg */static int font_header;static int icon_id_offset; /* offset of icon_id for every font */static int last_register_charset;static void set_rect_value(RECT *rect, int xs, int ys, int xe, int ye);static void get_rect_value(RECT *rect, int *xs, int *ys, int *xe, int *ye);static void get_area_rect_value(int, int *xs, int *ys, int *xe, int *ye);static void color_map_set(ICON_CHAR *pichar, int *map, int bkc);static int icon_control(int icon_id);static int data_width(unsigned char width, unsigned char depth);static void align_transfer(int align, RECT *rect);static uchar *hli_insert(uchar* buff,uchar* msg,int length,int hs,int he);static int icon_index(int icon_id);#ifdef NOT_USEDstatic unsigned char *icon_address(int icon_id);#endifstatic uchar *cg_font_info(FONT_ATR *pfa, int charset, int index, int *size);static int icon_char_info(FONT_ATR *pf, uchar *p, ICON_CHAR *pichar);static int icon_size(uchar *p, int headin);static int icon_show(FONT_ATR* pfont_atr, ICON_CHAR *pic, uchar *addr, int index, int x, int y);static int textinfo(uchar *message, int x, int y, int align, RECT *rect, int *base);static int textout(uchar *message, int x, int y, int align, int mode);static FONT_ATR *charset_index2font(int charset, int index);static int icon_extension(uchar *buffer, ICON_CHAR *pic, int bkcolor);static void icon_screen_check(void);static int gi_msg_display(int i, int immed);#ifdef NOT_USEDstatic int gi_msg_animate(int entry);#endifstatic int gi_msg_manage(int i);static int gi_msg_neighbor(int i, int j);static int gi_area_erase(RECT rect);static int gi_msg_remove(int entry, int mode);static int gi_msg_info(int entry);static int gi_msg_out(int entry);/********************************************************************* Function: Description:*********************************************************************/int msg_in_region(int i, int area){ return(gi_msg[i].rect.xstart==OSD2CG_map[area].x && gi_msg[i].rect.ystart==OSD2CG_map[area].y); #if 0 if(gi_msg[i].rect.xend<=OSD2CG_map[area].x || gi_msg[i].rect.xstart>=OSD2CG_map[area].x+((area%3)?10:8)*CG_FONT_WIDTH || gi_msg[i].rect.yend<=OSD2CG_map[area].y || gi_msg[i].rect.ystart>=OSD2CG_map[area].y+CG_FONT_HEIGHT ) return 0; else return 1;#endif}/* * outosd(): * Use OSD to display a message to a region. * * * Inputs: * region: One of fifteen predefined OSD regions.. * (refer to OSD2CG_map[]) * msg: Message to display * sec: Number of seconds to display msg before clearing. * If duration is 0, then the message will be displayed * indefinitely. * * Additional parameters for bilingual language output if BILINGUAL_OSD * is defined. * * c_msg: Chinese OSD string */int outosd(int area,unsigned char *e_msg,#ifdef BILINGUAL_OSD unsigned char *c_msg,#endif int sec, int immed){ int gi_msg_index, osdarea; osdarea = area;#if (defined MP3 || defined WMA_DEC || defined CD_TEXT) if (CG_menu_on#ifdef CD_TEXT || CDT_data_ready#endif ) {if( area>3 ) osdarea = 1;} /* ((area-1)%3)+1; */#endif gi_msg_index = GI_msg_show(immed,e_msg,#ifdef BILINGUAL_OSD c_msg,#endif OSD2CG_map[osdarea].x,OSD2CG_map[osdarea].y,0, sec?sec:-1,-1,-1,AREA_CLEAR,0); if (gi_msg_index >= 0) { OSD_displayed_regions |= ptrLshift[area-1]; } return (gi_msg_index);}#ifdef BILINGUAL_OSDvoid OSD_language_change(){ uchar tmp[MAX_TEXT_LENGTH]; int i,j;#ifdef DATA_CD if (STREAM_type) CG_clear_message(0,0,CG_LINE_WIDTH); else#endif dram_clear(OSD_start, OP_OSD_LENGTH); if (gi_msg_number) { for (i=0; i<MAX_MESSAGE_NUMBER; i++) { if ((gi_msg[i].state==STATE_ERASE) && (gi_msg[i].time)){ gi_area_erase(gi_msg[i].rect); for ( j=0; j<MAX_TEXT_LENGTH; j++) { tmp[j] = gi_msg[i].msg[j]; gi_msg[i].msg[j] = gi_msg[i].bmsg[j]; gi_msg[i].bmsg[j] = tmp[j]; } if ( gi_msg[i].msg[0] == 0 ) { gi_msg[i].msg[0] = FONT_BLANK; gi_msg[i].msg[1] = 0; } gi_msg_info(i); gi_msg_out(i); } } } if ( osd_lang == ENGLISH_OSD ) { osd_lang = CHINESE_OSD; } else { osd_lang = ENGLISH_OSD; OUTOSD(11,"ENGLISH","",3); }}#endif/* * OSD_update_info(): * This routine updates track and/or time information. Track and time * display can be controlled by defines. */void OSD_update_info(){ int i, tmp;#ifdef EQUALIZER if (EQ_refresh_cnt) return; /* we are updating EQ..different charset */#endif #ifdef PLAY20 if (OSD_displayed_regions & OSD_TIME_REGION_MASK) { tmp = (D2A_BLANK << 20) | (OSD_time_minute << 12) | (D2A_COLON << 8) | OSD_time_second; for (i=5; i>=0; i--) { OSD_new_time[i] = T_digit2ascii[tmp&0xf]; tmp >>= 4; } OUTOSDX(OSD_TIME_REGION,OSD_new_time,OSD_new_time,0); /* We use two complementary methods to update time: * 1) through servo Q-code when we receive "seconds" and * 2) "one-second" timer, in case someone holds the disc * and prevents Q-code update. This is needed for * MP3/WMA and CDDA w/ANTI_SHOCK. * So we'll need to set a minumum time for next update, * to prevent "quick" seconds update. */ OSD_next_update = glbTimer + 50; } if ( (OSD_displayed_regions & OSD_TRACK_REGION_MASK) && ((CG_track_entry&0xfff) != cur_track_number)) { i = UTIL_hex2bcd(cur_track_number); tmp = (i<<16) | (D2A_SLASH<<12); if (i < 0x100) tmp |= (D2A_BLANK<<24); if (bcd_num_of_track < 0x100) { tmp |= ((bcd_num_of_track<<4) | D2A_NULL); } else { tmp |= bcd_num_of_track; } /* tmp = track | '/' | num_of_track */ for (i = 6; i >= 0; i--) { OSD_new_track[i] = T_digit2ascii[tmp&0xf]; tmp >>= 4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -