Commit b1b79e3a authored by deuce's avatar deuce
Browse files

Add setpixel(x, y, colour) function.

parent 27b7ef13
......@@ -1164,3 +1164,14 @@ static int update_rect(int sx, int sy, int width, int height, int force)
return(0);
}
int bitmap_setpixel(uint32_t x, uint32_t y, uint32_t colour)
{
pthread_mutex_lock(&screenlock);
screen[PIXEL_OFFSET(x, y)]=colour;
pthread_mutex_unlock(&screenlock);
pthread_mutex_lock(&vstatlock);
send_rectangle(&vstat, x, y, 1, 1, 1);
pthread_mutex_unlock(&vstatlock);
return 1;
}
......@@ -32,5 +32,6 @@ void bitmap_setvideoflags(int flags);
void bitmap_setscaling(int new_value);
int bitmap_getscaling(void);
int bitmap_attr2palette(uint8_t attr, uint32_t *fgp, uint32_t *bgp);
int bitmap_setpixel(uint32_t x, uint32_t y, uint32_t colour);
#endif
......@@ -124,6 +124,7 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_setpalette(uint32_t entry, uint16_t r, uint16
CIOLIBEXPORT int CIOLIBCALL ciolib_cputch(uint32_t fg_palette, uint32_t bg_palette, int a);
CIOLIBEXPORT int CIOLIBCALL ciolib_ccputs(uint32_t fg_palette, uint32_t bg_palette, const char *str);
CIOLIBEXPORT int CIOLIBCALL ciolib_attr2palette(uint8_t attr, uint32_t *fg, uint32_t *bg);
CIOLIBEXPORT int CIOLIBCALL ciolib_setpixel(uint32_t x, uint32_t y, uint32_t colour);
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
int sdl_video_initialized = 0;
......@@ -172,6 +173,7 @@ int try_sdl_init(int mode)
cio_api.getscaling=sdl_getscaling;
cio_api.setpalette=sdl_setpalette;
cio_api.attr2palette=bitmap_attr2palette;
cio_api.setpixel=bitmap_setpixel;
return(1);
}
return(0);
......@@ -221,6 +223,7 @@ int try_x_init(int mode)
cio_api.getscaling=bitmap_getscaling;
cio_api.setpalette=x_setpalette;
cio_api.attr2palette=bitmap_attr2palette;
cio_api.setpixel=bitmap_setpixel;
return(1);
}
return(0);
......@@ -1741,3 +1744,12 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_attr2palette(uint8_t attr, uint32_t *fg, uint
*/
return -1;
}
CIOLIBEXPORT int CIOLIBCALL ciolib_setpixel(uint32_t x, uint32_t y, uint32_t colour)
{
CIOLIB_INIT();
if (cio_api.setpixel)
return cio_api.setpixel(x, y, colour);
return 0;
}
......
......@@ -318,6 +318,7 @@ typedef struct {
int *ESCDELAY;
int (*setpalette) (uint32_t entry, uint16_t r, uint16_t g, uint16_t b);
int (*attr2palette) (uint8_t attr, uint32_t *fg, uint32_t *bg);
int (*setpixel) (uint32_t x, uint32_t y, uint32_t colour);
} cioapi_t;
CIOLIBEXPORTVAR cioapi_t cio_api;
......@@ -392,6 +393,7 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_setscaling(int flags);
CIOLIBEXPORT int CIOLIBCALL ciolib_getscaling(void);
CIOLIBEXPORT int CIOLIBCALL ciolib_setpalette(uint32_t entry, uint16_t r, uint16_t g, uint16_t b);
CIOLIBEXPORT int CIOLIBCALL ciolib_attr2palette(uint8_t attr, uint32_t *fg, uint32_t *bg);
CIOLIBEXPORT int CIOLIBCALL ciolib_setpixel(uint32_t x, uint32_t y, uint32_t colour);
/* DoorWay specific stuff that's only applicable to ANSI mode. */
CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable);
......@@ -459,6 +461,7 @@ CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable);
#define getscaling() ciolib_getscaling()
#define setpalette(e,r,g,b) ciolib_setpalette(e,r,g,b)
#define attr2palette(a,b,c) ciolib_attr2palette(a,b,c)
#define setpixel(a,b,c) ciolib_setpixel(a,b,c)
#endif
#ifdef WITH_SDL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment