2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file 32bpp_noanim.cpp 32bpp blitter without animation support. */
10 #include "../stdafx.h"
12 #include "32bpp_noanim.hpp"
14 #include "../table/sprites.h"
16 void Blitter_32bppNoanim::Surface::set_pixel (void *video
, int x
, int y
, uint8 colour
)
18 *(this->movep
<Colour
> (video
, x
, y
)) = LookupColourInPalette (colour
);
21 void Blitter_32bppNoanim::Surface::draw_rect (void *video
, int width
, int height
, uint8 colour
)
23 Colour colour32
= LookupColourInPalette (colour
);
26 Colour
*dst
= (Colour
*)video
;
27 for (int i
= width
; i
> 0; i
--) {
31 video
= (uint32
*)video
+ this->pitch
;
35 void Blitter_32bppNoanim::Surface::recolour_rect (void *dst
, int width
, int height
, PaletteID pal
)
37 Colour
*udst
= (Colour
*)dst
;
39 if (pal
== PALETTE_TO_TRANSPARENT
) {
41 for (int i
= 0; i
!= width
; i
++) {
42 *udst
= MakeTransparent (*udst
, 154);
45 udst
= udst
- width
+ this->pitch
;
49 if (pal
== PALETTE_NEWSPAPER
) {
51 for (int i
= 0; i
!= width
; i
++) {
52 *udst
= MakeGrey (*udst
);
55 udst
= udst
- width
+ this->pitch
;
60 DEBUG(misc
, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal
);
63 void Blitter_32bppNoanim::Surface::draw_checker (void *video
, uint width
, uint height
, uint8 colour
, byte bo
)
65 Colour colour32
= LookupColourInPalette (colour
);
66 Colour
*dst
= (Colour
*) video
;
69 for (i
= !(i
& 1); i
< width
; i
+= 2) dst
[i
] = colour32
;
71 } while (--height
> 0);
74 void Blitter_32bppNoanim::Surface::copy (Buffer
*dst
, int x
, int y
, uint width
, uint height
)
76 dst
->resize (width
, height
, sizeof(uint32
));
77 /* Only change buffer capacity? */
78 if ((x
< 0) || (y
< 0)) return;
83 byte
*udst
= &dst
->data
.front();
84 const uint32
*src
= (const uint32
*) this->Blitter_32bppNoanim::Surface::move (this->ptr
, x
, y
);
86 for (; height
> 0; height
--) {
87 memcpy (udst
, src
, width
* sizeof(uint32
));
88 udst
+= width
* sizeof(uint32
);
92 /* Sanity check that we did not overrun the buffer. */
93 assert (udst
<= &dst
->data
.front() + dst
->data
.size());
96 void Blitter_32bppNoanim::Surface::paste (const Buffer
*src
, int x
, int y
)
98 uint32
*dst
= (uint32
*) this->Blitter_32bppNoanim::Surface::move (this->ptr
, x
, y
);
99 const byte
*usrc
= &src
->data
.front();
101 const uint width
= src
->width
;
102 for (uint height
= src
->height
; height
> 0; height
--) {
103 memcpy (dst
, usrc
, width
* sizeof(uint32
));
104 usrc
+= width
* sizeof(uint32
);