switch source tree from k&r to c99

This commit is contained in:
nhmall
2021-01-26 21:06:16 -05:00
parent a2a9cb7b4f
commit f963c5aca7
232 changed files with 12099 additions and 17782 deletions
+20 -36
View File
@@ -61,23 +61,21 @@ struct BitmapInfoHeader {
#define BI_JPEG 4
#define BI_PNG 5
static uint16 FDECL(read_u16, (const unsigned char buf[2]));
static uint32 FDECL(read_u32, (const unsigned char buf[4]));
static int32 FDECL(read_s32, (const unsigned char buf[4]));
static struct Pixel FDECL(build_pixel, (const struct BitmapInfoHeader *, uint32));
static unsigned char FDECL(pixel_element, (uint32, uint32));
static boolean FDECL(read_header, (FILE *, struct BitmapHeader *));
static boolean FDECL(read_info_header, (FILE *, struct BitmapInfoHeader *));
static boolean FDECL(check_info_header, (const struct BitmapInfoHeader *));
static unsigned FDECL(get_palette_size, (const struct BitmapInfoHeader *));
static boolean FDECL(read_palette, (FILE *, struct Pixel *, unsigned));
static uint16 read_u16(const unsigned char buf[2]);
static uint32 read_u32(const unsigned char buf[4]);
static int32 read_s32(const unsigned char buf[4]);
static struct Pixel build_pixel(const struct BitmapInfoHeader *, uint32);
static unsigned char pixel_element(uint32, uint32);
static boolean read_header(FILE *, struct BitmapHeader *);
static boolean read_info_header(FILE *, struct BitmapInfoHeader *);
static boolean check_info_header(const struct BitmapInfoHeader *);
static unsigned get_palette_size(const struct BitmapInfoHeader *);
static boolean read_palette(FILE *, struct Pixel *, unsigned);
/* Read a .BMP file into the image structure */
/* Return TRUE if successful, FALSE on any error */
boolean
read_bmp_tiles(filename, image)
const char *filename;
struct TileSetImage *image;
read_bmp_tiles(const char *filename, struct TileSetImage *image)
{
struct BitmapHeader header1;
struct BitmapInfoHeader header2;
@@ -325,9 +323,7 @@ error:
/* Read and decode the first header */
static boolean
read_header(fp, header)
FILE *fp;
struct BitmapHeader *header;
read_header(FILE *fp, struct BitmapHeader *header)
{
unsigned char buf[14];
size_t size;
@@ -344,9 +340,7 @@ struct BitmapHeader *header;
/* Read and decode the second header */
static boolean
read_info_header(fp, header)
FILE *fp;
struct BitmapInfoHeader *header;
read_info_header(FILE *fp, struct BitmapInfoHeader *header)
{
unsigned char buf[124]; /* maximum size */
size_t size;
@@ -441,8 +435,7 @@ struct BitmapInfoHeader *header;
/* Check the second header for consistency and unsupported features */
static boolean
check_info_header(header)
const struct BitmapInfoHeader *header;
check_info_header(const struct BitmapInfoHeader *header)
{
if (header->NumPlanes != 1) return FALSE;
switch (header->BitsPerPixel) {
@@ -492,8 +485,7 @@ const struct BitmapInfoHeader *header;
/* Return the number of palette entries to read from the file */
static unsigned
get_palette_size(header)
const struct BitmapInfoHeader *header;
get_palette_size(const struct BitmapInfoHeader *header)
{
switch (header->BitsPerPixel) {
case 1:
@@ -517,10 +509,7 @@ const struct BitmapInfoHeader *header;
* Return TRUE if successful, FALSE on any error
*/
static boolean
read_palette(fp, palette, palette_size)
FILE *fp;
struct Pixel *palette;
unsigned palette_size;
read_palette(FILE *fp, struct Pixel *palette, unsigned palette_size)
{
unsigned i;
unsigned char buf[4];
@@ -547,8 +536,7 @@ unsigned palette_size;
/* Decode an unsigned 16 bit quantity */
static uint16
read_u16(buf)
const unsigned char buf[2];
read_u16(const unsigned char buf[2])
{
return ((uint16)buf[0] << 0)
| ((uint16)buf[1] << 8);
@@ -556,8 +544,7 @@ const unsigned char buf[2];
/* Decode an unsigned 32 bit quantity */
static uint32
read_u32(buf)
const unsigned char buf[4];
read_u32(const unsigned char buf[4])
{
return ((uint32)buf[0] << 0)
| ((uint32)buf[1] << 8)
@@ -567,8 +554,7 @@ const unsigned char buf[4];
/* Decode a signed 32 bit quantity */
static int32
read_s32(buf)
const unsigned char buf[4];
read_s32(const unsigned char buf[4])
{
return (int32)((read_u32(buf) ^ 0x80000000) - 0x80000000);
}
@@ -591,9 +577,7 @@ uint32 color;
/* Extract one element (red, green, blue or alpha) from a pixel */
static unsigned char
pixel_element(mask, color)
uint32 mask;
uint32 color;
pixel_element(uint32 mask, uint32 color)
{
uint32 bits, shift;