MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ScrollBuffer

Method ScrollBuffer

src/blitter/8bpp_base.cpp:89–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
90{
91 const uint8_t *src;
92 uint8_t *dst;
93
94 if (scroll_y > 0) {
95 /* Calculate pointers */
96 dst = (uint8_t *)video + left + (top + height - 1) * _screen.pitch;
97 src = dst - scroll_y * _screen.pitch;
98
99 /* Decrease height and increase top */
100 top += scroll_y;
101 height -= scroll_y;
102 assert(height > 0);
103
104 /* Adjust left & width */
105 if (scroll_x >= 0) {
106 dst += scroll_x;
107 left += scroll_x;
108 width -= scroll_x;
109 } else {
110 src -= scroll_x;
111 width += scroll_x;
112 }
113
114 Blitter::MovePixels(src, dst, width, height, -_screen.pitch);
115 } else {
116 /* Calculate pointers */
117 dst = (uint8_t *)video + left + top * _screen.pitch;
118 src = dst - scroll_y * _screen.pitch;
119
120 /* Decrease height. (scroll_y is <=0). */
121 height += scroll_y;
122 assert(height > 0);
123
124 /* Adjust left & width */
125 if (scroll_x >= 0) {
126 dst += scroll_x;
127 left += scroll_x;
128 width -= scroll_x;
129 } else {
130 src -= scroll_x;
131 width += scroll_x;
132 }
133
134 Blitter::MovePixels(src, dst, width, height, _screen.pitch);
135 }
136}
137
138size_t Blitter_8bppBase::BufferSize(uint width, uint height)
139{

Callers 1

GfxScrollFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected