static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s)

{

    int copy_count;

    uint8_t *end_ptr;



    if (s->cirrus_srccounter > 0) {

        if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) {

            cirrus_bitblt_common_patterncopy(s, s->cirrus_bltbuf);

        the_end:

            s->cirrus_srccounter = 0;

            cirrus_bitblt_reset(s);

        } else {

            /* at least one scan line */

            do {

                (*s->cirrus_rop)(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr,

                                  s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1);

                cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0,

                                         s->cirrus_blt_width, 1);

                s->cirrus_blt_dstaddr += s->cirrus_blt_dstpitch;

                s->cirrus_srccounter -= s->cirrus_blt_srcpitch;

                if (s->cirrus_srccounter <= 0)

                    goto the_end;

                /* more bytes than needed can be transferred because of

                   word alignment, so we keep them for the next line */

                /* XXX: keep alignment to speed up transfer */

                end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch;

                copy_count = s->cirrus_srcptr_end - end_ptr;

                memmove(s->cirrus_bltbuf, end_ptr, copy_count);

                s->cirrus_srcptr = s->cirrus_bltbuf + copy_count;

                s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch;

            } while (s->cirrus_srcptr >= s->cirrus_srcptr_end);

        }

    }

}
