Adding of _t to (u)int types, and WChar to char32_t

See: eaae0bb5e
This commit is contained in:
Jonathan G Rennison
2024-01-07 16:41:53 +00:00
parent 55d78a23be
commit 97e6f3062e
655 changed files with 7555 additions and 7555 deletions

View File

@@ -33,15 +33,15 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
const BlitterSpriteFlags sprite_flags = src->flags;
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]);
const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
for (uint i = bp->skip_top; i != 0; i--) {
src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
}
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
const byte *remap = bp->remap; // store so we don't have to access it via bp every time
const int width = bp->width;
@@ -52,12 +52,12 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
for (int y = 0; y < height; y++) {
Colour *dst_ln = dst + pitch;
uint16 *anim_ln = anim + anim_pitch;
uint16_t *anim_ln = anim + anim_pitch;
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
src_px++;
const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
src_n += 2;
Colour *dst_end = dst;
@@ -132,7 +132,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
} else {
uint r = remap[GB(m, 0, 8)];
if (r != 0) {
uint8 brightness = GB(m, 8, 8);
uint8_t brightness = GB(m, 8, 8);
if (mode == BM_COLOUR_REMAP_WITH_BRIGHTNESS) {
brightness = Clamp(brightness + bp->brightness_adjust, 0, 255);
SB(m, 8, 8, brightness);
@@ -158,7 +158,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
uint r = remap[GB(m, 0, 8)];
*anim = 0;
if (r != 0) {
uint8 brightness = GB(m, 8, 8);
uint8_t brightness = GB(m, 8, 8);
if (mode == BM_COLOUR_REMAP_WITH_BRIGHTNESS) brightness = Clamp(brightness + bp->brightness_adjust, 0, 255);
*dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), brightness), src_px->a, *dst);
}
@@ -176,7 +176,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
do {
uint m = *src_n;
if (m == 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
*anim = 0;
} else {
@@ -194,7 +194,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
uint m = *src_n;
if (m == 0) {
if (src_px->a != 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
*anim = 0;
}
@@ -273,7 +273,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
} else if (src_px->a == 255) {
do {
/* Compiler assumes pointer aliasing, can't optimise this on its own */
uint16 mv = *src_n;
uint16_t mv = *src_n;
uint m = GB(mv, 0, 8);
/* Above PALETTE_ANIM_START is palette animation */
if (m >= PALETTE_ANIM_START) {
@@ -293,7 +293,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
uint m = GB(*src_n, 0, 8);
*anim++ = 0;
if (m >= PALETTE_ANIM_START) {
uint8 brightness = GB(*src_n, 8, 8);
uint8_t brightness = GB(*src_n, 8, 8);
if (mode == BM_NORMAL_WITH_BRIGHTNESS) brightness = Clamp(brightness + bp->brightness_adjust, 0, 255);
*dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(m), brightness), src_px->a, *dst);
} else {
@@ -373,7 +373,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
}
Colour *udst = (Colour *)dst;
uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)dst);
uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)dst);
if (pal == PALETTE_TO_TRANSPARENT) {
do {
@@ -405,25 +405,25 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
}
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
{
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
/* Set the colour in the anim-buffer too, if we are rendering to the screen */
if (_screen_disable_anim) return;
this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
}
void Blitter_32bppAnim::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32)
void Blitter_32bppAnim::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32)
{
*((Colour *)video + x + y * _screen.pitch) = colour32;
/* Set the colour in the anim-buffer too, if we are rendering to the screen */
if (_screen_disable_anim) return;
this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch] = 0;
this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = 0;
}
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)
void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
{
const Colour c = LookupColourInPalette(colour);
@@ -432,8 +432,8 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
*((Colour *)video + x + y * _screen.pitch) = c;
});
} else {
uint16 * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32 *)video);
const uint16 anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
uint16_t * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)video);
const uint16_t anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
*((Colour *)video + x + y * _screen.pitch) = c;
offset_anim_buf[x + y * this->anim_buf_pitch] = anim_colour;
@@ -441,7 +441,7 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
}
}
void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch)
void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch)
{
Colour *dst = (Colour *)video + x + y * _screen.pitch;
@@ -457,7 +457,7 @@ void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8 *colours,
colours += pitch - width;
} while (--lines);
} else {
uint16 *dstanim = (uint16 *)(&this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch]);
uint16_t *dstanim = (uint16_t *)(&this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch]);
do {
uint w = width;
do {
@@ -474,21 +474,21 @@ void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8 *colours,
}
}
void Blitter_32bppAnim::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch)
void Blitter_32bppAnim::SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch)
{
uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
uint32_t *dst = (uint32_t *)video + x + y * _screen.pitch;
if (_screen_disable_anim) {
do {
memcpy(dst, colours, width * sizeof(uint32));
memcpy(dst, colours, width * sizeof(uint32_t));
dst += _screen.pitch;
colours += pitch;
} while (--lines);
} else {
uint16 *dstanim = (uint16 *)(&this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch]);
uint16_t *dstanim = (uint16_t *)(&this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch]);
do {
memcpy(dst, colours, width * sizeof(uint32));
memset(dstanim, 0, width * sizeof(uint16));
memcpy(dst, colours, width * sizeof(uint32_t));
memset(dstanim, 0, width * sizeof(uint16_t));
dst += _screen.pitch;
dstanim += this->anim_buf_pitch;
colours += pitch;
@@ -496,7 +496,7 @@ void Blitter_32bppAnim::SetRect32(void *video, int x, int y, const uint32 *colou
}
}
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t colour)
{
if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
@@ -505,11 +505,11 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou
}
Colour colour32 = LookupColourInPalette(colour);
uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf;
uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf;
do {
Colour *dst = (Colour *)video;
uint16 *anim = anim_line;
uint16_t *anim = anim_line;
for (int i = width; i > 0; i--) {
*dst = colour32;
@@ -518,12 +518,12 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou
dst++;
anim++;
}
video = (uint32 *)video + _screen.pitch;
video = (uint32_t *)video + _screen.pitch;
anim_line += this->anim_buf_pitch;
} while (--height);
}
void Blitter_32bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour)
void Blitter_32bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour)
{
this->Blitter_32bppAnim::DrawRect((Colour *)video + x + y * _screen.pitch, width, height, colour);
}
@@ -531,22 +531,22 @@ void Blitter_32bppAnim::DrawRectAt(void *video, int x, int y, int width, int hei
void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
Colour *dst = (Colour *)video;
const uint32 *usrc = (const uint32 *)src;
uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf;
const uint32_t *usrc = (const uint32_t *)src;
uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf;
for (; height > 0; height--) {
/* We need to keep those for palette animation. */
Colour *dst_pal = dst;
uint16 *anim_pal = anim_line;
uint16_t *anim_pal = anim_line;
memcpy(static_cast<void *>(dst), usrc, width * sizeof(uint32));
memcpy(static_cast<void *>(dst), usrc, width * sizeof(uint32_t));
usrc += width;
dst += _screen.pitch;
/* Copy back the anim-buffer */
memcpy(anim_line, usrc, width * sizeof(uint16));
usrc = (const uint32 *)&((const uint16 *)usrc)[width];
memcpy(anim_line, usrc, width * sizeof(uint16_t));
usrc = (const uint32_t *)&((const uint16_t *)usrc)[width];
anim_line += this->anim_buf_pitch;
/* Okay, it is *very* likely that the image we stored is using
@@ -571,21 +571,21 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *udst = (uint32 *)dst;
const uint32 *src = (const uint32 *)video;
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32_t *udst = (uint32_t *)dst;
const uint32_t *src = (const uint32_t *)video;
if (this->anim_buf == nullptr) return;
const uint16 *anim_line = this->ScreenToAnimOffset((const uint32 *)video) + this->anim_buf;
const uint16_t *anim_line = this->ScreenToAnimOffset((const uint32_t *)video) + this->anim_buf;
for (; height > 0; height--) {
memcpy(udst, src, width * sizeof(uint32));
memcpy(udst, src, width * sizeof(uint32_t));
src += _screen.pitch;
udst += width;
/* Copy the anim-buffer */
memcpy(udst, anim_line, width * sizeof(uint16));
udst = (uint32 *)&((uint16 *)udst)[width];
memcpy(udst, anim_line, width * sizeof(uint16_t));
udst = (uint32_t *)&((uint16_t *)udst)[width];
anim_line += this->anim_buf_pitch;
}
}
@@ -593,8 +593,8 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint16 *dst, *src;
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint16_t *dst, *src;
/* We need to scroll the anim-buffer too */
if (scroll_y > 0) {
@@ -611,7 +611,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width,
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
uint th = height - scroll_y;
for (; th > 0; th--) {
memcpy(dst, src, tw * sizeof(uint16));
memcpy(dst, src, tw * sizeof(uint16_t));
src -= this->anim_buf_pitch;
dst -= this->anim_buf_pitch;
}
@@ -632,7 +632,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width,
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
uint th = height + scroll_y;
for (; th > 0; th--) {
memmove(dst, src, tw * sizeof(uint16));
memmove(dst, src, tw * sizeof(uint16_t));
src += this->anim_buf_pitch;
dst += this->anim_buf_pitch;
}
@@ -643,7 +643,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width,
size_t Blitter_32bppAnim::BufferSize(uint width, uint height)
{
return (sizeof(uint32) + sizeof(uint16)) * width * height;
return (sizeof(uint32_t) + sizeof(uint16_t)) * width * height;
}
void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
@@ -656,7 +656,7 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
* Especially when going between toyland and non-toyland. */
assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
const uint16 *anim = this->anim_buf;
const uint16_t *anim = this->anim_buf;
Colour *dst = (Colour *)_screen.dst_ptr;
/* Let's walk the anim buffer and try to find the pixels */
@@ -665,8 +665,8 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
const int anim_pitch_offset = this->anim_buf_pitch - width;
for (int y = this->anim_buf_height; y != 0 ; y--) {
for (int x = width; x != 0 ; x--) {
uint16 value = *anim;
uint8 colour = GB(value, 0, 8);
uint16_t value = *anim;
uint8_t colour = GB(value, 0, 8);
if (colour >= PALETTE_ANIM_START) {
/* Update this pixel */
*dst = this->AdjustBrightness(LookupColourInPalette(colour), GB(value, 8, 8));
@@ -695,9 +695,9 @@ void Blitter_32bppAnim::PostResize()
this->anim_buf_width = _screen.width;
this->anim_buf_height = _screen.height;
this->anim_buf_pitch = (_screen.width + 7) & ~7;
this->anim_alloc = CallocT<uint16>(this->anim_buf_pitch * this->anim_buf_height + 8);
this->anim_alloc = CallocT<uint16_t>(this->anim_buf_pitch * this->anim_buf_height + 8);
/* align buffer to next 16 byte boundary */
this->anim_buf = reinterpret_cast<uint16 *>((reinterpret_cast<uintptr_t>(this->anim_alloc) + 0xF) & (~0xF));
this->anim_buf = reinterpret_cast<uint16_t *>((reinterpret_cast<uintptr_t>(this->anim_alloc) + 0xF) & (~0xF));
}
}

View File

@@ -15,7 +15,7 @@
/** The optimised 32 bpp blitter with palette animation. */
class Blitter_32bppAnim : public Blitter_32bppOptimized {
protected:
uint16 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
uint16_t *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
void *anim_alloc; ///< The raw allocated buffer, not necessarily aligned correctly
int anim_buf_width; ///< The width of the animation buffer.
int anim_buf_pitch; ///< The pitch of the animation buffer (width rounded up to 16 byte boundary).
@@ -37,13 +37,13 @@ public:
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
void SetPixel(void *video, int x, int y, uint8 colour) override;
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override;
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8 colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override;
void SetPixel(void *video, int x, int y, uint8_t colour) override;
void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) override;
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;
void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override;
void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8_t colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) override;
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override;
@@ -62,9 +62,9 @@ public:
return this->palette.palette[index];
}
inline int ScreenToAnimOffset(const uint32 *video)
inline int ScreenToAnimOffset(const uint32_t *video)
{
int raw_offset = video - (const uint32 *)_screen.dst_ptr;
int raw_offset = video - (const uint32_t *)_screen.dst_ptr;
if (_screen.pitch == this->anim_buf_pitch) return raw_offset;
int lines = raw_offset / _screen.pitch;
int across = raw_offset % _screen.pitch;

View File

@@ -30,7 +30,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
* Especially when going between toyland and non-toyland. */
assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
const uint16 *anim = this->anim_buf;
const uint16_t *anim = this->anim_buf;
Colour *dst = (Colour *)_screen.dst_ptr;
bool screen_dirty = false;
@@ -44,7 +44,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
__m128i colour_mask = _mm_set1_epi16(0xFF);
for (int y = this->anim_buf_height; y != 0 ; y--) {
Colour *next_dst_ln = dst + screen_pitch;
const uint16 *next_anim_ln = anim + anim_pitch;
const uint16_t *next_anim_ln = anim + anim_pitch;
int x = width;
while (x > 0) {
__m128i data = _mm_load_si128((const __m128i *) anim);
@@ -61,7 +61,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
/* slow path: < 8 pixels left or unexpected brightnesses */
for (int z = std::min<int>(x, 8); z != 0 ; z--) {
int value = _mm_extract_epi16(data, 0);
uint8 colour = GB(value, 0, 8);
uint8_t colour = GB(value, 0, 8);
if (colour >= PALETTE_ANIM_START) {
/* Update this pixel */
*dst = AdjustBrightneSSE(LookupColourInPalette(colour), GB(value, 8, 8));

View File

@@ -35,7 +35,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
{
const byte * const remap = bp->remap;
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
uint16 *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
uint16_t *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
int effective_width = bp->width;
/* Find where to start reading in the source sprite. */
@@ -60,7 +60,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
Colour *dst = dst_line;
const Colour *src = src_rgba_line + META_LENGTH;
if (mode != BM_TRANSPARENT) src_mv = src_mv_line;
uint16 *anim = anim_line;
uint16_t *anim = anim_line;
if (read_mode == RM_WITH_MARGIN) {
assert(bt_last == BT_NONE); // or you must ensure block type is preserved
@@ -82,7 +82,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
for (uint x = (uint) effective_width; x > 0; x--) {
if (src->a) {
if (animated) {
*anim = *(const uint16*) src_mv;
*anim = *(const uint16_t*) src_mv;
*dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(this->LookupColourInPalette(src_mv->m), src_mv->v) : src->data;
} else {
*anim = 0;
@@ -98,7 +98,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
}
for (uint x = (uint) effective_width/2; x != 0; x--) {
uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
@@ -118,26 +118,26 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
/* Update anim buffer. */
const byte a0 = src[0].a;
const byte a1 = src[1].a;
uint32 anim01 = 0;
uint32_t anim01 = 0;
if (a0 == 255) {
if (a1 == 255) {
*(uint32*) anim = mvX2;
*(uint32_t*) anim = mvX2;
goto bmno_full_opacity;
}
anim01 = (uint16) mvX2;
anim01 = (uint16_t) mvX2;
} else if (a0 == 0) {
if (a1 == 0) {
goto bmno_full_transparency;
} else {
if (a1 == 255) anim[1] = (uint16) (mvX2 >> 16);
if (a1 == 255) anim[1] = (uint16_t) (mvX2 >> 16);
goto bmno_alpha_blend;
}
}
if (a1 > 0) {
if (a1 == 255) anim01 |= mvX2 & 0xFFFF0000;
*(uint32*) anim = anim01;
*(uint32_t*) anim = anim01;
} else {
anim[0] = (uint16) anim01;
anim[0] = (uint16_t) anim01;
}
} else {
if (src[0].a) anim[0] = 0;
@@ -160,7 +160,7 @@ bmno_full_transparency:
if (src->a == 0) {
/* Complete transparency. */
} else if (src->a == 255) {
*anim = *(const uint16*) src_mv;
*anim = *(const uint16_t*) src_mv;
*dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(LookupColourInPalette(src_mv->m), src_mv->v) : *src;
} else {
*anim = 0;
@@ -180,7 +180,7 @@ bmno_full_transparency:
case BM_COLOUR_REMAP:
for (uint x = (uint) effective_width / 2; x != 0; x--) {
uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
@@ -202,14 +202,14 @@ bmno_full_transparency:
m_colour = m != 0 ? m_colour : srcm; \
}
#ifdef POINTER_IS_64BIT
uint64 srcs = _mm_cvtsi128_si64(srcABCD);
uint64 dsts;
uint64_t srcs = _mm_cvtsi128_si64(srcABCD);
uint64_t dsts;
if (animated) dsts = _mm_cvtsi128_si64(dstABCD);
uint64 remapped_src = 0;
uint64_t remapped_src = 0;
CMOV_REMAP(c0, animated ? dsts : 0, srcs, mvX2);
remapped_src = c0.data;
CMOV_REMAP(c1, animated ? dsts >> 32 : 0, srcs >> 32, mvX2 >> 16);
remapped_src |= (uint64) c1.data << 32;
remapped_src |= (uint64_t) c1.data << 32;
srcABCD = _mm_cvtsi64_si128(remapped_src);
#else
Colour remapped_src[2];
@@ -227,11 +227,11 @@ bmno_full_transparency:
if (animated) {
const byte a0 = src[0].a;
const byte a1 = src[1].a;
uint32 anim01 = mvX2 & 0xFF00FF00;
uint32_t anim01 = mvX2 & 0xFF00FF00;
if (a0 == 255) {
anim01 |= r0;
if (a1 == 255) {
*(uint32*) anim = anim01 | (r1 << 16);
*(uint32_t*) anim = anim01 | (r1 << 16);
goto bmcr_full_opacity;
}
} else if (a0 == 0) {
@@ -246,9 +246,9 @@ bmno_full_transparency:
}
if (a1 > 0) {
if (a1 == 255) anim01 |= r1 << 16;
*(uint32*) anim = anim01;
*(uint32_t*) anim = anim01;
} else {
anim[0] = (uint16) anim01;
anim[0] = (uint16_t) anim01;
}
} else {
if (src[0].a) anim[0] = 0;
@@ -273,7 +273,7 @@ bmcr_full_transparency:
if (src->a == 0) break;
if (src_mv->m) {
const uint r = remap[src_mv->m];
*anim = (animated && src->a == 255) ? r | ((uint16) src_mv->v << 8 ) : 0;
*anim = (animated && src->a == 255) ? r | ((uint16_t) src_mv->v << 8 ) : 0;
if (r != 0) {
Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), src_mv->v);
if (src->a == 255) {
@@ -337,7 +337,7 @@ bmcr_alpha_blend_single:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src_mv->m == 0) {
if (src->a != 0) {
uint8 g = MakeDark(src->r, src->g, src->b);
uint8_t g = MakeDark(src->r, src->g, src->b);
*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
*anim = 0;
}
@@ -376,7 +376,7 @@ bmcr_alpha_blend_single:
} else {
*dst = AdjustBrightneSSE(src->data, DEFAULT_BRIGHTNESS + bp->brightness_adjust);
}
*anim = *(const uint16*) &mv;
*anim = *(const uint16_t*) &mv;
} else {
*anim = 0;
__m128i srcABCD;
@@ -406,7 +406,7 @@ bmcr_alpha_blend_single:
MapValue mv = *src_mv;
mv.v = Clamp(mv.v + bp->brightness_adjust, 0, 255);
const uint r = remap[mv.m];
*anim = (animated && src->a == 255) ? r | ((uint16) mv.v << 8) : 0;
*anim = (animated && src->a == 255) ? r | ((uint16_t) mv.v << 8) : 0;
if (r != 0) {
Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), mv.v);
if (src->a == 255) {

View File

@@ -15,20 +15,20 @@
void *Blitter_32bppBase::MoveTo(void *video, int x, int y)
{
return (uint32 *)video + x + y * _screen.pitch;
return (uint32_t *)video + x + y * _screen.pitch;
}
void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8 colour)
void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8_t colour)
{
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
}
void Blitter_32bppBase::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32)
void Blitter_32bppBase::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32)
{
*((Colour *)video + x + y * _screen.pitch) = colour32;
}
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)
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)
{
const Colour c = LookupColourInPalette(colour);
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
@@ -36,7 +36,7 @@ void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int
});
}
void Blitter_32bppBase::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch)
void Blitter_32bppBase::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch)
{
Colour *dst = (Colour *)video + x + y * _screen.pitch;
do {
@@ -51,17 +51,17 @@ void Blitter_32bppBase::SetRect(void *video, int x, int y, const uint8 *colours,
} while (--lines);
}
void Blitter_32bppBase::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch)
void Blitter_32bppBase::SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch)
{
uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
uint32_t *dst = (uint32_t *)video + x + y * _screen.pitch;
do {
memcpy(dst, colours, width * sizeof(uint32));
memcpy(dst, colours, width * sizeof(uint32_t));
dst += _screen.pitch;
colours += pitch;
} while (--lines);
}
void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 colour)
void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8_t colour)
{
Colour colour32 = LookupColourInPalette(colour);
@@ -71,22 +71,22 @@ void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 colou
*dst = colour32;
dst++;
}
video = (uint32 *)video + _screen.pitch;
video = (uint32_t *)video + _screen.pitch;
} while (--height);
}
void Blitter_32bppBase::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour)
void Blitter_32bppBase::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour)
{
this->Blitter_32bppBase::DrawRect((Colour *)video + x + y * _screen.pitch, width, height, colour);
}
void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height)
{
uint32 *dst = (uint32 *)video;
const uint32 *usrc = (const uint32 *)src;
uint32_t *dst = (uint32_t *)video;
const uint32_t *usrc = (const uint32_t *)src;
for (; height > 0; height--) {
memcpy(dst, usrc, width * sizeof(uint32));
memcpy(dst, usrc, width * sizeof(uint32_t));
usrc += width;
dst += _screen.pitch;
}
@@ -94,11 +94,11 @@ void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width,
void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, int height)
{
uint32 *udst = (uint32 *)dst;
const uint32 *src = (const uint32 *)video;
uint32_t *udst = (uint32_t *)dst;
const uint32_t *src = (const uint32_t *)video;
for (; height > 0; height--) {
memcpy(udst, src, width * sizeof(uint32));
memcpy(udst, src, width * sizeof(uint32_t));
src += _screen.pitch;
udst += width;
}
@@ -106,11 +106,11 @@ void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, in
void Blitter_32bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
{
uint32 *udst = (uint32 *)dst;
const uint32 *src = (const uint32 *)video;
uint32_t *udst = (uint32_t *)dst;
const uint32_t *src = (const uint32_t *)video;
for (; height > 0; height--) {
memcpy(udst, src, width * sizeof(uint32));
memcpy(udst, src, width * sizeof(uint32_t));
src += _screen.pitch;
udst += dst_pitch;
}
@@ -118,12 +118,12 @@ void Blitter_32bppBase::CopyImageToBuffer(const void *video, void *dst, int widt
void Blitter_32bppBase::ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y)
{
const uint32 *src;
uint32 *dst;
const uint32_t *src;
uint32_t *dst;
if (scroll_y > 0) {
/* Calculate pointers */
dst = (uint32 *)video + left + (top + height - 1) * _screen.pitch;
dst = (uint32_t *)video + left + (top + height - 1) * _screen.pitch;
src = dst - scroll_y * _screen.pitch;
/* Decrease height and increase top */
@@ -142,13 +142,13 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int left, int top, int width,
}
for (int h = height; h > 0; h--) {
memcpy(dst, src, width * sizeof(uint32));
memcpy(dst, src, width * sizeof(uint32_t));
src -= _screen.pitch;
dst -= _screen.pitch;
}
} else {
/* Calculate pointers */
dst = (uint32 *)video + left + top * _screen.pitch;
dst = (uint32_t *)video + left + top * _screen.pitch;
src = dst - scroll_y * _screen.pitch;
/* Decrease height. (scroll_y is <=0). */
@@ -168,7 +168,7 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int left, int top, int width,
/* the y-displacement may be 0 therefore we have to use memmove,
* because source and destination may overlap */
for (int h = height; h > 0; h--) {
memmove(dst, src, width * sizeof(uint32));
memmove(dst, src, width * sizeof(uint32_t));
src += _screen.pitch;
dst += _screen.pitch;
}
@@ -177,7 +177,7 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int left, int top, int width,
size_t Blitter_32bppBase::BufferSize(uint width, uint height)
{
return sizeof(uint32) * width * height;
return sizeof(uint32_t) * width * height;
}
void Blitter_32bppBase::PaletteAnimate(const Palette &)
@@ -185,22 +185,22 @@ void Blitter_32bppBase::PaletteAnimate(const Palette &)
/* By default, 32bpp doesn't have palette animation */
}
Colour Blitter_32bppBase::ReallyAdjustBrightness(Colour colour, uint8 brightness)
Colour Blitter_32bppBase::ReallyAdjustBrightness(Colour colour, uint8_t brightness)
{
assert(DEFAULT_BRIGHTNESS == 1 << 7);
uint64 combined = (((uint64) colour.r) << 32) | (((uint64) colour.g) << 16) | ((uint64) colour.b);
uint64_t combined = (((uint64_t) colour.r) << 32) | (((uint64_t) colour.g) << 16) | ((uint64_t) colour.b);
combined *= brightness;
uint16 r = GB(combined, 39, 9);
uint16 g = GB(combined, 23, 9);
uint16 b = GB(combined, 7, 9);
uint16_t r = GB(combined, 39, 9);
uint16_t g = GB(combined, 23, 9);
uint16_t b = GB(combined, 7, 9);
if ((combined & 0x800080008000L) == 0L) {
return Colour(r, g, b, colour.a);
}
uint16 ob = 0;
uint16_t ob = 0;
/* Sum overbright */
if (r > 255) ob += r - 255;
if (g > 255) ob += g - 255;

View File

@@ -24,13 +24,13 @@ public:
}
void *MoveTo(void *video, int x, int y) override;
void SetPixel(void *video, int x, int y, uint8 colour) override;
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override;
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8 colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override;
void SetPixel(void *video, int x, int y, uint8_t colour) override;
void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) override;
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;
void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override;
void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8_t colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) override;
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
@@ -125,7 +125,7 @@ public:
* @param b blue component
* @return the brightness value of the new colour, now dark grey.
*/
static inline uint8 MakeDark(uint8 r, uint8 g, uint8 b)
static inline uint8_t MakeDark(uint8_t r, uint8_t g, uint8_t b)
{
/* Magic-numbers are ~66% of those used in MakeGrey() */
return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536;
@@ -138,7 +138,7 @@ public:
*/
static inline Colour MakeDark(Colour colour)
{
uint8 d = MakeDark(colour.r, colour.g, colour.b);
uint8_t d = MakeDark(colour.r, colour.g, colour.b);
return Colour(d, d, d);
}
@@ -164,9 +164,9 @@ public:
static const int DEFAULT_BRIGHTNESS = 128;
static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness);
static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness);
static inline Colour AdjustBrightness(Colour colour, uint8 brightness)
static inline Colour AdjustBrightness(Colour colour, uint8_t brightness)
{
/* Shortcut for normal brightness */
if (likely(brightness == DEFAULT_BRIGHTNESS)) return colour;
@@ -174,9 +174,9 @@ public:
return ReallyAdjustBrightness(colour, brightness);
}
static inline uint8 GetColourBrightness(Colour colour)
static inline uint8_t GetColourBrightness(Colour colour)
{
uint8 rgb_max = std::max(colour.r, std::max(colour.g, colour.b));
uint8_t rgb_max = std::max(colour.r, std::max(colour.g, colour.b));
/* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;

View File

@@ -31,18 +31,18 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
{
const SpriteData *src = (const SpriteData *)bp->sprite;
/* src_px : each line begins with uint32 n = 'number of bytes in this line',
/* src_px : each line begins with uint32_t n = 'number of bytes in this line',
* then n times is the Colour struct for this line */
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
/* src_n : each line begins with uint32 n = 'number of bytes in this line',
/* src_n : each line begins with uint32_t n = 'number of bytes in this line',
* then interleaved stream of 'm' and 'n' channels. 'm' is remap,
* 'n' is number of bytes with the same alpha channel class */
const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]);
const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
/* skip upper lines in src_px and src_n */
for (uint i = bp->skip_top; i != 0; i--) {
src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
}
/* skip lines in dst */
@@ -56,11 +56,11 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
Colour *dst_ln = dst + bp->pitch;
/* next src line begins here */
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
src_px++;
/* next src_n line begins here */
const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
src_n += 2;
/* we will end this line when we reach this point */
@@ -153,7 +153,7 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
do {
uint m = *src_n;
if (m == 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
} else {
uint r = remap[GB(m, 0, 8)];
@@ -168,7 +168,7 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
uint m = *src_n;
if (m == 0) {
if (src_px->a != 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
}
} else {
@@ -308,14 +308,14 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
*
* it has to be stored in one stream so fewer registers are used -
* x86 has problems with register allocation even with this solution */
uint16 *dst_n_orig[ZOOM_LVL_SPR_COUNT];
uint16_t *dst_n_orig[ZOOM_LVL_SPR_COUNT];
/* lengths of streams */
uint32 lengths[ZOOM_LVL_SPR_COUNT][2];
uint32_t lengths[ZOOM_LVL_SPR_COUNT][2];
ZoomLevel zoom_min;
ZoomLevel zoom_max;
uint8 missing_zoom_levels = 0;
uint8_t missing_zoom_levels = 0;
if (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font) {
zoom_min = ZOOM_LVL_NORMAL;
@@ -341,17 +341,17 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
}
Colour * const px_buffer = MallocT<Colour>(px_size);
uint16 * const n_buffer = MallocT<uint16>(n_size);
uint16_t * const n_buffer = MallocT<uint16_t>(n_size);
Colour *px_buffer_next = px_buffer;
uint16 *n_buffer_next = n_buffer;
uint16_t *n_buffer_next = n_buffer;
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
const SpriteLoader::Sprite *src_orig = &sprite[z];
dst_px_orig[z] = px_buffer_next;
dst_n_orig[z] = n_buffer_next;
uint32 *dst_px_ln = (uint32 *)px_buffer_next;
uint32 *dst_n_ln = (uint32 *)n_buffer_next;
uint32_t *dst_px_ln = (uint32_t *)px_buffer_next;
uint32_t *dst_n_ln = (uint32_t *)n_buffer_next;
const SpriteLoader::CommonPixel *src = (const SpriteLoader::CommonPixel *)src_orig->data;
@@ -365,16 +365,16 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
for (uint y = src_orig->height; y > 0; y--) {
/* Index 0 of dst_px and dst_n is left as space to save the length of the row to be filled later. */
Colour *dst_px = (Colour *)&dst_px_ln[1];
uint16 *dst_n = (uint16 *)&dst_n_ln[1];
uint16_t *dst_n = (uint16_t *)&dst_n_ln[1];
uint16 *dst_len = dst_n++;
uint16_t *dst_len = dst_n++;
*dst_len = 0;
uint last = 3;
int len = 0;
for (uint x = src_orig->width; x > 0; x--) {
uint8 a = src->a;
uint8_t a = src->a;
uint t = a > 0 && a < 255 ? 1 : a;
if (last != t || len == 65535) {
@@ -396,7 +396,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
*dst_n = 0;
/* Get brightest value */
uint8 rgb_max = std::max({ src->r, src->g, src->b });
uint8_t rgb_max = std::max({ src->r, src->g, src->b });
/* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
@@ -411,7 +411,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
if (src->m >= PALETTE_ANIM_START) flags &= ~BSF_NO_ANIM;
/* Get brightest value */
uint8 rgb_max = std::max({ src->r, src->g, src->b });
uint8_t rgb_max = std::max({ src->r, src->g, src->b });
/* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
@@ -450,20 +450,20 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
}
dst_px = (Colour *)AlignPtr(dst_px, 4);
dst_n = (uint16 *)AlignPtr(dst_n, 4);
dst_n = (uint16_t *)AlignPtr(dst_n, 4);
*dst_px_ln = (uint8 *)dst_px - (uint8 *)dst_px_ln;
*dst_n_ln = (uint8 *)dst_n - (uint8 *)dst_n_ln;
*dst_px_ln = (uint8_t *)dst_px - (uint8_t *)dst_px_ln;
*dst_n_ln = (uint8_t *)dst_n - (uint8_t *)dst_n_ln;
dst_px_ln = (uint32 *)dst_px;
dst_n_ln = (uint32 *)dst_n;
dst_px_ln = (uint32_t *)dst_px;
dst_n_ln = (uint32_t *)dst_n;
}
lengths[z][0] = (byte *)dst_px_ln - (byte *)dst_px_orig[z]; // all are aligned to 4B boundary
lengths[z][1] = (byte *)dst_n_ln - (byte *)dst_n_orig[z];
px_buffer_next = (Colour *)dst_px_ln;
n_buffer_next = (uint16 *)dst_n_ln;
n_buffer_next = (uint16_t *)dst_n_ln;
}
uint len = 0; // total length of data
@@ -490,7 +490,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
/* Store sprite flags. */
dst->flags = flags;
uint32 next_offset = 0;
uint32_t next_offset = 0;
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
dst->offset[z][0] = next_offset;
dst->offset[z][1] = lengths[z][0] + next_offset;

View File

@@ -18,8 +18,8 @@ public:
/** Data stored about a (single) sprite. */
struct SpriteData {
BlitterSpriteFlags flags;
uint32 offset[ZOOM_LVL_SPR_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
byte data[]; ///< Data, all zoomlevels.
uint32_t offset[ZOOM_LVL_SPR_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
byte data[]; ///< Data, all zoomlevels.
};
Blitter_32bppOptimized()

View File

@@ -61,7 +61,7 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
case BM_CRASH_REMAP:
if (src->m == 0) {
if (src->a != 0) {
uint8 g = MakeDark(src->r, src->g, src->b);
uint8_t g = MakeDark(src->r, src->g, src->b);
*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
}
} else {
@@ -159,7 +159,7 @@ Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite
dst[i].v = 0;
} else {
/* Get brightest value */
uint8 rgb_max = std::max({src->r, src->g, src->b});
uint8_t rgb_max = std::max({src->r, src->g, src->b});
/* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;

View File

@@ -16,12 +16,12 @@
/** The most trivial 32 bpp blitter (without palette animation). */
class Blitter_32bppSimple : public Blitter_32bppBase {
struct Pixel {
uint8 r; ///< Red-channel
uint8 g; ///< Green-channel
uint8 b; ///< Blue-channel
uint8 a; ///< Alpha-channel
uint8 m; ///< Remap-channel
uint8 v; ///< Brightness-channel
uint8_t r; ///< Red-channel
uint8_t g; ///< Green-channel
uint8_t b; ///< Blue-channel
uint8_t a; ///< Alpha-channel
uint8_t m; ///< Remap-channel
uint8_t v; ///< Brightness-channel
};
public:
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;

View File

@@ -22,13 +22,13 @@ static FBlitter_32bppSSE2 iFBlitter_32bppSSE2;
Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
{
/* First uint32 of a line = the number of transparent pixels from the left.
* Second uint32 of a line = the number of transparent pixels from the right.
/* First uint32_t of a line = the number of transparent pixels from the left.
* Second uint32_t of a line = the number of transparent pixels from the right.
* Then all RGBA then all MV.
*/
ZoomLevel zoom_min = ZOOM_LVL_NORMAL;
ZoomLevel zoom_max = ZOOM_LVL_NORMAL;
uint8 missing_zoom_levels = 0;
uint8_t missing_zoom_levels = 0;
if (sprite[ZOOM_LVL_NORMAL].type != SpriteType::Font) {
zoom_min = _settings_client.gui.zoom_min;
zoom_max = (ZoomLevel) std::min(_settings_client.gui.zoom_max, ZOOM_LVL_DRAW_SPR);
@@ -52,7 +52,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
sd.infos[z].sprite_width = src_sprite->width;
sd.infos[z].sprite_offset = all_sprites_size;
sd.infos[z].sprite_line_size = sizeof(Colour) * src_sprite->width + sizeof(uint32) * META_LENGTH;
sd.infos[z].sprite_line_size = sizeof(Colour) * src_sprite->width + sizeof(uint32_t) * META_LENGTH;
const uint rgba_size = sd.infos[z].sprite_line_size * src_sprite->height;
sd.infos[z].mv_offset = all_sprites_size + rgba_size;
@@ -91,7 +91,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
dst_mv->m = src->m;
if (z >= _settings_client.gui.disable_water_animation && src->m >= 245 && src->m <= 254) {
/* Get brightest value */
uint8 rgb_max = std::max({ src->r, src->g, src->b });
uint8_t rgb_max = std::max({ src->r, src->g, src->b });
/* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = Blitter_32bppBase::DEFAULT_BRIGHTNESS;
@@ -108,7 +108,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
if (src->m >= PALETTE_ANIM_START) has_anim = true;
/* Get brightest value (or default brightness if it's a black pixel). */
const uint8 rgb_max = std::max({src->r, src->g, src->b});
const uint8_t rgb_max = std::max({src->r, src->g, src->b});
dst_mv->v = (rgb_max == 0) ? Blitter_32bppBase::DEFAULT_BRIGHTNESS : rgb_max;
/* Pre-convert the mapping channel to a RGB value. */
@@ -124,7 +124,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
}
} else {
dst_rgba->data = 0;
*(uint16*) dst_mv = 0;
*(uint16_t*) dst_mv = 0;
}
dst_rgba++;
dst_mv++;
@@ -133,7 +133,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
/* Count the number of transparent pixels from the left. */
dst_rgba = dst_rgba_line + META_LENGTH;
uint32 nb_pix_transp = 0;
uint32_t nb_pix_transp = 0;
for (uint x = src_sprite->width; x != 0; x--) {
if (dst_rgba->a == 0) nb_pix_transp++;
else break;

View File

@@ -32,8 +32,8 @@ public:
virtual ~Blitter_32bppSSE_Base() = default;
struct MapValue {
uint8 m;
uint8 v;
uint8_t m;
uint8_t v;
};
static_assert(sizeof(MapValue) == 2);
@@ -53,10 +53,10 @@ public:
/** Data stored about a (single) sprite. */
struct SpriteInfo {
uint32 sprite_offset; ///< The offset to the sprite data.
uint32 mv_offset; ///< The offset to the map value data.
uint16 sprite_line_size; ///< The size of a single line (pitch).
uint16 sprite_width; ///< The width of the sprite.
uint32_t sprite_offset; ///< The offset to the sprite data.
uint32_t mv_offset; ///< The offset to the map value data.
uint16_t sprite_line_size; ///< The size of a single line (pitch).
uint16_t sprite_width; ///< The width of the sprite.
};
struct SpriteData {
BlitterSpriteFlags flags;

View File

@@ -75,7 +75,7 @@ inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
GNU_TARGET(SSE_TARGET)
inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
{
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8 into uint16
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8_t into uint16
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
__m128i alphaMaskAB = _mm_cmpgt_epi16(srcAB, _mm_setzero_si128()); // PCMPGTW (alpha > 0) ? 0xFFFF : 0
@@ -111,19 +111,19 @@ inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribu
IGNORE_UNINITIALIZED_WARNING_START
GNU_TARGET(SSE_TARGET)
static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness)
static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness)
{
uint64 c16 = colour.b | (uint64) colour.g << 16 | (uint64) colour.r << 32;
uint64_t c16 = colour.b | (uint64_t) colour.g << 16 | (uint64_t) colour.r << 32;
c16 *= brightness;
uint64 c16_ob = c16; // Helps out of order execution.
uint64_t c16_ob = c16; // Helps out of order execution.
c16 /= Blitter_32bppBase::DEFAULT_BRIGHTNESS;
c16 &= 0x01FF01FF01FFULL;
/* Sum overbright (maximum for each rgb is 508, 9 bits, -255 is changed in -256 so we just have to take the 8 lower bits into account). */
c16_ob = (((c16_ob >> (8 + 7)) & 0x0100010001ULL) * 0xFF) & c16;
const uint ob = ((uint16) c16_ob + (uint16) (c16_ob >> 16) + (uint16) (c16_ob >> 32)) / 2;
const uint ob = ((uint16_t) c16_ob + (uint16_t) (c16_ob >> 16) + (uint16_t) (c16_ob >> 32)) / 2;
const uint32 alpha32 = colour.data & 0xFF000000;
const uint32_t alpha32 = colour.data & 0xFF000000;
__m128i ret;
LoadUint64(c16, ret);
if (ob != 0) {
@@ -224,7 +224,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
const Colour *src_rgba_line = (const Colour *) ((const byte *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
uint32 bm_normal_brightness = 0;
uint32_t bm_normal_brightness = 0;
if (mode == BM_NORMAL_WITH_BRIGHTNESS) {
bm_normal_brightness = (DEFAULT_BRIGHTNESS + bp->brightness_adjust) << 8;
bm_normal_brightness |= bm_normal_brightness << 16;
@@ -304,7 +304,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
for (uint x = (uint) effective_width / 2; x > 0; x--) {
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
/* Remap colours. */
if (mvX2 & 0x00FF00FF) {
@@ -320,12 +320,12 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
m_colour = m != 0 ? m_colour : srcm; \
}
#ifdef POINTER_IS_64BIT
uint64 srcs = _mm_cvtsi128_si64(srcABCD);
uint64 remapped_src = 0;
uint64_t srcs = _mm_cvtsi128_si64(srcABCD);
uint64_t remapped_src = 0;
CMOV_REMAP(c0, 0, srcs, mvX2);
remapped_src = c0.data;
CMOV_REMAP(c1, 0, srcs >> 32, mvX2 >> 16);
remapped_src |= (uint64) c1.data << 32;
remapped_src |= (uint64_t) c1.data << 32;
srcABCD = _mm_cvtsi64_si128(remapped_src);
#else
Colour remapped_src[2];
@@ -414,7 +414,7 @@ bmcr_alpha_blend_single:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src_mv->m == 0) {
if (src->a != 0) {
uint8 g = MakeDark(src->r, src->g, src->b);
uint8_t g = MakeDark(src->r, src->g, src->b);
*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
}
} else {

View File

@@ -21,7 +21,7 @@
#include <smmintrin.h>
#endif
#define META_LENGTH 2 ///< Number of uint32 inserted before each line of pixels in a sprite.
#define META_LENGTH 2 ///< Number of uint32_t inserted before each line of pixels in a sprite.
#define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
#define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP.
@@ -35,10 +35,10 @@
typedef union ALIGN(16) um128i {
__m128i m128i;
uint8 m128i_u8[16];
uint16 m128i_u16[8];
uint32 m128i_u32[4];
uint64 m128i_u64[2];
uint8_t m128i_u8[16];
uint16_t m128i_u16[8];
uint32_t m128i_u32[4];
uint64_t m128i_u64[2];
} um128i;
#define CLEAR_HIGH_BYTE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0)

View File

@@ -24,7 +24,7 @@
static FBlitter_40bppAnim iFBlitter_40bppAnim;
void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
{
if (_screen_disable_anim) {
Blitter_32bppOptimized::SetPixel(video, x, y, colour);
@@ -32,11 +32,11 @@ void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
size_t y_offset = static_cast<size_t>(y) * _screen.pitch;
*((Colour *)video + x + y_offset) = _black_colour;
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y_offset] = colour;
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + x + y_offset] = colour;
}
}
void Blitter_40bppAnim::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32)
void Blitter_40bppAnim::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32)
{
if (_screen_disable_anim) {
Blitter_32bppOptimized::SetPixel32(video, x, y, colour, colour32);
@@ -44,20 +44,20 @@ void Blitter_40bppAnim::SetPixel32(void *video, int x, int y, uint8 colour, uint
size_t y_offset = static_cast<size_t>(y) * _screen.pitch;
*((Colour *)video + x + y_offset) = colour32;
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y_offset] = 0;
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + x + y_offset] = 0;
}
}
void Blitter_40bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch)
void Blitter_40bppAnim::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch)
{
if (_screen_disable_anim) {
Blitter_32bppOptimized::SetRect(video, x, y, colours, lines, width, pitch);
} else {
Colour *dst = (Colour *)video + x + y * _screen.pitch;
uint8 *dstanim = ((uint32 *)dst - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *dstanim = ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
do {
memset_colour(dst, _black_colour, width);
memcpy(dstanim, colours, width * sizeof(uint8));
memcpy(dstanim, colours, width * sizeof(uint8_t));
dst += _screen.pitch;
dstanim += _screen.pitch;
colours += pitch;
@@ -65,16 +65,16 @@ void Blitter_40bppAnim::SetRect(void *video, int x, int y, const uint8 *colours,
}
}
void Blitter_40bppAnim::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch)
void Blitter_40bppAnim::SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch)
{
if (_screen_disable_anim) {
Blitter_32bppOptimized::SetRect32(video, x, y, colours, lines, width, pitch);
} else {
Colour *dst = (Colour *)video + x + y * _screen.pitch;
uint8 *dstanim = ((uint32 *)dst - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *dstanim = ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
do {
memcpy((uint32 *)dst, colours, width * sizeof(uint32));
memset(dstanim, 0, width * sizeof(uint8));
memcpy((uint32_t *)dst, colours, width * sizeof(uint32_t));
memset(dstanim, 0, width * sizeof(uint8_t));
dst += _screen.pitch;
dstanim += _screen.pitch;
colours += pitch;
@@ -82,7 +82,7 @@ void Blitter_40bppAnim::SetRect32(void *video, int x, int y, const uint32 *colou
}
}
void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8_t colour)
{
if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
@@ -91,23 +91,23 @@ void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colou
}
assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
do {
memset_colour((Colour *)video, _black_colour, width);
memset(anim_line, colour, width);
video = (uint32 *)video + _screen.pitch;
video = (uint32_t *)video + _screen.pitch;
anim_line += _screen.pitch;
} while (--height);
}
void Blitter_40bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour)
void Blitter_40bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour)
{
this->Blitter_40bppAnim::DrawRect((Colour *)video + x + y * _screen.pitch, width, height, colour);
}
void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
{
if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
@@ -116,7 +116,7 @@ void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
}
assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
uint8 *anim = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *anim = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
*((Colour *)video + x + y * _screen.pitch) = _black_colour;
@@ -136,24 +136,24 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
{
const SpriteData *src = (const SpriteData *)bp->sprite;
/* src_px : each line begins with uint32 n = 'number of bytes in this line',
/* src_px : each line begins with uint32_t n = 'number of bytes in this line',
* then n times is the Colour struct for this line */
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
/* src_n : each line begins with uint32 n = 'number of bytes in this line',
/* src_n : each line begins with uint32_t n = 'number of bytes in this line',
* then interleaved stream of 'm' and 'n' channels. 'm' is remap,
* 'n' is number of bytes with the same alpha channel class */
const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]);
const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
/* skip upper lines in src_px and src_n */
for (uint i = bp->skip_top; i != 0; i--) {
src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
}
/* skip lines in dst */
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
uint8 *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left;
uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)bp->dst - (uint32_t *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left;
/* store so we don't have to access it via bp everytime (compiler assumes pointer aliasing) */
const byte *remap = bp->remap;
@@ -161,14 +161,14 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
for (int y = 0; y < bp->height; y++) {
/* next dst line begins here */
Colour *dst_ln = dst + bp->pitch;
uint8 *anim_ln = anim + bp->pitch;
uint8_t *anim_ln = anim + bp->pitch;
/* next src line begins here */
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
src_px++;
/* next src_n line begins here */
const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
src_n += 2;
/* we will end this line when we reach this point */
@@ -228,7 +228,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
case BM_COLOUR_REMAP_WITH_BRIGHTNESS:
if (src_px->a == 255) {
do {
uint8 m = GB(*src_n, 0, 8);
uint8_t m = GB(*src_n, 0, 8);
/* In case the m-channel is zero, only apply the crash remap by darkening the RGB colour. */
if (m == 0) {
Colour c = *src_px;
@@ -254,7 +254,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
} while (--n != 0);
} else {
do {
uint8 m = GB(*src_n, 0, 8);
uint8_t m = GB(*src_n, 0, 8);
Colour b = this->RealizeBlendedColour(*anim, *dst);
if (m == 0) {
Colour c = *src_px;
@@ -355,7 +355,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
break;
} else {
do {
uint8 m = GB(*src_n, 0, 8);
uint8_t m = GB(*src_n, 0, 8);
Colour b = this->RealizeBlendedColour(*anim, *dst);
if (m == 0) {
@@ -425,7 +425,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height,
}
Colour *udst = (Colour *)dst;
uint8 *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr);
if (pal == PALETTE_TO_TRANSPARENT) {
/* If the anim buffer contains a color value, the image composition will
@@ -442,7 +442,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height,
anim = anim - width + _screen.pitch;
} while (--height);
} else if (pal == PALETTE_NEWSPAPER) {
const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
do {
for (int i = 0; i != width; i++) {
if (*anim == 0) *udst = MakeGrey(*udst);
@@ -454,7 +454,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height,
anim = anim - width + _screen.pitch;
} while (--height);
} else {
const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
do {
for (int i = 0; i != width; i++) {
*anim = remap[*anim];
@@ -474,21 +474,21 @@ Sprite *Blitter_40bppAnim::Encode(const SpriteLoader::SpriteCollection &sprite,
void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *dst = (uint32 *)video;
const uint32 *usrc = (const uint32 *)src;
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32_t *dst = (uint32_t *)video;
const uint32_t *usrc = (const uint32_t *)src;
uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
if (anim_buf == nullptr) return;
uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf;
uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
for (; height > 0; height--) {
memcpy(dst, usrc, width * sizeof(uint32));
memcpy(dst, usrc, width * sizeof(uint32_t));
usrc += width;
dst += _screen.pitch;
/* Copy back the anim-buffer */
memcpy(anim_line, usrc, width * sizeof(uint8));
usrc = (const uint32 *)((const uint8 *)usrc + width);
memcpy(anim_line, usrc, width * sizeof(uint8_t));
usrc = (const uint32_t *)((const uint8_t *)usrc + width);
anim_line += _screen.pitch;
}
}
@@ -496,36 +496,36 @@ void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width,
void Blitter_40bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *udst = (uint32 *)dst;
const uint32 *src = (const uint32 *)video;
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32_t *udst = (uint32_t *)dst;
const uint32_t *src = (const uint32_t *)video;
uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
if (anim_buf == nullptr) return;
const uint8 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf;
const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
for (; height > 0; height--) {
memcpy(udst, src, width * sizeof(uint32));
memcpy(udst, src, width * sizeof(uint32_t));
src += _screen.pitch;
udst += width;
/* Copy the anim-buffer */
memcpy(udst, anim_line, width * sizeof(uint8));
udst = (uint32 *)((uint8 *)udst + width);
memcpy(udst, anim_line, width * sizeof(uint8_t));
udst = (uint32_t *)((uint8_t *)udst + width);
anim_line += _screen.pitch;
}
}
void Blitter_40bppAnim::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
{
uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
if (anim_buf == nullptr) {
Blitter_32bppOptimized::CopyImageToBuffer(video, dst, width, height, dst_pitch);
return;
}
uint32 *udst = (uint32 *)dst;
const uint32 *src = (const uint32 *)video;
const uint8 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf;
uint32_t *udst = (uint32_t *)dst;
const uint32_t *src = (const uint32_t *)video;
const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
for (; height > 0; height--) {
for (int x = 0; x < width; x++) {
@@ -540,9 +540,9 @@ void Blitter_40bppAnim::CopyImageToBuffer(const void *video, void *dst, int widt
void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y)
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
uint8 *dst, *src;
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
uint8_t *dst, *src;
/* We need to scroll the anim-buffer too */
if (scroll_y > 0) {
@@ -559,7 +559,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width,
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
uint th = height - scroll_y;
for (; th > 0; th--) {
memcpy(dst, src, tw * sizeof(uint8));
memcpy(dst, src, tw * sizeof(uint8_t));
src -= _screen.pitch;
dst -= _screen.pitch;
}
@@ -580,7 +580,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width,
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
uint th = height + scroll_y;
for (; th > 0; th--) {
memmove(dst, src, tw * sizeof(uint8));
memmove(dst, src, tw * sizeof(uint8_t));
src += _screen.pitch;
dst += _screen.pitch;
}
@@ -591,7 +591,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width,
size_t Blitter_40bppAnim::BufferSize(uint width, uint height)
{
return (sizeof(uint32) + sizeof(uint8)) * width * height;
return (sizeof(uint32_t) + sizeof(uint8_t)) * width * height;
}
Blitter::PaletteAnimation Blitter_40bppAnim::UsePaletteAnimation()

View File

@@ -18,13 +18,13 @@
class Blitter_40bppAnim : public Blitter_32bppOptimized {
public:
void SetPixel(void *video, int x, int y, uint8 colour) override;
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override;
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8 colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override;
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
void SetPixel(void *video, int x, int y, uint8_t colour) override;
void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) override;
void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override;
void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8_t colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) override;
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;
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
@@ -41,7 +41,7 @@ public:
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
protected:
static inline Colour RealizeBlendedColour(uint8 anim, Colour c)
static inline Colour RealizeBlendedColour(uint8_t anim, Colour c)
{
return anim != 0 ? AdjustBrightness(LookupColourInPalette(anim), GetColourBrightness(c)) : c;
}

View File

@@ -16,66 +16,66 @@
void Blitter_8bppBase::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
{
const uint8 *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1;
const uint8_t *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1;
do {
for (int i = 0; i != width; i++) *((uint8 *)dst + i) = ctab[((uint8 *)dst)[i]];
dst = (uint8 *)dst + _screen.pitch;
for (int i = 0; i != width; i++) *((uint8_t *)dst + i) = ctab[((uint8_t *)dst)[i]];
dst = (uint8_t *)dst + _screen.pitch;
} while (--height);
}
void *Blitter_8bppBase::MoveTo(void *video, int x, int y)
{
return (uint8 *)video + x + y * _screen.pitch;
return (uint8_t *)video + x + y * _screen.pitch;
}
void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8 colour)
void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8_t colour)
{
*((uint8 *)video + x + y * _screen.pitch) = colour;
*((uint8_t *)video + x + y * _screen.pitch) = colour;
}
void Blitter_8bppBase::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32)
void Blitter_8bppBase::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32)
{
this->Blitter_8bppBase::SetPixel(video, x, y, colour);
}
void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
{
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
*((uint8 *)video + x + y * _screen.pitch) = colour;
*((uint8_t *)video + x + y * _screen.pitch) = colour;
});
}
void Blitter_8bppBase::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch)
void Blitter_8bppBase::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch)
{
uint8 *dst = (uint8 *)video + x + y * _screen.pitch;
uint8_t *dst = (uint8_t *)video + x + y * _screen.pitch;
do {
memcpy(dst, colours, width * sizeof(uint8));
memcpy(dst, colours, width * sizeof(uint8_t));
dst += _screen.pitch;
colours += pitch;
} while (--lines);
}
void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8 colour)
void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8_t colour)
{
do {
memset(video, colour, width);
video = (uint8 *)video + _screen.pitch;
video = (uint8_t *)video + _screen.pitch;
} while (--height);
}
void Blitter_8bppBase::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour)
void Blitter_8bppBase::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour)
{
this->Blitter_8bppBase::DrawRect((uint8 *)video + x + y * _screen.pitch, width, height, colour);
this->Blitter_8bppBase::DrawRect((uint8_t *)video + x + y * _screen.pitch, width, height, colour);
}
void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height)
{
uint8 *dst = (uint8 *)video;
const uint8 *usrc = (const uint8 *)src;
uint8_t *dst = (uint8_t *)video;
const uint8_t *usrc = (const uint8_t *)src;
for (; height > 0; height--) {
memcpy(dst, usrc, width * sizeof(uint8));
memcpy(dst, usrc, width * sizeof(uint8_t));
usrc += width;
dst += _screen.pitch;
}
@@ -83,11 +83,11 @@ void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, i
void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height)
{
uint8 *udst = (uint8 *)dst;
const uint8 *src = (const uint8 *)video;
uint8_t *udst = (uint8_t *)dst;
const uint8_t *src = (const uint8_t *)video;
for (; height > 0; height--) {
memcpy(udst, src, width * sizeof(uint8));
memcpy(udst, src, width * sizeof(uint8_t));
src += _screen.pitch;
udst += width;
}
@@ -95,11 +95,11 @@ void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int
void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
{
uint8 *udst = (uint8 *)dst;
const uint8 *src = (const uint8 *)video;
uint8_t *udst = (uint8_t *)dst;
const uint8_t *src = (const uint8_t *)video;
for (; height > 0; height--) {
memcpy(udst, src, width * sizeof(uint8));
memcpy(udst, src, width * sizeof(uint8_t));
src += _screen.pitch;
udst += dst_pitch;
}
@@ -107,12 +107,12 @@ void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width
void Blitter_8bppBase::ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y)
{
const uint8 *src;
uint8 *dst;
const uint8_t *src;
uint8_t *dst;
if (scroll_y > 0) {
/* Calculate pointers */
dst = (uint8 *)video + left + (top + height - 1) * _screen.pitch;
dst = (uint8_t *)video + left + (top + height - 1) * _screen.pitch;
src = dst - scroll_y * _screen.pitch;
/* Decrease height and increase top */
@@ -131,13 +131,13 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int left, int top, int width, i
}
for (int h = height; h > 0; h--) {
memcpy(dst, src, width * sizeof(uint8));
memcpy(dst, src, width * sizeof(uint8_t));
src -= _screen.pitch;
dst -= _screen.pitch;
}
} else {
/* Calculate pointers */
dst = (uint8 *)video + left + top * _screen.pitch;
dst = (uint8_t *)video + left + top * _screen.pitch;
src = dst - scroll_y * _screen.pitch;
/* Decrease height. (scroll_y is <=0). */
@@ -157,7 +157,7 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int left, int top, int width, i
/* the y-displacement may be 0 therefore we have to use memmove,
* because source and destination may overlap */
for (int h = height; h > 0; h--) {
memmove(dst, src, width * sizeof(uint8));
memmove(dst, src, width * sizeof(uint8_t));
src += _screen.pitch;
dst += _screen.pitch;
}

View File

@@ -22,12 +22,12 @@ public:
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
void *MoveTo(void *video, int x, int y) override;
void SetPixel(void *video, int x, int y, uint8 colour) override;
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override;
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8 colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override;
void SetPixel(void *video, int x, int y, uint8_t colour) override;
void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) override;
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;
void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override;
void DrawRect(void *video, int width, int height, uint8_t colour) override;
void DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) override;
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;

View File

@@ -26,8 +26,8 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
uint offset = sprite_src->offset[zoom];
/* Find where to start reading in the source sprite */
const uint8 *src = sprite_src->data + offset;
uint8 *dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left;
const uint8_t *src = sprite_src->data + offset;
uint8_t *dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left;
/* Skip over the top lines in the source image */
for (int y = 0; y < bp->skip_top; y++) {
@@ -39,10 +39,10 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
}
}
const uint8 *src_next = src;
const uint8_t *src_next = src;
for (int y = 0; y < bp->height; y++) {
uint8 *dst = dst_line;
uint8_t *dst = dst_line;
dst_line += bp->pitch;
uint skip_left = bp->skip_left;
@@ -87,7 +87,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
case BM_COLOUR_REMAP:
case BM_CRASH_REMAP:
case BM_COLOUR_REMAP_WITH_BRIGHTNESS: {
const uint8 *remap = bp->remap;
const uint8_t *remap = bp->remap;
do {
uint m = remap[*src];
if (m != 0) *dst = m;

View File

@@ -18,8 +18,8 @@ class Blitter_8bppOptimized FINAL : public Blitter_8bppBase {
public:
/** Data stored about a (single) sprite. */
struct SpriteData {
uint32 offset[ZOOM_LVL_SPR_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
byte data[]; ///< Data, all zoomlevels.
uint32_t offset[ZOOM_LVL_SPR_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
byte data[]; ///< Data, all zoomlevels.
};
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;

View File

@@ -18,12 +18,12 @@ static FBlitter_8bppSimple iFBlitter_8bppSimple;
void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
{
const uint8 *src, *src_line;
uint8 *dst, *dst_line;
const uint8_t *src, *src_line;
uint8_t *dst, *dst_line;
/* Find where to start reading in the source sprite */
src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left;
src_line = (const uint8_t *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left;
for (int y = 0; y < bp->height; y++) {
dst = dst_line;

View File

@@ -45,10 +45,10 @@ DECLARE_ENUM_AS_BIT_SET(BlitterSpriteFlags);
* How all blitters should look like. Extend this class to make your own.
*/
class Blitter : public SpriteEncoder {
uint8 screen_depth = 0;
uint8_t screen_depth = 0;
protected:
void SetScreenDepth(uint8 depth)
void SetScreenDepth(uint8_t depth)
{
this->screen_depth = depth;
this->SetIs32BppSupported(depth > 8);
@@ -85,7 +85,7 @@ public:
* Get the screen depth this blitter works for.
* This is either: 8, 16, 24 or 32.
*/
inline uint8 GetScreenDepth() const
inline uint8_t GetScreenDepth() const
{
return this->screen_depth;
}
@@ -123,7 +123,7 @@ public:
* @param y The y position within video-buffer.
* @param colour A 8bpp mapping colour.
*/
virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
virtual void SetPixel(void *video, int x, int y, uint8_t colour) = 0;
/**
* Draw a pixel with a given 32bpp colour on the video-buffer.
@@ -134,7 +134,7 @@ public:
* @param colour A 8bpp mapping colour.
* @param colour32 A 32bpp colour.
*/
virtual void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) = 0;
virtual void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) = 0;
/**
* Draw a rectangle of pixels on the video-buffer.
@@ -146,7 +146,7 @@ public:
* @param width The length of the lines.
* @param pitch The pitch of the colours buffer
*/
virtual void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) = 0;
virtual void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) = 0;
/**
* Draw a rectangle of pixels on the video-buffer (no LookupColourInPalette).
@@ -158,7 +158,7 @@ public:
* @param width The length of the lines.
* @param pitch The pitch of the colours buffer.
*/
virtual void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) { NOT_REACHED(); };
virtual void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) { NOT_REACHED(); };
/**
* Make a single horizontal line in a single colour on the video-buffer.
@@ -167,7 +167,7 @@ public:
* @param height The height of the line.
* @param colour A 8bpp mapping colour.
*/
virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
virtual void DrawRect(void *video, int width, int height, uint8_t colour) = 0;
/**
* Make a single horizontal line in a single colour on the video-buffer.
@@ -178,7 +178,7 @@ public:
* @param height The height of the line.
* @param colour A 8bpp mapping colour.
*/
virtual void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) = 0;
virtual void DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) = 0;
/**
* Draw a line with a given colour.
@@ -193,7 +193,7 @@ public:
* @param width Line width.
* @param dash Length of dashes for dashed lines. 0 means solid line.
*/
virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash = 0) = 0;
virtual 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 = 0) = 0;
/**
* Copy from a buffer to the screen.

View File

@@ -58,11 +58,11 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
/* compute frac_diff = width * sqrt(dx*dx + dy*dy)
* Start interval:
* max(dx, dy) <= sqrt(dx*dx + dy*dy) <= sqrt(2) * max(dx, dy) <= 3/2 * max(dx, dy) */
int64 frac_sq = ((int64) width) * ((int64) width) * (((int64) dx) * ((int64) dx) + ((int64) dy) * ((int64) dy));
int64_t frac_sq = ((int64_t) width) * ((int64_t) width) * (((int64_t) dx) * ((int64_t) dx) + ((int64_t) dy) * ((int64_t) dy));
int frac_max = 3 * frac_diff / 2;
while (frac_diff < frac_max) {
int frac_test = (frac_diff + frac_max) / 2;
if (((int64) frac_test) * ((int64) frac_test) < frac_sq) {
if (((int64_t) frac_test) * ((int64_t) frac_test) < frac_sq) {
frac_diff = frac_test + 1;
} else {
frac_max = frac_test - 1;
@@ -97,8 +97,8 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
if (x1 < 0) {
dash_count = (-x1) % (dash + gap);
auto adjust_frac = [&](int64 frac, int &y_bound) -> int {
frac -= ((int64) dy) * ((int64) x1);
auto adjust_frac = [&](int64_t frac, int &y_bound) -> int {
frac -= ((int64_t) dy) * ((int64_t) x1);
if (frac >= 0) {
int quotient = frac / dx;
int remainder = frac % dx;
@@ -159,8 +159,8 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
if (y1 < 0) {
dash_count = (-y1) % (dash + gap);
auto adjust_frac = [&](int64 frac, int &x_bound) -> int {
frac -= ((int64) dx) * ((int64) y1);
auto adjust_frac = [&](int64_t frac, int &x_bound) -> int {
frac -= ((int64_t) dx) * ((int64_t) y1);
if (frac >= 0) {
int quotient = frac / dy;
int remainder = frac % dy;
@@ -200,12 +200,12 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
}
}
inline void memset_uint32(uint32 *s, uint32 c, size_t n)
inline void memset_uint32(uint32_t *s, uint32_t c, size_t n)
{
#ifdef __APPLE__
memset_pattern4(static_cast<void *>(s), static_cast<const void *>(&c), n * sizeof(uint32));
memset_pattern4(static_cast<void *>(s), static_cast<const void *>(&c), n * sizeof(uint32_t));
#else
if constexpr (sizeof(wchar_t) == sizeof(uint32)) {
if constexpr (sizeof(wchar_t) == sizeof(uint32_t)) {
wmemset((wchar_t *)s, (wchar_t)c, n);
} else {
for (; n > 0; n--) {
@@ -218,7 +218,7 @@ inline void memset_uint32(uint32 *s, uint32 c, size_t n)
inline void memset_colour(Colour *s, Colour c, size_t n)
{
memset_uint32((uint32 *)s, c.data, n);
memset_uint32((uint32_t *)s, c.data, n);
}
#endif /* BLITTER_COMMON_HPP */

View File

@@ -25,13 +25,13 @@ public:
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
void *MoveTo(void *video, int x, int y) override { return nullptr; };
void SetPixel(void *video, int x, int y, uint8 colour) override {};
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override {};
void DrawRect(void *video, int width, int height, uint8 colour) override {};
void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override {};
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {};
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override {};
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override {};
void SetPixel(void *video, int x, int y, uint8_t colour) override {};
void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) override {};
void DrawRect(void *video, int width, int height, uint8_t colour) override {};
void DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) override {};
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 {};
void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override {};
void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) override {};
void CopyFromBuffer(void *video, const void *src, int width, int height) override {};
void CopyToBuffer(const void *video, void *dst, int width, int height) override {};
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {};