示例#1
0
文件: w_system.c 项目: j13s/devil
/* set cursor (cursor==NULL is allowed) */
void ws_changecursor(ws_cursor *cursor) {
    if (cursor) {
        GrMouseEraseCursor(); /* GrMouseSetCursor((GrCursor *)cursor); */
        GrMouseDisplayCursor();
    }
    else {
        ws_resetmousecolors();
    }
}
示例#2
0
int main(int argc,char **argv)
{
  GrEvent ev;

  GrSetMode(GR_biggest_graphics);
  GrEventInit();
  GrMouseDisplayCursor();
  TestFunc();
  PrintInfo();
  GrEventWait(&ev);
  GrEventUnInit();
  GrSetMode(GR_default_text);
  return(0);
}
示例#3
0
文件: w_system.c 项目: j13s/devil
/* Initialize Grfx-Mode&Mouse.Try to use xres,yres,colors and font <fontname>.
   If you are successful, return a 1.
   If you can't initialize this mode, return a 0. */
int ws_initgrfx(int xres, int yres, int colors, const char *fontname) {
    static char pixels[2];
/* unsigned char value; 
    Why?  -jgk*/
    GrBitmap pat_bm = {
        0, 2, pixels, 1, 0, 0
    };


    if ( ( ws_private.textopt.txo_font =
              GrLoadFont( (char *)(fontname == NULL ?
                                   DEFAULT_FONT :
                                   fontname) ) ) == NULL ) {
        fprintf(errf, "Can't find font %s\n", fontname);
        return 0;
    }

    if ( !GrSetMode(GR_width_height_color_graphics, xres, yres, colors) ) {
        fprintf(errf, "Can't set grfx-mode. Try to load VESA-driver\n");
        return 0;
    }

    if (GrSizeX() != xres || GrSizeY() != yres) {
        fprintf(errf, "Can't set grfx-mode. Try to load VESA-driver\n");
        return 0;
    }

    GrClearScreen(0);

    if ( !GrMouseDetect() ) {
        fprintf(errf, "Can't find mouse\n");
        return 0;
    }

    GrMouseInit();
    GrMouseSetColors(255, 0);
    GrMouseDisplayCursor();
    pixels[0] = 0x79;   /* Prevent compiler warning for now */
    pixels[1] = 0x55;
    ws_private.pat_box.gp_bitmap = pat_bm;
/* value=_farpeekb(0x40,0x17);
   _farpokeb(0x40,0x17,value^0x20); */
    return 1;
}
示例#4
0
int main(void)
{
    GrContext *grc;
    int wide, high, maxval;
    char s[81];
    GrEvent ev;

    /*GrSetMode( GR_default_graphics ); */
    GrSetMode(GR_width_height_color_graphics, 640, 480, 32768);
    GrEventInit();
    GrMouseDisplayCursor();
    GrQueryPnm(FIMAGEPPM, &wide, &high, &maxval);
    sprintf(s, "%s %d x %d pixels", FIMAGEPPM, wide, high);
    GrTextXY(10, 20, s, GrBlack(), GrWhite());
    GrBox(10, 40, 10+wide+1, 40+high+1, GrWhite());
    grc = GrCreateSubContext(11, 41, 11+wide-1, 41+high-1, NULL, NULL);
    GrLoadContextFromPnm(grc, FIMAGEPPM);
    GrSaveContextToPgm(grc, FIMAGEPGM, "TestPnm");
    GrDestroyContext(grc);
    GrTextXY(10, 50+high, "Press RETURN to continue", GrBlack(), GrWhite());
    GrEventWaitKeyOrClick(&ev);

    GrClearScreen(GrBlack());
    GrQueryPnm(FIMAGEPGM, &wide, &high, &maxval);
    sprintf(s, "%s %d x %d pixels", FIMAGEPGM, wide, high);
    GrTextXY(10, 20, s, GrBlack(), GrWhite());
    GrBox(10, 40, 10+wide+1, 40+high+1, GrWhite());
    grc = GrCreateSubContext(11, 41, 11+wide-1, 41+high-1, NULL, NULL);
    GrLoadContextFromPnm(grc,FIMAGEPGM);
    GrDestroyContext(grc);
    GrTextXY(10, 50+high, "Press RETURN to continue", GrBlack(), GrWhite());
    GrEventWaitKeyOrClick(&ev);

    GrClearScreen(GrBlack());
    GrQueryPnm(FIMAGEPBM, &wide, &high, &maxval);
    sprintf(s, "%s %d x %d pixels", FIMAGEPBM, wide, high);
    GrTextXY(10, 20, s, GrBlack(), GrWhite());
    GrBox(10, 40, 10+wide+1, 40+high+1, GrWhite());
    grc = GrCreateSubContext(11, 41, 11+wide-1, 41+high-1, NULL, NULL);
    GrLoadContextFromPnm(grc,FIMAGEPBM);
    GrSaveContextToPbm(grc, FIMAGEPBM2, "TestPnm");
    GrDestroyContext(grc);
    GrTextXY(10, 50+high, "Press RETURN to continue", GrBlack(), GrWhite());
    GrEventWaitKeyOrClick(&ev);

    GrClearScreen(GrBlack());
    GrQueryPnm(FIMAGEPPM, &wide, &high, &maxval);
    GrBox(10, 40, 10+wide+1, 40+high+1, GrWhite());
    grc = GrCreateSubContext(11, 41, 11+wide-1, 41+high-1, NULL, NULL);
    GrLoadContextFromPnm(grc,FIMAGEPPM);
    GrDestroyContext(grc);
    GrQueryPnm(FIMAGEPGM, &wide, &high, &maxval);
    GrBox(110, 140, 110+wide+1, 140+high+1, GrWhite());
    grc = GrCreateSubContext(111, 141, 111+wide-1, 141+high-1, NULL, NULL);
    GrLoadContextFromPnm(grc, FIMAGEPGM);
    GrDestroyContext(grc);
    GrQueryPnm(FIMAGEPBM, &wide, &high, &maxval);
    GrBox(210, 240, 210+wide+1, 240+high+1, GrWhite());
    grc = GrCreateSubContext(211, 241, 211+wide-1, 241+high-1, NULL, NULL);
    GrLoadContextFromPnm(grc,FIMAGEPBM2);
    GrDestroyContext(grc);
    GrTextXY(10, 20, "Press RETURN to save screen", GrBlack(), GrWhite());
    GrEventWaitKeyOrClick(&ev);

    GrSaveContextToPpm(NULL, FSCREEN, "TestPnm");
    GrClearScreen(GrWhite());
    GrTextXY(10, 20, "Press RETURN to reload screen", GrWhite(), GrBlack());
    GrEventWaitKeyOrClick(&ev);

    GrLoadContextFromPnm(NULL, FSCREEN);
    GrTextXY(10, 20, "Press RETURN to end        ", GrBlack(), GrWhite());
    GrEventWaitKeyOrClick(&ev);

    GrEventUnInit();
    GrSetMode(GR_default_text);
    return 0;
}
示例#5
0
文件: w_system.c 项目: j13s/devil
void ws_displaymouse(void) {
    if (++ws_private.mousecounter >= 0) {
        ws_private.mousecounter = 0;
        GrMouseDisplayCursor();
    }
}
示例#6
0
文件: w_system.c 项目: j13s/devil
/* Reinit mouse colors (if palette is new) */
void ws_resetmousecolors(void) {
    GrMouseEraseCursor();
    GrMouseSetColors( w_makecolor(255, 255, 255), w_makecolor(0, 0, 0) );
    GrMouseUpdateCursor();
    GrMouseDisplayCursor();
}
示例#7
0
int main(void)
{
    GrContext *pContext;
    int sizex = 40;
    int sizey = 40;
    int x = 0;
    int y = 40;
    GrColor fcolor, bcolor;
    int k;
    GrEvent ev;

    GrSetMode(GR_default_graphics);
    GrEventInit();
    GrMouseDisplayCursor();
    /* Create a 1bpp bitmap */
    pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL);
    /* draw something (black and white) into the bitmap */
    GrSetContext(pContext);
    GrClearContext(GrBlack());
    GrLine(0, 0, sizex-1, sizey-1, GrWhite());
    GrLine(0, sizey-1, sizex-1, 0, GrWhite());

    GrSetContext(NULL);
    fcolor = GrAllocColor(255, 0, 0);
    bcolor = GrAllocColor(0, 0, 255);
    GrTextXY(0, 0, "Type u d l r U D L R to move, 1 2 to change color, q to quit",
           GrWhite(), GrNOCOLOR);
    GrSetClipBox(0, 40, GrScreenX(), GrScreenY());

    /* Put the bitmap into the screen */
    GrBitBlt1bpp(NULL, x, y, pContext, 0, 0, sizex-1, sizey-1, fcolor, bcolor);

    while (1) {
        k = '\0';
        GrEventWait(&ev);
        if (ev.type == GREV_KEY) k = ev.p1;
        if (k == 'q') break;
        switch (k) {
            case 'u': y--; break;
            case 'd': y++; break;
            case 'l': x--; break;
            case 'r': x++; break;
            case 'U': y -= 10; break;
            case 'D': y += 10; break;
            case 'L': x -= 10; break;
            case 'R': x += 10; break;
            case '1': fcolor = GrAllocColor(255, 0, 0);
                      bcolor = GrAllocColor(0, 0, 255);
                      break;
            case '2': fcolor = GrAllocColor(0, 255, 255);
                      bcolor = GrAllocColor(255, 255, 0);
                      break;
            default:  continue;
        }
        if (x < -40) x = -40;
        if (x > GrScreenX()) x = GrScreenX();
        if (y < 0) y = 0;
        if (y > GrScreenY()) y = GrScreenY();
        GrBitBlt1bpp( NULL, x, y, pContext, 0, 0, sizex-1, sizey-1, fcolor, bcolor);
    }

    /* Destroy */
    GrDestroyContext(pContext);

    GrEventUnInit();
    GrSetMode(GR_default_text);
    return 0;
}