@ -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 ) ) ;
}
}