2008-01-04 23:42:38 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* New greyscale framework
|
|
|
|
* Scrolling routines
|
|
|
|
*
|
|
|
|
* This is a generic framework to display 129 shades of grey on low-depth
|
|
|
|
* bitmap LCDs (Archos b&w, Iriver & Ipod 4-grey) within plugins.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Jens Arnold
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2008-01-04 23:42:38 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "grey.h"
|
|
|
|
|
|
|
|
/*** Scrolling ***/
|
|
|
|
|
|
|
|
/* Scroll left */
|
|
|
|
void grey_scroll_left(int count)
|
|
|
|
{
|
|
|
|
unsigned char *data, *data_end;
|
|
|
|
int length, blank;
|
|
|
|
|
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.width)
|
|
|
|
return;
|
|
|
|
|
|
|
|
data = _grey_info.buffer;
|
|
|
|
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
|
|
|
length = _grey_info.width - count;
|
|
|
|
blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(data, data + count, length);
|
2008-01-10 22:51:33 +00:00
|
|
|
data += length;
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memset(data, blank, count);
|
2008-01-10 22:51:33 +00:00
|
|
|
data += count;
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
|
|
|
while (data < data_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Scroll right */
|
|
|
|
void grey_scroll_right(int count)
|
|
|
|
{
|
|
|
|
unsigned char *data, *data_end;
|
|
|
|
int length, blank;
|
|
|
|
|
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.width)
|
|
|
|
return;
|
|
|
|
|
|
|
|
data = _grey_info.buffer;
|
|
|
|
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
|
|
|
length = _grey_info.width - count;
|
|
|
|
blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(data + count, data, length);
|
|
|
|
rb->memset(data, blank, count);
|
2008-01-04 23:42:38 +00:00
|
|
|
data += _grey_info.width;
|
|
|
|
}
|
|
|
|
while (data < data_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Scroll up */
|
|
|
|
void grey_scroll_up(int count)
|
|
|
|
{
|
|
|
|
long shift, length;
|
|
|
|
int blank;
|
|
|
|
|
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.height)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shift = _GREY_MULUQ(_grey_info.width, count);
|
|
|
|
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
|
|
|
blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(_grey_info.buffer, _grey_info.buffer + shift,
|
2008-01-13 00:11:43 +00:00
|
|
|
length);
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memset(_grey_info.buffer + length, blank, shift);
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Scroll down */
|
|
|
|
void grey_scroll_down(int count)
|
|
|
|
{
|
|
|
|
long shift, length;
|
|
|
|
int blank;
|
|
|
|
|
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.height)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shift = _GREY_MULUQ(_grey_info.width, count);
|
|
|
|
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
|
|
|
blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(_grey_info.buffer + shift, _grey_info.buffer,
|
2008-01-13 00:11:43 +00:00
|
|
|
length);
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memset(_grey_info.buffer, blank, shift);
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Unbuffered scrolling functions ***/
|
|
|
|
|
|
|
|
/* Scroll left */
|
|
|
|
void grey_ub_scroll_left(int count)
|
|
|
|
{
|
2008-01-10 22:51:33 +00:00
|
|
|
unsigned char *data, *data_end;
|
|
|
|
int blank, length;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.width)
|
2008-01-04 23:42:38 +00:00
|
|
|
return;
|
2008-01-13 00:11:43 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
data = _grey_info.values;
|
|
|
|
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
|
|
|
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
|
|
|
count <<= _GREY_BSHIFT;
|
2008-01-13 18:39:09 +00:00
|
|
|
blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
|
|
|
_grey_info.fg_brightness :
|
|
|
|
_grey_info.bg_brightness];
|
2008-01-10 22:51:33 +00:00
|
|
|
do
|
2008-01-04 23:42:38 +00:00
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(data, data + count, length);
|
2008-01-10 22:51:33 +00:00
|
|
|
data += length;
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memset(data, blank, count);
|
2008-01-10 22:51:33 +00:00
|
|
|
data += count;
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
2008-01-10 22:51:33 +00:00
|
|
|
while (data < data_end);
|
2008-01-13 18:39:09 +00:00
|
|
|
#ifdef SIMULATOR
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.width, _grey_info.height);
|
|
|
|
#endif
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Scroll right */
|
|
|
|
void grey_ub_scroll_right(int count)
|
|
|
|
{
|
2008-01-10 22:51:33 +00:00
|
|
|
unsigned char *data, *data_end;
|
|
|
|
int blank, length;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.width)
|
2008-01-04 23:42:38 +00:00
|
|
|
return;
|
2008-01-13 00:11:43 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
data = _grey_info.values;
|
|
|
|
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
|
|
|
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
|
|
|
count <<= _GREY_BSHIFT;
|
2008-01-13 18:39:09 +00:00
|
|
|
blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
|
|
|
_grey_info.fg_brightness :
|
|
|
|
_grey_info.bg_brightness];
|
2008-01-10 22:51:33 +00:00
|
|
|
do
|
2008-01-04 23:42:38 +00:00
|
|
|
{
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(data + count, data, length);
|
|
|
|
rb->memset(data, blank, count);
|
2008-01-10 22:51:33 +00:00
|
|
|
data += _grey_info.width << _GREY_BSHIFT;
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
2008-01-10 22:51:33 +00:00
|
|
|
while (data < data_end);
|
2008-01-13 18:39:09 +00:00
|
|
|
#ifdef SIMULATOR
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.width, _grey_info.height);
|
|
|
|
#endif
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
/* Scroll up */
|
2008-01-04 23:42:38 +00:00
|
|
|
void grey_ub_scroll_up(int count)
|
|
|
|
{
|
2008-01-10 22:51:33 +00:00
|
|
|
unsigned char *dst, *end, *src;
|
|
|
|
int blank;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.height)
|
|
|
|
return;
|
2008-01-13 00:11:43 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
dst = _grey_info.values;
|
|
|
|
end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width);
|
2008-01-13 18:39:09 +00:00
|
|
|
blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
|
|
|
_grey_info.fg_brightness :
|
|
|
|
_grey_info.bg_brightness];
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-03-25 23:21:36 +00:00
|
|
|
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
|
|
|
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
2008-01-10 22:51:33 +00:00
|
|
|
if (count & _GREY_BMASK)
|
2008-01-04 23:42:38 +00:00
|
|
|
{
|
2008-01-10 22:51:33 +00:00
|
|
|
/* Scrolling by fractional blocks - move pixel wise. */
|
|
|
|
unsigned char *line_end;
|
|
|
|
int ys, yd;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
for (ys = count, yd = 0; ys < _grey_info.height; ys++, yd++)
|
2008-01-04 23:42:38 +00:00
|
|
|
{
|
2008-01-10 22:51:33 +00:00
|
|
|
dst = _grey_info.values
|
|
|
|
+ _GREY_MULUQ(_grey_info.width, yd & ~_GREY_BMASK)
|
|
|
|
+ (~yd & _GREY_BMASK);
|
|
|
|
src = _grey_info.values
|
|
|
|
+ _GREY_MULUQ(_grey_info.width, ys & ~_GREY_BMASK)
|
|
|
|
+ (~ys & _GREY_BMASK);
|
|
|
|
line_end = dst + _grey_info.width * _GREY_BSIZE;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
*dst = *src;
|
|
|
|
dst += _GREY_BSIZE;
|
|
|
|
src += _GREY_BSIZE;
|
|
|
|
}
|
|
|
|
while (dst < line_end);
|
|
|
|
}
|
|
|
|
for (; yd & _GREY_BMASK; yd++) /* Fill remainder of current block. */
|
|
|
|
{
|
|
|
|
dst = _grey_info.values
|
|
|
|
+ _GREY_MULUQ(_grey_info.width, yd & ~_GREY_BMASK)
|
|
|
|
+ (~yd & _GREY_BMASK);
|
|
|
|
line_end = dst + _grey_info.width * _GREY_BSIZE;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
*dst = blank;
|
|
|
|
dst += _GREY_BSIZE;
|
|
|
|
}
|
|
|
|
while (dst < line_end);
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-10 22:51:33 +00:00
|
|
|
else
|
2008-01-04 23:42:38 +00:00
|
|
|
#endif
|
2008-01-10 22:51:33 +00:00
|
|
|
{
|
|
|
|
int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width);
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
src = dst + _GREY_MULUQ(count, _grey_info.width);
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(dst, src, blen);
|
2008-01-10 22:51:33 +00:00
|
|
|
dst += blen;
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memset(dst, blank, end - dst); /* Fill remainder at once. */
|
2008-01-13 18:39:09 +00:00
|
|
|
#ifdef SIMULATOR
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.width, _grey_info.height);
|
|
|
|
#endif
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
/* Scroll down */
|
2008-01-04 23:42:38 +00:00
|
|
|
void grey_ub_scroll_down(int count)
|
|
|
|
{
|
2008-01-10 23:01:11 +00:00
|
|
|
unsigned char *start, *dst;
|
2008-01-10 22:51:33 +00:00
|
|
|
int blank;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
|
|
|
if ((unsigned)count >= (unsigned)_grey_info.height)
|
|
|
|
return;
|
2008-01-13 00:11:43 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
start = _grey_info.values;
|
|
|
|
dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width);
|
2008-01-13 18:39:09 +00:00
|
|
|
blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
|
|
|
_grey_info.fg_brightness :
|
|
|
|
_grey_info.bg_brightness];
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-03-25 23:21:36 +00:00
|
|
|
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
|
|
|
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
2008-01-10 22:51:33 +00:00
|
|
|
if (count & _GREY_BMASK)
|
2008-01-04 23:42:38 +00:00
|
|
|
{
|
2008-01-10 22:51:33 +00:00
|
|
|
/* Scrolling by fractional blocks - move pixel wise. */
|
2008-01-10 23:01:11 +00:00
|
|
|
unsigned char *src, *line_end;
|
2008-01-10 22:51:33 +00:00
|
|
|
int ys, yd;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
yd = _grey_info.height - 1;
|
|
|
|
for (ys = yd - count; ys >= 0; ys--, yd--)
|
2008-01-04 23:42:38 +00:00
|
|
|
{
|
2008-01-10 22:51:33 +00:00
|
|
|
dst = _grey_info.values
|
|
|
|
+ _GREY_MULUQ(_grey_info.width, yd & ~_GREY_BMASK)
|
|
|
|
+ (~yd & _GREY_BMASK);
|
|
|
|
src = _grey_info.values
|
|
|
|
+ _GREY_MULUQ(_grey_info.width, ys & ~_GREY_BMASK)
|
|
|
|
+ (~ys & _GREY_BMASK);
|
|
|
|
line_end = dst + _grey_info.width * _GREY_BSIZE;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
*dst = *src;
|
|
|
|
dst += _GREY_BSIZE;
|
|
|
|
src += _GREY_BSIZE;
|
|
|
|
}
|
|
|
|
while (dst < line_end);
|
|
|
|
}
|
2008-01-13 00:11:43 +00:00
|
|
|
for (; ~yd & _GREY_BMASK; yd--) /* Fill remainder of current block. */
|
2008-01-10 22:51:33 +00:00
|
|
|
{
|
|
|
|
dst = _grey_info.values
|
|
|
|
+ _GREY_MULUQ(_grey_info.width, yd & ~_GREY_BMASK)
|
|
|
|
+ (~yd & _GREY_BMASK);
|
|
|
|
line_end = dst + _grey_info.width * _GREY_BSIZE;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
line_end -= _GREY_BSIZE;
|
|
|
|
*line_end = blank;
|
|
|
|
}
|
|
|
|
while (dst < line_end);
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
2008-03-25 23:21:36 +00:00
|
|
|
/* Top pixel in a block has the highest address, but dst must point
|
|
|
|
* to the lowest address in that block for the subsequent fill. */
|
|
|
|
dst -= _GREY_BMASK;
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
2008-01-10 22:51:33 +00:00
|
|
|
else
|
2008-01-04 23:42:38 +00:00
|
|
|
#endif
|
2008-01-10 22:51:33 +00:00
|
|
|
{
|
|
|
|
int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width);
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
dst -= blen;
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memmove(dst, start, blen);
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->memset(start, blank, dst - start);
|
2008-01-13 00:11:43 +00:00
|
|
|
/* Fill remainder at once. */
|
2008-01-13 18:39:09 +00:00
|
|
|
#ifdef SIMULATOR
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
|
2008-01-13 18:39:09 +00:00
|
|
|
_grey_info.width, _grey_info.height);
|
|
|
|
#endif
|
2008-01-04 23:42:38 +00:00
|
|
|
}
|