libwld: Rename some things to get closer to current coding standard.
This commit is contained in:
parent
9885b5c9b3
commit
505d80dd4c
@ -69,5 +69,5 @@ uint16_t g_nbitmaps;
|
||||
* the sky and ground
|
||||
*/
|
||||
|
||||
uint8_t skyColor;
|
||||
uint8_t groundColor;
|
||||
uint8_t g_sky_color;
|
||||
uint8_t g_ground_color;
|
||||
|
@ -115,8 +115,8 @@ extern uint16_t g_nbitmaps;
|
||||
* the sky and ground
|
||||
*/
|
||||
|
||||
extern uint8_t skyColor;
|
||||
extern uint8_t groundColor;
|
||||
extern uint8_t g_sky_color;
|
||||
extern uint8_t g_ground_color;
|
||||
|
||||
/*************************************************************************
|
||||
* Global Function Prototypes
|
||||
|
@ -77,15 +77,15 @@ wld_camera_t g_initial_camera;
|
||||
* the position of the player's "feet"
|
||||
*/
|
||||
|
||||
wld_coord_t playerHeight;
|
||||
wld_coord_t g_player_height;
|
||||
|
||||
/* This is size of something that the player can step over when "walking" */
|
||||
|
||||
wld_coord_t walkStepHeight;
|
||||
wld_coord_t g_walk_stepheight;
|
||||
|
||||
/* This is size of something that the player can step over when "running" */
|
||||
|
||||
wld_coord_t runStepHeight;
|
||||
wld_coord_t g_run_stepheight;
|
||||
|
||||
/*************************************************************************
|
||||
* Private Constant Data
|
||||
@ -164,7 +164,7 @@ static uint8_t wld_manage_worldfile(INIHANDLE handle)
|
||||
|
||||
/* Get the height of the player */
|
||||
|
||||
result = wld_read_shortint(handle, &playerHeight,
|
||||
result = wld_read_shortint(handle, &g_player_height,
|
||||
g_player_section_name, g_player_height_name);
|
||||
if (result != 0)
|
||||
{
|
||||
@ -173,7 +173,7 @@ static uint8_t wld_manage_worldfile(INIHANDLE handle)
|
||||
|
||||
/* Read the player's capability to step on top of things in the world. */
|
||||
|
||||
result = wld_read_shortint(handle, &walkStepHeight,
|
||||
result = wld_read_shortint(handle, &g_walk_stepheight,
|
||||
g_player_section_name,
|
||||
g_player_walk_stepheight_name);
|
||||
if (result != 0)
|
||||
@ -181,7 +181,7 @@ static uint8_t wld_manage_worldfile(INIHANDLE handle)
|
||||
return result;
|
||||
}
|
||||
|
||||
result = wld_read_shortint(handle, &runStepHeight,
|
||||
result = wld_read_shortint(handle, &g_run_stepheight,
|
||||
g_player_section_name,
|
||||
g_player_run_stepheight_name);
|
||||
if (result != 0)
|
||||
|
@ -48,12 +48,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_DiscardWorldPlane
|
||||
* Name: wld_discard_worldplane
|
||||
* Description:
|
||||
* This function deallocates one plane of the world
|
||||
************************************************************************/
|
||||
|
||||
static void wld_DiscardWorldPlane(rect_list_t * rect)
|
||||
static void wld_discard_worldplane(rect_list_t * rect)
|
||||
{
|
||||
rect_list_t *next;
|
||||
|
||||
@ -77,12 +77,12 @@ static void wld_DiscardWorldPlane(rect_list_t * rect)
|
||||
|
||||
void wld_discard_planes(void)
|
||||
{
|
||||
wld_DiscardWorldPlane(g_xplane_list.head);
|
||||
wld_discard_worldplane(g_xplane_list.head);
|
||||
g_xplane_list.head = g_xplane_list.tail = NULL;
|
||||
wld_DiscardWorldPlane(g_yplane_list.head);
|
||||
wld_discard_worldplane(g_yplane_list.head);
|
||||
g_yplane_list.head = g_yplane_list.tail = NULL;
|
||||
wld_DiscardWorldPlane(g_zplane_list.head);
|
||||
wld_discard_worldplane(g_zplane_list.head);
|
||||
g_zplane_list.head = g_zplane_list.tail = NULL;
|
||||
wld_DiscardWorldPlane(freeList);
|
||||
wld_discard_worldplane(freeList);
|
||||
freeList = NULL;
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ rect_list_t *wld_find_plane(wld_coord_t h, wld_coord_t v, wld_coord_t plane,
|
||||
* within the rectangle.
|
||||
*/
|
||||
|
||||
if ((h >= rect->d.hStart) && (h <= rect->d.hEnd)
|
||||
&& (v >= rect->d.vStart) && (v <= rect->d.vEnd))
|
||||
if ((h >= rect->d.hstart) && (h <= rect->d.hend)
|
||||
&& (v >= rect->d.vstart) && (v <= rect->d.vend))
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
@ -68,19 +68,19 @@
|
||||
|
||||
enum graphic_file_format_e
|
||||
{
|
||||
formatGIF87,
|
||||
formatGIF89,
|
||||
formatPPM,
|
||||
formatPCX,
|
||||
formatUnknown
|
||||
FORMAT_GIT87,
|
||||
FORMAT_GIT89,
|
||||
FORMAT_PPM,
|
||||
FORMAT_PCX,
|
||||
FORMAT_UNKNOWN
|
||||
};
|
||||
|
||||
typedef enum graphic_file_format_e graphic_file_format_t;
|
||||
|
||||
enum graphic_file_enum_e
|
||||
{
|
||||
gfTrueColor,
|
||||
gfPaletted
|
||||
GFILE_TRUECOLOR,
|
||||
GFILE_PALETTED
|
||||
};
|
||||
|
||||
typedef enum graphic_file_enum_e graphic_file_enum_t;
|
||||
@ -88,7 +88,8 @@ typedef enum graphic_file_enum_e graphic_file_enum_t;
|
||||
struct graphic_file_e
|
||||
{
|
||||
graphic_file_enum_t type;
|
||||
uint16_t height, width;
|
||||
uint16_t height;
|
||||
uint16_t width;
|
||||
int palette_entries;
|
||||
long transparent_entry;
|
||||
color_rgb_t *palette;
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
color_rgb_t wld_graphicfile_pixel(graphic_file_t *gfile, int x, int y)
|
||||
{
|
||||
if (gfile->type == gfPaletted)
|
||||
if (gfile->type == GFILE_PALETTED)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
#define PLAYER_SECTION_NAME "player"
|
||||
|
||||
/* These are charwld_erictics of the player. */
|
||||
|
||||
#define PLAYER_HEIGHT "playerheight"
|
||||
#define PLAYER_WALK_STEPHEIGHT "playerwalkstepheight"
|
||||
#define PLAYER_RUN_STEPHEIGHT "playerrunstepheight"
|
||||
|
@ -148,8 +148,8 @@ static uint8_t wld_load_bitmaps(FILE * fp)
|
||||
|
||||
/* Read the colors used to rend the sky and ground */
|
||||
|
||||
skyColor = wld_read_decimal(fp);
|
||||
groundColor = wld_read_decimal(fp);
|
||||
g_sky_color = wld_read_decimal(fp);
|
||||
g_ground_color = wld_read_decimal(fp);
|
||||
|
||||
#if MSWINDOWS
|
||||
/* Load the textures -- Note that the first texture will be used to define
|
||||
|
@ -52,76 +52,76 @@
|
||||
* Pre-processor Definitions
|
||||
*************************************************************************/
|
||||
|
||||
#define NEXTBYTE (*ptr++)
|
||||
#define IMAGESEP 0x2c
|
||||
#define GRAPHIC_EXT 0xf9
|
||||
#define PLAINTEXT_EXT 0x01
|
||||
#define NEXTBYTE (*ptr++)
|
||||
#define IMAGESEP 0x2c
|
||||
#define GRAPHIC_EXT 0xf9
|
||||
#define PLAINTEXT_EXT 0x01
|
||||
#define APPLICATION_EXT 0xff
|
||||
#define COMMENT_EXT 0xfe
|
||||
#define COMMENT_EXT 0xfe
|
||||
#define START_EXTENSION 0x21
|
||||
#define INTERLACEMASK 0x40
|
||||
#define COLORMAPMASK 0x80
|
||||
#define INTERLACEMASK 0x40
|
||||
#define COLORMAPMASK 0x80
|
||||
|
||||
/*************************************************************************
|
||||
* Private Data
|
||||
*************************************************************************/
|
||||
|
||||
int BitOffset = 0, /* Bit Offset of next code */
|
||||
XC = 0, YC = 0, /* Output X and Y coords of current pixel */
|
||||
Pass = 0, /* Used by output routine if interlaced pic */
|
||||
OutCount = 0, /* Decompressor output 'stack count' */
|
||||
RWidth, RHeight, /* screen dimensions */
|
||||
Width, Height, /* image dimensions */
|
||||
LeftOfs, TopOfs, /* image offset */
|
||||
BitsPerPixel, /* Bits per pixel, read from GIF header */
|
||||
BytesPerScanline, /* bytes per scanline in output rwld_er */
|
||||
ColorMapSize, /* number of colors */
|
||||
Background, /* background color */
|
||||
CodeSize, /* Code size, read from GIF header */
|
||||
InitCodeSize, /* Starting code size, used during Clear */
|
||||
Code, /* Value returned by ReadCode */
|
||||
MaxCode, /* limiting value for current code size */
|
||||
ClearCode, /* GIF clear code */
|
||||
EOFCode, /* GIF end-of-information code */
|
||||
CurCode, OldCode, InCode, /* Decompressor variables */
|
||||
FirstFree, /* First free code, generated per GIF spec */
|
||||
FreeCode, /* Decompressor, next free slot in hash table */
|
||||
FinChar, /* Decompressor variable */
|
||||
BitMask, /* AND mask for data size */
|
||||
ReadMask; /* Code AND mask for current code size */
|
||||
static int BitOffset = 0; /* Bit Offset of next code */
|
||||
static int XC = 0, YC = 0; /* Output X and Y coords of current pixel */
|
||||
static int Pass = 0; /* Used by output routine if interlaced pic */
|
||||
static int OutCount = 0; /* Decompressor output 'stack count' */
|
||||
static int RWidth, RHeight; /* screen dimensions */
|
||||
static int Width, Height; /* image dimensions */
|
||||
static int LeftOfs, TopOfs; /* image offset */
|
||||
static int BitsPerPixel; /* Bits per pixel, read from GIF header */
|
||||
static int BytesPerScanline; /* bytes per scanline in output rwld_er */
|
||||
static int ColorMapSize; /* number of colors */
|
||||
static int Background; /* background color */
|
||||
static int CodeSize; /* Code size, read from GIF header */
|
||||
static int InitCodeSize; /* Starting code size, used during Clear */
|
||||
static int Code; /* Value returned by ReadCode */
|
||||
static int MaxCode; /* limiting value for current code size */
|
||||
static int ClearCode; /* GIF clear code */
|
||||
static int EOFCode; /* GIF end-of-information code */
|
||||
static int CurCode, OldCode, InCode; /* Decompressor variables */
|
||||
static int FirstFree; /* First free code, generated per GIF spec */
|
||||
static int FreeCode; /* Decompressor, next free slot in hash table */
|
||||
static int FinChar; /* Decompressor variable */
|
||||
static int BitMask; /* AND mask for data size */
|
||||
static int ReadMask; /* Code AND mask for current code size */
|
||||
|
||||
bool Interlace, HasColormap;
|
||||
bool Verbose = true;
|
||||
static bool Interlace, HasColormap;
|
||||
static bool Verbose = true;
|
||||
|
||||
uint8_t *Image; /* The result array */
|
||||
uint8_t *RawGIF; /* The heap array to hold it, raw */
|
||||
uint8_t *Rwld_er; /* The rwld_er data stream, unblocked */
|
||||
static uint8_t *Image; /* The result array */
|
||||
static uint8_t *RawGIF; /* The heap array to hold it, raw */
|
||||
static uint8_t *Rwld_er; /* The rwld_er data stream, unblocked */
|
||||
|
||||
/* The hash table used by the decompressor */
|
||||
|
||||
int Prefix[4096];
|
||||
int Suffix[4096];
|
||||
static int Prefix[4096];
|
||||
static int Suffix[4096];
|
||||
|
||||
/* An output array used by the decompressor */
|
||||
|
||||
int OutCode[1025];
|
||||
static int OutCode[1025];
|
||||
|
||||
/* The color map, read from the GIF header */
|
||||
|
||||
uint8_t Red[256], Green[256], Blue[256], used[256];
|
||||
int numused;
|
||||
static uint8_t Red[256], Green[256], Blue[256], used[256];
|
||||
static int numused;
|
||||
|
||||
char *id87 = "GIF87a";
|
||||
char *id89 = "GIF89a";
|
||||
static char *id87 = "GIF87a";
|
||||
static char *id89 = "GIF89a";
|
||||
|
||||
/*************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name:
|
||||
* Name: ReadCode
|
||||
* Description:
|
||||
* Fetch the next code from the rwld_er data stream. The codes can be
|
||||
* Fetch the next code from the data stream. The codes can be
|
||||
* any length from 3 to 12 bits, packed into 8-bit bytes, so we have to
|
||||
* maintain our location in the Rwld_er array as a BIT Offset. We compute
|
||||
* the byte Offset into the rwld_er array by dividing this by 8, pick up
|
||||
@ -131,7 +131,8 @@ char *id89 = "GIF89a";
|
||||
|
||||
static int ReadCode(void)
|
||||
{
|
||||
int RawCode, ByteOffset;
|
||||
int RawCode;
|
||||
int ByteOffset;
|
||||
|
||||
ByteOffset = BitOffset / 8;
|
||||
RawCode = Rwld_er[ByteOffset] + (0x100 * Rwld_er[ByteOffset + 1]);
|
||||
@ -376,7 +377,7 @@ graphic_file_t *wld_LoadGIF(FILE * fp, char *fname)
|
||||
}
|
||||
|
||||
gfile->bitmap = (uint8_t *) wld_malloc(Width * Height);
|
||||
gfile->type = gfPaletted;
|
||||
gfile->type = GFILE_PALETTED;
|
||||
gfile->width = Width;
|
||||
gfile->height = Height;
|
||||
gfile->transparent_entry = transparency;
|
||||
|
@ -52,21 +52,21 @@
|
||||
* Private Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
static void wld_loadpcxHeader(FILE * fp, pcx_header_t * header);
|
||||
static void wld_loadpcxData(FILE * fp, int32_t imagSize, uint8_t * imageBuffer);
|
||||
static void wld_loadpcxPalette(FILE * fp, color_rgb_t * palette);
|
||||
static void wld_load_pcxheader(FILE * fp, pcx_header_t * header);
|
||||
static void wld_load_pcxdata(FILE * fp, int32_t imagSize,
|
||||
uint8_t * imageBuffer);
|
||||
static void wld_load_pcxpalette(FILE * fp, color_rgb_t * palette);
|
||||
|
||||
/*************************************************************************
|
||||
* Private Functions
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_loadpcxHeader
|
||||
* Name: wld_load_pcxheader
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
static void wld_loadpcxHeader(FILE * fp, pcx_header_t * header)
|
||||
static void wld_load_pcxheader(FILE * fp, pcx_header_t * header)
|
||||
{
|
||||
uint8_t *tempBuffer;
|
||||
int i;
|
||||
@ -82,11 +82,11 @@ static void wld_loadpcxHeader(FILE * fp, pcx_header_t * header)
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_loadpcxData
|
||||
* Name: wld_load_pcxdata
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
static void wld_loadpcxData(FILE * fp, int32_t imageSize, uint8_t * imageBuffer)
|
||||
static void wld_load_pcxdata(FILE * fp, int32_t imageSize, uint8_t * imageBuffer)
|
||||
{
|
||||
uint32_t count;
|
||||
int16_t numBytes;
|
||||
@ -128,11 +128,11 @@ static void wld_loadpcxData(FILE * fp, int32_t imageSize, uint8_t * imageBuffer)
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_loadpcxPalette
|
||||
* Name: wld_load_pcxpalette
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
static void wld_loadpcxPalette(FILE * fp, color_rgb_t * palette)
|
||||
static void wld_load_pcxpalette(FILE * fp, color_rgb_t * palette)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -188,7 +188,7 @@ uint8_t wld_loadpcx(char *filename, pcxPicturePtr image)
|
||||
|
||||
/* Load the PCX Header */
|
||||
|
||||
wld_loadpcxHeader(fp, &image->header);
|
||||
wld_load_pcxheader(fp, &image->header);
|
||||
|
||||
/* Load the PCX data */
|
||||
|
||||
@ -197,14 +197,14 @@ uint8_t wld_loadpcx(char *filename, pcxPicturePtr image)
|
||||
imageWidth = image->header.width - image->header.x + 1;
|
||||
imageHeight = image->header.height - image->header.y + 1;
|
||||
imageSize = imageHeight * imageWidth;
|
||||
wld_loadpcxData(fp, imageSize, image->buffer);
|
||||
wld_load_pcxdata(fp, imageSize, image->buffer);
|
||||
}
|
||||
|
||||
/* Load the PCX palette */
|
||||
|
||||
if (image->palette)
|
||||
{
|
||||
wld_loadpcxPalette(fp, &image->palette);
|
||||
wld_load_pcxpalette(fp, &image->palette);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
@ -222,7 +222,7 @@ graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
|
||||
|
||||
/* Load the PCX Header */
|
||||
|
||||
wld_loadpcxHeader(fp, &header);
|
||||
wld_load_pcxheader(fp, &header);
|
||||
|
||||
/* Allocate Space to hold the image data */
|
||||
|
||||
@ -233,7 +233,7 @@ graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
|
||||
|
||||
/* Load the PCX data into the buffer */
|
||||
|
||||
wld_loadpcxData(fp, imageSize, (uint8_t *) buffer);
|
||||
wld_load_pcxdata(fp, imageSize, (uint8_t *) buffer);
|
||||
|
||||
/* Allocate space to hold the PCX palette */
|
||||
|
||||
@ -241,12 +241,12 @@ graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
|
||||
|
||||
/* Load the PCX palette */
|
||||
|
||||
wld_loadpcxPalette(fp, palette);
|
||||
wld_load_pcxpalette(fp, palette);
|
||||
|
||||
/* Now save the resulting data in a graphic_file_t structure */
|
||||
|
||||
gFile = wld_new_graphicfile();
|
||||
gFile->type = gfPaletted;
|
||||
gFile->type = GFILE_PALETTED;
|
||||
gFile->palette = palette;
|
||||
gFile->width = imageWidth;
|
||||
gFile->height = imageHeight;
|
||||
|
@ -108,11 +108,11 @@ uint8_t wld_load_planes(FILE * fp)
|
||||
|
||||
/* Then load each grid, performing run length (rle) decoding */
|
||||
|
||||
result = wld_load_worldplane(fp, &g_xplane_list, fileHeader.numXRects);
|
||||
result = wld_load_worldplane(fp, &g_xplane_list, fileHeader.num_xrects);
|
||||
if (!result)
|
||||
result = wld_load_worldplane(fp, &g_yplane_list, fileHeader.numYRects);
|
||||
result = wld_load_worldplane(fp, &g_yplane_list, fileHeader.num_yrects);
|
||||
if (!result)
|
||||
result = wld_load_worldplane(fp, &g_zplane_list, fileHeader.numZRects);
|
||||
result = wld_load_worldplane(fp, &g_zplane_list, fileHeader.num_zrects);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ graphic_file_t *wld_LoadPPM(FILE * fp, char *filename)
|
||||
}
|
||||
|
||||
gfile = wld_new_graphicfile();
|
||||
gfile->type = gfTrueColor;
|
||||
gfile->type = GFILE_TRUECOLOR;
|
||||
gfile->palette = NULL;
|
||||
gfile->width = width;
|
||||
gfile->height = height;
|
||||
|
@ -108,38 +108,48 @@ enum
|
||||
typedef short wld_coord_t; /* Max world size is +/- 65536/64 = 1024 */
|
||||
typedef uint8_t attrib_t; /* Max attributes = 8 */
|
||||
|
||||
typedef struct rectDataStruct
|
||||
struct rect_data_s
|
||||
{
|
||||
wld_coord_t plane; /* defines the plane that the rect lies in */
|
||||
wld_coord_t hStart; /* defines the starting "horizontal" position */
|
||||
wld_coord_t hEnd; /* defines the ending "horizontal" position */
|
||||
wld_coord_t vStart; /* defines the starting "vertical" position */
|
||||
wld_coord_t vEnd; /* defines the ending "vertical" position */
|
||||
wld_coord_t hstart; /* defines the starting "horizontal" position */
|
||||
wld_coord_t hend; /* defines the ending "horizontal" position */
|
||||
wld_coord_t vstart; /* defines the starting "vertical" position */
|
||||
wld_coord_t vend; /* defines the ending "vertical" position */
|
||||
attrib_t attribute; /* bit-encoded attributes of the plane */
|
||||
uint8_t texture; /* defines the texture that should be applied */
|
||||
uint8_t scale; /* defines the scaling of the texture */
|
||||
} rect_data_t;
|
||||
};
|
||||
|
||||
typedef struct rect_data_s rect_data_t;
|
||||
|
||||
#define SIZEOF_RECTDATATYPE 13
|
||||
|
||||
typedef struct rectListStruct
|
||||
struct rect_list_s
|
||||
{
|
||||
struct rectListStruct *flink; /* points at next rectangle in a list */
|
||||
struct rectListStruct *blink; /* points at previous rectangle in a list */
|
||||
struct rect_list_s *flink; /* points at next rectangle in a list */
|
||||
struct rect_list_s *blink; /* points at previous rectangle in a list */
|
||||
rect_data_t d; /* the data which defines the rectangle */
|
||||
} rect_list_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
typedef struct rect_list_s rect_list_t;
|
||||
|
||||
struct rect_head_s
|
||||
{
|
||||
rect_list_t *head; /* points to the start of the list */
|
||||
rect_list_t *tail; /* points to the end of the list */
|
||||
} rect_head_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
typedef struct rect_head_s rect_head_t;
|
||||
|
||||
struct plane_file_header_s
|
||||
{
|
||||
uint16_t numXRects;
|
||||
uint16_t numYRects;
|
||||
uint16_t numZRects;
|
||||
} plane_file_header_t;
|
||||
uint16_t num_xrects;
|
||||
uint16_t num_yrects;
|
||||
uint16_t num_zrects;
|
||||
};
|
||||
|
||||
typedef struct plane_file_header_s plane_file_header_t;
|
||||
|
||||
#define SIZEOF_PLANEFILEHEADERTYPE 6
|
||||
|
||||
/*************************************************************************
|
||||
@ -166,23 +176,23 @@ extern rect_list_t *freeList;
|
||||
* Public Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
extern uint8_t wld_initialize_planes(void);
|
||||
extern void wld_discard_planes(void);
|
||||
extern uint8_t wld_load_planefile(const char *wldfile);
|
||||
extern uint8_t wld_load_planes(FILE *fp);
|
||||
extern uint8_t wld_save_planes(const char *wldFile);
|
||||
extern rect_list_t *wld_new_plane(void);
|
||||
extern void wld_add_plane(rect_list_t *rect,
|
||||
rect_head_t *list);
|
||||
extern void wld_merge_planelists(rect_head_t *outList,
|
||||
rect_head_t *inList);
|
||||
extern void wld_remove_plane(rect_list_t *rect,
|
||||
rect_head_t *list);
|
||||
extern void wld_move_plane(rect_list_t *rect,
|
||||
rect_head_t *destList,
|
||||
rect_head_t *srcList);
|
||||
extern rect_list_t *wld_find_plane(wld_coord_t h, wld_coord_t v, wld_coord_t plane,
|
||||
rect_head_t *list);
|
||||
uint8_t wld_initialize_planes(void);
|
||||
void wld_discard_planes(void);
|
||||
uint8_t wld_load_planefile(const char *wldfile);
|
||||
uint8_t wld_load_planes(FILE *fp);
|
||||
uint8_t wld_save_planes(const char *wldFile);
|
||||
rect_list_t *wld_new_plane(void);
|
||||
void wld_add_plane(rect_list_t *rect,
|
||||
rect_head_t *list);
|
||||
void wld_merge_planelists(rect_head_t *outList,
|
||||
rect_head_t *inList);
|
||||
void wld_remove_plane(rect_list_t *rect,
|
||||
rect_head_t *list);
|
||||
void wld_move_plane(rect_list_t *rect,
|
||||
rect_head_t *destList,
|
||||
rect_head_t *srcList);
|
||||
rect_list_t *wld_find_plane(wld_coord_t h, wld_coord_t v, wld_coord_t plane,
|
||||
rect_head_t *list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -54,18 +54,18 @@ graphic_file_t *wld_LoadGIF(FILE * fp, char *filename);
|
||||
* Private Data
|
||||
*************************************************************************/
|
||||
|
||||
static const char pcxExtension[] = ".PCX";
|
||||
static const char g_pcx_extension[] = ".PCX";
|
||||
|
||||
/*************************************************************************
|
||||
* Private Functions
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_CheckFormat
|
||||
* Name: wld_check_format
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename)
|
||||
static graphic_file_format_t wld_check_format(FILE * fp, char *filename)
|
||||
{
|
||||
char magic[MAGIC_LENGTH];
|
||||
|
||||
@ -76,15 +76,15 @@ static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename)
|
||||
|
||||
if (strncmp(magic, PPM_MAGIC, sizeof(PPM_MAGIC) - 1) == 0)
|
||||
{
|
||||
return formatPPM;
|
||||
return FORMAT_PPM;
|
||||
}
|
||||
else if (strncmp(magic, GIF_MAGIC, sizeof(GIF_MAGIC) - 1) == 0)
|
||||
{
|
||||
return formatGIF87;
|
||||
return FORMAT_GIT87;
|
||||
}
|
||||
else if (strncmp(magic, GIF89_MAGIC, sizeof(GIF89_MAGIC) - 1) == 0)
|
||||
{
|
||||
return formatGIF89;
|
||||
return FORMAT_GIT89;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -101,11 +101,11 @@ static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename)
|
||||
|
||||
/* Check if the extension matches */
|
||||
|
||||
for (ptr2 = (char *)pcxExtension; ((*ptr1) && (*ptr2)); ptr1++, ptr2++)
|
||||
for (ptr2 = (char *)g_pcx_extension; ((*ptr1) && (*ptr2)); ptr1++, ptr2++)
|
||||
{
|
||||
if (toupper((int)*ptr1) != *ptr2)
|
||||
{
|
||||
return formatUnknown;
|
||||
return FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,11 +115,11 @@ static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename)
|
||||
|
||||
if (!(*ptr1) && !(*ptr2))
|
||||
{
|
||||
return formatPCX;
|
||||
return FORMAT_PCX;
|
||||
}
|
||||
}
|
||||
|
||||
return formatUnknown;
|
||||
return FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@ -142,25 +142,25 @@ graphic_file_t *wld_readgraphic_file(char *filename)
|
||||
wld_fatal_error("Could not open texture %s", filename);
|
||||
}
|
||||
|
||||
format = wld_CheckFormat(fp, filename);
|
||||
format = wld_check_format(fp, filename);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case formatGIF89:
|
||||
case formatGIF87:
|
||||
case FORMAT_GIT89:
|
||||
case FORMAT_GIT87:
|
||||
gfile = wld_LoadGIF(fp, filename);
|
||||
break;
|
||||
|
||||
case formatPPM:
|
||||
case FORMAT_PPM:
|
||||
gfile = wld_LoadPPM(fp, filename);
|
||||
break;
|
||||
|
||||
case formatPCX:
|
||||
case FORMAT_PCX:
|
||||
gfile = wld_loadpcx(fp, filename);
|
||||
break;
|
||||
|
||||
case formatUnknown:
|
||||
case FORMAT_UNKNOWN:
|
||||
wld_fatal_error("Unknown graphic file format.\n");
|
||||
break;
|
||||
|
||||
|
@ -48,12 +48,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_CountRectangles
|
||||
* Name: wld_count_rectangles
|
||||
* Description:
|
||||
* This function counts the number of rectangles in one plane
|
||||
************************************************************************/
|
||||
|
||||
static uint16_t wld_CountRectangles(rect_list_t * rect)
|
||||
static uint16_t wld_count_rectangles(rect_list_t * rect)
|
||||
{
|
||||
uint16_t count;
|
||||
for (count = 0; (rect); count++, rect = rect->flink);
|
||||
@ -61,12 +61,12 @@ static uint16_t wld_CountRectangles(rect_list_t * rect)
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_SaveWorldPlane
|
||||
* Name: wld_save_worldplane
|
||||
* Description:
|
||||
* This function stores the world data for one plane
|
||||
************************************************************************/
|
||||
|
||||
static uint8_t wld_SaveWorldPlane(FILE * fp, rect_list_t * rect)
|
||||
static uint8_t wld_save_worldplane(FILE * fp, rect_list_t * rect)
|
||||
{
|
||||
/* For each rectangle in the list */
|
||||
|
||||
@ -107,9 +107,9 @@ uint8_t wld_save_planes(const char *wldFile)
|
||||
|
||||
/* Create world file header */
|
||||
|
||||
fileHeader.numXRects = wld_CountRectangles(g_xplane_list.head);
|
||||
fileHeader.numYRects = wld_CountRectangles(g_yplane_list.head);
|
||||
fileHeader.numZRects = wld_CountRectangles(g_zplane_list.head);
|
||||
fileHeader.num_xrects = wld_count_rectangles(g_xplane_list.head);
|
||||
fileHeader.num_yrects = wld_count_rectangles(g_yplane_list.head);
|
||||
fileHeader.num_zrects = wld_count_rectangles(g_zplane_list.head);
|
||||
|
||||
/* Write the file header to the output file */
|
||||
|
||||
@ -122,15 +122,15 @@ uint8_t wld_save_planes(const char *wldFile)
|
||||
|
||||
else
|
||||
{
|
||||
result = wld_SaveWorldPlane(fp, g_xplane_list.head);
|
||||
result = wld_save_worldplane(fp, g_xplane_list.head);
|
||||
if (result == PLANE_SUCCESS)
|
||||
{
|
||||
result = wld_SaveWorldPlane(fp, g_yplane_list.head);
|
||||
result = wld_save_worldplane(fp, g_yplane_list.head);
|
||||
}
|
||||
|
||||
if (result == PLANE_SUCCESS)
|
||||
{
|
||||
wld_SaveWorldPlane(fp, g_zplane_list.head);
|
||||
wld_save_worldplane(fp, g_zplane_list.head);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,15 +98,15 @@ extern wld_camera_t g_initial_camera;
|
||||
* the position of the player's "feet"
|
||||
*/
|
||||
|
||||
extern wld_coord_t playerHeight;
|
||||
extern wld_coord_t g_player_height;
|
||||
|
||||
/* This is size of something that the player can step over when "walking" */
|
||||
|
||||
extern wld_coord_t walkStepHeight;
|
||||
extern wld_coord_t g_walk_stepheight;
|
||||
|
||||
/* This is size of something that the player can step over when "running" */
|
||||
|
||||
extern wld_coord_t runStepHeight;
|
||||
extern wld_coord_t g_run_stepheight;
|
||||
|
||||
/*************************************************************************
|
||||
* Global Function Prototypes
|
||||
|
Loading…
Reference in New Issue
Block a user