From 7c56df3fd7bff0925131b01a1e0e75cec48d1333 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 11 May 2004 20:50:08 +0000 Subject: [PATCH] types --- stepmania/src/RageBitmapTexture.cpp | 8 +++--- stepmania/src/RageSoundReader_MP3.cpp | 6 ++--- stepmania/src/RageThreads.cpp | 2 +- stepmania/src/RageTimer.cpp | 14 +++++------ stepmania/src/SDL_SaveJPEG.cpp | 2 +- stepmania/src/SDL_dither.cpp | 36 +++++++++++++-------------- stepmania/src/SDL_rotozoom.cpp | 22 ++++++++-------- 7 files changed, 45 insertions(+), 45 deletions(-) diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index 0116ad0fa9..d47313ecac 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -87,10 +87,10 @@ void RageBitmapTexture::Create() // TODO: Get rid of this hack and save DDR PC textures in a format that supports alpha. bool bUse248 = false; { - const Uint8 *p = (Uint8*)img->pixels; + const uint8_t *p = (uint8_t*)img->pixels; for( int i=0; iw; i++ ) { - Uint8 color[4]; + uint8_t color[4]; mySDL_GetRGBAV( p, img, color ); if( color[0]==248 && color[1]==0 && color[2]==248 ) { @@ -101,11 +101,11 @@ void RageBitmapTexture::Create() } } { - const Uint8 *p = (Uint8*)img->pixels; + const uint8_t *p = (uint8_t*)img->pixels; p += img->pitch * (img->h-1); for( int i=0; iw; i++ ) { - Uint8 color[4]; + uint8_t color[4]; mySDL_GetRGBAV( p, img, color ); if( color[0]==248 && color[1]==0 && color[2]==248 ) { diff --git a/stepmania/src/RageSoundReader_MP3.cpp b/stepmania/src/RageSoundReader_MP3.cpp index 1414914a7b..ffe56c2f3a 100644 --- a/stepmania/src/RageSoundReader_MP3.cpp +++ b/stepmania/src/RageSoundReader_MP3.cpp @@ -180,7 +180,7 @@ static void mad_timer_sub(mad_timer_t *a, mad_timer_t b) /* internal->decoder_private field */ struct madlib_t { - Uint8 inbuf[16384], outbuf[8192]; + uint8_t inbuf[16384], outbuf[8192]; int outpos; unsigned outleft; @@ -716,9 +716,9 @@ static void mono_to_stereo( char *dst, const char *src, unsigned len ) int RageSoundReader_MP3::Read( char *buf, unsigned len ) { - Uint32 bw = 0; + uint32_t bw = 0; - ASSERT( (len % (sizeof(Sint16)*2)) == 0 ); + ASSERT( (len % (sizeof(int16_t)*2)) == 0 ); while( bw < len ) { diff --git a/stepmania/src/RageThreads.cpp b/stepmania/src/RageThreads.cpp index b97b735a01..1a308cdb4d 100644 --- a/stepmania/src/RageThreads.cpp +++ b/stepmania/src/RageThreads.cpp @@ -53,7 +53,7 @@ static const unsigned int UnknownThreadID = 0xFFFFFFFF; struct ThreadSlot { mutable char name[1024]; /* mutable so we can force nul-termination */ - Uint32 threadid; + uint32_t threadid; /* Format this beforehand, since it's easier to do that than to do it under crash conditions. */ char ThreadFormattedOutput[1024]; diff --git a/stepmania/src/RageTimer.cpp b/stepmania/src/RageTimer.cpp index db7c7929de..cdbf34c8c7 100644 --- a/stepmania/src/RageTimer.cpp +++ b/stepmania/src/RageTimer.cpp @@ -38,24 +38,24 @@ void mySDL_GetTicks( unsigned &secs, unsigned &us ) * wrapping isn't a problem. */ - static Uint32 last = 0; - static Uint32 offset_secs = 0, offset_us = 0; + static uint32_t last = 0; + static uint32_t offset_secs = 0, offset_us = 0; - const Uint32 millisecs = SDL_GetTicks(); + const uint32_t millisecs = SDL_GetTicks(); /* The time has wrapped if the last time was very high and the current time is very low. */ - const Uint32 one_day = 24*60*60*1000; + const uint32_t one_day = 24*60*60*1000; if( last > (0-one_day) && millisecs < one_day ) { - const Uint32 wraparound_secs = 4294967; /* (2^32 / 1000) */ - const Uint32 wraparound_us = 296000; /* (2^32 % 1000) * 1000 */ + const uint32_t wraparound_secs = 4294967; /* (2^32 / 1000) */ + const uint32_t wraparound_us = 296000; /* (2^32 % 1000) * 1000 */ offset_secs += wraparound_secs; offset_us += wraparound_us; } else if( millisecs < last ) { /* The time has moved backwards. Increase the offset by the amount we moved. */ - const Uint32 offset_ms = last - millisecs; + const uint32_t offset_ms = last - millisecs; offset_secs += offset_ms/1000; offset_us += (offset_ms%1000) * 1000; } diff --git a/stepmania/src/SDL_SaveJPEG.cpp b/stepmania/src/SDL_SaveJPEG.cpp index 9af13b6c23..ea6ff7c8ca 100644 --- a/stepmania/src/SDL_SaveJPEG.cpp +++ b/stepmania/src/SDL_SaveJPEG.cpp @@ -29,7 +29,7 @@ typedef struct struct jpeg::jpeg_destination_mgr pub; SDL_RWops *ctx; - Uint8 buffer[OUTPUT_BUFFER_SIZE]; + uint8_t buffer[OUTPUT_BUFFER_SIZE]; } my_destination_mgr; diff --git a/stepmania/src/SDL_dither.cpp b/stepmania/src/SDL_dither.cpp index dac75177e3..1566111b63 100644 --- a/stepmania/src/SDL_dither.cpp +++ b/stepmania/src/SDL_dither.cpp @@ -26,7 +26,7 @@ static const int DitherMat[DitherMatDim][DitherMatDim] = static int DitherMatCalc[DitherMatDim][DitherMatDim]; /* conv is the ratio from the input to the output. */ -static Uint8 DitherPixel(int x, int y, int intensity, int conv) +static uint8_t DitherPixel(int x, int y, int intensity, int conv) { /* The intensity matrix wraps. This assumes the matrix dims are a power of 2. */ x &= DitherMatDim-1; @@ -49,7 +49,7 @@ static Uint8 DitherPixel(int x, int y, int intensity, int conv) out_intensity += DitherMatCalc[y][x]; /* Truncate, and add e to make sure a value of 14.999998 -> 15. */ - return Uint8((out_intensity + 1) >> 16); + return uint8_t((out_intensity + 1) >> 16); } void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst) @@ -74,7 +74,7 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst) /* We can't dither to paletted surfaces. */ ASSERT( dst->format->BytesPerPixel > 1 ); - Uint32 src_cbits[4], dst_cbits[4]; + uint32_t src_cbits[4], dst_cbits[4]; mySDL_GetBitsPerChannel( src->format, src_cbits ); mySDL_GetBitsPerChannel( dst->format, dst_cbits ); @@ -92,18 +92,18 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst) } /* Max alpha value; used when there's no alpha source. */ - const Uint8 alpha_max = Uint8((1 << dst_cbits[3]) - 1); + const uint8_t alpha_max = uint8_t((1 << dst_cbits[3]) - 1); /* For each row: */ for( int row = 0; row < src->h; ++row ) { - const Uint8 *srcp = (const Uint8 *) src->pixels + row * src->pitch; - Uint8 *dstp = (Uint8 *) dst->pixels + row * dst->pitch; + const uint8_t *srcp = (const uint8_t *) src->pixels + row * src->pitch; + uint8_t *dstp = (uint8_t *) dst->pixels + row * dst->pitch; /* For each pixel: */ for( int col = 0; col < src->w; ++col ) { - Uint8 colors[4]; + uint8_t colors[4]; mySDL_GetRawRGBAV( srcp, src, colors ); /* Note that we don't dither the alpha channel. */ @@ -125,13 +125,13 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst) int out_intensity = colors[3] * conv[3]; /* Truncate, and add e to make sure a value of 14.999998 -> 15. */ -// colors[3] = Uint8((out_intensity + 1) >> 16); +// colors[3] = uint8_t((out_intensity + 1) >> 16); /* I don't remember why this used to truncate. Doing that causes * dithering to an image with 1-bit alpha to be transparent on all * source alpha values except for full-opaque, which is wrong. * Add .5, so we round. */ - colors[3] = Uint8((out_intensity + 32767) >> 16); + colors[3] = uint8_t((out_intensity + 32767) >> 16); } /* Raw value -> int -> pixel */ @@ -172,7 +172,7 @@ void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst) /* We can't dither to paletted surfaces. */ ASSERT( dst->format->BytesPerPixel > 1 ); - Uint32 src_cbits[4], dst_cbits[4]; + uint32_t src_cbits[4], dst_cbits[4]; mySDL_GetBitsPerChannel( src->format, src_cbits ); mySDL_GetBitsPerChannel( dst->format, dst_cbits ); @@ -190,20 +190,20 @@ void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst) } /* Max alpha value; used when there's no alpha source. */ - const Uint8 alpha_max = Uint8((1 << dst_cbits[3]) - 1); + const uint8_t alpha_max = uint8_t((1 << dst_cbits[3]) - 1); /* For each row: */ for(int row = 0; row < src->h; ++row) { - Sint32 accumError[4] = { 0, 0, 0, 0 }; // accum error values are reset every row + int32_t accumError[4] = { 0, 0, 0, 0 }; // accum error values are reset every row - const Uint8 *srcp = (const Uint8 *)src->pixels + row * src->pitch; - Uint8 *dstp = (Uint8 *)dst->pixels + row * dst->pitch; + const uint8_t *srcp = (const uint8_t *)src->pixels + row * src->pitch; + uint8_t *dstp = (uint8_t *)dst->pixels + row * dst->pitch; /* For each pixel in row: */ for( int col = 0; col < src->w; ++col ) { - Uint8 colors[4]; + uint8_t colors[4]; mySDL_GetRawRGBAV( srcp, src, colors ); for( int c = 0; c < 3; ++c ) @@ -225,7 +225,7 @@ void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst) clamped_intensity &= 0xFF0000; /* Truncate. */ - colors[c] = Uint8(clamped_intensity >> 16); + colors[c] = uint8_t(clamped_intensity >> 16); accumError[c] = out_intensity - clamped_intensity; @@ -255,13 +255,13 @@ void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst) int out_intensity = colors[3] * conv[3]; /* Truncate, and add e to make sure a value of 14.999998 -> 15. */ -// colors[3] = Uint8((out_intensity + 1) >> 16); +// colors[3] = uint8_t((out_intensity + 1) >> 16); /* I don't remember why this used to truncate. Doing that causes * dithering to an image with 1-bit alpha to be transparent on all * source alpha values except for full-opaque, which is wrong. * Add .5, so we round. */ - colors[3] = Uint8((out_intensity + 32767) >> 16); + colors[3] = uint8_t((out_intensity + 32767) >> 16); } mySDL_SetRawRGBAV( dstp, dst, colors ); diff --git a/stepmania/src/SDL_rotozoom.cpp b/stepmania/src/SDL_rotozoom.cpp index dadd8b9e74..a3d545f21a 100644 --- a/stepmania/src/SDL_rotozoom.cpp +++ b/stepmania/src/SDL_rotozoom.cpp @@ -81,25 +81,25 @@ static void ZoomSurface( SDL_Surface * src, SDL_Surface * dst ) } } - const Uint8 *sp = (Uint8 *) src->pixels; + const uint8_t *sp = (uint8_t *) src->pixels; for( y = 0; y < dst->h; y++ ) { - Uint8 *dp = ((Uint8 *) dst->pixels + dst->pitch*y); + uint8_t *dp = ((uint8_t *) dst->pixels + dst->pitch*y); /* current source pointer and next source pointer (first and second * rows sampled for this row): */ - const Uint8 *csp = (Uint8 *) (sp + esy0[y] * src->pitch); - const Uint8 *ncsp = (Uint8 *) (sp + esy1[y] * src->pitch); + const uint8_t *csp = (uint8_t *) (sp + esy0[y] * src->pitch); + const uint8_t *ncsp = (uint8_t *) (sp + esy1[y] * src->pitch); for( x = 0; x < dst->w; x++ ) { /* Grab pointers to the sampled pixels: */ - const Uint8 *c00 = (Uint8 *) (csp + esx0[x]*4); - const Uint8 *c01 = (Uint8 *) (csp + esx1[x]*4); - const Uint8 *c10 = (Uint8 *) (ncsp + esx0[x]*4); - const Uint8 *c11 = (Uint8 *) (ncsp + esx1[x]*4); + const uint8_t *c00 = (uint8_t *) (csp + esx0[x]*4); + const uint8_t *c01 = (uint8_t *) (csp + esx1[x]*4); + const uint8_t *c10 = (uint8_t *) (ncsp + esx0[x]*4); + const uint8_t *c11 = (uint8_t *) (ncsp + esx1[x]*4); - Uint8 color[4]; + uint8_t color[4]; for( int c = 0; c < 4; ++c ) { float x0, x1; @@ -109,9 +109,9 @@ static void ZoomSurface( SDL_Surface * src, SDL_Surface * dst ) x1 += c11[c] * (1-ex0[x]); const float res = (x0 * ey0[y]) + (x1 * (1-ey0[y])); - color[c] = Uint8(res); + color[c] = uint8_t(res); } - *(Uint32 *) dp = *(Uint32 *) color; + *(uint32_t *) dp = *(uint32_t *) color; /* Advance destination pointer. */ dp += 4;