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

📄 cg.c

📁 ESS3890+SL原代码(1*16内存)
💻 C
📖 第 1 页 / 共 5 页
字号:
        icon_on_screen++;        OSD_on(1);        return 1;    }    return 0;}/*************************************************************************************************************************************************/#ifdef NOT_USED static int gi_msg_animate(int entry){    int k;    if (gi_msg[entry].state==STATE_ERASE&&entry>=0        &&entry<MAX_MESSAGE_NUMBER) {        gi_msg_out(entry);  	gi_msg[entry].ani_time = gi_msg[entry].speed;	        OSD_on(1);        return 1;    }    return 0;}/*************************************************************************************************************************************************/int GI_animation_remove(void){    int i;    if (gi_msg_number==0)	return 0;    for (i=0; i<MAX_MESSAGE_NUMBER; i++) {	if (gi_msg[i].state!=STATE_INVALID&&gi_msg[i].speed) {            if (gi_msg[i].state==STATE_ERASE)		gi_area_erase(gi_msg[i].rect);            gi_msg[i].state = STATE_INVALID;            gi_msg_number--;	    icon_screen_check();	}    }    return 1;}#endif/*************************************************************************************************************************************************/static int gi_msg_remove(int entry, int mode){    if (gi_msg[entry].state==STATE_ERASE&&entry>=0        &&entry<MAX_MESSAGE_NUMBER) {        gi_msg[entry].state = STATE_INVALID;        gi_msg_number--;        if (mode | (gi_msg[entry].area&AREA_REFRESH)==AREA_REFRESH) {	    gi_area_erase(gi_msg[entry].rect);	    icon_screen_check();	} else if (icon_on_screen>0) icon_on_screen--;        gi_msg[entry].rect.xstart = 0;        gi_msg[entry].rect.xend = 0;        gi_msg[entry].rect.ystart = 0;        gi_msg[entry].rect.yend = 0;	/* Check Track OSD region for overwrite..	 * reset CG_track_entry to force Track update.	 */	if ((CG_track_entry>>12) == entry) CG_track_entry = 0;        return 1;    }    return 0;}/*****************************************************************************************************************************************/#ifdef ZORDERint gi_restore_check(int entry, int res_num, int *res_array){    int j;    if ((gi_msg[entry].area&0x3)==AREA_FREE&& entry>=0&&        entry<MAX_MESSAGE_NUMBER) {        for (j=0; j<MAX_MESSAGE_NUMBER; j++) {            if (gi_msg[j].state==STATE_ERASE&&                    (gi_msg[j].area&0x3)==AREA_FREE&&                    gi_msg[j].time<0&&(j!=entry)&&                    gi_msg_neighbor(entry,j)) {                res_array[res_num++] = j;                if (res_num>=255) { assert(0); }            }        }    }    return res_num;}/*****************************************************************************************************************************************/int gi_auto_restore(int res_num, int *res_array){    int l, m, min, index, order;    uchar res_array1[256];    for (l=0; l<res_num; l++) {        min = index = 256;        for (m=0; m<res_num; m++) {            m = res_array[l];            if (m<0) continue;            order = gi_msg[m].z;            order -= z_start;            if (order < 0) order += 255;            if (min>order) { min=order, index = m; }        }	assert(min<256);        res_array[m] = -1;        res_array1[l] = m;    }    for (l=0; l<res_num; l++)        gi_msg_out(l);    return res_num;}/*****************************************************************************************************************************************/int GI_msg_remove(int entry){    int res_array[256], res_num=0;    uchar res_array1[256];    res_num = gi_restore_check(entry, res_num, res_array);    gi_msg_remove(entry, 1);    gi_auto_restore(res_num, res_array);    return res_num;}/*****************************************************************************************************************************************/int GI_msgsgrp_remove(int del_num, uchar del_entry[]){    int i, entry, res_array[256], res_num=0;    uchar res_array1[256];    for (i=0; i<del_num; i++) {	entry = del_entry[i];    	res_num = gi_restore_check(entry, res_num, res_array);        gi_msg_remove(entry, 1);    }    gi_auto_restore(res_num, res_array);    return res_num;}/*************************************************************************************************************************************************/int GI_msg_show_auto(uchar *msg, int x, int y, int align, int hli_s, int hli_e){    return GI_msg_show(1, msg, x, y, 0, -1, hli_s, hli_e, AREA_FREE, 0);}#endif/*************************************************************************************************************************************************/static int gi_msg_info(int entry){    FONT_ATR *pfa;    ICON_CHAR ichar;    GI_MSG *ptr= &gi_msg[entry];    uchar *addr, *p=ptr->msg;    int x=ptr->x, y=ptr->y, x1, x2, y1, y2, height, original_charset;    int i, size, total_width=0, max_height1=0, max_height2=0, save_charset;    save_charset = current_charset;    current_charset = (ptr->align&0xf0)>>4;    while (*p) {        while (icon_control(*p)) p++;        if (*p==0) break;	*p = i = icon_index(*p);         if (i<0) { p++; continue; }        pfa = charset_index2font(current_charset, i);        addr = cg_font_info(pfa, current_charset, i, &size);        icon_char_info(pfa, addr, &ichar);#ifdef NOT_USED        if (ptr->speed) {            if (total_width<ichar.width)                total_width = ichar.width;        } else#endif            total_width += ichar.width;        height = ichar.height - ichar.base;        if (max_height1<height)            max_height1 = height;        if (max_height2<ichar.base)            max_height2 = ichar.base;        p++;	font_header = -1;    }    icon_hli_flag = 0;    current_charset = save_charset;    height = max_height1+max_height2;    ptr->base = max_height2;    set_rect_value(&(ptr->rect), x, y, x+total_width, y+height);    align_transfer(ptr->align, &(ptr->rect));    return OSD_area_check(ptr->rect.xstart, ptr->rect.ystart, 	ptr->rect.xend, ptr->rect.yend);}/*************************************************************************************************************************************************/static int gi_msg_out(int entry){    FONT_ATR *pfa;    ICON_CHAR ichar, *pic;    GI_MSG *ptr= &gi_msg[entry];    uchar *addr, *msg;    int i, index, size, x1, x2, y1, y2;     int align, save_charset, save_auto_mapping, base;    uchar cg_map_color_delayed;    int default_color_map[] = {	0, /* always */	(TEXT_BACKGROUND<<4)|TEXT_BACKGROUND,	(TEXT_BORDER<<4)|TEXT_BORDER,	(TEXT_FOREGROUND<<4)|TEXT_FOREGROUND    };    get_area_rect_value(entry, &x1, &y1, &x2, &y2);    if (icon_back_erase) {	icon_back_erase = 0;        OSD_area_fill(x1,y1,x2,y2,icon_back_color);    }#ifdef NOT_USED    msg = ptr->msg + ptr->ani_index;#else    msg = ptr->msg;#endif    align = ptr->align&0xf;     save_auto_mapping = icon_auto_mapping;    save_charset = current_charset;    current_charset = (ptr->align&0xf0)>>4;    icon_auto_mapping = (ptr->area&0xf0)>>4;    icon_back_color = ptr->colormap[4];    if (current_charset<VWENGLISH_FONTS)	CG_map_color3((ptr->colormap[1] & 0xf), 		      (ptr->colormap[2] & 0xf),		      (ptr->colormap[3] & 0xf));    else	ICON_color_array_mapping(ptr->colormap[1], ptr->colormap[2],				 ptr->colormap[3]);    base = ptr->base;     pic = &ichar;    cg_map_color_delayed = (uchar)(((ptr->colormap[0])>>4)&0xf);    while (*msg) {        while (icon_control(*msg)) {	    msg++; #ifdef NOT_USED	    if (gi_msg[entry].speed) ptr->ani_index++;#endif	}        if (*msg==0) break;        index = *msg;          if (index<0) { msg++; continue; }        pfa = charset_index2font(current_charset, index);        addr = cg_font_info(pfa, current_charset, index, &size);        icon_char_info(pfa, addr, pic);        if (ichar.width>0&&ichar.height>0) {            icon_show(pfa, pic, addr, index, x1, y1+base-ichar.base);            x1+=ichar.width;        }        msg++;	font_header = -1;#ifdef NOT_USED	if (gi_msg[entry].speed) {	    if (*msg) ptr->ani_index++;	    else ptr->ani_index=0;	    break;	}#endif        if (cg_map_color_delayed > 0) {            cg_map_color_delayed--;            if (cg_map_color_delayed==0) check_map_color_delayed();        }    }    /* put back default map CG char color map */    addr = (uchar *)&cg_map_color_array;    for (i=0; i<4; i++) {	addr[i] = (uchar)default_color_map[i];    }    icon_hli_flag = 0;     current_charset = save_charset;    icon_auto_mapping = save_auto_mapping;    return 0;}/*************************************************************************************************************************************************/static int gi_msg_manage(int entry){    int ret,j, k=0;        if ((gi_msg[entry].area&AREA_WAIT)==AREA_WAIT) {        for (j=0; j<MAX_MESSAGE_NUMBER; j++) {            if (gi_msg[j].state==STATE_ERASE&&(j!=entry)                &&gi_msg_neighbor(entry,j)) {                return -1;            }        }    }    for (j=0; j<MAX_MESSAGE_NUMBER; j++) {        if (gi_msg[j].state==STATE_ERASE&&(j!=entry)&&	    (gi_msg[j].area&AREA_CLEAR)==AREA_CLEAR && 	    (ret=gi_msg_neighbor(entry,j))) {            if( ret <= 2 ) {                k++;                gi_msg_remove(j, ret-1);            } else {               /* gi_msg[entry].state = STATE_INVALID; */                return -1;            }        }    }    return k;}/*************************************************************************************************************************************************/static int gi_msg_neighbor(int i, int j){    if (gi_msg[j].rect.xend<=gi_msg[i].rect.xstart ||	gi_msg[i].rect.xend<=gi_msg[j].rect.xstart ||	gi_msg[j].rect.yend<=gi_msg[i].rect.ystart ||	gi_msg[i].rect.yend<=gi_msg[j].rect.ystart) {        return 0;    } else {        if (gi_msg[j].rect.xstart<gi_msg[i].rect.xstart) {            return 3;  /* supress msg i, not display msg i */        }        if (gi_msg[i].rect.xstart<gi_msg[j].rect.xstart) {            return 2;  /* supress msg j, erase msg j immediatly */        }        if (gi_msg[i].rect.xend < gi_msg[j].rect.xend) return 2;        return 1;  /* msg i j are in the same region */    }}/*************************************************************************************************************************************************/static int gi_area_erase(RECT rect){    OSD_area_fill(rect.xstart, rect.ystart, rect.xend, rect.yend, 	icon_back_color);}/*************************************************************************************************************************************************/void GI_msg_reset(int screen_erase){    int i;    if (!icon_on_screen) 	OSD_on(0);          if (gi_msg_number==0) return;    for (i=0; i<MAX_MESSAGE_NUMBER; i++) {	if (screen_erase)	    gi_msg_remove(i, 1); 	gi_msg[i].state = STATE_INVALID;    }    gi_msg_number = 0;}/************************************************************************  convert x, y to pixel *************************************************************************/void cg_ch2pixel(int *x, int *y) {    *x = CG_SCREEN_XSTART + CG_FONT_WIDTH * (*x);    *y = CG_SCREEN_YSTART + CG_LINE_HEIGHT * (*y);}/************************************************************************  copy the specific font's bitmap to the buffer. *************************************************************************/void cg_copy_char_bitmap( uchar *addr, int hli, FONT_ATR *ptr){    int i,j, k0, k1;    uchar filter = 0;    uchar tmp = 0;    uchar *srcptr0, *srcptr1;    int height;    int bytes;    int new = 1;		/* A new character			*/    uchar scratch_buf[350];	/* To store decompressed data plus 5B */    uchar *bufend = (unsigned char *) &scratch_buf[350];    uchar n2h_mapping[2][8];    for (i=0; i<8; i++) {	n2h_mapping[0][i] = n2h_color_mapping[i];	n2h_mapping[1][i] = (n2h_color_mapping[i]<<4);     }    srcptr0 = bufend;    newicon_decomp((uchar*)scratch_buf, (ptr->comp_font+        *(ptr->offset_tbl+ptr->index)), ptr->code_book,        (ptr->width+3)/4, ptr->height);    srcptr0 =  scratch_buf;    for(i = 0; i < ptr->bytes; i++) {	tmp = *srcptr0++;        if (hli) {	    k1 = map4to8[tmp>>4];	    k0 = k1&0x0f;	    k1 >>= 4;	    *addr++ = n2h_mapping[1][k1]+n2h_mapping[0][k0];            k1 = map4to8[tmp & 0xf];            k0 = k1&0x0f;            k1 >>= 4;            *addr++ = n2h_mapping[1][k1]+n2h_mapping[0][k0];	} else {            *addr++ = map4to8[tmp>>4];            *addr++ = map4to8[tmp & 0xf];	}    }    return;}#ifdef UPDATE_BANK30/************************************************************************  Copy char fonts to DRAM so that we don't need the fonts from ROM.  The location in DRAM is given by "temp_bitmap".  For each character in "set", you must reserve CG_DWORDS_PER_CH  dwords in "temp_bitmap" (assuming single width fonts only).*************************************************************************/void CG_copy_char_font(uint *temp_bitmap, char *set){    FONT_ATR *pfont_atr;    while (*set) {        pfont_atr = charset_index2font(ENGLISH_FONTS, *set);    	cg_copy_char_bitmap((uchar *)temp_bitmap, 0, pfont_atr);    	temp_bitmap += CG_DWORDS_PER_CH;	set++;    }}/************************************************************************  Copy chars from temporary DRAM space to OSD memory.  Single width characters only. No hilight. No automatic erase.*************************************************************************/int  CG_show_message_poor(uint *temp_bitmap, uchar *msg, int x, int y){    uint *bitmap;    int font_x, font_y;    FONT_ATR *pfont_atr = &cg_font_attr[ENGLISH_FONTS];    if (x >= CG_LINE_WIDTH || y >= CG_LINES) return -1;    icon_on_screen = 1;    OSD_on(1);        while( *msg && (x < CG_LINE_WIDTH)) {	bitmap = temp_bitmap + ((*msg)-1)*CG_DWORDS_PER_CH;	font_x = x; font_y = y;	cg_ch2pixel(&font_x, &font_y);		OSD_bitblt(font_x, font_y, pfont_atr->width, pfont_atr->height, 		   (uchar *)bitmap);	msg++;	x++;    }    return 0;}#endif

⌨️ 快捷键说明

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