Index: sub_cc.c =================================================================== --- sub_cc.c (revision 24830) +++ sub_cc.c (working copy) @@ -34,9 +34,16 @@ static subtitle *fb,*bb; static unsigned int cursor_pos=0; - static int inited=0; +#define CC_ROLLON 1 +#define CC_ROLLUP 2 + +static int cc_mode=CC_ROLLON; +static int cc_lines=4; + +static void display_buffer(subtitle * buf); + static void build_char_table(void) { int i; @@ -64,6 +71,22 @@ } +static void scroll_buffer() +{ + int i; + + while(bb->lines > cc_lines) + { + if(bb->text[0]) free(bb->text[0]); + + for(i = 0; i < (bb->lines - 1); i++) bb->text[i] = bb->text[i+1]; + + bb->text[bb->lines-1] = NULL; + bb->lines--; + } +} + + void subcc_init(void) { int i; @@ -90,7 +113,14 @@ if(c=='\n') { if(cursor_pos>0 && bb->lines < SUB_MAX_TEXT) + { bb->lines++;cursor_pos=0; + if(cc_mode==CC_ROLLUP){ + bb->text[bb->lines - 1]=malloc(CC_MAX_LINE_LENGTH); + memset(bb->text[bb->lines - 1],0,CC_MAX_LINE_LENGTH); + scroll_buffer(); + } + } } else { @@ -101,6 +131,7 @@ } bb->text[bb->lines - 1][cursor_pos++]=c; } + if(cc_mode==CC_ROLLUP) display_buffer(bb); } @@ -125,7 +156,6 @@ static unsigned short int lastcode=0x0000; unsigned char c1 = data & 0x7f; unsigned char c2 = (data >> 8) & 0x7f; - if (c1 & 0x60) { /* normal character, 0x20 <= c1 <= 0x7f */ append_char(chartbl[c1]); if(c2 & 0x60) /*c2 might not be a normal char even if c1 is*/ @@ -159,6 +189,13 @@ case 0x14: switch(c2) { + case 0x00: cc_mode=CC_ROLLON;break; + case 0x25: + case 0x26: + case 0x27: + cc_lines=c2-0x23; + cc_mode=CC_ROLLUP; + break; case 0x2C: display_buffer(NULL); //EDM clear_buffer(fb); break; case 0x2d: append_char('\n'); //carriage return