コード例 #1
0
ファイル: chopper.c プロジェクト: Rockbox/rockbox
static void chopDrawPlayer(int x,int y) /* These are SCREEN coords, not world!*/
{

#if LCD_DEPTH > 2
    rb->lcd_set_foreground(LCD_RGBPACK(50,50,200));
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground(LCD_DARKGRAY);
#endif
    rb->lcd_fillrect(SCALE(x+6), SCALE(y+2), SCALE(12), SCALE(9));
    rb->lcd_fillrect(SCALE(x-3), SCALE(y+6), SCALE(20), SCALE(3));

#if LCD_DEPTH > 2
    rb->lcd_set_foreground(LCD_RGBPACK(50,50,50));
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground(LCD_DARKGRAY);
#endif
    rb->lcd_fillrect(SCALE(x+10), SCALE(y), SCALE(2), SCALE(3));
    rb->lcd_fillrect(SCALE(x+10), SCALE(y), SCALE(1), SCALE(3));

#if LCD_DEPTH > 2
    rb->lcd_set_foreground(LCD_RGBPACK(40,40,100));
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground(LCD_BLACK);
#endif
    rb->lcd_drawline(SCALE(x), SCALE(y+iRotorOffset), SCALE(x+20),
                     SCALE(y-iRotorOffset));

#if LCD_DEPTH > 2
    rb->lcd_set_foreground(LCD_RGBPACK(20,20,50));
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground(LCD_BLACK);
#endif
    rb->lcd_fillrect(SCALE(x - 2), SCALE(y + 5), SCALE(2), SCALE(5));

}
コード例 #2
0
ファイル: clix.c プロジェクト: Brandon7357/rockbox
/* Function for drawing a cell */
static void clix_draw_cell(struct clix_game_state_t* state, const int x, const int y)
{
    int realx = XOFS;
    int realy = YOFS;

    realx += x * (CELL_SIZE + 1);
    realy += y * (CELL_SIZE + 1);

    if (state->blink && state->board_selected[ XYPOS( x, y)]) {
        rb->lcd_set_foreground(LCD_WHITE);
    } else {
        switch (state->board[ XYPOS( x, y)])
        {
            case CC_BLUE:
                rb->lcd_set_foreground( LCD_RGBPACK( 25, 25, 255));
            break;
            case CC_GREEN:
                rb->lcd_set_foreground( LCD_RGBPACK( 25, 255, 25));
            break;
            case CC_RED:
                rb->lcd_set_foreground( LCD_RGBPACK( 255, 25, 25));
            break;
            case CC_YELLOW:
                rb->lcd_set_foreground( LCD_RGBPACK( 225, 225, 25));
            break;
            case CC_ORANGE:
                rb->lcd_set_foreground( LCD_RGBPACK( 230, 140, 15));
            break;
            case CC_CYAN:
                rb->lcd_set_foreground( LCD_RGBPACK( 25, 245, 230));
            break;
            case CC_BROWN:
                rb->lcd_set_foreground( LCD_RGBPACK(139, 69, 19));
            break;
            case CC_PINK:
                rb->lcd_set_foreground( LCD_RGBPACK(255, 105, 180));
            break;
            case CC_DARK_GREEN:
                rb->lcd_set_foreground( LCD_RGBPACK( 0, 100, 0));
            break;
            case CC_DARK_BLUE:
                rb->lcd_set_foreground( LCD_RGBPACK( 280, 32, 144));
            break;
            default:
                rb->lcd_set_foreground( LCD_BLACK);
            break;
        }
    }

    rb->lcd_fillrect( realx, realy, CELL_SIZE, CELL_SIZE);

    /* draw cursor */
    if ( x == state->x && y == state->y) {
        rb->lcd_set_foreground( LCD_WHITE);
        rb->lcd_drawrect( realx - 1, realy - 1, CELL_SIZE + 2, CELL_SIZE + 2);
    }
}
コード例 #3
0
int read_ppm_row(int fd, 
                 int const row, 
                 int const cols, 
                 int const rows,
                 int const maxval, 
                 int const format)
{
#if   !(defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE)
    (void) rows;
#endif

    int col;
    int r, g, b;
    switch (format) {
        case PPM_FORMAT:
            for (col = 0; col < cols; ++col) {
                r = ppm_getuint(fd);
                g = ppm_getuint(fd);
                b = ppm_getuint(fd);

                if (r == PLUGIN_ERROR || g == PLUGIN_ERROR ||
                    b == PLUGIN_ERROR)
                {
                    return PLUGIN_ERROR;
                } 
                *BUFADDR(col, row, cols, rows) = LCD_RGBPACK(
                    (255 / maxval) * r,
                    (255 / maxval) * g,
                    (255 / maxval) * b);
            }
            break;

        case RPPM_FORMAT:
            for (col = 0; col < cols; ++col) {
                r = ppm_getrawsample(fd, maxval);
                g = ppm_getrawsample(fd, maxval);
                b = ppm_getrawsample(fd, maxval);

                if (r == PLUGIN_ERROR || g == PLUGIN_ERROR ||
                    b == PLUGIN_ERROR)
                {
                    return PLUGIN_ERROR;
                } 
                *BUFADDR(col, row, cols, rows) = LCD_RGBPACK(
                    (255 / maxval) * r,
                    (255 / maxval) * g,
                    (255 / maxval) * b);
            }
            break;

        default:
            ppm_error("What?!");
            return PLUGIN_ERROR;
    }
    return 1;
}
コード例 #4
0
ファイル: remote_control.c プロジェクト: 4nykey/rockbox
/*****************************************************************************
* remote_control_setcolors() set the foreground and background colors.
******************************************************************************/
static inline void remote_control_setcolors(void)
{
#ifdef HAVE_LCD_COLOR
    rb->lcd_set_background(LCD_RGBPACK(181, 181, 222));
    rb->lcd_set_foreground(LCD_BLACK);
#endif
}
コード例 #5
0
ファイル: plasma.c プロジェクト: BurntBrunch/rockbox-fft
/* Make a smooth colour cycle. */
void shades_generate(int time)
{
    int i;
    unsigned red, green, blue;
    unsigned r = time * redfactor + redphase;
    unsigned g = time * greenfactor + greenphase;
    unsigned b = time * bluefactor + bluephase;

    for(i=0; i < 256; ++i)
    {
        r &= 0xFF; g &= 0xFF; b &= 0xFF;

        red = 2 * r;
        if (red > 255)
            red = 510 - red;
        green = 2 * g;
        if (green > 255)
            green = 510 - green;
        blue = 2 * b;
        if (blue > 255)
            blue= 510 - blue;

        colours[i] = LCD_RGBPACK(red, green, blue);

        r++; g++; b++;
    }
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
    rb->lcd_pal256_update_pal(colours);
#endif
}
コード例 #6
0
/*
 * Draws the yesno
 *  - yn : the yesno structure
 */
