/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Additional LCD routines not present in the rockbox core
* Scrolling functions
*
* Copyright (C) 2005 Jens Arnold
*
* 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.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
#include "xlcd.h"
#if (LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
static const unsigned short patterns[4] = {0xFFFF, 0xFF00, 0x00FF, 0x0000};
#endif
#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
void xlcd_scroll_left(int count)
{
int length, oldmode;
if ((unsigned)count >= LCD_WIDTH)
{
rb->lcd_clear_display();
return;
}
length = (LCD_WIDTH-count)*LCD_FBHEIGHT;
rb->memmove(rb->lcd_framebuffer, rb->lcd_framebuffer + LCD_HEIGHT*count,
length * sizeof(fb_data));
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(LCD_WIDTH-count, 0, count, LCD_HEIGHT);
rb->lcd_set_drawmode(oldmode);
}
/* Scroll right */
void xlcd_scroll_right(int count)
{
int length, oldmode;
if ((unsigned)count >= LCD_WIDTH)
{
rb->lcd_clear_display();
return;
}
length = (LCD_WIDTH-count)*LCD_FBHEIGHT;
rb->memmove(rb->lcd_framebuffer + LCD_HEIGHT*count,
rb->lcd_framebuffer, length * sizeof(fb_data));
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(0, 0, count, LCD_HEIGHT);
rb->lcd_set_drawmode(oldmode);
}
/* Scroll up */
void xlcd_scroll_up(int count)
{
int width, length, oldmode;
fb_data *data;
if ((unsigned)count >= LCD_HEIGHT)
{
rb->lcd_clear_display();
return;
}
length = LCD_HEIGHT - count;
width = LCD_WIDTH-1;
data = rb->lcd_framebuffer;
do {
rb->memmove(data,data + count,length * sizeof(fb_data));
data += LCD_HEIGHT;
} while(width--);
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(0, length, LCD_WIDTH, count);
rb->lcd_set_drawmode(oldmode);
}
/* Scroll down */
void xlcd_scroll_down(int count)
{
int width, length, oldmode;
fb_data *data;
if ((unsigned)count >= LCD_HEIGHT)
{
rb->lcd_clear_display();
return;
}
length = LCD_HEIGHT - count;
width = LCD_WIDTH-1;
data = rb->lcd_framebuffer;
do {
rb->memmove(data + count, data, length * sizeof(fb_data));
data += LCD_HEIGHT;
} while(width--);
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(0, 0, LCD_WIDTH, count);
rb->lcd_set_drawmode(oldmode);
}
#else
#if (LCD_PIXELFORMAT == HORIZONTAL_PACKING) && (LCD_DEPTH < 8)
/* Scroll left */
void xlcd_scroll_left(int count)
{
int bitcount, oldmode;
int blockcount, blocklen;
if ((unsigned) count >= LCD_WIDTH)
{
rb->lcd_clear_display();
return;
}
#if LCD_DEPTH == 2
blockcount = count >> 2;
blocklen = LCD_FBWIDTH - blockcount;
bitcount = 2 * (count & 3);
#endif
if (blockcount)
{
unsigned char *data = rb->lcd_framebuffer;
unsigned char *data_end = data + LCD_FBWIDTH*LCD_HEIGHT;
do
{
rb->memmove(data, data + blockcount, blocklen);
data += LCD_FBWIDTH;
}
while (data < data_end);
}
if (bitcount)
{
int bx, y;
unsigned char *addr = rb->lcd_framebuffer + blocklen;
#if LCD_DEPTH == 2
unsigned fill = (0x55 * (~rb->lcd_get_background() & 3)) << bitcount;
#endif
for (y = 0; y < LCD_HEIGHT; y++)
{
unsigned char *row_addr = addr;
unsigned data = fill;
for (bx = 0; bx < blocklen; bx++)
{
--row_addr;
data = (data >> 8) | (*row_addr << bitcount);
*row_addr = data;
}
addr += LCD_FBWIDTH;
}
}
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(LCD_WIDTH - count, 0, count, LCD_HEIGHT);
rb->lcd_set_drawmode(oldmode);
}
/* Scroll right */
void xlcd_scroll_right(int count)
{
int bitcount, oldmode;
int blockcount, blocklen;
if ((unsigned) count >= LCD_WIDTH)
{
rb->lcd_clear_display();
return;
}
#if LCD_DEPTH == 2
blockcount = count >> 2;
blocklen = LCD_FBWIDTH - blockcount;
bitcount = 2 * (count & 3);
#endif
if (blockcount)
{
unsigned char *data = rb->lcd_framebuffer;
unsigned char *data_end = data + LCD_FBWIDTH*LCD_HEIGHT;
do
{
rb->memmove(data + blockcount, data, blocklen);
data += LCD_FBWIDTH;
}
while (data < data_end);
}
if (bitcount)
{
int bx, y;
unsigned char *addr = rb->lcd_framebuffer + blockcount;
#if LCD_DEPTH == 2
unsigned fill = 0x55 * (~rb->lcd_get_background() & 3);
#endif
for (y = 0; y < LCD_HEIGHT; y++)
{
unsigned char *row_addr = addr;
unsigned data = fill;
for (bx = 0; bx < blocklen; bx++)
{
data = (data << 8) | *row_addr;
*row_addr = data >> bitcount;
row_addr++;
}
addr += LCD_FBWIDTH;
}
}
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(0, 0, count, LCD_HEIGHT);
rb->lcd_set_drawmode(oldmode);
}
#else /* LCD_PIXELFORMAT vertical packed or >= 8bit / pixel */
/* Scroll left */
void xlcd_scroll_left(int count)
{
fb_data *data, *data_end;
int length, oldmode;
if ((unsigned)count >= LCD_WIDTH)
{
rb->lcd_clear_display();
return;
}
data = rb->lcd_framebuffer;
data_end = data + LCD_WIDTH*LCD_FBHEIGHT;
length = LCD_WIDTH - count;
do
{
rb->memmove(data, data + count, length * sizeof(fb_data));
data += LCD_WIDTH;
}
while (data < data_end);
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(length, 0, count, LCD_HEIGHT);
rb->lcd_set_drawmode(oldmode);
}
/* Scroll right */
void xlcd_scroll_right(int count)
{
fb_data *data, *data_end;
int length, oldmode;
if ((unsigned)count >= LCD_WIDTH)
{
rb->lcd_clear_display();
return;
}
data = rb->lcd_framebuffer;
data_end = data + LCD_WIDTH*LCD_FBHEIGHT;
length = LCD_WIDTH - count;
do
{
rb->memmove(data + count, data, length * sizeof(fb_data));
data += LCD_WIDTH;
}
while (data < data_end);
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(0, 0, count, LCD_HEIGHT);
rb->lcd_set_drawmode(oldmode);
}
#endif /* LCD_PIXELFORMAT, LCD_DEPTH */
#if (LCD_PIXELFORMAT == HORIZONTAL_PACKING) || (LCD_DEPTH >= 8)
/* Scroll up */
void xlcd_scroll_up(int count)
{
int length, oldmode;
if ((unsigned)count >= LCD_HEIGHT)
{
rb->lcd_clear_display();
return;
}
length = LCD_HEIGHT - count;
rb->memmove(rb->lcd_framebuffer,
rb->lcd_framebuffer + count * LCD_FBWIDTH,
length * LCD_FBWIDTH * sizeof(fb_data));
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(0, length, LCD_WIDTH, count);
rb->lcd_set_drawmode(oldmode);
}
/* Scroll down */
void xlcd_scroll_down(int count)
{
int length, oldmode;
if ((unsigned)count >= LCD_HEIGHT)
{
rb->lcd_clear_display();
return;
}
length = LCD_HEIGHT - count;
rb->memmove(/* Copyright (C) 2002 Jean-Marc Valin
File: exc_8_128_table.c
Codebook for excitation in narrowband CELP mode (7000 bps)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config-speex.h"
const signed char exc_8_128_table[1024] ICONST_ATTR = {
-14,9,13,-32,2,-10,31,-10,
-8,-8,6,-4,-1,10,-64,23,
6,20,13,6,8,-22,16,34,
7,42,-49,-28,5,26,4,-15,
41,34,41,32,33,24,23,14,
8,40,34,4,-24,-41,-19,-15,
13,-13,33,-54,24,27,-44,33,
27,-15,-15,24,-19,14,-36,14,
-9,24,-12,-4,37,-5,16,-34,
5,10,33,-15,-54,-16,12,25,
12,1,2,0,3,-1,-4,-4,
11,2,-56,54,27,-20,13,-6,
-46,-41,-33,-11,-5,7,12,14,
-14,-5,8,20,6,3,4,-8,
-5,-42,11,8,-14,25,-2,2,
13,11,-22,39,-9,9,5,-45, \n" /* current_row++ */
"cmp/hi r3,%[rows] \n" /* current_row < bheight - shift ? */
"bt .sd_iloop \n"
"add #1,%[addr] \n" /* start_address++ */
"add #1,r4 \n" /* x++ */
"cmp/hi r4,%[wide] \n" /* x < width ? */
"bt .sd_cloop \n"
: /* outputs */
: /* inputs */
[addr]"r"(rb->lcd_framebuffer + blockcount * LCD_FBWIDTH),
[wide]"r"(LCD_WIDTH),
[rows]"r"(blocklen),
[cnt] "r"(bitcount)
: /* clobbers */
"r0", "r1", "r2", "r3", "r4"
);
#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2)
asm (
"move.l %[wide],%%d3\n" /* columns = width */
".sd_cloop: \n" /* repeat for every column */
"move.l %[addr],%%a1\n" /* get start address */
"move.l %[rows],%%d2\n" /* rows = row_count */
"move.l %[bkg],%%d1 \n" /* fill with background */
".sd_iloop: \n" /* repeat for all rows */
"lsr.l #8,%%d1 \n" /* shift right to get residue */
"clr.l %%d0 \n"
"move.b (%%a1),%%d0 \n" /* get data byte */
"lsl.l %[cnt],%%d0 \n"
"or.l %%d0,%%d1 \n" /* combine with last residue */
"move.b %%d1,(%%a1) \n" /* store data */
"add.l %[wide],%%a1\n" /* address += width */
"subq.l #1,%%d2 \n" /* rows-- */
"bne.b .sd_iloop \n"
"lea.l (1,%[addr]),%[addr] \n" /* start_address++ */
"subq.l #1,%%d3 \n" /* columns-- */
"bne.b .sd_cloop \n"
: /* outputs */
: /* inputs */
[wide]"r"(LCD_WIDTH),
[rows]"r"(blocklen),
[addr]"a"(rb->lcd_framebuffer + blockcount * LCD_FBWIDTH),
[cnt] "d"(bitcount),
[bkg] "d"((0x55 * (~rb->lcd_get_background() & 3)) << bitcount)
: /* clobbers */
"a1", "d0", "d1", "d2", "d3"
);
#else /* C version */
int x, by;
unsigned char *addr = rb->lcd_framebuffer + blockcount * LCD_FBWIDTH;
#if LCD_DEPTH == 2
unsigned fill = (0x55 * (~rb->lcd_get_background() & 3)) << bitcount;
#else
const unsigned fill = 0;
#endif
for (x = 0; x < LCD_WIDTH; x++)
{
unsigned char *col_addr = addr++;
unsigned data = fill;
for (by = 0; by < blocklen; by++)
{
data = (data >> 8) | (*col_addr << bitcount);
*col_addr = data;
col_addr += LCD_FBWIDTH;
}
}
#endif /* CPU, LCD_DEPTH */
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
#if LCD_DEPTH == 2
int x, by;
fb_data *addr = rb->lcd_framebuffer + blockcount * LCD_FBWIDTH;
unsigned fill, mask;
fill = patterns[rb->lcd_get_background() & 3] >> (8 - bitcount);
mask = (0xFFu >> bitcount) << bitcount;
mask |= mask << 8;
for (x = 0; x < LCD_WIDTH; x++)
{
fb_data *col_addr = addr++;
unsigned olddata = fill;
unsigned data;
for (by = 0; by < blocklen; by++)
{
data = *col_addr << bitcount;
*col_addr = olddata ^ ((data ^ olddata) & mask);
olddata = data >> 8;
col_addr += LCD_FBWIDTH;
}
}
#endif /* LCD_DEPTH == 2 */
#endif /* LCD_PIXELFORMAT */
}
oldmode = rb->lcd_get_drawmode();
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(0, 0, LCD_WIDTH, count);
rb->lcd_set_drawmode(oldmode);
}
#endif /* LCD_PIXELFORMAT, LCD_DEPTH */
#endif /* defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE */
#endif /* HAVE_LCD_BITMAP */