switch source tree from k&r to c99
This commit is contained in:
+20
-36
@@ -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;
|
||||
|
||||
|
||||
+24
-46
@@ -20,7 +20,7 @@
|
||||
#include "tile.h"
|
||||
|
||||
#ifndef MONITOR_HEAP
|
||||
extern long *FDECL(alloc, (unsigned int));
|
||||
extern long *alloc(unsigned int);
|
||||
#endif
|
||||
|
||||
#define PPM_ASSIGN(p, red, grn, blu) \
|
||||
@@ -65,24 +65,22 @@ static int tiles_across, tiles_down, curr_tiles_across, curr_tiles_down;
|
||||
static pixel **image;
|
||||
static unsigned char input_code_size;
|
||||
|
||||
static int FDECL(GetDataBlock, (FILE * fd, unsigned char *buf));
|
||||
static void FDECL(DoExtension, (FILE * fd, int label));
|
||||
static boolean FDECL(ReadColorMap, (FILE * fd, int number));
|
||||
static void FDECL(read_header, (FILE * fd));
|
||||
static int FDECL(GetCode, (FILE * fd, int code_size, int flag));
|
||||
static int FDECL(LWZReadByte, (FILE * fd, int flag, int input_code_size));
|
||||
static void FDECL(ReadInterleavedImage, (FILE * fd, int len, int height));
|
||||
static void FDECL(ReadTileStrip, (FILE * fd, int len));
|
||||
static int GetDataBlock(FILE * fd, unsigned char *buf);
|
||||
static void DoExtension(FILE * fd, int label);
|
||||
static boolean ReadColorMap(FILE * fd, int number);
|
||||
static void read_header(FILE * fd);
|
||||
static int GetCode(FILE * fd, int code_size, int flag);
|
||||
static int LWZReadByte(FILE * fd, int flag, int input_code_size);
|
||||
static void ReadInterleavedImage(FILE * fd, int len, int height);
|
||||
static void ReadTileStrip(FILE * fd, int len);
|
||||
|
||||
/* These should be in gif.h, but there isn't one. */
|
||||
boolean FDECL(fopen_gif_file, (const char *, const char *));
|
||||
boolean FDECL(read_gif_tile, (pixel(*) [TILE_X]));
|
||||
int NDECL(fclose_gif_file);
|
||||
boolean fopen_gif_file(const char *, const char *);
|
||||
boolean read_gif_tile(pixel(*) [TILE_X]);
|
||||
int fclose_gif_file(void);
|
||||
|
||||
static int
|
||||
GetDataBlock(fd, buf)
|
||||
FILE *fd;
|
||||
unsigned char *buf;
|
||||
GetDataBlock(FILE *fd, unsigned char *buf)
|
||||
{
|
||||
unsigned char count;
|
||||
|
||||
@@ -102,9 +100,7 @@ unsigned char *buf;
|
||||
}
|
||||
|
||||
static void
|
||||
DoExtension(fd, label)
|
||||
FILE *fd;
|
||||
int label;
|
||||
DoExtension(FILE *fd, int label)
|
||||
{
|
||||
static char buf[256];
|
||||
char *str;
|
||||
@@ -169,9 +165,7 @@ int label;
|
||||
}
|
||||
|
||||
static boolean
|
||||
ReadColorMap(fd, number)
|
||||
FILE *fd;
|
||||
int number;
|
||||
ReadColorMap(FILE *fd, int number)
|
||||
{
|
||||
int i;
|
||||
unsigned char rgb[3];
|
||||
@@ -194,8 +188,7 @@ int number;
|
||||
* file, so if that image has a local colormap, overwrite the global one.
|
||||
*/
|
||||
static void
|
||||
read_header(fd)
|
||||
FILE *fd;
|
||||
read_header(FILE *fd)
|
||||
{
|
||||
unsigned char buf[16];
|
||||
unsigned char c;
|
||||
@@ -294,10 +287,7 @@ FILE *fd;
|
||||
}
|
||||
|
||||
static int
|
||||
GetCode(fd, code_size, flag)
|
||||
FILE *fd;
|
||||
int code_size;
|
||||
int flag;
|
||||
GetCode(FILE *fd, int code_size, int flag)
|
||||
{
|
||||
static unsigned char buf[280];
|
||||
static int curbit, lastbit, done, last_byte;
|
||||
@@ -338,10 +328,7 @@ int flag;
|
||||
}
|
||||
|
||||
static int
|
||||
LWZReadByte(fd, flag, input_code_size)
|
||||
FILE *fd;
|
||||
int flag;
|
||||
int input_code_size;
|
||||
LWZReadByte(FILE *fd, int flag, int input_code_size)
|
||||
{
|
||||
static int fresh = FALSE;
|
||||
int code, incode;
|
||||
@@ -454,9 +441,7 @@ int input_code_size;
|
||||
}
|
||||
|
||||
static void
|
||||
ReadInterleavedImage(fd, len, height)
|
||||
FILE *fd;
|
||||
int len, height;
|
||||
ReadInterleavedImage(FILE *fd, int len, int height)
|
||||
{
|
||||
int v;
|
||||
int xpos = 0, ypos = 0, pass = 0;
|
||||
@@ -508,9 +493,7 @@ fini:
|
||||
}
|
||||
|
||||
static void
|
||||
ReadTileStrip(fd, len)
|
||||
FILE *fd;
|
||||
int len;
|
||||
ReadTileStrip(FILE *fd, int len)
|
||||
{
|
||||
int v;
|
||||
int xpos = 0, ypos = 0;
|
||||
@@ -530,9 +513,7 @@ int len;
|
||||
}
|
||||
|
||||
boolean
|
||||
fopen_gif_file(filename, type)
|
||||
const char *filename;
|
||||
const char *type;
|
||||
fopen_gif_file(const char *filename, const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -599,8 +580,7 @@ const char *type;
|
||||
|
||||
/* Read a tile. Returns FALSE when there are no more tiles */
|
||||
boolean
|
||||
read_gif_tile(pixels)
|
||||
pixel (*pixels)[TILE_X];
|
||||
read_gif_tile(pixel (*pixels)[TILE_X])
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -646,7 +626,7 @@ pixel (*pixels)[TILE_X];
|
||||
}
|
||||
|
||||
int
|
||||
fclose_gif_file()
|
||||
fclose_gif_file(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -670,9 +650,7 @@ static char *std_args[] = { "tilemap", /* dummy argv[0] */
|
||||
"objects.txt", "other.gif", "other.txt" };
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
pixel pixels[TILE_Y][TILE_X];
|
||||
|
||||
|
||||
+33
-46
@@ -45,14 +45,15 @@ struct DataBlock {
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
static boolean FDECL(read_data_block, (struct Bitstream *gif, struct DataBlock *block));
|
||||
static void FDECL(free_data_block, (struct DataBlock *block));
|
||||
static unsigned short FDECL(read_u16, (const unsigned char buf[2]));
|
||||
static void FDECL(init_decoder, (struct Bitstream *gif, unsigned bit_width));
|
||||
static void FDECL(reset_decoder, (struct Bitstream *gif));
|
||||
static int FDECL(decode, (struct Bitstream *gif, struct DataBlock *block));
|
||||
static int FDECL(get_code, (struct Bitstream *gif, struct DataBlock *block));
|
||||
static unsigned FDECL(interlace_incr, (unsigned y, unsigned height));
|
||||
static boolean read_data_block(struct Bitstream *gif,
|
||||
struct DataBlock *block);
|
||||
static void free_data_block(struct DataBlock *block);
|
||||
static unsigned short read_u16(const unsigned char buf[2]);
|
||||
static void init_decoder(struct Bitstream *gif, unsigned bit_width);
|
||||
static void reset_decoder(struct Bitstream *gif);
|
||||
static int decode(struct Bitstream *gif, struct DataBlock *block);
|
||||
static int get_code(struct Bitstream *gif, struct DataBlock *block);
|
||||
static unsigned interlace_incr(unsigned y, unsigned height);
|
||||
|
||||
/*
|
||||
* GIF specifies a canvas, which may have a palette (the "global color table")
|
||||
@@ -64,9 +65,7 @@ static unsigned FDECL(interlace_incr, (unsigned y, unsigned height));
|
||||
*/
|
||||
|
||||
boolean
|
||||
read_gif_tiles(filename, image)
|
||||
const char *filename;
|
||||
struct TileSetImage *image;
|
||||
read_gif_tiles(const char *filename, struct TileSetImage *image)
|
||||
{
|
||||
struct Bitstream gif;
|
||||
struct DataBlock block;
|
||||
@@ -158,7 +157,7 @@ struct TileSetImage *image;
|
||||
boolean have_lct, interlace;
|
||||
unsigned lct_start, lct_size;
|
||||
struct Pixel lct[256];
|
||||
int b;
|
||||
int new_b;
|
||||
unsigned x, y, x2, y2;
|
||||
|
||||
size = fread(buf, 1, 9, gif.fp);
|
||||
@@ -203,23 +202,23 @@ struct TileSetImage *image;
|
||||
}
|
||||
}
|
||||
/* 22. Table based image data */
|
||||
b = fgetc(gif.fp);
|
||||
if (b == EOF) goto error;
|
||||
if (b < MIN_LZW_BITS - 1 || MAX_LZW_BITS - 1 < b) goto error;
|
||||
init_decoder(&gif, b);
|
||||
new_b = fgetc(gif.fp);
|
||||
if (new_b == EOF) goto error;
|
||||
if (new_b < MIN_LZW_BITS - 1 || MAX_LZW_BITS - 1 < new_b) goto error;
|
||||
init_decoder(&gif, new_b);
|
||||
x = 0;
|
||||
y = 0;
|
||||
if (!read_data_block(&gif, &block)) goto error;
|
||||
while (TRUE) {
|
||||
b = decode(&gif, &block);
|
||||
if (b == EOF) goto error;
|
||||
if (b == END_OF_DATA) break;
|
||||
new_b = decode(&gif, &block);
|
||||
if (new_b == EOF) goto error;
|
||||
if (new_b == END_OF_DATA) break;
|
||||
if (y >= img_height) goto error;
|
||||
x2 = img_left + x;
|
||||
y2 = img_top + y;
|
||||
if (x2 < image->width && y2 < image->height) {
|
||||
image->pixels[y2 * image->width + x2] = lct[b];
|
||||
image->indexes[y2 * image->width + x2] = b + lct_start;
|
||||
image->pixels[y2 * image->width + x2] = lct[new_b];
|
||||
image->indexes[y2 * image->width + x2] = new_b + lct_start;
|
||||
}
|
||||
++x;
|
||||
if (x >= img_width) {
|
||||
@@ -310,9 +309,7 @@ error:
|
||||
}
|
||||
|
||||
static void
|
||||
init_decoder(gif, bit_width)
|
||||
struct Bitstream *gif;
|
||||
unsigned bit_width;
|
||||
init_decoder(struct Bitstream *gif, unsigned bit_width)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned clear;
|
||||
@@ -335,8 +332,7 @@ unsigned bit_width;
|
||||
}
|
||||
|
||||
static void
|
||||
reset_decoder(gif)
|
||||
struct Bitstream *gif;
|
||||
reset_decoder(struct Bitstream *gif)
|
||||
{
|
||||
/* Set the bit width */
|
||||
gif->bit_width = gif->initial_bit_width + 1;
|
||||
@@ -349,9 +345,7 @@ struct Bitstream *gif;
|
||||
}
|
||||
|
||||
static int
|
||||
decode(gif, block)
|
||||
struct Bitstream *gif;
|
||||
struct DataBlock *block;
|
||||
decode(struct Bitstream *gif, struct DataBlock *block)
|
||||
{
|
||||
int code;
|
||||
unsigned clear = 1 << gif->initial_bit_width;
|
||||
@@ -364,12 +358,12 @@ struct DataBlock *block;
|
||||
/* Get the next code, until code other than clear */
|
||||
while (TRUE) {
|
||||
code = get_code(gif, block);
|
||||
if (code != clear) break;
|
||||
if ((unsigned) code != clear) break;
|
||||
reset_decoder(gif);
|
||||
}
|
||||
|
||||
if (code == EOF) return EOF;
|
||||
if (code == clear + 1) return END_OF_DATA;
|
||||
if ((unsigned) code == clear + 1) return END_OF_DATA;
|
||||
if (code > gif->dict_size) return EOF;
|
||||
|
||||
/* Add a new string to the dictionary */
|
||||
@@ -396,7 +390,7 @@ struct DataBlock *block;
|
||||
/* code is less than gif->dict_size and not equal to clear or clear + 1 */
|
||||
/* Prepare the decoded string for return; note that it is stored in
|
||||
* reverse order */
|
||||
while (code >= clear) {
|
||||
while ((unsigned) code >= clear) {
|
||||
gif->string[gif->str_size++] = gif->dictionary[code].byte;
|
||||
code = gif->dictionary[code].next;
|
||||
}
|
||||
@@ -405,9 +399,7 @@ struct DataBlock *block;
|
||||
}
|
||||
|
||||
static int
|
||||
get_code(gif, block)
|
||||
struct Bitstream *gif;
|
||||
struct DataBlock *block;
|
||||
get_code(struct Bitstream *gif, struct DataBlock *block)
|
||||
{
|
||||
int code;
|
||||
|
||||
@@ -426,9 +418,7 @@ struct DataBlock *block;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
interlace_incr(y, height)
|
||||
unsigned y;
|
||||
unsigned height;
|
||||
interlace_incr(unsigned y, unsigned height)
|
||||
{
|
||||
static const unsigned char incr[] = { 8, 2, 4, 2 };
|
||||
|
||||
@@ -457,17 +447,14 @@ unsigned height;
|
||||
|
||||
/* Decode an unsigned 16 bit quantity */
|
||||
static unsigned short
|
||||
read_u16(buf)
|
||||
const unsigned char buf[2];
|
||||
read_u16(const unsigned char buf[2])
|
||||
{
|
||||
return ((unsigned short)buf[0] << 0)
|
||||
| ((unsigned short)buf[1] << 8);
|
||||
}
|
||||
|
||||
static boolean
|
||||
read_data_block(gif, block)
|
||||
struct Bitstream *gif;
|
||||
struct DataBlock *block;
|
||||
read_data_block(struct Bitstream *gif, struct DataBlock *block)
|
||||
{
|
||||
long pos = ftell(gif->fp);
|
||||
int b;
|
||||
@@ -494,7 +481,8 @@ struct DataBlock *block;
|
||||
b = fgetc(gif->fp);
|
||||
if (b == EOF) return FALSE;
|
||||
if (b == 0) break;
|
||||
if (fread(block->data + i, 1, b, gif->fp) != b) return FALSE;
|
||||
if (fread(block->data + i, 1, b, gif->fp) != (unsigned) b)
|
||||
return FALSE;
|
||||
i += b;
|
||||
}
|
||||
|
||||
@@ -503,8 +491,7 @@ struct DataBlock *block;
|
||||
}
|
||||
|
||||
static void
|
||||
free_data_block(block)
|
||||
struct DataBlock *block;
|
||||
free_data_block(struct DataBlock *block)
|
||||
{
|
||||
free(block->data);
|
||||
block->size = 0;
|
||||
|
||||
+9
-14
@@ -7,7 +7,7 @@
|
||||
#include "tile.h"
|
||||
|
||||
#ifndef MONITOR_HEAP
|
||||
extern long *FDECL(alloc, (unsigned int));
|
||||
extern long *alloc(unsigned int);
|
||||
#endif
|
||||
|
||||
FILE *ppm_file;
|
||||
@@ -20,18 +20,18 @@ struct ppmscreen {
|
||||
static int tiles_across, tiles_down, curr_tiles_across;
|
||||
static pixel **image;
|
||||
|
||||
static void NDECL(write_header);
|
||||
static void NDECL(WriteTileStrip);
|
||||
static void write_header(void);
|
||||
static void WriteTileStrip(void);
|
||||
|
||||
static void
|
||||
write_header()
|
||||
write_header(void)
|
||||
{
|
||||
(void) fprintf(ppm_file, "P6 %03d %03d 255\n", PpmScreen.Width,
|
||||
PpmScreen.Height);
|
||||
}
|
||||
|
||||
static void
|
||||
WriteTileStrip()
|
||||
WriteTileStrip(void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -45,9 +45,7 @@ WriteTileStrip()
|
||||
}
|
||||
|
||||
boolean
|
||||
fopen_ppm_file(filename, type)
|
||||
const char *filename;
|
||||
const char *type;
|
||||
fopen_ppm_file(const char *filename, const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -84,8 +82,7 @@ const char *type;
|
||||
}
|
||||
|
||||
boolean
|
||||
write_ppm_tile(pixels)
|
||||
pixel (*pixels)[TILE_X];
|
||||
write_ppm_tile(pixel (*pixels)[TILE_X])
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -104,7 +101,7 @@ pixel (*pixels)[TILE_X];
|
||||
}
|
||||
|
||||
int
|
||||
fclose_ppm_file()
|
||||
fclose_ppm_file(void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -139,9 +136,7 @@ fclose_ppm_file()
|
||||
}
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
pixel pixels[TILE_Y][TILE_X];
|
||||
|
||||
|
||||
+89
-129
@@ -101,8 +101,7 @@ struct window_procs safe_procs = {
|
||||
};
|
||||
|
||||
struct window_procs *
|
||||
get_safe_procs(optn)
|
||||
int optn;
|
||||
get_safe_procs(int optn)
|
||||
{
|
||||
if (optn) {
|
||||
/* include the slightly more functional stdc versions */
|
||||
@@ -118,126 +117,104 @@ int optn;
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
safe_init_nhwindows(argcp, argv)
|
||||
int *argcp UNUSED;
|
||||
char **argv UNUSED;
|
||||
safe_init_nhwindows(int *argcp UNUSED, char **argv UNUSED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_player_selection()
|
||||
safe_player_selection(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_askname()
|
||||
safe_askname(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_get_nh_event()
|
||||
safe_get_nh_event(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_suspend_nhwindows(str)
|
||||
const char *str;
|
||||
safe_suspend_nhwindows(const char *str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_resume_nhwindows()
|
||||
safe_resume_nhwindows(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_exit_nhwindows(str)
|
||||
const char *str;
|
||||
safe_exit_nhwindows(const char *str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
winid
|
||||
safe_create_nhwindow(type)
|
||||
int type;
|
||||
safe_create_nhwindow(int type)
|
||||
{
|
||||
return WIN_ERR;
|
||||
}
|
||||
|
||||
void
|
||||
safe_clear_nhwindow(window)
|
||||
winid window;
|
||||
safe_clear_nhwindow(winid window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
safe_display_nhwindow(window, blocking)
|
||||
winid window;
|
||||
boolean blocking;
|
||||
safe_display_nhwindow(winid window,boolean blocking)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_dismiss_nhwindow(window)
|
||||
winid window;
|
||||
safe_dismiss_nhwindow(winid window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_destroy_nhwindow(window)
|
||||
winid window;
|
||||
safe_destroy_nhwindow(winid window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_curs(window, x, y)
|
||||
winid window;
|
||||
int x, y;
|
||||
safe_curs(winid window, int x, int y)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_putstr(window, attr, str)
|
||||
winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
safe_putstr(winid window, int attr, const char *str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_putmixed(window, attr, str)
|
||||
winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
safe_putmixed(winid window, int attr, const char *str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_display_file(fname, complain)
|
||||
const char *fname;
|
||||
boolean complain;
|
||||
safe_display_file(const char * fname, boolean complain)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_start_menu(window, mbehavior)
|
||||
winid window;
|
||||
unsigned long mbehavior;
|
||||
safe_start_menu(winid window, unsigned long mbehavior)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -248,15 +225,15 @@ unsigned long mbehavior;
|
||||
* later.
|
||||
*/
|
||||
void
|
||||
safe_add_menu(window, glyphinfo, identifier, ch, gch, attr, str, itemflags)
|
||||
winid window; /* window to use, must be of type NHW_MENU */
|
||||
const glyph_info *glyphinfo UNUSED; /* glyph plus glyph info */
|
||||
const anything *identifier; /* what to return if selected */
|
||||
char ch; /* keyboard accelerator (0 = pick our own) */
|
||||
char gch; /* group accelerator (0 = no group) */
|
||||
int attr; /* attribute for string (like safe_putstr()) */
|
||||
const char *str; /* menu string */
|
||||
unsigned int itemflags; /* itemflags such as marked as selected */
|
||||
safe_add_menu(
|
||||
winid window, /* window to use, must be of type NHW_MENU */
|
||||
const glyph_info *glyphinfo UNUSED, /* glyph plus glyph info */
|
||||
const anything *identifier, /* what to return if selected */
|
||||
char ch, /* keyboard accelerator (0 = pick our own) */
|
||||
char gch, /* group accelerator (0 = no group) */
|
||||
int attr, /* attribute for string (like safe_putstr()) */
|
||||
const char *str, /* menu string */
|
||||
unsigned int itemflags) /* itemflags such as marked as selected */
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -265,52 +242,51 @@ unsigned int itemflags; /* itemflags such as marked as selected */
|
||||
* End a menu in this window, window must a type NHW_MENU.
|
||||
*/
|
||||
void
|
||||
safe_end_menu(window, prompt)
|
||||
winid window; /* menu to use */
|
||||
const char *prompt; /* prompt to for menu */
|
||||
safe_end_menu(
|
||||
winid window, /* menu to use */
|
||||
const char *prompt) /* prompt to for menu */
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
safe_select_menu(window, how, menu_list)
|
||||
winid window;
|
||||
int how;
|
||||
menu_item **menu_list;
|
||||
safe_select_menu(
|
||||
winid window,
|
||||
int how,
|
||||
menu_item **menu_list)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* special hack for treating top line --More-- as a one item menu */
|
||||
char
|
||||
safe_message_menu(let, how, mesg)
|
||||
char let;
|
||||
int how;
|
||||
const char *mesg;
|
||||
safe_message_menu(
|
||||
char let,
|
||||
int how,
|
||||
const char *mesg)
|
||||
{
|
||||
return '\033';
|
||||
}
|
||||
|
||||
void
|
||||
safe_update_inventory()
|
||||
safe_update_inventory(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_mark_synch()
|
||||
safe_mark_synch(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
safe_wait_synch()
|
||||
safe_wait_synch(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef CLIPPING
|
||||
void
|
||||
safe_cliparound(x, y)
|
||||
int x, y;
|
||||
safe_cliparound(int x, int y)
|
||||
{
|
||||
}
|
||||
#endif /* CLIPPING */
|
||||
@@ -321,31 +297,30 @@ int x, y;
|
||||
* Print the glyph to the output device. Don't flush the output device.
|
||||
*/
|
||||
void
|
||||
safe_print_glyph(window, x, y, glyphinfo, bkglyphinfo)
|
||||
winid window UNUSED;
|
||||
xchar x UNUSED, y UNUSED;
|
||||
const glyph_info *glyphinfo UNUSED;
|
||||
const glyph_info *bkglyphinfo UNUSED;
|
||||
safe_print_glyph(
|
||||
winid window UNUSED,
|
||||
xchar x UNUSED,
|
||||
xchar y UNUSED,
|
||||
const glyph_info *glyphinfo UNUSED,
|
||||
const glyph_info *bkglyphinfo UNUSED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_raw_print(str)
|
||||
const char *str;
|
||||
safe_raw_print(const char *str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_raw_print_bold(str)
|
||||
const char *str;
|
||||
safe_raw_print_bold(const char *str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
safe_nhgetch()
|
||||
safe_nhgetch(void)
|
||||
{
|
||||
return '\033';
|
||||
}
|
||||
@@ -357,23 +332,20 @@ safe_nhgetch()
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
safe_nh_poskey(x, y, mod)
|
||||
int *x, *y, *mod;
|
||||
safe_nh_poskey(int *x, int *y, int *mod)
|
||||
{
|
||||
return '\033';
|
||||
}
|
||||
|
||||
void
|
||||
win_safe_init(dir)
|
||||
int dir;
|
||||
win_safe_init(int dir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef POSITIONBAR
|
||||
void
|
||||
safe_update_positionbar(posbar)
|
||||
char *posbar;
|
||||
safe_update_positionbar(char *posbar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -384,130 +356,121 @@ char *posbar;
|
||||
* -- initialize the port-specific data structures.
|
||||
*/
|
||||
void
|
||||
safe_status_init()
|
||||
safe_status_init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean
|
||||
safe_can_suspend()
|
||||
safe_can_suspend(void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
safe_nhbell()
|
||||
safe_nhbell(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
safe_doprev_message()
|
||||
safe_doprev_message(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char
|
||||
safe_yn_function(query, resp, def)
|
||||
const char *query;
|
||||
const char *resp;
|
||||
char def;
|
||||
safe_yn_function(const char * query, const char* resp, char def)
|
||||
{
|
||||
return '\033';
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
safe_getlin(prompt, outbuf)
|
||||
const char *prompt UNUSED;
|
||||
char *outbuf;
|
||||
safe_getlin(const char* prompt UNUSED, char *outbuf)
|
||||
{
|
||||
Strcpy(outbuf, "\033");
|
||||
}
|
||||
|
||||
int
|
||||
safe_get_ext_cmd()
|
||||
safe_get_ext_cmd(void)
|
||||
{
|
||||
return '\033';
|
||||
}
|
||||
|
||||
void
|
||||
safe_number_pad(mode)
|
||||
int mode;
|
||||
safe_number_pad(int mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_delay_output()
|
||||
safe_delay_output(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_start_screen()
|
||||
safe_start_screen(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_end_screen()
|
||||
safe_end_screen(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
safe_outrip(tmpwin, how, when)
|
||||
winid tmpwin;
|
||||
int how;
|
||||
time_t when;
|
||||
safe_outrip(winid tmpwin, int how, time_t when)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
safe_preference_update(pref)
|
||||
const char *pref UNUSED;
|
||||
safe_preference_update(const char* pref UNUSED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
safe_getmsghistory(init)
|
||||
boolean init UNUSED;
|
||||
safe_getmsghistory(boolean init UNUSED)
|
||||
{
|
||||
return (char *) 0;
|
||||
}
|
||||
|
||||
void
|
||||
safe_putmsghistory(msg, is_restoring)
|
||||
const char *msg;
|
||||
boolean is_restoring;
|
||||
safe_putmsghistory(
|
||||
const char *msg,
|
||||
boolean is_restoring)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
safe_status_finish()
|
||||
safe_status_finish(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
safe_status_enablefield(fieldidx, nm, fmt, enable)
|
||||
int fieldidx;
|
||||
const char *nm;
|
||||
const char *fmt;
|
||||
boolean enable;
|
||||
safe_status_enablefield(
|
||||
int fieldidx,
|
||||
const char *nm,
|
||||
const char *fmt,
|
||||
boolean enable)
|
||||
{
|
||||
}
|
||||
|
||||
/* call once for each field, then call with BL_FLUSH to output the result */
|
||||
void
|
||||
safe_status_update(idx, ptr, chg, percent, color, colormasks)
|
||||
int idx;
|
||||
genericptr_t ptr;
|
||||
int chg UNUSED, percent UNUSED, color UNUSED;
|
||||
unsigned long *colormasks UNUSED;
|
||||
safe_status_update(
|
||||
int idx,
|
||||
genericptr_t ptr,
|
||||
int chg UNUSED,
|
||||
int percent UNUSED,
|
||||
int color UNUSED,
|
||||
unsigned long *colormasks UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -528,7 +491,7 @@ unsigned long *colormasks UNUSED;
|
||||
|
||||
/* Add to your code: windowprocs.win_raw_print = stdio_wait_synch; */
|
||||
void
|
||||
stdio_wait_synch()
|
||||
stdio_wait_synch(void)
|
||||
{
|
||||
char valid[] = {' ', '\n', '\r', '\033', '\0'};
|
||||
|
||||
@@ -540,8 +503,7 @@ stdio_wait_synch()
|
||||
|
||||
/* Add to your code: windowprocs.win_raw_print = stdio_raw_print; */
|
||||
void
|
||||
stdio_raw_print(str)
|
||||
const char *str;
|
||||
stdio_raw_print(const char* str)
|
||||
{
|
||||
if (str)
|
||||
fprintf(stdout, "%s\n", str);
|
||||
@@ -551,8 +513,7 @@ const char *str;
|
||||
/* no newline variation, add to your code:
|
||||
windowprocs.win_raw_print = stdio_nonl_raw_print; */
|
||||
void
|
||||
stdio_nonl_raw_print(str)
|
||||
const char *str;
|
||||
stdio_nonl_raw_print(const char* str)
|
||||
{
|
||||
if (str)
|
||||
fprintf(stdout, "%s", str);
|
||||
@@ -561,8 +522,7 @@ const char *str;
|
||||
|
||||
/* Add to your code: windowprocs.win_raw_print_bold = stdio_raw_print_bold; */
|
||||
void
|
||||
stdio_raw_print_bold(str)
|
||||
const char *str;
|
||||
stdio_raw_print_bold(const char* str)
|
||||
{
|
||||
stdio_raw_print(str);
|
||||
return;
|
||||
@@ -570,7 +530,7 @@ const char *str;
|
||||
|
||||
/* Add to your code: windowprocs.win_nhgetch = stdio_nhgetch; */
|
||||
int
|
||||
stdio_nhgetch()
|
||||
stdio_nhgetch(void)
|
||||
{
|
||||
return getchar();
|
||||
}
|
||||
|
||||
+8
-8
@@ -33,18 +33,18 @@ extern int colorsinmainmap;
|
||||
|
||||
#define Fprintf (void) fprintf
|
||||
|
||||
extern boolean FDECL(fopen_text_file, (const char *, const char *));
|
||||
extern boolean FDECL(read_text_tile, (pixel(*) [TILE_X]));
|
||||
extern boolean FDECL(write_text_tile, (pixel(*) [TILE_X]));
|
||||
extern int NDECL(fclose_text_file);
|
||||
extern boolean fopen_text_file(const char *, const char *);
|
||||
extern boolean read_text_tile(pixel(*) [TILE_X]);
|
||||
extern boolean write_text_tile(pixel(*) [TILE_X]);
|
||||
extern int fclose_text_file(void);
|
||||
|
||||
extern void FDECL(set_grayscale, (int));
|
||||
extern void NDECL(init_colormap);
|
||||
extern void NDECL(merge_colormap);
|
||||
extern void set_grayscale(int);
|
||||
extern void init_colormap(void);
|
||||
extern void merge_colormap(void);
|
||||
|
||||
#if defined(MICRO) || defined(WIN32)
|
||||
#undef exit
|
||||
#if !defined(MSDOS) && !defined(WIN32)
|
||||
extern void FDECL(exit, (int));
|
||||
extern void exit(int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+10
-15
@@ -18,8 +18,8 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "tile.h"
|
||||
extern void NDECL(monst_globals_init);
|
||||
extern void NDECL(objects_globals_init);
|
||||
extern void monst_globals_init(void);
|
||||
extern void objects_globals_init(void);
|
||||
|
||||
#include <stdint.h>
|
||||
#if defined(UINT32_MAX) && defined(INT32_MAX) && defined(UINT16_MAX)
|
||||
@@ -45,7 +45,7 @@ extern void NDECL(objects_globals_init);
|
||||
|
||||
#define BITCOUNT 8
|
||||
|
||||
extern char *FDECL(tilename, (int, int));
|
||||
extern char *tilename(int, int);
|
||||
|
||||
#define MAGICTILENO (340 + 440 + 231 + 340)
|
||||
|
||||
@@ -158,9 +158,9 @@ FILE *tibfile2;
|
||||
|
||||
pixel tilepixels[TILE_Y][TILE_X];
|
||||
|
||||
static void FDECL(build_bmfh, (BITMAPFILEHEADER *));
|
||||
static void FDECL(build_bmih, (BITMAPINFOHEADER *));
|
||||
static void FDECL(build_bmptile, (pixel(*) [TILE_X]));
|
||||
static void build_bmfh(BITMAPFILEHEADER *);
|
||||
static void build_bmih(BITMAPINFOHEADER *);
|
||||
static void build_bmptile(pixel(*) [TILE_X]);
|
||||
|
||||
const char *tilefiles[] = {
|
||||
#if (TILE_X == 32)
|
||||
@@ -184,9 +184,7 @@ char bmpname[128];
|
||||
FILE *fp;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -271,8 +269,7 @@ char *argv[];
|
||||
}
|
||||
|
||||
static void
|
||||
build_bmfh(pbmfh)
|
||||
BITMAPFILEHEADER *pbmfh;
|
||||
build_bmfh(BITMAPFILEHEADER* pbmfh)
|
||||
{
|
||||
pbmfh->bfType = leshort(0x4D42);
|
||||
pbmfh->bfSize = lelong(BMPFILESIZE);
|
||||
@@ -283,8 +280,7 @@ BITMAPFILEHEADER *pbmfh;
|
||||
}
|
||||
|
||||
static void
|
||||
build_bmih(pbmih)
|
||||
BITMAPINFOHEADER *pbmih;
|
||||
build_bmih(BITMAPINFOHEADER* pbmih)
|
||||
{
|
||||
WORD cClrBits;
|
||||
int w, h;
|
||||
@@ -335,8 +331,7 @@ BITMAPINFOHEADER *pbmih;
|
||||
}
|
||||
|
||||
static void
|
||||
build_bmptile(pixels)
|
||||
pixel (*pixels)[TILE_X];
|
||||
build_bmptile(pixel(*pixels)[TILE_X])
|
||||
{
|
||||
int cur_x, cur_y, cur_color, apply_color;
|
||||
int x, y;
|
||||
|
||||
+15
-18
@@ -30,15 +30,15 @@
|
||||
FILE *tilemap_file;
|
||||
#endif
|
||||
|
||||
const char *FDECL(tilename, (int, int, int));
|
||||
void NDECL(init_tilemap);
|
||||
void FDECL(process_substitutions, (FILE *));
|
||||
boolean FDECL(acceptable_tilename, (int, int, const char *, const char *));
|
||||
const char *tilename(int, int, int);
|
||||
void init_tilemap(void);
|
||||
void process_substitutions(FILE *);
|
||||
boolean acceptable_tilename(int, int, const char *, const char *);
|
||||
|
||||
#if defined(MICRO) || defined(WIN32)
|
||||
#undef exit
|
||||
#if !defined(MSDOS) && !defined(WIN32)
|
||||
extern void FDECL(exit, (int));
|
||||
extern void exit(int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -113,8 +113,7 @@ struct substitute {
|
||||
* file_entry is the position of the tile within the monsters/objects/other set
|
||||
*/
|
||||
const char *
|
||||
tilename(set, file_entry, gend)
|
||||
int set, file_entry, gend;
|
||||
tilename(int set, int file_entry, int gend)
|
||||
{
|
||||
int i, j, condnum, tilenum, gendnum;
|
||||
static char buf[BUFSZ];
|
||||
@@ -296,7 +295,7 @@ int lastmontile, lastobjtile, lastothtile;
|
||||
* introduced in 3.3.1.
|
||||
*/
|
||||
void
|
||||
init_tilemap()
|
||||
init_tilemap(void)
|
||||
{
|
||||
int i, j, condnum, tilenum;
|
||||
int corpsetile, swallowbase;
|
||||
@@ -564,15 +563,14 @@ init_tilemap()
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *prolog[] = { "", "void", "substitute_tiles(plev)",
|
||||
"d_level *plev;", "{", " int i;", "" };
|
||||
const char *prolog[] = { "", "void", "substitute_tiles(d_level *plev)",
|
||||
"{", " int i;", "" };
|
||||
|
||||
const char *epilog[] = { " return;", "}" };
|
||||
|
||||
/* write out the substitutions in an easily-used form. */
|
||||
void
|
||||
process_substitutions(ofp)
|
||||
FILE *ofp;
|
||||
process_substitutions(FILE *ofp)
|
||||
{
|
||||
static const char Dent[] = " "; /* 4 space indentation */
|
||||
int i, j, k, span, start;
|
||||
@@ -642,12 +640,12 @@ FILE *ofp;
|
||||
}
|
||||
|
||||
#ifdef OBTAIN_TILEMAP
|
||||
extern void NDECL(monst_globals_init);
|
||||
extern void NDECL(objects_globals_init);
|
||||
extern void monst_globals_init(void);
|
||||
extern void objects_globals_init(void);
|
||||
#endif
|
||||
|
||||
int
|
||||
main()
|
||||
main(int argc UNUSED, char *argv[] UNUSED)
|
||||
{
|
||||
register int i;
|
||||
char filename[30];
|
||||
@@ -802,9 +800,8 @@ struct {
|
||||
};
|
||||
|
||||
boolean
|
||||
acceptable_tilename(glyph_set, idx, encountered, expected)
|
||||
int glyph_set, idx;
|
||||
const char *encountered, *expected;
|
||||
acceptable_tilename(int glyph_set, int idx, const char *encountered,
|
||||
const char *expected)
|
||||
{
|
||||
if (glyph_set == OTH_GLYPH) {
|
||||
if (idx >= 0 && idx < SIZE(altlabels)) {
|
||||
|
||||
+19
-31
@@ -7,10 +7,10 @@
|
||||
#include "flag.h"
|
||||
#include "tileset.h"
|
||||
|
||||
static void FDECL(get_tile_map, (const char *));
|
||||
static unsigned FDECL(gcd, (unsigned, unsigned));
|
||||
static void FDECL(split_tiles, (const struct TileSetImage *));
|
||||
static void FDECL(free_image, (struct TileSetImage *));
|
||||
static void get_tile_map(const char *);
|
||||
static unsigned gcd(unsigned, unsigned);
|
||||
static void split_tiles(const struct TileSetImage *);
|
||||
static void free_image(struct TileSetImage *);
|
||||
|
||||
static struct TileImage *tiles;
|
||||
static unsigned num_tiles;
|
||||
@@ -20,9 +20,7 @@ static boolean have_palette;
|
||||
static struct Pixel palette[256];
|
||||
|
||||
boolean
|
||||
read_tiles(filename, true_color)
|
||||
const char *filename;
|
||||
boolean true_color;
|
||||
read_tiles(const char *filename, boolean true_color)
|
||||
{
|
||||
static const unsigned char png_sig[] = {
|
||||
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A
|
||||
@@ -105,8 +103,7 @@ error:
|
||||
|
||||
/* Free tile memory not required by the chosen display mode */
|
||||
void
|
||||
set_tile_type(true_color)
|
||||
boolean true_color;
|
||||
set_tile_type(boolean true_color)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@@ -127,21 +124,20 @@ boolean true_color;
|
||||
}
|
||||
|
||||
const struct Pixel *
|
||||
get_palette()
|
||||
get_palette(void)
|
||||
{
|
||||
return have_palette ? palette : NULL;
|
||||
}
|
||||
|
||||
/* TODO: derive tile_map from image_desc */
|
||||
static void
|
||||
get_tile_map(image_desc)
|
||||
const char *image_desc;
|
||||
get_tile_map(const char *image_desc UNUSED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
free_tiles()
|
||||
free_tiles(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@@ -161,8 +157,7 @@ free_tiles()
|
||||
}
|
||||
|
||||
static void
|
||||
free_image(image)
|
||||
struct TileSetImage *image;
|
||||
free_image(struct TileSetImage *image)
|
||||
{
|
||||
if (image->pixels)
|
||||
free((genericptr_t) image->pixels), image->pixels = NULL;
|
||||
@@ -173,8 +168,7 @@ struct TileSetImage *image;
|
||||
}
|
||||
|
||||
const struct TileImage *
|
||||
get_tile(tile_index)
|
||||
unsigned tile_index;
|
||||
get_tile(unsigned tile_index)
|
||||
{
|
||||
if (tile_index >= num_tiles)
|
||||
return &blank_tile;
|
||||
@@ -183,9 +177,8 @@ unsigned tile_index;
|
||||
|
||||
/* Note that any tile returned by this function must be freed */
|
||||
struct TileImage *
|
||||
stretch_tile(inp_tile, out_width, out_height)
|
||||
const struct TileImage *inp_tile;
|
||||
unsigned out_width, out_height;
|
||||
stretch_tile(const struct TileImage *inp_tile,
|
||||
unsigned out_width, unsigned out_height)
|
||||
{
|
||||
unsigned x_scale_inp, x_scale_out, y_scale_inp, y_scale_out;
|
||||
unsigned divisor;
|
||||
@@ -264,8 +257,7 @@ unsigned out_width, out_height;
|
||||
/* Free a tile returned by stretch_tile */
|
||||
/* Do NOT use this with tiles returned by get_tile */
|
||||
void
|
||||
free_tile(tile)
|
||||
struct TileImage *tile;
|
||||
free_tile(struct TileImage *tile)
|
||||
{
|
||||
if (tile != NULL) {
|
||||
free(tile->indexes);
|
||||
@@ -276,8 +268,7 @@ struct TileImage *tile;
|
||||
|
||||
/* Return the greatest common divisor */
|
||||
static unsigned
|
||||
gcd(a, b)
|
||||
unsigned a, b;
|
||||
gcd(unsigned a, unsigned b)
|
||||
{
|
||||
while (TRUE) {
|
||||
if (b == 0) return a;
|
||||
@@ -288,8 +279,7 @@ unsigned a, b;
|
||||
}
|
||||
|
||||
static void
|
||||
split_tiles(image)
|
||||
const struct TileSetImage *image;
|
||||
split_tiles(const struct TileSetImage *image)
|
||||
{
|
||||
unsigned tile_rows, tile_cols;
|
||||
size_t tile_size, i, j;
|
||||
@@ -317,8 +307,8 @@ const struct TileSetImage *image;
|
||||
if (image->indexes != NULL) {
|
||||
tile->indexes = (unsigned char *) alloc(tile_size);
|
||||
}
|
||||
for (y2 = 0; y2 < iflags.wc_tile_height; ++y2) {
|
||||
for (x2 = 0; x2 < iflags.wc_tile_width; ++x2) {
|
||||
for (y2 = 0; y2 < (unsigned) iflags.wc_tile_height; ++y2) {
|
||||
for (x2 = 0; x2 < (unsigned) iflags.wc_tile_width; ++x2) {
|
||||
unsigned x = x1 * iflags.wc_tile_width + x2;
|
||||
unsigned y = y1 * iflags.wc_tile_height + y2;
|
||||
|
||||
@@ -351,9 +341,7 @@ const struct TileSetImage *image;
|
||||
}
|
||||
|
||||
boolean
|
||||
read_png_tiles(filename, image)
|
||||
const char *filename;
|
||||
struct TileSetImage *image;
|
||||
read_png_tiles(const char *filename UNUSED, struct TileSetImage *image UNUSED)
|
||||
{
|
||||
/* stub */
|
||||
return FALSE;
|
||||
|
||||
+17
-28
@@ -26,12 +26,12 @@ static const char *text_sets[] = { "monsters.txt", "objects.txt",
|
||||
"other.txt" };
|
||||
#endif
|
||||
|
||||
extern const char *FDECL(tilename, (int, int, int));
|
||||
extern boolean FDECL(acceptable_tilename, (int, int, const char *, const char *));
|
||||
static void FDECL(read_text_colormap, (FILE *));
|
||||
static boolean FDECL(write_text_colormap, (FILE *));
|
||||
static boolean FDECL(read_txttile, (FILE *, pixel (*)[TILE_X]));
|
||||
static void FDECL(write_txttile, (FILE *, pixel (*)[TILE_X]));
|
||||
extern const char *tilename(int, int, int);
|
||||
extern boolean acceptable_tilename(int, int, const char *, const char *);
|
||||
static void read_text_colormap(FILE *);
|
||||
static boolean write_text_colormap(FILE *);
|
||||
static boolean read_txttile(FILE *, pixel (*)[TILE_X]);
|
||||
static void write_txttile(FILE *, pixel (*)[TILE_X]);
|
||||
|
||||
enum { MONSTER_SET, OBJECT_SET, OTHER_SET};
|
||||
|
||||
@@ -50,15 +50,13 @@ static const int graymappings[] = {
|
||||
};
|
||||
|
||||
void
|
||||
set_grayscale(g)
|
||||
int g;
|
||||
set_grayscale(int g)
|
||||
{
|
||||
grayscale = g;
|
||||
}
|
||||
|
||||
static void
|
||||
read_text_colormap(txtfile)
|
||||
FILE *txtfile;
|
||||
read_text_colormap(FILE *txtfile)
|
||||
{
|
||||
int i, r, g, b;
|
||||
char c[2];
|
||||
@@ -80,8 +78,7 @@ FILE *txtfile;
|
||||
#undef FORMAT_STRING
|
||||
|
||||
static boolean
|
||||
write_text_colormap(txtfile)
|
||||
FILE *txtfile;
|
||||
write_text_colormap(FILE *txtfile)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
@@ -108,9 +105,7 @@ FILE *txtfile;
|
||||
}
|
||||
|
||||
static boolean
|
||||
read_txttile(txtfile, pixels)
|
||||
FILE *txtfile;
|
||||
pixel (*pixels)[TILE_X];
|
||||
read_txttile(FILE *txtfile, pixel (*pixels)[TILE_X])
|
||||
{
|
||||
int ph, i, j, k, reslt;
|
||||
char buf[BUFSZ], ttype[BUFSZ], gend[BUFSZ];
|
||||
@@ -202,9 +197,7 @@ pixel (*pixels)[TILE_X];
|
||||
}
|
||||
|
||||
static void
|
||||
write_txttile(txtfile, pixels)
|
||||
FILE *txtfile;
|
||||
pixel (*pixels)[TILE_X];
|
||||
write_txttile(FILE *txtfile, pixel (*pixels)[TILE_X])
|
||||
{
|
||||
const char *p;
|
||||
const char *type;
|
||||
@@ -252,7 +245,7 @@ pixel (*pixels)[TILE_X];
|
||||
|
||||
/* initialize main colormap from globally accessed ColorMap */
|
||||
void
|
||||
init_colormap()
|
||||
init_colormap(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -266,7 +259,7 @@ init_colormap()
|
||||
|
||||
/* merge new colors from ColorMap into MainColorMap */
|
||||
void
|
||||
merge_colormap()
|
||||
merge_colormap(void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -292,9 +285,7 @@ merge_colormap()
|
||||
}
|
||||
|
||||
boolean
|
||||
fopen_text_file(filename, type)
|
||||
const char *filename;
|
||||
const char *type;
|
||||
fopen_text_file(const char *filename, const char *type)
|
||||
{
|
||||
const char *p;
|
||||
int i;
|
||||
@@ -350,22 +341,20 @@ const char *type;
|
||||
}
|
||||
|
||||
boolean
|
||||
read_text_tile(pixels)
|
||||
pixel (*pixels)[TILE_X];
|
||||
read_text_tile(pixel (*pixels)[TILE_X])
|
||||
{
|
||||
return (read_txttile(tile_file, pixels));
|
||||
}
|
||||
|
||||
boolean
|
||||
write_text_tile(pixels)
|
||||
pixel (*pixels)[TILE_X];
|
||||
write_text_tile(pixel (*pixels)[TILE_X])
|
||||
{
|
||||
write_txttile(tile_file, pixels);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
fclose_text_file()
|
||||
fclose_text_file(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user