static void gui_yesno_draw(struct gui_yesno * yn)
{
    struct screen * display=yn->display;
    struct viewport *vp = yn->vp;
    int nb_lines, vp_lines, line_shift=0;

    display->set_viewport(vp);
    display->clear_viewport();
    nb_lines = yn->main_message->nb_lines;
    vp_lines = viewport_get_nb_lines(vp);

    if(nb_lines+3< vp_lines)
        line_shift=1;

    line_shift += put_message(display, yn->main_message,
                              line_shift, vp_lines);
#ifdef HAVE_TOUCHSCREEN
    if (display->screen_type == SCREEN_MAIN)
    {
        int w,h;
        int rect_w = vp->width/2, rect_h = vp->height/2;
        int old_pattern = vp->fg_pattern;
        vp->fg_pattern = LCD_RGBPACK(0,255,0);
        display->drawrect(0, rect_h, rect_w, rect_h);
        display->getstringsize(str(LANG_SET_BOOL_YES), &w, &h);
        display->putsxy((rect_w-w)/2, rect_h+(rect_h-h)/2, str(LANG_SET_BOOL_YES));
        vp->fg_pattern = LCD_RGBPACK(255,0,0);
        display->drawrect(rect_w, rect_h, rect_w, rect_h);
        display->getstringsize(str(LANG_SET_BOOL_NO), &w, &h);
        display->putsxy(rect_w + (rect_w-w)/2, rect_h+(rect_h-h)/2, str(LANG_SET_BOOL_NO));
        vp->fg_pattern = old_pattern;
    }
#else
    /* Space remaining for yes / no text ? */
    if(line_shift+2 <= vp_lines)
    {
        if(line_shift+3 <= vp_lines)
            line_shift++;
        display->puts(0, line_shift, str(LANG_CONFIRM_WITH_BUTTON));
#ifdef HAVE_LCD_BITMAP
        display->puts(0, line_shift+1, str(LANG_CANCEL_WITH_ANY));
#endif
    }
#endif
    display->update_viewport();
    display->set_viewport(NULL);
}
コード例 #7
0
ファイル: highscore.c プロジェクト: BurntBrunch/rockbox-fft
void highscore_show(int position, struct highscore *scores, int num_scores, bool show_level)
{
    int i, w, h;
    char str[30];
#define MARGIN 5
#ifdef HAVE_LCD_COLOR
    rb->lcd_set_background(LCD_BLACK);
    rb->lcd_set_foreground(LCD_WHITE);
#endif
    rb->lcd_clear_display();

    rb->lcd_setfont(FONT_UI);
    rb->lcd_getstringsize("High Scores", &w, &h);
    /* check wether it fits on screen */
    if ((4*h + h*(num_scores-1) + MARGIN) > LCD_HEIGHT) {
        rb->lcd_setfont(FONT_SYSFIXED);
        rb->lcd_getstringsize("High Scores", &w, &h);
    }
    rb->lcd_putsxy(LCD_WIDTH/2-w/2, MARGIN, "High Scores");
    rb->lcd_putsxy(LCD_WIDTH/4-w/4,2*h, "Score");
    
    /* Decide whether to display the level column or not */
    if(show_level) {
        rb->lcd_putsxy(LCD_WIDTH*3/4-w/4,2*h, "Level");
    }

    for (i = 0; i<num_scores; i++)
    {
#ifdef HAVE_LCD_COLOR
        if (i == position) {
            rb->lcd_set_foreground(LCD_RGBPACK(245,0,0));
        }
#endif
        rb->snprintf (str, sizeof (str), "%d)", i+1);
        rb->lcd_putsxy (MARGIN,3*h + h*i, str);
        rb->snprintf (str, sizeof (str), "%d", scores[i].score);
        rb->lcd_putsxy (LCD_WIDTH/4-w/4,3*h + h*i, str);
        
        /* Decide whether to display the level column or not */
        if(show_level) {
            rb->snprintf (str, sizeof (str), "%d", scores[i].level);
            rb->lcd_putsxy (LCD_WIDTH*3/4-w/4,3*h + h*i, str);
        }
        
        if(i == position) {
#ifdef HAVE_LCD_COLOR
            rb->lcd_set_foreground(LCD_WHITE);
#else
            rb->lcd_hline(MARGIN, LCD_WIDTH-MARGIN, 3*h + h*(i+1));
#endif
        }
    }
    rb->lcd_update();
    rb->sleep(HZ/2);
    rb->button_clear_queue();
    rb->button_get(true);
    rb->lcd_setfont(FONT_SYSFIXED);
}
コード例 #8
0
ファイル: chopper.c プロジェクト: Rockbox/rockbox
static void chopRenderTerrain(struct CTerrain *ter, bool isground)
{

    int i = 1;

    int oldx = 0;

    while(i < ter->iNodesCount && oldx < iScreenX)
    {

        int x = ter->mNodes[i-1].x - iCameraPosX;
        int y = ter->mNodes[i-1].y;

        int x2 = ter->mNodes[i].x - iCameraPosX;
        int y2 = ter->mNodes[i].y;

        int ax, ay;

        if ((y < y2) != isground)
        {
            ax = x2;
            ay = y;
        }
        else
        {
            ax = x;
            ay = y2;
        }
#if LCD_DEPTH > 2
        rb->lcd_set_foreground(LCD_RGBPACK(100,255,100));
#elif LCD_DEPTH == 2
        rb->lcd_set_foreground(LCD_DARKGRAY);
#endif

        rb->lcd_drawline(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2));

        xlcd_filltriangle(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2),
                          SCALE(ax), SCALE(ay));

        if (isground)
        {
            y = ay;
            y2 = (LCD_HEIGHT*SIZE);
        }
        else
        {
            y = 0;
            y2 = ay;
        }
        if (y2-y > 0)
            rb->lcd_fillrect(SCALE(x), SCALE(y), SCALE(x2-x)+1, SCALE(y2-y)+1);

        oldx = x;
        i++;
    }
}
コード例 #9
0
void draw_logo(struct screen* display){
#ifdef HAVE_LCD_COLOR
    if(display->is_color){
        display->set_foreground(LCD_BLACK);
        display->set_background(LCD_RGBPACK(180,200,230));
    }
#endif

    const struct picture* logo = &(logos[display->screen_type]);
    display->clear_display();
    picture_draw(display, logo, 0, 0);
}
コード例 #10
0
ファイル: chopper.c プロジェクト: Rockbox/rockbox
static void chopDrawBlock(struct CBlock *mBlock)
{
    int iPosX = (mBlock->iWorldX - iCameraPosX);
    int iPosY = (mBlock->iWorldY);
#if LCD_DEPTH > 2
    rb->lcd_set_foreground(LCD_RGBPACK(100,255,100));
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground(LCD_BLACK);
#endif
    rb->lcd_fillrect(SCALE(iPosX), SCALE(iPosY), SCALE(mBlock->iSizeX),
                     SCALE(mBlock->iSizeY));
}
コード例 #11
0
ファイル: sysvid_rockbox.c プロジェクト: foolsh/xrick
void sysvid_setPalette(img_color_t *pal, U16 n)
{
    U16 i;

    for (i = 0; i < n; i++)
    {
#ifdef HAVE_LCD_COLOR
        palette[i] = LCD_RGBPACK(pal[i].r, pal[i].g, pal[i].b);
#else
        palette[i] = ((3 * pal[i].r) + (6 * pal[i].g) + pal[i].b) / 10;
#endif
    }
}
コード例 #12
0
ファイル: chopper.c プロジェクト: Rockbox/rockbox
static void chopDrawParticle(struct CParticle *mParticle)
{

    int iPosX = (mParticle->iWorldX - iCameraPosX);
    int iPosY = (mParticle->iWorldY);
#if LCD_DEPTH > 2
    rb->lcd_set_foreground(LCD_RGBPACK(192,192,192));
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground(LCD_LIGHTGRAY);
#endif
    rb->lcd_fillrect(SCALE(iPosX), SCALE(iPosY), SCALE(3), SCALE(3));

}
コード例 #13
0
ファイル: sdl.c プロジェクト: theunamedguy/paintrun
int main(int argc, char* argv[])
{
    srand(7);
    plat_logf("SDL init");
    SDL_Init(SDL_INIT_VIDEO);
    screen = SDL_SetVideoMode(LCD_WIDTH, LCD_HEIGHT, 32, SDL_HWSURFACE | SDL_HWACCEL);

    SDL_EnableKeyRepeat(1, SDL_DEFAULT_REPEAT_INTERVAL);

    assert(screen != NULL);
    fgcol = LCD_RGBPACK(255,255,255);
    bgcol = LCD_RGBPACK(0,0,0);

    action = NONE;

    SDL_WM_SetCaption(GAME_TITLE, GAME_TITLE);
    atexit(SDL_Quit);

    plat_logf("TTF init");
    if(TTF_Init() < 0)
    {
        plat_logf("TTF init fail!\n");
    }

    gameover_font = TTF_OpenFont("/usr/share/fonts/TTF/LiberationSans-Regular.ttf", LCD_HEIGHT / 12);

    font = TTF_OpenFont("/usr/share/fonts/TTF/LiberationSans-Regular.ttf", LCD_HEIGHT / 24);

    if(!gameover_font)
    {
        plat_logf("WARNING: font loading failed");
    }

    atexit(TTF_Quit);

    dash_main();
    return 0;
}
コード例 #14
0
static inline void star_init(struct star * star, int z_move, bool color)
{
    star->velocity=rb->rand() % STAR_MAX_VELOCITY+1;
    /* choose x between -MAX_INIT_STAR_X and MAX_INIT_STAR_X */
    star->x=rb->rand() % (2*MAX_INIT_STAR_X)-MAX_INIT_STAR_X;
    star->y=rb->rand() % (2*MAX_INIT_STAR_Y)-MAX_INIT_STAR_Y;
#ifdef HAVE_LCD_COLOR
    if(color)
        star->color=LCD_RGBPACK(rb->rand()%128+128,rb->rand()%128+128,
                                rb->rand()%128+128);
    else
        star->color=LCD_WHITE;
#else
    (void)color;
#endif
    if(z_move>=0)
        star->z=Z_MAX_DIST;
    else
        star->z=rb->rand() %Z_MAX_DIST/2+1;
}
コード例 #15
0
ファイル: fire.c プロジェクト: realtsiry/rockbox4linux
/*
 * Color palette generation algorithm taken from
 * the "The Demo Effects Collection" GPL project
 * Copyright (C) 2002 W.P. van Paassen
 */
