void cc708_service_reset(cc708_service_decoder *decoder) { // There's lots of other stuff that we need to do, such as canceling delays for (int j=0;j<8;j++) { decoder->windows[j].is_defined=0; decoder->windows[j].visible=0; decoder->windows[j].memory_reserved=0; decoder->windows[j].is_empty=1; memset (decoder->windows[j].commands, 0, sizeof (decoder->windows[j].commands)); } decoder->current_window=-1; clearTV(decoder); decoder->inited=1; }
void updateScreen (cc708_service_decoder *decoder) { clearTV (decoder); // THIS FUNCTION WILL DO THE MAGIC OF ACTUALLY EXPORTING THE DECODER STATUS // TO SEVERAL FILES e708Window *wnd[I708_MAX_WINDOWS]; // We'll store here the visible windows that contain anything int visible=0; for (int i=0;i<I708_MAX_WINDOWS;i++) { if (decoder->windows[i].is_defined && decoder->windows[i].visible && !decoder->windows[i].is_empty) wnd[visible++]=&decoder->windows[i]; } qsort (wnd,visible,sizeof (e708Window *),compWindowsPriorities); for (int i=0;i<visible;i++) { int top,left; // For each window we calculate the top,left position depending on the // anchor switch (wnd[i]->anchor_point) { case anchorpoint_top_left: top=wnd[i]->anchor_vertical; left=wnd[i]->anchor_horizontal; break; case anchorpoint_top_center: top=wnd[i]->anchor_vertical; left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; break; case anchorpoint_top_right: top=wnd[i]->anchor_vertical; left=wnd[i]->anchor_horizontal - wnd[i]->col_count; break; case anchorpoint_middle_left: top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; left=wnd[i]->anchor_horizontal; break; case anchorpoint_middle_center: top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; break; case anchorpoint_middle_right: top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; left=wnd[i]->anchor_horizontal - wnd[i]->col_count; break; case anchorpoint_bottom_left: top=wnd[i]->anchor_vertical - wnd[i]->row_count; left=wnd[i]->anchor_horizontal; break; case anchorpoint_bottom_center: top=wnd[i]->anchor_vertical - wnd[i]->row_count; left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; break; case anchorpoint_bottom_right: top=wnd[i]->anchor_vertical - wnd[i]->row_count; left=wnd[i]->anchor_horizontal - wnd[i]->col_count; break; default: // Shouldn't happen, but skip the window just in case continue; } if (top<0) top=0; if (left<0) left=0; int copyrows=top + wnd[i]->row_count >= I708_SCREENGRID_ROWS ? I708_SCREENGRID_ROWS - top : wnd[i]->row_count; int copycols=left + wnd[i]->col_count >= I708_SCREENGRID_COLUMNS ? I708_SCREENGRID_COLUMNS - left : wnd[i]->col_count; for (int j=0;j<copyrows;j++) { memcpy (decoder->tv.chars[top+j],wnd[i]->rows[j],copycols); } } printTVtoBuf(decoder); decoder->callback(decoder->service, decoder->userdata); }
void updateScreen (cc708_service_decoder *decoder) { // THIS FUNCTION WILL DO THE MAGIC OF ACTUALLY EXPORTING THE DECODER STATUS // TO SEVERAL FILES e708Window *wnd[I708_MAX_WINDOWS]; // We'll store here the visible windows int visible=0; for (int i=0;i<I708_MAX_WINDOWS;i++) { if (decoder->windows[i].is_defined && decoder->windows[i].visible) wnd[visible++]=&decoder->windows[i]; } qsort (wnd,visible,sizeof (int),compWindowsPriorities); printf ("Visible windows in priority order: "); for (int i=0;i<visible;i++) { printf ("%d (%d) | ",wnd[i]->number, wnd[i]->priority); } printf ("\n"); clearTV(decoder); for (int i=0;i<visible;i++) { int top,left; // For each window we calculate the top,left position depending on the // anchor switch (wnd[i]->anchor_point) { case anchorpoint_top_left: top=wnd[i]->anchor_vertical; left=wnd[i]->anchor_horizontal; break; case anchorpoint_top_center: top=wnd[i]->anchor_vertical; left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; break; case anchorpoint_top_right: top=wnd[i]->anchor_vertical; left=wnd[i]->anchor_horizontal - wnd[i]->col_count; break; case anchorpoint_middle_left: top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; left=wnd[i]->anchor_horizontal; break; case anchorpoint_middle_center: top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; break; case anchorpoint_middle_right: top=wnd[i]->anchor_vertical - wnd[i]->row_count/2; left=wnd[i]->anchor_horizontal - wnd[i]->col_count; break; case anchorpoint_bottom_left: top=wnd[i]->anchor_vertical - wnd[i]->row_count; left=wnd[i]->anchor_horizontal; break; case anchorpoint_bottom_center: top=wnd[i]->anchor_vertical - wnd[i]->row_count; left=wnd[i]->anchor_horizontal - wnd[i]->col_count/2; break; case anchorpoint_bottom_right: top=wnd[i]->anchor_vertical - wnd[i]->row_count; left=wnd[i]->anchor_horizontal - wnd[i]->col_count; break; default: // Shouldn't happen, but skip the window just in case continue; } printf ("For window %d: Anchor point -> %d, size %d:%d, real position %d:%d\n", wnd[i]->number, wnd[i]->anchor_point, wnd[i]->row_count,wnd[i]->col_count, top,left); if (top<0) top=0; if (left<0) left=0; int copyrows=top + wnd[i]->row_count >= I708_SCREENGRID_ROWS ? I708_SCREENGRID_ROWS - top : wnd[i]->row_count; int copycols=left + wnd[i]->col_count >= I708_SCREENGRID_COLUMNS ? I708_SCREENGRID_COLUMNS - left : wnd[i]->col_count; printf ("%d*%d will be copied to the TV.\n", copyrows, copycols); for (int j=0;j<copyrows;j++) { memcpy (decoder->tv.chars[top+j],wnd[i]->rows[j],copycols); } } }