Example #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);
}
Example #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;
}
Example #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;
}
Example #4
0
/****************************************************************************
REMARKS:
Main routine. Expects the x & y resolution of the desired video mode
to be passed on the command line. Will print out a list of available
video modes if no command line is present.
****************************************************************************/
int main(
    int argc,
    char *argv[])
{
    /* Check to see if we are running in a window */
    if (PM_runningInAWindow()) {
        printf("This program cannot run in a window. Please switch to a fullscreen mode.\n");
        return -1;
        }

    /* Save the state of the console */
    hwndConsole = PM_openConsole(0,0,640,480,8,true);
    if ((stateBuf = malloc(PM_getConsoleStateSize())) == NULL)
        PM_fatalError("Out of memory!");
    PM_saveConsoleState(stateBuf,hwndConsole);

    /* Register our fatal error cleanup handler */
    PM_setFatalErrorCleanup(FatalErrorCleanup);

    /* Register the ISV license file if desired */
#ifdef  ISV_LICENSE
    GA_registerLicense(OemLicense,false);
#endif

    /* Load the device driver for this device */
    if ((dc = GA_loadDriver(0,false)) == NULL)
        PM_fatalError(GA_errorMsg(GA_status()));
    init.dwSize = sizeof(init);
    if (!GA_queryFunctions(dc,GA_GET_INITFUNCS,&init))
        PM_fatalError("Unable to get device driver functions!");
    driver.dwSize = sizeof(driver);
    if (!GA_queryFunctions(dc,GA_GET_DRIVERFUNCS,&driver))
        PM_fatalError("Unable to get device driver functions!");

    /* Display available modes for invalid command line */
    if (argc != 4) {
        /* Restore the console */
        PM_restoreConsoleState(stateBuf,hwndConsole);
        PM_closeConsole(hwndConsole);
        AvailableModes();
        GA_unloadDriver(dc);
        return 0;
        }

    /* Get requested resolution, start graphics and draw pattern */
    xRes = atoi(argv[1]);
    yRes = atoi(argv[2]);
    bpp = atoi(argv[3]);
    if ((oldMode = InitGraphics(xRes,yRes,bpp)) != -1) {
        DrawMoire();
        PM_getch();

        virtualX = virtualY = bytesPerLine = -1;
        init.SetVideoMode(oldMode,&virtualX,&virtualY,&bytesPerLine,&maxMem,0,NULL);
        }

    /* Restore the console */
    ExitSoftwareRasterizer();
    PM_restoreConsoleState(stateBuf,hwndConsole);
    PM_closeConsole(hwndConsole);

    /* Unload the device driver */
    GA_unloadDriver(dc);

    if (oldMode == -1)
        printf("Unable to find specified graphics mode, or error starting mode.\n");
    return 0;
}