void color_palette_init(fb_data* palette)
{
    int i;
    for (i = 0; i < 32; i++){
        /* black to blue, 32 values*/
        palette[i]=LCD_RGBPACK(0, 0, 2*i);

        /* blue to red, 32 values*/
        palette[i +  32]=LCD_RGBPACK(8*i, 0, 64 - 2*i);

        /* red to yellow, 32 values*/
        palette[i +  64]=LCD_RGBPACK(255, 8*i, 0);

        /* yellow to white, 162 values */
        palette[i +  96]=LCD_RGBPACK(255, 255,   0 + 4*i);
        palette[i + 128]=LCD_RGBPACK(255, 255,  64 + 4*i);
        palette[i + 160]=LCD_RGBPACK(255, 255, 128 + 4*i);
        palette[i + 192]=LCD_RGBPACK(255, 255, 192 + i);
        palette[i + 224]=LCD_RGBPACK(255, 255, 224 + i);
    }
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
    rb->lcd_pal256_update_pal(palette);
#endif
}
コード例 #16
0
void GIO0(void)
{
    /* Mask GIO0 interrupt */
    IO_INTC_IRQ1 = INTR_IRQ1_EXT0;
    
    unsigned char msg[4];
    i2c_read(PIC_ADR, msg, sizeof(msg));
    tick_diff = current_tick - last_tick;
    last_tick = current_tick;
    unsigned short btn_press = le2short(msg);
    if(tick_diff >= TICK_MIN && tick_diff <= TICK_MAX)
    {
        /* Ignore this, as it is a hold event */
        return;
    }
    last_btn = btn_press;
    switch(btn_press)
    {
        map_button(BTN_LEFT,                 BUTTON_LEFT);
        map_button(BTN_RIGHT,                BUTTON_RIGHT);
        map_button(BTN_BACK,                 BUTTON_BACK);
        map_button(BTN_CUSTOM,               BUTTON_CUSTOM);
        map_button(BTN_MENU,                 BUTTON_MENU);
        map_button(BTN_PLAY,                 BUTTON_PLAY);
        map_button(BTN_POWER,                BUTTON_POWER);
        map_button(BTN_TOUCHPAD_PRESS,       BUTTON_SELECT);
        map_button(BTN_TOUCHPAD_CORNER_DOWN, BUTTON_DOWN);
        map_button(BTN_TOUCHPAD_CORNER_UP,   BUTTON_UP);
    #ifndef ZEN_VISION
    /* These don't seem to work for some reason on the Zen Vision.. */
    case BTN_TOUCHPAD_SCROLL_DOWN:
        btn = BUTTON_DOWN;
        break;
    case BTN_TOUCHPAD_SCROLL_UP:
        btn = BUTTON_UP;
        break;
    #endif
    case BTN_HOLD:
        hold_switch = true;
        break;
    case BTN_UNHOLD:
        hold_switch = false;
        break;
    #ifndef ZEN_VISION
    /* These don't seem to work for some reason.. */
    case HEADPHONE_PLUGIN_A:
    case HEADPHONE_PLUGIN_B:
        nonbtn |= NONBUTTON_HEADPHONE;
        break;
    case HEADPHONE_UNPLUG_A:
    case HEADPHONE_UNPLUG_B:
        nonbtn &= ~NONBUTTON_HEADPHONE;
        break;
    #endif
    case DOCK_INSERT:
        nonbtn |= NONBUTTON_DOCK;
        break;
    case DOCK_UNPLUG:
        nonbtn &= ~(NONBUTTON_DOCK | NONBUTTON_USB | NONBUTTON_POWER);
        break;
    case DOCK_USB_INSERT:
        nonbtn |= NONBUTTON_USB;
        break;
    case DOCK_USB_UNPLUG:
        nonbtn &= ~NONBUTTON_USB;
        break;
    case DOCK_POWER_INSERT:
        nonbtn |= NONBUTTON_POWER;
        break;
    case DOCK_POWER_UNPLUG:
        nonbtn &= ~NONBUTTON_POWER;
        break;
    }
#ifdef BUTTON_DEBUG
    unsigned char weergvn[10];
#ifdef BOOTLOADER
    lcd_set_foreground((sw ? LCD_RGBPACK(255,0,0) : LCD_RGBPACK(0,255,0) ));
#endif
    snprintf(weergvn, sizeof(char)*10, "%x",
             (unsigned int)((msg[3] << 24) |
                            (msg[2] << 16) | (msg[1] << 8) | msg[0]));
    lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*10,
               weergvn);
    snprintf(weergvn, sizeof(char)*10, "%x", btn);
    lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*10, LCD_HEIGHT-SYSFONT_HEIGHT*7,
               weergvn);
#ifdef BOOTLOADER
    lcd_set_foreground(LCD_BLACK);
#endif
    lcd_update();
    sw = !sw;
#endif
    logf("PIC: 0x%x", (unsigned int)((msg[3] << 24) |
                            (msg[2] << 16) | (msg[1] << 8) | msg[0]));
}
コード例 #17
0
/* plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
    int button = 0;
    enum touchscreen_mode mode = TOUCHSCREEN_BUTTON;

    /* standard stuff */
    (void)parameter;
    
    rb->touchscreen_set_mode(mode);

    /* wait until user closes plugin */
    do
    {
        short x = 0;
        short y = 0;
        bool draw_rect = false;
        
        button = rb->button_get(true);

        if (button & BUTTON_TOPLEFT)
        {
            draw_rect = true;
            x = 0; y = 0;
        }
        else if (button & BUTTON_TOPMIDDLE)
        {
            draw_rect = true;
            x = LCD_WIDTH/3; y = 0;
        }
        else if (button & BUTTON_TOPRIGHT)
        {
            draw_rect = true;
            x = 2*(LCD_WIDTH/3); y = 0;
        }
        else if (button & BUTTON_MIDLEFT)
        {
            draw_rect = true;
            x = 0; y = LCD_HEIGHT/3;
        }
        else if (button & BUTTON_CENTER)
        {
            draw_rect = true;
            x = LCD_WIDTH/3; y = LCD_HEIGHT/3;
        }
        else if (button & BUTTON_MIDRIGHT)
        {
            draw_rect = true;
            x = 2*(LCD_WIDTH/3); y = LCD_HEIGHT/3;
        }
        else if (button & BUTTON_BOTTOMLEFT)
        {
            draw_rect = true;
            x = 0; y = 2*(LCD_HEIGHT/3);
        }
        else if (button & BUTTON_BOTTOMMIDDLE)
        {
            draw_rect = true;
            x = LCD_WIDTH/3; y = 2*(LCD_HEIGHT/3);
        }
        else if (button & BUTTON_BOTTOMRIGHT)
        {
            draw_rect = true;
            x = 2*(LCD_WIDTH/3); y = 2*(LCD_HEIGHT/3);
        }

        if (button & TOUCHSCREEN_TOGGLE && (button & BUTTON_REL))
        {
            mode = (mode == TOUCHSCREEN_POINT) ? TOUCHSCREEN_BUTTON : TOUCHSCREEN_POINT;
            rb->touchscreen_set_mode(mode);
        }
        
        if (button & BUTTON_REL) draw_rect = false;

        rb->lcd_clear_display();

        if (draw_rect)
        {
            rb->lcd_set_foreground(LCD_RGBPACK(0xc0, 0, 0));
            rb->lcd_fillrect(x, y, LCD_WIDTH/3, LCD_HEIGHT/3);
        }

        if (draw_rect || button & BUTTON_TOUCHSCREEN)
        {
            intptr_t button_data = rb->button_get_data();
            x = button_data >> 16;
            y = button_data & 0xffff;

            rb->lcd_set_foreground(LCD_RGBPACK(0, 0, 0xc0));
            rb->lcd_fillrect(x-7, y-7, 14, 14);
            
            /* in stylus mode, show REL position in black */
            if (mode == TOUCHSCREEN_POINT && (button & BUTTON_REL))
                rb->lcd_set_foreground(LCD_BLACK);
            else
                rb->lcd_set_foreground(LCD_WHITE);

            rb->lcd_hline(x-5, x+5, y);
            rb->lcd_vline(x, y-5, y+5);
        }
        rb->lcd_update();

    } while (button != TOUCHSCREEN_QUIT);
コード例 #18
0
ファイル: fireworks.c プロジェクト: eisnerd/rockbox
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
    (void)parameter;

    int j, i;
    int thisrocket=0;
    int start_tick, elapsed_tick;
    int button;

    /* set everything up.. no BL timeout, no backdrop,
       white-text-on-black-background. */
    backlight_force_on(); /* backlight control in lib/helper.c */
