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),