Beispiel #1
0
/****************************************************************************
REMARKS:
Restore the old display mode active before graphics mode was started.
****************************************************************************/
void RestoreMode(
    GC_devCtx *gc)
{
    /* Clean up the software rasteriser on exit */
    if (modeInfo.BitsPerPixel >= 4)
        ExitSoftwareRasterizer();
    GC_restore(gc);
}
Beispiel #2
0
/****************************************************************************
REMARKS:
Main function to do the interactive tests.
****************************************************************************/
ibool doVideoCaptureTest(
    GC_devCtx *gc,
    GA_glCtx *gl,
    int xRes,
    int yRes,
    int bitsPerPixel,
    N_uint32 flags,
    int refreshRate,
    GA_CRTCInfo *crtc,
    N_uint32 planeMask,
    ibool force1bppShadow)
{
    int                     i,choice;
    ibool                   success = true,all = true;
    GA_videoFuncs           video;
    GA_videoCaptureFuncs    capture;
    GA_VideoCaptureInf      captureInfo;
    GA_captureInputTypes    inputs[ ] = { gaCaptureCompositeInput,
                                          gaCaptureSVideoInput,
                                          gaCaptureRGBInput,
                                          gaCaptureRS170Input };
#define NUM_INPUTS (sizeof(inputs) / sizeof(inputs[0]))

    /* Obtain the mode information before setting the mode */
    dc = gc->dc;
    virtualX = virtualY = bytesPerLine = -1;
    modeInfo.dwSize = sizeof(modeInfo);
    if (xRes == -1) {
        if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
            return false;
        }
    else {
        if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
            return false;
        }

    /* Check mode for video acceleration capabilities */
    if (!(modeInfo.Attributes & gaHaveAccelVideo)) {
        GC_printf(gc,"Video acceleration not available!\n\n");
        return false;
        }

    /* Check mode for video capture format list */
    captureInfo.dwSize = sizeof(captureInfo);
    if (!(modeInfo.VideoWindows)) {
        GC_printf(gc,"Video capture format list not available!\n\n");
        return false;
        }
    else
        memcpy(&captureInfo,*modeInfo.VideoCapture,captureInfo.dwSize);

    for (;;) {
        /* Display video format menu while in graphics console mode */
        GC_clrscr(gc);
        GC_printf(gc,"Video Capture Test\n\n");

        /* Display menu of available video overlay formats */
        GC_printf(gc,"Select Video Capture input to test:\n\n");
        for (i = 0; i < NUM_INPUTS; i++) {
            if ((captureInfo.InputType & inputs[i]) != inputs[i])
                continue;
            GC_printf(gc,"  [%i] - %s\n",i,displayInput(inputs[i]));
            }
        GC_printf(gc,"  [Q] - Quit\n\n");
        GC_printf(gc,"Choice: ");
        for (;;) {
            choice = EVT_getch();
            if (tolower(choice) == 'q' || choice == 0x1B)
                return true;
            choice = (choice) - '0';
            if (choice >= 0 && choice < NUM_INPUTS) {
                if ((captureInfo.InputType & inputs[choice]) == inputs[choice])
                    break;
                }
            }

        /* Obtain the mode information and set the display mode */
        GC_leave(gc);
        dc = gc->dc;
        virtualX = virtualY = bytesPerLine = -1;
        modeInfo.dwSize = sizeof(modeInfo);
        if (xRes == -1) {
            if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
                return false;
            if (init.SetVideoMode(flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,refreshRate,crtc) != 0)
                return false;
            }
        else {
            if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
                return false;
            if (init.SetCustomVideoMode(xRes,yRes,bitsPerPixel,flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,crtc) != 0)
                return false;
            }
        cntMode = flags;
        if (!InitSoftwareRasterizer(cntDevice,1,false))
            PM_fatalError("Unable to initialise software rasteriser!");

        /* Get the hardware video overlay functions */
        video.dwSize = sizeof(video);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOFUNCS,&video)) {
            displayError("Video functions not available!");
            success = false;
            goto DoneTests;
            }
        capture.dwSize = sizeof(capture);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOCAPTUREFUNCS,&capture)) {
            displayError("Video capture functions not available!");
            success = false;
            goto DoneTests;
            }

        /* Run the tests for the selected capture input */
        i = choice;
        all = (stricmp(accelTestName,"all") == 0);
        if (all || stricmp(accelTestName,"capture") == 0)
            if (staticTest(&video,&capture,inputs[i],gaCaptureStandardNTSC,&captureInfo) == 0x1B)
                goto DoneTests;