#if LCD_DEPTH > 1
    rb->lcd_set_backdrop(NULL);
    rb->lcd_set_background(LCD_BLACK);
    rb->lcd_set_foreground(LCD_WHITE);
#endif

#ifdef HAVE_ADJUSTABLE_CPU_FREQ
    rb->cpu_boost(true);
#endif

    fireworks_menu();

    start_tick = *rb->current_tick;

    while(!quit_plugin)
    {
        rb->lcd_clear_display();

        /* loop through every possible rocket */
        for(j=0; j<MAX_ROCKETS; j++)
        {
            /* if the current rocket is actually moving/"alive" then go on and
             * move/update/explode it */
            if(rocket_phase[j] > -1)
            {
#ifdef HAVE_LCD_COLOR /* draw trail, if requested */
                if(show_rockets==2)
                {
                    rb->lcd_set_foreground(LCD_RGBPACK(128,128,128));
                    rb->lcd_fillrect(rocket_xpos[j], rocket_ypos[j],
                                     ROCKET_SIZE, ROCKET_SIZE);
                    rb->lcd_set_foreground(LCD_RGBPACK(64,64,64));
                    rb->lcd_fillrect(rocket_xpos[j]-rocket_xspeed[j],
                                     rocket_ypos[j]+rocket_yspeed[j],
                                     ROCKET_SIZE, ROCKET_SIZE);
                }
#endif

                /* move rocket */
                rocket_xpos[j] += rocket_xspeed[j];
                rocket_ypos[j] -= rocket_yspeed[j];

#ifdef HAVE_LCD_COLOR
                rb->lcd_set_foreground(LCD_WHITE);
#endif
                if(show_rockets==2 || show_rockets==1)
                    rb->lcd_fillrect(rocket_xpos[j], rocket_ypos[j],
                                     ROCKET_SIZE, ROCKET_SIZE);

                /* if(rocket isn't "there" yet) keep moving
                 * if(rocket IS there) explode it. */
                if(rocket_phase[j] < rocket_targetphase[j])
                    rocket_phase[j]++;
                else
                {
                    rocket_phase[j] = -1;

                    firework_phase[j] = 0;
                    init_explode(rocket_xpos[j], rocket_ypos[j], j,
                                 particle_values[particles_per_firework]);
                }
            }

            /* and now onto the fireworks for this particular rocket... */
            if(firework_phase[j] > -1)
            {
                for(i=0; i<particle_values[particles_per_firework]; i++)
                {
                    firework_xpoints[j][i] += firework_xspeed[j][i];
                    firework_ypoints[j][i] += firework_yspeed[j][i];

                    if(gravity != 0)
                        firework_ypoints[j][i] += firework_phase[j]
                                                  /gravity_values[gravity];

#ifdef HAVE_LCD_COLOR
                    rb->lcd_set_foreground(
                        firework_darkest_colors[firework_color[j][i]]);
                    rb->lcd_fillrect(firework_xpoints[j][i]-1,
                                     firework_ypoints[j][i]-1,
                                     FIREWORK_SIZE+2, FIREWORK_SIZE+2);

                    int phase_left = particle_life_values[particle_life]
                                     - firework_phase[j];
                    if(phase_left > 10)
                        rb->lcd_set_foreground(
                            firework_colors[firework_color[j][i]]);
                    else if(phase_left > 7)
                        rb->lcd_set_foreground(
                            firework_dark_colors[firework_color[j][i]]);
                    else if(phase_left > 3)
                        rb->lcd_set_foreground(
                            firework_darker_colors[firework_color[j][i]]);
                    else
                        rb->lcd_set_foreground(
                            firework_darkest_colors[firework_color[j][i]]);
#endif
                    rb->lcd_fillrect(firework_xpoints[j][i],
                                     firework_ypoints[j][i],
                                     FIREWORK_SIZE, FIREWORK_SIZE);
                    /* WIP - currently ugly explosion effect
                    #ifdef HAVE_LCD_COLOR
                                        if(firework_phase[j] < 10)
                                        {
                                            rb->lcd_set_foreground(EXPLOSION_COLOR);
                                            rb->lcd_fillrect(rocket_xpos[j]-firework_phase[j],
                                                             rocket_ypos[j]-firework_phase[j],
                                                             firework_phase[j]*2, firework_phase[j]*2);
                                        }
                    #endif */
                }

#ifdef HAVE_LCD_COLOR
                rb->lcd_set_foreground(LCD_WHITE);
#endif

                /* firework at its destination age?
                 * no = keep aging; yes = delete it. */
                if(firework_phase[j] < particle_life_values[particle_life])
                    firework_phase[j]++;
                else
                    firework_phase[j] = -1;
            }
        }

        /* is autofire on? */
        if(autofire_delay != 0)
        {
            elapsed_tick = *rb->current_tick - start_tick;

            if(elapsed_tick > autofire_delay_values[autofire_delay])
            {
                init_rocket(thisrocket);
                if(++thisrocket == MAX_ROCKETS)
                    thisrocket = 0;

                start_tick = *rb->current_tick;
            }
        }

        rb->lcd_update();

        button = rb->button_get_w_tmo(HZ/fps_values[frames_per_second]);
        switch(button)
        {
        case BTN_MENU: /* back to config menu */
            fireworks_menu();
            break;

        case BTN_FIRE: /* fire off rockets manually */
        case BTN_FIRE|BUTTON_REPEAT:
            init_rocket(thisrocket);
            if(++thisrocket == MAX_ROCKETS)
                thisrocket=0;
            break;
        }
    }
    /* Turn on backlight timeout (revert to settings) */
    backlight_use_settings(); /* backlight control in lib/helper.c */

#ifdef HAVE_ADJUSTABLE_CPU_FREQ
    rb->cpu_boost(false);
#endif

    return PLUGIN_OK;
}
コード例 #19
0
ファイル: fireworks.c プロジェクト: eisnerd/rockbox
int autofire_delay = 0;
int particles_per_firework = 2;
int particle_life = 1;
int gravity = 1;
int show_rockets = 1;
int frames_per_second = 4;
bool quit_plugin = false;

/* firework colors:
 * firework_colors = brightest firework color, used most of the time.
 * DARK colors = fireworks are nearly burnt out.
 * DARKER colors = fireworks are several frames away from burning out.
 * DARKEST colors = fireworks are a couple frames from burning out. */
#ifdef HAVE_LCD_COLOR
static const unsigned firework_colors[] = {
    LCD_RGBPACK(0,255,64), LCD_RGBPACK(61,255,249), LCD_RGBPACK(255,200,61),
    LCD_RGBPACK(217,22,217), LCD_RGBPACK(22,217,132), LCD_RGBPACK(67,95,254),
    LCD_RGBPACK(151,84,213)
};

static const unsigned firework_dark_colors[] = {
    LCD_RGBPACK(0,128,32), LCD_RGBPACK(30,128,128), LCD_RGBPACK(128,100,30),
    LCD_RGBPACK(109,11,109), LCD_RGBPACK(11,109,66), LCD_RGBPACK(33,47,128),
    LCD_RGBPACK(75,42,105)
};

static const unsigned firework_darker_colors[] = {
    LCD_RGBPACK(0,64,16), LCD_RGBPACK(15,64,64), LCD_RGBPACK(64,50,15),
    LCD_RGBPACK(55,5,55), LCD_RGBPACK(5,55,33), LCD_RGBPACK(16,24,64),
    LCD_RGBPACK(38,21,52)
};
コード例 #20
0
ファイル: lamp.c プロジェクト: a-martinez/rockbox
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
    long button;
    (void)parameter;

#ifdef HAVE_LCD_COLOR
    int cs = 0;
    bool quit = false;
#endif /* HAVE_LCD_COLOR */

#ifdef HAVE_BACKLIGHT_BRIGHTNESS
    short old_brightness = rb->global_settings->brightness;
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
    short old_buttonlight_brightness =
            rb->global_settings->buttonlight_brightness;
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */

#if LCD_DEPTH > 1
    unsigned bg_color=rb->lcd_get_background();
    rb->lcd_set_backdrop(NULL);
    rb->lcd_set_background(LCD_WHITE);
#endif

#ifdef HAVE_BACKLIGHT_BRIGHTNESS
    rb->backlight_set_brightness(MAX_BRIGHTNESS_SETTING);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
    rb->buttonlight_set_brightness(MAX_BRIGHTNESS_SETTING);
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */

#ifdef HAVE_LCD_INVERT
#ifdef HAVE_NEGATIVE_LCD
    rb->lcd_set_invert_display(true);
#else
    rb->lcd_set_invert_display(false);
#endif /* HAVE_NEGATIVE_LCD */
#endif /* HAVE_LCD_INVERT */

    backlight_force_on();
#ifdef HAVE_BUTTON_LIGHT
    buttonlight_force_on();
