wonx/WWColorMap.c
Hiroaki Sakai 5e1a9795b7 Create your own header file. It became compilable with only Wonx.
Since there is a possibility that the Error () function will collide with libwonx.a when linking,
It changed to Wonx_Error ().
Added bios_exit ().
sprite_set_char, sprite_get_char, palette number minus 8
Fixed bug that was not specified.
font_set_monodata (), font_set_colordata (), font_get_data (), disp.c,
The arguments of screen_set_char (), screen_get_char (), sprite_set_data ()
Changed from void * to appropriate type.
Sample program and attached SpeedMac.
I added a document.

Version 0.3 beta - from wonx-b03.tar.gz
2018-03-07 23:06:08 +00:00

91 lines
2.4 KiB
C

/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WWColorMapP.h"
#include "etc.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
WWColorMap WWColorMap_Create(int * lcd_colors)
{
WWColorMap color_map;
color_map = (WWColorMap)malloc(sizeof(_WWColorMap));
if (color_map == NULL)
Wonx_Error("WWColorMap_Create", "Cannot allocate memory");
WWColorMap_SetLCDColors(color_map, lcd_colors);
return (color_map);
}
WWColorMap WWColorMap_Destroy(WWColorMap color_map)
{
if (color_map == NULL) return (NULL);
free(color_map);
return (NULL);
}
int * WWColorMap_GetLCDColors(WWColorMap color_map, int * lcd_colors)
{
int i;
for (i = 0; i < 8; i++) {
lcd_colors[i] = WWColorMap_GetLCDColor(color_map, i);
}
return (lcd_colors);
}
int WWColorMap_SetLCDColors(WWColorMap color_map, int * lcd_colors)
{
int i;
for (i = 0; i < 8; i++) {
if (lcd_colors == NULL) {
WWColorMap_SetLCDColor(color_map, i, (i * 2) + ((i == 7) ? 1 : 0));
} else {
WWColorMap_SetLCDColor(color_map, i, lcd_colors[i]);
}
}
return (0);
}
int WWColorMap_GetLCDColor(WWColorMap color_map, int color)
{
return (color_map->lcd_color[color]);
}
int WWColorMap_SetLCDColor(WWColorMap color_map, int color, int lcd_color)
{
return (color_map->lcd_color[color] = lcd_color);
}
int WWColorMap_PrintData(WWColorMap c, FILE * f)
{
int i;
fprintf(f, "\n");
for (i = 0; i < 8; i++) {
fprintf(f, "colormap :\tcolor[%d] = %d\n",
i, WWColorMap_GetLCDColor(c, i));
}
fflush(f);
return (0);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/