summaryrefslogtreecommitdiff
path: root/apps/codecs/lib/codeclib.h
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2012-04-08 11:46:02 +0200
committerBertrik Sikken <bertrik@sikken.nl>2012-04-08 11:46:02 +0200
commita12b2a5df96233465a2811f9b056e15d7ff30ee2 (patch)
tree18c388393659a32d6cd150592ac5527e8268cba1 /apps/codecs/lib/codeclib.h
parent80f9577d815e670cbf1110e9a4d52212371f6af6 (diff)
downloadrockbox-a12b2a5df96233465a2811f9b056e15d7ff30ee2.zip
rockbox-a12b2a5df96233465a2811f9b056e15d7ff30ee2.tar.gz
rockbox-a12b2a5df96233465a2811f9b056e15d7ff30ee2.tar.bz2
rockbox-a12b2a5df96233465a2811f9b056e15d7ff30ee2.tar.xz
mkamsboot: add support for clip zip original firmware 01.01.20 (tested by me)
Change-Id: I1d071539d496c63f47d305375e244f9fbe107ced
Diffstat (limited to 'apps/codecs/lib/codeclib.h')
0 files changed, 0 insertions, 0 deletions
0 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 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930
/***************************************************************************
*             __________               __   ___.
*   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
*   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
*   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
*   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
*                     \/            \/     \/    \/            \/
* $Id$
*
* Greyscale framework
* Scrolling routines
*
* This is a generic framework to display up to 33 shades of grey
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey, iPod 4-grey)
* within plugins.
*
* Copyright (C) 2004-2006 Jens Arnold
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* 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 "gray.h"

/*** Scrolling ***/

#if LCD_PIXELFORMAT == HORIZONTAL_PACKING

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

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

    data = _gray_info.cur_buffer;
    data_end = data + MULU16(_gray_info.width, _gray_info.height);
    length = _gray_info.width - count;
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    do
    {
        _gray_rb->memmove(data, data + count, length);
        _gray_rb->memset(data + length, blank, count);
        data += _gray_info.width;
    }
    while (data < data_end);
}

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

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

    data = _gray_info.cur_buffer;
    data_end = data + MULU16(_gray_info.width, _gray_info.height);
    length = _gray_info.width - count;
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    do
    {
        _gray_rb->memmove(data + count, data, length);
        _gray_rb->memset(data, blank, count);
        data += _gray_info.width;
    }
    while (data < data_end);
}

/* Scroll up */
void gray_scroll_up(int count)
{
    long shift, length;
    int blank;

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

    shift = MULU16(_gray_info.width, count);
    length = MULU16(_gray_info.width, _gray_info.height - count);
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    _gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift,
                      length);
    _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
}

/* Scroll down */
void gray_scroll_down(int count)
{
    long shift, length;
    int blank;

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

    shift = MULU16(_gray_info.width, count);
    length = MULU16(_gray_info.width, _gray_info.height - count);
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    _gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer,
                      length);
    _gray_rb->memset(_gray_info.cur_buffer, blank, shift);
}

#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */

/* Scroll left */
void gray_scroll_left(int count)
{
    long shift, length;
    int blank;

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

    shift = MULU16(_gray_info.height, count);
    length = MULU16(_gray_info.height, _gray_info.width - count);
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    _gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift,
                      length);
    _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
}

/* Scroll right */
void gray_scroll_right(int count)
{
    long shift, length;
    int blank;

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

    shift = MULU16(_gray_info.height, count);
    length = MULU16(_gray_info.height, _gray_info.width - count);
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    _gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer,
                      length);
    _gray_rb->memset(_gray_info.cur_buffer, blank, shift);
}

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

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

    data = _gray_info.cur_buffer;
    data_end = data + MULU16(_gray_info.width, _gray_info.height);
    length = _gray_info.height - count;
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    do
    {
        _gray_rb->memmove(data, data + count, length);
        _gray_rb->memset(data + length, blank, count);
        data += _gray_info.height;
    }
    while (data < data_end);
}

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

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

    data = _gray_info.cur_buffer;
    data_end = data + MULU16(_gray_info.width, _gray_info.height);
    length = _gray_info.height - count;
    blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
            _gray_info.fg_index : _gray_info.bg_index;

    do
    {
        _gray_rb->memmove(data + count, data, length);
        _gray_rb->memset(data, blank, count);
        data += _gray_info.height;
    }
    while (data < data_end);
}
#endif /* LCD_PIXELFORMAT */

/*** Unbuffered scrolling functions ***/