#endif /* HAVE_BUTTON_LIGHT */

#ifdef HAVE_LCD_COLOR
    do
    {
        if(cs < 0)
            cs = NUM_COLORSETS-1;
        if(cs >= NUM_COLORSETS)
            cs = 0;
        rb->lcd_set_background( LCD_RGBPACK( colorset[cs][0],
                                colorset[cs][1],
                                colorset[cs][2] ) );
        rb->lcd_clear_display();
        rb->lcd_update();

        switch((button = rb->button_get(true)))
        {
            case LAMP_RIGHT:
#ifdef LAMP_NEXT
            case LAMP_NEXT:
#endif /* LAMP_NEXT */
                cs++;
                break;

            case LAMP_LEFT:
#ifdef LAMP_PREV
            case LAMP_PREV:
#endif /* LAMP_PREV */
                cs--;
                break;

            case (LAMP_RIGHT|BUTTON_REPEAT):
            case (LAMP_RIGHT|BUTTON_REL):
            case (LAMP_LEFT|BUTTON_REPEAT):
            case (LAMP_LEFT|BUTTON_REL):
#ifdef LAMP_NEXT
            case (LAMP_NEXT|BUTTON_REPEAT):
            case (LAMP_NEXT|BUTTON_REL):
#endif /* LAMP_NEXT */
#ifdef LAMP_PREV
            case (LAMP_PREV|BUTTON_REPEAT):
            case (LAMP_PREV|BUTTON_REL):
#endif /* LAMP_PREV */
                /* eat these... */
                break;    
            default:
                    quit = true;
        }
    } while (!quit);

#else /* HAVE_LCD_COLOR */
    rb->lcd_clear_display();
    rb->lcd_update();
    /* wait */
    do
    {
        button = rb->button_get(false);
        if (button && !IS_SYSEVENT(button))
            break;
        rb->yield();
    } while (1);

#endif /*HAVE_LCD_COLOR */

    /* restore */
    backlight_use_settings();
#ifdef HAVE_BUTTON_LIGHT
    buttonlight_use_settings();
#endif /* HAVE_BUTTON_LIGHT */

#ifdef HAVE_LCD_INVERT
    rb->lcd_set_invert_display(rb->global_settings->invert);
#endif /* HAVE_LCD_INVERT */

#ifdef HAVE_BACKLIGHT_BRIGHTNESS
    rb->backlight_set_brightness(old_brightness);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
    rb->buttonlight_set_brightness(old_buttonlight_brightness);
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */

#if LCD_DEPTH > 1
    rb->lcd_set_background(bg_color);
#endif
    return PLUGIN_OK;
}
コード例 #21
0
ファイル: button-fuzeplus.c プロジェクト: IlVerz/rockbox
void button_debug_screen(void)
{
    char product_id[RMI_PRODUCT_ID_LEN];
    rmi_read(RMI_PRODUCT_ID, RMI_PRODUCT_ID_LEN, product_id);
    int x_max = rmi_read_single(RMI_2D_SENSOR_XMAX_MSB(0)) << 8 | rmi_read_single(RMI_2D_SENSOR_XMAX_LSB(0));
    int y_max = rmi_read_single(RMI_2D_SENSOR_YMAX_MSB(0)) << 8 | rmi_read_single(RMI_2D_SENSOR_YMAX_LSB(0));
    int func_presence = rmi_read_single(RMI_FUNCTION_PRESENCE(RMI_2D_TOUCHPAD_FUNCTION));
    int sensor_prop = rmi_read_single(RMI_2D_SENSOR_PROP2(0));
    int sensor_resol = rmi_read_single(RMI_2D_SENSOR_RESOLUTION(0));
    int min_dist = rmi_read_single(RMI_2D_MIN_DIST);
    int gesture_settings = rmi_read_single(RMI_2D_GESTURE_SETTINGS);
    union
    {
        unsigned char data;
        signed char value;
    }sensitivity;
    rmi_read(RMI_2D_SENSITIVITY_ADJ, 1, &sensitivity.data);

    /* Device to screen */
    int zone_w = LCD_WIDTH;
    int zone_h = (zone_w * y_max + x_max - 1) / x_max;
    int zone_x = 0;
    int zone_y = LCD_HEIGHT - zone_h;
    #define DX2SX(x) (((x) * zone_w ) / x_max)
    #define DY2SY(y) (zone_h - ((y) * zone_h ) / y_max)
    struct viewport report_vp;
    memset(&report_vp, 0, sizeof(report_vp));
    report_vp.x = zone_x;
    report_vp.y = zone_y;
    report_vp.width = zone_w;
    report_vp.height = zone_h;
    struct viewport gesture_vp;
    memset(&gesture_vp, 0, sizeof(gesture_vp));
    gesture_vp.x = 0;
    gesture_vp.y = zone_y - 80;
    gesture_vp.width = LCD_WIDTH;
    gesture_vp.height = 80;
    
    while(1)
    {
        lcd_set_viewport(NULL);
        lcd_clear_display();
        int btns = button_read_device();
        lcd_putsf(0, 0, "button bitmap: %x", btns);
        lcd_putsf(0, 1, "RMI: id=%s p=%x s=%x", product_id, func_presence, sensor_prop);
        lcd_putsf(0, 2, "xmax=%d ymax=%d res=%d", x_max, y_max, sensor_resol);
        lcd_putsf(0, 3, "attn=%d ctl=%x int=%x",
            imx233_get_gpio_input_mask(0, 0x08000000) ? 0 : 1,
            rmi_read_single(RMI_DEVICE_CONTROL),
            rmi_read_single(RMI_INTERRUPT_REQUEST));
        lcd_putsf(0, 4, "sensi: %d min_dist: %d", (int)sensitivity.value, min_dist);
        lcd_putsf(0, 5, "gesture: %x", gesture_settings);
        
        union
        {
            unsigned char data[10];
            struct
            {
                struct rmi_2d_absolute_data_t absolute;
                struct rmi_2d_relative_data_t relative;
                struct rmi_2d_gesture_data_t gesture;
            }s;
        }u;
        int absolute_x = u.s.absolute.x_msb << 8 | u.s.absolute.x_lsb;
        int absolute_y = u.s.absolute.y_msb << 8 | u.s.absolute.y_lsb;
        int nr_fingers = u.s.absolute.misc & 7;
        bool gesture = (u.s.absolute.misc & 8) == 8;
        int palm_width = u.s.absolute.misc >> 4;
        rmi_read(RMI_DATA_REGISTER(0), 10, u.data);
        lcd_putsf(0, 6, "abs: %d %d %d", absolute_x, absolute_y, (int)u.s.absolute.z);
        lcd_putsf(0, 7, "rel: %d %d", (int)u.s.relative.x, (int)u.s.relative.y);
        lcd_putsf(0, 8, "gesture: %x %x", u.s.gesture.misc, u.s.gesture.flick);
        lcd_putsf(0, 9, "misc: w=%d g=%d f=%d", palm_width, gesture, nr_fingers);

        lcd_set_viewport(&report_vp);
        lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0, 0), LCD_BLACK);
        lcd_drawrect(0, 0, zone_w, zone_h);
        if(nr_fingers == 1)
        {
            lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0, 0, 0xff), LCD_BLACK);
            lcd_drawline(DX2SX(absolute_x) - u.s.relative.x,
                DY2SY(absolute_y) + u.s.relative.y,
                DX2SX(absolute_x), DY2SY(absolute_y));
            lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0, 0xff, 0), LCD_BLACK);
            lcd_fillrect(DX2SX(absolute_x) - 1, DY2SY(absolute_y) - 1, 3, 3);
        }
        lcd_set_viewport(&gesture_vp);
        lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0xff, 0), LCD_BLACK);
        if(u.s.gesture.misc & RMI_2D_GEST_MISC_CONFIRMED)
        {
            switch(u.s.gesture.misc & RMI_2D_GEST_MISC_TAP_CODE_BM)
            {
                case RMI_2D_GEST_MISC_NO_TAP: break;
                case RMI_2D_GEST_MISC_SINGLE_TAP:
                    lcd_putsf(0, 0, "TAP!");
                    break;
                case RMI_2D_GEST_MISC_DOUBLE_TAP:
                    lcd_putsf(0, 0, "DOUBLE TAP!");
                    break;
                case RMI_2D_GEST_MISC_TAP_AND_HOLD:
                    lcd_putsf(0, 0, "TAP & HOLD!");
                    break;
                default: break;
            }
            
            if(u.s.gesture.misc & RMI_2D_GEST_MISC_FLICK)
            {
                lcd_putsf(0, 1, "FLICK!");
                int flick_x = u.s.gesture.flick & RMI_2D_GEST_FLICK_X_BM;
                int flick_y = (u.s.gesture.flick & RMI_2D_GEST_FLICK_Y_BM) >> RMI_2D_GEST_FLICK_Y_BP;
                #define SIGN4EXT(a) \
                    if(a & 8) a = -((a ^ 0xf) + 1);
                SIGN4EXT(flick_x);
                SIGN4EXT(flick_y);
                
                int center_x = (LCD_WIDTH * 2) / 3;
                int center_y = 40;
                lcd_drawline(center_x, center_y, center_x + flick_x * 5, center_y - flick_y * 5);
            }
        }
        lcd_update();
        
        if(btns & BUTTON_POWER)
            break;
        if(btns & BUTTON_VOL_DOWN || btns & BUTTON_VOL_UP)
        {
            if(btns & BUTTON_VOL_UP)
                sensitivity.value++;
            if(btns & BUTTON_VOL_DOWN)
                sensitivity.value--;
            rmi_write(RMI_2D_SENSITIVITY_ADJ, 1, &sensitivity.data);
        }
        
        yield();
    }
