12 #include "../stdafx.h"
13 #include "../video/video_driver.hpp"
16 #include "../table/sprites.h"
18 #include "../safeguards.h"
23 template <BlitterMode mode>
29 const uint16 *src_n = (
const uint16 *)(src->
data + src->
offset[zoom][1]);
31 for (uint i = bp->
skip_top; i != 0; i--) {
32 src_px = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
33 src_n = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
37 uint16 *anim = this->anim_buf + ((uint32 *)bp->
dst - (uint32 *)_screen.dst_ptr) + bp->
top * this->
anim_buf_width + bp->
left;
39 const byte *remap = bp->
remap;
41 for (
int y = 0; y < bp->
height; y++) {
45 const Colour *src_px_ln = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
48 const uint16 *src_n_ln = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
55 while (dst < dst_end) {
63 if (dst > dst_end) anim += dst - dst_end;
65 if (dst + n > dst_end) {
66 uint d = dst_end - dst;
71 dst_end = dst + bp->
width;
73 n = min<uint>(n - d, (uint)bp->
width);
87 while (dst < dst_end) {
88 n = min<uint>(*src_n++, (uint)(dst_end - dst));
102 if (src_px->a == 255) {
110 uint r = remap[
GB(m, 0, 8)];
111 *anim = r | (m & 0xFF00);
126 uint r = remap[
GB(m, 0, 8)];
139 if (src_px->a == 255) {
143 uint8 g =
MakeDark(src_px->r, src_px->g, src_px->b);
147 uint r = remap[
GB(m, 0, 8)];
148 *anim = r | (m & 0xFF00);
160 if (src_px->a != 0) {
161 uint8 g =
MakeDark(src_px->r, src_px->g, src_px->b);
166 uint r = remap[
GB(m, 0, 8)];
195 if (src_px->a == 255) {
215 if (src_px->a == 255) {
218 uint m =
GB(*src_n, 0, 8);
227 uint m =
GB(*src_n, 0, 8);
259 default: NOT_REACHED();
260 case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom);
return;
279 anim = this->
anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
283 for (
int i = 0; i != width; i++) {
289 udst = udst - width + _screen.pitch;
296 for (
int i = 0; i != width; i++) {
302 udst = udst - width + _screen.pitch;
308 DEBUG(misc, 0,
"32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
317 this->
anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->
anim_buf_width] = colour | (DEFAULT_BRIGHTNESS << 8);
331 anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->
anim_buf;
335 uint16 *anim = anim_line;
337 for (
int i = width; i > 0; i--) {
340 *anim = colour | (DEFAULT_BRIGHTNESS << 8);
344 video = (uint32 *)video + _screen.pitch;
345 anim_line += this->anim_buf_width;
352 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
354 const uint32 *usrc = (
const uint32 *)src;
355 uint16 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->
anim_buf;
357 for (; height > 0; height--) {
360 uint16 *anim_pal = anim_line;
362 memcpy(dst, usrc, width *
sizeof(uint32));
364 dst += _screen.pitch;
366 memcpy(anim_line, usrc, width *
sizeof(uint16));
367 usrc = (
const uint32 *)((
const uint16 *)usrc + width);
377 for (
int i = 0; i < width; i++) {
378 uint colour =
GB(*anim_pal, 0, 8);
392 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
393 uint32 *udst = (uint32 *)dst;
394 const uint32 *src = (
const uint32 *)video;
395 const uint16 *anim_line;
399 anim_line = ((
const uint32 *)video - (uint32 *)_screen.dst_ptr) + this->
anim_buf;
401 for (; height > 0; height--) {
402 memcpy(udst, src, width *
sizeof(uint32));
403 src += _screen.pitch;
406 memcpy(udst, anim_line, width *
sizeof(uint16));
407 udst = (uint32 *)((uint16 *)udst + width);
415 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
430 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
431 uint th = height - scroll_y;
432 for (; th > 0; th--) {
433 memcpy(dst, src, tw *
sizeof(uint16));
451 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
452 uint th = height + scroll_y;
453 for (; th > 0; th--) {
454 memmove(dst, src, tw *
sizeof(uint16));
465 return width * height * (
sizeof(uint32) +
sizeof(uint16));
478 const uint16 *anim = this->
anim_buf;
484 uint colour =
GB(*anim, 0, 8);
506 if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
509 this->
anim_buf = CallocT<uint16>(_screen.width * _screen.height);