More name changes
This commit is contained in:
parent
4b933231f7
commit
aee656ea36
graphics/traveler/tools
libwld
wld_addplane.cwld_bitmaps.hwld_createworld.cwld_deallocateworld.cwld_discardbitmaps.cwld_discardpaltable.cwld_discardplanes.cwld_free.cwld_freegraphicfile.cwld_freetexture.cwld_graphicfile.hwld_graphicfilepixel.cwld_initializebitmaps.cwld_initializeplanes.cwld_loadbitmapfile.cwld_loadgif.cwld_loadpaltable.cwld_loadpcx.cwld_loadplanefile.cwld_loadplanes.cwld_loadppm.cwld_malloc.cwld_mem.hwld_mergeplanelists.cwld_moveplane.cwld_newgraphicfile.cwld_newplane.cwld_paltable.hwld_pcx.hwld_pcxinit.cwld_plane.hwld_readdecimal.cwld_readgraphicfile.cwld_readtexturefile.cwld_realloc.cwld_saveplanes.cwld_utils.hwld_world.h
tcledit
@ -47,12 +47,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_AddPlane
|
||||
* Name: wld_add_plane
|
||||
* Description:
|
||||
* This function adds a plane to a world plane list
|
||||
************************************************************************/
|
||||
|
||||
void wld_AddPlane(rectListType *newRect, rectHeadType *list)
|
||||
void wld_add_plane(rectListType *newRect, rectHeadType *list)
|
||||
{
|
||||
rectListType *nextRect, *prevRect;
|
||||
|
||||
|
@ -127,12 +127,12 @@ extern uint8_t groundColor;
|
||||
* Global Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
uint8_t wld_InitializeBitmaps(void);
|
||||
void wld_DiscardBitmaps(void);
|
||||
uint8_t wld_LoadBitmapFile(char *bmlfile);
|
||||
uint8_t wld_initialize_bitmaps(void);
|
||||
void wld_discard_bitmaps(void);
|
||||
uint8_t wld_load_bitmapfile(char *bmlfile);
|
||||
|
||||
void wld_FreeTexture(bitmapType *t);
|
||||
bitmapType *wld_ReadTextureFile(char *filename);
|
||||
void wld_free_texture(bitmapType *t);
|
||||
bitmapType *wld_read_texturefile(char *filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -109,11 +109,11 @@ static const char worldImagesName[] = WORLD_IMAGES;
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_CreateWorld
|
||||
* Name: wld_create_world
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_CreateWorld(char *wldFile)
|
||||
uint8_t wld_create_world(char *wldFile)
|
||||
{
|
||||
uint8_t result;
|
||||
|
||||
@ -139,7 +139,7 @@ uint8_t wld_CreateWorld(char *wldFile)
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_ManageWorldFile
|
||||
* Description: This is the guts of wld_CreateWorld. It is implemented as
|
||||
* Description: This is the guts of wld_create_world. It is implemented as
|
||||
* a separate file to simplify error handling
|
||||
************************************************************************/
|
||||
|
||||
@ -204,10 +204,10 @@ static uint8_t wld_ManageWorldFile(void)
|
||||
|
||||
/* Allocate and load the world */
|
||||
|
||||
result = wld_InitializePlanes();
|
||||
result = wld_initialize_planes();
|
||||
if (result != 0) return result;
|
||||
|
||||
result = wld_LoadPlaneFile(fileName);
|
||||
result = wld_load_planefile(fileName);
|
||||
if (result != 0) return result;
|
||||
|
||||
free_ini_string(fileName);
|
||||
@ -222,7 +222,7 @@ static uint8_t wld_ManageWorldFile(void)
|
||||
|
||||
/* Then load it into palTable. */
|
||||
|
||||
result = wld_LoadPalTable(fileName);
|
||||
result = wld_load_paltable(fileName);
|
||||
if (result != 0) return result;
|
||||
|
||||
free_ini_string(fileName);
|
||||
@ -235,10 +235,10 @@ static uint8_t wld_ManageWorldFile(void)
|
||||
|
||||
/* Then load the bitmaps */
|
||||
|
||||
result = wld_InitializeBitmaps();
|
||||
result = wld_initialize_bitmaps();
|
||||
if (result != 0) return result;
|
||||
|
||||
result = wld_LoadBitmapFile(fileName);
|
||||
result = wld_load_bitmapfile(fileName);
|
||||
free_ini_string(fileName);
|
||||
|
||||
return result;
|
||||
|
@ -48,13 +48,13 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_DeallocateWorld
|
||||
* Name: wld_deallocate_world
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
void wld_DeallocateWorld(void)
|
||||
void wld_deallocate_world(void)
|
||||
{
|
||||
wld_DiscardPlanes();
|
||||
wld_DiscardBitmaps();
|
||||
wld_DiscardPalTable();
|
||||
wld_discard_planes();
|
||||
wld_discard_bitmaps();
|
||||
wld_discard_paltable();
|
||||
}
|
||||
|
@ -53,26 +53,26 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_DiscardBitmaps
|
||||
* Name: wld_discard_bitmaps
|
||||
* Description:
|
||||
* This function deallocates the entire world.
|
||||
************************************************************************/
|
||||
|
||||
void wld_DiscardBitmaps(void)
|
||||
void wld_discard_bitmaps(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_BITMAPS; i++)
|
||||
{
|
||||
if (evenBitmaps[i])
|
||||
{
|
||||
wld_FreeTexture((void*)evenBitmaps[i]);
|
||||
wld_free_texture((void*)evenBitmaps[i]);
|
||||
evenBitmaps[i] = NULL;
|
||||
}
|
||||
|
||||
#ifndef WEDIT
|
||||
if (oddBitmaps[i])
|
||||
{
|
||||
wld_FreeTexture((void*)oddBitmaps[i]);
|
||||
wld_free_texture((void*)oddBitmaps[i]);
|
||||
oddBitmaps[i] = NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -47,18 +47,18 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_DiscardPalTable
|
||||
* Name: wld_discard_paltable
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
void wld_DiscardPalTable(void)
|
||||
void wld_discard_paltable(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NUM_ZONES; i++)
|
||||
{
|
||||
if (palTable[i])
|
||||
{
|
||||
wld_Free(palTable[i]);
|
||||
wld_free(palTable[i]);
|
||||
palTable[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ static void wld_DiscardWorldPlane(rectListType *rect)
|
||||
while (rect)
|
||||
{
|
||||
next = rect->flink;
|
||||
wld_Free((void *) rect);
|
||||
wld_free((void *) rect);
|
||||
rect = next;
|
||||
}
|
||||
}
|
||||
@ -70,12 +70,12 @@ static void wld_DiscardWorldPlane(rectListType *rect)
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_DiscardPlanes
|
||||
* Name: wld_discard_planes
|
||||
* Description:
|
||||
* This function deallocates the entire world.
|
||||
************************************************************************/
|
||||
|
||||
void wld_DiscardPlanes(void)
|
||||
void wld_discard_planes(void)
|
||||
{
|
||||
wld_DiscardWorldPlane(xPlane.head);
|
||||
xPlane.head = xPlane.tail = NULL;
|
||||
|
@ -48,11 +48,11 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_Free
|
||||
* Name: wld_free
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
void wld_Free(void *addr)
|
||||
void wld_free(void *addr)
|
||||
{
|
||||
if (addr == NULL)
|
||||
{
|
||||
|
@ -47,24 +47,24 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_FreeGraphicFile
|
||||
* Name: wld_free_graphicfile
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
void wld_FreeGraphicFile(GraphicFileType *gfile)
|
||||
void wld_free_graphicfile(GraphicFileType *gfile)
|
||||
{
|
||||
if (gfile != NULL)
|
||||
{
|
||||
if (gfile->palette != NULL)
|
||||
{
|
||||
wld_Free(gfile->palette);
|
||||
wld_free(gfile->palette);
|
||||
}
|
||||
|
||||
if (gfile->bitmap != NULL)
|
||||
{
|
||||
wld_Free(gfile->bitmap);
|
||||
wld_free(gfile->bitmap);
|
||||
}
|
||||
|
||||
wld_Free(gfile);
|
||||
wld_free(gfile);
|
||||
}
|
||||
}
|
||||
|
@ -48,12 +48,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_FreeTexture
|
||||
* Name: wld_free_texture
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
void wld_FreeTexture(bitmapType *t)
|
||||
void wld_free_texture(bitmapType *t)
|
||||
{
|
||||
if (t->bm) wld_Free(t->bm);
|
||||
wld_Free(t);
|
||||
if (t->bm) wld_free(t->bm);
|
||||
wld_free(t);
|
||||
}
|
||||
|
@ -101,10 +101,10 @@ typedef struct
|
||||
* Private Variables
|
||||
*************************************************************************/
|
||||
|
||||
GraphicFileType *wld_NewGraphicFile(void);
|
||||
void wld_FreeGraphicFile(GraphicFileType *gFile);
|
||||
RGBColor wld_GraphicFilePixel(GraphicFileType *gFile,
|
||||
GraphicFileType *wld_new_graphicfile(void);
|
||||
void wld_free_graphicfile(GraphicFileType *gFile);
|
||||
RGBColor wld_graphicfile_pixel(GraphicFileType *gFile,
|
||||
int x, int y);
|
||||
GraphicFileType *wld_ReadGraphicFile(char *filename);
|
||||
GraphicFileType *wld_readgraphic_file(char *filename);
|
||||
|
||||
#endif /* __ASTGRAPHICFILE_H */
|
||||
|
@ -50,7 +50,7 @@
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
RGBColor wld_GraphicFilePixel(GraphicFileType *gfile, int x, int y)
|
||||
RGBColor wld_graphicfile_pixel(GraphicFileType *gfile, int x, int y)
|
||||
{
|
||||
if (gfile->type == gfPaletted)
|
||||
{
|
||||
|
@ -53,11 +53,11 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_InitializeBitmaps
|
||||
* Name: wld_initialize_bitmaps
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_InitializeBitmaps(void)
|
||||
uint8_t wld_initialize_bitmaps(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_BITMAPS; i++)
|
||||
|
@ -48,11 +48,11 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_InitializePlanes
|
||||
* Name: wld_initialize_planes
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_InitializePlanes(void)
|
||||
uint8_t wld_initialize_planes(void)
|
||||
{
|
||||
xPlane.head = xPlane.tail = NULL;
|
||||
yPlane.head = yPlane.tail = NULL;
|
||||
|
@ -70,18 +70,18 @@ static uint8_t wld_LoadBitmaps(FILE *fp)
|
||||
|
||||
/* Discard any bitmaps that we may currently have buffered */
|
||||
|
||||
wld_DiscardBitmaps();
|
||||
wld_discard_bitmaps();
|
||||
|
||||
/* Get the number of bitmaps in the bitmap file */
|
||||
|
||||
numBitmaps = wld_ReadDecimal(fp);
|
||||
numBitmaps = wld_read_decimal(fp);
|
||||
if (numBitmaps >= MAX_BITMAPS)
|
||||
return BMAP_TOO_MANY;
|
||||
|
||||
/* Read the colors used to rend the sky and ground */
|
||||
|
||||
skyColor = wld_ReadDecimal(fp);
|
||||
groundColor = wld_ReadDecimal(fp);
|
||||
skyColor = wld_read_decimal(fp);
|
||||
groundColor = wld_read_decimal(fp);
|
||||
|
||||
#if MSWINDOWS
|
||||
/* Load the textures -- Note that the first texture will be used
|
||||
@ -106,7 +106,7 @@ static uint8_t wld_LoadBitmaps(FILE *fp)
|
||||
#if MSWINDOWS
|
||||
/* Setup to load the PCX bitmap from the file for the event bitmap */
|
||||
|
||||
result = wld_PCXInit(&workPCX, BITMAP_HEIGHT, BITMAP_WIDTH,
|
||||
result = wld_pcx_init(&workPCX, BITMAP_HEIGHT, BITMAP_WIDTH,
|
||||
palette, NULL);
|
||||
if (result) return result;
|
||||
|
||||
@ -119,7 +119,7 @@ static uint8_t wld_LoadBitmaps(FILE *fp)
|
||||
|
||||
/* Load the PCX bitmap from the file for the event bitmap */
|
||||
|
||||
result = wld_LoadPCX(graphicsFileName, &workPCX);
|
||||
result = wld_loadpcx(graphicsFileName, &workPCX);
|
||||
if (result) return result;
|
||||
|
||||
/* Don't bother to load the palette on the rest of the textures --
|
||||
@ -128,7 +128,7 @@ static uint8_t wld_LoadBitmaps(FILE *fp)
|
||||
|
||||
palette = NULL;
|
||||
#else
|
||||
evenBitmaps[bMapIndex] = wld_ReadTextureFile(graphicsFileName);
|
||||
evenBitmaps[bMapIndex] = wld_read_texturefile(graphicsFileName);
|
||||
if (!evenBitmaps[bMapIndex]) return BMAP_BML_READ_ERROR;
|
||||
#endif
|
||||
|
||||
@ -142,7 +142,7 @@ static uint8_t wld_LoadBitmaps(FILE *fp)
|
||||
#if MSWINDOWS
|
||||
/* Setup to load the PCX bitmap from the file for the odd bitmap */
|
||||
|
||||
result = wld_PCXInit(&workPCX, BITMAP_HEIGHT, BITMAP_WIDTH,
|
||||
result = wld_pcx_init(&workPCX, BITMAP_HEIGHT, BITMAP_WIDTH,
|
||||
palette, NULL);
|
||||
if (result) return result;
|
||||
|
||||
@ -155,9 +155,9 @@ static uint8_t wld_LoadBitmaps(FILE *fp)
|
||||
|
||||
/* Load the PCX bitmap from the file for the odd bitmap */
|
||||
|
||||
result = wld_LoadPCX(graphicsFileName, &workPCX);
|
||||
result = wld_loadpcx(graphicsFileName, &workPCX);
|
||||
#else
|
||||
oddBitmaps[bMapIndex] = wld_ReadTextureFile(graphicsFileName);
|
||||
oddBitmaps[bMapIndex] = wld_read_texturefile(graphicsFileName);
|
||||
if (!oddBitmaps[bMapIndex]) return BMAP_BML_READ_ERROR;
|
||||
#endif
|
||||
#endif
|
||||
@ -231,12 +231,12 @@ static boolean wld_ReadFileName(FILE *fp, char *fileName)
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadBitmapFile
|
||||
* Name: wld_load_bitmapfile
|
||||
* Description:
|
||||
* This function opens the input file and loads the world data from it
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_LoadBitmapFile(char *bmlFile)
|
||||
uint8_t wld_load_bitmapfile(char *bmlFile)
|
||||
{
|
||||
FILE *fp;
|
||||
uint8_t result;
|
||||
@ -249,7 +249,7 @@ uint8_t wld_LoadBitmapFile(char *bmlFile)
|
||||
/* Load all of the bitmaps */
|
||||
|
||||
result = wld_LoadBitmaps(fp);
|
||||
if (result) wld_DiscardBitmaps();
|
||||
if (result) wld_discard_bitmaps();
|
||||
|
||||
/* We are all done with the file, so close it */
|
||||
|
||||
|
@ -346,15 +346,15 @@ GraphicFileType *wld_LoadGIF(FILE *fp, char *fname)
|
||||
fprintf(stderr, "Reading a %d by %d %sinterlaced image...",
|
||||
Width, Height, (Interlace) ? "" : "non-");
|
||||
|
||||
gfile = wld_NewGraphicFile();
|
||||
gfile->palette = (RGBColor*)wld_Malloc(sizeof(RGBColor) * ColorMapSize);
|
||||
gfile = wld_new_graphicfile();
|
||||
gfile->palette = (RGBColor*)wld_malloc(sizeof(RGBColor) * ColorMapSize);
|
||||
for (i = 0; i < ColorMapSize; i++)
|
||||
{
|
||||
gfile->palette[i].red = Red[i];
|
||||
gfile->palette[i].green = Green[i];
|
||||
gfile->palette[i].blue = Blue[i];
|
||||
}
|
||||
gfile->bitmap = (uint8_t*)wld_Malloc(Width * Height);
|
||||
gfile->bitmap = (uint8_t*)wld_malloc(Width * Height);
|
||||
gfile->type = gfPaletted;
|
||||
gfile->width = Width;
|
||||
gfile->height = Height;
|
||||
|
@ -107,7 +107,7 @@ static void wld_AllocatePalTable(uint32 palTabEntrySize)
|
||||
|
||||
for (i = 0; i < NUM_ZONES; i++)
|
||||
{
|
||||
palTable[i] = (trv_pixel_t*)wld_Malloc(palTabEntrySize*sizeof(trv_pixel_t));
|
||||
palTable[i] = (trv_pixel_t*)wld_malloc(palTabEntrySize*sizeof(trv_pixel_t));
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,12 +116,12 @@ static void wld_AllocatePalTable(uint32 palTabEntrySize)
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadPalTable
|
||||
* Name: wld_load_paltable
|
||||
* Description:
|
||||
* This function loads the palTable from the specified file
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_LoadPalTable(char *file)
|
||||
uint8_t wld_load_paltable(char *file)
|
||||
{
|
||||
#if (!MSWINDOWS)
|
||||
trv_pixel_t *palPtr;
|
||||
@ -194,7 +194,7 @@ uint8_t wld_LoadPalTable(char *file)
|
||||
|
||||
/* Read the number of ranges from the file */
|
||||
|
||||
numRanges = wld_ReadDecimal(fp);
|
||||
numRanges = wld_read_decimal(fp);
|
||||
if (numRanges > MAX_PAL_RANGES)
|
||||
{
|
||||
fclose(fp);
|
||||
@ -205,9 +205,9 @@ uint8_t wld_LoadPalTable(char *file)
|
||||
|
||||
for (i = 0; i < numRanges; i++)
|
||||
{
|
||||
ranges[i].firstColor = wld_ReadDecimal(fp);
|
||||
ranges[i].colorRange = wld_ReadDecimal(fp);
|
||||
ranges[i].clipColor = wld_ReadDecimal(fp);
|
||||
ranges[i].firstColor = wld_read_decimal(fp);
|
||||
ranges[i].colorRange = wld_read_decimal(fp);
|
||||
ranges[i].clipColor = wld_read_decimal(fp);
|
||||
}
|
||||
|
||||
/* We are now done with the input file */
|
||||
@ -339,7 +339,7 @@ uint8_t wld_LoadPalTable(char *file)
|
||||
{
|
||||
/* Read the data into palTable */
|
||||
|
||||
palPtr[palIndex] = wld_ReadDecimal(fp);
|
||||
palPtr[palIndex] = wld_read_decimal(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@
|
||||
* Private Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
static void wld_LoadPCXHeader(FILE *fp, pcxHeader *header);
|
||||
static void wld_LoadPCXData(FILE *fp, sint32 imagSize, uint8_t *imageBuffer);
|
||||
static void wld_LoadPCXPalette(FILE *fp, RGBColor *palette);
|
||||
static void wld_loadpcxHeader(FILE *fp, pcxHeader *header);
|
||||
static void wld_loadpcxData(FILE *fp, sint32 imagSize, uint8_t *imageBuffer);
|
||||
static void wld_loadpcxPalette(FILE *fp, RGBColor *palette);
|
||||
|
||||
/*************************************************************************
|
||||
* Global Variables
|
||||
@ -81,7 +81,7 @@ static void wld_LoadPCXPalette(FILE *fp, RGBColor *palette);
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadPCX
|
||||
* Name: wld_loadpcx
|
||||
* Description:
|
||||
* This function loads a pcx file into a picture structure, the actual image
|
||||
* data for the pcx file is decompressed and expanded into a secondary buffer
|
||||
@ -90,7 +90,7 @@ static void wld_LoadPCXPalette(FILE *fp, RGBColor *palette);
|
||||
************************************************************************/
|
||||
|
||||
#if MSWINDOWS
|
||||
uint8_t wld_LoadPCX(char *filename, pcxPicturePtr image)
|
||||
uint8_t wld_loadpcx(char *filename, pcxPicturePtr image)
|
||||
{
|
||||
FILE *fp, *fopen();
|
||||
uint16_t imageWidth, imageHeight;
|
||||
@ -103,7 +103,7 @@ uint8_t wld_LoadPCX(char *filename, pcxPicturePtr image)
|
||||
|
||||
/* Load the PCX Header */
|
||||
|
||||
wld_LoadPCXHeader(fp, &image->header);
|
||||
wld_loadpcxHeader(fp, &image->header);
|
||||
|
||||
/* Load the PCX data */
|
||||
|
||||
@ -112,21 +112,21 @@ 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_loadpcxData(fp, imageSize, image->buffer);
|
||||
}
|
||||
|
||||
/* Load the PCX palette */
|
||||
|
||||
if (image->palette)
|
||||
{
|
||||
wld_LoadPCXPalette(fp, &image->palette);
|
||||
wld_loadpcxPalette(fp, &image->palette);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return PCX_SUCCESS;
|
||||
}
|
||||
#else
|
||||
GraphicFileType *wld_LoadPCX(FILE *fp, char *filename)
|
||||
GraphicFileType *wld_loadpcx(FILE *fp, char *filename)
|
||||
{
|
||||
pcxHeader header;
|
||||
trv_pixel_t *buffer;
|
||||
@ -137,30 +137,30 @@ GraphicFileType *wld_LoadPCX(FILE *fp, char *filename)
|
||||
|
||||
/* Load the PCX Header */
|
||||
|
||||
wld_LoadPCXHeader(fp, &header);
|
||||
wld_loadpcxHeader(fp, &header);
|
||||
|
||||
/* Allocate Space to hold the image data */
|
||||
|
||||
imageWidth = header.width - header.x + 1;
|
||||
imageHeight = header.height - header.y + 1;
|
||||
imageSize = imageHeight * imageWidth * sizeof(trv_pixel_t);
|
||||
buffer = (trv_pixel_t*)wld_Malloc(imageSize + 1);
|
||||
buffer = (trv_pixel_t*)wld_malloc(imageSize + 1);
|
||||
|
||||
/* Load the PCX data into the buffer */
|
||||
|
||||
wld_LoadPCXData(fp, imageSize, (uint8_t*)buffer);
|
||||
wld_loadpcxData(fp, imageSize, (uint8_t*)buffer);
|
||||
|
||||
/* Allocate space to hold the PCX palette */
|
||||
|
||||
palette = (RGBColor*)wld_Malloc(sizeof(RGBColor) * 256);
|
||||
palette = (RGBColor*)wld_malloc(sizeof(RGBColor) * 256);
|
||||
|
||||
/* Load the PCX palette */
|
||||
|
||||
wld_LoadPCXPalette(fp, palette);
|
||||
wld_loadpcxPalette(fp, palette);
|
||||
|
||||
/* Now save the resulting data in a GraphicFileType structure */
|
||||
|
||||
gFile = wld_NewGraphicFile();
|
||||
gFile = wld_new_graphicfile();
|
||||
gFile->type = gfPaletted;
|
||||
gFile->palette = palette;
|
||||
gFile->width = imageWidth;
|
||||
@ -172,11 +172,11 @@ GraphicFileType *wld_LoadPCX(FILE *fp, char *filename)
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadPCXHeader
|
||||
* Name: wld_loadpcxHeader
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
static void wld_LoadPCXHeader(FILE *fp, pcxHeader *header)
|
||||
static void wld_loadpcxHeader(FILE *fp, pcxHeader *header)
|
||||
{
|
||||
uint8_t *tempBuffer;
|
||||
int i;
|
||||
@ -192,11 +192,11 @@ static void wld_LoadPCXHeader(FILE *fp, pcxHeader *header)
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadPCXData
|
||||
* Name: wld_loadpcxData
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
static void wld_LoadPCXData(FILE *fp, sint32 imageSize, uint8_t *imageBuffer)
|
||||
static void wld_loadpcxData(FILE *fp, sint32 imageSize, uint8_t *imageBuffer)
|
||||
{
|
||||
uint32 count;
|
||||
int16_t numBytes;
|
||||
@ -238,11 +238,11 @@ static void wld_LoadPCXData(FILE *fp, sint32 imageSize, uint8_t *imageBuffer)
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadPCXPalette
|
||||
* Name: wld_loadpcxPalette
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
static void wld_LoadPCXPalette(FILE *fp, RGBColor *palette)
|
||||
static void wld_loadpcxPalette(FILE *fp, RGBColor *palette)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -50,12 +50,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadPlaneFile
|
||||
* Name: wld_load_planefile
|
||||
* Description:
|
||||
* This function opens the input file and loads the world data from it
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_LoadPlaneFile(const char *wldFile)
|
||||
uint8_t wld_load_planefile(const char *wldFile)
|
||||
{
|
||||
FILE *fp;
|
||||
uint8_t result;
|
||||
@ -72,7 +72,7 @@ uint8_t wld_LoadPlaneFile(const char *wldFile)
|
||||
|
||||
/* Load the world data from the file */
|
||||
|
||||
result = wld_LoadPlanes(fp);
|
||||
result = wld_load_planes(fp);
|
||||
|
||||
/* Close the file */
|
||||
|
||||
|
@ -62,7 +62,7 @@ static uint8_t wld_LoadWorldPlane(FILE *fp, rectHeadType *list, uint8_t numRects
|
||||
{
|
||||
/* Allocate space for the next rectangle */
|
||||
|
||||
rect = wld_NewPlane();
|
||||
rect = wld_new_plane();
|
||||
if (!rect) return PLANE_ALLOCATION_FAILURE;
|
||||
|
||||
/* Read the next rectangle from the input file */
|
||||
@ -78,7 +78,7 @@ static uint8_t wld_LoadWorldPlane(FILE *fp, rectHeadType *list, uint8_t numRects
|
||||
|
||||
/* Put the new rectangle into the plane list */
|
||||
|
||||
wld_AddPlane(rect, list);
|
||||
wld_add_plane(rect, list);
|
||||
}
|
||||
|
||||
return PLANE_SUCCESS;
|
||||
@ -89,12 +89,12 @@ static uint8_t wld_LoadWorldPlane(FILE *fp, rectHeadType *list, uint8_t numRects
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_LoadPlanes
|
||||
* Name: wld_load_planes
|
||||
* Description:
|
||||
* This function loads the world data from the opened file
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_LoadPlanes(FILE *fp)
|
||||
uint8_t wld_load_planes(FILE *fp)
|
||||
{
|
||||
planeFileHeaderType fileHeader;
|
||||
uint8_t result;
|
||||
|
@ -127,12 +127,12 @@ GraphicFileType *wld_LoadPPM(FILE *fp, char *filename)
|
||||
wld_fatal_error("%s: bad ppm file.", filename);
|
||||
}
|
||||
|
||||
gfile = wld_NewGraphicFile();
|
||||
gfile = wld_new_graphicfile();
|
||||
gfile->type = gfTrueColor;
|
||||
gfile->palette = NULL;
|
||||
gfile->width = width;
|
||||
gfile->height = height;
|
||||
gfile->bitmap = (uint8_t*)wld_Malloc(height * width * 3);
|
||||
gfile->bitmap = (uint8_t*)wld_malloc(height * width * 3);
|
||||
|
||||
if (fread(gfile->bitmap, height * width * 3, 1, fp) != 1)
|
||||
{
|
||||
|
@ -48,18 +48,18 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_Malloc
|
||||
* Name: wld_malloc
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
void *wld_Malloc(size_t size)
|
||||
void *wld_malloc(size_t size)
|
||||
{
|
||||
void *new;
|
||||
|
||||
new = malloc(size);
|
||||
if (new == NULL)
|
||||
{
|
||||
wld_fatal_error("out of memory (wld_Malloc %x bytes)", size);
|
||||
wld_fatal_error("out of memory (wld_malloc %x bytes)", size);
|
||||
}
|
||||
return new;
|
||||
}
|
||||
|
@ -46,8 +46,8 @@
|
||||
* Public Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
void *wld_Malloc(size_t size);
|
||||
void *wld_Realloc(void *v, size_t size);
|
||||
void wld_Free(void *v);
|
||||
void *wld_malloc(size_t size);
|
||||
void *wld_realloc(void *v, size_t size);
|
||||
void wld_free(void *v);
|
||||
|
||||
#endif /* __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_MEM_H */
|
||||
|
@ -47,12 +47,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_MergePlaneLists
|
||||
* Name: wld_merge_planelists
|
||||
* Description:
|
||||
* This function concatenates two world plane lists
|
||||
************************************************************************/
|
||||
|
||||
void wld_MergePlaneLists(rectHeadType *outList, rectHeadType *inList)
|
||||
void wld_merge_planelists(rectHeadType *outList, rectHeadType *inList)
|
||||
{
|
||||
rectListType *inRect, *nextInRect;
|
||||
rectListType *outRect, *prevRect;
|
||||
|
@ -73,5 +73,5 @@ void wld_move_plane(rectListType *rect, rectHeadType *destList,
|
||||
|
||||
/* Then add the rect to the specified list */
|
||||
|
||||
wld_AddPlane(rect, destList);
|
||||
wld_add_plane(rect, destList);
|
||||
}
|
||||
|
@ -51,9 +51,9 @@
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
GraphicFileType *wld_NewGraphicFile( void )
|
||||
GraphicFileType *wld_new_graphicfile( void )
|
||||
{
|
||||
GraphicFileType *gf = (GraphicFileType*)wld_Malloc(sizeof(GraphicFileType));
|
||||
GraphicFileType *gf = (GraphicFileType*)wld_malloc(sizeof(GraphicFileType));
|
||||
|
||||
gf->transparent_entry = -1;
|
||||
|
||||
|
@ -48,12 +48,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_NewPlane
|
||||
* Name: wld_new_plane
|
||||
* Description:
|
||||
* This function allocates memory for a new plane rectangle
|
||||
************************************************************************/
|
||||
|
||||
rectListType *wld_NewPlane(void)
|
||||
rectListType *wld_new_plane(void)
|
||||
{
|
||||
rectListType *rect;
|
||||
|
||||
@ -70,7 +70,7 @@ rectListType *wld_NewPlane(void)
|
||||
{
|
||||
/* Nothing on the free list. Allocate a new one */
|
||||
|
||||
rect = (rectListType*)wld_Malloc(sizeof(rectListType));
|
||||
rect = (rectListType*)wld_malloc(sizeof(rectListType));
|
||||
}
|
||||
|
||||
return rect;
|
||||
|
@ -91,8 +91,8 @@ extern trv_pixel_t *palTable[NUM_ZONES];
|
||||
* Pulblic Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
uint8_t wld_LoadPalTable(char *file);
|
||||
void wld_DiscardPalTable(void);
|
||||
uint8_t wld_load_paltable(char *file);
|
||||
void wld_discard_paltable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -97,11 +97,11 @@ typedef struct pcxPictureType
|
||||
*************************************************************************/
|
||||
|
||||
#if MSWINDOWS
|
||||
uint8_t wld_PCXInit(pcxPicturePtr image, uint16_t height, uint16_t width,
|
||||
uint8_t wld_pcx_init(pcxPicturePtr image, uint16_t height, uint16_t width,
|
||||
RGBColor *palette, uint8_t *buffer);
|
||||
uint8_t wld_LoadPCX(char *filename, pcxPicturePtr image);
|
||||
uint8_t wld_loadpcx(char *filename, pcxPicturePtr image);
|
||||
#else
|
||||
GraphicFileType *wld_LoadPCX(FILE *fp, char *filename);
|
||||
GraphicFileType *wld_loadpcx(FILE *fp, char *filename);
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -51,12 +51,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_PCXInit
|
||||
* Name: wld_pcx_init
|
||||
* Description:
|
||||
* This function allocates the buffer region needed to load a pcx file
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_PCXInit(pcxPicturePtr image, uint16_t height, uint16_t width,
|
||||
uint8_t wld_pcx_init(pcxPicturePtr image, uint16_t height, uint16_t width,
|
||||
RGBColor *palette, uint8_t *buffer)
|
||||
{
|
||||
image->palette = palette;
|
||||
@ -67,7 +67,7 @@ uint8_t wld_PCXInit(pcxPicturePtr image, uint16_t height, uint16_t width,
|
||||
}
|
||||
else
|
||||
{
|
||||
image->buffer = (uint8_t*)wld_Malloc(height * width + 1);
|
||||
image->buffer = (uint8_t*)wld_malloc(height * width + 1);
|
||||
}
|
||||
|
||||
if (!image->buffer)
|
||||
|
@ -39,7 +39,7 @@
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_PLANE_H
|
||||
#define ___APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_PLANE_H
|
||||
#define __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_PLANE_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -166,15 +166,15 @@ extern rectListType *freeList;
|
||||
* Public Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
extern uint8_t wld_InitializePlanes(void);
|
||||
extern void wld_DiscardPlanes(void);
|
||||
extern uint8_t wld_LoadPlaneFile(const char *wldfile);
|
||||
extern uint8_t wld_LoadPlanes(FILE *fp);
|
||||
extern uint8_t wld_SavePlanes(const char *wldFile);
|
||||
extern rectListType *wld_NewPlane(void);
|
||||
extern void wld_AddPlane(rectListType *rect,
|
||||
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 rectListType *wld_new_plane(void);
|
||||
extern void wld_add_plane(rectListType *rect,
|
||||
rectHeadType *list);
|
||||
extern void wld_MergePlaneLists(rectHeadType *outList,
|
||||
extern void wld_merge_planelists(rectHeadType *outList,
|
||||
rectHeadType *inList);
|
||||
extern void wld_remove_plane(rectListType *rect,
|
||||
rectHeadType *list);
|
||||
@ -188,4 +188,4 @@ extern rectListType *wld_find_plane(coord_t h, coord_t v, coord_t plane,
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ___APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_PLANE_H */
|
||||
#endif /* __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_PLANE_H */
|
||||
|
@ -46,12 +46,12 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_ReadDecimal
|
||||
* Name: wld_read_decimal
|
||||
* Description:
|
||||
* Read a decimal number from the steam fp
|
||||
************************************************************************/
|
||||
|
||||
int16_t wld_ReadDecimal(FILE *fp)
|
||||
int16_t wld_read_decimal(FILE *fp)
|
||||
{
|
||||
int16_t value = 0;
|
||||
boolean negative = FALSE;
|
||||
|
@ -130,7 +130,7 @@ static GraphicFileFormatType wld_CheckFormat(FILE *fp, char *filename)
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
GraphicFileType *wld_ReadGraphicFile(char *filename)
|
||||
GraphicFileType *wld_readgraphic_file(char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
GraphicFileFormatType format;
|
||||
@ -156,7 +156,7 @@ GraphicFileType *wld_ReadGraphicFile(char *filename)
|
||||
break;
|
||||
|
||||
case formatPCX:
|
||||
gfile = wld_LoadPCX(fp, filename);
|
||||
gfile = wld_loadpcx(fp, filename);
|
||||
break;
|
||||
|
||||
case formatUnknown:
|
||||
|
@ -75,8 +75,8 @@ static bitmapType *wld_NewTexture(uint16_t width, uint16_t height)
|
||||
if (height <= 0 || width <= 0)
|
||||
wld_fatal_error("wld_NewTexture: bad texture dimensions");
|
||||
|
||||
t = (bitmapType*)wld_Malloc(sizeof(bitmapType));
|
||||
t->bm = (trv_pixel_t*)wld_Malloc(height * width * sizeof(trv_pixel_t));
|
||||
t = (bitmapType*)wld_malloc(sizeof(bitmapType));
|
||||
t->bm = (trv_pixel_t*)wld_malloc(height * width * sizeof(trv_pixel_t));
|
||||
|
||||
t->w = width;
|
||||
t->h = height;
|
||||
@ -125,7 +125,7 @@ static void wld_QuantizeTexture(GraphicFileType *gFile, bitmapType *t)
|
||||
{
|
||||
for (y = gFile->height - 1; y >= 0; y--)
|
||||
{
|
||||
pixel = wld_GraphicFilePixel(gFile, x, y);
|
||||
pixel = wld_graphicfile_pixel(gFile, x, y);
|
||||
*destPixel++ = wld_Rgb2Pixel(&pixel);
|
||||
}
|
||||
}
|
||||
@ -140,12 +140,12 @@ static void wld_QuantizeTexture(GraphicFileType *gFile, bitmapType *t)
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
bitmapType *wld_ReadTextureFile(char *filename)
|
||||
bitmapType *wld_read_texturefile(char *filename)
|
||||
{
|
||||
GraphicFileType *gFile;
|
||||
bitmapType *t;
|
||||
|
||||
gFile = wld_ReadGraphicFile(filename);
|
||||
gFile = wld_readgraphic_file(filename);
|
||||
if (gFile == NULL)
|
||||
wld_fatal_error("Error reading texture %s.", filename);
|
||||
|
||||
@ -160,7 +160,7 @@ bitmapType *wld_ReadTextureFile(char *filename)
|
||||
t = wld_NewTexture(gFile->width, gFile->height);
|
||||
wld_QuantizeTexture(gFile, t);
|
||||
|
||||
wld_FreeGraphicFile(gFile);
|
||||
wld_free_graphicfile(gFile);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
@ -48,11 +48,11 @@
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_Realloc
|
||||
* Name: wld_realloc
|
||||
* Description:
|
||||
************************************************************************/
|
||||
|
||||
void *wld_Realloc(void *addr, size_t size)
|
||||
void *wld_realloc(void *addr, size_t size)
|
||||
{
|
||||
void *new;
|
||||
|
||||
|
@ -87,12 +87,12 @@ static uint8_t wld_SaveWorldPlane(FILE *fp, rectListType *rect)
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* Name: wld_SavePlanes
|
||||
* Name: wld_save_planes
|
||||
* Description:
|
||||
* This function stores the world data into the specified file
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_SavePlanes(const char *wldFile)
|
||||
uint8_t wld_save_planes(const char *wldFile)
|
||||
{
|
||||
FILE *fp;
|
||||
planeFileHeaderType fileHeader;
|
||||
|
@ -47,7 +47,7 @@
|
||||
* Global Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
int16_t wld_ReadDecimal(FILE *fp);
|
||||
int16_t wld_read_decimal(FILE *fp);
|
||||
void wld_fatal_error(char *message, ...);
|
||||
|
||||
#endif /* __APPS_GRAPHICS_TRAVELER_TOOSL_LIBWLD_WLD_UTILS_H */
|
||||
|
@ -112,8 +112,8 @@ extern coord_t runStepHeight;
|
||||
* Global Function Prototypes
|
||||
*************************************************************************/
|
||||
|
||||
uint8_t wld_CreateWorld(FAR char *mapfile);
|
||||
void wld_DeallocateWorld(void);
|
||||
uint8_t wld_create_world(FAR char *mapfile);
|
||||
void wld_deallocate_world(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <debug.h>
|
||||
@ -56,33 +57,10 @@
|
||||
#include "wld_bitmaps.h"
|
||||
#include "wld_plane.h"
|
||||
#include "wld_utils.h"
|
||||
#include "x11edit.h"
|
||||
#include "tcl_x11graphics.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void x11_CreateWindow(tcl_window_t *w);
|
||||
static void x11_LoadPalette(tcl_window_t *w);
|
||||
static boolean x11_AllocateColors(tcl_window_t *w, Colormap colormap);
|
||||
static void x11_MapSharedMemory(tcl_window_t *w, int depth);
|
||||
static void x11_UnMapSharedMemory(tcl_window_t *w);
|
||||
static void x11_UnMapAllSharedMemory(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static GC gc;
|
||||
@ -94,50 +72,26 @@ static int shmCheckPoint = 0;
|
||||
static int useShm;
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_InitGraphics
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
void x11_InitGraphics(tcl_window_t *w)
|
||||
{
|
||||
XWindowAttributes windowAttributes;
|
||||
|
||||
/* Create the X11 window */
|
||||
|
||||
x11_CreateWindow(w);
|
||||
|
||||
/* Determine the supported pixel depth of the current window */
|
||||
|
||||
XGetWindowAttributes(w->display, DefaultRootWindow(w->display),
|
||||
&windowAttributes);
|
||||
|
||||
printf("Pixel depth is %d bits\n", windowAttributes.depth);
|
||||
if (windowAttributes.depth != 24)
|
||||
{
|
||||
wld_fatal_error("Unsupported pixel depth: %d", windowAttributes.depth);
|
||||
}
|
||||
|
||||
x11_LoadPalette(w);
|
||||
x11_MapSharedMemory(w, windowAttributes.depth);
|
||||
}
|
||||
static void x11_create_window(tcl_window_t *w);
|
||||
static void x11_load_palette(tcl_window_t *w);
|
||||
static bool x11_allocate_colors(tcl_window_t *w, Colormap colormap);
|
||||
static void x11_map_sharedmemory(tcl_window_t *w, int depth);
|
||||
static void x11_unmap_sharedmemory(tcl_window_t *w);
|
||||
static void x11_unmap_all_sharedmemory(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_EndGraphics
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
void x11_EndGraphics(tcl_window_t *w)
|
||||
{
|
||||
x11_UnMapAllSharedMemory();
|
||||
XCloseDisplay(w->display);
|
||||
}
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_CreateWindow
|
||||
* Name: x11_create_window
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
static void x11_CreateWindow(tcl_window_t *w)
|
||||
static void x11_create_window(tcl_window_t *w)
|
||||
{
|
||||
XGCValues gcValues;
|
||||
char *argv[2] = { "xast", NULL };
|
||||
@ -175,18 +129,18 @@ static void x11_CreateWindow(tcl_window_t *w)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_LoadPalette
|
||||
* Name: x11_load_palette
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
static void x11_LoadPalette(tcl_window_t *w)
|
||||
static void x11_load_palette(tcl_window_t *w)
|
||||
{
|
||||
Colormap cMap;
|
||||
|
||||
cMap = DefaultColormap(w->display, w->screen);
|
||||
printf("Using Default Colormap: ");
|
||||
|
||||
if (!astAllocateColors(w, cMap))
|
||||
if (!x11_allocate_colors(w, cMap))
|
||||
{
|
||||
printf("failed\nCreating Colormap: ");
|
||||
|
||||
@ -196,7 +150,7 @@ static void x11_LoadPalette(tcl_window_t *w)
|
||||
DefaultVisual(w->display, w->screen),
|
||||
AllocNone);
|
||||
|
||||
if (!astAllocateColors(w, cMap))
|
||||
if (!x11_allocate_colors(w, cMap))
|
||||
{
|
||||
printf("failed\n");
|
||||
wld_fatal_error("Unable to allocate enough color cells.");
|
||||
@ -208,11 +162,11 @@ static void x11_LoadPalette(tcl_window_t *w)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_AllocateColors
|
||||
* Name: x11_allocate_colors
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
static boolean x11_AllocateColors(tcl_window_t *w, Colormap colormap)
|
||||
static bool x11_allocate_colors(tcl_window_t *w, Colormap colormap)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -297,20 +251,20 @@ static int untrapErrors(Display *display)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_MapSharedMemory
|
||||
* Name: x11_map_sharedmemory
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
static void x11_MapSharedMemory(tcl_window_t *w, int depth)
|
||||
static void x11_map_sharedmemory(tcl_window_t *w, int depth)
|
||||
{
|
||||
#ifndef NO_XSHM
|
||||
Status result;
|
||||
#endif
|
||||
|
||||
shmCheckPoint = 0;
|
||||
x11_UnMapSharedMemory(w);
|
||||
x11_unmap_sharedmemory(w);
|
||||
|
||||
if (!shmCheckPoint) atexit(astUnMapAllSharedMemory);
|
||||
if (!shmCheckPoint) atexit(x11_unmap_all_sharedmemory);
|
||||
shmCheckPoint = 1;
|
||||
|
||||
useShm = 0;
|
||||
@ -329,7 +283,7 @@ static void x11_MapSharedMemory(tcl_window_t *w, int depth)
|
||||
|
||||
if (untrapErrors(w->display))
|
||||
{
|
||||
x11_UnMapSharedMemory(w);
|
||||
x11_unmap_sharedmemory(w);
|
||||
goto shmerror;
|
||||
}
|
||||
|
||||
@ -344,7 +298,7 @@ static void x11_MapSharedMemory(tcl_window_t *w, int depth)
|
||||
IPC_CREAT | 0777);
|
||||
if (xshminfo.shmid < 0)
|
||||
{
|
||||
x11_UnMapSharedMemory(w);
|
||||
x11_unmap_sharedmemory(w);
|
||||
goto shmerror;
|
||||
}
|
||||
shmCheckPoint++;
|
||||
@ -352,7 +306,7 @@ static void x11_MapSharedMemory(tcl_window_t *w, int depth)
|
||||
w->image->data = (char *) shmat(xshminfo.shmid, 0, 0);
|
||||
if (image->data == ((char *) -1))
|
||||
{
|
||||
x11_UnMapSharedMemory(w);
|
||||
x11_unmap_sharedmemory(w);
|
||||
goto shmerror;
|
||||
}
|
||||
shmCheckPoint++;
|
||||
@ -364,7 +318,7 @@ static void x11_MapSharedMemory(tcl_window_t *w, int depth)
|
||||
result = XShmAttach(w->display, &xshminfo);
|
||||
if (untrapErrors(w->display) || !result)
|
||||
{
|
||||
x11_UnMapSharedMemory(w);
|
||||
x11_unmap_sharedmemory(w);
|
||||
goto shmerror;
|
||||
}
|
||||
|
||||
@ -380,7 +334,7 @@ static void x11_MapSharedMemory(tcl_window_t *w, int depth)
|
||||
useShm = 0;
|
||||
|
||||
w->frameBuffer = (dev_pixel_t*)
|
||||
x11_Malloc(w->width * w->height * sizeof(dev_pixel_t));
|
||||
wld_malloc(w->width * w->height * sizeof(dev_pixel_t));
|
||||
|
||||
w->image = XCreateImage(w->display,
|
||||
DefaultVisual(w->display, w->screen),
|
||||
@ -395,16 +349,17 @@ static void x11_MapSharedMemory(tcl_window_t *w, int depth)
|
||||
{
|
||||
wld_fatal_error("Unable to create image.");
|
||||
}
|
||||
|
||||
shmCheckPoint++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_UnMapSharedMemory
|
||||
* Name: x11_unmap_sharedmemory
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
static void x11_UnMapSharedMemory(tcl_window_t *w)
|
||||
static void x11_unmap_sharedmemory(tcl_window_t *w)
|
||||
{
|
||||
#ifndef NO_XSHM
|
||||
if (shmCheckPoint > 4)
|
||||
@ -428,7 +383,7 @@ static void x11_UnMapSharedMemory(tcl_window_t *w)
|
||||
XDestroyImage(w->image);
|
||||
if (!useShm)
|
||||
{
|
||||
x11_Free(w->frameBuffer);
|
||||
wld_free(w->frameBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,17 +394,17 @@ static void x11_UnMapSharedMemory(tcl_window_t *w)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_UnMapSharedMemory
|
||||
* Name: x11_unmap_sharedmemory
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
static void x11_UnMapAllSharedMemory(void)
|
||||
static void x11_unmap_all_sharedmemory(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_PLANES; i++)
|
||||
{
|
||||
x11_UnMapSharedMemory(&windows[i]);
|
||||
x11_unmap_sharedmemory(&windows[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,3 +429,46 @@ void x11_UpdateScreen(tcl_window_t *w)
|
||||
}
|
||||
XSync(w->display, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_InitGraphics
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
void x11_InitGraphics(tcl_window_t *w)
|
||||
{
|
||||
XWindowAttributes windowAttributes;
|
||||
|
||||
/* Create the X11 window */
|
||||
|
||||
x11_create_window(w);
|
||||
|
||||
/* Determine the supported pixel depth of the current window */
|
||||
|
||||
XGetWindowAttributes(w->display, DefaultRootWindow(w->display),
|
||||
&windowAttributes);
|
||||
|
||||
printf("Pixel depth is %d bits\n", windowAttributes.depth);
|
||||
if (windowAttributes.depth != 24)
|
||||
{
|
||||
wld_fatal_error("Unsupported pixel depth: %d", windowAttributes.depth);
|
||||
}
|
||||
|
||||
x11_load_palette(w);
|
||||
x11_map_sharedmemory(w, windowAttributes.depth);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: x11_EndGraphics
|
||||
* Description:
|
||||
***************************************************************************/
|
||||
|
||||
void x11_EndGraphics(tcl_window_t *w)
|
||||
{
|
||||
x11_unmap_all_sharedmemory();
|
||||
XCloseDisplay(w->display);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user