コード例 #22
0
    hour = (hour % 12) * 5 + minute / 12;

    rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);

    /* draw a circle */
    for(i = 1; i < 60; i += 3) 
        rb->lcd_drawline(xminute[i], yminute[i],
                         xminute[(i+1)%60], yminute[(i+1)%60]);
}
#endif /* CONFIG_RTC */

#if LCD_DEPTH > 1
static const unsigned face_colors[] =
{
#ifdef HAVE_LCD_COLOR
    LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
#else
    LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
#endif
};
#endif

static int scrollit(void)
{
    int b;
    unsigned int y=100;
    unsigned int yy;
    int x = LCD_WIDTH;
    int xx;
    unsigned int i;
    unsigned int textpos=0;
コード例 #23
0
bool quit = false;
bool sound_on;
BYTE final_wave[2048 * 2];
int waveptr;
int wavflag;
int wavdone;

WORD *wfx;

DWORD dwPad1;
DWORD dwPad2;
DWORD dwSystem;

WORD NesPalette[ 64 ] =
{
LCD_RGBPACK(117, 117, 117) , LCD_RGBPACK(39, 27, 143) , LCD_RGBPACK(0, 0, 171) , LCD_RGBPACK(71, 0, 159) , LCD_RGBPACK(143, 0, 119) , LCD_RGBPACK(171, 0, 19) , LCD_RGBPACK(167, 0, 0) , LCD_RGBPACK(127, 11, 0) , LCD_RGBPACK(67, 47, 0) , LCD_RGBPACK(0, 71, 0) , LCD_RGBPACK(0, 81, 0) , LCD_RGBPACK(0, 63, 23) , LCD_RGBPACK(27, 63, 95) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(188, 188, 188) , LCD_RGBPACK(0, 115, 239) , LCD_RGBPACK(35, 59, 239) , LCD_RGBPACK(131, 0, 243) , LCD_RGBPACK(191, 0, 191) , LCD_RGBPACK(231, 0, 91) , LCD_RGBPACK(219, 43, 0) , LCD_RGBPACK(203, 79, 15) , LCD_RGBPACK(139, 115, 0) , LCD_RGBPACK(0, 151, 0) , LCD_RGBPACK(0, 171, 0) , LCD_RGBPACK(0, 147, 59) , LCD_RGBPACK(0, 131, 139) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(255, 255, 255) , LCD_RGBPACK(63, 191, 255) , LCD_RGBPACK(95, 151, 255) , LCD_RGBPACK(167, 139, 253) , LCD_RGBPACK(247, 123, 255) , LCD_RGBPACK(255, 119, 183) , LCD_RGBPACK(255, 119, 99) , LCD_RGBPACK(255, 155, 59) , LCD_RGBPACK(243, 191, 63) , LCD_RGBPACK(131, 211, 19) , LCD_RGBPACK(79, 223, 75) , LCD_RGBPACK(88, 248, 152) , LCD_RGBPACK(0, 235, 219) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(255, 255, 255) , LCD_RGBPACK(171, 231, 255) , LCD_RGBPACK(199, 215, 255) , LCD_RGBPACK(215, 203, 255) , LCD_RGBPACK(255, 199, 255) , LCD_RGBPACK(255, 199, 219) , LCD_RGBPACK(255, 191, 179) , LCD_RGBPACK(255, 219, 171) , LCD_RGBPACK(255, 231, 163) , LCD_RGBPACK(227, 255, 163) , LCD_RGBPACK(171, 243, 191) , LCD_RGBPACK(179, 255, 207) , LCD_RGBPACK(159, 255, 243) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0) , LCD_RGBPACK(0, 0, 0)
};

