12 #include "../stdafx.h" 16 #include "../safeguards.h" 20 return (uint32 *)video + x + y * _screen.pitch;
28 void Blitter_32bppBase::DrawLine(
void *video,
int x,
int y,
int x2,
int y2,
int screen_width,
int screen_height, uint8 colour,
int width,
int dash)
31 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](
int x,
int y) {
32 *((
Colour *)video + x + y * _screen.pitch) = c;
42 for (
int i = width; i > 0; i--) {
46 video = (uint32 *)video + _screen.pitch;
52 uint32 *dst = (uint32 *)video;
53 const uint32 *usrc = (
const uint32 *)src;
55 for (; height > 0; height--) {
56 memcpy(dst, usrc, width *
sizeof(uint32));
64 uint32 *udst = (uint32 *)dst;
65 const uint32 *src = (
const uint32 *)video;
67 for (; height > 0; height--) {
68 memcpy(udst, src, width *
sizeof(uint32));
76 uint32 *udst = (uint32 *)dst;
77 const uint32 *src = (
const uint32 *)video;
79 for (; height > 0; height--) {
80 memcpy(udst, src, width *
sizeof(uint32));
93 dst = (uint32 *)video + left + (top + height - 1) * _screen.pitch;
94 src = dst - scroll_y * _screen.pitch;
111 for (
int h = height; h > 0; h--) {
112 memcpy(dst, src, width *
sizeof(uint32));
113 src -= _screen.pitch;
114 dst -= _screen.pitch;
118 dst = (uint32 *)video + left + top * _screen.pitch;
119 src = dst - scroll_y * _screen.pitch;
137 for (
int h = height; h > 0; h--) {
138 memmove(dst, src, width *
sizeof(uint32));
139 src += _screen.pitch;
140 dst += _screen.pitch;
147 return width * height *
sizeof(uint32);
155 Colour Blitter_32bppBase::ReallyAdjustBrightness(
Colour colour, uint8 brightness)
157 assert(DEFAULT_BRIGHTNESS == 1 << 7);
159 uint64 combined = (((uint64) colour.r) << 32) | (((uint64) colour.g) << 16) | ((uint64) colour.b);
160 combined *= brightness;
162 uint16 r =
GB(combined, 39, 9);
163 uint16 g =
GB(combined, 23, 9);
164 uint16 b =
GB(combined, 7, 9);
166 if ((combined & 0x800080008000L) == 0L) {
167 return Colour(r, g, b, colour.
a);
172 if (r > 255) ob += r - 255;
173 if (g > 255) ob += g - 255;
174 if (b > 255) ob += b - 255;
179 r >= 255 ? 255 :
min(r + ob * (255 - r) / 256, 255),
180 g >= 255 ? 255 :
min(g + ob * (255 - g) / 256, 255),
181 b >= 255 ? 255 :
min(b + ob * (255 - b) / 256, 255),
Blitter::PaletteAnimation UsePaletteAnimation()
Check if the blitter uses palette animation at all.
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp...
Information about the currently used palette.
void * MoveTo(void *video, int x, int y)
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
uint8 a
colour channels in LE order
int BufferSize(int width, int height)
Calculate how much memory there is needed for an image of this size in the video-buffer.
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
void DrawRect(void *video, int width, int height, uint8 colour)
Make a single horizontal line in a single colour on the video-buffer.
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.
Base for all 32 bits blitters.
Common functionality for all blitter implementations.
void SetPixel(void *video, int x, int y, uint8 colour)
Draw a pixel with a given colour on the video-buffer.
void CopyFromBuffer(void *video, const void *src, int width, int height)
Copy from a buffer to the screen.
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 T min(const T a, const T b)
Returns the minimum of two values.
void CopyToBuffer(const void *video, void *dst, int width, int height)
Copy from the screen to a 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...
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
PaletteAnimation
Types of palette animation.