10 #include "../stdafx.h"
14 #include "../safeguards.h"
18 return (uint32_t *)video + x + y * _screen.pitch;
26 void Blitter_32bppBase::DrawLine(
void *video,
int x,
int y,
int x2,
int y2,
int screen_width,
int screen_height, uint8_t colour,
int width,
int dash)
29 this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](
int x,
int y) {
30 *((
Colour *)video + x + y * _screen.pitch) = c;
40 for (
int i = width; i > 0; i--) {
44 video = (uint32_t *)video + _screen.pitch;
50 uint32_t *dst = (uint32_t *)video;
51 const uint32_t *usrc = (
const uint32_t *)src;
53 for (; height > 0; height--) {
54 memcpy(dst, usrc, width *
sizeof(uint32_t));
62 uint32_t *udst = (uint32_t *)dst;
63 const uint32_t *src = (
const uint32_t *)video;
65 for (; height > 0; height--) {
66 memcpy(udst, src, width *
sizeof(uint32_t));
74 uint32_t *udst = (uint32_t *)dst;
75 const uint32_t *src = (
const uint32_t *)video;
77 for (; height > 0; height--) {
78 memcpy(udst, src, width *
sizeof(uint32_t));
91 dst = (uint32_t *)video + left + (top + height - 1) * _screen.pitch;
92 src = dst - scroll_y * _screen.pitch;
109 for (
int h = height; h > 0; h--) {
110 memcpy(dst, src, width *
sizeof(uint32_t));
111 src -= _screen.pitch;
112 dst -= _screen.pitch;
116 dst = (uint32_t *)video + left + top * _screen.pitch;
117 src = dst - scroll_y * _screen.pitch;
135 for (
int h = height; h > 0; h--) {
136 memmove(dst, src, width *
sizeof(uint32_t));
137 src += _screen.pitch;
138 dst += _screen.pitch;
145 return sizeof(uint32_t) * width * height;
153 Colour Blitter_32bppBase::ReallyAdjustBrightness(
Colour colour, uint8_t brightness)
155 assert(DEFAULT_BRIGHTNESS == 1 << 7);
157 uint64_t combined = (((uint64_t) colour.r) << 32) | (((uint64_t) colour.g) << 16) | ((uint64_t) colour.b);
158 combined *= brightness;
160 uint16_t r =
GB(combined, 39, 9);
161 uint16_t g =
GB(combined, 23, 9);
162 uint16_t b =
GB(combined, 7, 9);
164 if ((combined & 0x800080008000L) == 0L) {
165 return Colour(r, g, b, colour.
a);
170 if (r > 255) ob += r - 255;
171 if (g > 255) ob += g - 255;
172 if (b > 255) ob += b - 255;
177 r >= 255 ? 255 : std::min(r + ob * (255 - r) / 256, 255),
178 g >= 255 ? 255 : std::min(g + ob * (255 - g) / 256, 255),
179 b >= 255 ? 255 : std::min(b + ob * (255 - b) / 256, 255),
Base for all 32 bits blitters.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
size_t BufferSize(uint width, uint height) override
Calculate how much memory there is needed for an image of this size in the video-buffer.
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override
Draw a line with a given colour.
void CopyToBuffer(const void *video, void *dst, int width, int height) override
Copy from the screen to a buffer.
void DrawRect(void *video, int width, int height, uint8_t colour) override
Make a single horizontal line in a single colour on the video-buffer.
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
Blitter::PaletteAnimation UsePaletteAnimation() override
Check if the blitter uses palette animation at all.
void * MoveTo(void *video, int x, int y) override
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
void PaletteAnimate(const Palette &palette) override
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
void CopyFromBuffer(void *video, const void *src, int width, int height) override
Copy from a buffer to the screen.
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override
Scroll the videobuffer some 'x' and 'y' value.
void SetPixel(void *video, int x, int y, uint8_t colour) override
Draw a pixel with a given colour on the video-buffer.
PaletteAnimation
Types of palette animation.
@ PALETTE_ANIMATION_NONE
No palette animation.
Common functionality for all blitter implementations.
Information about the currently used palette.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
uint8_t a
colour channels in LE order