BYTE NesPaletteRGB[64][3] = {
 { 112, 112, 112, },{ 32,  24, 136, },{  0,   0, 168, },{ 64,   0, 152,},
 { 136,   0, 112, },{168,   0,  16, },{160,   0,   0, },{120,   8,   0,},
 {  64,  40,   0, },{  0,  64,   0, },{  0,  80,   0, },{  0,  56,  16,},
 {  24,  56,  88, },{  0,   0,   0, },{  0,   0,   0, },{  0,   0,   0,},
 { 184, 184, 184, },{  0, 112, 232, },{ 32,  56, 232, },{128,   0, 240,},
 { 184,   0, 184, },{224,   0,  88, },{216,  40,   0, },{200,  72,   8,},
 { 136, 112,   0, },{  0, 144,   0, },{  0, 168,   0, },{  0, 144,  56,},
 {   0, 128, 136, },{  0,   0,   0, },{  0,   0,   0, },{  0,   0,   0,},
 { 248, 248, 248, },{ 56, 184, 248, },{ 88, 144, 248, },{ 64, 136, 248,},
 { 240, 120, 248, },{248, 112, 176, },{248, 112,  96, },{248, 152,  56,},
 { 240, 184,  56, },{128, 208,  16, },{ 72, 216,  72, },{ 88, 248, 152,},
 {   0, 232, 216, },{  0,   0,   0, },{  0,   0,   0, },{  0,   0,   0,},
コード例 #24
0
enum plugin_status plugin_start(const void* parameter)
{
    int button;
#ifdef MAZE_NEW_PRE
    int lastbutton = BUTTON_NONE;
#endif
    int quit = 0;
    struct maze maze;
    (void)parameter;

    /* Turn off backlight timeout */
    backlight_ignore_timeout();

    /* Seed the RNG */
    rb->srand(*rb->current_tick);

    FOR_NB_SCREENS(i)
        rb->screens[i]->set_viewport(NULL);

    /* Draw the background */
#if LCD_DEPTH > 1
    rb->lcd_set_backdrop(NULL);
#if LCD_DEPTH >= 16
    rb->lcd_set_foreground(LCD_RGBPACK( 0, 0, 0));
    rb->lcd_set_background(LCD_RGBPACK(182, 198, 229)); /* rockbox blue */
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground(0);
    rb->lcd_set_background(LCD_DEFAULT_BG);
#endif
#endif

    /* Initialize and draw the maze */
    maze_init(&maze);
    maze_generate(&maze);
    FOR_NB_SCREENS(i)
        maze_draw(&maze, rb->screens[i]);

    while(!quit) {
#ifdef __PLUGINLIB_ACTIONS_H__
        button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts,
                ARRAYLEN(plugin_contexts));
#else
        button = rb->button_get(true);
#endif
        switch(button) {
        case MAZE_NEW:
#ifdef MAZE_NEW_PRE
            if(lastbutton != MAZE_NEW_PRE)
                break;
#endif
            maze_init(&maze);
            maze_generate(&maze);
            FOR_NB_SCREENS(i)
                maze_draw(&maze, rb->screens[i]);
            break;
        case MAZE_SOLVE:
            maze_solve(&maze);
            FOR_NB_SCREENS(i)
                maze_draw(&maze, rb->screens[i]);
            break;
        case MAZE_UP:
        case MAZE_UP_REPEAT:
            maze_move_player_up(&maze);
            FOR_NB_SCREENS(i)
                maze_draw(&maze, rb->screens[i]);
            break;
        case MAZE_RIGHT:
        case MAZE_RIGHT_REPEAT:
            maze_move_player_right(&maze);
            FOR_NB_SCREENS(i)
                maze_draw(&maze, rb->screens[i]);
            break;
        case MAZE_DOWN:
        case MAZE_DOWN_REPEAT:
            maze_move_player_down(&maze);
            FOR_NB_SCREENS(i)
                maze_draw(&maze, rb->screens[i]);
            break;
        case MAZE_LEFT:
        case MAZE_LEFT_REPEAT:
            maze_move_player_left(&maze);
            FOR_NB_SCREENS(i)
                maze_draw(&maze, rb->screens[i]);
            break;
        case MAZE_QUIT:
            /* quit plugin */
            quit=1;
            break;
        default:
            if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
                /* quit plugin */
                quit=2;
            }
            break;
        }
#ifdef MAZE_NEW_PRE
        if( button != BUTTON_NONE )
            lastbutton = button;
#endif
    }
    /* Turn on backlight timeout (revert to settings) */
    backlight_use_settings();
    return ((quit == 1) ? PLUGIN_OK : PLUGIN_USB_CONNECTED);
}
コード例 #25
0
static void maze_draw(struct maze* maze, struct screen* display)
{
    int x, y;
    int wx, wy;
    int point_width, point_height, point_offset_x, point_offset_y;
    uint8_t cell;

    /* calculate the size variables */

    wx = (int) display->lcdwidth / MAZE_WIDTH;
    wy = (int) display->lcdheight / MAZE_HEIGHT;

    if(wx>3){
        point_width=wx-3;
        point_offset_x=2;
    }else{
        point_width=1;
        point_offset_x=1;
    }

    if(wy>3){
        point_height=wy-3;
        point_offset_y=2;
    }else{
        point_height=1;
        point_offset_y=1;
    }

    /* start drawing */

    display->clear_display();

    /* draw the walls */
    for(y=0; y<MAZE_HEIGHT; y++){
        for(x=0; x<MAZE_WIDTH; x++){
            cell = maze->maze[x][y];
            if(cell & WALL_N)
                display->hline(x*wx, x*wx+wx, y*wy);
            if(cell & WALL_E)
                display->vline(x*wx+wx, y*wy, y*wy+wy);
            if(cell & WALL_S)
                display->hline(x*wx, x*wx+wx, y*wy+wy);
            if(cell & WALL_W)
                display->vline(x*wx, y*wy, y*wy+wy);
        }
    }

    /* draw the path */
    if(maze->show_path){
#if LCD_DEPTH >= 16
        if(display->depth>=16)
            display->set_foreground(LCD_RGBPACK(127,127,127));
#endif
#if LCD_DEPTH >= 2
        if(display->depth==2)
            display->set_foreground(1);
#endif

        /* highlight the path */
        for(y=0; y<MAZE_HEIGHT; y++){
            for(x=0; x<MAZE_WIDTH; x++){
                cell = maze->maze[x][y];
                if(cell & PATH)
                    display->fillrect(x*wx+point_offset_x,
                                      y*wy+point_offset_y,
                                      point_width, point_height);
            }
        }

        /* link the cells in the path together */
        for(y=0; y<MAZE_HEIGHT; y++){
            for(x=0; x<MAZE_WIDTH; x++){
                cell = maze->maze[x][y];
                if(cell & PATH){
                    if(!(cell & WALL_N) && (maze->maze[x][y-1] & PATH))
                        display->fillrect(x*wx+point_offset_x,
                                          y*wy,
                                          point_width, wy-point_height);
                    if(!(cell & WALL_E) && (maze->maze[x+1][y] & PATH))
                        display->fillrect(x*wx+wx-point_offset_x,
                                          y*wy+point_offset_y,
                                          wx-point_width, point_height);
                    if(!(cell & WALL_S) && (maze->maze[x][y+1] & PATH))
                        display->fillrect(x*wx+point_offset_x,
                                          y*wy+wy-point_offset_y,
                                          point_width, wy-point_height);
                    if(!(cell & WALL_W) && (maze->maze[x-1][y] & PATH))
                        display->fillrect(x*wx,
                                          y*wy+point_offset_y,
                                          wx-point_width, point_height);
                }
            }
        }

#if LCD_DEPTH >= 16
        if(display->depth>=16)
            display->set_foreground(LCD_RGBPACK(0,0,0));
#endif
#if LCD_DEPTH >= 2
        if(display->depth==2)
            display->set_foreground(0);
#endif
    }

    /* mark start and end */
    display->drawline(0, 0, wx, wy);
    display->drawline(0, wy, wx, 0);
    display->drawline((MAZE_WIDTH-1)*wx,(MAZE_HEIGHT-1)*wy,
                     (MAZE_WIDTH-1)*wx+wx, (MAZE_HEIGHT-1)*wy+wy);
    display->drawline((MAZE_WIDTH-1)*wx,(MAZE_HEIGHT-1)*wy+wy,
                     (MAZE_WIDTH-1)*wx+wx, (MAZE_HEIGHT-1)*wy);

    /* draw current position */
    display->fillrect(maze->player_x*wx+point_offset_x,
                      maze->player_y*wy+point_offset_y,
                      point_width, point_height);

    /* update the display */
    display->update();
}
コード例 #26
0
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
    (void)parameter;

    b = rb->lcd_framebuffer;

    rb->lcd_set_background(LCD_RGBPACK(0,0,0));
    rb->lcd_clear_display(); // TODO: Optimizes this by e.g. invalidating rects

    input_bmp.data = (char*)input_bmp_data;
    output_bmp.data = (char*)output_bmp_data;

    int ret = rb->read_bmp_file("/test.bmp", &input_bmp, sizeof(input_bmp_data),
                                FORMAT_NATIVE, NULL);

    if (ret < 0) {
        rb->splash(HZ, "Could not load /test.bmp");
        return PLUGIN_ERROR;
    }

    int button;
    output_bmp.width = 50;
    output_bmp.height = 50;

    DEBUGF("input_bmp_data starts at %p\n", input_bmp_data);
    DEBUGF("output_bmp_data starts at %p\n", output_bmp_data);

    int scale_algorithm = 0;

    while(1) {
        rb->lcd_clear_display();
        rb->lcd_bitmap(input_bmp_data, 0, 0, input_bmp.width, input_bmp.height);

        switch ( scale_algorithm ) {
            case 0:
                smooth_resize_bitmap(&input_bmp, &output_bmp);
                rb->lcd_putsxy(0,0,"smooth_resize_bitmap");
                break;
            case 1:
                simple_resize_bitmap(&input_bmp, &output_bmp);
                rb->lcd_putsxy(0,0,"simple_resize_bitmap");
                break;
        }

        rb->lcd_bitmap(output_bmp_data, 0, 100, output_bmp.width,
                       output_bmp.height);

        rb->lcd_update();
        button = pluginlib_getaction(HZ, plugin_contexts,
                        ARRAYLEN(plugin_contexts));
        switch (button) {
            case BUTTON_QUIT:
                return PLUGIN_OK;
            case SIZE_INCREASE:
            case SIZE_INCREASE_REPEAT:
                if (output_bmp.width < MAX_OUTPUT_WIDTH - 2)
                    output_bmp.width += 2;
                if (output_bmp.height < MAX_OUTPUT_HEIGHT - 2)
                    output_bmp.height += 2;
                break;

            case SIZE_DECREASE:
            case SIZE_DECREASE_REPEAT:
                if (output_bmp.width > 2) output_bmp.width -= 2;
                if (output_bmp.height > 2) output_bmp.height -= 2;
                break;

            case WIDTH_INCREASE:
            case WIDTH_INCREASE_REPEAT:
                if (output_bmp.width < MAX_OUTPUT_WIDTH - 2)
                    output_bmp.width += 2;
                break;

            case WIDTH_DECREASE:
            case WIDTH_DECREASE_REPEAT:
                if (output_bmp.width > 2) output_bmp.width -= 2;
                break;

            case CHANGE_MODE:
                scale_algorithm = (scale_algorithm+1)%2;
                break;
        }
    }
    return PLUGIN_OK;
}
コード例 #27
0
bool display_text(unsigned short words, char** text, struct style_text* style,
                  struct viewport* vp_text, bool wait_key)
{
#ifdef HAVE_LCD_BITMAP
    int prev_drawmode;
#endif
#ifdef HAVE_LCD_COLOR
    int standard_fgcolor;
#endif
    int space_w, width, height;
    unsigned short x , y;
    unsigned short vp_width = LCD_WIDTH;
    unsigned short vp_height = LCD_HEIGHT;
    unsigned short i = 0, style_index = 0;
    if (vp_text != NULL) {
        vp_width = vp_text->width;
        vp_height = vp_text->height;
    }
    rb->screens[SCREEN_MAIN]->set_viewport(vp_text);
#ifdef HAVE_LCD_BITMAP
    prev_drawmode = rb->lcd_get_drawmode();
    rb->lcd_set_drawmode(DRMODE_SOLID);
#endif
#ifdef HAVE_LCD_COLOR
    standard_fgcolor = rb->lcd_get_foreground();
#endif
    rb->screens[SCREEN_MAIN]->clear_viewport();
    x = MARGIN;
    y = MARGIN;
    rb->button_clear_queue();
    rb->lcd_getstringsize(" ", &space_w, &height);
    for (i = 0; i < words; i++) {
        rb->lcd_getstringsize(text[i], &width, NULL);
        /* skip to next line if the word is an empty string */
        if (rb->strcmp(text[i], "")==0) {
            x = MARGIN;
            y = y + height;
            continue;
        /* .. or if the current one can't fit the word */
        } else if (x + width > vp_width - MARGIN) {
            x = MARGIN;
            y = y + height;
        }
        /* display the remaining text by button click or exit */
        if (y + height > vp_height - MARGIN) {
            y = MARGIN;
            rb->screens[SCREEN_MAIN]->update_viewport();
            if (wait_key_press())
                return true;
            rb->screens[SCREEN_MAIN]->clear_viewport();
        }
        /* no text formatting available */
        if (style==NULL || style[style_index].index != i) {
            rb->lcd_putsxy(x, y, text[i]);
        } else {
            /* set align */
            if (style[style_index].flags&TEXT_CENTER) {
                x = (vp_width-width)/2;
            }
            /* set font color */
#ifdef HAVE_LCD_COLOR
            switch (style[style_index].flags&TEXT_COLOR_MASK) {
                case C_RED:
                    rb->lcd_set_foreground(LCD_RGBPACK(255,0,0));
                    break;
                case C_YELLOW:
                    rb->lcd_set_foreground(LCD_RGBPACK(255,255,0));
                    break;
                case C_GREEN:
                    rb->lcd_set_foreground(LCD_RGBPACK(0,192,0));
                    break;
                case C_BLUE:
                    rb->lcd_set_foreground(LCD_RGBPACK(0,0,255));
                    break;
                case C_ORANGE:
                    rb->lcd_set_foreground(LCD_RGBPACK(255,192,0));
                    break;
                case STANDARD:
                default:
                    rb->lcd_set_foreground(standard_fgcolor);
                    break;
            }
#endif
            rb->lcd_putsxy(x, y, text[i]);
            /* underline the word */
#ifdef HAVE_LCD_BITMAP
            if (style[style_index].flags&TEXT_UNDERLINE) {
                rb->lcd_hline(x, x+width, y+height-1);
            }
#endif
#ifdef HAVE_LCD_COLOR
            rb->lcd_set_foreground(standard_fgcolor);
#endif
            style_index++;
        }
        x += width + space_w;
    }
    rb->screens[SCREEN_MAIN]->update_viewport();
#ifdef HAVE_LCD_BITMAP
    rb->lcd_set_drawmode(prev_drawmode);
#endif
    if (wait_key)
    {
        if (wait_key_press())
            return true;
    }
    return false;
}
コード例 #28
0
ファイル: rockblox.c プロジェクト: josephks/rockbox
struct figure
{
#if LCD_DEPTH >= 2
    unsigned int color[3];    /* color of figure (light,middle,shadow) */
#endif
    unsigned short max_or;      /* max orientations */
    signed short shapeX[4], shapeY[4];  /* implementation of figures */
}

