10 #include "../stdafx.h"
11 #include "../video/video_driver.hpp"
15 #include "../table/sprites.h"
17 #include "../safeguards.h"
22 Blitter_32bppAnim::~Blitter_32bppAnim()
27 template <BlitterMode mode>
30 const SpriteData *src = (
const SpriteData *)bp->
sprite;
32 const Colour *src_px = (
const Colour *)(src->data + src->offset[zoom][0]);
33 const uint16 *src_n = (
const uint16 *)(src->data + src->offset[zoom][1]);
35 for (uint i = bp->
skip_top; i != 0; i--) {
36 src_px = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
37 src_n = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
41 uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->
dst) + bp->
top * this->anim_buf_pitch + bp->
left;
43 const byte *remap = bp->
remap;
45 for (
int y = 0; y < bp->
height; y++) {
49 const Colour *src_px_ln = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
52 const uint16 *src_n_ln = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
59 while (dst < dst_end) {
67 if (dst > dst_end) anim += dst - dst_end;
69 if (dst + n > dst_end) {
70 uint d = dst_end - dst;
75 dst_end = dst + bp->
width;
77 n = std::min(n - d, (uint)bp->
width);
91 while (dst < dst_end) {
92 n = std::min<uint>(*src_n++, dst_end - dst);
106 if (src_px->a == 255) {
114 uint r = remap[
GB(m, 0, 8)];
115 *anim = r | (m & 0xFF00);
130 uint r = remap[
GB(m, 0, 8)];
143 if (src_px->a == 255) {
147 uint8 g =
MakeDark(src_px->r, src_px->g, src_px->b);
151 uint r = remap[
GB(m, 0, 8)];
152 *anim = r | (m & 0xFF00);
164 if (src_px->a != 0) {
165 uint8 g =
MakeDark(src_px->r, src_px->g, src_px->b);
170 uint r = remap[
GB(m, 0, 8)];
199 if (src_px->a == 255) {
219 if (src_px->a == 255) {
222 uint m =
GB(*src_n, 0, 8);
231 uint m =
GB(*src_n, 0, 8);
263 default: NOT_REACHED();
264 case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom);
return;
281 uint16 *anim = this->
anim_buf + this->ScreenToAnimOffset((uint32 *)dst);
285 for (
int i = 0; i != width; i++) {
291 udst = udst - width + _screen.pitch;
298 for (
int i = 0; i != width; i++) {
304 udst = udst - width + _screen.pitch;
310 DEBUG(misc, 0,
"32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
320 this->
anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->
anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
323 void Blitter_32bppAnim::DrawLine(
void *video,
int x,
int y,
int x2,
int y2,
int screen_width,
int screen_height, uint8 colour,
int width,
int dash)
328 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](
int x,
int y) {
329 *((
Colour *)video + x + y * _screen.pitch) = c;
332 uint16 *
const offset_anim_buf = this->
anim_buf + this->ScreenToAnimOffset((uint32 *)video);
333 const uint16 anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
334 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](
int x,
int y) {
335 *((
Colour *)video + x + y * _screen.pitch) = c;
350 uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->
anim_buf;
354 uint16 *anim = anim_line;
356 for (
int i = width; i > 0; i--) {
359 *anim = colour | (DEFAULT_BRIGHTNESS << 8);
363 video = (uint32 *)video + _screen.pitch;
364 anim_line += this->anim_buf_pitch;
371 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
373 const uint32 *usrc = (
const uint32 *)src;
374 uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->
anim_buf;
376 for (; height > 0; height--) {
379 uint16 *anim_pal = anim_line;
381 memcpy(
static_cast<void *
>(dst), usrc, width *
sizeof(uint32));
383 dst += _screen.pitch;
385 memcpy(anim_line, usrc, width *
sizeof(uint16));
386 usrc = (
const uint32 *)((
const uint16 *)usrc + width);
396 for (
int i = 0; i < width; i++) {
397 uint colour =
GB(*anim_pal, 0, 8);
411 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
412 uint32 *udst = (uint32 *)dst;
413 const uint32 *src = (
const uint32 *)video;
415 if (this->
anim_buf ==
nullptr)
return;
417 const uint16 *anim_line = this->ScreenToAnimOffset((
const uint32 *)video) + this->
anim_buf;
419 for (; height > 0; height--) {
420 memcpy(udst, src, width *
sizeof(uint32));
421 src += _screen.pitch;
424 memcpy(udst, anim_line, width *
sizeof(uint16));
425 udst = (uint32 *)((uint16 *)udst + width);
433 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
438 dst = this->
anim_buf + left + (top + height - 1) * this->anim_buf_pitch;
448 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
449 uint th = height - scroll_y;
450 for (; th > 0; th--) {
451 memcpy(dst, src, tw *
sizeof(uint16));
469 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
470 uint th = height + scroll_y;
471 for (; th > 0; th--) {
472 memmove(dst, src, tw *
sizeof(uint16));
483 return width * height * (
sizeof(uint32) +
sizeof(uint16));
496 const uint16 *anim = this->
anim_buf;
500 const int width = this->anim_buf_width;
501 const int pitch_offset = _screen.pitch - width;
502 const int anim_pitch_offset = this->anim_buf_pitch - width;
504 for (
int x = width; x != 0 ; x--) {
505 uint16 value = *anim;
506 uint8 colour =
GB(value, 0, 8);
515 anim += anim_pitch_offset;
529 if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height ||
530 _screen.pitch != this->anim_buf_pitch) {
535 this->anim_buf_pitch = (_screen.width + 7) & ~7;
539 this->
anim_buf =
reinterpret_cast<uint16 *
>((
reinterpret_cast<uintptr_t
>(this->
anim_alloc) + 0xF) & (~0xF));