tcledit/libwld: Should not depend on configured trv_pixel_t or dev_pixel_t. Assume always uint8_t and uint32_t TrueColor.
This commit is contained in:
parent
635571db87
commit
c79f1deb2b
@ -47,6 +47,7 @@ extern "C"
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "wld_color.h"
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@ -83,7 +84,7 @@ struct wld_bitmap_s
|
|||||||
uint16_t w;
|
uint16_t w;
|
||||||
uint16_t h;
|
uint16_t h;
|
||||||
uint8_t log2h;
|
uint8_t log2h;
|
||||||
trv_pixel_t *bm;
|
wld_pixel_t *bm;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct wld_bitmap_s wld_bitmap_t;
|
typedef struct wld_bitmap_s wld_bitmap_t;
|
||||||
|
@ -40,13 +40,13 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "trv_graphics.h"
|
#include <stdint.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* This defines the size of the RGB cube that can be supported by trv_pixel_t
|
/* This defines the size of the RGB cube that can be supported by wld_pixel_t
|
||||||
* Use of the RGB cube gives us a fine control of the color space. However
|
* Use of the RGB cube gives us a fine control of the color space. However
|
||||||
* the lighting logic in this program requires fine control over luminance.
|
* the lighting logic in this program requires fine control over luminance.
|
||||||
* If the RGB_CUBE_SIZE is small, then an alternative luminance model is
|
* If the RGB_CUBE_SIZE is small, then an alternative luminance model is
|
||||||
@ -83,6 +83,8 @@
|
|||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
typedef uint8_t wld_pixel_t;
|
||||||
|
|
||||||
struct color_rgb_s
|
struct color_rgb_s
|
||||||
{
|
{
|
||||||
uint8_t red; /* red component of color 0-63 */
|
uint8_t red; /* red component of color 0-63 */
|
||||||
@ -177,8 +179,8 @@ void wld_rgblookup_allocate(void);
|
|||||||
void wld_rgblookup_endmapping(void);
|
void wld_rgblookup_endmapping(void);
|
||||||
void wld_rgblookup_free(void);
|
void wld_rgblookup_free(void);
|
||||||
|
|
||||||
trv_pixel_t wld_rgb2pixel(color_rgb_t *pixel);
|
wld_pixel_t wld_rgb2pixel(color_rgb_t *pixel);
|
||||||
void wld_pixel2lum(trv_pixel_t pixel_value, color_lum_t *lum);
|
void wld_pixel2lum(wld_pixel_t pixel_value, color_lum_t *lum);
|
||||||
trv_pixel_t wld_lum2pixel(color_lum_t *lum);
|
wld_pixel_t wld_lum2pixel(color_lum_t *lum);
|
||||||
|
|
||||||
#endif /* __APPS_GRAPHICS_TRAVELER_TOOLS_LIBWLD_WLD_COLOR_H */
|
#endif /* __APPS_GRAPHICS_TRAVELER_TOOLS_LIBWLD_WLD_COLOR_H */
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "trv_types.h"
|
#include "trv_types.h"
|
||||||
|
#include "wld_color.h"
|
||||||
#include "wld_world.h"
|
#include "wld_world.h"
|
||||||
#include "wld_bitmaps.h"
|
#include "wld_bitmaps.h"
|
||||||
#include "wld_paltable.h"
|
#include "wld_paltable.h"
|
||||||
|
@ -89,7 +89,7 @@ typedef struct
|
|||||||
* with distance
|
* with distance
|
||||||
*/
|
*/
|
||||||
|
|
||||||
trv_pixel_t *g_pal_table[NUM_ZONES];
|
wld_pixel_t *g_pal_table[NUM_ZONES];
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@ -107,7 +107,7 @@ static void wld_allocate_paltable(uint32_t palTabEntrySize)
|
|||||||
for (i = 0; i < NUM_ZONES; i++)
|
for (i = 0; i < NUM_ZONES; i++)
|
||||||
{
|
{
|
||||||
g_pal_table[i] =
|
g_pal_table[i] =
|
||||||
(trv_pixel_t *) wld_malloc(palTabEntrySize * sizeof(trv_pixel_t));
|
(wld_pixel_t *) wld_malloc(palTabEntrySize * sizeof(wld_pixel_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ static void wld_allocate_paltable(uint32_t palTabEntrySize)
|
|||||||
uint8_t wld_load_paltable(char *file)
|
uint8_t wld_load_paltable(char *file)
|
||||||
{
|
{
|
||||||
#if (!MSWINDOWS)
|
#if (!MSWINDOWS)
|
||||||
trv_pixel_t *palptr;
|
wld_pixel_t *palptr;
|
||||||
color_lum_t lum;
|
color_lum_t lum;
|
||||||
int16_t zone;
|
int16_t zone;
|
||||||
float scale;
|
float scale;
|
||||||
@ -182,8 +182,8 @@ uint8_t wld_load_paltable(char *file)
|
|||||||
int16_t nranges;
|
int16_t nranges;
|
||||||
int16_t zone;
|
int16_t zone;
|
||||||
int16_t palndx;
|
int16_t palndx;
|
||||||
trv_pixel_t plotcolor;
|
wld_pixel_t plotcolor;
|
||||||
trv_pixel_t *palptr;
|
wld_pixel_t *palptr;
|
||||||
pal_range_t ranges[MAX_PAL_RANGES];
|
pal_range_t ranges[MAX_PAL_RANGES];
|
||||||
|
|
||||||
/* Open the file which contains the palette table */
|
/* Open the file which contains the palette table */
|
||||||
|
@ -214,7 +214,7 @@ uint8_t wld_loadpcx(char *filename, pcxPicturePtr image)
|
|||||||
graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
|
graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
|
||||||
{
|
{
|
||||||
pcx_header_t header;
|
pcx_header_t header;
|
||||||
trv_pixel_t *buffer;
|
wld_pixel_t *buffer;
|
||||||
graphic_file_t *gFile;
|
graphic_file_t *gFile;
|
||||||
color_rgb_t *palette;
|
color_rgb_t *palette;
|
||||||
uint16_t imageWidth, imageHeight;
|
uint16_t imageWidth, imageHeight;
|
||||||
@ -228,8 +228,8 @@ graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
|
|||||||
|
|
||||||
imageWidth = header.width - header.x + 1;
|
imageWidth = header.width - header.x + 1;
|
||||||
imageHeight = header.height - header.y + 1;
|
imageHeight = header.height - header.y + 1;
|
||||||
imageSize = imageHeight * imageWidth * sizeof(trv_pixel_t);
|
imageSize = imageHeight * imageWidth * sizeof(wld_pixel_t);
|
||||||
buffer = (trv_pixel_t *) wld_malloc(imageSize + 1);
|
buffer = (wld_pixel_t *) wld_malloc(imageSize + 1);
|
||||||
|
|
||||||
/* Load the PCX data into the buffer */
|
/* Load the PCX data into the buffer */
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ static enum unit_vector_index_e wld_lum2colorform(color_lum_t * lum)
|
|||||||
* Description: Convert an RGB-Luminance value into a pixel
|
* Description: Convert an RGB-Luminance value into a pixel
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
trv_pixel_t wld_color_lum2pixel(color_lum_t * lum)
|
wld_pixel_t wld_color_lum2pixel(color_lum_t * lum)
|
||||||
{
|
{
|
||||||
#if RGB_CUBE_SIZE < MIN_LUM_LEVELS
|
#if RGB_CUBE_SIZE < MIN_LUM_LEVELS
|
||||||
enum unit_vector_index_e uvndx;
|
enum unit_vector_index_e uvndx;
|
||||||
|
@ -46,7 +46,7 @@ extern "C"
|
|||||||
* Included Files
|
* Included Files
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "trv_types.h" /* For trv_pixel_t */
|
#include "wld_color.h"
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@ -91,7 +91,7 @@ enum
|
|||||||
* with distance
|
* with distance
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern trv_pixel_t *g_pal_table[NUM_ZONES];
|
extern wld_pixel_t *g_pal_table[NUM_ZONES];
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Pulblic Function Prototypes
|
* Pulblic Function Prototypes
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
* Description: Convert a pixel value into RGB-Luminance value.
|
* Description: Convert a pixel value into RGB-Luminance value.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
void wld_pixel2lum(trv_pixel_t pixel_value, color_lum_t * lum)
|
void wld_pixel2lum(wld_pixel_t pixel_value, color_lum_t * lum)
|
||||||
{
|
{
|
||||||
color_rgb_t *rgb = &g_rgb_lut[pixel_value];
|
color_rgb_t *rgb = &g_rgb_lut[pixel_value];
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ static wld_bitmap_t *wld_new_texture(uint16_t width, uint16_t height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
t = (wld_bitmap_t *) wld_malloc(sizeof(wld_bitmap_t));
|
t = (wld_bitmap_t *) wld_malloc(sizeof(wld_bitmap_t));
|
||||||
t->bm = (trv_pixel_t *) wld_malloc(height * width * sizeof(trv_pixel_t));
|
t->bm = (wld_pixel_t *) wld_malloc(height * width * sizeof(wld_pixel_t));
|
||||||
|
|
||||||
t->w = width;
|
t->w = width;
|
||||||
t->h = height;
|
t->h = height;
|
||||||
@ -129,7 +129,7 @@ static wld_bitmap_t *wld_new_texture(uint16_t width, uint16_t height)
|
|||||||
static void wld_quantize_texture(graphic_file_t * gFile, wld_bitmap_t * t)
|
static void wld_quantize_texture(graphic_file_t * gFile, wld_bitmap_t * t)
|
||||||
{
|
{
|
||||||
color_rgb_t pixel;
|
color_rgb_t pixel;
|
||||||
trv_pixel_t *dest = t->bm;
|
wld_pixel_t *dest = t->bm;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
* TRV_PIXEL_MAX.
|
* TRV_PIXEL_MAX.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
trv_pixel_t wld_rgb2pixel(color_rgb_t * pixel)
|
wld_pixel_t wld_rgb2pixel(color_rgb_t * pixel)
|
||||||
{
|
{
|
||||||
#if RGB_CUBE_SIZE < MIN_LUM_LEVELS
|
#if RGB_CUBE_SIZE < MIN_LUM_LEVELS
|
||||||
color_lum_t lum;
|
color_lum_t lum;
|
||||||
@ -76,7 +76,7 @@ trv_pixel_t wld_rgb2pixel(color_rgb_t * pixel)
|
|||||||
|
|
||||||
return wld_lum2pixel(&lum);
|
return wld_lum2pixel(&lum);
|
||||||
#else
|
#else
|
||||||
trv_pixel_t ret;
|
wld_pixel_t ret;
|
||||||
int red;
|
int red;
|
||||||
int green;
|
int green;
|
||||||
int blue;
|
int blue;
|
||||||
|
@ -241,7 +241,7 @@ void wld_rgblookup_allocate(void)
|
|||||||
= g_rgb_lut[index].green = g_rgb_lut[index].blue = 0;
|
= g_rgb_lut[index].green = g_rgb_lut[index].blue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the cube to trv_pixel_t scale factor. This factor will convert
|
/* Calculate the cube to wld_pixel_t scale factor. This factor will convert
|
||||||
* an RGB component in the range {0..RGB_CUBE_SIZE-1} to a value in the range
|
* an RGB component in the range {0..RGB_CUBE_SIZE-1} to a value in the range
|
||||||
* {0..WLD_PIXEL_MAX}. */
|
* {0..WLD_PIXEL_MAX}. */
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "trv_types.h"
|
#include "trv_types.h"
|
||||||
#include "trv_graphics.h"
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "wld_mem.h"
|
#include "wld_mem.h"
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include "wld_color.h"
|
#include "wld_color.h"
|
||||||
#include "trv_graphics.h"
|
|
||||||
#include "wld_bitmaps.h"
|
#include "wld_bitmaps.h"
|
||||||
#include "wld_plane.h"
|
#include "wld_plane.h"
|
||||||
|
|
||||||
@ -115,6 +114,10 @@
|
|||||||
* Public Type Definitions
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Assume 32-bit TrueColor */
|
||||||
|
|
||||||
|
typedef uint32_t dev_pixel_t;
|
||||||
|
|
||||||
enum edit_mode_e
|
enum edit_mode_e
|
||||||
{
|
{
|
||||||
EDITMODE_NONE = 0, /* Initial mode has not been selected */
|
EDITMODE_NONE = 0, /* Initial mode has not been selected */
|
||||||
|
Loading…
Reference in New Issue
Block a user