12 #include "../stdafx.h" 13 #include "../video/video_driver.hpp" 17 #include "../table/sprites.h" 19 #include "../safeguards.h" 24 Blitter_32bppAnim::~Blitter_32bppAnim()
29 template <BlitterMode mode>
32 const SpriteData *src = (
const SpriteData *)bp->
sprite;
34 const Colour *src_px = (
const Colour *)(src->data + src->offset[zoom][0]);
35 const uint16 *src_n = (
const uint16 *)(src->data + src->offset[zoom][1]);
37 for (uint i = bp->
skip_top; i != 0; i--) {
38 src_px = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
39 src_n = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
43 uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->
dst) + bp->
top * this->
anim_buf_pitch + bp->
left;
45 const byte *remap = bp->
remap;
47 for (
int y = 0; y < bp->
height; y++) {
51 const Colour *src_px_ln = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
54 const uint16 *src_n_ln = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
61 while (dst < dst_end) {
69 if (dst > dst_end) anim += dst - dst_end;
71 if (dst + n > dst_end) {
72 uint d = dst_end - dst;
77 dst_end = dst + bp->
width;
79 n = min<uint>(n - d, (uint)bp->
width);
93 while (dst < dst_end) {
94 n = min<uint>(*src_n++, (uint)(dst_end - dst));
108 if (src_px->a == 255) {
116 uint r = remap[
GB(m, 0, 8)];
117 *anim = r | (m & 0xFF00);
132 uint r = remap[
GB(m, 0, 8)];
145 if (src_px->a == 255) {
149 uint8 g =
MakeDark(src_px->r, src_px->g, src_px->b);
153 uint r = remap[
GB(m, 0, 8)];
154 *anim = r | (m & 0xFF00);
166 if (src_px->a != 0) {
167 uint8 g =
MakeDark(src_px->r, src_px->g, src_px->b);
172 uint r = remap[
GB(m, 0, 8)];
201 if (src_px->a == 255) {
221 if (src_px->a == 255) {
224 uint m =
GB(*src_n, 0, 8);
233 uint m =
GB(*src_n, 0, 8);
265 default: NOT_REACHED();
266 case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom);
return;
283 uint16 *anim = this->
anim_buf + this->ScreenToAnimOffset((uint32 *)dst);
287 for (
int i = 0; i != width; i++) {
293 udst = udst - width + _screen.pitch;
300 for (
int i = 0; i != width; i++) {
306 udst = udst - width + _screen.pitch;
312 DEBUG(misc, 0,
"32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
322 this->
anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->
anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
325 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)
330 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](
int x,
int y) {
331 *((
Colour *)video + x + y * _screen.pitch) = c;
334 uint16 *
const offset_anim_buf = this->
anim_buf + this->ScreenToAnimOffset((uint32 *)video);
335 const uint16 anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
336 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](
int x,
int y) {
337 *((
Colour *)video + x + y * _screen.pitch) = c;
352 uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->
anim_buf;
356 uint16 *anim = anim_line;
358 for (
int i = width; i > 0; i--) {
361 *anim = colour | (DEFAULT_BRIGHTNESS << 8);
365 video = (uint32 *)video + _screen.pitch;
366 anim_line += this->anim_buf_pitch;
373 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
375 const uint32 *usrc = (
const uint32 *)src;
376 uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->
anim_buf;
378 for (; height > 0; height--) {
381 uint16 *anim_pal = anim_line;
383 memcpy(static_cast<void *>(dst), usrc, width *
sizeof(uint32));
385 dst += _screen.pitch;
387 memcpy(anim_line, usrc, width *
sizeof(uint16));
388 usrc = (
const uint32 *)((
const uint16 *)usrc + width);
398 for (
int i = 0; i < width; i++) {
399 uint colour =
GB(*anim_pal, 0, 8);
413 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
414 uint32 *udst = (uint32 *)dst;
415 const uint32 *src = (
const uint32 *)video;
419 const uint16 *anim_line = this->ScreenToAnimOffset((
const uint32 *)video) + this->
anim_buf;
421 for (; height > 0; height--) {
422 memcpy(udst, src, width *
sizeof(uint32));
423 src += _screen.pitch;
426 memcpy(udst, anim_line, width *
sizeof(uint16));
427 udst = (uint32 *)((uint16 *)udst + width);
435 assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
450 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
451 uint th = height - scroll_y;
452 for (; th > 0; th--) {
453 memcpy(dst, src, tw *
sizeof(uint16));
471 uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
472 uint th = height + scroll_y;
473 for (; th > 0; th--) {
474 memmove(dst, src, tw *
sizeof(uint16));
485 return width * height * (
sizeof(uint32) +
sizeof(uint16));
498 const uint16 *anim = this->
anim_buf;
502 const int width = this->anim_buf_width;
503 const int pitch_offset = _screen.pitch - width;
504 const int anim_pitch_offset = this->anim_buf_pitch - width;
506 for (
int x = width; x != 0 ; x--) {
507 uint16 value = *anim;
508 uint8 colour =
GB(value, 0, 8);
517 anim += anim_pitch_offset;
531 if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height ||
532 _screen.pitch != this->anim_buf_pitch) {
541 this->
anim_buf =
reinterpret_cast<uint16 *
>((
reinterpret_cast<uintptr_t
>(this->
anim_alloc) + 0xF) & (~0xF));
virtual void MakeDirty(int left, int top, int width, int height)=0
Mark a particular area dirty.
int left
The left offset in the 'dst' in pixels to start drawing.
uint32 PaletteID
The number of the palette.
static const PaletteID PALETTE_TO_TRANSPARENT
This sets the sprite to transparent.
Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
Information about the currently used palette.
int height
The height in pixels that needs to be drawn to dst.
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
Draw a colourtable to the screen.
Perform transparency colour remapping.
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
uint32 data
Conversion of the channel information to a 32 bit number.
int width
The width in pixels that needs to be drawn to dst.
uint8 a
colour channels in LE order
void PostResize()
Post resize event.
uint16 * anim_buf
In this buffer we keep track of the 8bpp indexes so we can do palette animation.
int BufferSize(int width, int height)
Calculate how much memory there is needed for an image of this size in the video-buffer.
void * anim_alloc
The raw allocated buffer, not necessarily aligned correctly.
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
static Colour ComposeColourPANoCheck(Colour colour, uint a, Colour current)
Compose a colour based on Pixel value, alpha value, and the current pixel value.
void DrawRect(void *video, int width, int height, uint8 colour)
Make a single horizontal line in a single colour on the video-buffer.
static FBlitter_32bppAnim iFBlitter_32bppAnim
Instantiation of the 32bpp with animation blitter factory.
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
Scroll the videobuffer some 'x' and 'y' value.
void DrawRect(void *video, int width, int height, uint8 colour)
Make a single horizontal line in a single colour on the video-buffer.
Common functionality for all blitter implementations.
The blitter takes care of the palette animation.
int anim_buf_height
The height of the animation buffer.
Parameters related to blitting.
int pitch
The pitch of the destination buffer.
int anim_buf_pitch
The pitch of the animation buffer (width rounded up to 16 byte boundary).
static const PaletteID PALETTE_NEWSPAPER
Recolour sprite for newspaper-greying.
Perform a crash remapping.
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot) ...
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
Draw an image to the screen, given an amount of params defined above.
int first_dirty
The first dirty element.
Perform remapping to a completely blackened sprite.
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
Draw a colourtable to the screen.
#define DEBUG(name, level,...)
Output a line of debugging information.
static Colour MakeGrey(Colour colour)
Make a colour grey - based.
ZoomLevel
All zoom levels we know.
int top
The top offset in the 'dst' in pixels to start drawing.
int anim_buf_width
The width of the animation buffer.
Palette palette
The current palette.
const byte * remap
XXX – Temporary storage for remap array.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Factory for the 32bpp blitter with animation.
const void * sprite
Pointer to the sprite how ever the encoder stored it.
static uint8 MakeDark(uint8 r, uint8 g, uint8 b)
Make a colour dark grey, for specialized 32bpp remapping.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void CopyToBuffer(const void *video, void *dst, int width, int height)
Copy from the screen to a buffer.
Perform a colour remapping.
Blitter::PaletteAnimation UsePaletteAnimation()
Check if the blitter uses palette animation at all.
A 32 bpp blitter with animation support.
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
Scroll the videobuffer some 'x' and 'y' value.
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
Draws a sprite to a (screen) buffer.
void PaletteAnimate(const Palette &palette)
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
void * dst
Destination buffer.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
Perform the simple blitting.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
BlitterMode
The modes of blitting we can do.
PaletteAnimation
Types of palette animation.
void SetPixel(void *video, int x, int y, uint8 colour)
Draw a pixel with a given colour on the video-buffer.
static Colour ComposeColourRGBA(uint r, uint g, uint b, uint a, Colour current)
Compose a colour based on RGBA values and the current pixel value.
void CopyFromBuffer(void *video, const void *src, int width, int height)
Copy from a buffer to the screen.
Index in the _palettes array from which all animations are taking places (table/palettes.h)
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
Draw a line with a given colour.
static Colour MakeTransparent(Colour colour, uint nom, uint denom=256)
Make a pixel looks like it is transparent.
static Colour ComposeColourRGBANoCheck(uint r, uint g, uint b, uint a, Colour current)
Compose a colour based on RGBA values and the current pixel value.