From 6785ea670fa3eb4734be42851b0f31199bc5b7e5 Mon Sep 17 00:00:00 2001 From: truelight Date: Mon, 18 Jun 2007 20:08:21 +0000 Subject: (svn r10206) -Codechange: more moving things to blitter-layer: ScrollBuffer --- src/blitter/8bpp_base.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/blitter/8bpp_base.cpp') diff --git a/src/blitter/8bpp_base.cpp b/src/blitter/8bpp_base.cpp index 65de3b195..0a2ca6b52 100644 --- a/src/blitter/8bpp_base.cpp +++ b/src/blitter/8bpp_base.cpp @@ -126,6 +126,58 @@ void Blitter_8bppBase::MoveBuffer(void *video_dst, const void *video_src, int wi } } +void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) +{ + const uint8 *src; + uint8 *dst; + + if (scroll_y > 0) { + /*Calculate pointers */ + dst = (uint8 *)video + left + (top + height - 1) * _screen.pitch; + src = dst - scroll_y * _screen.pitch; + + /* Decrease height and increase top */ + top += scroll_y; + height -= scroll_y; + assert(height > 0); + + /* Adjust left & width */ + if (scroll_x >= 0) { + dst += scroll_x; + left += scroll_x; + width -= scroll_x; + } else { + src -= scroll_x; + width += scroll_x; + } + + /* Negative height as we want to copy from bottom to top */ + this->CopyFromBuffer(dst, src, width, -height, _screen.pitch); + } else { + /* Calculate pointers */ + dst = (uint8 *)video + left + top * _screen.pitch; + src = dst - scroll_y * _screen.pitch; + + /* Decrese height. (scroll_y is <=0). */ + height += scroll_y; + assert(height > 0); + + /* Adjust left & width */ + if (scroll_x >= 0) { + dst += scroll_x; + left += scroll_x; + width -= scroll_x; + } else { + src -= scroll_x; + width += scroll_x; + } + + /* the y-displacement may be 0 therefore we have to use memmove, + * because source and destination may overlap */ + this->MoveBuffer(dst, src, width, height); + } +} + int Blitter_8bppBase::BufferSize(int width, int height) { return width * height; -- cgit v1.2.3-70-g09d2