コード例 #1
0
ファイル: util.c プロジェクト: BackupTheBerlios/uuu
/****************************************************************************
REMARKS:
Simple utility function to use the event library to read an ASCII keypress
and return it. This function will block until a key is hit.
****************************************************************************/
int EVT_getch(void)
{
    event_t evt;

    do {
        EVT_halt(&evt,EVT_KEYDOWN | EVT_KEYREPEAT);
        } while (EVT_asciiCode(evt.message) == 0);
    return EVT_asciiCode(evt.message);
}
コード例 #2
0
ファイル: sterdemo.c プロジェクト: OS2World/LIB-VIDEO-MGL
void demo(MGLDC *dc)
{
	int             mode;
	int             x,y,width,height;
	bitmap_t        *bitmap;
	event_t     	evt;

	/* Get display mode selected. */
	maxx = MGL_maxx();
	maxy = MGL_maxy();
	mode = MGL_getMode(dc);

	/* Now load the bitmap file from disk. Note that we store the bitmap
	 * files with the left and right images together side by side in a
	 * single image, using the defacto standard "cross-eyed free-view"
	 * format (right-eye image on left, left-eye image on right). (DaveM)
	 */
	bitmap = MGL_loadBitmap(bitmapName,true);
	if (!bitmap)
		MGL_fatalError("Unable to locate stereo bitmap!");

	/* Create the stereo display mode */
	MGL_changeDisplayMode(mode);
	if ((dc = MGL_createStereoDisplayDC(1,refreshRate)) == NULL)
		MGL_fatalError(MGL_errorMsg(MGL_result()));
	MGL_makeCurrentDC(dc);

	/* Display the bitmap on the screen for the left and right images */
	width = bitmap->width/2;
	height = bitmap->height;
	x = (MGL_maxx()-width)/2;
	y = (MGL_maxy()-height)/2;
	MGL_setActivePage(dc,0 | MGL_LEFT_BUFFER);
	MGL_clearDevice();
	MGL_putBitmapSection(dc,width,0,width*2,height,x,y,bitmap,MGL_REPLACE_MODE);
	MGL_setActivePage(dc,0 | MGL_RIGHT_BUFFER);
	MGL_clearDevice();
	MGL_putBitmapSection(dc,0,0,width,height,x,y,bitmap,MGL_REPLACE_MODE);
	MGL_startStereo(dc);
	EVT_halt(&evt,EVT_KEYDOWN);

	/* Disable free running stereo mode */
	MGL_stopStereo(dc);
}
コード例 #3
0
ファイル: getch.c プロジェクト: A1DEVS/lenovo_a1_07_uboot
/****************************************************************************
REMARKS:
Joystick calibration routine
****************************************************************************/
void CalibrateJoy(void)
{
  event_t evt;
  if(EVT_joyIsPresent()){
    printf("Joystick Calibration\nMove the joystick to the upper left corner and press any button.\n");
    EVT_halt(&evt, EVT_JOYCLICK);
    EVT_halt(&evt, EVT_JOYCLICK);
    EVT_joySetUpperLeft();
    printf("Move the joystick to the lower right corner and press any button.\n");
    EVT_halt(&evt, EVT_JOYCLICK);
    EVT_halt(&evt, EVT_JOYCLICK);
    EVT_joySetLowerRight();
    printf("Move the joystick to center position and press any button.\n");
    EVT_halt(&evt, EVT_JOYCLICK);
    EVT_halt(&evt, EVT_JOYCLICK);
    EVT_joySetCenter();
    printf("Joystick calibrated\n");
  }
}
コード例 #4
0
ファイル: tv.c プロジェクト: BackupTheBerlios/uuu
/****************************************************************************
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;
}
コード例 #5
0
ファイル: direct.c プロジェクト: OS2World/LIB-VIDEO-MGL
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(void)
{
	MGLDC       	*dc,*memdc;
	event_t     	evt;
	pixel_format_t	pf;
	palette_t		pal[256];
	bitmap_t    	bmpHdr;

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

	/* Start the MGL in 640x480 256 color mode */
	dc = MGL_quickInit(640,480,8,1);

	/* Now extract the information about the device surface to our
	 * global variables and draw on it. Note that we must check that we
	 * have direct access to the surface. If it is a bank switched
	 * surface then we cannot directly write to it, and the surface
	 * pointer will be NULL.
     *
     * Note that the MGL fully supports virtualised framebuffer surfaces,
     * so in most cases it would be very rare to get a bank switched
     * surface (in fact since we did not register the bank switched
     * drivers, it would be impossible in this sample program!).
     */
    if (MGL_surfaceAccessType(dc) == MGL_NO_ACCESS)
        MGL_fatalError("This program requires a linear access surface");
    maxx = dc->mi.xRes;
    maxy = dc->mi.yRes;
    bytesPerLine = dc->mi.bytesPerLine;
    surface = dc->surface;

    /* If we are drawing to a hardware accelerated surface, we must call
     * MGL_beginDirectAccess() and MGL_endDirectAccess() before and after
     * doing any direct surface access
     */
    if (MGL_getHardwareFlags(dc) != MGL_HW_NONE)
        MGL_beginDirectAccess();

    /* Now draw directly to display surface */
    moire();

    if (MGL_getHardwareFlags(dc) != MGL_HW_NONE)
        MGL_endDirectAccess();

    /* Wait for a keypress */
    EVT_halt(&evt,EVT_KEYDOWN);

	/* Now we allocate a system memory block for a 100x100 memory
     * surface manually and attach it to our bitmap header. Then we
     * will draw directly to it and then display it on our main device
     * context. Note that we allocate it without a palette and with
     * a pixel format info block.
     */
    bmpHdr.width = 320;
    bmpHdr.height = 240;
    bmpHdr.bitsPerPixel = 8;
    bmpHdr.bytesPerLine = bmpHdr.width;
    bmpHdr.pal = NULL;
    bmpHdr.pf = NULL;
    bmpHdr.surface = malloc(bmpHdr.bytesPerLine * bmpHdr.height);
    if (bmpHdr.surface == NULL)
        MGL_fatalError("Out of memory");
	maxx = bmpHdr.width-1;
	maxy = bmpHdr.height-1;
	bytesPerLine = bmpHdr.bytesPerLine;
	surface = bmpHdr.surface;
	memset(surface,0,bytesPerLine * (maxy+1));

	/* Now draw directly to bitmap surface and display it */
	moire();
	MGL_putBitmap(dc,160,120,&bmpHdr,MGL_REPLACE_MODE);

	/* Wait for a keypress */
	EVT_halt(&evt,EVT_KEYDOWN);

	/* Now we allocate a system memory device context and draw directly
	 * onto this surface, then blit it to the display. It is similar to
	 * the above code but does not use a lightweight bitmap as the drawing
	 * surface but a full memory device context (which you can also render
	 * to using the MGL functions).
	 */
	if ((memdc = MGL_createMemoryDC(160,120,8,&pf)) == NULL)
		MGL_fatalError(MGL_errorMsg(MGL_result()));
	maxx = memdc->mi.xRes;
	maxy = memdc->mi.yRes;
	bytesPerLine = memdc->mi.bytesPerLine;
	surface = memdc->surface;
	memset(surface,0,bytesPerLine * (maxy+1));

	/* Now set the palette for the memory device to the same as the display
	 * DC so that we avoid palette remapping (you could use a different
	 * palette and it would be automatically mapped to the screen when you
	 * do a blit, but this would be slower).
	 */
	MGL_getPalette(dc,pal,256,0);
	MGL_setPalette(memdc,pal,256,0);
	MGL_realizePalette(memdc,256,0,false);

	/* Now draw directly to bitmap surface and display it */
	moire();
	MGL_bitBltCoord(dc,memdc,0,0,160,120,240,180,MGL_REPLACE_MODE);

	/* Wait for a keypress */
	EVT_halt(&evt,EVT_KEYDOWN);

	MGL_exit();
	return 0;
}