This commit is contained in:
Glenn Maynard
2004-05-11 20:50:08 +00:00
parent 4fd1ead7f4
commit 7c56df3fd7
7 changed files with 45 additions and 45 deletions
+4 -4
View File
@@ -87,10 +87,10 @@ void RageBitmapTexture::Create()
// TODO: Get rid of this hack and save DDR PC textures in a format that supports alpha. // TODO: Get rid of this hack and save DDR PC textures in a format that supports alpha.
bool bUse248 = false; bool bUse248 = false;
{ {
const Uint8 *p = (Uint8*)img->pixels; const uint8_t *p = (uint8_t*)img->pixels;
for( int i=0; i<img->w; i++ ) for( int i=0; i<img->w; i++ )
{ {
Uint8 color[4]; uint8_t color[4];
mySDL_GetRGBAV( p, img, color ); mySDL_GetRGBAV( p, img, color );
if( color[0]==248 && color[1]==0 && color[2]==248 ) 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); p += img->pitch * (img->h-1);
for( int i=0; i<img->w; i++ ) for( int i=0; i<img->w; i++ )
{ {
Uint8 color[4]; uint8_t color[4];
mySDL_GetRGBAV( p, img, color ); mySDL_GetRGBAV( p, img, color );
if( color[0]==248 && color[1]==0 && color[2]==248 ) if( color[0]==248 && color[1]==0 && color[2]==248 )
{ {
+3 -3
View File
@@ -180,7 +180,7 @@ static void mad_timer_sub(mad_timer_t *a, mad_timer_t b)
/* internal->decoder_private field */ /* internal->decoder_private field */
struct madlib_t struct madlib_t
{ {
Uint8 inbuf[16384], outbuf[8192]; uint8_t inbuf[16384], outbuf[8192];
int outpos; int outpos;
unsigned outleft; 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 ) 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 ) while( bw < len )
{ {
+1 -1
View File
@@ -53,7 +53,7 @@ static const unsigned int UnknownThreadID = 0xFFFFFFFF;
struct ThreadSlot struct ThreadSlot
{ {
mutable char name[1024]; /* mutable so we can force nul-termination */ 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. */ /* Format this beforehand, since it's easier to do that than to do it under crash conditions. */
char ThreadFormattedOutput[1024]; char ThreadFormattedOutput[1024];
+7 -7
View File
@@ -38,24 +38,24 @@ void mySDL_GetTicks( unsigned &secs, unsigned &us )
* wrapping isn't a problem. * wrapping isn't a problem.
*/ */
static Uint32 last = 0; static uint32_t last = 0;
static Uint32 offset_secs = 0, offset_us = 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. */ /* 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 ) if( last > (0-one_day) && millisecs < one_day )
{ {
const Uint32 wraparound_secs = 4294967; /* (2^32 / 1000) */ const uint32_t wraparound_secs = 4294967; /* (2^32 / 1000) */
const Uint32 wraparound_us = 296000; /* (2^32 % 1000) * 1000 */ const uint32_t wraparound_us = 296000; /* (2^32 % 1000) * 1000 */
offset_secs += wraparound_secs; offset_secs += wraparound_secs;
offset_us += wraparound_us; offset_us += wraparound_us;
} }
else if( millisecs < last ) else if( millisecs < last )
{ {
/* The time has moved backwards. Increase the offset by the amount we moved. */ /* 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_secs += offset_ms/1000;
offset_us += (offset_ms%1000) * 1000; offset_us += (offset_ms%1000) * 1000;
} }
+1 -1
View File
@@ -29,7 +29,7 @@ typedef struct
struct jpeg::jpeg_destination_mgr pub; struct jpeg::jpeg_destination_mgr pub;
SDL_RWops *ctx; SDL_RWops *ctx;
Uint8 buffer[OUTPUT_BUFFER_SIZE]; uint8_t buffer[OUTPUT_BUFFER_SIZE];
} my_destination_mgr; } my_destination_mgr;
+18 -18
View File
@@ -26,7 +26,7 @@ static const int DitherMat[DitherMatDim][DitherMatDim] =
static int DitherMatCalc[DitherMatDim][DitherMatDim]; static int DitherMatCalc[DitherMatDim][DitherMatDim];
/* conv is the ratio from the input to the output. */ /* 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. */ /* The intensity matrix wraps. This assumes the matrix dims are a power of 2. */
x &= DitherMatDim-1; x &= DitherMatDim-1;
@@ -49,7 +49,7 @@ static Uint8 DitherPixel(int x, int y, int intensity, int conv)
out_intensity += DitherMatCalc[y][x]; out_intensity += DitherMatCalc[y][x];
/* Truncate, and add e to make sure a value of 14.999998 -> 15. */ /* 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) 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. */ /* We can't dither to paletted surfaces. */
ASSERT( dst->format->BytesPerPixel > 1 ); 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( src->format, src_cbits );
mySDL_GetBitsPerChannel( dst->format, dst_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. */ /* 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 each row: */
for( int row = 0; row < src->h; ++row ) for( int row = 0; row < src->h; ++row )
{ {
const Uint8 *srcp = (const Uint8 *) src->pixels + row * src->pitch; const uint8_t *srcp = (const uint8_t *) src->pixels + row * src->pitch;
Uint8 *dstp = (Uint8 *) dst->pixels + row * dst->pitch; uint8_t *dstp = (uint8_t *) dst->pixels + row * dst->pitch;
/* For each pixel: */ /* For each pixel: */
for( int col = 0; col < src->w; ++col ) for( int col = 0; col < src->w; ++col )
{ {
Uint8 colors[4]; uint8_t colors[4];
mySDL_GetRawRGBAV( srcp, src, colors ); mySDL_GetRawRGBAV( srcp, src, colors );
/* Note that we don't dither the alpha channel. */ /* 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]; int out_intensity = colors[3] * conv[3];
/* Truncate, and add e to make sure a value of 14.999998 -> 15. */ /* 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 /* 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 * dithering to an image with 1-bit alpha to be transparent on all
* source alpha values except for full-opaque, which is wrong. * source alpha values except for full-opaque, which is wrong.
* Add .5, so we round. */ * Add .5, so we round. */
colors[3] = Uint8((out_intensity + 32767) >> 16); colors[3] = uint8_t((out_intensity + 32767) >> 16);
} }
/* Raw value -> int -> pixel */ /* 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. */ /* We can't dither to paletted surfaces. */
ASSERT( dst->format->BytesPerPixel > 1 ); 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( src->format, src_cbits );
mySDL_GetBitsPerChannel( dst->format, dst_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. */ /* 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 each row: */
for(int row = 0; row < src->h; ++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; const uint8_t *srcp = (const uint8_t *)src->pixels + row * src->pitch;
Uint8 *dstp = (Uint8 *)dst->pixels + row * dst->pitch; uint8_t *dstp = (uint8_t *)dst->pixels + row * dst->pitch;
/* For each pixel in row: */ /* For each pixel in row: */
for( int col = 0; col < src->w; ++col ) for( int col = 0; col < src->w; ++col )
{ {
Uint8 colors[4]; uint8_t colors[4];
mySDL_GetRawRGBAV( srcp, src, colors ); mySDL_GetRawRGBAV( srcp, src, colors );
for( int c = 0; c < 3; ++c ) 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; clamped_intensity &= 0xFF0000;
/* Truncate. */ /* Truncate. */
colors[c] = Uint8(clamped_intensity >> 16); colors[c] = uint8_t(clamped_intensity >> 16);
accumError[c] = out_intensity - clamped_intensity; 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]; int out_intensity = colors[3] * conv[3];
/* Truncate, and add e to make sure a value of 14.999998 -> 15. */ /* 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 /* 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 * dithering to an image with 1-bit alpha to be transparent on all
* source alpha values except for full-opaque, which is wrong. * source alpha values except for full-opaque, which is wrong.
* Add .5, so we round. */ * 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 ); mySDL_SetRawRGBAV( dstp, dst, colors );
+11 -11
View File
@@ -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++ ) 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 /* current source pointer and next source pointer (first and second
* rows sampled for this row): */ * rows sampled for this row): */
const Uint8 *csp = (Uint8 *) (sp + esy0[y] * src->pitch); const uint8_t *csp = (uint8_t *) (sp + esy0[y] * src->pitch);
const Uint8 *ncsp = (Uint8 *) (sp + esy1[y] * src->pitch); const uint8_t *ncsp = (uint8_t *) (sp + esy1[y] * src->pitch);
for( x = 0; x < dst->w; x++ ) for( x = 0; x < dst->w; x++ )
{ {
/* Grab pointers to the sampled pixels: */ /* Grab pointers to the sampled pixels: */
const Uint8 *c00 = (Uint8 *) (csp + esx0[x]*4); const uint8_t *c00 = (uint8_t *) (csp + esx0[x]*4);
const Uint8 *c01 = (Uint8 *) (csp + esx1[x]*4); const uint8_t *c01 = (uint8_t *) (csp + esx1[x]*4);
const Uint8 *c10 = (Uint8 *) (ncsp + esx0[x]*4); const uint8_t *c10 = (uint8_t *) (ncsp + esx0[x]*4);
const Uint8 *c11 = (Uint8 *) (ncsp + esx1[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 ) for( int c = 0; c < 4; ++c )
{ {
float x0, x1; float x0, x1;
@@ -109,9 +109,9 @@ static void ZoomSurface( SDL_Surface * src, SDL_Surface * dst )
x1 += c11[c] * (1-ex0[x]); x1 += c11[c] * (1-ex0[x]);
const float res = (x0 * ey0[y]) + (x1 * (1-ey0[y])); 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. */ /* Advance destination pointer. */
dp += 4; dp += 4;