#ifdef SIMULATOR

/* Scroll left */
void gray_ub_scroll_left(int count)
{
    gray_scroll_left(count);
    gray_update();
}

/* Scroll right */
void gray_ub_scroll_right(int count)
{
    gray_scroll_right(count);
    gray_update();
}

/* Scroll up */
void gray_ub_scroll_up(int count)
{
    gray_scroll_up(count);
    gray_update();
}

/* Scroll down */
void gray_ub_scroll_down(int count)
{
    gray_scroll_down(count);
    gray_update();
}

#else /* !SIMULATOR */

#if LCD_PIXELFORMAT == HORIZONTAL_PACKING

/* Scroll left */
void gray_ub_scroll_left(int count)
{
    int shift, length;
    unsigned char *ptr, *ptr_end;

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

    shift = count >> 3;
    count &= 7;

    if (shift)
    {
        length = _gray_info.bwidth - shift;
        ptr = _gray_info.plane_data;
        ptr_end = ptr + _gray_info.plane_size;

        /* Scroll row by row to minimize flicker */
        do
        {
            unsigned char *ptr_row = ptr;
            unsigned char *row_end = ptr_row
                             + MULU16(_gray_info.plane_size, _gray_info.depth);
            do
            {
                _gray_rb->memmove(ptr_row, ptr_row + shift, length);
                _gray_rb->memset(ptr_row + length, 0, shift);
                ptr_row += _gray_info.plane_size;
            }
            while (ptr_row < row_end);

            ptr += _gray_info.bwidth;
        }
        while (ptr < ptr_end);
    }
    if (count)
    {
        asm (
            "mov     r4, %[high]             \n" /* rows = height */

        ".sl_rloop:                          \n" /* repeat for every row */
            "mov     r5, %[addr]             \n" /* get start address */
            "mov     r2, %[dpth]             \n" /* planes = depth */

        ".sl_oloop:                          \n" /* repeat for every bitplane */
            "mov     r6, r5                  \n" /* get start address */
            "mov     r3, %[cols]             \n" /* cols = col_count */
            "mov     r1, #0                  \n" /* fill with zero */

        ".sl_iloop:                          \n" /* repeat for all cols */
            "mov     r1, r1, lsr #8          \n" /* shift right to get residue */
            "ldrb    r0, [r6, #-1]!          \n" /* decrement addr & get data byte */
            "orr     r1, r1, r0, lsl %[cnt]  \n" /* combine with last residue */
            "strb    r1, [r6]                \n" /* store data */

            "subs    r3, r3, #1              \n" /* cols-- */
            "bne     .sl_iloop               \n"

            "add     r5, r5, %[psiz]         \n" /* start_address += plane_size */
            "subs    r2, r2, #1              \n" /* planes-- */
            "bne     .sl_oloop               \n"

            "add     %[addr],%[addr],%[bwid] \n" /* start_address += bwidth */
            "subs    r4, r4, #1              \n" /* rows-- */
            "bne     .sl_rloop               \n"
            : /* outputs */
            : /* inputs */
            [dpth]"r"(_gray_info.depth),
            [high]"r"(_gray_info.height),
            [bwid]"r"(_gray_info.bwidth),
            [cols]"r"(_gray_info.bwidth - shift),
            [psiz]"r"(_gray_info.plane_size),
            [addr]"r"(_gray_info.plane_data + _gray_info.bwidth - shift),
            [cnt] "r"(count)
            : /* clobbers */
            "r0", "r1", "r2", "r3", "r4", "r5", "r6"
        );
    }
}

