forked from len0rd/rockbox
Scroll on main and remote with a single thread. Change the way system messages are defined before running out is an issue (which requires a full update of rockbox on the player).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14035 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
885cdfdeb9
commit
58fc279d26
17 changed files with 859 additions and 994 deletions
|
|
@ -33,8 +33,7 @@
|
|||
#include "font.h"
|
||||
#include "rbunicode.h"
|
||||
#include "bidi.h"
|
||||
|
||||
#define SCROLLABLE_LINES ((LCD_HEIGHT+4)/5 < 32 ? (LCD_HEIGHT+4)/5 : 32)
|
||||
#include "scroll_engine.h"
|
||||
|
||||
enum fill_opt {
|
||||
OPT_NONE = 0,
|
||||
|
|
@ -62,23 +61,6 @@ static int xmargin = 0;
|
|||
static int ymargin = 0;
|
||||
static int curfont = FONT_SYSFIXED;
|
||||
|
||||
/* scrolling */
|
||||
static volatile int scrolling_lines = 0; /* Bitpattern of which lines are scrolling */
|
||||
static long scroll_stack[DEFAULT_STACK_SIZE/sizeof(long)];
|
||||
static const char scroll_name[] = "scroll";
|
||||
static void scroll_thread(void);
|
||||
static int scroll_ticks = 12; /* # of ticks between updates*/
|
||||
static int scroll_delay = HZ/2; /* ticks delay before start */
|
||||
static int scroll_step = 6; /* pixels per scroll step */
|
||||
static int bidir_limit = 50; /* percent */
|
||||
static struct scrollinfo scroll[SCROLLABLE_LINES];
|
||||
|
||||
static const char scroll_tick_table[16] = {
|
||||
/* Hz values:
|
||||
1, 1.25, 1.55, 2, 2.5, 3.12, 4, 5, 6.25, 8.33, 10, 12.5, 16.7, 20, 25, 33 */
|
||||
100, 80, 64, 50, 40, 32, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3
|
||||
};
|
||||
|
||||
/* LCD init */
|
||||
void lcd_init(void)
|
||||
{
|
||||
|
|
@ -86,12 +68,7 @@ void lcd_init(void)
|
|||
|
||||
/* Call device specific init */
|
||||
lcd_init_device();
|
||||
|
||||
|
||||
create_thread(scroll_thread, scroll_stack,
|
||||
sizeof(scroll_stack), scroll_name
|
||||
IF_PRIO(, PRIORITY_USER_INTERFACE)
|
||||
IF_COP(, CPU, false));
|
||||
scroll_init();
|
||||
}
|
||||
|
||||
/*** parameter handling ***/
|
||||
|
|
@ -243,7 +220,8 @@ void lcd_clear_display(void)
|
|||
else
|
||||
memcpy(dst, lcd_backdrop, sizeof(lcd_framebuffer));
|
||||
}
|
||||
scrolling_lines = 0;
|
||||
|
||||
lcd_scroll_info.lines = 0;
|
||||
}
|
||||
|
||||
/* Set a single pixel */
|
||||
|
|
@ -819,7 +797,7 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style,
|
|||
int oldbgcolor = bg_pattern;
|
||||
|
||||
/* make sure scrolling is turned off on the line we are updating */
|
||||
scrolling_lines &= ~(1 << y);
|
||||
lcd_scroll_info.lines &= ~(1 << y);
|
||||
|
||||
if(!str || !str[0])
|
||||
return;
|
||||
|
|
@ -845,46 +823,6 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style,
|
|||
}
|
||||
|
||||
/*** scrolling ***/
|
||||
|
||||
/* Reverse the invert setting of the scrolling line (if any) at given char
|
||||
position. Setting will go into affect next time line scrolls. */
|
||||
void lcd_invertscroll(int x, int y)
|
||||
{
|
||||
struct scrollinfo* s;
|
||||
|
||||
(void)x;
|
||||
|
||||
if(y>=SCROLLABLE_LINES) return;
|
||||
|
||||
s = &scroll[y];
|
||||
s->invert = !s->invert;
|
||||
}
|
||||
|
||||
void lcd_stop_scroll(void)
|
||||
{
|
||||
scrolling_lines=0;
|
||||
}
|
||||
|
||||
void lcd_scroll_speed(int speed)
|
||||
{
|
||||
scroll_ticks = scroll_tick_table[speed];
|
||||
}
|
||||
|
||||
void lcd_scroll_step(int step)
|
||||
{
|
||||
scroll_step = step;
|
||||
}
|
||||
|
||||
void lcd_scroll_delay(int ms)
|
||||
{
|
||||
scroll_delay = ms / (HZ / 10);
|
||||
}
|
||||
|
||||
void lcd_bidir_scroll(int percent)
|
||||
{
|
||||
bidir_limit = percent;
|
||||
}
|
||||
|
||||
void lcd_puts_scroll(int x, int y, const unsigned char *string)
|
||||
{
|
||||
lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT);
|
||||
|
|
@ -906,11 +844,11 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
|
|||
struct scrollinfo* s;
|
||||
int w, h;
|
||||
|
||||
if(y>=SCROLLABLE_LINES) return;
|
||||
|
||||
s = &scroll[y];
|
||||
if(y>=LCD_SCROLLABLE_LINES) return;
|
||||
|
||||
s->start_tick = current_tick + scroll_delay;
|
||||
s = &lcd_scroll_info.scroll[y];
|
||||
|
||||
s->start_tick = current_tick + lcd_scroll_info.delay;
|
||||
s->invert = false;
|
||||
if (style & STYLE_INVERT) {
|
||||
s->invert = true;
|
||||
|
|
@ -931,9 +869,9 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
|
|||
|
||||
/* scroll bidirectional or forward only depending on the string
|
||||
width */
|
||||
if ( bidir_limit ) {
|
||||
if ( lcd_scroll_info.bidir_limit ) {
|
||||
s->bidir = s->width < (LCD_WIDTH - xmargin) *
|
||||
(100 + bidir_limit) / 100;
|
||||
(100 + lcd_scroll_info.bidir_limit) / 100;
|
||||
}
|
||||
else
|
||||
s->bidir = false;
|
||||
|
|
@ -951,95 +889,84 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
|
|||
s->offset = offset;
|
||||
s->startx = xmargin + x * s->width / s->len;
|
||||
s->backward = false;
|
||||
s->line_colour = (style&STYLE_COLORED)?
|
||||
s->line_color = (style&STYLE_COLORED)?
|
||||
(style&STYLE_COLOR_MASK): -1;
|
||||
scrolling_lines |= (1<<y);
|
||||
lcd_scroll_info.lines |= (1<<y);
|
||||
}
|
||||
else
|
||||
/* force a bit switch-off since it doesn't scroll */
|
||||
scrolling_lines &= ~(1<<y);
|
||||
lcd_scroll_info.lines &= ~(1<<y);
|
||||
}
|
||||
|
||||
static void scroll_thread(void)
|
||||
void lcd_scroll_fn(void)
|
||||
{
|
||||
struct font* pf;
|
||||
struct scrollinfo* s;
|
||||
int index;
|
||||
int xpos, ypos;
|
||||
int lastmode;
|
||||
unsigned old_bgcolour, old_fgcolour;
|
||||
unsigned old_fgcolor = fg_pattern;
|
||||
unsigned old_bgcolor = bg_pattern;
|
||||
|
||||
/* initialize scroll struct array */
|
||||
scrolling_lines = 0;
|
||||
|
||||
while ( 1 ) {
|
||||
if(!lcd_enabled()) {
|
||||
sleep(scroll_ticks);
|
||||
for ( index = 0; index < LCD_SCROLLABLE_LINES; index++ ) {
|
||||
/* really scroll? */
|
||||
if ((lcd_scroll_info.lines & (1 << index)) == 0)
|
||||
continue;
|
||||
}
|
||||
old_fgcolour = lcd_get_foreground();
|
||||
old_bgcolour = lcd_get_background();
|
||||
for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
|
||||
/* really scroll? */
|
||||
if ( !(scrolling_lines&(1<<index)) )
|
||||
continue;
|
||||
|
||||
s = &scroll[index];
|
||||
/* check pause */
|
||||
if (TIME_BEFORE(current_tick, s->start_tick))
|
||||
continue;
|
||||
if (s->line_colour >= 0)
|
||||
{
|
||||
if (s->invert)
|
||||
{
|
||||
lcd_set_foreground(old_fgcolour);
|
||||
lcd_set_background(s->line_colour);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_set_foreground(s->line_colour);
|
||||
lcd_set_background(old_bgcolour);
|
||||
}
|
||||
}
|
||||
|
||||
if (s->backward)
|
||||
s->offset -= scroll_step;
|
||||
else
|
||||
s->offset += scroll_step;
|
||||
s = &lcd_scroll_info.scroll[index];
|
||||
|
||||
pf = font_get(curfont);
|
||||
xpos = s->startx;
|
||||
ypos = ymargin + index * pf->height;
|
||||
/* check pause */
|
||||
if (TIME_BEFORE(current_tick, s->start_tick))
|
||||
continue;
|
||||
|
||||
if (s->bidir) { /* scroll bidirectional */
|
||||
if (s->offset <= 0) {
|
||||
/* at beginning of line */
|
||||
s->offset = 0;
|
||||
s->backward = false;
|
||||
s->start_tick = current_tick + scroll_delay * 2;
|
||||
}
|
||||
if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
|
||||
/* at end of line */
|
||||
s->offset = s->width - (LCD_WIDTH - xpos);
|
||||
s->backward = true;
|
||||
s->start_tick = current_tick + scroll_delay * 2;
|
||||
}
|
||||
if (s->line_color >= 0) {
|
||||
if (s->invert) {
|
||||
fg_pattern = old_fgcolor;
|
||||
bg_pattern = s->line_color;
|
||||
}
|
||||
else {
|
||||
/* scroll forward the whole time */
|
||||
if (s->offset >= s->width)
|
||||
s->offset %= s->width;
|
||||
fg_pattern = s->line_color;
|
||||
bg_pattern = old_bgcolor;
|
||||
}
|
||||
|
||||
lastmode = drawmode;
|
||||
drawmode = s->invert ?
|
||||
(DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
|
||||
lcd_putsxyofs(xpos, ypos, s->offset, s->line);
|
||||
drawmode = lastmode;
|
||||
lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
|
||||
}
|
||||
lcd_set_foreground(old_fgcolour);
|
||||
lcd_set_background(old_bgcolour);
|
||||
sleep(scroll_ticks);
|
||||
|
||||
if (s->backward)
|
||||
s->offset -= lcd_scroll_info.step;
|
||||
else
|
||||
s->offset += lcd_scroll_info.step;
|
||||
|
||||
pf = font_get(curfont);
|
||||
xpos = s->startx;
|
||||
ypos = ymargin + index * pf->height;
|
||||
|
||||
if (s->bidir) { /* scroll bidirectional */
|
||||
if (s->offset <= 0) {
|
||||
/* at beginning of line */
|
||||
s->offset = 0;
|
||||
s->backward = false;
|
||||
s->start_tick = current_tick + lcd_scroll_info.delay * 2;
|
||||
}
|
||||
if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
|
||||
/* at end of line */
|
||||
s->offset = s->width - (LCD_WIDTH - xpos);
|
||||
s->backward = true;
|
||||
s->start_tick = current_tick + lcd_scroll_info.delay * 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* scroll forward the whole time */
|
||||
if (s->offset >= s->width)
|
||||
s->offset %= s->width;
|
||||
}
|
||||
|
||||
lastmode = drawmode;
|
||||
drawmode = s->invert ?
|
||||
(DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
|
||||
lcd_putsxyofs(xpos, ypos, s->offset, s->line);
|
||||
drawmode = lastmode;
|
||||
lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
|
||||
}
|
||||
|
||||
fg_pattern = old_fgcolor;
|
||||
bg_pattern = old_bgcolor;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue