diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index 3314d7c5a..2fe8bc8eb 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include /* same as in rcinput.h... */ @@ -29,12 +30,6 @@ #define KEY_TTZOOM KEY_FN_2 #define KEY_REVEAL KEY_FN_D -#if HAVE_SPARK_HARDWARE -#define MARK_FB(a, b, c, d) if (p == lfb) CFrameBuffer::getInstance()->mark(a, b, (a) + (c), (b) + (d)) -#else -#define MARK_FB(a, b, c, d) -#endif - extern cVideo * videoDecoder; static pthread_t ttx_sub_thread; @@ -50,46 +45,42 @@ bool isTtxEplayer = false; static int screen_x, screen_y, screen_w, screen_h; -void FillRect(int x, int y, int w, int h, fb_pixel_t color, bool modeFullColor=false); -void FillBorder(fb_pixel_t color, bool modeFullColor=false); - -fb_pixel_t *getFBp(int *y) +fb_pixel_t *getFBp(int &y) { - if (*y < (int)var_screeninfo.yres) + if (y < (int)var_screeninfo.yres) return lfb; - *y -= var_screeninfo.yres; + y -= var_screeninfo.yres; return lbb; } -void FillRect(int x, int y, int w, int h, fb_pixel_t color, bool modeFullColor/*=false*/) +static void FillRect(int x, int y, int w, int h, fb_pixel_t color) { - fb_pixel_t *p = getFBp(&y); - MARK_FB(x, y, w, h); - p += x + y * stride; - if (w > 0) { - fb_pixel_t col = (modeFullColor) ? color : bgra[color]; + fb_pixel_t *p = getFBp(y); + p += x + y * var_screeninfo.xres; + fb_pixel_t col = argb[color]; + if (w > 0) for (int count = 0; count < h; count++) { fb_pixel_t *dest0 = p; for (int i = 0; i < w; i++) - *(dest0++) = col; - p += stride; + *dest0++ = col; + p += var_screeninfo.xres; } - } } -void FillBorder(fb_pixel_t color, bool modeFullColor/*=false*/) + +static void FillBorder(fb_pixel_t color) { int ys = (var_screeninfo.yres-var_screeninfo.yoffset); - FillRect(0 , ys ,StartX ,var_screeninfo.yres ,color, modeFullColor); - FillRect(StartX, ys ,displaywidth,StartY ,color, modeFullColor); - FillRect(StartX, ys+StartY+25*fontheight,displaywidth,var_screeninfo.yres-(StartY+25*fontheight),color, modeFullColor); + FillRect(0 , ys ,StartX ,var_screeninfo.yres ,color); + FillRect(StartX, ys ,displaywidth,StartY ,color); + FillRect(StartX, ys+StartY+25*fontheight,displaywidth,var_screeninfo.yres-(StartY+25*fontheight),color); - if (screenmode == 0 ) - FillRect(StartX+displaywidth, ys,var_screeninfo.xres-(StartX+displaywidth),var_screeninfo.yres ,color, modeFullColor); + if (screenmode[boxed] == 0 ) + FillRect(StartX+displaywidth, ys,var_screeninfo.xres-(StartX+displaywidth),var_screeninfo.yres ,color); } -int getIndexOfPageInHotlist() +static int getIndexOfPageInHotlist() { int i; for (i = 0; i <= maxhotlist; i++) @@ -100,7 +91,7 @@ int getIndexOfPageInHotlist() return -1; } -void gethotlist() +static void gethotlist() { FILE *hl; char line[100]; @@ -146,7 +137,7 @@ void gethotlist() } } -void savehotlist() +static void savehotlist() { FILE *hl; char line[100]; @@ -185,7 +176,7 @@ void savehotlist() #define number2char(c) ((c) + (((c) <= 9) ? '0' : ('A' - 10))) /* print hex-number into string, s points to last digit, caller has to provide enough space, no termination */ -void hex2str(char *s, unsigned int n) +static void hex2str(char *s, unsigned int n) { do { char c = (n & 0xF); @@ -195,7 +186,7 @@ void hex2str(char *s, unsigned int n) } -int toptext_getnext(int startpage, int up, int findgroup) +static int toptext_getnext(int startpage, int up, int findgroup) { int current, nextgrp, nextblk; @@ -231,13 +222,12 @@ int toptext_getnext(int startpage, int up, int findgroup) if (nextgrp) return nextgrp; - else if (nextblk) + if (nextblk) return nextblk; - else - return startpage; + return startpage; } -void RenderClearMenuLineBB(char *p, tstPageAttr *attrcol, tstPageAttr *attr) +static void RenderClearMenuLineBB(char *p, tstPageAttr *attrcol, tstPageAttr *attr) { int col; @@ -261,25 +251,28 @@ void RenderClearMenuLineBB(char *p, tstPageAttr *attrcol, tstPageAttr *attr) memset(p-TOPMENUCHARS, ' ', TOPMENUCHARS); /* init with spaces */ } -void ClearBB(fb_pixel_t color) +static void ClearBB(fb_pixel_t color) { - FillRect(0, (var_screeninfo.yres - var_screeninfo.yoffset), var_screeninfo.xres, var_screeninfo.yres, color); + FillRect(0, var_screeninfo.yres - var_screeninfo.yoffset, var_screeninfo.xres, var_screeninfo.yres, color); } -void ClearFB(int /*color*/) +static void ClearFB(int /*color*/) { - //memset(lfb,0, var_screeninfo.yres*fix_screeninfo.line_length); + //memset(lfb,0, var_screeninfo.yres*var_screeninfo.xres); CFrameBuffer::getInstance()->paintBackground(); } + #if 0 //never used -void ClearB(fb_pixel_t color) +static void ClearB(fb_pixel_t color) { FillRect(0, 0, var_screeninfo.xres, var_screeninfo.yres, color); /* framebuffer */ FillRect(0, var_screeninfo.yres, var_screeninfo.xres, var_screeninfo.yres, color); /* backbuffer */ + CFrameBuffer::getInstance()->blit(); } #endif -int GetCurFontWidth() + +static int GetCurFontWidth() { int mx = (displaywidth)%(40-nofirst); // # of unused pixels int abx = (mx == 0 ? displaywidth+1 : (displaywidth)/(mx+1));// distance between 'inserted' pixels @@ -288,7 +281,7 @@ int GetCurFontWidth() return fontwidth+(((PosX+fontwidth+1-sx) <= displaywidth && nx <= fontwidth+1) ? 1 : 0); } -void SetPosX(int column) +static void SetPosX(int column) { PosX = StartX; int i; @@ -296,7 +289,7 @@ void SetPosX(int column) PosX += GetCurFontWidth(); } -void setfontwidth(int newwidth) +static void setfontwidth(int newwidth) { if (fontwidth != newwidth) { @@ -319,17 +312,13 @@ void setfontwidth(int newwidth) } } -void setcolors(unsigned short *pcolormap, int offset, int number) -{ - int i,trans_tmp,tr; +static void setcolors(unsigned short *pcolormap, int offset, int number) { int j = offset; /* index in global color table */ - int R = var_screeninfo.red.offset; - int G = var_screeninfo.green.offset; - int B = var_screeninfo.blue.offset; - int A = var_screeninfo.transp.offset; + int trans_tmp=25-trans_mode; - for (i = 0; i < number; i++) - { + argb[transp2] = (((trans_tmp+7)<<11 | 0x7FF)>>8) << 24; + + for (int i = 0; i < number; i++) { int r = (pcolormap[i] << 12 & 0xF000) >> 8; int g = (pcolormap[i] << 8 & 0xF000) >> 8; int b = (pcolormap[i] << 4 & 0xF000) >> 8; @@ -337,21 +326,15 @@ void setcolors(unsigned short *pcolormap, int offset, int number) r = (r * (0x3f+(color_mode<<3))) >> 8; g = (g * (0x3f+(color_mode<<3))) >> 8; b = (b * (0x3f+(color_mode<<3))) >> 8; - bgra[j] = (r << R) | (g << G) | (b << B) | (0xff << A); + + argb[j] &= 0xff000000; + argb[j] |= (r << 16) | (g << 8) | b; j++; } - trans_tmp=25-trans_mode; - tr = ((trans_tmp+7)<<11 | 0x7FF)>>8; - bgra[transp2] &= ~(0xff << A); /* clear alpha */ - bgra[transp2] |= tr << A; - bgra[menu3] &= ~(0xff << A); - bgra[menu3] |= 0xc0 << A; - bgra[transp] &= ~(0xff << A); - bgra[transp] |= 0; } /* hexdump of page contents to stdout for debugging */ -void dump_page() +static void dump_page() { int r, c; char *p; @@ -377,7 +360,7 @@ void dump_page() /* in: absolute triplet number (0..506, start at packet 3 byte 1) */ /* in: pointer to cache struct of page data */ /* out: 18 bit triplet data, <0 if invalid number, not cached, or hamming error */ -int iTripletNumber2Data(int iONr, tstCachedPage *pstCachedPage, unsigned char* pagedata) +static int iTripletNumber2Data(int iONr, tstCachedPage *pstCachedPage, unsigned char* pagedata) { if (iONr > 506 || 0 == pstCachedPage) return -1; @@ -411,7 +394,7 @@ int iTripletNumber2Data(int iONr, tstCachedPage *pstCachedPage, unsigned char* p /* dump interpreted object data to stdout */ /* in: 18 bit object data */ /* out: termination info, >0 if end of object */ -void eval_object(int iONr, tstCachedPage *pstCachedPage, +static void eval_object(int iONr, tstCachedPage *pstCachedPage, unsigned char *pAPx, unsigned char *pAPy, unsigned char *pAPx0, unsigned char *pAPy0, tObjType ObjType, unsigned char* pagedata) @@ -468,7 +451,7 @@ void eval_object(int iONr, tstCachedPage *pstCachedPage, || iONr1 == iONr); /* repeat until termination reached */ } -void eval_NumberedObject(int p, int s, int packet, int triplet, int high, +static void eval_NumberedObject(int p, int s, int packet, int triplet, int high, unsigned char *pAPx, unsigned char *pAPy, unsigned char *pAPx0, unsigned char *pAPy0) { @@ -499,7 +482,7 @@ void eval_NumberedObject(int p, int s, int packet, int triplet, int high, } } -int eval_triplet(int iOData, tstCachedPage *pstCachedPage, +static int eval_triplet(int iOData, tstCachedPage *pstCachedPage, unsigned char *pAPx, unsigned char *pAPy, unsigned char *pAPx0, unsigned char *pAPy0, unsigned char *drcssubp, unsigned char *gdrcssubp, @@ -1064,40 +1047,40 @@ int eval_triplet(int iOData, tstCachedPage *pstCachedPage, return 0; /* normal exit, no termination */ } -int setnational(unsigned char sec) +static int setnational(unsigned char sec) { - switch (sec) - { - case 0x08: - return NAT_PL; //polish - case 0x16: - case 0x36: - return NAT_TR; //turkish - case 0x1d: - return NAT_SR; //serbian, croatian, slovenian - case 0x20: - return NAT_SC; // serbian, croatian - case 0x24: - return NAT_RB; // russian, bulgarian - case 0x25: - return NAT_UA; // ukrainian - case 0x22: - return NAT_ET; // estonian - case 0x23: - return NAT_LV; // latvian, lithuanian - case 0x37: - return NAT_GR; // greek - case 0x55: - return NAT_HB; // hebrew - case 0x47: - case 0x57: - return NAT_AR; // arabic - } - return countryconversiontable[sec & 0x07]; + switch (sec) + { + case 0x08: + return NAT_PL; //polish + case 0x16: + case 0x36: + return NAT_TR; //turkish + case 0x1d: + return NAT_SR; //serbian, croatian, slovenian + case 0x20: + return NAT_SC; // serbian, croatian + case 0x24: + return NAT_RB; // russian, bulgarian + case 0x25: + return NAT_UA; // ukrainian + case 0x22: + return NAT_ET; // estonian + case 0x23: + return NAT_LV; // latvian, lithuanian + case 0x37: + return NAT_GR; // greek + case 0x55: + return NAT_HB; // hebrew + case 0x47: + case 0x57: + return NAT_AR; // arabic + } + return countryconversiontable[sec & 0x07]; } /* evaluate level 2.5 information */ -void eval_l25() +static void eval_l25() { memset(FullRowColor, 0, sizeof(FullRowColor)); FullScrColor = black; @@ -1110,7 +1093,9 @@ void eval_l25() printf("=== %03x/%02x %d/%d===\n", tuxtxt_cache.page, tuxtxt_cache.subpage,tuxtxt_cache.astCachetable[tuxtxt_cache.page][tuxtxt_cache.subpage]->pageinfo.nationalvalid,tuxtxt_cache.astCachetable[tuxtxt_cache.page][tuxtxt_cache.subpage]->pageinfo.national); #endif -#if 0 //TUXTXT_DEBUG I don't think we need this any longer because this code is unreachable (HexPages are handled before eval_l25() is called) +#if 0 +//TUXTXT_DEBUG + //I don't think we need this any longer because this code is unreachable (HexPages are handled before eval_l25() is called) if (pageinfo->function == FUNC_MOT) /* magazine organization table */ { int i; @@ -1189,7 +1174,7 @@ void eval_l25() for (packet = 1; packet <= 4; packet++) { unsigned char *ptriplet = pagedata + 40*(packet-1); - int idata = dehamming[*ptriplet]; + int idata = dehamming[*ptriplet]; int triplet; if (idata == 0xff || 0 == (idata & 1)) /* hamming error or no pointer data: ignore packet */ @@ -1324,9 +1309,8 @@ void eval_l25() int o = 2 * (((tuxtxt_cache.page & 0xf0) >> 4) * 10 + (tuxtxt_cache.page & 0x0f)); /* offset of links for current page */ int opop = p[o] & 0x07; /* index of POP link */ int odrcs = p[o+1] & 0x07; /* index of DRCS link */ - unsigned char obj[3*4*4]; // types* objects * (triplet,packet,subp,high) + unsigned char obj[3*4*4] = { 0 }; // types* objects * (triplet,packet,subp,high) unsigned char type,ct, tstart = 4*4; - memset(obj,0,sizeof(obj)); if (p[o] & 0x08) /* GPOP data used */ @@ -1511,7 +1495,7 @@ void eval_l25() } } - if (boxed || transpmode) { + if (boxed || transpmode[boxed]) { FillBorder(transp); } else if(use_gui) { FillBorder(FullScrColor); @@ -1632,6 +1616,7 @@ int tuxtx_main(int pid, int page, int source) #endif use_gui = 1; boxed = 0; + oldboxed = boxed; //printf("to init tuxtxt\n");fflush(stdout); #if !TUXTXT_CFG_STANDALONE int initialized = tuxtxt_init(); @@ -1642,6 +1627,7 @@ int tuxtx_main(int pid, int page, int source) sub_pid = pid; use_gui = 0; boxed = 1; + oldboxed = boxed; } #endif @@ -1650,6 +1636,8 @@ int tuxtx_main(int pid, int page, int source) printf("TuxTxt %s\n", versioninfo); printf("for 32bpp framebuffer\n"); + fb = -1; + CFrameBuffer *fbp = CFrameBuffer::getInstance(); lfb = fbp->getFrameBufferPointer(); lbb = fbp->getBackBufferPointer(); @@ -1666,10 +1654,8 @@ int tuxtx_main(int pid, int page, int source) struct fb_var_screeninfo *var; var = fbp->getScreenInfo(); - /* this is actually the length of the screen in pixels */ - stride = fbp->getStride() / sizeof(fb_pixel_t); memcpy(&var_screeninfo, var, sizeof(struct fb_var_screeninfo)); - fix_screeninfo.line_length = var_screeninfo.xres * sizeof(fb_pixel_t); + /* set variable screeninfo for double buffering */ var_screeninfo.yoffset = 0; #if 0 @@ -1698,7 +1684,8 @@ int tuxtx_main(int pid, int page, int source) printf("[tuxtxt] screen is %dx%d at %dx%d border %d\n", ex-sx, ey-sy, sx, sy, tx); /* initialisations */ - transpmode = 0; + transpmode[0] = 0; + transpmode[1] = 0; if (Init(source) == 0) return 0; @@ -1707,12 +1694,12 @@ int tuxtx_main(int pid, int page, int source) pthread_create(&ttx_sub_thread, 0, reader_thread, (void *) NULL); return 1; } - //transpmode = 1; + /* main loop */ do { if (GetRCCode() == 1) { - if (transpmode == 2) /* TV mode */ + if (transpmode[boxed] == 2) /* TV mode */ { switch (RCCode) { @@ -1743,19 +1730,16 @@ int tuxtx_main(int pid, int page, int source) case RC_MINUS: case RC_DBOX: case RC_STANDBY: - transpmode = 1; /* switch to normal mode */ + transpmode[boxed] = 1; /* switch to normal mode */ SwitchTranspMode(); break; /* and evaluate key */ - case RC_TTTV: case RC_MUTE: /* regular toggle to transparent */ case RC_TEXT: break; case RC_HELP: /* switch to scart input and back */ - { continue; /* otherwise ignore exit key */ - } default: continue; /* ignore all other keys */ } @@ -1773,7 +1757,7 @@ int tuxtx_main(int pid, int page, int source) if (boxed) { subtitledelay++; - // display subtitledelay + // display subtitledelay PosY = StartY; char ns[10]; SetPosX(1); @@ -1784,14 +1768,14 @@ int tuxtx_main(int pid, int page, int source) RenderCharFB(ns[4],&atrtable[ATR_WB]); } else - GetNextSubPage(1); + GetNextSubPage(1); break; case RC_LEFT: if (boxed) { subtitledelay--; if (subtitledelay < 0) subtitledelay = 0; - // display subtitledelay + // display subtitledelay PosY = StartY; char ns[10]; SetPosX(1); @@ -1822,42 +1806,44 @@ int tuxtx_main(int pid, int page, int source) case RC_9: PageInput(CRCInput::getNumericValue(RCCode)); break; - case RC_RED: ColorKey(prev_100); break; - case RC_GREEN: ColorKey(prev_10); break; - case RC_YELLOW: ColorKey(next_10); break; - case RC_BLUE: ColorKey(next_100); break; + case RC_RED: ColorKey(prev_100); break; + case RC_GREEN: ColorKey(prev_10); break; + case RC_YELLOW: ColorKey(next_10); break; + case RC_BLUE: ColorKey(next_100); break; case RC_TTZOOM: - case RC_PLUS: SwitchZoomMode(); break; + case RC_PLUS: SwitchZoomMode(); break; case RC_SPLIT: - case RC_MINUS: SwitchScreenMode(-1);prevscreenmode = screenmode; break; + case RC_MINUS: SwitchScreenMode(-1); prevscreenmode[boxed] = screenmode[boxed]; break; case RC_TTTV: - case RC_MUTE: SwitchTranspMode(); break; + case RC_MUTE: SwitchTranspMode(); break; case RC_TEXT: - if(transpmode == 1) + if(transpmode[boxed] == 1) RCCode = RC_HOME; SwitchTranspMode(); break; - case RC_TTREVEAL: case RC_INFO: - case RC_HELP: SwitchHintMode(); break; - case RC_DBOX: ConfigMenu(0); break; + case RC_HELP: SwitchHintMode(); break; + case RC_DBOX: ConfigMenu(0); break; case RC_HOME: break; } } - /* update page or timestring and lcd */ + /* update page */ RenderPage(); #if HAVE_SPARK_HARDWARE fbp->blit(); #endif } while ((RCCode != RC_HOME) && (RCCode != RC_STANDBY)); /* if transparent mode was selected, remember the original mode */ - screenmode = prevscreenmode; + screenmode[boxed] = prevscreenmode[boxed]; /* exit */ CleanUp(); + if (fb >= 0) + close(fb); + #if 1 if ( initialized ) tuxtxt_close(); @@ -1866,7 +1852,7 @@ int tuxtx_main(int pid, int page, int source) fbp->setBorderColor(old_border_color); #endif - printf("Tuxtxt: plugin ended\n"); + printf("Tuxtxt: plugin ended\n"); return 1; } @@ -1896,9 +1882,10 @@ FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library plibrary, FT_Pointer /*r extern std::string ttx_font_file; static bool ft_init_done = false; static int oldfontheight = 0; -int Init(int source) +static int Init(int source) { int error, i; + unsigned char magazine; static std::string font_file; /* init data */ @@ -1906,21 +1893,20 @@ int Init(int source) //page_atrb[32] = transp<<4 | transp; inputcounter = 2; -#if TUXTXT_CFG_STANDALONE - unsigned char magazine; for (magazine = 1; magazine < 9; magazine++) { tuxtxt_cache.current_page [magazine] = -1; tuxtxt_cache.current_subpage [magazine] = -1; } +#if TUXTXT_CFG_STANDALONE /* init data */ - memset(&tuxtxt_cache.astCachetable, 0, sizeof(tuxtxt_cache.astCachetable)); - memset(&tuxtxt_cache.subpagetable, 0xFF, sizeof(tuxtxt_cache.subpagetable)); - memset(&tuxtxt_cache.astP29, 0, sizeof(tuxtxt_cache.astP29)); + memset(tuxtxt_cache.astCachetable, 0, sizeof(tuxtxt_cache.astCachetable)); + memset(tuxtxt_cache.subpagetable, 0xFF, sizeof(tuxtxt_cache.subpagetable)); + memset(tuxtxt_cache.astP29, 0, sizeof(tuxtxt_cache.astP29)); - memset(&tuxtxt_cache.basictop, 0, sizeof(tuxtxt_cache.basictop)); - memset(&tuxtxt_cache.adip, 0, sizeof(tuxtxt_cache.adip)); - memset(&tuxtxt_cache.flofpages, 0 , sizeof(tuxtxt_cache.flofpages)); + memset(tuxtxt_cache.basictop, 0, sizeof(tuxtxt_cache.basictop)); + memset(tuxtxt_cache.adip, 0, sizeof(tuxtxt_cache.adip)); + memset(tuxtxt_cache.flofpages, 0 , sizeof(tuxtxt_cache.flofpages)); tuxtxt_cache.maxadippg = -1; tuxtxt_cache.bttok = 0; maxhotlist = -1; @@ -1948,15 +1934,13 @@ int Init(int source) subtitledelay = 0; delaystarted = 0; - /* init lcd */ - UpdateLCD(); - /* create TUXTXTDIR if necessary */ if (!access(TUXTXTDIR, F_OK) == 0) mkdir(TUXTXTDIR, 0755); /* config defaults */ - screenmode = 0; + screenmode[0] = 0; + screenmode[1] = 0; screen_mode1 = 0; color_mode = 20; trans_mode = 6; @@ -2023,7 +2007,9 @@ int Init(int source) else if (1 == sscanf(line, "TTFShiftY %i", &ival)) TTFShiftY = ival; else if (1 == sscanf(line, "Screenmode %i", &ival)) - screenmode = ival; + screenmode[0] = ival; + else if (1 == sscanf(line, "ScreenmodeBoxed %i", &ival)) + screenmode[1] = ival; else if (1 == sscanf(line, "ShowFLOF %i", &ival)) showflof = ival & 1; else if (1 == sscanf(line, "Show39 %i", &ival)) @@ -2048,7 +2034,8 @@ int Init(int source) fclose(conf); } saveconfig = 0; - savedscreenmode = screenmode; + savedscreenmode[0] = screenmode[0]; + savedscreenmode[1] = screenmode[1]; national_subset_secondary = NAT_DEFAULT; fontwidth = 0; /* initialize at first setting */ @@ -2114,7 +2101,7 @@ int Init(int source) /* init fontlibrary */ if ((error = FT_Init_FreeType(&library))) { - printf("TuxTxt ", error); + printf("TuxTxt \n", error); return 0; } @@ -2143,7 +2130,7 @@ int Init(int source) typettf.height = (FT_UShort) 23; } - typettf.flags = FT_LOAD_MONOCHROME; + typettf.flags = FT_LOAD_RENDER; if ((error = FTC_Manager_LookupFace(manager, typettf.face_id, &face))) { @@ -2227,14 +2214,13 @@ int Init(int source) #else tuxtxt_start(tuxtxt_cache.vtxtpid, source); #endif + fcntl(rc, F_SETFL, O_NONBLOCK); gethotlist(); - if(use_gui) - SwitchScreenMode(screenmode); - else - SwitchScreenMode(0); + SwitchScreenMode(screenmode[use_gui ? 0 : 1]); - prevscreenmode = screenmode; + prevscreenmode[0] = screenmode[0]; + prevscreenmode[1] = screenmode[1]; printf("TuxTxt: init ok\n"); @@ -2246,12 +2232,14 @@ int Init(int source) * Cleanup * ******************************************************************************/ -void CleanUp() +static void CleanUp() { - int curscreenmode = screenmode; + int curscreenmode[2]; + curscreenmode[0] = screenmode[0]; + curscreenmode[1] = screenmode[1]; /* hide and close pig */ - if (screenmode) + if (screenmode[0]) SwitchScreenMode(0); /* turn off divided screen */ #if TUXTXT_CFG_STANDALONE @@ -2264,7 +2252,7 @@ void CleanUp() //tuxtxt_stop(); #endif - //memset(lfb,0, var_screeninfo.yres*fix_screeninfo.line_length); + //memset(lfb,0, var_screeninfo.yres*var_screeninfo.xres); //CFrameBuffer::getInstance()->paintBackground(); ClearFB(transp); @@ -2277,7 +2265,7 @@ void CleanUp() savehotlist(); /* save config */ - if (saveconfig || curscreenmode != savedscreenmode) + if (saveconfig || curscreenmode[0] != savedscreenmode[0] || curscreenmode[1] != savedscreenmode[1]) { if ((conf = fopen(TUXTXTCONF, "wt")) == 0) { @@ -2298,7 +2286,8 @@ void CleanUp() fprintf(conf, "TTFHeightFactor16 %d\n", TTFHeightFactor16); fprintf(conf, "TTFShiftX %d\n", TTFShiftX); fprintf(conf, "TTFShiftY %d\n", TTFShiftY); - fprintf(conf, "Screenmode %d\n", curscreenmode); + fprintf(conf, "Screenmode %d\n", curscreenmode[0]); + fprintf(conf, "ScreenmodeBoxed %d\n", curscreenmode[1]); fprintf(conf, "ShowFLOF %d\n", showflof); fprintf(conf, "Show39 %d\n", show39); fprintf(conf, "ShowLevel2p5 %d\n", showl25); @@ -2317,7 +2306,7 @@ void CleanUp() /****************************************************************************** * GetTeletextPIDs * ******************************************************************************/ -int GetTeletextPIDs() +static int GetTeletextPIDs() { #if HAVE_SPARK_HARDWARE if (isTtxEplayer) @@ -2528,16 +2517,13 @@ skip_pid: getpidsdone = 1; - RenderCharLCD(pids_found/10, 7, 44); - RenderCharLCD(pids_found%10, 19, 44); - return 1; } /****************************************************************************** * GetNationalSubset * ******************************************************************************/ -int GetNationalSubset(const char *cc) +static int GetNationalSubset(const char *cc) { if (memcmp(cc, "cze", 3) == 0 || memcmp(cc, "ces", 3) == 0 || memcmp(cc, "slo", 3) == 0 || memcmp(cc, "slk", 3) == 0) @@ -2591,7 +2577,7 @@ int GetNationalSubset(const char *cc) * ConfigMenu * ******************************************************************************/ #if TUXTXT_DEBUG -void charpage() +static void charpage() { PosY = StartY; PosX = StartX; @@ -2679,7 +2665,7 @@ void charpage() while (RCCode != RC_OK && RCCode != RC_HOME); } #endif -void Menu_HighlightLine(char *menu, int line, int high) +static void Menu_HighlightLine(char *menu, int line, int high) { char hilitline[] = "0111111111111111111111111111102"; int itext = Menu_Width*line; /* index start menuline */ @@ -2701,7 +2687,7 @@ void Menu_HighlightLine(char *menu, int line, int high) national_subset = national_subset_bak; } -void Menu_UpdateHotlist(char *menu, int hotindex, int menuitem) +static void Menu_UpdateHotlist(char *menu, int hotindex, int menuitem) { int i, j, k; tstPageAttr *attr; @@ -2750,7 +2736,7 @@ void Menu_UpdateHotlist(char *menu, int hotindex, int menuitem) Menu_HighlightLine(menu, MenuLine[M_HOT], (menuitem == M_HOT) ? 1 : 0); } -void Menu_Init(char *menu, int current_pid, int menuitem, int hotindex) +static void Menu_Init(char *menu, int current_pid, int menuitem, int hotindex) { int byte, line; int national_subset_bak = national_subset; @@ -2818,9 +2804,9 @@ void Menu_Init(char *menu, int current_pid, int menuitem, int hotindex) CFrameBuffer::getInstance()->blit(); } -void ConfigMenu(int Init) +static void ConfigMenu(int Init) { - int menuitem = M_Start; + int val, menuitem = M_Start; int current_pid = 0; int hotindex; int oldscreenmode, oldtrans = 0; @@ -2844,18 +2830,18 @@ void ConfigMenu(int Init) } /* reset to normal mode */ - if (zoommode) - zoommode = 0; + if (zoommode[0]) + zoommode[0] = 0; - if (transpmode) + if (transpmode[0]) { - oldtrans = transpmode; - transpmode = 0; + oldtrans = transpmode[0]; + transpmode[0] = 0; ClearBB(black); } - oldscreenmode = screenmode; - if (screenmode) + oldscreenmode = screenmode[0]; + if (screenmode[0]) SwitchScreenMode(0); /* turn off divided screen */ hotindex = getIndexOfPageInHotlist(); @@ -2874,6 +2860,10 @@ void ConfigMenu(int Init) clearbbcolor = black; Menu_Init(menu, current_pid, menuitem, hotindex); + /* set blocking mode */ + val = fcntl(rc, F_GETFL); + fcntl(rc, F_SETFL, val &~ O_NONBLOCK); + /* loop */ do { if (GetRCCode() == 1) @@ -3243,8 +3233,7 @@ void ConfigMenu(int Init) for (i1=hotindex; i1 maxhotlist) @@ -3346,10 +3335,11 @@ void ConfigMenu(int Init) current_service = current_pid; // RenderMessage(ShowServiceName); + fcntl(rc, F_SETFL, O_NONBLOCK); RCCode = -1; if (oldscreenmode) SwitchScreenMode(oldscreenmode); /* restore divided screen */ - transpmode = oldtrans; + transpmode[boxed] = oldtrans; return; } break; @@ -3403,24 +3393,27 @@ void ConfigMenu(int Init) } #if HAVE_SPARK_HARDWARE CopyBB2FB(); +#else + CFrameBuffer::getInstance()->blit(); #endif - UpdateLCD(); /* update number of cached pages */ } while ((RCCode != RC_HOME) && (RCCode != RC_DBOX) && (RCCode != RC_MUTE)); ClearBB(transp); CopyBB2FB(); + /* reset to nonblocking mode */ + fcntl(rc, F_SETFL, O_NONBLOCK); tuxtxt_cache.pageupdate = 1; RCCode = -1; if (oldscreenmode) SwitchScreenMode(oldscreenmode); /* restore divided screen */ - transpmode = oldtrans; + transpmode[boxed] = oldtrans; } /****************************************************************************** * PageInput * ******************************************************************************/ -void PageInput(int Number) +static void PageInput(int Number) { /* clear temp_page */ if (inputcounter == 2) @@ -3447,9 +3440,9 @@ void PageInput(int Number) } /* show pageinput */ - if (zoommode == 2) + if (zoommode[0] == 2) { - zoommode = 1; + zoommode[0] = 1; CopyBB2FB(); } @@ -3519,7 +3512,7 @@ void PageInput(int Number) * GetNextPageOne * ******************************************************************************/ -void GetNextPageOne(int up) +static void GetNextPageOne(int up) { /* disable subpage zapping */ tuxtxt_cache.zap_subpage_manual = 0; @@ -3542,8 +3535,8 @@ void GetNextPageOne(int up) /* update page */ if (tuxtxt_cache.page != lastpage) { - if (zoommode == 2) - zoommode = 1; + if (zoommode[boxed] == 2) + zoommode[boxed] = 1; tuxtxt_cache.subpage = subp; hintmode = 0; @@ -3557,7 +3550,7 @@ void GetNextPageOne(int up) /****************************************************************************** * GetNextSubPage * ******************************************************************************/ -void GetNextSubPage(int offset) +static void GetNextSubPage(int offset) { int loop; @@ -3579,8 +3572,8 @@ void GetNextSubPage(int offset) tuxtxt_cache.zap_subpage_manual = 1; /* update page */ - if (zoommode == 2) /* if zoomed to lower half */ - zoommode = 1; /* activate upper half */ + if (zoommode[boxed] == 2) /* if zoomed to lower half */ + zoommode[boxed] = 1; /* activate upper half */ tuxtxt_cache.subpage = loop; hintmode = 0; @@ -3600,12 +3593,12 @@ void GetNextSubPage(int offset) * ColorKey * ******************************************************************************/ -void ColorKey(int target) +static void ColorKey(int target) { if (!target) return; - if (zoommode == 2) - zoommode = 1; + if (zoommode[boxed] == 2) + zoommode[boxed] = 1; lastpage = tuxtxt_cache.page; tuxtxt_cache.page = target; tuxtxt_cache.subpage = tuxtxt_cache.subpagetable[tuxtxt_cache.page]; @@ -3621,10 +3614,10 @@ void ColorKey(int target) * PageCatching * ******************************************************************************/ -void PageCatching() +static void PageCatching() { - int byte; - int oldzoommode = zoommode; + int val, byte; + int oldzoommode = zoommode[boxed]; pagecatching = 1; @@ -3632,12 +3625,12 @@ void PageCatching() inputcounter = 2; /* show info line */ - zoommode = 0; + zoommode[boxed] = 0; PosX = StartX; PosY = StartY + 24*fontheight; for (byte = 0; byte < 40-nofirst; byte++) RenderCharFB(catchmenutext[menulanguage][byte], &atrtable[catchmenutext[menulanguage][byte+40] - '0' + ATR_CATCHMENU0]); - zoommode = oldzoommode; + zoommode[boxed] = oldzoommode; /* check for pagenumber(s) */ catch_row = 1; @@ -3653,6 +3646,10 @@ void PageCatching() return; } + /* set blocking mode */ + val = fcntl(rc, F_GETFL); + fcntl(rc, F_SETFL, val &~ O_NONBLOCK); + /* loop */ do { GetRCCode(); @@ -3691,6 +3688,7 @@ void PageCatching() case RC_HOME: case RC_HELP: case RC_MUTE: + fcntl(rc, F_SETFL, O_NONBLOCK); tuxtxt_cache.pageupdate = 1; pagecatching = 0; RCCode = -1; @@ -3698,13 +3696,14 @@ void PageCatching() } #if HAVE_SPARK_HARDWARE CopyBB2FB(); +#else + CFrameBuffer::getInstance()->blit(); #endif - UpdateLCD(); } while (RCCode != RC_OK); /* set new page */ - if (zoommode == 2) - zoommode = 1; + if (zoommode[boxed] == 2) + zoommode[boxed] = 1; lastpage = tuxtxt_cache.page; tuxtxt_cache.page = catched_page; @@ -3717,13 +3716,16 @@ void PageCatching() tuxtxt_cache.subpage = subp; else tuxtxt_cache.subpage = 0; + + /* reset to nonblocking mode */ + fcntl(rc, F_SETFL, O_NONBLOCK); } /****************************************************************************** * CatchNextPage * ******************************************************************************/ -void CatchNextPage(int firstlineinc, int inc) +static void CatchNextPage(int firstlineinc, int inc) { int tmp_page, allowwrap = 1; /* allow first wrap around */ @@ -3823,12 +3825,12 @@ void CatchNextPage(int firstlineinc, int inc) * RenderCatchedPage * ******************************************************************************/ -void RenderCatchedPage() +static void RenderCatchedPage() { int zoom = 0; /* handle zoom */ - if (zoommode) + if (zoommode[boxed]) zoom = 1<<10; if (pc_old_row || pc_old_col) /* not at first call */ @@ -3836,7 +3838,7 @@ void RenderCatchedPage() /* restore pagenumber */ SetPosX(pc_old_col); - if (zoommode == 2) + if (zoommode[boxed] == 2) PosY = StartY + (pc_old_row-12)*fontheight*((zoom>>10)+1); else PosY = StartY + pc_old_row*fontheight*((zoom>>10)+1); @@ -3850,24 +3852,23 @@ void RenderCatchedPage() pc_old_col = catch_col; /* mark pagenumber */ - if (zoommode == 1 && catch_row > 11) + if (zoommode[boxed] == 1 && catch_row > 11) { - zoommode = 2; + zoommode[boxed] = 2; #if !HAVE_SPARK_HARDWARE CopyBB2FB(); #endif } - else if (zoommode == 2 && catch_row < 12) + else if (zoommode[boxed] == 2 && catch_row < 12) { - zoommode = 1; + zoommode[boxed] = 1; #if !HAVE_SPARK_HARDWARE CopyBB2FB(); #endif } SetPosX(catch_col); - - if (zoommode == 2) + if (zoommode[boxed] == 2) PosY = StartY + (catch_row-12)*fontheight*((zoom>>10)+1); else PosY = StartY + catch_row*fontheight*((zoom>>10)+1); @@ -3894,18 +3895,18 @@ void RenderCatchedPage() * SwitchZoomMode * ******************************************************************************/ -void SwitchZoomMode() +static void SwitchZoomMode() { if (tuxtxt_cache.subpagetable[tuxtxt_cache.page] != 0xFF) { /* toggle mode */ - zoommode++; + zoommode[boxed]++; - if (zoommode == 3) - zoommode = 0; + if (zoommode[boxed] == 3) + zoommode[boxed] = 0; #if TUXTXT_DEBUG - printf("TuxTxt \n", zoommode); + printf("TuxTxt \n", zoommode[boxed], boxed); #endif /* update page */ tuxtxt_cache.pageupdate = 1; /* FIXME */ @@ -3916,44 +3917,48 @@ void SwitchZoomMode() * SwitchScreenMode * ******************************************************************************/ -void SwitchScreenMode(int newscreenmode) +static void SwitchScreenMode(int newscreenmode) { //struct v4l2_format format; /* reset transparency mode */ - if (transpmode) - transpmode = 0; + if (boxed) { + ClearFB(transp); + videoDecoder->Pig(-1, -1, -1, -1); + } + if (transpmode[boxed]) + transpmode[boxed] = 0; if (newscreenmode < 0) /* toggle mode */ - screenmode++; + screenmode[boxed]++; else /* set directly */ - screenmode = newscreenmode; + screenmode[boxed] = newscreenmode; - if ((screenmode > 2) || (screenmode < 0)) - screenmode = 0; + if ((screenmode[boxed] > 2) || (screenmode[boxed] < 0)) + screenmode[boxed] = 0; #if TUXTXT_DEBUG - printf("TuxTxt \n", screenmode); + printf("TuxTxt \n", (int)screenmode); #endif /* update page */ tuxtxt_cache.pageupdate = 1; /* clear back buffer */ - clearbbcolor = screenmode?transp:static_cast(FullScrColor); + clearbbcolor = screenmode[boxed]?transp:static_cast(FullScrColor); if(use_gui) ClearBB(clearbbcolor); /* set mode */ - if (screenmode) /* split */ + if (screenmode[boxed]) /* split */ { ClearFB(clearbbcolor); int fw, tx, ty, tw, th; - if (screenmode==1) /* split with topmenu */ + if (screenmode[boxed]==1) /* split with topmenu */ { int x = screen_x; int w = screen_w; @@ -4028,42 +4033,55 @@ void SwitchScreenMode(int newscreenmode) displaywidth= (ex-sx); StartX = sx; //+ (ex-sx - 40*fontwidth) / 2; /* center screen */ } + if (boxed) { + ClearBB(transp); + StartX = (screen_w - displaywidth) / 2; + } } /****************************************************************************** * SwitchTranspMode * ******************************************************************************/ -void SwitchTranspMode() +static void SwitchTranspMode() { - if (screenmode) + if (screenmode[boxed]) { - prevscreenmode = screenmode; - SwitchScreenMode(0); /* turn off divided screen */ + prevscreenmode[boxed] = screenmode[boxed]; + if (boxed) + videoDecoder->Pig(-1, -1, -1, -1); + else + SwitchScreenMode(0); /* turn off divided screen */ } /* toggle mode */ -#if 0 // transparent first +#if 0 + // transparent first if (transpmode == 2) transpmode = 0; else transpmode++; /* backward to immediately switch to TV-screen */ #endif /* transpmode: 0 normal, 1 transparent, 2 off */ - transpmode ++; - if(transpmode > 2) - transpmode = 0; + transpmode[boxed]++; + if(transpmode[boxed] > 2) + transpmode[boxed] = 0; #if TUXTXT_DEBUG - printf("TuxTxt \n", transpmode); + printf("TuxTxt \n", (int)transpmode, (int)boxed); #endif /* set mode */ - if (!transpmode) /* normal text-only */ + if (boxed && !transpmode[boxed]) + { + ClearBB(transp); + tuxtxt_cache.pageupdate = 1; + } + else if (!transpmode[boxed]) { ClearBB(FullScrColor); tuxtxt_cache.pageupdate = 1; } - else if (transpmode == 1) /* semi-transparent BG with FG text */ + else if (transpmode[boxed] == 1) /* semi-transparent BG with FG text */ { ClearBB(transp); tuxtxt_cache.pageupdate = 1; @@ -4079,7 +4097,7 @@ void SwitchTranspMode() * SwitchHintMode * ******************************************************************************/ -void SwitchHintMode() +static void SwitchHintMode() { /* toggle mode */ hintmode ^= 1; @@ -4098,7 +4116,7 @@ void SwitchHintMode() tuxtxt_cache.pageupdate = 1; } -void RenderDRCS( //FIX ME +static void RenderDRCS( //FIX ME unsigned char *s, /* pointer to char data, parity undecoded */ fb_pixel_t *d, /* pointer to frame buffer of top left pixel */ unsigned char *ax, /* array[0..12] of x-offsets, array[0..10] of y-offsets for each pixel */ @@ -4121,161 +4139,143 @@ void RenderDRCS( //FIX ME bit; bit >>= 1, x++) /* bit mask (MSB left), column counter */ { - int i, f1, f2; + unsigned int f1 = (c1 & bit) ? fgcolor : bgcolor; + unsigned int f2 = (c2 & bit) ? fgcolor : bgcolor; - f1 = (c1 & bit) ? fgcolor : bgcolor; - f2 = (c2 & bit) ? fgcolor : bgcolor; - - for (i = 0; i < h; i++) + for (int i = 0; i < h; i++) { if (ax[x+1] > ax[x]) { // memset(d + ax[x], f1, ax[x+1] - ax[x]); for (ltmp=0 ; ltmp <= (ax[x+1]-ax[x]); ltmp++) - *(d + ax[x] + ltmp) = bgra[f1]; + { + *(d + ax[x] + ltmp) = argb[f1]; + } } if (ax[x+7] > ax[x+6]) { // memset(d + ax[x+6], f2, ax[x+7] - ax[x+6]); /* 2nd byte 6 pixels to the right */ for (ltmp=0 ; ltmp <= (ax[x+7]-ax[x+6]); ltmp++) - *(d + ax[x+6] + ltmp) = bgra[f2]; + { + *(d + ax[x+6] + ltmp) = argb[f2]; + } + } - d += stride; + d += var_screeninfo.xres; } - d -= h * stride; + d -= h * var_screeninfo.xres; } - d += h * stride; + d += h * var_screeninfo.xres; } } -void DrawVLine(int x, int y, int l, fb_pixel_t color) +static void DrawVLine(int x, int y, int l, fb_pixel_t color) { - fb_pixel_t *p = getFBp(&y); - MARK_FB(x, y, 0, l); - p += x + y * stride; + fb_pixel_t *p = getFBp(y); + fb_pixel_t col = argb[color]; + p += x + y * var_screeninfo.xres; for ( ; l > 0 ; l--) { - *p = bgra[color]; - p += stride; + *p = col; + p += var_screeninfo.xres; } } -void DrawHLine(int x, int y, int l, fb_pixel_t color) +static void DrawHLine(int x, int y, int l, fb_pixel_t color) { - int ltmp; - fb_pixel_t *p = getFBp(&y); - MARK_FB(x, y, l, 0); - if (l > 0) + fb_pixel_t *p = getFBp(y); + fb_pixel_t col = argb[color]; + p += x + y * var_screeninfo.xres; + while (l > 0) { - for (ltmp=0; ltmp <= l; ltmp++) - *(p + x + ltmp + y * stride) = bgra[color]; + *p++ = col; + l--; } } -void FillRectMosaicSeparated(int x, int y, int w, int h, int fgcolor, int bgcolor, int set) +static void FillRectMosaicSeparated(int x, int y, int w, int h, int fgcolor, int bgcolor, int set) { FillRect(x, y, w, h, bgcolor); if (set) - { FillRect(x+1, y+1, w-2, h-2, fgcolor); - } } -void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, fb_pixel_t color) +static void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, fb_pixel_t color) { - fb_pixel_t *p = getFBp(&y0); - MARK_FB(x0, y0, l0, h); - p += x0 + y0 * stride; - - int xoffset, l; - int yoffset; - int ltmp; - - for (yoffset = 0; yoffset < h; yoffset++) - { - l = l0 + ((l1-l0) * yoffset + h/2) / h; - xoffset = (xoffset1 * yoffset + h/2) / h; + for (int yoffset = 0; yoffset < h; yoffset++) { + int l = l0 + ((l1-l0) * yoffset + h/2) / h; + int xoffset = (xoffset1 * yoffset + h/2) / h; if (l > 0) - { - for (ltmp=0; ltmp <= l; ltmp++) - *(p + xoffset + ltmp) = bgra[color]; - } - p += stride; + DrawHLine(xoffset + x0, yoffset + y0, l, color); } } -void FlipHorz(int x, int y, int w, int h) -{ - unsigned char *buf= new unsigned char[w*4]; - fb_pixel_t *p = getFBp(&y); - MARK_FB(x, y, w, h); - p += x + y * stride; - int w1,h1; - if(buf != NULL){ - for (h1 = 0 ; h1 < h ; h1++) - { - memmove(buf,p,w*4); - for (w1 = 0 ; w1 < w ; w1++) - { - memmove(p + w1,buf+((w-w1)*4)-4,4); - } - p += stride; +static void FlipHorz(int x, int y, int w, int h) +{ + uint32_t buf[w]; + fb_pixel_t *p = getFBp(y); + p += x + y * var_screeninfo.xres; + + for (int h1 = 0 ; h1 < h ; h1++) { + memcpy(buf, p, w * 4); + for (int w1 = 0 ; w1 < w ; w1++) { + if (w1 + x > (int) var_screeninfo.xres) + fprintf(stderr, "%s: x=%d out of bounds\n", __func__, w1 + x); + else + *(p + w1) = *(buf + w - w1 - 1); } - delete [] buf; + p += var_screeninfo.xres; } } -void FlipVert(int x, int y, int w, int h) +static void FlipVert(int x, int y, int w, int h) { - unsigned char *buf= new unsigned char[w*4]; + fb_pixel_t buf[w]; fb_pixel_t *p1, *p2; - fb_pixel_t *p = getFBp(&y); - MARK_FB(x, y, w, h); - p += x + y * stride; + fb_pixel_t *p = getFBp(y); + p += x + y * var_screeninfo.xres; - int h1; - if(buf != NULL){ - for (h1 = 0 ; h1 < h/2 ; h1++) - { - p1 = (p + (h1 * stride)); - p2 = (p + (h - (h1 + 1)) * stride); - memmove(buf,p1,w*4); - memmove(p1,p2,w*4); - memmove(p2,buf,w*4); - } - delete [] buf; + w *= 4; + + for (int h1 = 0 ; h1 < h/2 ; h1++) { + p1 = p+(h1*var_screeninfo.xres); + p2 = p+(h-(h1+1))*var_screeninfo.xres; + + memmove(buf, p1, w); + memmove(p1, p2, w); + memmove(p2, buf, w); } } -int ShapeCoord(int param, int curfontwidth, int curfontheight) +static int ShapeCoord(int param, int curfontwidth, int curfontheight) { switch (param) { - case S_W13: - return curfontwidth/3; - case S_W12: - return curfontwidth/2; - case S_W23: - return curfontwidth*2/3; - case S_W11: - return curfontwidth; - case S_WM3: - return curfontwidth-3; - case S_H13: - return curfontheight/3; - case S_H12: - return curfontheight/2; - case S_H23: - return curfontheight*2/3; - case S_H11: - return curfontheight; - default: - return param; + case S_W13: + return curfontwidth/3; + case S_W12: + return curfontwidth/2; + case S_W23: + return curfontwidth*2/3; + case S_W11: + return curfontwidth; + case S_WM3: + return curfontwidth-3; + case S_H13: + return curfontheight/3; + case S_H12: + return curfontheight/2; + case S_H23: + return curfontheight*2/3; + case S_H11: + return curfontheight; + default: + return param; } } -void DrawShape(int x, int y, int shapenumber, int curfontwidth, int curfontheight, int fgcolor, int bgcolor, int clear) +static void DrawShape(int x, int y, int shapenumber, int curfontwidth, int curfontheight, int fgcolor, int bgcolor, int clear) { if (shapenumber < 0x20 || shapenumber > 0x7e || (shapenumber == 0x7e && clear)) return; @@ -4295,63 +4295,63 @@ void DrawShape(int x, int y, int shapenumber, int curfontwidth, int curfontheigh while (*p != S_END) switch (*p++) { - case S_FHL: - { - int offset = ShapeCoord(*p++, curfontwidth, curfontheight); - DrawHLine(x, y + offset, curfontwidth, fgcolor); - break; - } - case S_FVL: - { - int offset = ShapeCoord(*p++, curfontwidth, curfontheight); - DrawVLine(x + offset, y, fontheight, fgcolor); - break; - } - case S_FLH: - FlipHorz(x,y,curfontwidth, fontheight); - break; - case S_FLV: - FlipVert(x,y,curfontwidth, fontheight); - break; - case S_BOX: - { - int xo = ShapeCoord(*p++, curfontwidth, curfontheight); - int yo = ShapeCoord(*p++, curfontwidth, curfontheight); - int w = ShapeCoord(*p++, curfontwidth, curfontheight); - int h = ShapeCoord(*p++, curfontwidth, curfontheight); - FillRect(x + xo, y + yo, w, h, fgcolor); - break; - } - case S_TRA: - { - int x0 = ShapeCoord(*p++, curfontwidth, curfontheight); - int y0 = ShapeCoord(*p++, curfontwidth, curfontheight); - int l0 = ShapeCoord(*p++, curfontwidth, curfontheight); - int x1 = ShapeCoord(*p++, curfontwidth, curfontheight); - int y1 = ShapeCoord(*p++, curfontwidth, curfontheight); - int l1 = ShapeCoord(*p++, curfontwidth, curfontheight); - FillTrapez(x + x0, y + y0, l0, x1-x0, y1-y0, l1, fgcolor); - break; - } - case S_BTR: - { - int x0 = ShapeCoord(*p++, curfontwidth, curfontheight); - int y0 = ShapeCoord(*p++, curfontwidth, curfontheight); - int l0 = ShapeCoord(*p++, curfontwidth, curfontheight); - int x1 = ShapeCoord(*p++, curfontwidth, curfontheight); - int y1 = ShapeCoord(*p++, curfontwidth, curfontheight); - int l1 = ShapeCoord(*p++, curfontwidth, curfontheight); - FillTrapez(x + x0, y + y0, l0, x1-x0, y1-y0, l1, bgcolor); - break; - } - case S_LNK: - { - DrawShape(x, y, ShapeCoord(*p, curfontwidth, curfontheight), curfontwidth, curfontheight, fgcolor, bgcolor, 0); - //p = aShapes[ShapeCoord(*p, curfontwidth, curfontheight) - 0x20]; - break; - } - default: - break; + case S_FHL: + { + int offset = ShapeCoord(*p++, curfontwidth, curfontheight); + DrawHLine(x, y + offset, curfontwidth, fgcolor); + break; + } + case S_FVL: + { + int offset = ShapeCoord(*p++, curfontwidth, curfontheight); + DrawVLine(x + offset, y, fontheight, fgcolor); + break; + } + case S_FLH: + FlipHorz(x,y,curfontwidth, fontheight); + break; + case S_FLV: + FlipVert(x,y,curfontwidth, fontheight); + break; + case S_BOX: + { + int xo = ShapeCoord(*p++, curfontwidth, curfontheight); + int yo = ShapeCoord(*p++, curfontwidth, curfontheight); + int w = ShapeCoord(*p++, curfontwidth, curfontheight); + int h = ShapeCoord(*p++, curfontwidth, curfontheight); + FillRect(x + xo, y + yo, w, h, fgcolor); + break; + } + case S_TRA: + { + int x0 = ShapeCoord(*p++, curfontwidth, curfontheight); + int y0 = ShapeCoord(*p++, curfontwidth, curfontheight); + int l0 = ShapeCoord(*p++, curfontwidth, curfontheight); + int x1 = ShapeCoord(*p++, curfontwidth, curfontheight); + int y1 = ShapeCoord(*p++, curfontwidth, curfontheight); + int l1 = ShapeCoord(*p++, curfontwidth, curfontheight); + FillTrapez(x + x0, y + y0, l0, x1-x0, y1-y0, l1, fgcolor); + break; + } + case S_BTR: + { + int x0 = ShapeCoord(*p++, curfontwidth, curfontheight); + int y0 = ShapeCoord(*p++, curfontwidth, curfontheight); + int l0 = ShapeCoord(*p++, curfontwidth, curfontheight); + int x1 = ShapeCoord(*p++, curfontwidth, curfontheight); + int y1 = ShapeCoord(*p++, curfontwidth, curfontheight); + int l1 = ShapeCoord(*p++, curfontwidth, curfontheight); + FillTrapez(x + x0, y + y0, l0, x1-x0, y1-y0, l1, bgcolor); + break; + } + case S_LNK: + { + DrawShape(x, y, ShapeCoord(*p, curfontwidth, curfontheight), curfontwidth, curfontheight, fgcolor, bgcolor, 0); + //p = aShapes[ShapeCoord(*p, curfontwidth, curfontheight) - 0x20]; + break; + } + default: + break; } } @@ -4359,8 +4359,64 @@ void DrawShape(int x, int y, int shapenumber, int curfontwidth, int curfontheigh /****************************************************************************** * RenderChar * ******************************************************************************/ +struct colors_struct +{ + uint32_t fgcolor, bgcolor; + uint32_t colors[256]; +}; -void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) +#define COLORS_LRU_SIZE 16 +static struct colors_struct *colors_lru_array[COLORS_LRU_SIZE] = { NULL }; + +static uint32_t *lookup_colors(uint32_t fgcolor, uint32_t bgcolor) +{ + struct colors_struct *cs; + int i = 0; + for (i = 0; i < COLORS_LRU_SIZE; i++) + if (colors_lru_array[i] && colors_lru_array[i]->fgcolor == fgcolor && colors_lru_array[i]->bgcolor == bgcolor) { + cs = colors_lru_array[i]; + for (int j = i; j > 0; j--) + colors_lru_array[j] = colors_lru_array[j - 1]; + colors_lru_array[0] = cs; + return cs->colors; + } + i--; + cs = colors_lru_array[i]; + if (!cs) + cs = (struct colors_struct *) calloc(1, sizeof(struct colors_struct)); + for (int j = i; j > 0; j--) + colors_lru_array[j] = colors_lru_array[j - 1]; + cs->fgcolor = fgcolor; + cs->bgcolor = bgcolor; + + int ro = var_screeninfo.red.offset; + int go = var_screeninfo.green.offset; + int bo = var_screeninfo.blue.offset; + int to = var_screeninfo.transp.offset; + int rm = (1 << var_screeninfo.red.length) - 1; + int gm = (1 << var_screeninfo.green.length) - 1; + int bm = (1 << var_screeninfo.blue.length) - 1; + int tm = (1 << var_screeninfo.transp.length) - 1; + int fgr = ((int)fgcolor >> ro) & rm; + int fgg = ((int)fgcolor >> go) & gm; + int fgb = ((int)fgcolor >> bo) & bm; + int fgt = ((int)fgcolor >> to) & tm; + int deltar = (((int)bgcolor >> ro) & rm) - fgr; + int deltag = (((int)bgcolor >> go) & gm) - fgg; + int deltab = (((int)bgcolor >> bo) & bm) - fgb; + int deltat = (((int)bgcolor >> to) & tm) - fgt; + for (i = 0; i < 256; i++) + cs->colors[255 - i] = + (((fgr + deltar * i / 255) & rm) << ro) | + (((fgg + deltag * i / 255) & gm) << go) | + (((fgb + deltab * i / 255) & bm) << bo) | + (((fgt + deltat * i / 255) & tm) << to); + + colors_lru_array[0] = cs; + return cs->colors; +} + +static void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) { int Row, Pitch, Bit; int error, glyph; @@ -4440,7 +4496,7 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) Attribute->bg = t; } fgcolor = Attribute->fg; - if (transpmode == 1 && PosY < StartY + 24*fontheight) + if (transpmode[boxed] == 1 && PosY < StartY + 24*fontheight) { if (fgcolor == transp) /* outside boxed elements (subtitles, news) completely transparent */ bgcolor = transp; @@ -4495,9 +4551,8 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) { int x,y,f,c; y = yoffset; - fb_pixel_t *p = getFBp(&y); - MARK_FB(PosX, PosY, curfontwidth, fontheight); - p += PosX + PosY * stride; + fb_pixel_t *p = getFBp(y); + p += PosX + PosY * var_screeninfo.xres; for (y=0; ycharset == C_G2 && Char >= 0x20 && Char <= 0x7F) { if (national_subset_local == NAT_GR) @@ -4731,7 +4787,8 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) } if (Char <= 0x20) { -#if 0//TUXTXT_DEBUG +#if 0 +//TUXTXT_DEBUG printf("TuxTxt found control char: %x \"%c\" \n", Char, Char); #endif FillRect(PosX, PosY + yoffset, curfontwidth, factor*fontheight, bgcolor); @@ -4742,7 +4799,8 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) if (!(glyph = FT_Get_Char_Index(face, Char))) { -#if 1// TUXTXT_DEBUG +#if 1 +// TUXTXT_DEBUG printf("TuxTxt c%x a%x g%x w%d h%d x%d y%d\n", error, Char, (int) Attribute, glyph, curfontwidth, fontheight, PosX, PosY); #endif - FillRect(PosX, PosY + yoffset, curfontwidth, fontheight, bgcolor); + FillRect(PosX, PosY + yoffset, curfontwidth, factor*fontheight, bgcolor); PosX += curfontwidth; return; } /* render char */ sbitbuffer = sbit->buffer; - char localbuffer[1000]; // should be enough to store one character-bitmap... + char localbuffer[8000]; // should be enough to store one character-bitmap... // add diacritical marks if (Attribute->diacrit) { @@ -4802,9 +4860,8 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) { for (Pitch = 0; Pitch < sbit->pitch; Pitch++) { - if (sbit_diacrit->pitch > Pitch && sbit_diacrit->height > Row) - if((sbit_diacrit->pitch*sbit_diacrit->height) > (Row*sbit->pitch+Pitch)) - sbitbuffer[Row*sbit->pitch+Pitch] |= sbit_diacrit->buffer[Row*sbit->pitch+Pitch]; + if (sbit_diacrit->pitch > Pitch && sbit_diacrit->height > Row && sbitbuffer[Row*sbit->pitch+Pitch] < sbit_diacrit->buffer[Row*sbit->pitch+Pitch]) + sbitbuffer[Row*sbit->pitch+Pitch] = sbit_diacrit->buffer[Row*sbit->pitch+Pitch]; } } } @@ -4821,50 +4878,50 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) sbit->height = fontheight - ascender + sbit->top - TTFShiftY; /* limit char height to defined/calculated fontheight */ int y = yoffset; - p = getFBp(&y); - p += PosX + (PosY + Row) * stride; /* running pointer into framebuffer */ + p = getFBp(y); + p += PosX + (PosY + Row) * var_screeninfo.xres; /* running pointer into framebuffer */ + + uint32_t *colors = lookup_colors(argb[fgcolor], argb[bgcolor]); for (Row = sbit->height; Row; Row--) /* row counts up, but down may be a little faster :) */ { int pixtodo = (usettf ? sbit->width : curfontwidth); fb_pixel_t *pstart = p; + fb_pixel_t bgcol = argb[bgcolor]; for (Bit = xfactor * (sbit->left + TTFShiftX); Bit > 0; Bit--) /* fill left margin */ { for (f = factor-1; f >= 0; f--) - *(p + f * stride) = bgra[bgcolor]; + *(p + f*var_screeninfo.xres) = bgcol; p++; if (!usettf) pixtodo--; } - for (Pitch = sbit->pitch; Pitch; Pitch--) + for (Pitch = sbit->width; Pitch; Pitch--) { - for (Bit = 0x80; Bit; Bit >>= 1) + uint32_t color; + + if (--pixtodo < 0) + break; + + if (*sbitbuffer) /* set -> foreground */ + color = colors[*sbitbuffer]; + else /* not set -> background */ + color = argb[bgcolor]; + + for (f = factor-1; f >= 0; f--) + *(p + f*var_screeninfo.xres) = color; + p++; + + if (xfactor > 1) /* double width */ { - fb_pixel_t color; - - if (--pixtodo < 0) - break; - - if (*sbitbuffer & Bit) /* bit set -> foreground */ - color = fgcolor; - else /* bit not set -> background */ - color = bgcolor; - for (f = factor-1; f >= 0; f--) - *(p + f * stride) = bgra[color]; + *(p + f*var_screeninfo.xres) = color; p++; - if (xfactor > 1) /* double width */ - { - for (f = factor-1; f >= 0; f--) - *(p + f * stride) = bgra[color]; - p++; - - if (!usettf) - pixtodo--; - } + if (!usettf) + pixtodo--; } sbitbuffer++; } @@ -4872,11 +4929,11 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) Bit > 0; Bit--) /* fill rest of char width */ { for (f = factor-1; f >= 0; f--) - *(p + f * stride) = bgra[bgcolor]; + *(p + f*var_screeninfo.xres) = argb[bgcolor]; p++; } - p = pstart + factor * stride; + p = pstart + factor*var_screeninfo.xres; } Row = ascender - sbit->top + sbit->height + TTFShiftY; @@ -4891,13 +4948,13 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) * RenderCharFB * ******************************************************************************/ -void RenderCharFB(int Char, tstPageAttr *Attribute) +static void RenderCharFB(int Char, tstPageAttr *Attribute) { #if HAVE_SPARK_HARDWARE - if (zoommode != 2) + if (zoommode[boxed] != 2) RenderCharBB(Char, Attribute); #else - RenderChar(Char, Attribute, zoommode, var_screeninfo.yoffset); + RenderChar(Char, Attribute, zoommode[boxed], var_screeninfo.yoffset); #endif } @@ -4905,52 +4962,16 @@ void RenderCharFB(int Char, tstPageAttr *Attribute) * RenderCharBB * ******************************************************************************/ -void RenderCharBB(int Char, tstPageAttr *Attribute) +static void RenderCharBB(int Char, tstPageAttr *Attribute) { RenderChar(Char, Attribute, 0, var_screeninfo.yres-var_screeninfo.yoffset); } -/****************************************************************************** - * RenderCharLCD * - ******************************************************************************/ - -void RenderCharLCD(int /*Digit*/, int /*XPos*/, int /*YPos*/) -{ -#if 0 - int x, y; - - /* render digit to lcd backbuffer */ - for (y = 0; y < 15; y++) - { - for (x = 0; x < 10; x++) - { - if (lcd_digits[Digit*15*10 + x + y*10]) - lcd_backbuffer[XPos + x + ((YPos+y)/8)*120] |= 1 << ((YPos+y)%8); - else - lcd_backbuffer[XPos + x + ((YPos+y)/8)*120] &= ~(1 << ((YPos+y)%8)); - } - } -#endif -} - -#if 0 -void RenderCharLCDsmall(int Char, int XPos, int YPos) -{ - int old_width = fontwidth; - int old_height = fontheight; - setfontwidth(fontwidth_small_lcd); - typettf.font.pix_height = fontheight = fontwidth_small_lcd; - RenderChar(Char, 0, 0, -(YPos<<8 | XPos)); - setfontwidth(old_width); - typettf.font.pix_height = fontheight = old_height; -} -#endif - /****************************************************************************** * RenderMessage * ******************************************************************************/ -void RenderMessage(int Message) +static void RenderMessage(int Message) { int byte; int fbcolor, imenuatr; @@ -4974,7 +4995,7 @@ void RenderMessage(int Message) memmove(&message_1[24], versioninfo, 4); /* reset zoom */ - zoommode = 0; + zoommode[boxed] = 0; /* set colors */ fbcolor = transp; @@ -5060,7 +5081,7 @@ void RenderMessage(int Message) * RenderPage * ******************************************************************************/ -void DoFlashing(int startrow) +static void DoFlashing(int startrow) { int row, col; /* get national subset */ @@ -5079,7 +5100,7 @@ void DoFlashing(int startrow) int srow = startrow; int erow = 24; int factor=1; - switch (zoommode) + switch (zoommode[boxed]) { case 1: erow = 12; factor=2;break; case 2: srow = 12; factor=2;break; @@ -5165,18 +5186,17 @@ void DoFlashing(int startrow) } #if HAVE_SPARK_HARDWARE CopyBB2FB(); +#else + CFrameBuffer::getInstance()->blit(); #endif } -void RenderPage() +static void RenderPage() { int row, col, byte, startrow = 0;; int national_subset_bak = national_subset; - /* update lcd */ - UpdateLCD(); - - if (transpmode != 2 && delaystarted) + if (transpmode[boxed] != 2 && delaystarted) { struct timeval tv; gettimeofday(&tv,NULL); @@ -5184,9 +5204,8 @@ void RenderPage() return; } - /* update page or timestring */ - if (transpmode != 2 && tuxtxt_cache.pageupdate && tuxtxt_cache.page_receiving != tuxtxt_cache.page && inputcounter == 2) + if (transpmode[boxed] != 2 && tuxtxt_cache.pageupdate && tuxtxt_cache.page_receiving != tuxtxt_cache.page && inputcounter == 2) { if (boxed && subtitledelay) { @@ -5210,15 +5229,9 @@ void RenderPage() else startrow = 1; - if (boxed) - { - if (screenmode != 0) - SwitchScreenMode(0); /* turn off divided screen */ - } - else - { - if (screenmode != prevscreenmode && !transpmode) - SwitchScreenMode(prevscreenmode); + if (oldboxed != boxed) { + SwitchScreenMode(screenmode[boxed]); + oldboxed = boxed; } /* display first column? */ @@ -5239,7 +5252,7 @@ void RenderPage() fontwidth_topmenusmall = (TVENDX - TOPMENUSTARTX) / TOPMENUCHARS; //fontwidth_small = (TV169FULLSTARTX-sx) / (40-nofirst); fontwidth_small = (screen_w / 2) / (40 - nofirst); - switch(screenmode) + switch(screenmode[boxed]) { case 0: case 1: setfontwidth(fontwidth_normal); @@ -5249,7 +5262,7 @@ void RenderPage() displaywidth = screen_w / 2; break; } - if (transpmode || (boxed && !screenmode)) + if (transpmode[boxed] || boxed) { FillBorder(transp);//ClearBB(transp); clearbbcolor = transp; @@ -5293,16 +5306,18 @@ void RenderPage() /* update framebuffer */ CopyBB2FB(); } - else if (use_gui && transpmode != 2) + else if (use_gui && transpmode[boxed] != 2) { - if (zoommode != 2) +#if !HAVE_SPARK_HARDWARE + if (zoommode[boxed] != 2) +#endif { PosY = StartY; if (tuxtxt_cache.subpagetable[tuxtxt_cache.page] == 0xff) { page_atrb[32].fg = yellow; page_atrb[32].bg = menu1; - int showpage = tuxtxt_cache.page_receiving < 0 ? 0 : tuxtxt_cache.page_receiving; + int showpage = tuxtxt_cache.page_receiving; int showsubpage = tuxtxt_cache.subpagetable[showpage]; if (showsubpage!=0xff) { @@ -5360,7 +5375,7 @@ void RenderPage() DoFlashing(startrow); national_subset = national_subset_bak; } - else if (transpmode == 2 && tuxtxt_cache.pageupdate == 2) + else if (transpmode[boxed] == 2 && tuxtxt_cache.pageupdate == 2) { #if TUXTXT_DEBUG printf("received Update flag for page %03x\n",tuxtxt_cache.page); @@ -5377,6 +5392,8 @@ void RenderPage() RenderCharFB(ns[2],&atrtable[ATR_WB]); #if HAVE_SPARK_HARDWARE CopyBB2FB(); +#else + CFrameBuffer::getInstance()->blit(); #endif tuxtxt_cache.pageupdate=0; @@ -5387,7 +5404,7 @@ void RenderPage() * CreateLine25 * ******************************************************************************/ -void showlink(int column, int linkpage) +static void showlink(int column, int linkpage) { unsigned char *p, line[] = " >??? "; int oldfontwidth = fontwidth; @@ -5437,7 +5454,7 @@ void showlink(int column, int linkpage) } } -void CreateLine25() +static void CreateLine25() { if (!tuxtxt_cache.bttok) @@ -5486,7 +5503,7 @@ void CreateLine25() } if (tuxtxt_cache.bttok && - screenmode == 1) /* TOP-Info present, divided screen -> create TOP overview */ + !boxed && screenmode[0] == 1) /* TOP-Info present, divided screen -> create TOP overview */ { char line[TOPMENUCHARS]; int current; @@ -5591,43 +5608,40 @@ void CreateLine25() * CopyBB2FB * ******************************************************************************/ -void CopyBB2FB() +static void CopyBB2FB() { +#if HAVE_SPARK_HARDWARE + int fillcolor, screenwidth; + CFrameBuffer *f = CFrameBuffer::getInstance(); +#else fb_pixel_t *src, *dst, *topsrc; int fillcolor, i, screenwidth, swtmp; -#if HAVE_SPARK_HARDWARE || HAVE_COOL_HARDWARE - CFrameBuffer *f = CFrameBuffer::getInstance(); #endif + if (transpmode[boxed]) + fillcolor = transp; + else + fillcolor = FullScrColor; /* line 25 */ if (!pagecatching && use_gui) CreateLine25(); /* copy backbuffer to framebuffer */ - if (!zoommode) + if (!zoommode[boxed]) { #if HAVE_SPARK_HARDWARE - f->blit2FB(lbb, var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, 0, true); -#elif HAVE_COOL_HARDWARE - f->fbCopyArea(var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, var_screeninfo.yres); + f->setBorderColor(argb[fillcolor]); + f->blitBPA2FB((unsigned char *)lbb, SURF_ARGB8888, var_screeninfo.xres, var_screeninfo.yres, + 0, 0, -1, -1, + -1, -1, -1, -1, true); #else - if ((uint32_t)stride > var_screeninfo.xres) { - fb_pixel_t *lfb_ = lfb; - fb_pixel_t *lbb_ = lbb; - for (uint32_t i1 = 0; i1 < var_screeninfo.yres; i1++) { - memcpy(lfb_, lbb_, var_screeninfo.xres * sizeof(fb_pixel_t)); - lfb_ += stride; - lbb_ += stride; - } - } - else - memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres); + memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres * sizeof(fb_pixel_t)); #endif /* adapt background of backbuffer if changed */ if (StartX > 0 && *lfb != *lbb) { - FillBorder(*lbb, true); -// ClearBB(*(lfb + var_screeninfo.xres * var_screeninfo.yoffset)); + FillBorder(*lbb); + //ClearBB(*(lfb + var_screeninfo.xres * var_screeninfo.yoffset)); } #if HAVE_SPARK_HARDWARE f->blit(); @@ -5635,247 +5649,102 @@ void CopyBB2FB() if (clearbbcolor >= 0) { -// ClearBB(clearbbcolor); + //ClearBB(clearbbcolor); clearbbcolor = -1; } return; } - src = topsrc = lbb + StartY * stride; - dst = lfb + StartY * stride; +#if !HAVE_SPARK_HARDWARE + src = topsrc = lbb + StartY * var_screeninfo.xres; + dst = lfb + StartY * var_screeninfo.xres; +#endif /* copy line25 in normal height */ if (!pagecatching ) - memmove(dst + (24 * fontheight) * stride, src + (24 * fontheight) * stride, stride * fontheight); - - if (transpmode) - fillcolor = transp; - else - fillcolor = FullScrColor; - - if (zoommode == 2) - src += 12 * fontheight * stride; +#if HAVE_SPARK_HARDWARE + f->blitBPA2FB((unsigned char *)lbb, SURF_ARGB8888, var_screeninfo.xres, var_screeninfo.yres, + 0, StartY + 24 * fontheight, var_screeninfo.xres, fontheight, + -1, -1, -1, -1, true); +#else + memmove(dst+(24*fontheight)*var_screeninfo.xres, src + (24*fontheight)*var_screeninfo.xres, var_screeninfo.xres*fontheight * sizeof(fb_pixel_t)); +#endif /* copy topmenu in normal height (since PIG also keeps dimensions) */ - if (screenmode == 1) + if (screenmode[boxed] == 1) { - screenwidth = ( TV43STARTX ); + screenwidth = TV43STARTX; #if HAVE_SPARK_HARDWARE int cx = var_screeninfo.xres - TV43STARTX; /* x start */ - int cw = TV43STARTX; /* width */ - int cy = StartY; - int ch = 24*fontheight; - f->blit2FB(lbb, cw, ch, cx, cy, cx, cy, true); + if (boxed) + cx = (screen_w - 40 * fontwidth) / 2; + + f->blitBPA2FB((unsigned char *)lbb, SURF_ARGB8888, var_screeninfo.xres, var_screeninfo.yres, + cx, StartY, var_screeninfo.xres - TV43STARTX, 24 * fontheight, + -1, -1, -1, -1, true); #else fb_pixel_t *topdst = dst; - size_t width = (ex - screenwidth) * sizeof(fb_pixel_t); + size_t width = ex * sizeof(fb_pixel_t) - screenwidth; topsrc += screenwidth; topdst += screenwidth; + for (i=0; i < 24*fontheight; i++) { memmove(topdst, topsrc, width); - topdst += stride; - topsrc += stride; + topdst += var_screeninfo.xres; + topsrc += var_screeninfo.xres; } #endif } - else if (screenmode == 2) - screenwidth = ( TV169FULLSTARTX ); + else if (screenmode[boxed] == 2) + screenwidth = TV169FULLSTARTX; else - screenwidth = stride; + screenwidth = var_screeninfo.xres; +#if HAVE_SPARK_HARDWARE + f->paintBox(0, 0, screenwidth, StartY, argb[fillcolor]); +#else for (i = StartY; i>0;i--) { for (swtmp=0; swtmp<=screenwidth; swtmp++) - *(dst - i * stride + swtmp) = bgra[fillcolor]; + { + *(dst - i*var_screeninfo.xres+swtmp) = argb[fillcolor]; + } } +#endif + +#if HAVE_SPARK_HARDWARE + f->blitBPA2FB((unsigned char *)lbb, SURF_ARGB8888, var_screeninfo.xres, var_screeninfo.yres, + 0, StartY + ((zoommode[boxed] == 2) ? 12 * fontheight : 0), screenwidth, 12 * fontheight, + 0, StartY, screenwidth, 24 * fontheight, true); +#else + if (zoommode[boxed] == 2) + src += 12*fontheight*var_screeninfo.xres; for (i = 12*fontheight; i; i--) { memmove(dst, src, screenwidth * sizeof(fb_pixel_t)); - dst += stride; + dst += var_screeninfo.xres; memmove(dst, src, screenwidth * sizeof(fb_pixel_t)); - dst += stride; - src += stride; + dst += var_screeninfo.xres; + src += var_screeninfo.xres; } +#endif +#if HAVE_SPARK_HARDWARE + f->paintBox(0, 25 * fontheight + StartY, screenwidth, StartY, argb[fillcolor]); +#else for (i = var_screeninfo.yres - StartY - 25*fontheight; i >= 0;i--) { for (swtmp=0; swtmp<= screenwidth;swtmp++) - *(dst + stride * (fontheight + i) + swtmp) = bgra[fillcolor]; + { + *(dst + var_screeninfo.xres*(fontheight+i)+swtmp) = argb[fillcolor]; + } } -#if HAVE_SPARK_HARDWARE - f->mark(0, 0, var_screeninfo.xres, var_screeninfo.yres); - f->blit(); #endif -} - -/****************************************************************************** - * UpdateLCD * - ******************************************************************************/ - -void UpdateLCD() -{ -#if 0 - static int init_lcd = 1, old_cached_pages = -1, old_page = -1, old_subpage = -1, old_subpage_max = -1, old_hintmode = -1; - int x, y, subpage_max = 0, update_lcd = 0; - - if (lcd == -1) return; // for Dreamboxes without LCD-Display (5xxx) - /* init or update lcd */ - if (init_lcd) - { - init_lcd = 0; - - for (y = 0; y < 64; y++) - { - int lcdbase = (y/8)*120; - int lcdmask = 1 << (y%8); - - for (x = 0; x < 120; ) - { - int rommask; - int rombyte = lcd_layout[x/8 + y*120/8]; - - for (rommask = 0x80; rommask; rommask >>= 1) - { - if (rombyte & rommask) - lcd_backbuffer[x + lcdbase] |= lcdmask; - else - lcd_backbuffer[x + lcdbase] &= ~lcdmask; - x++; - } - } - } - - write(lcd, &lcd_backbuffer, sizeof(lcd_backbuffer)); - - for (y = 16; y < 56; y += 8) /* clear rectangle in backbuffer */ - for (x = 1; x < 118; x++) - lcd_backbuffer[x + (y/8)*120] = 0; - - for (x = 3; x <= 116; x++) - lcd_backbuffer[x + (39/8)*120] |= 1 << (39%8); - - for (y = 42; y <= 60; y++) - lcd_backbuffer[35 + (y/8)*120] |= 1 << (y%8); - - for (y = 42; y <= 60; y++) - lcd_backbuffer[60 + (y/8)*120] |= 1 << (y%8); - - RenderCharLCD(10, 43, 20); - RenderCharLCD(11, 79, 20); - - return; - } - else - { - int p; - - if (inputcounter == 2) - p = tuxtxt_cache.page; - else - p = temp_page + (0xDD >> 4*(1-inputcounter)); /* partial pageinput (filled with spaces) */ - - /* page */ - if (old_page != p) - { - RenderCharLCD(p>>8, 7, 20); - RenderCharLCD((p&0x0F0)>>4, 19, 20); - RenderCharLCD(p&0x00F, 31, 20); - - old_page = p; - update_lcd = 1; - } - - /* current subpage */ - if (old_subpage != tuxtxt_cache.subpage) - { - if (!tuxtxt_cache.subpage) - { - RenderCharLCD(0, 55, 20); - RenderCharLCD(1, 67, 20); - } - else - { - if (tuxtxt_cache.subpage >= 0xFF) - tuxtxt_cache.subpage = 1; - else if (tuxtxt_cache.subpage > 99) - tuxtxt_cache.subpage = 0; - - RenderCharLCD(tuxtxt_cache.subpage>>4, 55, 20); - RenderCharLCD(tuxtxt_cache.subpage&0x0F, 67, 20); - } - - old_subpage = tuxtxt_cache.subpage; - update_lcd = 1; - } - - /* max subpage */ - for (x = 0; x <= 0x79; x++) - { - if (tuxtxt_cache.astCachetable[tuxtxt_cache.page][x]) - subpage_max = x; - } - - if (old_subpage_max != subpage_max) - { - if (!subpage_max) - { - RenderCharLCD(0, 91, 20); - RenderCharLCD(1, 103, 20); - } - else - { - RenderCharLCD(subpage_max>>4, 91, 20); - RenderCharLCD(subpage_max&0x0F, 103, 20); - } - - old_subpage_max = subpage_max; - update_lcd = 1; - } - - /* cachestatus */ - if (old_cached_pages != tuxtxt_cache.cached_pages) - { - #if 0 - int s; - int p = tuxtxt_cache.cached_pages; - for (s=107; s >= 107-4*fontwidth_small_lcd; s -= fontwidth_small_lcd) - { - int c = p % 10; - if (p) - RenderCharLCDsmall('0'+c, s, 44); - else - RenderCharLCDsmall(' ', s, 44); - p /= 10; - } - #else - RenderCharLCD(tuxtxt_cache.cached_pages/1000, 67, 44); - RenderCharLCD(tuxtxt_cache.cached_pages%1000/100, 79, 44); - RenderCharLCD(tuxtxt_cache.cached_pages%100/10, 91, 44); - RenderCharLCD(tuxtxt_cache.cached_pages%10, 103, 44); - #endif - - old_cached_pages = tuxtxt_cache.cached_pages; - update_lcd = 1; - } - - /* mode */ - if (old_hintmode != hintmode) - { - if (hintmode) - RenderCharLCD(12, 43, 44); - else - RenderCharLCD(13, 43, 44); - - old_hintmode = hintmode; - update_lcd = 1; - } - } - - if (update_lcd) - write(lcd, &lcd_backbuffer, sizeof(lcd_backbuffer)); +#if HAVE_SPARK_HARDWARE + f->blit(); #endif } @@ -5883,7 +5752,7 @@ void UpdateLCD() * DecodePage * ******************************************************************************/ -void DecodePage() +static void DecodePage() { int row, col; int hold, dhset; @@ -5919,7 +5788,7 @@ void DecodePage() /* modify header */ if (boxed) - memset(&page_char, ' ', 40); + memset(page_char, ' ', 40); else { memset(page_char, ' ', 8); @@ -6026,7 +5895,7 @@ void DecodePage() RenderDRCS( page_char + 20 * (DRCSCOLS * row + col + 2), lfb - + (StartY + fontheight + DRCSYSPC * row + var_screeninfo.yres - var_screeninfo.yoffset) * stride + + (StartY + fontheight + DRCSYSPC * row + var_screeninfo.yres - var_screeninfo.yoffset) * var_screeninfo.xres + (StartX + DRCSXSPC * col), ax, white, black); @@ -6036,14 +5905,14 @@ void DecodePage() } else { - int i; + int unsigned i; int h, parityerror = 0; for (i = 0; i < 8; i++) page_atrb[i] = atrtable[ATR_WB]; /* decode parity/hamming */ - for (i = 40; i < (int) sizeof(page_char); i++) + for (i = 40; i < sizeof(page_char); i++) { page_atrb[i] = atrtable[ATR_WB]; p = page_char + i; @@ -6396,7 +6265,7 @@ void DecodePage() /****************************************************************************** * GetRCCode * ******************************************************************************/ -int GetRCCode() +static int GetRCCode() { neutrino_msg_t msg; neutrino_msg_data_t data; diff --git a/lib/libtuxtxt/tuxtxt.h b/lib/libtuxtxt/tuxtxt.h index 305bc6a4b..0a544b7ac 100644 --- a/lib/libtuxtxt/tuxtxt.h +++ b/lib/libtuxtxt/tuxtxt.h @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -31,6 +32,12 @@ #include +#include + +#include +#include + +#include #include "tuxtxt_def.h" #include @@ -78,7 +85,6 @@ int fontheight, fontwidth, fontwidth_normal, fontwidth_small, fontwidth_topmenum int ymosaic[4]; int displaywidth; int tv_pip_y; -#define fontwidth_small_lcd 8 #define TV43STARTX (ex) #define TVENDX (screen_x + screen_w) //ex @@ -211,11 +217,10 @@ const char *ObjectType[] = #define NoServicesFound 3 /* framebuffer stuff */ -static fb_pixel_t *lfb = 0; -static fb_pixel_t *lbb = 0; +static fb_pixel_t *lfb = NULL; +static fb_pixel_t *lbb = NULL; struct fb_var_screeninfo var_screeninfo; struct fb_fix_screeninfo fix_screeninfo; -int stride; /* freetype stuff */ FT_Library library; @@ -557,12 +562,13 @@ char versioninfo[16]; int hotlist[10]; int maxhotlist; -int lcd; +int pig, rc, fb; int sx, ex, sy, ey; int PosX, PosY, StartX, StartY; int lastpage; int inputcounter; -int zoommode, screenmode, transpmode, hintmode, boxed, nofirst, savedscreenmode, showflof, show39, showl25, prevscreenmode; +int zoommode[2], screenmode[2], transpmode[2], hintmode, nofirst, savedscreenmode[2], showflof, show39, showl25, prevscreenmode[2]; +bool boxed, oldboxed; char dumpl25; int catch_row, catch_col, catched_page, pagecatching; int prev_100, prev_10, next_10, next_100; @@ -1196,7 +1202,6 @@ tstPageAttr atrtable[] = { white , menu1 , C_G0P, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0x3f} /* ATR_CATCHMENU1 a8 ¨ */ }; /* buffers */ -unsigned char lcd_backbuffer[120*64 / 8]; unsigned char page_char[40 * 25]; tstPageAttr page_atrb[40 * 25]; @@ -1213,8 +1218,18 @@ const unsigned short defaultcolors[] = /* 0x0bgr */ 0x420, 0x210, 0x420, 0x000, 0x000 }; -/* filled in setcolors() */ -fb_pixel_t bgra[SIZECOLTABLE]; +fb_pixel_t argb[] = { + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xff000000, 0xff000000, + 0xff000000, 0xff000000, 0xc0000000, 0x00000000, + 0x33000000 +}; /* old 8bit color table */ unsigned short rd0[] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0x00<<8, 0x00<<8, 0x00<<8, 0, 0 }; @@ -1367,362 +1382,37 @@ unsigned char *aShapes[] = aG3_70, aG3_71, aG3_72, aG3_73, aG3_74, aG3_75, aG3_76, aG3_77, aG3_78, aG3_79, aG3_7a, aG3_7b, aG3_7c, aG3_7d, aG3_7e }; -#if 0 -/* lcd layout */ -const char lcd_layout[] = -{ -#define ____ 0x0 -#define ___X 0x1 -#define __X_ 0x2 -#define __XX 0x3 -#define _X__ 0x4 -#define _X_X 0x5 -#define _XX_ 0x6 -#define _XXX 0x7 -#define X___ 0x8 -#define X__X 0x9 -#define X_X_ 0xA -#define X_XX 0xB -#define XX__ 0xC -#define XX_X 0xD -#define XXX_ 0xE -#define XXXX 0xF - -#define i <<4| - - ____ i _XXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXX_ i ____, - ___X i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i X___, - __XX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XX__ i ____,XXX_ i _X__,_XXX i __X_,__XX i X___,___X i XX__,X___ i XXX_,____ i _XXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XX__, - _XXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,X_XX i XXXX,_X_X i X_XX,X_X_ i XX_X,XX_X i _XXX,XXX_ i X_XX,_XXX i _X_X,XXXX i X_XX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXX_, - _XXX i XXXX,X___ i ____,____ i ____,____ i __XX,X_XX i XXXX,_X_X i X_XX,X_X_ i XX_X,XX_X i _XXX,XXX_ i X_XX,_XXX i _X_X,XXXX i X_XX,X___ i ____,____ i ____,____ i ___X,XXXX i XXX_, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,X_XX i XXXX,_X_X i X_XX,X_X_ i XX_X,XX_X i _XXX,XXX_ i X_XX,_XXX i _X_X,XXXX i X_XX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XX__ i XX__,XX_X i X_XX,X_X_ i XXXX,XX_X i X__X,X__X i X_XX,XXXX i _XX_,_XX_ i _XXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - XXXX i XX__,____ i ____,____ i ____,____ i __XX,XXX_ i XX_X,XX_X i X_XX,X_XX i _XXX,__XX i XX_X,X_XX i XX_X,XX__ i XXXX,_XX_ i XXXX,X___ i ____,____ i ____,____ i ____,__XX i XXXX, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXX_ i XX_X,XX_X i X_XX,X_X_ i XXXX,XX_X i XX_X,X_XX i X_XX,XXXX i _XXX,_XX_ i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXX_ i XX_X,XX_X i X_XX,X_X_ i XX_X,XX_X i XX_X,X_XX i X_XX,_XXX i _XXX,_XX_ i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - XXX_ i ____,____ i ____,____ i ____,____ i __XX,XXX_ i XX_X,XX_X i XXXX,X_X_ i XX_X,XX_X i XX_X,X_XX i X_XX,_XXX i _XXX,_XX_ i XXXX,X___ i ____,____ i ____,____ i ____,____ i _XXX, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXX_ i XX_X,XX_X i XXXX,X_X_ i XX_X,XX_X i XX_X,X_XX i X_XX,_XXX i _XXX,_XX_ i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i __XX,XXX_ i ____,_XXX i __X_,__XX i XXX_,_XXX i XX__,X___ i XXXX,X__X i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i XX__,_XXX i XXX_,__XX i ___X,XXXX i X___,XX__ i _XXX,XXX_ i __XX,____ i ___X,X___ i XXXX,XX__ i _XX_,__XX i XXXX,___X i XXXX,X___ i XX_X,XX__ i _XXX,XXX_ i __XX,XXXX i ___X, - X__X i __X_,X___ i ___X,_X__ i X_X_,____ i _X_X,__X_ i X___,___X i _X__,X___ i __X_,_X_X i ____,__X_ i X__X,_X__ i ____,X_X_ i ____,_X_X i __X_,__X_ i X___,___X i _X__,____ i X__X, - X__X i __X_,X___ i ___X,_X__ i X_X_,____ i _X_X,__X_ i X___,___X i _X__,X___ i __X_,_X_X i ____,__X_ i X__X,_X__ i ____,X_X_ i ____,_X_X i __X_,__X_ i X___,___X i _X__,____ i X__X, - X__X i __X_,X___ i ___X,_X__ i X_X_,____ i _X_X,__X_ i X___,___X i _X__,X___ i __X_,_X_X i ____,__X_ i X__X,_X__ i ____,X_X_ i ____,_X_X i __X_,__X_ i X___,___X i _X__,____ i X__X, - X__X i __X_,X__X i ___X,_X__ i X__X,X__X i X__X,__X_ i X__X,___X i _X__,X___ i __X_,_X_X i __XX,XX__ i X__X,_X__ i XXXX,__X_ i _X__,_X_X i __X_,__X_ i X__X,___X i _X__,XXXX i ___X, - X__X i __X_,X__X i ___X,_X__ i X___,X__X i ___X,__X_ i X___,___X i _X__,X___ i __X_,_X_X i ____,__X_ i X__X,_X__ i ____,X_X_ i ___X,X__X i __X_,__X_ i X__X,___X i _X__,X___ i X__X, - X__X i __X_,X__X i ___X,_X__ i X___,X__X i ___X,__X_ i X___,___X i _X__,X___ i __X_,_X_X i ____,__X_ i X__X,_X__ i ____,X_X_ i ____,_X_X i __X_,__X_ i X__X,___X i _X__,X___ i X__X, - X__X i __X_,X__X i ___X,_X__ i X___,X__X i ___X,__X_ i X__X,___X i _X__,XXXX i __X_,_X__ i XXX_,__X_ i X__X,_X__ i XXXX,__X_ i _X__,_X_X i __X_,__X_ i X__X,___X i _X__,X___ i X__X, - X__X i __X_,X__X i ___X,_X__ i X___,X__X i ___X,__X_ i X__X,___X i _X__,____ i X_X_,_X_X i ____,__X_ i X__X,_X__ i ____,X_X_ i _X__,_X_X i ____,__X_ i X__X,___X i _X__,____ i X__X, - X__X i __X_,X__X i ___X,_X__ i X___,X__X i ___X,__X_ i X__X,___X i _X__,____ i X_X_,_X_X i ____,__X_ i X__X,_X__ i ____,X_X_ i _X__,_X_X i ____,__X_ i X__X,___X i _X__,____ i X__X, - X___ i XX__,XXX_ i XXXX,__XX i ____,_XX_ i ____,XX__ i _XX_,XXX_ i __XX,XXXX i ___X,X___ i XXXX,XX__ i _XX_,__XX i XXXX,___X i X_XX,X___ i XXXX,XX__ i _XX_,XXX_ i __XX,XXXX i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,XXXX i XXXX,X___ i XXXX,XX__ i _XXX,XXXX i XX__,_XXX i XXX_,__XX i XXXX,___X i XXXX,X___ i ____,__XX i XXXX,___X i X___,XXXX i XX__,_XXX i XXX_,__XX i XXXX,____ i ___X, - X___ i ___X,____ i ____,_X_X i ____,__X_ i X___,____ i __X_,X___ i ___X,_X__ i ____,X_X_ i ____,_X__ i ____,_X__ i ____,X_X_ i _X_X,____ i __X_,X___ i ___X,_X__ i ____,X___ i ___X, - X___ i ___X,____ i ____,_X_X i ____,__X_ i X___,____ i __X_,X___ i ___X,_X__ i ____,X_X_ i ____,_X__ i ____,_X__ i ____,X_X_ i _X_X,____ i __X_,X___ i ___X,_X__ i ____,X___ i ___X, - X___ i ___X,____ i ____,_X_X i ____,__X_ i X___,____ i __X_,X___ i ___X,_X__ i ____,X_X_ i ____,_X__ i ____,_X__ i XX__,X_X_ i _X_X,____ i __X_,X___ i ___X,_X__ i ____,X___ i ___X, - X___ i ___X,__X_ i __X_,_X_X i __X_,__X_ i X__X,___X i __X_,X__X i XXX_,_X__ i X___,X__X i X__X,X___ i ____,_X__ i ____,X_X_ i _X__,XX__ i XX__,_XX_ i _XX_,_X__ i XXXX,____ i ___X, - X___ i ___X,__X_ i __X_,_X_X i __X_,__X_ i X__X,___X i __X_,X___ i ___X,_X__ i X___,X___ i X__X,____ i ____,_X__ i __XX,__X_ i _X__,_X__ i X___,__X_ i _X__,_X__ i ____,X___ i ___X, - X___ i ___X,__X_ i __X_,_X_X i __X_,__X_ i X__X,___X i __X_,X___ i ___X,_X__ i X___,X___ i X__X,____ i ____,_X__ i ____,X_X_ i _X__,_X__ i X___,__X_ i _X__,_X__ i ____,X___ i ___X, - X___ i ___X,__X_ i __X_,_X_X i __X_,__X_ i X__X,___X i __X_,X__X i XXX_,_X__ i X___,X___ i X__X,____ i ____,_X__ i XX__,X_X_ i _X__,_X__ i X___,__X_ i _X__,_X__ i XXXX,____ i ___X, - X___ i ___X,__X_ i __X_,_X_X i ____,__X_ i X__X,___X i __X_,X___ i ___X,_X__ i X___,X___ i X__X,____ i ____,_X__ i ____,X_X_ i _X__,_X__ i X___,__X_ i _X__,_X__ i ____,X___ i ___X, - X___ i ___X,__X_ i __X_,_X_X i ____,__X_ i X__X,___X i __X_,X___ i ___X,_X__ i X___,X___ i X__X,____ i ____,_X__ i ____,X_X_ i _X__,_X__ i X___,__X_ i _X__,_X__ i ____,X___ i ___X, - X___ i ____,XX_X i XX_X,X___ i XXXX,XX__ i _XX_,XXX_ i XX__,_XXX i XXX_,__XX i _XXX,____ i _XX_,____ i ____,__XX i XXXX,___X i X___,__XX i ____,___X i X___,__XX i XXXX,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - X___ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ___X, - _X__ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i __X_, - _X__ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i __X_, - __X_ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i _X__, - ___X i X___,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,____ i ____,___X i X___, - ____ i _XXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXXX i XXXX,XXX_ i ____, - -#undef i -}; - -/* lcd digits */ -const char lcd_digits[] = -{ - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,1,1,1,0, - - 0,0,0,1,1,1,1,0,0,0, - 0,0,1,1,0,0,1,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,1,0,0,1,1,0,0, - 0,0,0,1,1,1,1,0,0,0, - - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 0,1,1,1,1,1,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,1,1, - 1,0,0,0,0,1,1,1,1,0, - 1,0,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,1,1,1,0, - - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 0,1,1,1,1,1,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,1,1,1,0, - - 0,1,1,1,0,1,1,1,1,0, - 1,1,0,1,1,1,0,0,1,1, - 1,0,0,0,1,0,0,0,0,1, - 1,0,0,0,1,0,0,0,0,1, - 1,0,0,0,1,0,0,0,0,1, - 1,0,0,0,1,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 0,1,1,1,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,1,0,0,1,1, - 0,0,0,0,0,1,1,1,1,0, - - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,1,1, - 1,0,0,0,0,1,1,1,1,0, - 1,0,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 0,1,1,1,1,1,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,1,1,1,0, - - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,1,1, - 1,0,0,0,0,1,1,1,1,0, - 1,0,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,1,1,1,0, - - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 0,1,1,1,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,0,0,0,0,1, - 0,0,0,0,1,1,0,0,1,1, - 0,0,0,0,0,1,1,1,1,0, - - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,0,0,0,0,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,1,1,1,0, - - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,1,1,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 0,1,1,1,1,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,1,1, - 0,1,1,1,1,1,1,1,1,0, - - /* 10: - */ - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,1,1,1,1,1,1,0,0, - 0,1,0,0,0,0,0,0,1,0, - 0,1,0,0,0,0,0,0,1,0, - 0,1,0,0,0,0,0,0,1,0, - 0,0,1,1,1,1,1,1,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - - /* 11: / */ - 0,0,0,0,1,1,1,1,0,0, - 0,0,0,1,0,0,0,0,1,0, - 0,0,0,1,0,0,0,0,1,0, - 0,0,0,1,0,0,0,0,1,0, - 0,0,0,1,0,0,0,0,1,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,0,1,0,0,0,0,1,0,0, - 0,1,0,0,0,0,1,0,0,0, - 0,1,0,0,0,0,1,0,0,0, - 0,1,0,0,0,0,1,0,0,0, - 0,1,0,0,0,0,1,0,0,0, - 0,0,1,1,1,1,0,0,0,0, - - /* 12: ? */ - 0,1,1,1,1,1,1,1,1,0, - 1,1,0,0,0,0,0,0,1,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 0,1,1,1,1,1,0,0,0,1, - 1,1,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,0, - 1,0,0,0,0,1,0,0,0,0, - 1,0,0,0,0,1,0,0,0,0, - 1,0,0,0,0,1,0,0,0,0, - 1,1,0,0,1,1,0,0,0,0, - 0,1,1,1,1,0,0,0,0,0, - - /* 13: " " */ - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, -}; -#endif /* functions */ -void ConfigMenu(int Init); -void CleanUp(); -void PageInput(int Number); -void ColorKey(int); -void PageCatching(); -void CatchNextPage(int, int); -void GetNextPageOne(int up); -void GetNextSubPage(int offset); -void SwitchZoomMode(); -void SwitchScreenMode(int newscreenmode); -void SwitchTranspMode(); -void SwitchHintMode(); -void CreateLine25(); -void CopyBB2FB(); -void RenderCatchedPage(); -void RenderCharFB(int Char, tstPageAttr *Attribute); -void RenderCharBB(int Char, tstPageAttr *Attribute); -void RenderCharLCD(int Digit, int XPos, int YPos); -void RenderMessage(int Message); -void RenderPage(); -void DecodePage(); -void UpdateLCD(); -int Init(int source); -int GetNationalSubset(const char *country_code); -int GetTeletextPIDs(); -int GetRCCode(); -int eval_triplet(int iOData, tstCachedPage *pstCachedPage, +static void ConfigMenu(int Init); +static void CleanUp(); +static void PageInput(int Number); +static void ColorKey(int); +static void PageCatching(); +static void CatchNextPage(int, int); +static void GetNextPageOne(int up); +static void GetNextSubPage(int offset); +static void SwitchZoomMode(); +static void SwitchScreenMode(int newscreenmode); +static void SwitchTranspMode(); +static void SwitchHintMode(); +static void CreateLine25(); +static void CopyBB2FB(); +static void RenderCatchedPage(); +static void RenderCharFB(int Char, tstPageAttr *Attribute); +static void RenderCharBB(int Char, tstPageAttr *Attribute); +static void RenderMessage(int Message); +static void RenderPage(); +static void DecodePage(); +static int Init(int source); +static int GetNationalSubset(const char *country_code); +static int GetTeletextPIDs(); +static int GetRCCode(); +static int eval_triplet(int iOData, tstCachedPage *pstCachedPage, unsigned char *pAPx, unsigned char *pAPy, unsigned char *pAPx0, unsigned char *pAPy0, unsigned char *drcssubp, unsigned char *gdrcssubp, signed char *endcol, tstPageAttr *attrPassive, unsigned char* pagedata); -void eval_object(int iONr, tstCachedPage *pstCachedPage, +static void eval_object(int iONr, tstCachedPage *pstCachedPage, unsigned char *pAPx, unsigned char *pAPy, unsigned char *pAPx0, unsigned char *pAPy0, tObjType ObjType, unsigned char* pagedata);