/* Scroll right */
void gray_ub_scroll_right(int count)
{
    int shift, length;
    unsigned char *ptr, *ptr_end;

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

    shift = count >> 3;
    count &= 7;

    if (shift)
    {
        length = _gray_info.bwidth - shift;
        ptr = _gray_info.plane_data;
        ptr_end = ptr + _gray_info.plane_size;

        /* Scroll row by row to minimize flicker */
        do
        {
            unsigned char *ptr_row = ptr;
            unsigned char *row_end = ptr_row
                             + MULU16(_gray_info.plane_size, _gray_info.depth);
            do
            {
                _gray_rb->memmove(ptr_row + shift, ptr_row, length);
                _gray_rb->memset(ptr_row, 0, shift);
                ptr_row += _gray_info.plane_size;
            }
            while (ptr_row < row_end);

            ptr += _gray_info.bwidth;
        }
        while (ptr < ptr_end);
    }
    if (count)
    {
        asm (
            "mov     r4, %[high]             \n" /* rows = height */

        ".sr_rloop:                          \n" /* repeat for every row */
            "mov     r5, %[addr]             \n" /* get start address */
            "mov     r2, %[dpth]             \n" /* planes = depth */

        ".sr_oloop:                          \n" /* repeat for every bitplane */
            "mov     r6, r5                  \n" /* get start address */
            "mov     r3, %[cols]             \n" /* cols = col_count */
            "mov     r1, #0                  \n" /* fill with zero */

        ".sr_iloop:                          \n" /* repeat for all cols */
            "ldrb    r0, [r6]                \n" /* get data byte */
            "orr     r1, r0, r1, lsl #8      \n" /* combine w/ old data shifted to 2nd byte */
            "mov     r0, r1, lsr %[cnt]      \n" /* shift right */
            "strb    r0, [r6], #1            \n" /* store data, increment addr */

            "subs    r3, r3, #1              \n" /* cols-- */
            "bne     .sr_iloop               \n"

            "add     r5, r5, %[psiz]         \n" /* start_address += plane_size */
            "subs    r2, r2, #1              \n" /* planes-- */
            "bne     .sr_oloop               \n"

            "add     %[addr],%[addr],%[bwid] \n" /* start_address += bwidth */
            "subs    r4, r4, #1              \n" /* rows-- */
            "bne     .sr_rloop               \n"
            : /* outputs */
            : /* inputs */
            [dpth]"r"(_gray_info.depth),
            [high]"r"(_gray_info.height),
            [bwid]"r"(_gray_info.bwidth),
            [cols]"r"(_gray_info.bwidth - shift),
            [psiz]"r"(_gray_info.plane_size),
            [addr]"r"(_gray_info.plane_data + shift),
            [cnt] "r"(count)
            : /* clobbers */
            "r0", "r1", "r2", "r3", "r4", "r5", "r6"
        );
    }
}

/* Scroll up */
void gray_ub_scroll_up(int count)
{
    long blockshift;
    unsigned char *ptr, *ptr_end1, *ptr_end2;

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

    blockshift = MULU16(_gray_info.bwidth, count);
    ptr      = _gray_info.plane_data;
    ptr_end2 = ptr + _gray_info.plane_size;
    ptr_end1 = ptr_end2 - blockshift;
    /* Scroll row by row to minimize flicker */
    do
    {
        unsigned char *ptr_row = ptr;
        unsigned char *row_end = ptr_row
                             + MULU16(_gray_info.plane_size, _gray_info.depth);
        if (ptr < ptr_end1)
        {
            do
            {
                _gray_rb->memcpy(ptr_row, ptr_row + blockshift,
                                 _gray_info.bwidth);
                ptr_row += _gray_info.plane_size;
            }
            while (ptr_row < row_end);
        }
        else
        {
            do
            {
                _gray_rb->memset(ptr_row, 0, _gray_info.bwidth);
                ptr_row += _gray_info.plane_size;
            }
            while (ptr_row < row_end);
        }

        ptr += _gray_info.bwidth;
    }
    while (ptr < ptr_end2);
}

/* Scroll down */
void gray_ub_scroll_down(int count)
{
    long blockshift;
    unsigned char *ptr, *ptr_end1, *ptr_end2;

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

    blockshift = MULU16(_gray_info.bwidth, count);
    ptr_end2 = _gray_info.plane_data;
    ptr_end1 = ptr_end2 + blockshift;
    ptr      = ptr_end2 + _gray_info.plane_size;
    /* Scroll row by row to minimize flicker */
    do
    {
        unsigned char *ptr_row, *row_end;

        ptr -= _gray_info.bwidth;
        ptr_row = ptr;
        row_end = ptr_row + MULU16(_gray_info.plane_size, _gray_info.depth);

        if (ptr >= ptr_end1)
        {
            do
            {
                _gray_rb->memcpy(ptr_row, ptr_row - blockshift,
                                 _gray_info.bwidth);
                ptr_row += _gray_info.plane_size;
            }
            while (ptr_row < row_end);
        }
        else
        {
            do
            {
                _gray_rb->memset(ptr_row, 0, _gray_info.bwidth);
                ptr_row += _gray_info.plane_size;
            }
            while (ptr_row < row_end);
        }
    }
    while (ptr > ptr_end2);
}
#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */

/* Scroll left */
void gray_ub_scroll_left(int count)
{
    int length;
    unsigned char *ptr, *ptr_end;

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

    length = _gray_info.width - count;
    ptr = _gray_info.plane_data;
    ptr_end = ptr + _gray_info.plane_size;

    /* Scroll row by row to minimize flicker (pixel block rows) */
    do
    {
        unsigned char *ptr_row = ptr;
        unsigned char *row_end = ptr_row
                             + MULU16(_gray_info.plane_size, _gray_info.depth);
        do
        {
            _gray_rb->memmove(ptr_row, ptr_row + count, length);
            _gray_rb->memset(ptr_row + length, 0, count);
            ptr_row += _gray_info.plane_size;
        }
        while (ptr_row < row_end);

        ptr += _gray_info.width;
    }
    while (ptr < ptr_end);
}

/* Scroll right */
void gray_ub_scroll_right(int count)
{
    int length;
    unsigned char *ptr, *ptr_end;

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

    length = _gray_info.width - count;
    ptr = _gray_info.plane_data;
    ptr_end = ptr + _gray_info.plane_size;

    /* Scroll row by row to minimize flicker (pixel block rows) */
    do
    {
        unsigned char *ptr_row = ptr;
        unsigned char *row_end = ptr_row
                             + MULU16(_gray_info.plane_size, _gray_info.depth);
        do
        {
            _gray_rb->memmove(ptr_row + count, ptr_row, length);
            _gray_rb->memset(ptr_row, 0, count);
            ptr_row += _gray_info.plane_size;
        }
        while (ptr_row < row_end);

        ptr += _gray_info.width;
    }
    while (ptr < ptr_end);
}

/* Scroll up */
void gray_ub_scroll_up(int count)
{
    int shift;
    long blockshift = 0;
    unsigned char *ptr, *ptr_end1, *ptr_end2;

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

    shift = count >> 3;
    count &= 7;

    if (shift)
    {
        blockshift = MULU16(_gray_info.width, shift);
        ptr      = _gray_info.plane_data;
        ptr_end2 = ptr + _gray_info.plane_size;
        ptr_end1 = ptr_end2 - blockshift;
        /* Scroll row by row to minimize flicker (pixel block rows) */
        do
        {
            unsigned char *ptr_row = ptr;
            unsigned char *row_end = ptr_row
                             + MULU16(_gray_info.plane_size, _gray_info.depth);
            if (ptr < ptr_end1)
            {
                do
                {
                    _gray_rb->memcpy(ptr_row, ptr_row + blockshift,
                                     _gray_info.width);
                    ptr_row += _gray_info.plane_size;
                }
                while (ptr_row < row_end);
            }
            else
            {
                do
                {
                    _gray_rb->memset(ptr_row, 0, _gray_info.width);
                    ptr_row += _gray_info.plane_size;
                }
                while (ptr_row < row_end);
            }

            ptr += _gray_info.width;
        }
        while (ptr < ptr_end2);
    }
    if (count)
    {
#if CONFIG_CPU == SH7034
        /* scroll column by column to minimize flicker */
        asm (
            "mov     #0,r6       \n"  /* x = 0 */
            "mova    .su_shifttbl,r0 \n"  /* calculate jump destination for */
            "mov.b   @(r0,%[cnt]),%[cnt] \n"  /* shift amount from table */
            "bra     .su_cloop   \n"  /* skip table */
            "add     r0,%[cnt]   \n"

            ".align  2           \n"
        ".su_shifttbl:           \n"  /* shift jump offset table */
            ".byte   .su_shift0 - .su_shifttbl \n"
            ".byte   .su_shift1 - .su_shifttbl \n"
            ".byte   .su_shift2 - .su_shifttbl \n"
            ".byte   .su_shift3 - .su_shifttbl \n"
            ".byte   .su_shift4 - .su_shifttbl \n"
            ".byte   .su_shift5 - .su_shifttbl \n"
            ".byte   .su_shift6 - .su_shifttbl \n"
            ".byte   .su_shift7 - .su_shifttbl \n"

        ".su_cloop:              \n"  /* repeat for every column */
            "mov     %[addr],r2  \n"  /* get start address */
            "mov     #0,r3       \n"  /* current_plane = 0 */

        ".su_oloop:              \n"  /* repeat for every bitplane */
            "mov     r2,r4       \n"  /* get start address */
            "mov     #0,r5       \n"  /* current_row = 0 */
            "mov     #0,r1       \n"  /* fill with zero */

        ".su_iloop:              \n"  /* repeat for all rows */
            "sub     %[wide],r4  \n"  /* address -= width */
            "mov.b   @r4,r0      \n"  /* get data byte */
            "shll8   r1          \n"  /* old data to 2nd byte */
            "extu.b  r0,r0       \n"  /* extend unsigned */
            "or      r1,r0       \n"  /* combine old data */
            "jmp     @%[cnt]     \n"  /* jump into shift "path" */
            "extu.b  r0,r1       \n"  /* store data for next round */

        ".su_shift6:             \n"  /* shift right by 0..7 bits */
            "shll2   r0          \n"
            "bra     .su_shift0  \n"
            "shlr8   r0          \n"
        ".su_shift4:             \n"
            "shlr2   r0          \n"
        ".su_shift2:             \n"
            "bra     .su_shift0  \n"
            "shlr2   r0          \n"
        ".su_shift7:             \n"
            "shlr2   r0          \n"
        ".su_shift5:             \n"
            "shlr2   r0          \n"
        ".su_shift3:             \n"
            "shlr2   r0          \n"
        ".su_shift1:             \n"
            "shlr    r0          \n"
        ".su_shift0:             \n"

            "mov.b   r0,@r4      \n"  /* store data */
            "add     #1,r5       \n"  /* current_row++ */
            "cmp/hi  r5,%[rows]  \n"  /* current_row < bheight - shift ? */
            "bt      .su_iloop   \n"

            "add     %[psiz],r2  \n"  /* start_address += plane_size */
            "add     #1,r3       \n"  /* current_plane++ */
            "cmp/hi  r3,%[dpth]  \n"  /* current_plane < depth ? */
            "bt      .su_oloop   \n"

            "add     #1,%[addr]  \n"  /* start_address++ */
            "add     #1,r6       \n"  /* x++ */
            "cmp/hi  r6,%[wide]  \n"  /* x < width ? */
            "bt      .su_cloop   \n"
            : /* outputs */
            : /* inputs */
            [dpth]"r"(_gray_info.depth),
            [addr]"r"(_gray_info.plane_data + _gray_info.plane_size - blockshift),
            [wide]"r"(_gray_info.width),
            [rows]"r"(_gray_info.bheight - shift),
            [psiz]"r"(_gray_info.plane_size),
            [cnt] "r"(count)
            : /* clobbers */
            "r0", "r1", "r2", "r3", "r4", "r5", "r6"
        );
#elif defined(CPU_COLDFIRE)
        /* scroll column by column to minimize flicker */
        asm (
            "move.l  %[wide],%%d4\n"  /* columns = width */

        ".su_cloop:              \n"  /* repeat for every column */
            "move.l  %[addr],%%a0\n"  /* get start address */
            "move.l  %[dpth],%%d2\n"  /* planes = depth */

        ".su_oloop:              \n"  /* repeat for every bitplane */
            "move.l  %%a0,%%a1   \n"  /* get start address */
            "move.l  %[rows],%%d3\n"  /* rows = row_count */
            "clr.l   %%d1        \n"  /* fill with zero */

        ".su_iloop:              \n"  /* repeat for all rows */
            "sub.l   %[wide],%%a1\n"  /* address -= width */

            "clr.l   %%d0        \n"
            "move.b  (%%a1),%%d0 \n"  /* get data byte */
            "lsl.l   #8,%%d1     \n"  /* old data to 2nd byte */
            "or.l    %%d1,%%d0   \n"  /* combine old data */
            "move.l  %%d0,%%d1   \n"  /* keep data for next round */
            "lsr.l   %[cnt],%%d0 \n"  /* shift right */
            "move.b  %%d0,(%%a1) \n"  /* store data */

            "subq.l  #1,%%d3     \n"  /* rows-- */
            "bne.b   .su_iloop   \n"

            "add.l   %[psiz],%%a0\n"  /* start_address += plane_size */
            "subq.l  #1,%%d2     \n"  /* planes-- */
            "bne.b   .su_oloop   \n"

            "addq.l  #1,%[addr]  \n"  /* start_address++ */
            "subq.l  #1,%%d4     \n"  /* columns-- */
            "bne.b   .su_cloop   \n"
            : /* outputs */
            : /* inputs */
            [psiz]"r"(_gray_info.plane_size),
            [dpth]"r"(_gray_info.depth),
            [wide]"r"(_gray_info.width),
            [rows]"r"(_gray_info.bheight - shift),
            [addr]"a"(_gray_info.plane_data + _gray_info.plane_size - blockshift),
            [cnt] "d"(count)
            : /* clobbers */
            "a0", "a1", "d0", "d1", "d2", "d3", "d4"
        );
#endif
    }
}

/* Scroll down */