示例#1
0
static void starfield_move_and_draw(struct starfield * starfield)
{
    int i;
    for(i=0;i<starfield->nb_stars;++i)
    {
        move_star(&(starfield->tab[i]), starfield->z_move);
        draw_star(&(starfield->tab[i]), starfield->z_move);
    }
}
示例#2
0
/***********************************************************************
* draw a frame
***********************************************************************/
static void draw_frame(CellPadData *data)
{
    int8_t i;

    // all 32bit colors are ARGB, the framebuffer format
    set_foreground_color(0xFFFFFFFF);     // white, opac

    // set the right background color for current view
    set_background_color(bg_color_menu[view]);    

    draw_background();

    #ifdef HAVE_STARFIELD
    // first draw stars, keeping them under text lines
    move_star();
    #endif

    // print headline string, coordinates in canvas
    print_text(4, 4, "PS3 VSH Menu");

    // print all menu entries for view, and the current selected entry in green
    for(i = 0; i < max_menu[view]; i++)
    {
        i == line ? set_foreground_color(0xFF00FF00) : set_foreground_color(0xFFFFFFFF);

        print_text(4, 8 + ((FONT_H +1) * (i + 1)), entry_str[view][i]);
    }

    // (re)set back after draw last line
    set_foreground_color(0xFFFFFFFF);

    // ...

    // second menu, red one:
    if(view == 1)
    {
        /*
          hexdump pad data: store in text 8 buttons in a row
          in "%.4x" format plus 1 for ':', last one will be
          replaced by terminator, no need to add 1
        */
        char templn[8 * (4 + 1)];
        uint16_t tmp_x;

        // test text alignment
        sprintf(templn, "*%p, %d bytes;", data, data->len * sizeof(uint16_t));
        tmp_x = get_aligned_x(templn, CENTER);
        print_text(tmp_x, 180, templn);

        // hexdump first 32 buttons
        uint16_t x = 0, y = 200;
        for(i = 0; i < 32; i++)
        {
            sprintf(&templn[x], "%.4x:", data->button[i]);
            x += 5;
            templn[x] = '\0';

            if(x %8 == 0)
            {
                // overwrite last ':' with terminator
                templn[x -1] = '\0';
                tmp_x = get_aligned_x(templn, CENTER);
                print_text(tmp_x, y, templn);
                x = 0, y += (FONT_H +1);        // additional px to next line
            }
        }

        // update temp color
        uint32_t tmp_c = ARGB(a, r, g, b);

        // start draw text with updated color
        set_foreground_color(tmp_c);

        // print its value 
        sprintf(templn, "%.8x", tmp_c);
        tmp_x = get_aligned_x(templn, RIGHT) -4; // additional px from R margin
        print_text(tmp_x, 4, templn);

        // testing sine
        float amp = f_sinf(10);
        sprintf(templn, "%.4f", amp);
        tmp_x = get_aligned_x(templn, RIGHT) -4;
        print_text(tmp_x, 4 + (FONT_H +1), templn);

        read_meminfo(templn);
        tmp_x = get_aligned_x(templn, RIGHT) -4;
        print_text(tmp_x, CANVAS_H - (FONT_H +1) -4, templn); // additional px from lower border
    }

    // ...

}