really portable, and Visual Studio complains when they are not explicitely cast.tags/v0.99.beta14
@@ -43,7 +43,7 @@ | |||||
# define LOOKUP_HUE 16 | # define LOOKUP_HUE 16 | ||||
#endif | #endif | ||||
static unsigned char hsv_distances[LOOKUP_VAL][LOOKUP_SAT][LOOKUP_HUE]; | static unsigned char hsv_distances[LOOKUP_VAL][LOOKUP_SAT][LOOKUP_HUE]; | ||||
static enum cucul_color lookup_colors[8]; | |||||
static uint16_t lookup_colors[8]; | |||||
static int const hsv_palette[] = | static int const hsv_palette[] = | ||||
{ | { | ||||
@@ -771,7 +771,7 @@ void cucul_draw_bitmap(cucul_t *qq, int x1, int y1, int x2, int y2, | |||||
int fromx, fromy, tox, toy, myx, myy, dots, dist; | int fromx, fromy, tox, toy, myx, myy, dots, dist; | ||||
int error[3]; | int error[3]; | ||||
enum cucul_color outfg = 0, outbg = 0; | |||||
unsigned int outfg = 0, outbg = 0; | |||||
char const *outch; | char const *outch; | ||||
rgba[0] = rgba[1] = rgba[2] = rgba[3] = 0; | rgba[0] = rgba[1] = rgba[2] = rgba[3] = 0; | ||||
@@ -48,9 +48,9 @@ | |||||
* \param fgcolor The requested foreground colour. | * \param fgcolor The requested foreground colour. | ||||
* \param bgcolor The requested background colour. | * \param bgcolor The requested background colour. | ||||
*/ | */ | ||||
void cucul_set_color(cucul_t *qq, enum cucul_color fgcolor, | |||||
enum cucul_color bgcolor) | |||||
void cucul_set_color(cucul_t *qq, unsigned int fgcolor, unsigned int bgcolor) | |||||
{ | { | ||||
/* FIXME */ | |||||
if(fgcolor < 0 || fgcolor > 15 || bgcolor < 0 || bgcolor > 15) | if(fgcolor < 0 || fgcolor > 15 || bgcolor < 0 || bgcolor > 15) | ||||
return; | return; | ||||
@@ -176,8 +176,8 @@ void cucul_printf(cucul_t *qq, int x, int y, char const *format, ...) | |||||
*/ | */ | ||||
void cucul_clear(cucul_t *qq) | void cucul_clear(cucul_t *qq) | ||||
{ | { | ||||
enum cucul_color oldfg = qq->fgcolor; | |||||
enum cucul_color oldbg = qq->bgcolor; | |||||
uint16_t oldfg = qq->fgcolor; | |||||
uint16_t oldbg = qq->bgcolor; | |||||
int y = qq->height; | int y = qq->height; | ||||
cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | ||||
@@ -186,7 +186,8 @@ void cucul_clear(cucul_t *qq) | |||||
while(y--) | while(y--) | ||||
cucul_putstr(qq, 0, y, qq->empty_line); | cucul_putstr(qq, 0, y, qq->empty_line); | ||||
cucul_set_color(qq, oldfg, oldbg); | |||||
qq->fgcolor = oldfg; | |||||
qq->bgcolor = oldbg; | |||||
} | } | ||||
/** \brief Blit a canvas onto another one. | /** \brief Blit a canvas onto another one. | ||||
@@ -177,7 +177,7 @@ unsigned int cucul_get_height(cucul_t *qq) | |||||
* \param color The colour value. | * \param color The colour value. | ||||
* \return A static string containing the colour's name. | * \return A static string containing the colour's name. | ||||
*/ | */ | ||||
char const *cucul_get_color_name(enum cucul_color color) | |||||
char const *cucul_get_color_name(unsigned int color) | |||||
{ | { | ||||
static char const *color_names[] = | static char const *color_names[] = | ||||
{ | { | ||||
@@ -28,34 +28,32 @@ extern "C" | |||||
{ | { | ||||
#endif | #endif | ||||
/** \brief Colour definitions. | |||||
typedef struct cucul_context cucul_t; | |||||
/** \defgroup colour Colour definitions | |||||
* | * | ||||
* Colours that can be used with cucul_set_color(). | * Colours that can be used with cucul_set_color(). | ||||
*/ | |||||
enum cucul_color | |||||
{ | |||||
CUCUL_COLOR_BLACK = 0x0, /**< The colour index for black. */ | |||||
CUCUL_COLOR_BLUE = 0x1, /**< The colour index for blue. */ | |||||
CUCUL_COLOR_GREEN = 0x2, /**< The colour index for green. */ | |||||
CUCUL_COLOR_CYAN = 0x3, /**< The colour index for cyan. */ | |||||
CUCUL_COLOR_RED = 0x4, /**< The colour index for red. */ | |||||
CUCUL_COLOR_MAGENTA = 0x5, /**< The colour index for magenta. */ | |||||
CUCUL_COLOR_BROWN = 0x6, /**< The colour index for brown. */ | |||||
CUCUL_COLOR_LIGHTGRAY = 0x7, /**< The colour index for light gray. */ | |||||
CUCUL_COLOR_DARKGRAY = 0x8, /**< The colour index for dark gray. */ | |||||
CUCUL_COLOR_LIGHTBLUE = 0x9, /**< The colour index for blue. */ | |||||
CUCUL_COLOR_LIGHTGREEN = 0xa, /**< The colour index for light green. */ | |||||
CUCUL_COLOR_LIGHTCYAN = 0xb, /**< The colour index for light cyan. */ | |||||
CUCUL_COLOR_LIGHTRED = 0xc, /**< The colour index for light red. */ | |||||
CUCUL_COLOR_LIGHTMAGENTA = 0xd, /**< The colour index for light magenta. */ | |||||
CUCUL_COLOR_YELLOW = 0xe, /**< The colour index for yellow. */ | |||||
CUCUL_COLOR_WHITE = 0xf, /**< The colour index for white. */ | |||||
CUCUL_COLOR_TRANSPARENT = 0xfe, /**< The transparent colour. */ | |||||
CUCUL_COLOR_DEFAULT = 0xff, /**< The output driver's default colour. */ | |||||
}; | |||||
typedef struct cucul_context cucul_t; | |||||
* | |||||
* @{ */ | |||||
#define CUCUL_COLOR_BLACK 0x00 /**< The colour index for black. */ | |||||
#define CUCUL_COLOR_BLUE 0x01 /**< The colour index for blue. */ | |||||
#define CUCUL_COLOR_GREEN 0x02 /**< The colour index for green. */ | |||||
#define CUCUL_COLOR_CYAN 0x03 /**< The colour index for cyan. */ | |||||
#define CUCUL_COLOR_RED 0x04 /**< The colour index for red. */ | |||||
#define CUCUL_COLOR_MAGENTA 0x05 /**< The colour index for magenta. */ | |||||
#define CUCUL_COLOR_BROWN 0x06 /**< The colour index for brown. */ | |||||
#define CUCUL_COLOR_LIGHTGRAY 0x07 /**< The colour index for light gray. */ | |||||
#define CUCUL_COLOR_DARKGRAY 0x08 /**< The colour index for dark gray. */ | |||||
#define CUCUL_COLOR_LIGHTBLUE 0x09 /**< The colour index for blue. */ | |||||
#define CUCUL_COLOR_LIGHTGREEN 0x0a /**< The colour index for light green. */ | |||||
#define CUCUL_COLOR_LIGHTCYAN 0x0b /**< The colour index for light cyan. */ | |||||
#define CUCUL_COLOR_LIGHTRED 0x0c /**< The colour index for light red. */ | |||||
#define CUCUL_COLOR_LIGHTMAGENTA 0x0d /**< The colour index for light magenta. */ | |||||
#define CUCUL_COLOR_YELLOW 0x0e /**< The colour index for yellow. */ | |||||
#define CUCUL_COLOR_WHITE 0x0f /**< The colour index for white. */ | |||||
#define CUCUL_COLOR_DEFAULT 0x10 /**< The output driver's default colour. */ | |||||
#define CUCUL_COLOR_TRANSPARENT 0x20 /**< The transparent colour. */ | |||||
/* @} */ | |||||
/** \defgroup basic Basic functions | /** \defgroup basic Basic functions | ||||
* | * | ||||
@@ -77,8 +75,8 @@ void cucul_free(cucul_t *); | |||||
* higher level graphics functions. | * higher level graphics functions. | ||||
* | * | ||||
* @{ */ | * @{ */ | ||||
void cucul_set_color(cucul_t *, enum cucul_color, enum cucul_color); | |||||
char const *cucul_get_color_name(enum cucul_color); | |||||
void cucul_set_color(cucul_t *, unsigned int, unsigned int); | |||||
char const *cucul_get_color_name(unsigned int); | |||||
void cucul_putchar(cucul_t *, int, int, char); | void cucul_putchar(cucul_t *, int, int, char); | ||||
void cucul_putstr(cucul_t *, int, int, char const *); | void cucul_putstr(cucul_t *, int, int, char const *); | ||||
void cucul_printf(cucul_t *, int, int, char const *, ...); | void cucul_printf(cucul_t *, int, int, char const *, ...); | ||||
@@ -196,7 +194,6 @@ struct cucul_export | |||||
struct cucul_export * cucul_create_export(cucul_t *, char const *); | struct cucul_export * cucul_create_export(cucul_t *, char const *); | ||||
char const * const * cucul_get_export_list(void); | char const * const * cucul_get_export_list(void); | ||||
void cucul_free_export(struct cucul_export *); | void cucul_free_export(struct cucul_export *); | ||||
/* @} */ | /* @} */ | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
@@ -40,8 +40,8 @@ struct cucul_context | |||||
uint32_t *attr; | uint32_t *attr; | ||||
char *empty_line, *scratch_line; | char *empty_line, *scratch_line; | ||||
enum cucul_color fgcolor; | |||||
enum cucul_color bgcolor; | |||||
uint16_t fgcolor; | |||||
uint16_t bgcolor; | |||||
unsigned int refcount; | unsigned int refcount; | ||||
}; | }; | ||||
@@ -264,7 +264,7 @@ int cucul_get_sprite_dy(cucul_t *qq, struct cucul_sprite const *sprite, int f) | |||||
void cucul_draw_sprite(cucul_t *qq, int x, int y, struct cucul_sprite const *sprite, int f) | void cucul_draw_sprite(cucul_t *qq, int x, int y, struct cucul_sprite const *sprite, int f) | ||||
{ | { | ||||
int i, j; | int i, j; | ||||
enum cucul_color oldfg, oldbg; | |||||
unsigned int oldfg, oldbg; | |||||
struct cucul_frame *frame; | struct cucul_frame *frame; | ||||
if(sprite == NULL) | if(sprite == NULL) | ||||
@@ -20,7 +20,7 @@ | |||||
#define YRATIO 70*70 | #define YRATIO 70*70 | ||||
#define FUZZY 5000000 | #define FUZZY 5000000 | ||||
enum cucul_color points[] = | |||||
unsigned int points[] = | |||||
{ | { | ||||
CUCUL_COLOR_BLACK, | CUCUL_COLOR_BLACK, | ||||
CUCUL_COLOR_DARKGRAY, | CUCUL_COLOR_DARKGRAY, | ||||
@@ -24,7 +24,7 @@ static void unused_colors(void); | |||||
static int slang_assoc[16*16], palette[16*16]; | static int slang_assoc[16*16], palette[16*16]; | ||||
/* 6 colours in hue order */ | /* 6 colours in hue order */ | ||||
static enum cucul_color const hue_list[] = | |||||
static unsigned int const hue_list[] = | |||||
{ | { | ||||
CUCUL_COLOR_RED, | CUCUL_COLOR_RED, | ||||
CUCUL_COLOR_BROWN, | CUCUL_COLOR_BROWN, | ||||