10 #include "../stdafx.h"
11 #include "../video/video_driver.hpp"
12 #include "../palette_func.h"
16 #include "../table/sprites.h"
18 #include "../safeguards.h"
23 Blitter_32bppAnim::~Blitter_32bppAnim()
28 template <BlitterMode mode>
31 const SpriteData *src = (
const SpriteData *)bp->
sprite;
33 const Colour *src_px = (
const Colour *)(src->data + src->offset[zoom][0]);
34 const uint16_t *src_n = (
const uint16_t *)(src->data + src->offset[zoom][1]);
36 for (uint i = bp->
skip_top; i != 0; i--) {
37 src_px = (
const Colour *)((
const byte *)src_px + *(
const uint32_t *)src_px);
38 src_n = (
const uint16_t *)((
const byte *)src_n + *(
const uint32_t *)src_n);
42 uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->
dst) + bp->
top * this->anim_buf_pitch + bp->
left;
44 const byte *remap = bp->
remap;
46 for (
int y = 0; y < bp->
height; y++) {
50 const Colour *src_px_ln = (
const Colour *)((
const byte *)src_px + *(
const uint32_t *)src_px);
53 const uint16_t *src_n_ln = (
const uint16_t *)((
const byte *)src_n + *(
const uint32_t *)src_n);
60 while (dst < dst_end) {
68 if (dst > dst_end) anim += dst - dst_end;
70 if (dst + n > dst_end) {
71 uint d = dst_end - dst;
76 dst_end = dst + bp->
width;
78 n = std::min(n - d, (uint)bp->
width);
92 while (dst < dst_end) {
93 n = std::min<uint>(*src_n++, dst_end - dst);
107 if (src_px->a == 255) {
115 uint r = remap[
GB(m, 0, 8)];
116 *anim = r | (m & 0xFF00);
131 uint r = remap[
GB(m, 0, 8)];
144 if (src_px->a == 255) {
148 uint8_t g =
MakeDark(src_px->r, src_px->g, src_px->b);
152 uint r = remap[
GB(m, 0, 8)];
153 *anim = r | (m & 0xFF00);
165 if (src_px->a != 0) {
166 uint8_t g =
MakeDark(src_px->r, src_px->g, src_px->b);
171 uint r = remap[
GB(m, 0, 8)];
196 if (src_px->a == 255) {
218 if (src_px->a != 0) {
234 if (src_px->a == 255) {
237 uint m =
GB(*src_n, 0, 8);
246 uint m =
GB(*src_n, 0, 8);
278 default: NOT_REACHED();
279 case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom);
return;
297 uint16_t *anim = this->
anim_buf + this->ScreenToAnimOffset((uint32_t *)dst);
301 for (
int i = 0; i != width; i++) {
307 udst = udst - width + _screen.pitch;
314 for (
int i = 0; i != width; i++) {
320 udst = udst - width + _screen.pitch;
326 Debug(misc, 0,
"32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
336 this->
anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->
anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
339 void Blitter_32bppAnim::DrawLine(
void *video,
int x,
int y,
int x2,
int y2,
int screen_width,
int screen_height, uint8_t colour,
int width,
int dash)
344 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](
int x,
int y) {
345 *((
Colour *)video + x + y * _screen.pitch) = c;
348 uint16_t *
const offset_anim_buf = this->
anim_buf + this->ScreenToAnimOffset((uint32_t *)video);
349 const uint16_t anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
350 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](
int x,
int y) {
351 *((
Colour *)video + x + y * _screen.pitch) = c;
366 uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->
anim_buf;
370 uint16_t *anim = anim_line;
372 for (
int i = width; i > 0; i--) {
375 *anim = colour | (DEFAULT_BRIGHTNESS << 8);
379 video = (uint32_t *)video + _screen.pitch;
380 anim_line += this->anim_buf_pitch;
387 assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
389 const uint32_t *usrc = (
const uint32_t *)src;
390 uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->
anim_buf;
392 for (; height > 0; height--) {
395 uint16_t *anim_pal = anim_line;
397 memcpy(
static_cast<void *
>(dst), usrc, width *
sizeof(uint32_t));
399 dst += _screen.pitch;
401 memcpy(anim_line, usrc, width *
sizeof(uint16_t));
402 usrc = (
const uint32_t *)&((
const uint16_t *)usrc)[width];
412 for (
int i = 0; i < width; i++) {
413 uint colour =
GB(*anim_pal, 0, 8);
427 assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
428 uint32_t *udst = (uint32_t *)dst;
429 const uint32_t *src = (
const uint32_t *)video;
431 if (this->
anim_buf ==
nullptr)
return;
433 const uint16_t *anim_line = this->ScreenToAnimOffset((
const uint32_t *)video) + this->
anim_buf;
435 for (; height > 0; height--) {
436 memcpy(udst, src, width *
sizeof(uint32_t));
437 src += _screen.pitch;
440 memcpy(udst, anim_line, width *
sizeof(uint16_t));
441 udst = (uint32_t *)&((uint16_t *)udst)[width];
449 assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
454 dst = this->
anim_buf + left + (top + height - 1) * this->anim_buf_pitch;
464 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
465 uint th = height - scroll_y;
466 for (; th > 0; th--) {
467 memcpy(dst, src, tw *
sizeof(uint16_t));
485 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
486 uint th = height + scroll_y;
487 for (; th > 0; th--) {
488 memmove(dst, src, tw *
sizeof(uint16_t));
499 return (
sizeof(uint32_t) +
sizeof(uint16_t)) * width * height;
512 const uint16_t *anim = this->
anim_buf;
516 const int width = this->anim_buf_width;
517 const int pitch_offset = _screen.pitch - width;
518 const int anim_pitch_offset = this->anim_buf_pitch - width;
520 for (
int x = width; x != 0 ; x--) {
521 uint16_t value = *anim;
522 uint8_t colour =
GB(value, 0, 8);
531 anim += anim_pitch_offset;
545 if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height ||
546 _screen.pitch != this->anim_buf_pitch) {
551 this->anim_buf_pitch = (_screen.width + 7) & ~7;
555 this->
anim_buf =
reinterpret_cast<uint16_t *
>((
reinterpret_cast<uintptr_t
>(this->
anim_alloc) + 0xF) & (~0xF));