r4493@vps: verhaegs | 2007-04-19 14:44:00 -0400
[AROS.git] / rom / graphics / scrollrasterbf.c
blob66077d0446cc1fc7f12e23cf2d65a3869871a5e5
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function ScrollRasterBF()
6 Lang: english
7 */
8 #include "graphics_intern.h"
9 #include <graphics/rastport.h>
10 #include <graphics/gfx.h>
11 #include "gfxfuncsupport.h"
13 /*****************************************************************************
15 NAME */
16 #include <graphics/rastport.h>
17 #include <proto/graphics.h>
19 AROS_LH7(void, ScrollRasterBF,
21 /* SYNOPSIS */
22 AROS_LHA(struct RastPort *, rp, A1),
23 AROS_LHA(LONG , dx, D0),
24 AROS_LHA(LONG , dy, D1),
25 AROS_LHA(LONG , xMin, D2),
26 AROS_LHA(LONG , yMin, D3),
27 AROS_LHA(LONG , xMax, D4),
28 AROS_LHA(LONG , yMax, D5),
30 /* LOCATION */
31 struct GfxBase *, GfxBase, 167, Graphics)
33 /* FUNCTION
34 Scroll the contents of a rastport (dx,dy) towards (0,0).
35 The empty spaces is filled by a call to EraseRect().
36 Only the pixel in the rectangle (xMin,yMin)-(xMax,yMax)
37 will be affected. The lower right corner (xMax, yMax) is
38 automatically adjusted to the lower right corner in case
39 it would be outside.
40 After this operation the Flags bit of the layer associated
41 with this rastport, if there is any layer, should be tested
42 for simple layers in case there has any damage been created.
45 INPUTS
46 rp - pointer to rastport
47 dx,dy - distance to move in x and y direction. Positive values go
48 towards (0,0)
49 xMin,yMin - upper left hand corner of the affected rectangle
50 xMax,yMax - lower right hand corner of the affected rectangle
52 RESULT
54 NOTES
56 EXAMPLE
58 BUGS
60 SEE ALSO
62 INTERNALS
64 HISTORY
66 *****************************************************************************/
68 AROS_LIBFUNC_INIT
69 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
71 LONG width, height, absdx, absdy;
73 FIX_GFXCOORD(xMin);
74 FIX_GFXCOORD(yMin);
75 FIX_GFXCOORD(xMax);
76 FIX_GFXCOORD(yMax);
78 if ((xMin > xMax) || (yMin > yMax)) return;
81 This function will simply call ScrollRaster() and fill the empty
82 space with calls to EraseRect()
86 adjust xMax and yMax in case the lower right corner would be outside
87 the rastport
89 /* Is it a window's rastport ? */
90 if (NULL != rp->Layer)
92 struct Layer * L = rp->Layer;
94 if (xMax > (L->bounds.MaxX - L->bounds.MinX) )
95 xMax = (L->bounds.MaxX - L->bounds.MinX) ;
97 if (yMax > (L->bounds.MaxY - L->bounds.MinY) )
98 yMax = (L->bounds.MaxY - L->bounds.MinY) ;
101 else
103 /* this one belongs to a screen */
104 struct BitMap * bm = rp->BitMap;
106 ULONG width = GetBitMapAttr(bm, BMA_WIDTH);
107 ULONG height = GetBitMapAttr(bm, BMA_HEIGHT);
109 if ((ULONG)xMax >= width )
110 xMax = width - 1;
112 if ((ULONG)yMax >= height)
113 yMax = height - 1;
116 absdx = (dx >= 0) ? dx : -dx;
117 absdy = (dy >= 0) ? dy : -dy;
119 width = xMax - xMin + 1;
120 height = yMax - yMin + 1;
122 if ((width < 1) || (height < 1)) return;
124 if ((absdx >= width) || (absdy >= height))
126 EraseRect(rp, xMin, yMin, xMax, yMax);
127 return;
131 if (FALSE == MoveRaster(rp, dx, dy, xMin, yMin, xMax, yMax, TRUE, GfxBase))
132 return;
135 The raster is scrolled and I fill the empty area with the
136 EraseRect()
139 /* was it scrolled left or right? */
140 if (0 != dx)
142 if (dx > 0)
144 /* scrolled towards left, clearing on the right */
145 EraseRect(rp,
146 xMax - dx + 1,
147 yMin,
148 xMax,
149 yMax);
151 else
153 /* scrolled towards right, clearing on the left */
154 EraseRect(rp,
155 xMin,
156 yMin,
157 xMin - dx - 1, /* a scroll by -1 should only erase a row of width 1 */
158 yMax);
162 if (0 != dy)
164 if (dy > 0)
166 /* scrolled up, clearing on the bottom */
167 EraseRect(rp,
168 xMin,
169 yMax - dy + 1,
170 xMax,
171 yMax);
173 else
175 /* scrolled down, clearing on the top */
176 EraseRect(rp,
177 xMin,
178 yMin,
179 xMax,
180 yMin - dy - 1);
185 AROS_LIBFUNC_EXIT
186 } /* ScrollRasterBF */