DoneTests:
        /* Return to text mode, restore the state of the console and reloop */
        ExitSoftwareRasterizer();
        GC_restore(gc);
        if (!success)
            break;
        }

    (void)gl;
    (void)planeMask;
    (void)force1bppShadow;
    return success;
}
Beispiel #3
0
/****************************************************************************
REMARKS:
Main function to do the interactive tests.
****************************************************************************/
ibool CenterTVMode(
    GC_devCtx *gc,
    N_uint32 mode)
{
    GA_options  opt,defOpt;
    GA_TVParams *tv;
    int         ch;
    event_t     evt;

    /* Obtain the mode information and set the display mode */
    GC_leave(gc);
    dc = gc->dc;
    virtualX = virtualY = bytesPerLine = -1;
    modeInfo.dwSize = sizeof(modeInfo);
    if (init.GetVideoModeInfo(mode,&modeInfo) != 0)
        return false;
    if (init.SetVideoMode(mode,&virtualX,&virtualY,&bytesPerLine,&maxMem,0,NULL) != 0)
        return false;
    cntMode = mode;
    if (!InitSoftwareRasterizer(cntDevice,1,false))
        PM_fatalError("Unable to initialize reference rasteriser!");
    opt.dwSize = sizeof(opt);
    init.GetOptions(&opt);
    defOpt = opt;

    /* Find the appropriate TV parameters block depending on current mode */
    if (modeInfo.XResolution > 640) {
        switch (opt.outputDevice & gaOUTPUT_TVCOLORMASK) {
            case gaOUTPUT_TVPAL:
            case gaOUTPUT_TVPAL_M:
            case gaOUTPUT_TVPAL_60:
            case gaOUTPUT_TVPAL_CN:
            case gaOUTPUT_TVSCART_PAL:
                if (opt.outputDevice & gaOUTPUT_TVOVERSCAN)
                    tv = &opt.TV800PALOver;
                else
                    tv = &opt.TV800PALUnder;
                break;
            case gaOUTPUT_TVNTSC:
            case gaOUTPUT_TVNTSC_J:
            default:
                if (opt.outputDevice & gaOUTPUT_TVOVERSCAN)
                    tv = &opt.TV800NTSCOver;
                else
                    tv = &opt.TV800NTSCUnder;
                break;
            }
        }
    else {
        switch (opt.outputDevice & gaOUTPUT_TVCOLORMASK) {
            case gaOUTPUT_TVPAL:
            case gaOUTPUT_TVPAL_M:
            case gaOUTPUT_TVPAL_60:
            case gaOUTPUT_TVPAL_CN:
            case gaOUTPUT_TVSCART_PAL:
                if (opt.outputDevice & gaOUTPUT_TVOVERSCAN)
                    tv = &opt.TV640PALOver;
                else
                    tv = &opt.TV640PALUnder;
                break;
            case gaOUTPUT_TVNTSC:
            case gaOUTPUT_TVNTSC_J:
            default:
                if (opt.outputDevice & gaOUTPUT_TVOVERSCAN)
                    tv = &opt.TV640NTSCOver;
                else
                    tv = &opt.TV640NTSCUnder;
                break;
            }
        }

    /* Draw the background image */
    drawBackground();

    /* Now process key events */
    for (;;) {
        EVT_halt(&evt,EVT_KEYDOWN | EVT_KEYREPEAT);
        ch = EVT_scanCode(evt.message);
        if (ch == KB_esc || ch == KB_Q) {
            opt = defOpt;
            init.SetOptions(&opt);
            break;
            }
        if (ch == KB_enter) {
            /* Save the timing changes */
            GA_saveOptions(dc,&opt);
            break;
            }

        /* Now handle the key event */
        switch (ch) {
            case KB_R:          /* Reset to initial values */
                opt = defOpt;
                init.SetOptions(&opt);
                break;
            case KB_equals:
            case KB_padPlus:    /* Increase brightness */
                tv->brightness++;
                init.SetOptions(&opt);
                break;
            case KB_minus:
            case KB_padMinus:   /* Decrease brightness */
                tv->brightness--;
                init.SetOptions(&opt);
                break;
            case KB_up:         /* Move the image up */
                tv->vPos--;
                init.SetOptions(&opt);
                break;
            case KB_down:       /* Move the image down */
                tv->vPos++;
                init.SetOptions(&opt);
                break;
            case KB_left:       /* Move the image left */
                tv->hPos--;
                init.SetOptions(&opt);
                break;
            case KB_right:      /* Move the image right */
                tv->hPos++;
                init.SetOptions(&opt);
                break;
            }
        }

    /* Return to text mode, restore the state of the console and exit */
    ExitSoftwareRasterizer();
    GC_restore(gc);
    return true;
}