84 if (x > 0 && y > 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, color); |
84 if (x > 0 && y > 0 && x < screen_width && y < screen_height) this->SetPixel(video, x, y, color); |
85 } |
85 } |
86 } |
86 } |
87 } |
87 } |
88 |
88 |
89 void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) |
89 void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height) |
90 { |
90 { |
91 int direction = (height < 0) ? -1 : 1; |
|
92 uint8 *dst = (uint8 *)video; |
91 uint8 *dst = (uint8 *)video; |
93 uint8 *usrc = (uint8 *)src; |
92 uint8 *usrc = (uint8 *)src; |
94 |
93 |
95 height = abs(height); |
|
96 for (; height > 0; height--) { |
94 for (; height > 0; height--) { |
97 memcpy(dst, usrc, width); |
95 memcpy(dst, usrc, width * sizeof(uint8)); |
98 usrc += src_pitch * direction; |
96 usrc += width; |
99 dst += _screen.pitch * direction; |
97 dst += _screen.pitch; |
100 } |
98 } |
101 } |
99 } |
102 |
100 |
103 void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) |
101 void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height) |
104 { |
102 { |
105 int direction = (height < 0) ? -1 : 1; |
|
106 uint8 *udst = (uint8 *)dst; |
103 uint8 *udst = (uint8 *)dst; |
107 uint8 *src = (uint8 *)video; |
104 uint8 *src = (uint8 *)video; |
108 |
105 |
109 height = abs(height); |
|
110 for (; height > 0; height--) { |
106 for (; height > 0; height--) { |
111 memcpy(udst, src, width); |
107 memcpy(udst, src, width * sizeof(uint8)); |
112 src += _screen.pitch * direction; |
108 src += _screen.pitch; |
113 udst += dst_pitch * direction; |
109 udst += width; |
114 } |
110 } |
115 } |
111 } |
116 |
112 |
117 void Blitter_8bppBase::MoveBuffer(void *video_dst, const void *video_src, int width, int height) |
113 void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) |
118 { |
114 { |
119 uint8 *dst = (uint8 *)video_dst; |
115 uint8 *udst = (uint8 *)dst; |
120 uint8 *src = (uint8 *)video_src; |
116 uint8 *src = (uint8 *)video; |
121 |
117 |
122 for (; height > 0; height--) { |
118 for (; height > 0; height--) { |
123 memmove(dst, src, width); |
119 memcpy(udst, src, width * sizeof(uint8)); |
124 src += _screen.pitch; |
120 src += _screen.pitch; |
125 dst += _screen.pitch; |
121 udst += dst_pitch; |
126 } |
122 } |
127 } |
123 } |
128 |
124 |
129 void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) |
125 void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) |
130 { |
126 { |
149 } else { |
145 } else { |
150 src -= scroll_x; |
146 src -= scroll_x; |
151 width += scroll_x; |
147 width += scroll_x; |
152 } |
148 } |
153 |
149 |
154 /* Negative height as we want to copy from bottom to top */ |
150 for (int h = height; h > 0; h--) { |
155 this->CopyFromBuffer(dst, src, width, -height, _screen.pitch); |
151 memcpy(dst, src, width * sizeof(uint8)); |
|
152 src -= _screen.pitch; |
|
153 dst -= _screen.pitch; |
|
154 } |
156 } else { |
155 } else { |
157 /* Calculate pointers */ |
156 /* Calculate pointers */ |
158 dst = (uint8 *)video + left + top * _screen.pitch; |
157 dst = (uint8 *)video + left + top * _screen.pitch; |
159 src = dst - scroll_y * _screen.pitch; |
158 src = dst - scroll_y * _screen.pitch; |
160 |
159 |
172 width += scroll_x; |
171 width += scroll_x; |
173 } |
172 } |
174 |
173 |
175 /* the y-displacement may be 0 therefore we have to use memmove, |
174 /* the y-displacement may be 0 therefore we have to use memmove, |
176 * because source and destination may overlap */ |
175 * because source and destination may overlap */ |
177 this->MoveBuffer(dst, src, width, height); |
176 for (int h = height; h > 0; h--) { |
|
177 memmove(dst, src, width * sizeof(uint8)); |
|
178 src += _screen.pitch; |
|
179 dst += _screen.pitch; |
|
180 } |
178 } |
181 } |
179 } |
182 } |
180 |
183 |
181 int Blitter_8bppBase::BufferSize(int width, int height) |
184 int Blitter_8bppBase::BufferSize(int width, int height) |
182 { |
185 { |