Exemple #1
0
int PrintCC(void)
{
    char buffer[32];
    FormatCC(buffer);
    fprintf(stdout, buffer);
    return(strlen(buffer));
}
Exemple #2
0
void set_flags(y86_register val_new, int sign_A, int sign_B)
{
    /* zero flag if the new value is zero */
    ZF = (val_new == 0);

    /* sign flag if the new value is negative -- sign bit is one */
    SF = sign_bit(val_new);
    
    /* overflow flag is if the signs of the input (sign_A and sign_B) are 
       the same, and different from the result (val_new) */
    if (sign_A != sign_B)
        OF = 0;
    else if (sign_A == sign_bit(val_new))
        OF = 0;
    else
        OF = 1;
    if (debug) fprintf(stdout, "ZF=%d, SF=%d, OF=%d\n", ZF, SF, OF);

    char buffer[32];
    FormatCC(buffer);
    strcat(buffer, " -> CC");
    Part2Trace(buffer);
}
Exemple #3
0
void V4LRecorder::RunVBIDevice(void)
{
    if (vbi_fd < 0)
        return;

    unsigned char *buf = NULL, *ptr = NULL, *ptr_end = NULL;
    if (ntsc_vbi_width)
    {
        uint sz   = ntsc_vbi_width * ntsc_vbi_line_count * 2;
        buf = ptr = new unsigned char[sz];
        ptr_end   = buf + sz;
    }

    while (IsHelperRequested() && !IsErrored())
    {
        if (PauseAndWait())
            continue;

        if (!IsHelperRequested() || IsErrored())
            break;

        struct timeval tv;
        fd_set rdset;

        tv.tv_sec = 0;
        tv.tv_usec = 5000;
        FD_ZERO(&rdset);
        FD_SET(vbi_fd, &rdset);

        int nr = select(vbi_fd + 1, &rdset, 0, 0, &tv);
        if (nr < 0)
            LOG(VB_GENERAL, LOG_ERR, LOC + "vbi select failed" + ENO);

        if (nr <= 0)
        {
            if (nr==0)
                LOG(VB_GENERAL, LOG_DEBUG, LOC + "vbi select timed out");
            continue; // either failed or timed out..
        }
        if (VBIMode::PAL_TT == vbimode)
        {
            pal_vbi_cb->foundteletextpage = false;
            vbi_handler(pal_vbi_tt, pal_vbi_tt->fd);
            if (pal_vbi_cb->foundteletextpage)
            {
                // decode VBI as teletext subtitles
                FormatTT(pal_vbi_cb);
            }
        }
        else if (VBIMode::NTSC_CC == vbimode)
        {
            int ret = read(vbi_fd, ptr, ptr_end - ptr);
            ptr = (ret > 0) ? ptr + ret : ptr;
            if ((ptr_end - ptr) == 0)
            {
                unsigned char *line21_field1 =
                    buf + ((21 - ntsc_vbi_start_line) * ntsc_vbi_width);
                unsigned char *line21_field2 =
                    buf + ((ntsc_vbi_line_count + 21 - ntsc_vbi_start_line)
                           * ntsc_vbi_width);
                bool cc1 = vbi608->ExtractCC12(line21_field1, ntsc_vbi_width);
                bool cc2 = vbi608->ExtractCC34(line21_field2, ntsc_vbi_width);
                if (cc1 || cc2)
                {
                    int code1 = vbi608->GetCode1();
                    int code2 = vbi608->GetCode2();
                    code1 = (0xFFFF==code1) ? -1 : code1;
                    code2 = (0xFFFF==code2) ? -1 : code2;
                    FormatCC(code1, code2);
                }
                ptr = buf;
            }
            else if (ret < 0)
            {
                LOG(VB_GENERAL, LOG_ERR, LOC + "Reading VBI data" + ENO);
            }
        }
    }

    if (buf)
        delete [] buf;
}