summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/lvm.h
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2010-06-21 20:34:40 +0000
committerAmaury Pouly <pamaury@rockbox.org>2010-06-21 20:34:40 +0000
commit06b9064205d3e8aaf7f743fb1486733dd369ce1c (patch)
treeeb6ab83ee4ddd26d7f32f6d87246455d71b1a303 /apps/plugins/lua/lvm.h
parent4ed8306121e8ca2a8baf5a56dd682ec4f3486ec8 (diff)
downloadrockbox-06b9064205d3e8aaf7f743fb1486733dd369ce1c.zip
rockbox-06b9064205d3e8aaf7f743fb1486733dd369ce1c.tar.gz
rockbox-06b9064205d3e8aaf7f743fb1486733dd369ce1c.tar.bz2
rockbox-06b9064205d3e8aaf7f743fb1486733dd369ce1c.tar.xz
Add Jérôme Heil to CREDITS for figuring out the usb clock problem on as3525v2.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27034 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lua/lvm.h')
0 files changed, 0 insertions, 0 deletions
href='#n120'>120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
/***************************************************************************
*             __________               __   ___.
*   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
*
* 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"
#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) ?
             _grey_info.fg_brightness : _grey_info.bg_brightness;

    do
    {
        rb->memmove(data, data + count, length);
        data += length;
        rb->memset(data, blank, count);
        data += count;
    }
    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) ?
             _grey_info.fg_brightness : _grey_info.bg_brightness;

    do
    {
        rb->memmove(data + count, data, length);
        rb->memset(data, blank, count);
        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) ?
             _grey_info.fg_brightness : _grey_info.bg_brightness;

    rb->memmove(_grey_info.buffer, _grey_info.buffer + shift,
                           length);
    rb->memset(_grey_info.buffer + length, blank, shift);
}

/* 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) ?
             _grey_info.fg_brightness : _grey_info.bg_brightness;

    rb->memmove(_grey_info.buffer + shift, _grey_info.buffer,
                           length);
    rb->memset(_grey_info.buffer, blank, shift);
}

/*** Unbuffered scrolling functions ***/

/* Scroll left */
void grey_ub_scroll_left(int count)
{
    unsigned char *data, *data_end;
    int blank, length;

    if ((unsigned)count >= (unsigned)_grey_info.width)
        return;

    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;
    blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
                              _grey_info.fg_brightness :
                              _grey_info.bg_brightness];
    do
    {
        rb->memmove(data, data + count, length);
        data += length;
        rb->memset(data, blank, count);
        data += count;
    }
    while (data < data_end);
#ifdef SIMULATOR
    rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
                                          _grey_info.width, _grey_info.height);
#endif
}

/* Scroll right */
void grey_ub_scroll_right(int count)
{
    unsigned char *data, *data_end;
    int blank, length;

    if ((unsigned)count >= (unsigned)_grey_info.width)
        return;

    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;
    blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
                              _grey_info.fg_brightness :
                              _grey_info.bg_brightness];
    do
    {
        rb->memmove(data + count, data, length);
        rb->memset(data, blank, count);
        data += _grey_info.width << _GREY_BSHIFT;
    }
    while (data < data_end);
#ifdef SIMULATOR
    rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
                                          _grey_info.width, _grey_info.height);
#endif
}

/* Scroll up */
void grey_ub_scroll_up(int count)
{
    unsigned char *dst, *end, *src;
    int blank;

    if ((unsigned)count >= (unsigned)_grey_info.height)
        return;

    dst   = _grey_info.values;
    end   = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width);
    blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
                              _grey_info.fg_brightness :
                              _grey_info.bg_brightness];

#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
 || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
    if (count & _GREY_BMASK)
    {
        /* Scrolling by fractional blocks - move pixel wise. */
        unsigned char *line_end;
        int ys, yd;

        for (ys = count, yd = 0; ys < _grey_info.height; ys++, yd++)
        {
            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);
        }
    }
    else
#endif
    {
        int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width);

        src = dst + _GREY_MULUQ(count, _grey_info.width);
        rb->memmove(dst, src, blen);
        dst += blen;
    }
    rb->memset(dst, blank, end - dst); /* Fill remainder at once. */
#ifdef SIMULATOR
    rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
                                          _grey_info.width, _grey_info.height);
#endif
}

/* Scroll down */
void grey_ub_scroll_down(int count)
{
    unsigned char *start, *dst;
    int blank;

    if ((unsigned)count >= (unsigned)_grey_info.height)
        return;

    start = _grey_info.values;
    dst   = start + _GREY_MULUQ(_grey_info.height, _grey_info.width);
    blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
                              _grey_info.fg_brightness :
                              _grey_info.bg_brightness];

#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
 || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
    if (count & _GREY_BMASK)
    {
        /* Scrolling by fractional blocks - move pixel wise. */
        unsigned char *src, *line_end;
        int ys, yd;

        yd = _grey_info.height - 1;
        for (ys = yd - count; ys >= 0; ys--, yd--)
        {
            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
            {
                line_end -= _GREY_BSIZE;
                *line_end = blank;
            }
            while (dst < line_end);
        }
        /* 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;
    }
    else
#endif
    {
        int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width);

        dst -= blen;
        rb->memmove(dst, start, blen);
    }
    rb->memset(start, blank, dst - start);
    /* Fill remainder at once. */
#ifdef SIMULATOR
    rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
                                          _grey_info.width, _grey_info.height);
#endif
}