signed char -> int8_t (ISO/IEC 2382-1:1993)

master
an 2019-11-25 17:27:06 -05:00
parent f86e0719bb
commit 5d5dc61d1b
10 changed files with 31 additions and 31 deletions

View File

@ -775,7 +775,7 @@ int MSG_ReadChar (void)
return -1;
}
c = (signed char)net_message.data[msg_readcount];
c = (int8_t)net_message.data[msg_readcount];
msg_readcount++;
return c;

View File

@ -297,7 +297,7 @@ typedef struct aliasmesh_s
typedef struct meshxyz_s
{
byte xyz[4];
signed char normal[4];
int8_t normal[4];
} meshxyz_t;
typedef struct meshst_s

View File

@ -59,8 +59,8 @@ typedef struct gltexture_s {
uint32_t source_width; //size of image in source data
uint32_t source_height; //size of image in source data
uint16_t source_crc; //generated by source data before modifications
char shirt; //0-13 shirt color, or -1 if never colormapped
char pants; //0-13 pants color, or -1 if never colormapped
int8_t shirt; //0-13 shirt color, or -1 if never colormapped
int8_t pants; //0-13 pants color, or -1 if never colormapped
//used for rendering
int visframe; //matches r_framecount if texture was bound this frame
} gltexture_t;

View File

@ -61,7 +61,7 @@ static inline int Buf_GetC(stdio_buffer_t *buf)
{
buf->size = fread(buf->buffer, 1, sizeof(buf->buffer), buf->f);
buf->pos = 0;
if (buf->size == 0)
return EOF;
}
@ -384,18 +384,18 @@ byte *Image_LoadTGA (FILE *fin, int *width, int *height)
typedef struct
{
char signature;
char version;
char encoding;
char bits_per_pixel;
uint16_t xmin,ymin,xmax,ymax;
uint16_t hdpi,vdpi;
byte colortable[48];
char reserved;
char color_planes;
uint16_t bytes_per_line;
uint16_t palette_type;
char filler[58];
int8_t signature;
int8_t version;
int8_t encoding;
int8_t bits_per_pixel;
uint16_t xmin,ymin,xmax,ymax;
uint16_t hdpi,vdpi;
uint8_t colortable[48];
int8_t reserved;
int8_t color_planes;
uint16_t bytes_per_line;
uint16_t palette_type;
uint8_t filler[58];
} pcxheader_t;
/*

View File

@ -5292,7 +5292,7 @@ static unsigned filter(uint8_t* out, const uint8_t* in, unsigned w, unsigned h,
for(x = 0; x != linebytes; ++x)
{
/*For differences, each byte should be treated as signed, values above 127 are negative
(converted to signed char). Filtertype 0 isn't a difference though, so use unsigned there.
(converted to int8_t). Filtertype 0 isn't a difference though, so use unsigned there.
This means filtertype 0 is almost never chosen, but that is justified.*/
uint8_t s = attempt[type][x];
sum[type] += s < 128 ? s : (255U - s);

View File

@ -740,8 +740,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
break;
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
// s_rawsamples [dst].left = ((signed char *) data)[src * 2] * intVolume;
// s_rawsamples [dst].right = ((signed char *) data)[src * 2 + 1] * intVolume;
// s_rawsamples [dst].left = ((int8_t *) data)[src * 2] * intVolume;
// s_rawsamples [dst].right = ((int8_t *) data)[src * 2 + 1] * intVolume;
s_rawsamples [dst].left = (((byte *) data)[src * 2] - 128) * intVolume;
s_rawsamples [dst].right = (((byte *) data)[src * 2 + 1] - 128) * intVolume;
}
@ -757,8 +757,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
break;
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
// s_rawsamples [dst].left = ((signed char *) data)[src] * intVolume;
// s_rawsamples [dst].right = ((signed char *) data)[src] * intVolume;
// s_rawsamples [dst].left = ((int8_t *) data)[src] * intVolume;
// s_rawsamples [dst].right = ((int8_t *) data)[src] * intVolume;
s_rawsamples [dst].left = (((byte *) data)[src] - 128) * intVolume;
s_rawsamples [dst].right = (((byte *) data)[src] - 128) * intVolume;
}

View File

@ -60,7 +60,7 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
{
// fast special case
for (i = 0; i < outcount; i++)
((signed char *)sc->data)[i] = (int)( (uint8_t)(data[i]) - 128);
((int8_t *)sc->data)[i] = (int)( (uint8_t)(data[i]) - 128);
}
else
{
@ -78,7 +78,7 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
if (sc->width == 2)
((int16_t *)sc->data)[i] = sample;
else
((signed char *)sc->data)[i] = sample >> 8;
((int8_t *)sc->data)[i] = sample >> 8;
}
}
}

View File

@ -135,7 +135,7 @@ static void S_TransferPaintBuffer (int endtime)
}
else if (shm->samplebits == 8) /* S8 format, e.g. with Amiga AHI */
{
signed char *out = (signed char *) shm->buffer;
int8_t *out = (int8_t *) shm->buffer;
while (count--)
{
val = *p / 256;
@ -457,12 +457,12 @@ void SND_InitScaletable (void)
for (j = 0; j < 256; j++)
{
/* When compiling with gcc-4.1.0 at optimisations O1 and
higher, the tricky signed char type conversion is not
higher, the tricky int8_t type conversion is not
guaranteed. Therefore we explicity calculate the signed
value from the index as required. From Kevin Shanahan.
See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26719
*/
// snd_scaletable[i][j] = ((signed char)j) * scale;
// snd_scaletable[i][j] = ((int8_t)j) * scale;
snd_scaletable[i][j] = ((j < 128) ? j : j - 256) * scale;
}
}

View File

@ -211,7 +211,7 @@ static int read_typname(fshandle_t *f, const struct upkg_hdr *hdr,
FS_fseek(f, hdr->name_offset + l, SEEK_SET);
FS_fread(buf, 1, 63, f);
if (hdr->file_version >= 64) {
s = *(signed char *)buf; /* numchars *including* terminator */
s = *(int8_t *)buf; /* numchars *including* terminator */
if (s <= 0 || s > 64) return -1;
l += s + 5; /* 1 for buf[0], 4 for int32_t name_flags */
} else {

View File

@ -60,9 +60,9 @@ typedef struct
int filepos;
int disksize;
int size; // uncompressed
char type;
char compression;
char pad1, pad2;
int8_t type;
int8_t compression;
uint8_t pad1, pad2;
char name[16]; // must be null terminated
} lumpinfo_t;