예제 #1
0
void bootmgr_do_sleep(char on)
{
    if(sleep_mode == on)
        return;

    FILE *file = fopen("/sys/power/state", "w");
    fputs(on ? "mem" : "on", file);
    fclose(file);

    usleep(500000);

    bootmgr_fill_fb_black();
    fb_update(&fb);

    usleep(100000);

    bootmgr_draw();

    sleep_mode = on;

    if(!on)
    {
        bootmgr_reset_input_iters();
        force_update_time = 1;
    }
}
예제 #2
0
int load_565rle_image(char *fn)
{
    struct FB fb;
    struct stat s;
    unsigned short *data, *bits, *ptr;
    unsigned count, max;
    int fd;

    if (vt_set_mode(1))
        return -1;

    fd = open(fn, O_RDONLY);
    if (fd < 0) {
        ERROR("cannot open '%s'\n", fn);
        goto fail_restore_text;
    }

    if (fstat(fd, &s) < 0) {
        goto fail_close_file;
    }

    data = mmap(0, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
    if (data == MAP_FAILED)
        goto fail_close_file;

    if (fb_open(&fb))
        goto fail_unmap_data;

    max = fb_width(&fb) * fb_height(&fb);
    ptr = data;
    count = s.st_size;
    bits = fb.bits;
    while (count > 3) {
        unsigned n = ptr[0];
        if (n > max)
            break;
        android_memset16(bits, ptr[1], n << 1);
        bits += n;
        max -= n;
        ptr += 2;
        count -= 4;
    }

    munmap(data, s.st_size);
    fb_update(&fb);
    fb_close(&fb);
    close(fd);
    unlink(fn);
    return 0;

fail_unmap_data:
    munmap(data, s.st_size);
fail_close_file:
    close(fd);
fail_restore_text:
    vt_set_mode(0);
    return -1;
}
예제 #3
0
int console_suppress_fbupdate (int modify) {
  // pass 1 to suppress calls to fb_update with linefeeds, pass -1 to undo it again
  // pass 0 to inquire the current value
  // once the counter goes back to 0, a fb_update is performed
  console_suppress_fbupdate_cnt += modify;
  if (!console_suppress_fbupdate_cnt) {
    fb_update (console.fb);
  }
  return console_suppress_fbupdate_cnt;
}
예제 #4
0
파일: fb.c 프로젝트: gettler/mvpmc
int quickdir_change(mvp_widget_t *widget,char *path )
{
	int rc;
	struct stat64 sb;
	rc = stat64(path, &sb);
	if (rc==0) {
		if (strstr(path,"/uPnP")!=NULL && strstr(cwd,"/uPnP")==NULL ){
			mount_djmount(path);
				
		} else if (strstr(path,"/uPnP")==NULL && strstr(cwd,"/uPnP")!=NULL ) { 
			unmount_djmount();
		}
		snprintf(cwd,1024,"%s",path);
		fb_update(widget);
	}
	return rc;
}
예제 #5
0
static void console_linefeed () {
  console.cursor.x = 0;
  console.cursor.y++;

  /* Check if we need to scroll the display up */
  if(console.cursor.y >= font_lines ) {
    if (console.scrollMode) {
      console.scroll_pending = 1; // delay scroll until we actually write text to a new line
    } else {
      // reset cursor to top of screen
      console.cursor.y = 0;
      console.cls_pending = 1; // we must delay fb_cls or we'd never see the just printed line!
    }
  }
  if (!console_suppress_fbupdate_cnt) {
    fb_update(console.fb);
    #ifdef MSGDELAY // actually, such a delay can now be achieved using the debug option in the config file
      unsigned int start = inl (0x60005010);
      while (inl (0x60005010) < start + MSGDELAY) {}
    #endif
  }
}
예제 #6
0
void tetris_draw(uint8_t move)
{
    if(move && current)
    {
        pthread_mutex_lock(tetris_draw_mutex);
        if(!tetris_can_move_piece(TETRIS_DOWN))
        {
            if(!current->moved)
            {
                uint8_t lines = 2;
                if(settings.tetris_max_score < score)
                {
                    ++lines;
                    settings.tetris_max_score = score;
                    bootmgr_save_settings();
                    bootmgr_printf(10+((220 - 15*8)/2), 16, WHITE, "New high score!");
                }
                bootmgr_print_fill(11, 14*ISO_CHAR_HEIGHT, 219, lines*ISO_CHAR_HEIGHT, BLACK, 1);
                bootmgr_printf(10+((220 - 9*8)/2),  14, WHITE, "Game over");
                bootmgr_printf(10+((220 - 23*8)/2), 15, WHITE, "Press \"Home\" to restart");
                bootmgr_draw_fills();
                bootmgr_draw_text();
                fb_update(&fb);
                state = TETRIS_FINISHED;
                pthread_mutex_unlock(tetris_draw_mutex);
                return;
            }

            uint8_t x,y;
            for(x = 0; x < 5; ++x)
                for(y = current->y < 2 ? current->y : 0; y < 5; ++y)
                    if(p_shape[current->type][current->rotation][y][x])
                        pieces[current->x+(x-2)][current->y+(y-2)] = current;

            tetris_check_line();
            tetris_spawn_new();
        }
        else
            tetris_move_piece(TETRIS_DOWN);
        pthread_mutex_unlock(tetris_draw_mutex);
    }

    android_memset16(fb.bits, BLACK, BOOTMGR_DIS_W*BOOTMGR_DIS_H*2);

    tetris_print_batt();
    bootmgr_draw_fills();
    bootmgr_draw_text();


    tetris_piece *itr = current;
    uint8_t i = 0;
    uint16_t *bits;

    uint8_t y, x;
    do
    {
        for(y = 0; y < 5; ++y)
        {
            uint8_t len = 0;
            int8_t st = -1;
            for(x = 0; x < (i ? 4 : 5); ++x)
            {
                if(p_shape[itr->type][itr->rotation][y][x])
                {
                    if(st == -1)
                        st = x;
                    ++len;
                }
            }
            if(st == -1)
                continue;

            bits = fb.bits;
            bits += BOOTMGR_DIS_W*(30+((itr->y-(2-y))*BLOCK_SIZE)) + 10 + (itr->x-(2-st))*BLOCK_SIZE;
            for(x = 0; x < BLOCK_SIZE; ++x)
            {
                android_memset16(bits, tetris_get_color_for_type(itr->type), len*BLOCK_SIZE*2);
                bits += BOOTMGR_DIS_W;
            }
        }
        itr = preview;
        ++i;
    } while(i < 2);

    for(x = 0; x < TETRIS_W; ++x)
    {
        for(y = 0; y < TETRIS_H; ++y)
        {
            if(!pieces[x][y])
                continue;

            bits = fb.bits;
            bits += BOOTMGR_DIS_W*(30+(y*BLOCK_SIZE)) + 10 + x*BLOCK_SIZE;

            for(i = 0; i < BLOCK_SIZE; ++i)
            {
                android_memset16(bits, tetris_get_color_for_type(pieces[x][y]->type), BLOCK_SIZE*2);
                bits += BOOTMGR_DIS_W;
            }
        }
    }

    fb_update(&fb);
}
예제 #7
0
void tetris_key(int key)
{
    switch(key)
    {
        case KEY_VOLUMEDOWN:
        {
            if(state & TETRIS_PAUSED)
            {
                bootmgr_erase_text(14);
                bootmgr_erase_text(15);
                bootmgr_erase_fill(1);
                state &= ~(TETRIS_PAUSED);
                state |= TETRIS_STARTED;
            }
            else if(state & TETRIS_STARTED)
            {
                bootmgr_print_fill(11, 14*ISO_CHAR_HEIGHT, 219, 32, BLACK, 1);
                bootmgr_printf(10+((220 - 6*8)/2),  14, WHITE, "Paused");
                bootmgr_printf(10+((220 - 25*8)/2), 15, WHITE, "Press \"VolDown\" to resume");
                bootmgr_draw_fills();
                bootmgr_draw_text();
                fb_update(&fb);
                state &= ~(TETRIS_STARTED);
                state |= TETRIS_PAUSED;
            }
            break;
        }
        case KEY_VOLUMEUP:
            tetris_exit();
            bootmgr_set_time_thread(1);
            break;
        case KEY_HOME:
        {
            if(!(state & TETRIS_STARTED))
            {
                if(state & TETRIS_FINISHED)
                {
                    tetris_clear(0);
                    tetris_set_defaults();
                    bootmgr_erase_text(14);
                    bootmgr_erase_fill(1);
                    tetris_print_score();
                }
                bootmgr_erase_text(15);
                state = (TETRIS_STARTED | TETRIS_SPAWN_NEW);
            }
            else
            {
                pthread_mutex_lock(tetris_draw_mutex);
                tetris_move_piece(TETRIS_DOWN_FAST);
                tetris_draw(0);
                pthread_mutex_unlock(tetris_draw_mutex);
            }
            break;
        }
        case KEY_BACK:
        {
            if(state & TETRIS_STARTED)
            {
                pthread_mutex_lock(tetris_draw_mutex);
                tetris_rotate_piece();
                tetris_draw(0);
                pthread_mutex_unlock(tetris_draw_mutex);
            }
            break;
        }
        case KEY_MENU:
        case KEY_SEARCH:
        {
            if(state & TETRIS_STARTED)
            {
                pthread_mutex_lock(tetris_draw_mutex);
                if(tetris_can_move_piece(key == KEY_MENU ? TETRIS_LEFT : TETRIS_RIGHT))
                    tetris_move_piece(key == KEY_MENU ? TETRIS_LEFT : TETRIS_RIGHT);
                tetris_draw(0);
                pthread_mutex_unlock(tetris_draw_mutex);
            }
            break;
        }
    }
}