/* array of figures */
figures[BLOCKS_NUM] = {
        /* O */
    {
#if LCD_DEPTH >= 16
        {LCD_RGBPACK (153, 255, 255), LCD_RGBPACK(0, 255, 255),
                LCD_RGBPACK(0,153,153)},
#elif LCD_DEPTH  == 2
        {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
#endif
        1,
        {-1, 0, -1, 0},
        {0, 0, 1, 1}
    },
        /* I */
    {
#if LCD_DEPTH >= 16
        {LCD_RGBPACK (255, 153, 128), LCD_RGBPACK (255, 0, 0),
                LCD_RGBPACK (153, 0, 0)},
#elif LCD_DEPTH  == 2
        {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
コード例 #29
0
ファイル: rockblox.c プロジェクト: josephks/rockbox
/* draws the preview of next block in the preview window */
static void draw_next_block (void)
{
    int i, rx, ry;
    /* clear preview window first */
#if LCD_DEPTH >= 2
    rb->lcd_set_foreground (LCD_BLACK);
#elif LCD_DEPTH == 1
    mylcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID);
#endif

    /* 4x4 */
    mylcd_fillrect (PREVIEW_X, PREVIEW_Y, BLOCK_WIDTH * 4, BLOCK_HEIGHT * 4);

#if LCD_DEPTH == 1
    mylcd_set_drawmode (DRMODE_SOLID);
#endif

    /* draw the lightgray rectangles */
#if LCD_DEPTH >= 16
    rb->lcd_set_foreground (LCD_RGBPACK (40, 40, 40));
#elif LCD_DEPTH == 2
    rb->lcd_set_foreground (LCD_DARKGRAY);
#endif

#if LCD_DEPTH >= 2
    for (rx = 0; rx < 4; rx++)
        for (ry = 0; ry < 4; ry++)
            rb->lcd_drawrect (PREVIEW_X + rx * BLOCK_WIDTH,
                              PREVIEW_Y + ry * BLOCK_HEIGHT, BLOCK_WIDTH,
                              BLOCK_HEIGHT);
#endif

    /* draw the figure */
    for (i = 0; i < 4; i++) {
        rx = getRelativeX (rockblox_status.nf, i, 0) + 2;
        ry = getRelativeY (rockblox_status.nf, i, 0) + 2;
#ifdef HAVE_LCD_BITMAP
#if LCD_DEPTH >= 2
        rb->lcd_set_foreground (figures[rockblox_status.nf].color[1]);  /* middle drawing */
#endif
        rb->lcd_fillrect (PREVIEW_X + rx * BLOCK_WIDTH,
                          PREVIEW_Y + ry * BLOCK_HEIGHT,
                          BLOCK_WIDTH, BLOCK_HEIGHT);
#if LCD_DEPTH >= 2
        rb->lcd_set_foreground (figures[rockblox_status.nf].color[0]);  /* light drawing */
#endif
        rb->lcd_vline (PREVIEW_X + rx * BLOCK_WIDTH,
                       PREVIEW_Y + ry * BLOCK_HEIGHT,
                       PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 2);
        rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH,
                       PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 2,
                       PREVIEW_Y + ry * BLOCK_HEIGHT);
#if LCD_DEPTH >= 2
        rb->lcd_set_foreground (figures[rockblox_status.nf].color[2]);  /* shadow drawing */
#endif
        rb->lcd_vline (PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1,
                       PREVIEW_Y + ry * BLOCK_HEIGHT + 1,
                       PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1);
        rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH + 1,
                       PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1,
                       PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1);
#else /* HAVE_LCD_CHARCELLS */
        pgfx_drawpixel (PREVIEW_X + rx, PREVIEW_Y + ry);
#endif
    }

}
コード例 #30
0
ファイル: resistor.c プロジェクト: IlVerz/rockbox
/* Warning: dirty kludge */
#define LCD_RGBPACK(x,y,z) 0
#endif

static struct band_data
{
    enum color color;
    char *name;
    int color_value;
    int resistance_value;
    int multiplier;
    char *unit;
    int tolerance;
} band_data[] =
{
    { RES_BLACK,  "Black",  LCD_RGBPACK(0, 0, 0),       0,   100,   "Ohms",-1 },
    { RES_BROWN,  "Brown",  LCD_RGBPACK(118, 78, 0),    1,  1000,   "Ohms", 1 },
    { RES_RED,    "Red",    LCD_RGBPACK(255, 0, 0),     2, 10000,   "Ohms", 2 },
    { RES_ORANGE, "Orange", LCD_RGBPACK(255, 199, 76),  3,   100,  "KOhms",-1 },
    { RES_YELLOW, "Yellow", LCD_RGBPACK(255, 255, 0),   4,  1000,  "KOhms",-1 },
    { RES_GREEN,  "Green",  LCD_RGBPACK(0, 128, 0),     5, 10000,  "KOhms",-1 },
    { RES_BLUE,   "Blue",   LCD_RGBPACK(0, 0, 255),     6,   100,  "MOhms",-1 },
    { RES_VIOLET, "Violet", LCD_RGBPACK(153, 51, 255),  7,  1000,  "MOhms",-1 },
    { RES_GREY,   "Grey",   LCD_RGBPACK(192, 192, 192), 8, 10000,  "MOhms",-1 },
    { RES_WHITE,  "White",  LCD_RGBPACK(255, 255, 255), 9,   100,  "GOhms",-1 },
    { RES_GOLD,   "Gold",   LCD_RGBPACK(146, 146, 0),  -1,    10,  "Ohms",  5 },
    { RES_SILVER, "Silver", LCD_RGBPACK(213, 213, 213),-1,     1,  "Ohms", 10 },
    { RES_NONE,   "[None]",  -1                       ,-1,    -1,       0, 20 }
};

static char *unit_abbrev;